浏览代码

add. 工时统计

caozixuan 9 月之前
父节点
当前提交
940578da05
共有 33 个文件被更改,包括 2097 次插入248 次删除
  1. 66 1
      sop-api/src/main/java/com/qmth/sop/server/api/TBDingStatisticController.java
  2. 1 1
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/DingStatisticByCrmDto.java
  3. 1 1
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/DingStatisticBySupplierDto.java
  4. 156 0
      sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticByCrm.java
  5. 157 0
      sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticByCustom.java
  6. 134 0
      sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticByPerson.java
  7. 156 0
      sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticBySop.java
  8. 135 0
      sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticBySupplier.java
  9. 27 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticByCrmMapper.java
  10. 26 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticByCustomMapper.java
  11. 28 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticByPersonMapper.java
  12. 27 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticBySopMapper.java
  13. 26 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticBySupplierMapper.java
  14. 45 0
      sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticByCrmService.java
  15. 45 0
      sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticByCustomService.java
  16. 43 0
      sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticByPersonService.java
  17. 45 0
      sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticBySopService.java
  18. 45 0
      sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticBySupplierService.java
  19. 12 28
      sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticService.java
  20. 118 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticByCrmServiceImpl.java
  21. 116 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticByCustomServiceImpl.java
  22. 56 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticByPersonServiceImpl.java
  23. 102 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticBySopServiceImpl.java
  24. 93 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticBySupplierServiceImpl.java
  25. 69 217
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticServiceImpl.java
  26. 103 0
      sop-business/src/main/resources/db/log/caozixuan_update_log.sql
  27. 50 0
      sop-business/src/main/resources/mapper/TBDingStatisticByCrmMapper.xml
  28. 50 0
      sop-business/src/main/resources/mapper/TBDingStatisticByCustomMapper.xml
  29. 48 0
      sop-business/src/main/resources/mapper/TBDingStatisticByPersonMapper.xml
  30. 50 0
      sop-business/src/main/resources/mapper/TBDingStatisticBySopMapper.xml
  31. 46 0
      sop-business/src/main/resources/mapper/TBDingStatisticBySupplierMapper.xml
  32. 20 0
      sop-common/src/main/java/com/qmth/sop/common/enums/DingStatisticTypeEnum.java
  33. 1 0
      sop-task/src/main/java/com/qmth/sop/task/job/service/impl/JobServiceImpl.java

+ 66 - 1
sop-api/src/main/java/com/qmth/sop/server/api/TBDingStatisticController.java

@@ -1,11 +1,25 @@
 package com.qmth.sop.server.api;
 
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.bean.result.DingSubmitResult;
+import com.qmth.sop.business.service.*;
+import com.qmth.sop.common.annotation.OperationLog;
 import com.qmth.sop.common.contant.SystemConstant;
-import io.swagger.annotations.Api;
+import com.qmth.sop.common.enums.DingStatisticTypeEnum;
+import com.qmth.sop.common.enums.LogTypeEnum;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.io.IOException;
+
 /**
  * @Description: 考勤统计Controller
  * @Author: CaoZixuan
@@ -16,4 +30,55 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_DING_STATISTIC)
 public class TBDingStatisticController {
 
+    @Resource
+    private TBDingStatisticService tbDingStatisticService;
+
+    @Resource
+    private TBDingStatisticByPersonService tbdingStatisticByPersonService;
+
+    @Resource
+    private TBDingStatisticByCrmService tbdingStatisticByCrmService;
+
+    @Resource
+    private TBDingStatisticBySopService tbdingStatisticBySopService;
+
+    @Resource
+    private TBDingStatisticByCustomService tbdingStatisticByCustomService;
+
+    @Resource
+    private TBDingStatisticBySupplierService tbdingStatisticBySupplierService;
+
+    @ApiOperation(value = "工时统计-分页查询")
+    @RequestMapping(value = "/page", method = RequestMethod.POST)
+    @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = DingSubmitResult.class) })
+    public Result findDingSubmitPage(@ApiParam(value = "服务单元id", required = true) @RequestParam Long serviceId,
+            @ApiParam(value = "统计维度", required = true) @RequestParam DingStatisticTypeEnum type,
+            @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+            @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        switch (type) {
+        case BY_PERSON:
+            return ResultUtil.ok(
+                    tbdingStatisticByPersonService.findStatisticByPersonPage(serviceId, pageNumber, pageSize));
+        case BY_CRM:
+            return ResultUtil.ok(tbdingStatisticByCrmService.findStatisticByCrmPage(serviceId, pageNumber, pageSize));
+        case BY_SOP:
+            return ResultUtil.ok(tbdingStatisticBySopService.findStatisticBySopPage(serviceId, pageNumber, pageSize));
+        case BY_CUSTOM:
+            return ResultUtil.ok(
+                    tbdingStatisticByCustomService.findStatisticByCustomPage(serviceId, pageNumber, pageSize));
+        case BY_SUPPLIER:
+            return ResultUtil.ok(tbdingStatisticBySupplierService.findStatisticBySupplierPage(serviceId, pageNumber, pageSize));
+        }
+        return ResultUtil.ok();
+    }
+
+    @ApiOperation(value = "工时统计-批量导出")
+    @RequestMapping(value = "/export", method = RequestMethod.POST)
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
+    @OperationLog(logType = LogTypeEnum.EXPORT)
+    public Result exportDingSubmit(@ApiParam(value = "服务单元id", required = true) @RequestParam Long serviceId,
+            @ApiParam(value = "统计维度", required = true) @RequestParam DingStatisticTypeEnum type) throws IOException {
+        tbDingStatisticService.exportStatisticData(serviceId, type);
+        return ResultUtil.ok();
+    }
 }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/bean/dto/DingStatisticByCrmDto.java

@@ -7,7 +7,7 @@ import com.alibaba.excel.annotation.write.style.HeadStyle;
 import io.swagger.annotations.ApiModelProperty;
 
 /**
- * @Description: 工时统计-按人员统计
+ * @Description: 工时统计-按派单统计
  * @Author: CaoZixuan
  * @Date: 2024-09-06
  */

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/bean/dto/DingStatisticBySupplierDto.java

@@ -7,7 +7,7 @@ import com.alibaba.excel.annotation.write.style.HeadStyle;
 import io.swagger.annotations.ApiModelProperty;
 
 /**
- * @Description: 工时统计-按人员统计
+ * @Description: 工时统计-按供应商统计
  * @Author: CaoZixuan
  * @Date: 2024-09-06
  */

+ 156 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticByCrm.java

@@ -0,0 +1,156 @@
+package com.qmth.sop.business.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 工时统计-按派单统计
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@ApiModel(value="TBDingStatisticByCrm对象", description="工时统计-按派单统计")
+public class TBDingStatisticByCrm extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "服务单元id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long serviceId;
+
+    @ApiModelProperty(value = "服务单元名称")
+    private String serviceName;
+
+    @ApiModelProperty(value = "派单号")
+    private String crmNo;
+
+    @ApiModelProperty(value = "派单名称")
+    private String crmName;
+
+    @ApiModelProperty(value = "实际出勤(天)")
+    private Integer actualDays;
+
+    @ApiModelProperty(value = "工作日(天)")
+    private Integer weekdays;
+
+    @ApiModelProperty(value = "周末(天)")
+    private Integer weekends;
+
+    @ApiModelProperty(value = "法定节假日(天)")
+    private Integer legalHolidays;
+
+    @ApiModelProperty(value = "扫描周期(天)")
+    private Integer scanPeriod;
+
+    @ApiModelProperty(value = "阅卷周期(天)")
+    private Integer markPaperPeriod;
+
+    @ApiModelProperty(value = "累计工时(小时)")
+    private BigDecimal workHours;
+
+    @ApiModelProperty(value = "违规工时(天)")
+    private Integer violationDays;
+
+    public Long getServiceId() {
+        return serviceId;
+    }
+
+    public void setServiceId(Long serviceId) {
+        this.serviceId = serviceId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public String getCrmNo() {
+        return crmNo;
+    }
+
+    public void setCrmNo(String crmNo) {
+        this.crmNo = crmNo;
+    }
+
+    public String getCrmName() {
+        return crmName;
+    }
+
+    public void setCrmName(String crmName) {
+        this.crmName = crmName;
+    }
+
+    public Integer getActualDays() {
+        return actualDays;
+    }
+
+    public void setActualDays(Integer actualDays) {
+        this.actualDays = actualDays;
+    }
+
+    public Integer getWeekdays() {
+        return weekdays;
+    }
+
+    public void setWeekdays(Integer weekdays) {
+        this.weekdays = weekdays;
+    }
+
+    public Integer getWeekends() {
+        return weekends;
+    }
+
+    public void setWeekends(Integer weekends) {
+        this.weekends = weekends;
+    }
+
+    public Integer getLegalHolidays() {
+        return legalHolidays;
+    }
+
+    public void setLegalHolidays(Integer legalHolidays) {
+        this.legalHolidays = legalHolidays;
+    }
+
+    public Integer getScanPeriod() {
+        return scanPeriod;
+    }
+
+    public void setScanPeriod(Integer scanPeriod) {
+        this.scanPeriod = scanPeriod;
+    }
+
+    public Integer getMarkPaperPeriod() {
+        return markPaperPeriod;
+    }
+
+    public void setMarkPaperPeriod(Integer markPaperPeriod) {
+        this.markPaperPeriod = markPaperPeriod;
+    }
+
+    public BigDecimal getWorkHours() {
+        return workHours;
+    }
+
+    public void setWorkHours(BigDecimal workHours) {
+        this.workHours = workHours;
+    }
+
+    public Integer getViolationDays() {
+        return violationDays;
+    }
+
+    public void setViolationDays(Integer violationDays) {
+        this.violationDays = violationDays;
+    }
+}

+ 157 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticByCustom.java

