Parcourir la source

add: 考勤统计

caozixuan il y a 1 an
Parent
commit
6213b04a93

+ 3 - 3
sop-business/src/main/java/com/qmth/sop/business/bean/dto/DingSubmitExportDto.java

@@ -77,7 +77,7 @@ public class DingSubmitExportDto {
 
     @ExcelProperty(value = "违规工时(天)")
     @ApiModelProperty(value = "违规工时(天)")
-    private Double violationDays;
+    private Integer violationDays;
 
     @ExcelProperty(value = "考勤异常数")
     @ApiModelProperty(value = "考勤异常数")
@@ -223,11 +223,11 @@ public class DingSubmitExportDto {
         this.workHours = workHours;
     }
 
-    public Double getViolationDays() {
+    public Integer getViolationDays() {
         return violationDays;
     }
 
-    public void setViolationDays(Double violationDays) {
+    public void setViolationDays(Integer violationDays) {
         this.violationDays = violationDays;
     }
 

+ 3 - 3
sop-business/src/main/java/com/qmth/sop/business/bean/result/DingSubmitResult.java

@@ -83,7 +83,7 @@ public class DingSubmitResult {
     private Double workHours;
 
     @ApiModelProperty(value = "违规工时(天)")
-    private Double violationDays;
+    private Integer violationDays;
 
     @ApiModelProperty(value = "考勤异常数")
     private Integer dingExceptionCount;
@@ -291,11 +291,11 @@ public class DingSubmitResult {
         this.workHours = workHours;
     }
 
-    public Double getViolationDays() {
+    public Integer getViolationDays() {
         return violationDays;
     }
 
-    public void setViolationDays(Double violationDays) {
+    public void setViolationDays(Integer violationDays) {
         this.violationDays = violationDays;
     }
 

+ 4 - 4
sop-business/src/main/java/com/qmth/sop/business/entity/TBDing.java

@@ -46,7 +46,7 @@ public class TBDing extends BaseEntity implements Serializable {
     private RoleTypeEnum roleType;
 
     @ApiModelProperty("sop角色类型")
-    private SopRoleTypeEnum sopRoleType;
+    private String sopRoleType;
 
     @ApiModelProperty(value = "用户id")
     @JsonSerialize(using = ToStringSerializer.class)
@@ -106,7 +106,7 @@ public class TBDing extends BaseEntity implements Serializable {
 
     }
 
-    public TBDing(String sopNo, String crmNo, Long serviceId, Long userArchivesId, SopRoleTypeEnum sopRoleType, Long userId, Long flowId) {
+    public TBDing(String sopNo, String crmNo, Long serviceId, Long userArchivesId, String sopRoleType, Long userId, Long flowId) {
         setId(SystemConstant.getDbUuid());
         this.sopNo = sopNo;
         this.dingSopNo = sopNo;
@@ -168,11 +168,11 @@ public class TBDing extends BaseEntity implements Serializable {
         this.roleType = roleType;
     }
 
-    public SopRoleTypeEnum getSopRoleType() {
+    public String getSopRoleType() {
         return sopRoleType;
     }
 
-    public void setSopRoleType(SopRoleTypeEnum sopRoleType) {
+    public void setSopRoleType(String sopRoleType) {
         this.sopRoleType = sopRoleType;
     }
 

+ 10 - 11
sop-business/src/main/java/com/qmth/sop/business/entity/TBDingStatistic.java

@@ -3,7 +3,6 @@ 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 com.qmth.sop.common.enums.SopRoleTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -48,8 +47,8 @@ public class TBDingStatistic extends BaseEntity {
     @ApiModelProperty(value = "阅卷开始时间")
     private Long markPaperEndTime;
 
-    @ApiModelProperty(value = "项目角色类型")
-    private SopRoleTypeEnum roleType;
+    @ApiModelProperty(value = "打卡时该用户在sop的身份集合")
+    private String sopRoleType;
 
     @ApiModelProperty(value = "实际出勤(天)")
     private Integer actualDays;
@@ -66,8 +65,8 @@ public class TBDingStatistic extends BaseEntity {
     @ApiModelProperty(value = "累计工时(小时)")
     private BigDecimal workHours;
 
-    @ApiModelProperty(value = "违规工时")
-    private BigDecimal violationDays;
+    @ApiModelProperty(value = "违规天数(天)")
+    private Integer violationDays;
 
     @ApiModelProperty(value = "提交人id")
     @JsonSerialize(using = ToStringSerializer.class)
@@ -143,12 +142,12 @@ public class TBDingStatistic extends BaseEntity {
         this.markPaperEndTime = markPaperEndTime;
     }
 
-    public SopRoleTypeEnum getRoleType() {
-        return roleType;
+    public String getSopRoleType() {
+        return sopRoleType;
     }
 
-    public void setRoleType(SopRoleTypeEnum roleType) {
-        this.roleType = roleType;
+    public void setSopRoleType(String sopRoleType) {
+        this.sopRoleType = sopRoleType;
     }
 
     public Integer getActualDays() {
@@ -191,11 +190,11 @@ public class TBDingStatistic extends BaseEntity {
         this.workHours = workHours;
     }
 
-    public BigDecimal getViolationDays() {
+    public Integer getViolationDays() {
         return violationDays;
     }
 
-    public void setViolationDays(BigDecimal violationDays) {
+    public void setViolationDays(Integer violationDays) {
         this.violationDays = violationDays;
     }
 

+ 4 - 4
sop-business/src/main/java/com/qmth/sop/business/entity/TBDingSubmit.java

@@ -58,8 +58,8 @@ public class TBDingSubmit extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "累计工时(小时)")
     private Double workHours;
 
-    @ApiModelProperty(value = "违规工时")
-    private Double violationDays;
+    @ApiModelProperty(value = "违规天数(天)")
+    private Integer violationDays;
 
     @ApiModelProperty(value = "提交人id")
     @JsonSerialize(using = ToStringSerializer.class)
@@ -167,11 +167,11 @@ public class TBDingSubmit extends BaseEntity implements Serializable {
         this.workHours = workHours;
     }
 
-    public Double getViolationDays() {
+    public Integer getViolationDays() {
         return violationDays;
     }
 
-    public void setViolationDays(Double violationDays) {
+    public void setViolationDays(Integer violationDays) {
         this.violationDays = violationDays;
     }
 

+ 0 - 1
sop-business/src/main/java/com/qmth/sop/business/service/TBDingService.java

@@ -8,7 +8,6 @@ import com.qmth.sop.business.bean.result.*;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBDing;
 import com.qmth.sop.common.enums.DingResultEnum;
-import com.qmth.sop.common.enums.DingSubmitStatusEnum;
 import com.qmth.sop.common.enums.InOutTypeEnum;
 
 import java.io.IOException;

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBDingStatisticService.java

@@ -13,4 +13,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface TBDingStatisticService extends IService<TBDingStatistic> {
 
+    /**
+     * 构建考勤统计 (sop计划时间变更 -> 更新打卡统计时间)
+     *
+     * @param sopNo sopNo
+     */
+    void buildDingStatistic(String sopNo);
+
+    /**
+     * 构建考勤统计 (构建打卡统计信息)
+     */
+    void buildDingStatistic();
 }

+ 2 - 2
sop-business/src/main/java/com/qmth/sop/business/service/TBUserArchivesAllocationService.java

@@ -98,10 +98,10 @@ public interface TBUserArchivesAllocationService extends IService<TBUserArchives
      * 查询用户在某派单中执行的工程师
      *
      * @param userId 用户id
-     * @param crmNo  派单号
+     * @param sopNo  sopNo
      * @return 角色
      */
-    SopRoleTypeEnum findRoleTypeByUserCrm(Long userId, String crmNo);
+    List<SopRoleTypeEnum> findSopRoleTypeByUserSopNo(Long userId, String sopNo);
 
     /**
      * 查询派单详情中可以分配的人员

+ 7 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.qmth.sop.business.service.impl;
 
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -351,9 +352,13 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
 
                 TBUserArchives tbUserArchives = tbUserArchivesService.getOne(new QueryWrapper<TBUserArchives>().lambda()
                         .eq(TBUserArchives::getMobileNumber, sysUser.getMobileNumber()));
+
+                List<SopRoleTypeEnum> roleType = tbUserArchivesAllocationService.findSopRoleTypeByUserSopNo(sysUser.getId(), tbDingApply.getSopNo());
+                if (org.apache.commons.collections4.CollectionUtils.isEmpty(roleType)){
+                    throw ExceptionResultEnum.ERROR.exception("未找到用户在当前sop的身份信息");
+                }
                 tbDing = new TBDing(tbDingApply.getSopNo(), tbDingApply.getCrmNo(), tbCrm.getServiceId(),
-                        tbUserArchives.getId(),
-                        tbUserArchivesAllocationService.findRoleTypeByUserCrm(sysUser.getId(), tbCrm.getCrmNo()),
+                        tbUserArchives.getId(), JSON.toJSONString(roleType),
                         sysUser.getId(), tfCustomFlowEntity.getFlowId());
                 tbDing.setSignDate(
                         DateFormatUtils.format(tbDingApply.getApplyTime(), SystemConstant.DEFAULT_DATE_DAY_PATTERN));

+ 23 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.sop.business.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -88,6 +89,9 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
     @Resource
     private TBUserArchivesAllocationService tbUserArchivesAllocationService;
 
+    @Resource
+    private TBCrmDetailService tbCrmDetailService;
+
     @Override
     public DingElementResult findDingElements(String sopNo, Long userId) {
 
@@ -304,8 +308,6 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
 
         Long signTime = dingSaveParam.getSignTime();
         SopPlanTimeResult sopPlan = tbSopInfoService.querySopPlanTime(sopNo);
-        // 打卡异常
-        boolean dingException = !(sopPlan.getBeginTime() <= signTime && signTime <= sopPlan.getEndTime());
 
         DingDateTypeEnum dateType = sysDingDateService.getDingDateType(DateDisposeUtils.timestampToLocalDate(signTime));
 
@@ -349,7 +351,10 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
         String crmNo = sopCrmInfo.getCrmNo();
         Long serviceId = sopCrmInfo.getServiceUnitId();
         Long flowId = sopCrmInfo.getFlowId();
-        SopRoleTypeEnum roleType = tbUserArchivesAllocationService.findRoleTypeByUserCrm(userId, crmNo);
+        List<SopRoleTypeEnum> roleType = tbUserArchivesAllocationService.findSopRoleTypeByUserSopNo(userId, sopNo);
+        if (CollectionUtils.isEmpty(roleType)) {
+            throw ExceptionResultEnum.ERROR.exception("未找到用户在当前sop的身份信息");
+        }
         String signDate = DateFormatUtils.format(signTime, SystemConstant.DEFAULT_DATE_DAY_PATTERN);
         String signYear = DateFormatUtils.format(signTime, SystemConstant.DEFAULT_DATE_YEAR_PATTERN);
         String currentDayStr = DateFormatUtils.format(System.currentTimeMillis(), SystemConstant.DEFAULT_DATE_DAY_PATTERN);
@@ -388,13 +393,12 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
             tbDing.setCrmNo(crmNo);
             tbDing.setServiceId(serviceId);
             tbDing.setUserArchivesId(userArchivesId);
-            tbDing.setSopRoleType(roleType);
+            tbDing.setSopRoleType(JSON.toJSONString(roleType));
             tbDing.setUserId(userId);
             tbDing.setFlowId(flowId);
             tbDing.setSignDate(signDate);
             tbDing.setSignYear(signYear);
             tbDing.setDateType(dateType);
-            tbDing.setDingException(dingException);
             switch (signType) {
             case IN: // 签到打卡
                 tbDing.setSignInTime(signTime);
@@ -418,7 +422,6 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
                 throw ExceptionResultEnum.ERROR.exception(String.format("用户id为[%s],sop单号为[%s],在[%s]的打卡记录异常", userId, sopNo, signDate));
             }
             TBDing tbDing = tbDingList.get(0);
-            tbDing.setDingException(tbDing.getDingException() && dingException);
             switch (signType) {
             case IN: // 签到打卡
                 tbDing.setSignInTime(signTime);
@@ -435,6 +438,14 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
                 tbDing.setFaceOutPass(facePass);
                 break;
             }
+            Long signInTime = tbDing.getSignInTime();
+            Long signOutTime = tbDing.getSignOutTime();
+            if (signInTime != null && signInTime > 0 && signOutTime != null && signOutTime > 0) {
+                // 打卡异常 (两个打卡时间均不在时间点 -> 异常)
+                boolean signInException = !(sopPlan.getBeginTime() <= signInTime && signInTime <= sopPlan.getEndTime());
+                boolean signOutException = !(sopPlan.getBeginTime() <= signOutTime && signOutTime <= sopPlan.getEndTime());
+                tbDing.setDingException(signInException && signOutException);
+            }
             this.updateById(tbDing);
         }
     }
@@ -670,7 +681,12 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
                         addDing.setServiceId(tbCrm.getServiceId());
                         addDing.setUserId(userId);
                         addDing.setUserArchivesId(tbUserArchivesService.findByUserId(userId).getId());
-                        addDing.setSopRoleType(tbUserArchivesAllocationService.findRoleTypeByUserCrm(userId, crmNo));
+                        List<SopRoleTypeEnum> roleType = tbUserArchivesAllocationService.findSopRoleTypeByUserSopNo(
+                                userId, sopNo);
+                        if (CollectionUtils.isEmpty(roleType)) {
+                            throw ExceptionResultEnum.ERROR.exception("未找到用户在当前sop的身份信息");
+                        }
+                        addDing.setSopRoleType(JSON.toJSONString(roleType));
                         addDing.setFlowId(sopCrmInfo.getFlowId());
                         addDing.setSignYear(signYear);
                         addDing.setSignDate(signDay);

+ 127 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingStatisticServiceImpl.java

@@ -1,11 +1,30 @@
 package com.qmth.sop.business.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.entity.TBCrm;
+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.business.mapper.TBDingStatisticMapper;
-import com.qmth.sop.business.service.TBDingStatisticService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+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.ExceptionResultEnum;
+import com.qmth.sop.common.enums.SopRoleTypeEnum;
+import io.swagger.models.auth.In;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
 /**
  * <p>
  * 考勤提交统计表 服务实现类
@@ -16,5 +35,111 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class TBDingStatisticServiceImpl extends ServiceImpl<TBDingStatisticMapper, TBDingStatistic> implements TBDingStatisticService {
+    private final static Logger log = LoggerFactory.getLogger(TBDingStatisticServiceImpl.class);
+
+    @Resource
+    private TBCrmDetailService tbCrmDetailService;
+
+    @Resource
+    private TBDingService tbDingService;
+
+    @Resource
+    private TBCrmService tbCrmService;
+
+    @Resource
+    private SysUserService sysUserService;
+
+    @Resource
+    private TBUserArchivesAllocationService tbUserArchivesAllocationService;
+
+    @Override
+    public void buildDingStatistic(String sopNo) {
+
+    }
+
+    @Override
+    public void buildDingStatistic() {
+
+        List<TBDing> datasource = tbDingService.list();
+        List<String> sopNoList = datasource.stream().map(TBDing::getSopNo).distinct().collect(Collectors.toList());
+
+        for (String sopNo : sopNoList) {
+            TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
+            if (Objects.isNull(tbCrmDetail)){
+                log.error(String.format("sopNo[%s]未找到派单详情信息",sopNo));
+                throw ExceptionResultEnum.ERROR.exception("未找到派单详情信息");
+            }
+            
+            String crmNo = tbCrmDetail.getCrmNo();
+            TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
+            if (Objects.isNull(tbCrm)){
+                log.error(String.format("crmNo[%s]未找到派单信息",crmNo));
+                throw ExceptionResultEnum.ERROR.exception("未找到派单信息");
+            }
+
+            Long serviceUnitId = tbCrm.getServiceId();
+
+
+            Long scanStartTime = tbCrmDetail.getScanStartTime();
+            Long scanEndTime = tbCrmDetail.getScanEndTime();
+            Long markPaperStartTime = tbCrmDetail.getMarkPaperStartTime();
+            Long markPaperEndTime = tbCrmDetail.getMarkPaperEndTime();
+            // 该sop计划有效的日期
+            
+            
+            List<Long> userArchivesIdList = datasource.stream().filter(e -> Objects.equals(sopNo, e.getSopNo())).map(TBDing::getUserArchivesId).distinct().collect(Collectors.toList());
+
+            for (Long archivesId : userArchivesIdList) {
+                // 打卡数据集合
+                List<TBDing> dingList = datasource.stream()
+                        .filter(e -> Objects.equals(sopNo, e.getSopNo()) && Objects.equals(archivesId, e.getUserArchivesId())).collect(Collectors.toList());
+
+                // 非异常打卡(打卡时间在计划时间范围内 以及 缺少签到或签退的)
+                List<TBDing> effectDingList = dingList.stream().filter(e -> !e.getDingException()).collect(Collectors.toList());
+
+                List<SopRoleTypeEnum> sopRoleTypeList = dingList.stream().flatMap(e -> {
+                    String sopRoleTypeStr = e.getSopRoleType();
+                    List<SopRoleTypeEnum> list = JSONArray.parseArray(sopRoleTypeStr, SopRoleTypeEnum.class);
+                    return list.stream();
+                }).distinct().collect(Collectors.toList());
+                String sopRoleType = JSON.toJSONString(sopRoleTypeList);
 
+                // 根据非异常打卡数据统计
+                int actualDays = 0;
+                int weekDays = 0;
+                int weekends = 0;
+                int legalHolidays = 0;
+                BigDecimal workHours = BigDecimal.ZERO;
+                BigDecimal var = new BigDecimal(3600000);
+                for (TBDing effectDing : effectDingList) {
+                    if (!SystemConstant.isOneNull(effectDing.getSignInTime(), effectDing.getSignOutTime())){
+                        // 有效天数
+                        actualDays ++;
+                        DingDateTypeEnum dateType = effectDing.getDateType();
+                        switch (dateType){
+                            case WEEKEND:
+                                weekends ++;
+                                break;
+                            case LEGAL_HOLIDAYS:
+                                legalHolidays ++;
+                                break;
+                            default:
+                                weekDays ++;
+                                break;
+                        }
+                        // 累计工时
+                        workHours = workHours.add(new BigDecimal(effectDing.getSignOutTime() - effectDing.getSignInTime()).divide(var, 1,
+                                RoundingMode.HALF_UP));
+                    }
+                }
+                // 违规工时
+                int violationDays = Math.toIntExact(
+                        dingList.stream().filter(e -> SystemConstant.isOneNull(e.getSignInTime(), e.getSignOutTime()))
+                                .count());
+                
+                TBDingStatistic tbDingStatistic = new TBDingStatistic();
+                // TODO: 2024/5/23 新增实体对象-czx 
+            }
+        }
+    }
 }

+ 10 - 6
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesAllocationServiceImpl.java

@@ -509,14 +509,18 @@ public class TBUserArchivesAllocationServiceImpl
     }
 
     @Override
-    public SopRoleTypeEnum findRoleTypeByUserCrm(Long userId, String crmNo) {
-        SopRoleTypeEnum result = null;
+    public List<SopRoleTypeEnum> findSopRoleTypeByUserSopNo(Long userId, String sopNo) {
+        TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
+        if (Objects.isNull(tbCrmDetail)) {
+            throw ExceptionResultEnum.ERROR.exception(String.format("未找到sop[%s]", sopNo));
+        }
         List<TBUserArchivesAllocation> tbUserArchivesAllocationList = this.list(
                 new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getUserId, userId)
-                        .eq(TBUserArchivesAllocation::getCrmNo, crmNo));
-        if (!org.springframework.util.CollectionUtils.isEmpty(tbUserArchivesAllocationList)) {
-            TBUserArchivesAllocation tbUserArchivesAllocation = tbUserArchivesAllocationList.get(0);
-            result = tbUserArchivesAllocation.getSopRoleType();
+                        .eq(TBUserArchivesAllocation::getCrmDetailId, tbCrmDetail.getId()));
+
+        List<SopRoleTypeEnum> result = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(tbUserArchivesAllocationList)) {
+            result = tbUserArchivesAllocationList.stream().map(TBUserArchivesAllocation::getSopRoleType).collect(Collectors.toList());
         }
         return result;
     }

+ 13 - 1
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -126,4 +126,16 @@ CREATE TABLE `t_b_ding_statistic` (
     `update_time` bigint DEFAULT NULL COMMENT '更新时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `t_b_ding_statistic_un` (`sop_no`,`user_archives_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='考勤提交统计表';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='考勤提交统计表';
+
+-- 2024-05-23
+ALTER TABLE t_b_ding
+    CHANGE COLUMN sop_role_type sop_role_type VARCHAR(100) NOT NULL COMMENT '打卡时该用户在sop的身份集合' ;
+
+ALTER TABLE t_b_ding_statistic
+    CHANGE COLUMN role_type sop_role_type VARCHAR(100) NOT NULL COMMENT '打卡时该用户在sop的身份集合' ;
+
+ALTER TABLE t_b_ding_submit
+    CHANGE COLUMN violation_days violation_days INT NULL DEFAULT NULL COMMENT '违规天数(天)' ;
+ALTER TABLE t_b_ding_statistic
+    CHANGE COLUMN violation_days violation_days INT NULL DEFAULT NULL COMMENT '违规天数(天)' ;

+ 37 - 27
sop-common/src/main/java/com/qmth/sop/common/util/DateDisposeUtils.java

@@ -1,7 +1,5 @@
 package com.qmth.sop.common.util;
 
-import cn.hutool.core.date.DateUnit;
-import cn.hutool.core.date.DateUtil;
 import com.qmth.sop.common.contant.SystemConstant;
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.apache.commons.lang3.time.DateUtils;
@@ -24,6 +22,7 @@ import java.util.List;
  * @author ruoyi
  */
 public class DateDisposeUtils extends DateUtils {
+
     public static String YYYY = "yyyy";
 
     public static String YYYY_MM = "yyyy-MM";
@@ -34,10 +33,9 @@ public class DateDisposeUtils extends DateUtils {
 
     public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
 
-    private static String[] parsePatterns = {
-            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
-            "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
-            "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
+    private static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
+            "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss",
+            "yyyy.MM.dd HH:mm", "yyyy.MM" };
 
     /**
      * 获取当前Date型日期
@@ -115,7 +113,6 @@ public class DateDisposeUtils extends DateUtils {
         }
     }
 
-
     /**
      * 获取服务器启动时间
      */
@@ -194,6 +191,38 @@ public class DateDisposeUtils extends DateUtils {
         return days;
     }
 
+    /**
+     * 获取当前时间戳所在天的最早时间
+     *
+     * @param date 时间戳
+     * @return 0点时间
+     */
+    public static Long getEarliestTime(Long date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(System.currentTimeMillis());
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        return calendar.getTimeInMillis();
+    }
+
+    /**
+     * 获取当前时间戳所在天的最晚时间
+     *
+     * @param date 时间戳
+     * @return 24点时间
+     */
+    public static Long getLatestTime(Long date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(System.currentTimeMillis());
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.add(Calendar.DATE, 1);
+        calendar.add(Calendar.MILLISECOND, -1);
+        return calendar.getTimeInMillis();
+    }
+
     /**
      * 时间戳(毫秒级)转换成localDate
      *
@@ -205,25 +234,6 @@ public class DateDisposeUtils extends DateUtils {
     }
 
     public static void main(String[] args) {
-        List<Long> timeList = new ArrayList<>();
-
-        Date date = new Date();
-
-        for (int i = 0; i < 7; i++) {
-            int v = i + 1;
-            Calendar calendar = Calendar.getInstance();
-            calendar.setTime(date);
-            calendar.add(Calendar.DAY_OF_MONTH,- v);
-            calendar.set(Calendar.HOUR_OF_DAY,24);
-            calendar.set(Calendar.MINUTE,0);
-            calendar.set(Calendar.SECOND,0);
-            calendar.set(Calendar.MILLISECOND,0);
-            Long endTime = calendar.getTimeInMillis();
-            timeList.add(endTime);
-        }
-
-        for (Long time : timeList) {
-            System.out.println(DateFormatUtils.format(time, SystemConstant.DEFAULT_DATE_PATTERN));
-        }
+        System.out.println(getDaysBetween(1693497600000L,1693756800000L,SystemConstant.DEFAULT_DATE_DAY_PATTERN));
     }
 }