Pārlūkot izejas kodu

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

haogh 9 mēneši atpakaļ
vecāks
revīzija
7fe3e5d629

+ 40 - 38
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -109,10 +109,7 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         TBDing tbDing = tbDingService.getById(tbDingApply.getDingId());
         String sopNo = Objects.nonNull(tbDing) ? tbDing.getSopNo() : tbDingApply.getSopNo();
-        if (sopNo.equals("undefined")) {
-            // TODO: 2024/9/11 前端改
-            sopNo = null;
-        }
+
         String crmNo = Objects.nonNull(tbDing) ? tbDing.getCrmNo() : tbDingApply.getCrmNo();
         if (!SystemConstant.strNotNull(crmNo)) {
             crmNo = "-1";
@@ -347,29 +344,32 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
                 }
                 tbDingService.updateById(tbDing);
             } else {
-                TBCrm tbCrm = tbCrmService.getOne(
-                        new QueryWrapper<TBCrm>().lambda().eq(TBCrm::getCrmNo, tbDingApply.getCrmNo()));
-                Optional.ofNullable(tbCrm).orElseThrow(ExceptionResultEnum.CRM_NO_NO_DATA::exception);
-
                 SysUser sysUser = sysUserService.getById(tbDingApply.getCreateId());
                 Optional.ofNullable(sysUser).orElseThrow(ExceptionResultEnum.USER_NO_EXISTS::exception);
+                UserArchivesResult userArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(null,
+                        sysUser.getId());
 
                 List<SysRole> sysRoleList = sysUserRoleService.listRoleByUserId(sysUser.getId());
                 if (CollectionUtils.isEmpty(sysRoleList)) {
                     throw ExceptionResultEnum.ERROR.exception("用户角色不存在");
                 }
-                TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByCode(tbDingApply.getSopNo());
-                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的身份信息");
+                String sopNo = tbDingApply.getSopNo();
+                if (SystemConstant.strNotNull(sopNo)) {
+                    TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByCode(sopNo);
+
+                    List<SopRoleTypeEnum> roleType = tbUserArchivesAllocationService.findSopRoleTypeByUserSopNo(
+                            sysUser.getId(), sopNo);
+                    if (org.apache.commons.collections4.CollectionUtils.isEmpty(roleType)) {
+                        throw ExceptionResultEnum.ERROR.exception("未找到用户在当前sop的身份信息");
+                    }
+                    tbDing = new TBDing(sopNo, tbDingApply.getCrmNo(), tbDingApply.getServiceId(),
+                            userArchivesResult.getUserArchivesId(), JSON.toJSONString(roleType), sysUser.getId(),
+                            tfCustomFlowEntity.getFlowId());
+                } else {
+                    // 区协
+                    tbDing = new TBDing(null, null, tbDingApply.getServiceId(), userArchivesResult.getUserArchivesId(),
+                            JSON.toJSONString(SopRoleTypeEnum.REGION_COORDINATOR), sysUser.getId(), null);
                 }
-                tbDing = new TBDing(tbDingApply.getSopNo(), tbDingApply.getCrmNo(), tbCrm.getServiceId(),
-                        tbUserArchives.getId(), JSON.toJSONString(roleType), sysUser.getId(),
-                        tfCustomFlowEntity.getFlowId());
                 tbDing.setSignDate(
                         DateFormatUtils.format(tbDingApply.getApplyTime(), SystemConstant.DEFAULT_DATE_DAY_PATTERN));
                 tbDing.setSignYear(
@@ -387,9 +387,6 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
                 tbDingService.save(tbDing);
                 tbDingApply.setDingId(tbDing.getId());
             }
-        } else {
-            TBUserArchives tbUserArchives = tbUserArchivesService.findByUserId(tbDingApply.getCreateId());
-            tbDingStatisticService.buildDingStatistic(tbDingApply.getSopNo(), tbUserArchives.getId());
         }
         tbDingApply.setApprove(dingExceptionApprove);
         return tbDingApplyService.updateById(tbDingApply);
@@ -446,23 +443,28 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
                 .eq(TBDingApply::getDingExceptionNo, tfCustomFlowEntity.getCode()));
         Optional.ofNullable(tbDingApply).orElseThrow(() -> ExceptionResultEnum.DING_APPLY_NO_DATA.exception());
 
-        TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(
-                Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getSopNo() : null,
-                Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null, tfCustomFlowEntity.getCrmNo());
-        Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
-
-        //        List<UserArchivesDto> regionCoordinatorList = crmProjectResult.getRegionCoordinatorList();
-        //        if (CollectionUtils.isEmpty(regionCoordinatorList)) {
-        //            throw ExceptionResultEnum.ERROR.exception("crm区域协调人数据为空");
-        //        }
-        //        Optional.ofNullable(regionCoordinatorList.get(0).getUserId())
-        //                .orElseThrow(() -> ExceptionResultEnum.ERROR.exception("crm区域协调人数据为空"));
-
-        List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(),
-                tbDingApply.getCreateId(), tbDingApply.getSopNo());
         List<String> approveUserIds = new ArrayList<>();
-        approveUserIds.addAll(sysUserRoleList);
+        if (!Objects.equals(tfCustomFlowEntity.getCrmNo(), "-1")) {
+            TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(
+                    Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getSopNo() : null,
+                    Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null, tfCustomFlowEntity.getCrmNo());
+            Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
+
+            //        List<UserArchivesDto> regionCoordinatorList = crmProjectResult.getRegionCoordinatorList();
+            //        if (CollectionUtils.isEmpty(regionCoordinatorList)) {
+            //            throw ExceptionResultEnum.ERROR.exception("crm区域协调人数据为空");
+            //        }
+            //        Optional.ofNullable(regionCoordinatorList.get(0).getUserId())
+            //                .orElseThrow(() -> ExceptionResultEnum.ERROR.exception("crm区域协调人数据为空"));
+            List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(),
+                    tbDingApply.getCreateId(), tbDingApply.getSopNo());
+
+            approveUserIds.addAll(sysUserRoleList);
+        } else {
+            // 区协补卡的审核
+            approveUserIds.addAll(Collections.singletonList(String.valueOf(sysUser.getId())));
+        }
         activitiService.taskApprove(
                 new FlowApproveParam(taskId, FlowApprovePassEnum.PASS, approveUserIds, tfCustomFlowEntity.getCrmNo(),
                         dingExceptionApprove.getTitle()));