@@ -0,0 +1,157 @@
+package com.qmth.sop.business.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 工时统计-按客户统计
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@ApiModel(value="TBDingStatisticByCustom对象", description="工时统计-按客户统计")
+public class TBDingStatisticByCustom extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "服务单元id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long serviceId;
+
+    @ApiModelProperty(value = "服务单元名称")
+    private String serviceName;
+
+    @ApiModelProperty(value = "客户id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long customId;
+
+    @ApiModelProperty(value = "客户名称")
+    private String customName;
+
+    @ApiModelProperty(value = "实际出勤(天)")
+    private Integer actualDays;
+
+    @ApiModelProperty(value = "工作日(天)")
+    private Integer weekdays;
+
+    @ApiModelProperty(value = "周末(天)")
+    private Integer weekends;
+
+    @ApiModelProperty(value = "法定节假日(天)")
+    private Integer legalHolidays;
+
+    @ApiModelProperty(value = "扫描周期(天)")
+    private Integer scanPeriod;
+
+    @ApiModelProperty(value = "阅卷周期(天)")
+    private Integer markPaperPeriod;
+
+    @ApiModelProperty(value = "累计工时(小时)")
+    private BigDecimal workHours;
+
+    @ApiModelProperty(value = "违规工时(天)")
+    private Integer violationDays;
+
+    public Long getServiceId() {
+        return serviceId;
+    }
+
+    public void setServiceId(Long serviceId) {
+        this.serviceId = serviceId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public Long getCustomId() {
+        return customId;
+    }
+
+    public void setCustomId(Long customId) {
+        this.customId = customId;
+    }
+
+    public String getCustomName() {
+        return customName;
+    }
+
+    public void setCustomName(String customName) {
+        this.customName = customName;
+    }
+
+    public Integer getActualDays() {
+        return actualDays;
+    }
+
+    public void setActualDays(Integer actualDays) {
+        this.actualDays = actualDays;
+    }
+
+    public Integer getWeekdays() {
+        return weekdays;
+    }
+
+    public void setWeekdays(Integer weekdays) {
+        this.weekdays = weekdays;
+    }
+
+    public Integer getWeekends() {
+        return weekends;
+    }
+
+    public void setWeekends(Integer weekends) {
+        this.weekends = weekends;
+    }
+
+    public Integer getLegalHolidays() {
+        return legalHolidays;
+    }
+
+    public void setLegalHolidays(Integer legalHolidays) {
+        this.legalHolidays = legalHolidays;
+    }
+
+    public Integer getScanPeriod() {
+        return scanPeriod;
+    }
+
+    public void setScanPeriod(Integer scanPeriod) {
+        this.scanPeriod = scanPeriod;
+    }
+
+    public Integer getMarkPaperPeriod() {
+        return markPaperPeriod;
+    }
+
+    public void setMarkPaperPeriod(Integer markPaperPeriod) {
+        this.markPaperPeriod = markPaperPeriod;
+    }
+
+    public BigDecimal getWorkHours() {
+        return workHours;
+    }
+
+    public void setWorkHours(BigDecimal workHours) {
+        this.workHours = workHours;
+    }
+
+    public Integer getViolationDays() {
+        return violationDays;
+    }
+
+    public void setViolationDays(Integer violationDays) {
+        this.violationDays = violationDays;
+    }
+}

+ 134 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticByPerson.java

@@ -0,0 +1,134 @@
+package com.qmth.sop.business.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 工时统计-按人员统计
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@ApiModel(value="TBDingStatisticByPerson对象", description="工时统计-按人员统计")
+public class TBDingStatisticByPerson extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "服务单元id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long serviceId;
+
+    @ApiModelProperty(value = "服务单元名称")
+    private String serviceName;
+
+    @ApiModelProperty(value = "姓名(人员档案号)")
+    private String userInfo;
+
+    @ApiModelProperty(value = "供应商")
+    private String supplierName;
+
+    @ApiModelProperty(value = "实际出勤(天)")
+    private Integer actualDays;
+
+    @ApiModelProperty(value = "工作日(天)")
+    private Integer weekdays;
+
+    @ApiModelProperty(value = "周末(天)")
+    private Integer weekends;
+
+    @ApiModelProperty(value = "法定节假日(天)")
+    private Integer legalHolidays;
+
+    @ApiModelProperty(value = "累计工时(小时)")
+    private BigDecimal workHours;
+
+    @ApiModelProperty(value = "违规工时(天)")
+    private Integer violationDays;
+
+    public Long getServiceId() {
+        return serviceId;
+    }
+
+    public void setServiceId(Long serviceId) {
+        this.serviceId = serviceId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public String getUserInfo() {
+        return userInfo;
+    }
+
+    public void setUserInfo(String userInfo) {
+        this.userInfo = userInfo;
+    }
+
+    public String getSupplierName() {
+        return supplierName;
+    }
+
+    public void setSupplierName(String supplierName) {
+        this.supplierName = supplierName;
+    }
+
+    public Integer getActualDays() {
+        return actualDays;
+    }
+
+    public void setActualDays(Integer actualDays) {
+        this.actualDays = actualDays;
+    }
+
+    public Integer getWeekdays() {
+        return weekdays;
+    }
+
+    public void setWeekdays(Integer weekdays) {
+        this.weekdays = weekdays;
+    }
+
+    public Integer getWeekends() {
+        return weekends;
+    }
+
+    public void setWeekends(Integer weekends) {
+        this.weekends = weekends;
+    }
+
+    public Integer getLegalHolidays() {
+        return legalHolidays;
+    }
+
+    public void setLegalHolidays(Integer legalHolidays) {
+        this.legalHolidays = legalHolidays;
+    }
+
+    public BigDecimal getWorkHours() {
+        return workHours;
+    }
+
+    public void setWorkHours(BigDecimal workHours) {
+        this.workHours = workHours;
+    }
+
+    public Integer getViolationDays() {
+        return violationDays;
+    }
+
+    public void setViolationDays(Integer violationDays) {
+        this.violationDays = violationDays;
+    }
+}

+ 156 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticBySop.java

@@ -0,0 +1,156 @@
+package com.qmth.sop.business.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 工时统计-按sop统计
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@ApiModel(value="TBDingStatisticBySop对象", description="工时统计-按sop统计")
+public class TBDingStatisticBySop extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "服务单元id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long serviceId;
+
+    @ApiModelProperty(value = "服务单元名称")
+    private String serviceName;
+
+    @ApiModelProperty(value = "sop流水号")
+    private String sopNo;
+
+    @ApiModelProperty(value = "科目名称")
+    private String courseName;
+
+    @ApiModelProperty(value = "实际出勤(天)")
+    private Integer actualDays;
+
+    @ApiModelProperty(value = "工作日(天)")
+    private Integer weekdays;
+
+    @ApiModelProperty(value = "周末(天)")
+    private Integer weekends;
+
+    @ApiModelProperty(value = "法定节假日(天)")
+    private Integer legalHolidays;
+
+    @ApiModelProperty(value = "扫描周期(天)")
+    private Integer scanPeriod;
+
+    @ApiModelProperty(value = "阅卷周期(天)")
+    private Integer markPaperPeriod;
+
+    @ApiModelProperty(value = "累计工时(小时)")
+    private BigDecimal workHours;
+
+    @ApiModelProperty(value = "违规工时(天)")
+    private Integer violationDays;
+
+    public Long getServiceId() {
+        return serviceId;
+    }
+
+    public void setServiceId(Long serviceId) {
+        this.serviceId = serviceId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public String getSopNo() {
+        return sopNo;
+    }
+
+    public void setSopNo(String sopNo) {
+        this.sopNo = sopNo;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public Integer getActualDays() {
+        return actualDays;
+    }
+
+    public void setActualDays(Integer actualDays) {
+        this.actualDays = actualDays;
+    }
+
+    public Integer getWeekdays() {
+        return weekdays;
+    }
+
+    public void setWeekdays(Integer weekdays) {
+        this.weekdays = weekdays;
+    }
+
+    public Integer getWeekends() {
+        return weekends;
+    }
+
+    public void setWeekends(Integer weekends) {
+        this.weekends = weekends;
+    }
+
+    public Integer getLegalHolidays() {
+        return legalHolidays;
+    }
+
+    public void setLegalHolidays(Integer legalHolidays) {
+        this.legalHolidays = legalHolidays;
+    }
+
+    public Integer getScanPeriod() {
+        return scanPeriod;
+    }
+
+    public void setScanPeriod(Integer scanPeriod) {
+        this.scanPeriod = scanPeriod;
+    }
+
+    public Integer getMarkPaperPeriod() {
+        return markPaperPeriod;
+    }
+
+    public void setMarkPaperPeriod(Integer markPaperPeriod) {
+        this.markPaperPeriod = markPaperPeriod;
+    }
+
+    public BigDecimal getWorkHours() {
+        return workHours;
+    }
+
+    public void setWorkHours(BigDecimal workHours) {
+        this.workHours = workHours;
+    }
+
+    public Integer getViolationDays() {
+        return violationDays;
+    }
+
+    public void setViolationDays(Integer violationDays) {
+        this.violationDays = violationDays;
+    }
+}

+ 135 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatisticBySupplier.java

@@ -0,0 +1,135 @@
+package com.qmth.sop.business.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 工时统计-按供应商统计
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@ApiModel(value="TBDingStatisticBySupplier对象", description="工时统计-按供应商统计")
+public class TBDingStatisticBySupplier extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "服务单元id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long serviceId;
+
+    @ApiModelProperty(value = "服务单元名称")
+    private String serviceName;
+
+    @ApiModelProperty(value = "供应商id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long supplierId;
+
+    @ApiModelProperty(value = "供应商名称")
+    private String supplierName;
+
+    @ApiModelProperty(value = "实际出勤(天)")
+    private Integer actualDays;
+
+    @ApiModelProperty(value = "工作日(天)")
+    private Integer weekdays;
+
+    @ApiModelProperty(value = "周末(天)")
+    private Integer weekends;
+
+    @ApiModelProperty(value = "法定节假日(天)")
+    private Integer legalHolidays;
+
+    @ApiModelProperty(value = "累计工时(小时)")
+    private BigDecimal workHours;
+
+    @ApiModelProperty(value = "违规工时(天)")
+    private Integer violationDays;
+
+    public Long getServiceId() {
+        return serviceId;
+    }
+
+    public void setServiceId(Long serviceId) {
+        this.serviceId = serviceId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public Long getSupplierId() {
+        return supplierId;
+    }
+
+    public void setSupplierId(Long supplierId) {
+        this.supplierId = supplierId;
+    }
+
+    public String getSupplierName() {
+        return supplierName;
+    }
+
+    public void setSupplierName(String supplierName) {
+        this.supplierName = supplierName;
+    }
+
+    public Integer getActualDays() {
+        return actualDays;
+    }
+
+    public void setActualDays(Integer actualDays) {
+        this.actualDays = actualDays;
+    }
+
+    public Integer getWeekdays() {
+        return weekdays;
+    }
+
+    public void setWeekdays(Integer weekdays) {
+        this.weekdays = weekdays;
+    }
+
+    public Integer getWeekends() {
+        return weekends;
+    }
+
+    public void setWeekends(Integer weekends) {
+        this.weekends = weekends;
+    }
+
+    public Integer getLegalHolidays() {
+        return legalHolidays;
+    }
+
+    public void setLegalHolidays(Integer legalHolidays) {
+        this.legalHolidays = legalHolidays;
+    }
+
+    public BigDecimal getWorkHours() {
+        return workHours;
+    }
+
+    public void setWorkHours(BigDecimal workHours) {
+        this.workHours = workHours;
+    }
+
+    public Integer getViolationDays() {
+        return violationDays;
+    }
+
+    public void setViolationDays(Integer violationDays) {
+        this.violationDays = violationDays;
+    }
+}

+ 27 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticByCrmMapper.java

@@ -0,0 +1,27 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.sop.business.bean.dto.DingStatisticByCrmDto;
+import com.qmth.sop.business.bean.result.SysLogResult;
+import com.qmth.sop.business.entity.TBDingStatisticByCrm;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按派单统计 Mapper 接口
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticByCrmMapper extends BaseMapper<TBDingStatisticByCrm> {
+    List<DingStatisticByCrmDto> findStatisticByCrmList(@Param("serviceId") Long serviceId);
+
+    IPage<DingStatisticByCrmDto> findStatisticByCrmPage(@Param("iPage") Page<DingStatisticByCrmDto> iPage, @Param("serviceId") Long serviceId);
+
+    void truncateTable();
+}

+ 26 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticByCustomMapper.java

@@ -0,0 +1,26 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.sop.business.bean.dto.DingStatisticByCustomDto;
+import com.qmth.sop.business.entity.TBDingStatisticByCustom;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按客户统计 Mapper 接口
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticByCustomMapper extends BaseMapper<TBDingStatisticByCustom> {
+    List<DingStatisticByCustomDto> findStatisticByCustomList(@Param("serviceId") Long serviceId);
+
+    IPage<DingStatisticByCustomDto> findStatisticByCustomPage(@Param("iPage") Page<DingStatisticByCustomDto> iPage, @Param("serviceId") Long serviceId);
+
+    void truncateTable();
+}

+ 28 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticByPersonMapper.java

@@ -0,0 +1,28 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.sop.business.bean.dto.DingStatisticByPersonDto;
+import com.qmth.sop.business.bean.result.SysLogResult;
+import com.qmth.sop.business.entity.TBDingStatisticByPerson;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按人员统计 Mapper 接口
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticByPersonMapper extends BaseMapper<TBDingStatisticByPerson> {
+
+    List<DingStatisticByPersonDto> findStatisticByPersonList(@Param("serviceId") Long serviceId);
+
+    IPage<DingStatisticByPersonDto> findStatisticByPersonPage(@Param("iPage") Page<DingStatisticByPersonDto> iPage, @Param("serviceId") Long serviceId);
+
+    void truncateTable();
+}

+ 27 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticBySopMapper.java

@@ -0,0 +1,27 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.sop.business.bean.dto.DingStatisticBySopDto;
+import com.qmth.sop.business.bean.result.SysLogResult;
+import com.qmth.sop.business.entity.TBDingStatisticBySop;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按sop统计 Mapper 接口
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticBySopMapper extends BaseMapper<TBDingStatisticBySop> {
+    List<DingStatisticBySopDto> findStatisticBySopList(@Param("serviceId") Long serviceId);
+
+    IPage<DingStatisticBySopDto> findStatisticBySopPage(@Param("iPage") Page<DingStatisticBySopDto> iPage, @Param("serviceId") Long serviceId);
+
+    void truncateTable();
+}

+ 26 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingStatisticBySupplierMapper.java

@@ -0,0 +1,26 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.sop.business.bean.dto.DingStatisticBySupplierDto;
+import com.qmth.sop.business.entity.TBDingStatisticBySupplier;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按供应商统计 Mapper 接口
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticBySupplierMapper extends BaseMapper<TBDingStatisticBySupplier> {
+    List<DingStatisticBySupplierDto> findStatisticBySupplierList(@Param("serviceId") Long serviceId);
+
+    IPage<DingStatisticBySupplierDto> findStatisticBySupplierPage(@Param("iPage") Page<DingStatisticBySupplierDto> iPage, @Param("serviceId") Long serviceId);
+
+    void truncateTable();
+}

+ 45 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticByCrmService.java

@@ -0,0 +1,45 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.bean.dto.DingStatisticByCrmDto;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticByCrm;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按派单统计 服务类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticByCrmService extends IService<TBDingStatisticByCrm> {
+
+    /**
+     * 按crm统计(不统计区协数据)
+     *
+     * @param datasource 数据源
+     */
+    void buildStatisticByCrm(List<TBDingStatistic> datasource);
+
+    /**
+     * 按派单统计(不统计区协数据)
+     *
+     * @param serviceId  服务单元id
+     * @param pageNumber 页码
+     * @param pageSize   容量
+     * @return 分页结果
+     */
+    IPage<DingStatisticByCrmDto> findStatisticByCrmPage(Long serviceId, Integer pageNumber, Integer pageSize);
+
+    /**
+     * 查询按派单统计列表
+     *
+     * @param serviceId 服务单元id
+     * @return 查询结果
+     */
+    List<DingStatisticByCrmDto> findStatisticByCrmList(Long serviceId);
+}

+ 45 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticByCustomService.java

@@ -0,0 +1,45 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.bean.dto.DingStatisticByCustomDto;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticByCustom;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按客户统计 服务类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticByCustomService extends IService<TBDingStatisticByCustom> {
+
+    /**
+     * 按客户统计(不统计区协数据)
+     *
+     * @param datasource 数据源
+     */
+    void buildStatisticByCustom(List<TBDingStatistic> datasource);
+
+    /**
+     * 按客户统计(不统计区协数据)
+     *
+     * @param serviceId  服务单元id
+     * @param pageNumber 页码
+     * @param pageSize   容量
+     * @return 分页结果
+     */
+    IPage<DingStatisticByCustomDto> findStatisticByCustomPage(Long serviceId, Integer pageNumber, Integer pageSize);
+
+    /**
+     * 查询按客户统计列表
+     *
+     * @param serviceId 服务单元id
+     * @return 查询结果
+     */
+    List<DingStatisticByCustomDto> findStatisticByCustomList(Long serviceId);
+}

+ 43 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticByPersonService.java

@@ -0,0 +1,43 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.bean.dto.DingStatisticByPersonDto;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticByPerson;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按人员统计 服务类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticByPersonService extends IService<TBDingStatisticByPerson> {
+
+    /**
+     * 按人员统计(统计区协数据)
+     */
+    void buildStatisticByPerson(List<TBDingStatistic> datasource);
+
+    /**
+     * 按人员统计(统计区协数据)
+     *
+     * @param serviceId  服务单元id
+     * @param pageNumber 页码
+     * @param pageSize   容量
+     * @return 分页结果
+     */
+    IPage<DingStatisticByPersonDto> findStatisticByPersonPage(Long serviceId, Integer pageNumber, Integer pageSize);
+
+    /**
+     * 查询按人员统计列表
+     *
+     * @param serviceId 服务单元id
+     * @return 查询结果
+     */
+    List<DingStatisticByPersonDto> findStatisticByPersonList(Long serviceId);
+}

+ 45 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticBySopService.java

@@ -0,0 +1,45 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.bean.dto.DingStatisticBySopDto;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticBySop;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按sop统计 服务类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticBySopService extends IService<TBDingStatisticBySop> {
+
+    /**
+     * 按sop统计(不统计区协数据)
+     *
+     * @param datasource 数据源
+     */
+    void buildStatisticBySop(List<TBDingStatistic> datasource);
+
+    /**
+     * 按Sop统计(不统计区协数据)
+     *
+     * @param serviceId  服务单元id
+     * @param pageNumber 页码
+     * @param pageSize   容量
+     * @return 分页结果
+     */
+    IPage<DingStatisticBySopDto> findStatisticBySopPage(Long serviceId, Integer pageNumber, Integer pageSize);
+
+    /**
+     * 查询按Sop统计列表
+     *
+     * @param serviceId 服务单元id
+     * @return 查询结果
+     */
+    List<DingStatisticBySopDto> findStatisticBySopList(Long serviceId);
+}

+ 45 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticBySupplierService.java

@@ -0,0 +1,45 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.bean.dto.DingStatisticBySupplierDto;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticBySupplier;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按供应商统计 服务类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+public interface TBDingStatisticBySupplierService extends IService<TBDingStatisticBySupplier> {
+
+    /**
+     * 按供应商统计(统计区协数据)
+     *
+     * @param datasource 数据源
+     */
+    void buildStatisticBySupplier(List<TBDingStatistic> datasource);
+
+    /**
+     * 按供应商统计(统计区协数据)
+     *
+     * @param serviceId  服务单元id
+     * @param pageNumber 页码
+     * @param pageSize   容量
+     * @return 分页结果
+     */
+    IPage<DingStatisticBySupplierDto> findStatisticBySupplierPage(Long serviceId, Integer pageNumber, Integer pageSize);
+
+    /**
+     * 查询按供应商统计列表
+     *
+     * @param serviceId 服务单元id
+     * @return 查询结果
+     */
+    List<DingStatisticBySupplierDto> findStatisticBySupplierList(Long serviceId);
+}

+ 12 - 28
sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticService.java

@@ -2,9 +2,12 @@ package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.bean.dto.*;
+import com.qmth.sop.business.entity.TBCrmDetail;
 import com.qmth.sop.business.entity.TBDing;
 import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.common.enums.DingStatisticTypeEnum;
 
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -66,42 +69,23 @@ public interface TBDingStatisticService extends IService<TBDingStatistic> {
     void buildDingStatisticByService(Long serviceId, List<TBDing> datasource, Long requestUserId);
 
     /**
-     * 按人员统计(统计区协数据)
-     *
-     * @param serviceId 服务单元id
-     * @return 统计结果
-     */
-    List<DingStatisticByPersonDto> findStatisticByPerson(Long serviceId);
-
-    /**
-     * 按sop统计(不统计区协数据)
-     *
-     * @param serviceId 服务单元id
-     * @return 统计结果
+     * 生成统计数据
      */
-    List<DingStatisticBySopDto> findStatisticBySop(Long serviceId);
+    void buildStatisticData();
 
     /**
-     * 按crm统计(不统计区协数据)
+     * 导出统计数据
      *
      * @param serviceId 服务单元id
-     * @return 统计结果
+     * @param type      类型
      */
-    List<DingStatisticByCrmDto> findStatisticByCrm(Long serviceId);
+    void exportStatisticData(Long serviceId, DingStatisticTypeEnum type) throws IOException;
 
     /**
-     * 按客户统计(不统计区协数据)
+     * 查询扫描和阅卷周期
      *
-     * @param serviceId 服务单元id
-     * @return 统计结果
-     */
-    List<DingStatisticByCustomDto> findStatisticByCustom(Long serviceId);
-
-    /**
-     * 按供应商统计(统计区协数据)
-     *
-     * @param serviceId 服务单元id
-     * @return 统计结果
+     * @param tbCrmDetail 派单详情
+     * @return 结果
      */
-    List<DingStatisticBySupplierDto> findStatisticBySupplier(Long serviceId);
+    SopPeriodDto findSopPeriod(TBCrmDetail tbCrmDetail);
 }

+ 118 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticByCrmServiceImpl.java

@@ -0,0 +1,118 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.bean.dto.DingStatisticByCrmDto;
+import com.qmth.sop.business.bean.dto.SopPeriodDto;
+import com.qmth.sop.business.entity.TBCrm;
+import com.qmth.sop.business.entity.TBCrmDetail;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticByCrm;
+import com.qmth.sop.business.mapper.TBDingStatisticByCrmMapper;
+import com.qmth.sop.business.service.TBCrmDetailService;
+import com.qmth.sop.business.service.TBCrmService;
+import com.qmth.sop.business.service.TBDingStatisticByCrmService;
+import com.qmth.sop.business.service.TBDingStatisticService;
+import com.qmth.sop.common.contant.SystemConstant;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 工时统计-按派单统计 服务实现类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@Service
+public class TBDingStatisticByCrmServiceImpl extends ServiceImpl<TBDingStatisticByCrmMapper, TBDingStatisticByCrm> implements TBDingStatisticByCrmService {
+
+    @Resource
+    TBCrmService tbCrmService;
+
+    @Resource
+    TBCrmDetailService tbCrmDetailService;
+
+    @Resource
+    TBDingStatisticService tbDingStatisticService;
+
+    @Transactional
+    @Override
+    public void buildStatisticByCrm(List<TBDingStatistic> datasource) {
+        List<TBDingStatisticByCrm> result = new ArrayList<>();
+
+        datasource = datasource.stream()
+                .filter(e -> SystemConstant.strNotNull(e.getSopNo()) && SystemConstant.strNotNull(e.getCrmNo()))
+                .collect(Collectors.toList());
+        List<String> crmNoList = datasource.stream().map(TBDingStatistic::getCrmNo).distinct().collect(Collectors.toList());
+
+        for (String crmNo : crmNoList) {
+            TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
+            List<TBCrmDetail> tbCrmDetailList = tbCrmDetailService.list(
+                    new QueryWrapper<TBCrmDetail>().lambda().eq(TBCrmDetail::getCrmNo, crmNo));
+            int scanPeriod = 0;
+            int markPaperPeriod = 0;
+            for (TBCrmDetail tbCrmDetail : tbCrmDetailList) {
+                SopPeriodDto sopPeriodDto = tbDingStatisticService.findSopPeriod(tbCrmDetail);
+                scanPeriod = scanPeriod + sopPeriodDto.getScanPeriod();
+                markPaperPeriod = markPaperPeriod + sopPeriodDto.getMarkPaperPeriod();
+            }
+
+            List<TBDingStatistic> tbDingStatisticList = datasource.stream().filter(e -> crmNo.equals(e.getCrmNo())).collect(Collectors.toList());
+            Long serviceId = null;
+            String serviceName = "";
+            int actualDays = 0;
+            int weekdays = 0;
+            int weekends = 0;
+            int legalHolidays = 0;
+            BigDecimal workHours = new BigDecimal(0);
+            int violationDays = 0;
+
+            for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
+                serviceId = tbDingStatistic.getServiceId();
+                serviceName = tbDingStatistic.getServiceName();
+                actualDays = actualDays + tbDingStatistic.getActualDays();
+                weekdays = weekdays + tbDingStatistic.getWeekdays();
+                weekends = weekends + tbDingStatistic.getWeekends();
+                legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
+                workHours = workHours.add(tbDingStatistic.getWorkHours());
+                violationDays = violationDays + tbDingStatistic.getViolationDays();
+            }
+            TBDingStatisticByCrm tbDingStatisticByCrm = new TBDingStatisticByCrm();
+            tbDingStatisticByCrm.setServiceId(serviceId);
+            tbDingStatisticByCrm.setServiceName(serviceName);
+            tbDingStatisticByCrm.setCrmNo(crmNo);
+            tbDingStatisticByCrm.setCrmName(tbCrm.getName());
+            tbDingStatisticByCrm.setActualDays(actualDays);
+            tbDingStatisticByCrm.setWeekdays(weekdays);
+            tbDingStatisticByCrm.setWeekends(weekends);
+            tbDingStatisticByCrm.setLegalHolidays(legalHolidays);
+            tbDingStatisticByCrm.setWorkHours(workHours);
+            tbDingStatisticByCrm.setViolationDays(violationDays);
+            tbDingStatisticByCrm.setScanPeriod(scanPeriod);
+            tbDingStatisticByCrm.setMarkPaperPeriod(markPaperPeriod);
+            result.add(tbDingStatisticByCrm);
+        }
+        this.baseMapper.truncateTable();
+        this.saveBatch(result);
+    }
+
+    @Override
+    public IPage<DingStatisticByCrmDto> findStatisticByCrmPage(Long serviceId, Integer pageNumber, Integer pageSize) {
+        return this.baseMapper.findStatisticByCrmPage(new Page<>(pageNumber, pageSize), serviceId);
+    }
+
+    @Override
+    public List<DingStatisticByCrmDto> findStatisticByCrmList(Long serviceId) {
+        return this.baseMapper.findStatisticByCrmList(serviceId);
+    }
+}

+ 116 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticByCustomServiceImpl.java

@@ -0,0 +1,116 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.bean.dto.DingStatisticByCustomDto;
+import com.qmth.sop.business.bean.dto.SopPeriodDto;
+import com.qmth.sop.business.entity.TBCrmDetail;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticByCustom;
+import com.qmth.sop.business.mapper.TBDingStatisticByCustomMapper;
+import com.qmth.sop.business.service.SysCustomService;
+import com.qmth.sop.business.service.TBCrmDetailService;
+import com.qmth.sop.business.service.TBDingStatisticByCustomService;
+import com.qmth.sop.business.service.TBDingStatisticService;
+import com.qmth.sop.common.contant.SystemConstant;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 工时统计-按客户统计 服务实现类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@Service
+public class TBDingStatisticByCustomServiceImpl extends ServiceImpl<TBDingStatisticByCustomMapper, TBDingStatisticByCustom> implements TBDingStatisticByCustomService {
+
+    @Resource
+    TBCrmDetailService tbCrmDetailService;
+
+    @Resource
+    TBDingStatisticService tbDingStatisticService;
+
+    @Resource
+    SysCustomService sysCustomService;
+
+    @Transactional
+    @Override
+    public void buildStatisticByCustom(List<TBDingStatistic> datasource) {
+        List<TBDingStatisticByCustom> result = new ArrayList<>();
+        datasource = datasource.stream().filter(e -> SystemConstant.strNotNull(e.getSopNo())).collect(Collectors.toList());
+        List<Long> serviceIdList = datasource.stream().map(TBDingStatistic::getServiceId).distinct().collect(Collectors.toList());
+        for (Long serviceId : serviceIdList) {
+            List<TBDingStatistic> serviceStatisticList = datasource.stream().filter(e -> serviceId.equals(e.getServiceId())).collect(Collectors.toList());
+            List<Long> customIdList = serviceStatisticList.stream().map(TBDingStatistic::getCustomId).distinct().collect(Collectors.toList());
+
+            for (Long customId : customIdList) {
+                List<TBCrmDetail> tbCrmDetailList = tbCrmDetailService.findByServiceIdAndCustomId(serviceId, customId);
+                int scanPeriod = 0;
+                int markPaperPeriod = 0;
+                for (TBCrmDetail tbCrmDetail : tbCrmDetailList) {
+                    SopPeriodDto sopPeriodDto = tbDingStatisticService.findSopPeriod(tbCrmDetail);
+                    scanPeriod = scanPeriod + sopPeriodDto.getScanPeriod();
+                    markPaperPeriod = markPaperPeriod + sopPeriodDto.getMarkPaperPeriod();
+                }
+
+                List<TBDingStatistic> tbDingStatisticList = serviceStatisticList.stream().filter(e -> customId.equals(e.getCustomId())).collect(Collectors.toList());
+                String serviceName = "";
+                String customName = sysCustomService.getById(customId).getName();
+                int actualDays = 0;
+                int weekdays = 0;
+                int weekends = 0;
+                int legalHolidays = 0;
+                BigDecimal workHours = new BigDecimal(0);
+                int violationDays = 0;
+
+                for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
+                    serviceName = tbDingStatistic.getServiceName();
+                    actualDays = actualDays + tbDingStatistic.getActualDays();
+                    weekdays = weekdays + tbDingStatistic.getWeekdays();
+                    weekends = weekends + tbDingStatistic.getWeekends();
+                    legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
+                    workHours = workHours.add(tbDingStatistic.getWorkHours());
+                    violationDays = violationDays + tbDingStatistic.getViolationDays();
+                }
+                TBDingStatisticByCustom tbDingStatisticByCustom = new TBDingStatisticByCustom();
+                tbDingStatisticByCustom.setServiceId(serviceId);
+                tbDingStatisticByCustom.setServiceName(serviceName);
+                tbDingStatisticByCustom.setCustomId(customId);
+                tbDingStatisticByCustom.setCustomName(customName);
+                tbDingStatisticByCustom.setActualDays(actualDays);
+                tbDingStatisticByCustom.setWeekdays(weekdays);
+                tbDingStatisticByCustom.setWeekends(weekends);
+                tbDingStatisticByCustom.setLegalHolidays(legalHolidays);
+                tbDingStatisticByCustom.setWorkHours(workHours);
+                tbDingStatisticByCustom.setViolationDays(violationDays);
+                tbDingStatisticByCustom.setScanPeriod(scanPeriod);
+                tbDingStatisticByCustom.setMarkPaperPeriod(markPaperPeriod);
+                result.add(tbDingStatisticByCustom);
+            }
+        }
+        this.baseMapper.truncateTable();
+        this.saveBatch(result);
+    }
+
+    @Override
+    public IPage<DingStatisticByCustomDto> findStatisticByCustomPage(Long serviceId, Integer pageNumber,
+            Integer pageSize) {
+        return this.baseMapper.findStatisticByCustomPage(new Page<>(pageNumber, pageSize), serviceId);
+    }
+
+    @Override
+    public List<DingStatisticByCustomDto> findStatisticByCustomList(Long serviceId) {
+        return this.baseMapper.findStatisticByCustomList(serviceId);
+    }
+}

+ 56 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticByPersonServiceImpl.java

@@ -0,0 +1,56 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.bean.dto.DingStatisticByPersonDto;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticByPerson;
+import com.qmth.sop.business.mapper.TBDingStatisticByPersonMapper;
+import com.qmth.sop.business.service.TBDingStatisticByPersonService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 工时统计-按人员统计 服务实现类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@Service
+public class TBDingStatisticByPersonServiceImpl extends ServiceImpl<TBDingStatisticByPersonMapper, TBDingStatisticByPerson> implements TBDingStatisticByPersonService {
+
+    @Transactional
+    @Override
+    public void buildStatisticByPerson(List<TBDingStatistic> datasource) {
+        List<TBDingStatisticByPerson> result = new ArrayList<>();
+        for (TBDingStatistic tbDingStatistic : datasource) {
+            TBDingStatisticByPerson tbDingStatisticByPerson = new TBDingStatisticByPerson();
+            BeanUtils.copyProperties(tbDingStatistic, tbDingStatisticByPerson);
+            tbDingStatisticByPerson.setUserInfo(
+                    tbDingStatistic.getUserArchivesName() + "(" + tbDingStatistic.getUserArchivesCode() + ")");
+            result.add(tbDingStatisticByPerson);
+        }
+        this.baseMapper.truncateTable();
+        this.saveBatch(result);
+    }
+
+    @Override
+    public IPage<DingStatisticByPersonDto> findStatisticByPersonPage(Long serviceId, Integer pageNumber,
+            Integer pageSize) {
+        return this.baseMapper.findStatisticByPersonPage(new Page<>(pageNumber, pageSize), serviceId);
+    }
+
+    @Override
+    public List<DingStatisticByPersonDto> findStatisticByPersonList(Long serviceId) {
+        return this.baseMapper.findStatisticByPersonList(serviceId);
+    }
+}

+ 102 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticBySopServiceImpl.java

@@ -0,0 +1,102 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.bean.dto.DingStatisticBySopDto;
+import com.qmth.sop.business.bean.dto.SopPeriodDto;
+import com.qmth.sop.business.entity.TBCrmDetail;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticBySop;
+import com.qmth.sop.business.mapper.TBDingStatisticBySopMapper;
+import com.qmth.sop.business.service.TBCrmDetailService;
+import com.qmth.sop.business.service.TBDingStatisticBySopService;
+import com.qmth.sop.business.service.TBDingStatisticService;
+import com.qmth.sop.common.contant.SystemConstant;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 工时统计-按sop统计 服务实现类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@Service
+public class TBDingStatisticBySopServiceImpl extends ServiceImpl<TBDingStatisticBySopMapper, TBDingStatisticBySop> implements TBDingStatisticBySopService {
+
+    @Resource
+    TBCrmDetailService tbCrmDetailService;
+
+    @Resource
+    TBDingStatisticService tbDingStatisticService;
+
+    @Transactional
+    @Override
+    public void buildStatisticBySop(List<TBDingStatistic> datasource) {
+        List<TBDingStatisticBySop> result = new ArrayList<>();
+        datasource = datasource.stream().filter(e -> SystemConstant.strNotNull(e.getSopNo())).collect(Collectors.toList());
+        List<String> sopNoList = datasource.stream().map(TBDingStatistic::getSopNo).distinct().collect(Collectors.toList());
+
+        for (String sopNo : sopNoList) {
+            TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
+            SopPeriodDto sopPeriodDto = tbDingStatisticService.findSopPeriod(tbCrmDetail);
+
+            List<TBDingStatistic> tbDingStatisticList = datasource.stream().filter(e -> sopNo.equals(e.getSopNo())).collect(Collectors.toList());
+            Long serviceId = null;
+            String serviceName = "";
+            int actualDays = 0;
+            int weekdays = 0;
+            int weekends = 0;
+            int legalHolidays = 0;
+            BigDecimal workHours = new BigDecimal(0);
+            int violationDays = 0;
+
+            for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
+                serviceId = tbDingStatistic.getServiceId();
+                serviceName = tbDingStatistic.getServiceName();
+                actualDays = actualDays + tbDingStatistic.getActualDays();
+                weekdays = weekdays + tbDingStatistic.getWeekdays();
+                weekends = weekends + tbDingStatistic.getWeekends();
+                legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
+                workHours = workHours.add(tbDingStatistic.getWorkHours());
+                violationDays = violationDays + tbDingStatistic.getViolationDays();
+            }
+            TBDingStatisticBySop tbDingStatisticBySop = new TBDingStatisticBySop();
+            tbDingStatisticBySop.setServiceId(serviceId);
+            tbDingStatisticBySop.setServiceName(serviceName);
+            tbDingStatisticBySop.setSopNo(sopNo);
+            tbDingStatisticBySop.setCourseName(tbCrmDetail.getCourseName());
+            tbDingStatisticBySop.setActualDays(actualDays);
+            tbDingStatisticBySop.setWeekdays(weekdays);
+            tbDingStatisticBySop.setWeekends(weekends);
+            tbDingStatisticBySop.setLegalHolidays(legalHolidays);
+            tbDingStatisticBySop.setWorkHours(workHours);
+            tbDingStatisticBySop.setViolationDays(violationDays);
+            tbDingStatisticBySop.setScanPeriod(sopPeriodDto.getScanPeriod());
+            tbDingStatisticBySop.setMarkPaperPeriod(sopPeriodDto.getMarkPaperPeriod());
+            result.add(tbDingStatisticBySop);
+        }
+        this.baseMapper.truncateTable();
+        this.saveBatch(result);
+    }
+
+    @Override
+    public IPage<DingStatisticBySopDto> findStatisticBySopPage(Long serviceId, Integer pageNumber, Integer pageSize) {
+        return this.baseMapper.findStatisticBySopPage(new Page<>(pageNumber, pageSize), serviceId);
+    }
+
+    @Override
+    public List<DingStatisticBySopDto> findStatisticBySopList(Long serviceId) {
+        return this.baseMapper.findStatisticBySopList(serviceId);
+    }
+}

