Quellcode durchsuchen

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

wangliang vor 1 Jahr
Ursprung
Commit
830644a3b4

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmServiceImpl.java

@@ -150,6 +150,9 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
         if (Objects.isNull(tbCrm)) {
             throw ExceptionResultEnum.ERROR.exception("未找到派单");
         }
+        if (CrmStatusEnum.PUBLISH.equals(tbCrm.getStatus())) {
+            throw ExceptionResultEnum.ERROR.exception("该派单已经发布,不能重新划定");
+        }
         Long customId = tbCrm.getCustomId();
         CrmBindResult crmBindResult = this.findCrmBindInfo(serviceUnitId, customId);
         RegionManagerSelectedTypeEnum defaultLeadType = crmBindResult.getLeadType();
@@ -158,6 +161,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
         String customName = crmBindResult.getCustomName();
         List<Long> similarCrmIdList = crmBindResult.getSimilarCrmIdList();
 
+        // 删除旧的分配
+        tbUserArchivesAllocationService.remove(new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, tbCrm.getCrmNo()));
         if (canEdit) {
             // 可以更改
             switch (leadType) {
@@ -230,6 +235,9 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 throw ExceptionResultEnum.ERROR.exception("服务单元的当前状态更新为" + ServiceStatusEnum.FINISH.name() + "不允许移除");
             }
         }
+        // 删除旧的分配
+        tbUserArchivesAllocationService.remove(new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, tbCrm.getCrmNo()));
+
         UpdateWrapper<TBCrm> updateWrapper = new UpdateWrapper<>();
         updateWrapper.lambda().eq(TBCrm::getId, crmId).set(TBCrm::getServiceId, null).set(TBCrm::getLeadType, null)
                 .set(TBCrm::getLeadId, null).set(TBCrm::getRegionId, null).set(TBCrm::getRegionDetailId, null).set(TBCrm::getUpdateId, requestUser.getId()).set(TBCrm::getUpdateTime, System.currentTimeMillis());

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

@@ -615,6 +615,7 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
 
         for (TBService tbService : tbServiceList) {
             Long serviceUnitId = tbService.getId();
+            // TODO: 2024/5/21 系统自动生成打卡记录方法修改 -czx 
 //            List<Map<String, Object>> sopPassageMap = tbSopInfoService.findSopPassage(serviceUnitId);
 //            if (CollectionUtils.isNotEmpty(sopPassageMap)) {
 //                Map<String, Object> map = sopPassageMap.get(0);

+ 33 - 17
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesAllocationServiceImpl.java

@@ -135,6 +135,7 @@ public class TBUserArchivesAllocationServiceImpl
         if (Objects.isNull(crmDetail)) {
             throw ExceptionResultEnum.ERROR.exception("未找到派单详情");
         }
+        CrmStatusEnum crmStatus = crmDetail.getStatus();
 
         String crmNo = crmDetail.getCrmNo();
         TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
@@ -156,22 +157,24 @@ public class TBUserArchivesAllocationServiceImpl
 
             // 经过对比要删除的人员档案id集合
             List<Long> removeList = allocatedIdList.stream().filter(e -> !archivesIdList.contains(e)).distinct().collect(Collectors.toList());
-            // 对删除的档案人员添加历史记录
-            List<TBUserArchivesAllocationLog> historicList = removeList.stream().flatMap(e -> {
-                UserArchivesResult userArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(e,
-                        null);
-                TBUserArchivesAllocationLog historic = new TBUserArchivesAllocationLog();
-                historic.setCrmDetailId(crmDetailId);
-                historic.setSopRoleType(sopRoleType);
-                historic.setUserId(userArchivesResult.getUserId());
-                historic.setArchivesId(e);
-                historic.setArchivesName(userArchivesResult.getName());
-                historic.setSupplierName(userArchivesResult.getSupplierName());
-                historic.setCity(userArchivesResult.getCity());
-                historic.insertInfo(requestUser.getId());
-                return Stream.of(historic);
-            }).collect(Collectors.toList());
-            tbUserArchivesAllocationLogService.saveBatch(historicList);
+            // 对删除的档案人员添加历史记录 (*发布的才记录历史)
+            if (CrmStatusEnum.PUBLISH.equals(crmStatus)) {
+                List<TBUserArchivesAllocationLog> historicList = removeList.stream().flatMap(e -> {
+                    UserArchivesResult userArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(e,
+                            null);
+                    TBUserArchivesAllocationLog historic = new TBUserArchivesAllocationLog();
+                    historic.setCrmDetailId(crmDetailId);
+                    historic.setSopRoleType(sopRoleType);
+                    historic.setUserId(userArchivesResult.getUserId());
+                    historic.setArchivesId(e);
+                    historic.setArchivesName(userArchivesResult.getName());
+                    historic.setSupplierName(userArchivesResult.getSupplierName());
+                    historic.setCity(userArchivesResult.getCity());
+                    historic.insertInfo(requestUser.getId());
+                    return Stream.of(historic);
+                }).collect(Collectors.toList());
+                tbUserArchivesAllocationLogService.saveBatch(historicList);
+            }
             this.remove(new QueryWrapper<TBUserArchivesAllocation>().lambda()
                     .eq(TBUserArchivesAllocation::getArchivesId, removeList)
                     .eq(TBUserArchivesAllocation::getCrmDetailId, crmDetailId));
@@ -197,7 +200,20 @@ public class TBUserArchivesAllocationServiceImpl
             }).collect(Collectors.toList());
             this.saveBatch(addListData);
 
-            tbSopInfoService.sopApproverExchange(crmDetailId);
+            if (CrmStatusEnum.PUBLISH.equals(crmStatus)) {
+                String sopNo = crmDetail.getSopNo();
+                if (sopNo == null || sopNo.length() == 0) {
+                    throw ExceptionResultEnum.ERROR.exception("未找到sopNo");
+                }
+                TBSopInfo tbSopInfo = tbSopInfoService.getOne(
+                        new QueryWrapper<TBSopInfo>().lambda().eq(TBSopInfo::getSopNo, sopNo).last(SystemConstant.LIMIT1));
+                if (Objects.isNull(tbSopInfo)) {
+                    throw ExceptionResultEnum.ERROR.exception("未找到sop信息");
+                }
+                if (SopStatusEnum.DRAFT.equals(tbSopInfo.getStatus())) {
+                    tbSopInfoService.sopApproverExchange(crmDetailId);
+                }
+            }
         }
     }