Browse Source

全公司每个人每天工时 内部办公接口

wuweihao 5 months ago
parent
commit
a0715edbb3

+ 5 - 2
gis_application/src/main/resources/application-dev.properties

@@ -4,11 +4,14 @@ spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 
 
-spring.datasource.druid.url=jdbc:mysql://221.4.210.172:22264/zentao?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+#spring.datasource.druid.url=jdbc:mysql://221.4.210.172:22264/zentao?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+#spring.datasource.druid.username=root
+#spring.datasource.druid.password=4DAGE168
+
+spring.datasource.druid.url=jdbc:mysql://192.168.0.21:3306/zentao?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
 spring.datasource.druid.username=root
 spring.datasource.druid.password=4DAGE168
 
-
 # \u521D\u59CB\u8FDE\u63A5\u6570
 spring.datasource.druid.initial-size=5
 # \u6700\u5C0F\u8FDE\u63A5\u6C60\u6570\u91CF

+ 1 - 0
gis_application/src/main/resources/application.properties

@@ -1,5 +1,6 @@
 server.port=8085
 
+#spring.profiles.active=lorPro
 spring.profiles.active=dev
 
 # \u9879\u76EE\u540D\u79F0

+ 60 - 1
gis_common/src/main/java/com/gis/common/exception/BaseRuntimeException.java

@@ -1,5 +1,10 @@
 package com.gis.common.exception;
 