+ 93 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticBySupplierServiceImpl.java

@@ -0,0 +1,93 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.bean.dto.DingStatisticBySupplierDto;
+import com.qmth.sop.business.entity.TBDingStatistic;
+import com.qmth.sop.business.entity.TBDingStatisticBySupplier;
+import com.qmth.sop.business.mapper.TBDingStatisticBySupplierMapper;
+import com.qmth.sop.business.service.SysSupplierService;
+import com.qmth.sop.business.service.TBDingStatisticBySupplierService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 工时统计-按供应商统计 服务实现类
+ * </p>
+ *
+ * @author CaoZixuan
+ * @since 2024-09-09
+ */
+@Service
+public class TBDingStatisticBySupplierServiceImpl extends ServiceImpl<TBDingStatisticBySupplierMapper, TBDingStatisticBySupplier> implements TBDingStatisticBySupplierService {
+
+    @Resource
+    SysSupplierService sysSupplierService;
+
+    @Transactional
+    @Override
+    public void buildStatisticBySupplier(List<TBDingStatistic> datasource) {
+        List<TBDingStatisticBySupplier> result = new ArrayList<>();
+        List<Long> serviceIdList = datasource.stream().map(TBDingStatistic::getServiceId).distinct().collect(Collectors.toList());
+        for (Long serviceId : serviceIdList) {
+            List<TBDingStatistic> serviceStatisticList = datasource.stream().filter(e -> serviceId.equals(e.getServiceId())).collect(Collectors.toList());
+            List<Long> supplierIdList = serviceStatisticList.stream().map(TBDingStatistic::getSupplierId).distinct().collect(Collectors.toList());
+
+            for (Long supplierId : supplierIdList) {
+                List<TBDingStatistic> tbDingStatisticList = serviceStatisticList.stream().filter(e -> supplierId.equals(e.getSupplierId())).collect(Collectors.toList());
+                String serviceName = "";
+                String supplierName = sysSupplierService.getById(supplierId).getName();
+                int actualDays = 0;
+                int weekdays = 0;
+                int weekends = 0;
+                int legalHolidays = 0;
+                BigDecimal workHours = new BigDecimal(0);
+                int violationDays = 0;
+
+                for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
+                    serviceName = tbDingStatistic.getServiceName();
+                    actualDays = actualDays + tbDingStatistic.getActualDays();
+                    weekdays = weekdays + tbDingStatistic.getWeekdays();
+                    weekends = weekends + tbDingStatistic.getWeekends();
+                    legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
+                    workHours = workHours.add(tbDingStatistic.getWorkHours());
+                    violationDays = violationDays + tbDingStatistic.getViolationDays();
+                }
+                TBDingStatisticBySupplier tbDingStatisticBySupplier = new TBDingStatisticBySupplier();
+                tbDingStatisticBySupplier.setServiceId(serviceId);
+                tbDingStatisticBySupplier.setServiceName(serviceName);
+                tbDingStatisticBySupplier.setSupplierId(supplierId);
+                tbDingStatisticBySupplier.setSupplierName(supplierName);
+                tbDingStatisticBySupplier.setActualDays(actualDays);
+                tbDingStatisticBySupplier.setWeekdays(weekdays);
+                tbDingStatisticBySupplier.setWeekends(weekends);
+                tbDingStatisticBySupplier.setLegalHolidays(legalHolidays);
+                tbDingStatisticBySupplier.setWorkHours(workHours);
+                tbDingStatisticBySupplier.setViolationDays(violationDays);
+                result.add(tbDingStatisticBySupplier);
+            }
+        }
+        this.baseMapper.truncateTable();
+        this.saveBatch(result);
+    }
+
+    @Override
+    public IPage<DingStatisticBySupplierDto> findStatisticBySupplierPage(Long serviceId, Integer pageNumber,
+            Integer pageSize) {
+        return this.baseMapper.findStatisticBySupplierPage(new Page<>(pageNumber, pageSize), serviceId);
+    }
+
+    @Override
+    public List<DingStatisticBySupplierDto> findStatisticBySupplierList(Long serviceId) {
+        return this.baseMapper.findStatisticBySupplierList(serviceId);
+    }
+}

