Преглед на файлове

Merge remote-tracking branch 'origin/dev_1.1.1' into dev_1.1.1

wangliang преди 9 месеца
родител
ревизия
845739433d

+ 12 - 2
sop-business/src/main/java/com/qmth/sop/business/entity/TBDingApply.java

@@ -34,12 +34,14 @@ public class TBDingApply implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long id;
 
+    @ApiModelProperty(value = "服务单元id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long serviceId;
+
     @ApiModelProperty(value = "sop编号")
-    @NotBlank(message = "sop号不能为空")
     private String sopNo;
 
     @ApiModelProperty(value = "派单号")
-    @NotBlank(message = "crm派单号不能为空")
     private String crmNo;
 
     @ApiModelProperty(value = "考勤id")
@@ -135,6 +137,14 @@ public class TBDingApply implements Serializable {
         this.dingExceptionTypeStr = dingExceptionTypeStr;
     }
 
+    public Long getServiceId() {
+        return serviceId;
+    }
+
+    public void setServiceId(Long serviceId) {
+        this.serviceId = serviceId;
+    }
+
     public String getApproveUserName() {
         return approveUserName;
     }

+ 18 - 11
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingMapper.java

@@ -3,7 +3,6 @@ package com.qmth.sop.business.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.bean.dto.SopCrmInfo;
 import com.qmth.sop.business.bean.result.*;
 import com.qmth.sop.business.entity.TBDing;
 import com.qmth.sop.business.entity.TFFlowApprove;
@@ -30,17 +29,25 @@ public interface TBDingMapper extends BaseMapper<TBDing> {
      * @return
      */
 
-    IPage<TBDingSubmitQueryResult> query(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("status") String status, @Param("createId") Long createId, @Param("userName") String userName, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("days") Long days, @Param("dpr") DataPermissionDto dpr);
+    IPage<TBDingSubmitQueryResult> query(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("status") String status, @Param("createId") Long createId, @Param("userName") String userName,
+            @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("days") Long days, @Param("dpr") DataPermissionDto dpr);
 
-    List<TBDingSubmitQueryResult> query(@Param("serviceId") Long serviceId, @Param("status") String status, @Param("createId") Long createId, @Param("userName") String userName, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("days") Long days, @Param("dpr") DataPermissionDto dpr);
+    List<TBDingSubmitQueryResult> query(@Param("serviceId") Long serviceId, @Param("status") String status, @Param("createId") Long createId, @Param("userName") String userName, @Param("supplierId") Long supplierId,
+            @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("days") Long days, @Param("dpr") DataPermissionDto dpr);
 
-    TBDingCountResult count(@Param("serviceId") Long serviceId,@Param("status") String status, @Param("createId") Long createId, @Param("userName") String userName, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("dpr") DataPermissionDto dpr);
+    TBDingCountResult count(@Param("serviceId") Long serviceId, @Param("status") String status, @Param("createId") Long createId, @Param("userName") String userName, @Param("supplierId") Long supplierId,
+            @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("dpr") DataPermissionDto dpr);
 
-    IPage<TBDingAttendanceResult> attendanceQuery(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("userName") String userName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("type") String type, @Param("status") String status, @Param("dpr")DataPermissionDto dpr,@Param("abnormal")Long abnormal);
+    IPage<TBDingAttendanceResult> attendanceQuery(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("userName") String userName, @Param("startTime") Long startTime, @Param("endTime") Long endTime,
+            @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("type") String type, @Param("status") String status, @Param("dpr") DataPermissionDto dpr,
+            @Param("abnormal") Long abnormal);
 
-    TBDingAttendanceCountResult attendanceCount(@Param("serviceId") Long serviceId, @Param("userName") String userName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("dpr")DataPermissionDto dpr);
+    TBDingAttendanceCountResult attendanceCount(@Param("serviceId") Long serviceId, @Param("userName") String userName,
+            @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("dpr") DataPermissionDto dpr);
 
-    List<TBDingAttendanceResult> attendanceQuery(@Param("serviceId") Long serviceId, @Param("userName") String userName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("type") String type, @Param("status") String status,@Param("abnormal")Long abnormal);
+    List<TBDingAttendanceResult> attendanceQuery(@Param("serviceId") Long serviceId, @Param("userName") String userName,
+            @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("type") String type,
+            @Param("status") String status, @Param("abnormal") Long abnormal);
 
     /**
      * 根据用户id查询打卡信息
@@ -62,10 +69,10 @@ public interface TBDingMapper extends BaseMapper<TBDing> {
     /**
      * 查询打卡异常提交次数
      *
-     * @param userId 用户id
-     * @param sopNo  sopNo
+     * @param userId    用户id
+     * @param serviceId 服务单元id
+     * @param sopNo     sopNo
      * @return 暂用的打卡次数
      */
-    int findDingExceptionApplyCount(@Param("userId") Long userId,
-                                    @Param("sopNo") String sopNo);
+    int findDingExceptionApplyCount(@Param("userId") Long userId, @Param("serviceId") Long serviceId, @Param("sopNo") String sopNo);
 }

+ 6 - 5
sop-business/src/main/java/com/qmth/sop/business/service/TBDingService.java

@@ -42,8 +42,8 @@ public interface TBDingService extends IService<TBDing> {
      * 考勤结果统计
      *
      * @param serviceId 服务单元id
-     * @param sopNo  sop单号
-     * @param userId 用户id
+     * @param sopNo     sop单号
+     * @param userId    用户id
      * @return 考勤结果统计
      */
     DingStatisticResult findDingStatistic(Long serviceId, String sopNo, Long userId);
@@ -104,11 +104,12 @@ public interface TBDingService extends IService<TBDing> {
     /**
      * 查询剩余补卡天数
      *
-     * @param userId 用户id
-     * @param sopNo  流水号
+     * @param userId    用户id
+     * @param serviceId 服务单元id
+     * @param sopNo     流水号
      * @return 剩余补卡天数
      */
-    int findRemainCount(Long userId, String sopNo);
+    int findRemainCount(Long userId, Long serviceId, String sopNo);
 
     /**
      * 每天晚上自动为没有打卡(签到签退都没打)的人生成打卡记录

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

@@ -110,8 +110,9 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         TBDing tbDing = tbDingService.getById(tbDingApply.getDingId());
         String sopNo = Objects.nonNull(tbDing) ? tbDing.getSopNo() : tbDingApply.getSopNo();
         String crmNo = Objects.nonNull(tbDing) ? tbDing.getCrmNo() : tbDingApply.getCrmNo();
+        Long serviceId = Objects.nonNull(tbDing) ? tbDing.getServiceId() : tbDingApply.getServiceId();
 
-        int count = tbDingService.findRemainCount(sysUser.getId(), sopNo);
+        int count = tbDingService.findRemainCount(sysUser.getId(), serviceId, sopNo);
         if (count == 0) {
             throw ExceptionResultEnum.ERROR.exception("该用户剩余补卡次数为0");
         }

+ 25 - 14
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingServiceImpl.java

@@ -133,6 +133,7 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
 
     @Override
     public DingStatisticResult findDingStatistic(Long serviceId, String sopNo, Long userId) {
+        boolean isCoordinator = tbUserArchivesService.containsRegionCoordinator(userId);
         // 截取年分割截止
         final int yearEnd = 4;
         // 截取日分割开始
@@ -214,11 +215,14 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
             String endDate = dateFormDto.getEndDate();
             endDate = endDate.substring(dayStart);
 
-            // TODO: 2024/9/4 更改补卡记录
             // 查询正在补卡中的记录
-            List<TBDingApply> resigningList = tbDingApplyService.list(
-                    new QueryWrapper<TBDingApply>().lambda().select(TBDingApply::getType, TBDingApply::getApplyTime).eq(TBDingApply::getSopNo, sopNo).eq(TBDingApply::getCreateId, userId)
-                            .isNull(TBDingApply::getApprove));
+            QueryWrapper<TBDingApply> dingApplyQueryWrapper = new QueryWrapper<>();
+            dingApplyQueryWrapper.lambda().select(TBDingApply::getType, TBDingApply::getApplyTime).eq(TBDingApply::getServiceId, serviceId).eq(TBDingApply::getCreateId, userId)
+                    .isNull(TBDingApply::getApprove);
+            if (SystemConstant.strNotNull(sopNo)) {
+                dingApplyQueryWrapper.lambda().eq(TBDingApply::getSopNo, sopNo);
+            }
+            List<TBDingApply> resigningList = tbDingApplyService.list(dingApplyQueryWrapper);
 
             for (String date : dateFormList) {
                 String year = date.substring(0, yearEnd);
@@ -295,7 +299,7 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
         dingStatisticResult.setDingFormList(formList);
         dingStatisticResult.setWorkDays(workCount);
         dingStatisticResult.setExceptionCount(exceptionCount);
-        dingStatisticResult.setRemainCount(this.findRemainCount(userId, sopNo));
+        dingStatisticResult.setRemainCount(this.findRemainCount(userId, serviceId, sopNo));
         return dingStatisticResult;
     }
 
@@ -624,8 +628,9 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
                 return result;
             }
             Long endTime = dingTimeDto.getEndTime();
-            result.setDateFormList(DateDisposeUtils.getDaysBetween(startTime, Math.min(currentTime, endTime),
-                    SystemConstant.DEFAULT_DATE_YMD_S_PATTERN));
+            dateList = DateDisposeUtils.getDaysBetween(startTime, Math.min(currentTime, endTime),
+                    SystemConstant.DEFAULT_DATE_YMD_S_PATTERN);
+            result.setDateFormList(dateList);
         }
         if (CollectionUtils.isNotEmpty(dateList)) {
             result.setEndDate(dateList.get(0));
@@ -642,14 +647,20 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
 
     @Override
     public DingElementResult findDingRule(Long userId, Long serviceUnitId) {
+        boolean isCoordinator = tbUserArchivesService.containsRegionCoordinator(userId);
         List<DingElementResult> dingElementResultList = this.baseMapper.findDingResultByUserId(userId, serviceUnitId);
         List<Long> dingGroupIds = dingElementResultList.stream().map(DingElementResult::getDingGroupId).distinct().collect(Collectors.toList());
 
         if (CollectionUtils.isNotEmpty(dingGroupIds)) {
-            List<SysDingObj> sysDingObjList = sysDingObjService.list(
-                    new QueryWrapper<SysDingObj>().lambda().in(SysDingObj::getDingGroupId, dingGroupIds)
-                            .eq(SysDingObj::getSopRoleType, SopRoleTypeEnum.ENGINEER)
-                            .eq(SysDingObj::getType, DingObjTypeEnum.DING));
+            QueryWrapper<SysDingObj> sysDingObjQueryWrapper = new QueryWrapper<>();
+            sysDingObjQueryWrapper.lambda().in(SysDingObj::getDingGroupId, dingGroupIds)
+                    .eq(SysDingObj::getType, DingObjTypeEnum.DING);
+            if (isCoordinator) {
+                sysDingObjQueryWrapper.lambda().eq(SysDingObj::getSopRoleType, SopRoleTypeEnum.REGION_COORDINATOR);
+            } else {
+                sysDingObjQueryWrapper.lambda().eq(SysDingObj::getSopRoleType, SopRoleTypeEnum.ENGINEER);
+            }
+            List<SysDingObj> sysDingObjList = sysDingObjService.list(sysDingObjQueryWrapper);
 
             if (CollectionUtils.isNotEmpty(sysDingObjList) && sysDingObjList.size() == 1) {
                 dingElementResultList = dingElementResultList.stream()
@@ -664,10 +675,10 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
     }
 
     @Override
-    public int findRemainCount(Long userId, String sopNo) {
-        DingElementResult dingElementResult = this.findDingRule(userId, sopNo);
+    public int findRemainCount(Long userId, Long serviceId, String sopNo) {
+        DingElementResult dingElementResult = this.findDingRule(userId, serviceId);
         int reissueCardCount = dingElementResult != null ? dingElementResult.getReissueCardCount() : 0;
-        int applyCount = this.baseMapper.findDingExceptionApplyCount(userId, sopNo);
+        int applyCount = this.baseMapper.findDingExceptionApplyCount(userId, serviceId, sopNo);
         return reissueCardCount != 0 ? reissueCardCount - applyCount : 0;
     }
 

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

@@ -218,7 +218,7 @@ public class TBDingStatisticServiceImpl extends ServiceImpl<TBDingStatisticMappe
             }
 
             // 剩余补卡数
-            int remainCount = tbDingService.findRemainCount(userId, sopNo);
+            int remainCount = tbDingService.findRemainCount(userId, serviceUnitId, sopNo);
 
             // 待处理异常数
             int exceptionCount = tbDingApplyService.count(

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingSubmitServiceImpl.java

@@ -217,7 +217,7 @@ public class TBDingSubmitServiceImpl extends ServiceImpl<TBDingSubmitMapper, TBD
             dto.setWorkHours(e.getWorkHours());
             dto.setViolationDays(e.getViolationDays());
             dto.setDingExceptionCount(e.getDingExceptionCount());
-            dto.setRemainCount(tbDingService.findRemainCount(e.getUserId(), e.getSopNo()));
+            dto.setRemainCount(tbDingService.findRemainCount(e.getUserId(), serviceUnitId, e.getSopNo()));
             dto.setExceptionCount(e.getExceptionCount());
             dto.setSubmitStatus(e.getSubmitStatus().getSubmitDesc());
             dto.setSubmitUserName(e.getSubmitUserName());

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

@@ -4,3 +4,21 @@ ALTER TABLE t_b_ding
     CHANGE COLUMN ding_sop_no ding_sop_no VARCHAR(100) CHARACTER SET 'utf8mb4' NULL COMMENT '实际打卡对应的sop单号' ;
 
 INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('41', 'region.coordinator.ding.time', '区域协调人打卡时间段', '{\"startTime\": 1725292800000,\"endTime\": 1725897600000}', '1', '1', '1');
+
+-- 2024-09-05
+ALTER TABLE t_b_ding_apply
+    ADD COLUMN service_id BIGINT NULL COMMENT '服务单元id' AFTER id;
+ALTER TABLE t_b_ding_apply
+    CHANGE COLUMN sop_no sop_no VARCHAR(100) CHARACTER SET 'utf8mb4' NULL COMMENT 'sop编号' ,
+    CHANGE COLUMN crm_no crm_no VARCHAR(100) CHARACTER SET 'utf8mb4' NULL COMMENT '派单编号' ;
+
+UPDATE t_b_ding_apply tbda
+SET
+    tbda.service_id = (SELECT
+            tbc.service_id
+        FROM
+            t_b_crm tbc
+        WHERE
+            tbda.crm_no = tbc.crm_no)
+WHERE
+    service_id IS NULL;

+ 3 - 0
sop-business/src/main/resources/mapper/TBDingMapper.xml

@@ -400,6 +400,9 @@
             <if test="userId != null">
                 AND create_id = #{userId}
             </if>
+            <if test="serviceId != null and serviceId != ''">
+                AND service_id = #{serviceId}
+            </if>
             <if test="sopNo != null and sopNo != ''">
                 AND sop_no = #{sopNo}
             </if>