+import cn.hutool.core.util.StrUtil;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+
 public class BaseRuntimeException extends RuntimeException{
 
     private static final long serialVersionUID = -1518945670203783450L;
@@ -8,15 +13,22 @@ public class BaseRuntimeException extends RuntimeException{
 
     public BaseRuntimeException(String msg){
         super(msg);
+        this.code = -1;
         this.msg = msg;
     }
 
+    /**
+     *
+     * @param code 允许为null
+     * @param msg
+     */
     public BaseRuntimeException(Integer code, String msg){
         super(msg);
-        this.code = code;
+        this.code = code == null? -1 : code;
         this.msg = msg;
     }
 
+
     public Integer getCode() {
         return code;
     }
@@ -32,4 +44,51 @@ public class BaseRuntimeException extends RuntimeException{
     public void setMsg(String msg) {
         this.msg = msg;
     }
+
+
+    public static void isNull(Object obj, Integer code, String msg){
+        if (obj == null){
+            getExc(code, msg);
+        }
+    }
+
+    public static void isBlank(Object obj, Integer code, String msg){
+        if (obj == null){
+            getExc(code, msg);
+        }
+
+        if (obj instanceof String && StrUtil.isBlank(obj.toString())){
+            getExc(code, msg);
+        }
+
+    }
+
+
+
+
+
+    /**
+     *
+     * @param obj 存在抛异常
+     * @param code 允许为null
+     * @param msg
+     */
+    public static void isTrue(boolean obj, Integer code, String msg){
+        if (obj){
+            getExc(code, msg);
+        }
+    }
+
+    public static void  getExc(Integer code, String msg){
+        throw new BaseRuntimeException(code, msg);
+    }
+
+
+
+    public static void isEmpty(List obj, Integer code, String msg){
+        if (CollectionUtils.isEmpty(obj)){
+            getExc(code, msg);
+        }
+    }
+
 }

+ 1 - 1
gis_common/src/main/java/com/gis/common/util/ExcelUtils.java

@@ -23,7 +23,7 @@ public class ExcelUtils {
      */
     public static void createExcel(List rows, String savePath, Map<String, String> rowTitle) {
         log.info("rows size: {}", rows.size());
-//        log.info("savePath: {}", savePath);
+        log.info("savePath: {}", savePath);
         ExcelWriter writer = ExcelUtil.getWriter(savePath);
 
         // 特殊列宽

+ 27 - 0
gis_domain/src/main/java/com/gis/domain/dto/DateDto2.java

@@ -0,0 +1,27 @@
+package com.gis.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * Created by owen on 2025/3/7 0027 9:15
+ *
+ */
+@Data
+public class DateDto2 {
+
+    /**
+     * 开始时间
+     * 需要用字符串接收
+     */
+    @ApiModelProperty(value = "开始时间", name = "startTime")
+    private String startTime;
+
+
+    @ApiModelProperty(value = "结束时间", name = "endTime")
+    private String endTime;
+
+
+}

+ 34 - 0
gis_domain/src/main/java/com/gis/domain/vo/TaskestimateVo.java

@@ -0,0 +1,34 @@
+package com.gis.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Created by owen on 2025/3/8 0026 12:13
+ * 工时表
+ */
+@Data
+public class TaskestimateVo implements Serializable {
+
+
+    private static final long serialVersionUID = 6265805965200890355L;
+    @ApiModelProperty(value = "账号")
+    private String account;
+
+    @ApiModelProperty(value = "消耗时间, 单位是小时")
+    private String consumed;
+
+    @ApiModelProperty(value = "日期")
+    private Date date;
+
+
+
+
+
+
+
+
+}

+ 4 - 0
gis_mapper/src/main/java/com/gis/mapper/TaskesTimateMapper.java

@@ -10,6 +10,7 @@ import com.gis.domain.entity.TaskesTimateEntity;
 import com.gis.domain.vo.FinanceMonthVo;
 import com.gis.domain.vo.MonthVo;
 import com.gis.domain.vo.DetailVo;
+import com.gis.domain.vo.TaskestimateVo;
 import com.gis.mapper.provider.TaskesTimateProvider;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
@@ -86,4 +87,7 @@ public interface TaskesTimateMapper extends ZtBaseMapper<TaskesTimateEntity, Lon
 
     @SelectProvider(type = BaseProvider.class, method = "selectSql")
     List<DetailVo> excelByYearDetail(String sql);
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    List<TaskestimateVo> getList(String sqlStr);
 }

+ 60 - 29
gis_service/src/main/java/com/gis/service/impl/TaskesTimateServiceImpl.java

@@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
 
 import java.time.LocalDate;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
@@ -46,8 +47,44 @@ public class TaskesTimateServiceImpl extends ZtBaseServiceImpl<TaskesTimateEntit
 
     // 部门id分类
     private static HashMap<String, Object> deptMap = new HashMap<>();
+    // 禅道数据库zt_dept拿的数据
+
+    /**
+     * 1	WEB开发部
+     * 2	技术研发部
+     * 24	行政部
+     * 4	平面美术部
+     * 5	三维美术部
+     * 6	品牌策划部
+     * 7	图像算法部
+     * 8	硬件部
+     * 9	市场部
+     * 23	对外合作部
+     * 11	测试部
+     * 12	三维创意部
+     * 13	应用程序部
+     * 14	知识产权部
+     * 15	财务部
+     * 16	总经理办公室
+     * 17	芜湖市场部
+     * 18	芜湖项目策划部
+     * 19	芜湖技术部
+     * 20	人力资源部
+     * 21	供应链管理部
+     * 22	产品部
+     * 25	芜湖人事行政部
+     * 26	数据计算部
+     * 27	项目策划部
+     * 28	智慧城市事业部
+     * 29	项目管理部
+     * 30	数字营销事业部
+     * 31	生产部
+     * 32	海外事业部
+     * 33	政企事业部
+     */
     static {
-        deptMap.put("age", "");
+        deptMap.put("age", "1,11");
+//        deptMap.put("age", "1,2,4,5,6,7,8,44,12,13,22,29");
         deptMap.put("wufu", "17,18,19,25");
     }
 
@@ -58,34 +95,7 @@ public class TaskesTimateServiceImpl extends ZtBaseServiceImpl<TaskesTimateEntit
         return Result.success(new PageInfo<>(this.findAll()));
     }
 
-//    @Override
-//    public Result<FinanceMonthVo> allProjectEffortByMonthExcel(String date) {
-//
-//        long start = System.currentTimeMillis();
-//        List<FinanceMonthVo> effortVos = entityMapper.allProjectEffortByMonth(date);
-//        long end = System.currentTimeMillis();
-//        log.info("sql耗时: {}s", (end-start)/1000);
-//        String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmss");
-//        String savePath = configConstant.serverBasePath + time + ".xlsx";
-//        HashMap<String, String> rowTitle = new HashMap<>();
-//
-//        rowTitle.put("slack", "工号");
-////        rowTitle.put("project", "项目id");
-//        rowTitle.put("code", "项目号");
-//        rowTitle.put("projectName", "项目名称");
-//        rowTitle.put("account", "账号");
-//        rowTitle.put("realname", "姓名");
-//        rowTitle.put("consumed", "消耗时间(天)");
-//        ExcelUtils.createExcel(effortVos, savePath, rowTitle);
-//
-//        String domain = configConstant.serverDomain + time + ".xlsx";
-//        log.info("url: {}", domain);
-//
-//        HashMap<String, Object> result = new HashMap<>();
-//        result.put("size", effortVos.size());
-//        result.put("domain", domain);
-//        return Result.success(domain);
-//    }
+
 
     @Override
     public Result<FinanceMonthVo> allProjectEffortByMonthExcel(String date) {
@@ -293,9 +303,30 @@ public class TaskesTimateServiceImpl extends ZtBaseServiceImpl<TaskesTimateEntit
         builder.append(" order by a.account asc");
 
         List<DetailVo> effortVos = entityMapper.excelByYearDetail(builder.toString());
+
+//        groupByProject(effortVos);
+
+
         return Result.success(createExcel(effortVos));
     }
 
+//    private void groupByProject(List<DetailVo> vos){
+//        HashMap<String, Double> map = new HashMap<>();
+//        for (DetailVo vo : vos) {
+//            String key = vo.getProjectName();
+//            String consumed = vo.getConsumed();
+//            Double val = Double.valueOf(consumed);
+//            Double o = map.get(key);
+//            if (o != null){
+//                val = o + val;
+//            }
+//            map.put(key, val);
+//
+//
+//        }
+//
+//    }
+
 
     private  HashMap<String, Object> createExcel(List rows){
 

+ 1 - 0
gis_web/src/main/java/com/gis/web/controller/FinanceController.java

@@ -53,6 +53,7 @@ public class FinanceController extends BaseController {
 
     /***
      * by owen 2022-07-26
+     * http://face3d.4dage.com:8086/api/finance/excelByYearDetail/2023
      * @param
      * @return
      */

+ 65 - 0
gis_web/src/main/java/com/gis/web/controller/OpenApiController.java

@@ -0,0 +1,65 @@
+package com.gis.web.controller;
+
+import com.gis.common.exception.BaseRuntimeException;
+import com.gis.common.util.Result;
+import com.gis.domain.dto.*;
+import com.gis.domain.entity.TaskEntity;
+import com.gis.domain.vo.DetailVo;
+import com.gis.domain.vo.TaskestimateVo;
+import com.gis.mapper.TaskMapper;
+import com.gis.mapper.TaskesTimateMapper;
+import com.gis.service.IBaseService;
+import com.gis.service.TaskService;
+import com.gis.service.TaskesTimateService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.List;
+
+
+/**
+ * Created by owen on 2025/3/8 0026 11:57
+ *
+ */
+@Api(tags = "对外开放接口")
+@Slf4j
+@RequestMapping("api/openApi")
+@RestController
+public class OpenApiController extends BaseController {
+
+
+    @Autowired
+    TaskesTimateService taskesTimateService;
+
+    @Autowired
+    TaskesTimateMapper taskesTimateMapper;
+
+
+
+    @ApiOperation(value = "全公司每个人每天工时")
+    @PostMapping(value = "getAllTaskestimate")
+    public Result<TaskestimateVo> getAllTaskestimate(@RequestBody DateDto2 param) {
+        StringBuilder builder = new StringBuilder();
+        builder.append("select account, date, consumed from zt_taskestimate where ");
+        String startTime = param.getStartTime();
+        String endTime = param.getEndTime();
+        BaseRuntimeException.isBlank(startTime, null, "开始时间不能为空");
+        BaseRuntimeException.isBlank(endTime, null, "结束时间不能为空");
+        builder.append(" date between '").append(startTime).append("' and '").append(endTime).append("'");
+        builder.append(" GROUP BY account,date");
+        List<TaskestimateVo> res = taskesTimateMapper.getList(builder.toString());
+
+
+        return Result.success(res);
+    }
+
+
+
+
+
+}

File diff suppressed because it is too large
+ 7 - 1
remark.md