+ 69 - 217
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticServiceImpl.java

@@ -1,20 +1,25 @@
 package com.qmth.sop.business.service.impl;
 
+import com.alibaba.excel.EasyExcel;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.bean.dto.*;
 import com.qmth.sop.business.bean.result.CrmProjectResult;
+import com.qmth.sop.business.bean.result.TBDeviceDeliveryResult;
 import com.qmth.sop.business.bean.result.UserArchivesResult;
 import com.qmth.sop.business.entity.*;
 import com.qmth.sop.business.mapper.TBDingStatisticMapper;
 import com.qmth.sop.business.service.*;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.DingDateTypeEnum;
+import com.qmth.sop.common.enums.DingStatisticTypeEnum;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.SopRoleTypeEnum;
 import com.qmth.sop.common.util.DateDisposeUtils;
+import com.qmth.sop.common.util.FileUtil;
+import com.qmth.sop.common.util.ServletUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
@@ -22,6 +27,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
@@ -69,6 +77,21 @@ public class TBDingStatisticServiceImpl extends ServiceImpl<TBDingStatisticMappe
     @Resource
     private SysSupplierService sysSupplierService;
 
+    @Resource
+    private TBDingStatisticByPersonService tbdingStatisticByPersonService;
+
+    @Resource
+    private TBDingStatisticByCrmService tbdingStatisticByCrmService;
+
+    @Resource
+    private TBDingStatisticBySopService tbdingStatisticBySopService;
+
+    @Resource
+    private TBDingStatisticByCustomService tbdingStatisticByCustomService;
+
+    @Resource
+    private TBDingStatisticBySupplierService tbdingStatisticBySupplierService;
+
     @Override
     public TBDingStatistic findBySopNoAndUserArchivesId(Long serviceId, String sopNo, Long userArchivesId) {
         QueryWrapper<TBDingStatistic> queryWrapper = new QueryWrapper<>();
@@ -457,229 +480,57 @@ public class TBDingStatisticServiceImpl extends ServiceImpl<TBDingStatisticMappe
         this.saveOrUpdateBatch(tbDingStatisticList);
     }
 
+    @Transactional
     @Override
-    public List<DingStatisticByPersonDto> findStatisticByPerson(Long serviceId) {
-        List<DingStatisticByPersonDto> result = new ArrayList<>();
-        QueryWrapper<TBDingStatistic> queryWrapper = new QueryWrapper<>();
-        if (serviceId != null) {
-            queryWrapper.lambda().eq(TBDingStatistic::getServiceId, serviceId);
-        }
-        List<TBDingStatistic> datasource = this.list(queryWrapper);
-        for (TBDingStatistic tbDingStatistic : datasource) {
-            DingStatisticByPersonDto dto = new DingStatisticByPersonDto();
-            BeanUtils.copyProperties(tbDingStatistic, dto);
-            dto.setUserInfo(tbDingStatistic.getUserArchivesName() + "(" + tbDingStatistic.getUserArchivesCode() + ")");
-            result.add(dto);
-        }
-        return result;
-    }
-
-    @Override
-    public List<DingStatisticBySopDto> findStatisticBySop(Long serviceId) {
-        List<DingStatisticBySopDto> result = new ArrayList<>();
-        QueryWrapper<TBDingStatistic> queryWrapper = new QueryWrapper<>();
-        if (serviceId != null) {
-            queryWrapper.lambda().eq(TBDingStatistic::getServiceId, serviceId);
-        }
-        queryWrapper.lambda().isNotNull(TBDingStatistic::getSopNo);
-        List<TBDingStatistic> datasource = this.list(queryWrapper);
-        List<String> sopNoList = datasource.stream().map(TBDingStatistic::getSopNo).distinct().collect(Collectors.toList());
-
-        for (String sopNo : sopNoList) {
-            TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
-            SopPeriodDto sopPeriodDto = this.findSopPeriod(tbCrmDetail);
-
-            List<TBDingStatistic> tbDingStatisticList = datasource.stream().filter(e -> sopNo.equals(e.getSopNo())).collect(Collectors.toList());
-            String serviceName = "";
-            int actualDays = 0;
-            int weekdays = 0;
-            int weekends = 0;
-            int legalHolidays = 0;
-            BigDecimal workHours = new BigDecimal(0);
-            int violationDays = 0;
-
-            for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
-                serviceName = tbDingStatistic.getServiceName();
-                actualDays = actualDays + tbDingStatistic.getActualDays();
-                weekdays = weekdays + tbDingStatistic.getWeekdays();
-                weekends = weekends + tbDingStatistic.getWeekends();
-                legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
-                workHours = workHours.add(tbDingStatistic.getWorkHours());
-                violationDays = violationDays + tbDingStatistic.getViolationDays();
-            }
-            DingStatisticBySopDto dto = new DingStatisticBySopDto();
-            dto.setServiceName(serviceName);
-            dto.setSopNo(sopNo);
-            dto.setCourseName(tbCrmDetail.getCourseName());
-            dto.setActualDays(actualDays);
-            dto.setWeekdays(weekdays);
-            dto.setWeekends(weekends);
-            dto.setLegalHolidays(legalHolidays);
-            dto.setWorkHours(workHours.doubleValue());
-            dto.setViolationDays(violationDays);
-            dto.setScanPeriod(sopPeriodDto.getScanPeriod());
-            dto.setMarkPaperPeriod(sopPeriodDto.getMarkPaperPeriod());
-            result.add(dto);
-        }
-        return result;
-    }
-
-    @Override
-    public List<DingStatisticByCrmDto> findStatisticByCrm(Long serviceId) {
-        List<DingStatisticByCrmDto> result = new ArrayList<>();
-        QueryWrapper<TBDingStatistic> queryWrapper = new QueryWrapper<>();
-        if (serviceId != null) {
-            queryWrapper.lambda().eq(TBDingStatistic::getServiceId, serviceId).isNotNull(TBDingStatistic::getSopNo);
-        }
-        queryWrapper.lambda().isNotNull(TBDingStatistic::getCrmNo);
-        List<TBDingStatistic> datasource = this.list(queryWrapper);
-        List<String> crmNoList = datasource.stream().map(TBDingStatistic::getCrmNo).distinct().collect(Collectors.toList());
-
-        for (String crmNo : crmNoList) {
-            TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
-            List<TBCrmDetail> tbCrmDetailList = tbCrmDetailService.list(
-                    new QueryWrapper<TBCrmDetail>().lambda().eq(TBCrmDetail::getCrmNo, crmNo));
-            int scanPeriod = 0;
-            int markPaperPeriod = 0;
-            for (TBCrmDetail tbCrmDetail : tbCrmDetailList) {
-                SopPeriodDto sopPeriodDto = this.findSopPeriod(tbCrmDetail);
-                scanPeriod = scanPeriod + sopPeriodDto.getScanPeriod();
-                markPaperPeriod = markPaperPeriod + sopPeriodDto.getMarkPaperPeriod();
-            }
-
-            List<TBDingStatistic> tbDingStatisticList = datasource.stream().filter(e -> crmNo.equals(e.getCrmNo())).collect(Collectors.toList());
-            String serviceName = "";
-            int actualDays = 0;
-            int weekdays = 0;
-            int weekends = 0;
-            int legalHolidays = 0;
-            BigDecimal workHours = new BigDecimal(0);
-            int violationDays = 0;
-
-            for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
-                serviceName = tbDingStatistic.getServiceName();
-                actualDays = actualDays + tbDingStatistic.getActualDays();
-                weekdays = weekdays + tbDingStatistic.getWeekdays();
-                weekends = weekends + tbDingStatistic.getWeekends();
-                legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
-                workHours = workHours.add(tbDingStatistic.getWorkHours());
-                violationDays = violationDays + tbDingStatistic.getViolationDays();
-            }
-            DingStatisticByCrmDto dto = new DingStatisticByCrmDto();
-            dto.setServiceName(serviceName);
-            dto.setCrmNo(crmNo);
-            dto.setCrmName(tbCrm.getName());
-            dto.setActualDays(actualDays);
-            dto.setWeekdays(weekdays);
-            dto.setWeekends(weekends);
-            dto.setLegalHolidays(legalHolidays);
-            dto.setWorkHours(workHours.doubleValue());
-            dto.setViolationDays(violationDays);
-            dto.setScanPeriod(scanPeriod);
-            dto.setMarkPaperPeriod(markPaperPeriod);
-            result.add(dto);
-        }
-        return result;
+    public void buildStatisticData() {
+        List<TBDingStatistic> datasource = this.list();
+        tbdingStatisticByPersonService.buildStatisticByPerson(datasource);
+        tbdingStatisticBySopService.buildStatisticBySop(datasource);
+        tbdingStatisticByCrmService.buildStatisticByCrm(datasource);
+        tbdingStatisticByCustomService.buildStatisticByCustom(datasource);
+        tbdingStatisticBySupplierService.buildStatisticBySupplier(datasource);
     }
 
     @Override
-    public List<DingStatisticByCustomDto> findStatisticByCustom(Long serviceId) {
-        List<DingStatisticByCustomDto> result = new ArrayList<>();
-        QueryWrapper<TBDingStatistic> queryWrapper = new QueryWrapper<>();
-        if (serviceId != null) {
-            queryWrapper.lambda().eq(TBDingStatistic::getServiceId, serviceId);
-        }
-        queryWrapper.lambda().isNotNull(TBDingStatistic::getSopNo);
-        List<TBDingStatistic> datasource = this.list(queryWrapper);
-        List<Long> customIdList = datasource.stream().map(TBDingStatistic::getCustomId).distinct().collect(Collectors.toList());
-
-        for (Long customId : customIdList) {
-            List<TBCrmDetail> tbCrmDetailList = tbCrmDetailService.findByServiceIdAndCustomId(serviceId, customId);
-            int scanPeriod = 0;
-            int markPaperPeriod = 0;
-            for (TBCrmDetail tbCrmDetail : tbCrmDetailList) {
-                SopPeriodDto sopPeriodDto = this.findSopPeriod(tbCrmDetail);
-                scanPeriod = scanPeriod + sopPeriodDto.getScanPeriod();
-                markPaperPeriod = markPaperPeriod + sopPeriodDto.getMarkPaperPeriod();
-            }
-
-            List<TBDingStatistic> tbDingStatisticList = datasource.stream().filter(e -> customId.equals(e.getCustomId())).collect(Collectors.toList());
-            String serviceName = "";
-            String customName = sysCustomService.getById(customId).getName();
-            int actualDays = 0;
-            int weekdays = 0;
-            int weekends = 0;
-            int legalHolidays = 0;
-            BigDecimal workHours = new BigDecimal(0);
-            int violationDays = 0;
-
-            for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
-                serviceName = tbDingStatistic.getServiceName();
-                actualDays = actualDays + tbDingStatistic.getActualDays();
-                weekdays = weekdays + tbDingStatistic.getWeekdays();
-                weekends = weekends + tbDingStatistic.getWeekends();
-                legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
-                workHours = workHours.add(tbDingStatistic.getWorkHours());
-                violationDays = violationDays + tbDingStatistic.getViolationDays();
+    public void exportStatisticData(Long serviceId, DingStatisticTypeEnum type) throws IOException {
+        File fileTemp = null;
+        try {
+            fileTemp = SystemConstant.getFileTempVar(SystemConstant.XLSX_PREFIX);
+
+            switch (type) {
+            case BY_PERSON:
+                List<DingStatisticByPersonDto> byPersonData = tbdingStatisticByPersonService.findStatisticByPersonList(
+                        serviceId);
+                EasyExcel.write(fileTemp, TBDeviceDeliveryResult.class).sheet("工时统计-按人员").doWrite(byPersonData);
+                break;
+            case BY_SOP:
+                List<DingStatisticBySopDto> bySopData = tbdingStatisticBySopService.findStatisticBySopList(serviceId);
+                EasyExcel.write(fileTemp, TBDeviceDeliveryResult.class).sheet("工时统计-按sop").doWrite(bySopData);
+                break;
+            case BY_CRM:
+                List<DingStatisticByCrmDto> byCrmData = tbdingStatisticByCrmService.findStatisticByCrmList(serviceId);
+                EasyExcel.write(fileTemp, TBDeviceDeliveryResult.class).sheet("工时统计-按crm").doWrite(byCrmData);
+                break;
+            case BY_CUSTOM:
+                List<DingStatisticByCustomDto> byCustomData = tbdingStatisticByCustomService.findStatisticByCustomList(
+                        serviceId);
+                EasyExcel.write(fileTemp, TBDeviceDeliveryResult.class).sheet("工时统计-按客户").doWrite(byCustomData);
+                break;
+            case BY_SUPPLIER:
+                List<DingStatisticBySupplierDto> bySupplierData = tbdingStatisticBySupplierService.findStatisticBySupplierList(
+                        serviceId);
+                EasyExcel.write(fileTemp, TBDeviceDeliveryResult.class).sheet("工时统计-按供应商").doWrite(bySupplierData);
+                break;
+            default:
+                break;
             }
-            DingStatisticByCustomDto dto = new DingStatisticByCustomDto();
-            dto.setServiceName(serviceName);
-            dto.setCustomName(customName);
-            dto.setActualDays(actualDays);
-            dto.setWeekdays(weekdays);
-            dto.setWeekends(weekends);
-            dto.setLegalHolidays(legalHolidays);
-            dto.setWorkHours(workHours.doubleValue());
-            dto.setViolationDays(violationDays);
-            dto.setScanPeriod(scanPeriod);
-            dto.setMarkPaperPeriod(markPaperPeriod);
-            result.add(dto);
-        }
-        return result;
-    }
-
-    @Override
-    public List<DingStatisticBySupplierDto> findStatisticBySupplier(Long serviceId) {
-        List<DingStatisticBySupplierDto> result = new ArrayList<>();
-        QueryWrapper<TBDingStatistic> queryWrapper = new QueryWrapper<>();
-        if (serviceId != null) {
-            queryWrapper.lambda().eq(TBDingStatistic::getServiceId, serviceId);
-        }
-        List<TBDingStatistic> datasource = this.list(queryWrapper);
-        List<Long> supplierIdList = datasource.stream().map(TBDingStatistic::getSupplierId).distinct().collect(Collectors.toList());
-
-        for (Long supplierId : supplierIdList) {
-            List<TBDingStatistic> tbDingStatisticList = datasource.stream().filter(e -> supplierId.equals(e.getSupplierId())).collect(Collectors.toList());
-            String serviceName = "";
-            String supplierName = sysSupplierService.getById(supplierId).getName();
-            int actualDays = 0;
-            int weekdays = 0;
-            int weekends = 0;
-            int legalHolidays = 0;
-            BigDecimal workHours = new BigDecimal(0);
-            int violationDays = 0;
-
-            for (TBDingStatistic tbDingStatistic : tbDingStatisticList) {
-                serviceName = tbDingStatistic.getServiceName();
-                actualDays = actualDays + tbDingStatistic.getActualDays();
-                weekdays = weekdays + tbDingStatistic.getWeekdays();
-                weekends = weekends + tbDingStatistic.getWeekends();
-                legalHolidays = legalHolidays + tbDingStatistic.getLegalHolidays();
-                workHours = workHours.add(tbDingStatistic.getWorkHours());
-                violationDays = violationDays + tbDingStatistic.getViolationDays();
+            HttpServletResponse response = ServletUtil.getResponse();
+            FileUtil.outputFile(response, fileTemp, "工时统计结果.xlsx");
+        } finally {
+            if (Objects.nonNull(fileTemp)) {
+                fileTemp.delete();
             }
-            DingStatisticBySupplierDto dto = new DingStatisticBySupplierDto();
-            dto.setServiceName(serviceName);
-            dto.setSupplierName(supplierName);
-            dto.setActualDays(actualDays);
-            dto.setWeekdays(weekdays);
-            dto.setWeekends(weekends);
-            dto.setLegalHolidays(legalHolidays);
-            dto.setWorkHours(workHours.doubleValue());
-            dto.setViolationDays(violationDays);
-            result.add(dto);
         }
-        return result;
     }
 
     /**
@@ -688,7 +539,8 @@ public class TBDingStatisticServiceImpl extends ServiceImpl<TBDingStatisticMappe
      * @param tbCrmDetail 派单详情
      * @return 结果
      */
-    private SopPeriodDto findSopPeriod(TBCrmDetail tbCrmDetail) {
+    @Override
+    public SopPeriodDto findSopPeriod(TBCrmDetail tbCrmDetail) {
         Long scanActualStartTime = tbCrmDetail.getScanActualStartTime();
         Long scanActualEndTime = tbCrmDetail.getScanActualEndTime();
         Long markPaperActualStartTime = tbCrmDetail.getMarkPaperActualStartTime();

+ 103 - 0
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -64,3 +64,106 @@ SET
             tbds.service_id = tbs.id)
 WHERE
     service_name IS NULL;
+
+-- 2024-09-09
+CREATE TABLE t_b_ding_statistic_by_person (
+  id BIGINT NOT NULL,
+  service_id BIGINT NOT NULL COMMENT '服务单元id',
+  service_name VARCHAR(100) NULL COMMENT '服务单元名称',
+  user_info VARCHAR(100) NULL COMMENT '姓名(人员档案号)',
+  supplier_name VARCHAR(100) NULL COMMENT '供应商',
+  actual_days INT NULL COMMENT '实际出勤(天)',
+  weekdays INT NULL COMMENT '工作日(天)',
+  weekends INT NULL COMMENT '周末(天)',
+  legal_holidays INT NULL COMMENT '法定节假日(天)',
+  work_hours DECIMAL(8,2) NULL COMMENT '累计工时(小时)',
+  violation_days INT NULL COMMENT '违规工时(天)',
+  create_id BIGINT NULL COMMENT '创建人id',
+  create_time BIGINT NULL COMMENT '创建时间',
+  update_id BIGINT NULL COMMENT '更新人id',
+  update_time BIGINT NULL COMMENT '更新时间',
+  PRIMARY KEY (id))
+COMMENT = '工时统计-按人员统计';
+
+CREATE TABLE t_b_ding_statistic_by_sop (
+  id BIGINT NOT NULL,
+  service_id BIGINT NOT NULL COMMENT '服务单元id',
+  service_name VARCHAR(100) NULL COMMENT '服务单元名称',
+  sop_no VARCHAR(100) NULL COMMENT 'sop流水号',
+  course_name VARCHAR(100) NULL COMMENT '科目名称',
+  actual_days INT NULL COMMENT '实际出勤(天)',
+  weekdays INT NULL COMMENT '工作日(天)',
+  weekends INT NULL COMMENT '周末(天)',
+  legal_holidays INT NULL COMMENT '法定节假日(天)',
+  scan_period INT NULL COMMENT '扫描周期(天)',
+  mark_paper_period INT NULL COMMENT '阅卷周期(天)',
+  work_hours DECIMAL(8,2) NULL COMMENT '累计工时(小时)',
+  violation_days INT NULL COMMENT '违规工时(天)',
+  create_id BIGINT NULL COMMENT '创建人id',
+  create_time BIGINT NULL COMMENT '创建时间',
+  update_id BIGINT NULL COMMENT '更新人id',
+  update_time BIGINT NULL COMMENT '更新时间',
+  PRIMARY KEY (id))
+COMMENT = '工时统计-按sop统计';
+
+CREATE TABLE t_b_ding_statistic_by_crm (
+  id BIGINT NOT NULL,
+  service_id BIGINT NOT NULL COMMENT '服务单元id',
+  service_name VARCHAR(100) NULL COMMENT '服务单元名称',
+  crm_no VARCHAR(100) NULL COMMENT '派单号',
+  crm_name VARCHAR(100) NULL COMMENT '派单名称',
+  actual_days INT NULL COMMENT '实际出勤(天)',
+  weekdays INT NULL COMMENT '工作日(天)',
+  weekends INT NULL COMMENT '周末(天)',
+  legal_holidays INT NULL COMMENT '法定节假日(天)',
+  scan_period INT NULL COMMENT '扫描周期(天)',
+  mark_paper_period INT NULL COMMENT '阅卷周期(天)',
+  work_hours DECIMAL(8,2) NULL COMMENT '累计工时(小时)',
+  violation_days INT NULL COMMENT '违规工时(天)',
+  create_id BIGINT NULL COMMENT '创建人id',
+  create_time BIGINT NULL COMMENT '创建时间',
+  update_id BIGINT NULL COMMENT '更新人id',
+  update_time BIGINT NULL COMMENT '更新时间',
+  PRIMARY KEY (id))
+COMMENT = '工时统计-按派单统计';
+
+CREATE TABLE t_b_ding_statistic_by_custom (
+  id BIGINT NOT NULL,
+  service_id BIGINT NOT NULL COMMENT '服务单元id',
+  service_name VARCHAR(100) NULL COMMENT '服务单元名称',
+  custom_id BIGINT NULL COMMENT '客户id',
+  custom_name VARCHAR(100) NULL COMMENT '客户名称',
+  actual_days INT NULL COMMENT '实际出勤(天)',
+  weekdays INT NULL COMMENT '工作日(天)',
+  weekends INT NULL COMMENT '周末(天)',
+  legal_holidays INT NULL COMMENT '法定节假日(天)',
+  scan_period INT NULL COMMENT '扫描周期(天)',
+  mark_paper_period INT NULL COMMENT '阅卷周期(天)',
+  work_hours DECIMAL(8,2) NULL COMMENT '累计工时(小时)',
+  violation_days INT NULL COMMENT '违规工时(天)',
+  create_id BIGINT NULL COMMENT '创建人id',
+  create_time BIGINT NULL COMMENT '创建时间',
+  update_id BIGINT NULL COMMENT '更新人id',
+  update_time BIGINT NULL COMMENT '更新时间',
+  PRIMARY KEY (id))
+COMMENT = '工时统计-按客户统计';
+
+CREATE TABLE t_b_ding_statistic_by_supplier (
+  id BIGINT NOT NULL,
+  service_id BIGINT NOT NULL COMMENT '服务单元id',
+  service_name VARCHAR(100) NULL COMMENT '服务单元名称',
+  supplier_id BIGINT NULL COMMENT '供应商id',
+  supplier_name VARCHAR(100) NULL COMMENT '供应商名称',
+  actual_days INT NULL COMMENT '实际出勤(天)',
+  weekdays INT NULL COMMENT '工作日(天)',
+  weekends INT NULL COMMENT '周末(天)',
+  legal_holidays INT NULL COMMENT '法定节假日(天)',
+  work_hours DECIMAL(8,2) NULL COMMENT '累计工时(小时)',
+  violation_days INT NULL COMMENT '违规工时(天)',
+  create_id BIGINT NULL COMMENT '创建人id',
+  create_time BIGINT NULL COMMENT '创建时间',
+  update_id BIGINT NULL COMMENT '更新人id',
+  update_time BIGINT NULL COMMENT '更新时间',
+  PRIMARY KEY (id))
+COMMENT = '工时统计-按供应商统计';
+

+ 50 - 0
sop-business/src/main/resources/mapper/TBDingStatisticByCrmMapper.xml

@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmth.sop.business.mapper.TBDingStatisticByCrmMapper">
+    <update id="truncateTable">
+        TRUNCATE TABLE t_b_ding_statistic_by_crm
+    </update>
+
+    <select id="findStatisticByCrmList" resultType="com.qmth.sop.business.bean.dto.DingStatisticByCrmDto">
+        SELECT
+            service_name AS serviceName,
+            crm_no AS crmNo,
+            crm_name AS crmName,
+            actual_days AS actualDays,
+            weekdays,
+            weekends,
+            legal_holidays AS legalHolidays,
+            scan_period AS scanPeriod,
+            mark_paper_period AS markPaperPeriod,
+            work_hours AS workHours,
+            violation_days AS violationDays
+        FROM
+            t_b_ding_statistic_by_crm
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+    <select id="findStatisticByCrmPage" resultType="com.qmth.sop.business.bean.dto.DingStatisticByCrmDto">
+        SELECT
+            service_name AS serviceName,
+            crm_no AS crmNo,
+            crm_name AS crmName,
+            actual_days AS actualDays,
+            weekdays,
+            weekends,
+            legal_holidays AS legalHolidays,
+            scan_period AS scanPeriod,
+            mark_paper_period AS markPaperPeriod,
+            work_hours AS workHours,
+            violation_days AS violationDays
+        FROM
+            t_b_ding_statistic_by_crm
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 50 - 0
sop-business/src/main/resources/mapper/TBDingStatisticByCustomMapper.xml

@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmth.sop.business.mapper.TBDingStatisticByCustomMapper">
+    <update id="truncateTable">
+        TRUNCATE TABLE t_b_ding_statistic_by_custom
+    </update>
+
+    <select id="findStatisticByCustomList"
+            resultType="com.qmth.sop.business.bean.dto.DingStatisticByCustomDto">
+        SELECT
+            service_name AS serviceName,
+            custom_name AS customName,
+            actual_days AS actualDays,
+            weekdays,
+            weekends,
+            legal_holidays AS legalHolidays,
+            scan_period AS scanPeriod,
+            mark_paper_period AS markPaperPeriod,
+            work_hours AS workHours,
+            violation_days AS violationDays
+        FROM
+            t_b_ding_statistic_by_custom
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+    <select id="findStatisticByCustomPage"
+            resultType="com.qmth.sop.business.bean.dto.DingStatisticByCustomDto">
+        SELECT
+            service_name AS serviceName,
+            custom_name AS customName,
+            actual_days AS actualDays,
+            weekdays,
+            weekends,
+            legal_holidays AS legalHolidays,
+            scan_period AS scanPeriod,
+            mark_paper_period AS markPaperPeriod,
+            work_hours AS workHours,
+            violation_days AS violationDays
+        FROM
+            t_b_ding_statistic_by_custom
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 48 - 0
sop-business/src/main/resources/mapper/TBDingStatisticByPersonMapper.xml

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmth.sop.business.mapper.TBDingStatisticByPersonMapper">
+    <update id="truncateTable">
+        TRUNCATE TABLE t_b_ding_statistic_by_person;
+    </update>
+
+    <select id="findStatisticByPersonList"
+            resultType="com.qmth.sop.business.bean.dto.DingStatisticByPersonDto">
+        SELECT
+            service_name AS serviceName,
+            user_info AS userInfo,
+            supplier_name AS supplierName,
+            actual_days AS actualDays,
+            weekdays,
+            weekends,
+            legal_holidays AS legalHolidays,
+            work_hours AS workHours,
+            violation_days AS violationDays
+        FROM
+            t_b_ding_statistic_by_person
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+    <select id="findStatisticByPersonPage"
+            resultType="com.qmth.sop.business.bean.dto.DingStatisticByPersonDto">
+        SELECT
+            service_name as serviceName,
+            user_info as userInfo,
+            supplier_name as supplierName,
+            actual_days as actualDays,
+            weekdays,
+            weekends,
+            legal_holidays as legalHolidays,
+            work_hours as workHours,
+            violation_days as violationDays
+        FROM
+            t_b_ding_statistic_by_person
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 50 - 0
sop-business/src/main/resources/mapper/TBDingStatisticBySopMapper.xml

@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmth.sop.business.mapper.TBDingStatisticBySopMapper">
+    <update id="truncateTable">
+        TRUNCATE TABLE t_b_ding_statistic_by_sop;
+    </update>
+
+    <select id="findStatisticBySopList" resultType="com.qmth.sop.business.bean.dto.DingStatisticBySopDto">
+        SELECT
+            service_name AS serviceName,
+            sop_no AS sopNo,
+            course_name AS courseName,
+            actual_days AS actualDays,
+            weekdays,
+            weekends,
+            legal_holidays AS legalHolidays,
+            scan_period AS scanPeriod,
+            mark_paper_period AS markPaperPeriod,
+            work_hours AS workHours,
+            violation_days AS violationDays
+        FROM
+            t_b_ding_statistic_by_sop
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+    <select id="findStatisticBySopPage" resultType="com.qmth.sop.business.bean.dto.DingStatisticBySopDto">
+        SELECT
+            service_name AS serviceName,
+            sop_no AS sopNo,
+            course_name AS courseName,
+            actual_days AS actualDays,
+            weekdays,
+            weekends,
+            legal_holidays AS legalHolidays,
+            scan_period AS scanPeriod,
+            mark_paper_period AS markPaperPeriod,
+            work_hours AS workHours,
+            violation_days AS violationDays
+        FROM
+            t_b_ding_statistic_by_sop;
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 46 - 0
sop-business/src/main/resources/mapper/TBDingStatisticBySupplierMapper.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmth.sop.business.mapper.TBDingStatisticBySupplierMapper">
+    <update id="truncateTable">
+        TRUNCATE TABLE t_b_ding_statistic_by_supplier
+    </update>
+
+    <select id="findStatisticBySupplierList"
+            resultType="com.qmth.sop.business.bean.dto.DingStatisticBySupplierDto">
+        SELECT
+            service_name AS serviceName,
+            supplier_name AS supplierName,
+            actual_days AS actualDays,
+            weekdays,
+            weekends,
+            legal_holidays AS legalHolidays,
+            work_hours AS workHours,
+            violation_days AS violationDays
+        FROM
+            t_b_ding_statistic_by_supplier
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+    <select id="findStatisticBySupplierPage"
+            resultType="com.qmth.sop.business.bean.dto.DingStatisticBySupplierDto">
+        SELECT
+            service_name AS serviceName,
+            supplier_name AS supplierName,
+            actual_days AS actualDays,
+            weekdays,
+            weekends,
+            legal_holidays AS legalHolidays,
+            work_hours AS workHours,
+            violation_days AS violationDays
+        FROM
+            t_b_ding_statistic_by_supplier
+        <where>
+            <if test="serviceId != null">
+                AND service_id = #{serviceId}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 20 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/DingStatisticTypeEnum.java

@@ -0,0 +1,20 @@
+package com.qmth.sop.common.enums;
+
+/**
+ * @Description: 工时统计类型
+ * @Author: CaoZixuan
+ * @Date: 2024-09-09
+ */
+public enum DingStatisticTypeEnum {
+    BY_PERSON("按人员统计"), BY_SOP("按sop统计"), BY_CRM("按crm统计"), BY_CUSTOM("按客户统计"), BY_SUPPLIER("按供应商统计");
+
+    private final String title;
+
+    DingStatisticTypeEnum(String title) {
+        this.title = title;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+}

+ 1 - 0
sop-task/src/main/java/com/qmth/sop/task/job/service/impl/JobServiceImpl.java

@@ -308,5 +308,6 @@ public class JobServiceImpl implements JobService {
     @Override
     public void dingStatistic() {
         tbDingStatisticService.buildDingStatistic();
+        tbDingStatisticService.buildStatisticData();
     }
 }