Kaynağa Gözat

加入历史项目经理审批

wangliang 1 yıl önce
ebeveyn
işleme
2bd9787dbd

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/CrmProjectResult.java

@@ -98,6 +98,17 @@ public class CrmProjectResult {
     @ApiModelProperty(value = "过程变量")
     private String processVar;
 
+    @ApiModelProperty(value = "科目名称")
+    private String courseName;
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
     public String getCrmNo() {
         return crmNo;
     }

+ 50 - 27
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmServiceImpl.java

@@ -162,7 +162,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
         List<Long> similarCrmIdList = crmBindResult.getSimilarCrmIdList();
 
         // 删除旧的分配
-        tbUserArchivesAllocationService.remove(new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, tbCrm.getCrmNo()));
+        tbUserArchivesAllocationService.remove(new QueryWrapper<TBUserArchivesAllocation>().lambda()
+                .eq(TBUserArchivesAllocation::getCrmNo, tbCrm.getCrmNo()));
         // 删除派单详情
         tbCrmDetailService.remove(new QueryWrapper<TBCrmDetail>().lambda().eq(TBCrmDetail::getCrmNo, tbCrm.getCrmNo()));
 
@@ -179,7 +180,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 UpdateWrapper<TBCrm> areaUpdateWrapper = new UpdateWrapper<>();
                 areaUpdateWrapper.lambda().set(TBCrm::getServiceId, serviceUnitId).set(TBCrm::getLeadType, leadType)
                         .set(TBCrm::getUpdateId, requestUser.getId())
-                        .set(TBCrm::getUpdateTime, System.currentTimeMillis()).set(TBCrm::getLeadId, serviceRegionDetailResult.getLeadId())
+                        .set(TBCrm::getUpdateTime, System.currentTimeMillis())
+                        .set(TBCrm::getLeadId, serviceRegionDetailResult.getLeadId())
                         .set(TBCrm::getRegionId, serviceRegionDetailResult.getServiceRegionId())
                         .set(TBCrm::getRegionDetailId, serviceRegionDetailResult.getServiceRegionDetailId());
                 if (Objects.isNull(defaultLeadType) || leadType.equals(defaultLeadType)) {
@@ -199,7 +201,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                         .set(TBCrm::getLeadId, leadId).set(TBCrm::getRegionId, null).set(TBCrm::getRegionDetailId, null)
                         .set(TBCrm::getUpdateId, requestUser.getId())
                         .set(TBCrm::getUpdateTime, System.currentTimeMillis());
-                if ((Objects.isNull(defaultLeadType) || !SystemConstant.longNotNull(defaultLeadId)) || (leadType.equals(defaultLeadType) && leadId.equals(defaultLeadId))) {
+                if ((Objects.isNull(defaultLeadType) || !SystemConstant.longNotNull(defaultLeadId)) || (
+                        leadType.equals(defaultLeadType) && leadId.equals(defaultLeadId))) {
                     // 更新自己信息(没有默认信息或默认信息与更改信息一致)
                     personUpdateWrapper.lambda().eq(TBCrm::getId, crmId);
                 } else if (CollectionUtils.isNotEmpty(similarCrmIdList)) {
@@ -242,18 +245,21 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
             }
         }
         // 删除旧的分配
-        tbUserArchivesAllocationService.remove(new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, tbCrm.getCrmNo()));
+        tbUserArchivesAllocationService.remove(new QueryWrapper<TBUserArchivesAllocation>().lambda()
+                .eq(TBUserArchivesAllocation::getCrmNo, tbCrm.getCrmNo()));
         // 删除派单详情
         tbCrmDetailService.remove(new QueryWrapper<TBCrmDetail>().lambda().eq(TBCrmDetail::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());
+                .set(TBCrm::getLeadId, null).set(TBCrm::getRegionId, null).set(TBCrm::getRegionDetailId, null)
+                .set(TBCrm::getUpdateId, requestUser.getId()).set(TBCrm::getUpdateTime, System.currentTimeMillis());
         this.update(updateWrapper);
     }
 
     @Override
-    public CrmSubTotalResult findCrmSubTotalData(Long serviceUnitId, String city, ProductTypeEnum productType, String customName, Boolean bindStatus) {
+    public CrmSubTotalResult findCrmSubTotalData(Long serviceUnitId, String city, ProductTypeEnum productType,
+            String customName, Boolean bindStatus) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
         List<CrmServiceResult> crmServiceResultList = this.baseMapper.findServiceScopeList(serviceUnitId, city,
@@ -346,7 +352,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3).replaceAll("'", "");
-                throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
+                throw ExceptionResultEnum.SQL_ERROR.exception(
+                        "[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
                 ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
@@ -437,7 +444,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3).replaceAll("'", "");
-                throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
+                throw ExceptionResultEnum.SQL_ERROR.exception(
+                        "[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
             } else if (e instanceof ApiException) {
                 ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
             } else {
@@ -483,7 +491,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
             tbCrmDetail = tbCrmDetailService.getById(crmDetailId);
         } else if (sopNo != null && sopNo.length() > 0) {
             tbCrmDetail = tbCrmDetailService.getOne(
-                    new QueryWrapper<TBCrmDetail>().lambda().eq(TBCrmDetail::getSopNo, sopNo).last(SystemConstant.LIMIT1));
+                    new QueryWrapper<TBCrmDetail>().lambda().eq(TBCrmDetail::getSopNo, sopNo)
+                            .last(SystemConstant.LIMIT1));
         } else if (crmNo != null && crmNo.length() > 0) {
             // 传派单号 -> 派单详情的调配信息直接返回派单信息
             List<CrmProjectResult> crmProjectResultList = this.baseMapper.findCrmProjectByCrmNo(crmNo);
@@ -502,13 +511,17 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
             result = crmProjectResultList.get(0);
         }
         List<TBUserArchivesAllocation> datasource = tbUserArchivesAllocationService.list(
-                new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmDetailId, crmDetailId));
-        List<UserArchivesDto> regionCoordinatorList = this.buildUserArchivesDtoList(datasource, SopRoleTypeEnum.REGION_COORDINATOR);
-        List<UserArchivesDto> projectManagerList = this.buildUserArchivesDtoList(datasource, SopRoleTypeEnum.PROJECT_MANAGER);
+                new QueryWrapper<TBUserArchivesAllocation>().lambda()
+                        .eq(TBUserArchivesAllocation::getCrmDetailId, crmDetailId));
+        List<UserArchivesDto> regionCoordinatorList = this.buildUserArchivesDtoList(datasource,
+                SopRoleTypeEnum.REGION_COORDINATOR);
+        List<UserArchivesDto> projectManagerList = this.buildUserArchivesDtoList(datasource,
+                SopRoleTypeEnum.PROJECT_MANAGER);
         List<UserArchivesDto> engineerList = this.buildUserArchivesDtoList(datasource, SopRoleTypeEnum.ENGINEER);
         result.setRegionCoordinatorList(regionCoordinatorList);
         result.setProjectManagerList(projectManagerList);
         result.setEngineerList(engineerList);
+        result.setCourseName(tbCrmDetail.getCourseName());
         return result;
     }
 
@@ -550,11 +563,11 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
             break;
         case FINISH: // 完结
             tbCrm.setStatus(CrmStatusEnum.FINISH);
-//            // crm完结 释放工程师资源
-//            List<CrmArchivesAllocationResult> crmArchivesAllocationResultList = tbUserArchivesAllocationService.findAllocationByCrmNo(
-//                    crmNo);
-//            List<Long> engineerArchivesIdList = crmArchivesAllocationResultList.stream().filter(e -> !RoleTypeEnum.REGION_COORDINATOR.equals(e.getType()))
-//                    .map(CrmArchivesAllocationResult::getArchivesId).distinct().collect(Collectors.toList());
+            //            // crm完结 释放工程师资源
+            //            List<CrmArchivesAllocationResult> crmArchivesAllocationResultList = tbUserArchivesAllocationService.findAllocationByCrmNo(
+            //                    crmNo);
+            //            List<Long> engineerArchivesIdList = crmArchivesAllocationResultList.stream().filter(e -> !RoleTypeEnum.REGION_COORDINATOR.equals(e.getType()))
+            //                    .map(CrmArchivesAllocationResult::getArchivesId).distinct().collect(Collectors.toList());
 
             //            if (CollectionUtils.isNotEmpty(engineerArchivesIdList)) {
             //                UpdateWrapper<TBUserArchives> updateWrapper = new UpdateWrapper<>();
@@ -583,11 +596,13 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
         if (oldServiceUnitId != null && oldServiceUnitId > 0) {
             // 之前派单有划定在服务单元 -> 解绑派单所有资源信息
             List<TBUserArchivesAllocation> dbAllocationList = tbUserArchivesAllocationService.list(
-                    new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, crmNo).eq(TBUserArchivesAllocation::getServiceId, oldServiceUnitId));
+                    new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, crmNo)
+                            .eq(TBUserArchivesAllocation::getServiceId, oldServiceUnitId));
 
             if (CollectionUtils.isNotEmpty(dbAllocationList)) {
                 // 释放工程师资源
-                List<Long> archivesIdList = dbAllocationList.stream().map(TBUserArchivesAllocation::getArchivesId).distinct().collect(Collectors.toList());
+                List<Long> archivesIdList = dbAllocationList.stream().map(TBUserArchivesAllocation::getArchivesId)
+                        .distinct().collect(Collectors.toList());
                 if (CollectionUtils.isNotEmpty(archivesIdList)) {
                     UpdateWrapper<TBUserArchives> archivesUpdateWrapper = new UpdateWrapper<>();
                     archivesUpdateWrapper.lambda().in(TBUserArchives::getId, archivesIdList)
@@ -596,7 +611,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 }
                 // 删除之前的派单分配详情
                 tbUserArchivesAllocationService.removeByIds(
-                        dbAllocationList.stream().map(TBUserArchivesAllocation::getId).distinct().collect(Collectors.toList()));
+                        dbAllocationList.stream().map(TBUserArchivesAllocation::getId).distinct()
+                                .collect(Collectors.toList()));
             }
             UpdateWrapper<TBCrm> updateWrapper = new UpdateWrapper<>();
             updateWrapper.lambda().eq(TBCrm::getId, tbCrm.getId()).set(TBCrm::getServiceId, null)
@@ -695,7 +711,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                     // 客户经理校验
                     Long crmUserId = null;
                     SysUser sysUser = sysUserService.getOne(
-                            new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, managerMobileNumber).eq(SysUser::getRealName, managerName));
+                            new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, managerMobileNumber)
+                                    .eq(SysUser::getRealName, managerName));
                     if (Objects.isNull(sysUser) || !sysUser.getEnable()) {
                         matchInfoError = matchInfoError + String.format("纷享销客中的客户经理[%s(%s)]在质控平台不存在或已禁用(姓名 + 手机号)\n",
                                 managerName, managerMobileNumber);
@@ -713,10 +730,12 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                     // 系统客户校验
                     Long customId = null;
                     List<SysCustom> sysCustomList = sysCustomService.list(
-                            new QueryWrapper<SysCustom>().lambda().eq(SysCustom::getName, customName).eq(SysCustom::getType, customType));
+                            new QueryWrapper<SysCustom>().lambda().eq(SysCustom::getName, customName)
+                                    .eq(SysCustom::getType, customType));
 
                     if (CollectionUtils.isEmpty(sysCustomList)) {
-                        if (customProvince == null || customProvince.length() == 0 || customCity == null || customCity.length() == 0) {
+                        if (customProvince == null || customProvince.length() == 0 || customCity == null
+                                || customCity.length() == 0) {
                             // 客户不存在且客户信息缺失
                             String customMissKey = customName + "-" + customType;
                             if (!customMissList.contains(customMissKey)) {
@@ -791,7 +810,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 String configKey = SystemConstant.SMS_CUSTOM_INFO_MISSING_REMIND_CODE;
                 String mobileNumber = "18903719928";
                 SysUser signature = sysUserService.getOne(
-                        new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, mobileNumber).last(SystemConstant.LIMIT1));
+                        new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, mobileNumber)
+                                .last(SystemConstant.LIMIT1));
                 if (Objects.nonNull(signature)) {
                     String userName = signature.getRealName();
                     String customInfo = String.join(";", customMissList);
@@ -835,7 +855,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 .eq(TBCrm::getServiceId, serviceUnitId));
         if (CollectionUtils.isNotEmpty(sameCrmList)) {
             // 对于同一服务单元同客户下有发布sop的,不允许更换大区经理,上述两图中内容置灰,不可更换大区经理。一旦更换大区经理,该客户的所有派单均更换大区经理
-            List<RegionManagerSelectedTypeEnum> leadTypeList = sameCrmList.stream().map(TBCrm::getLeadType).distinct().collect(Collectors.toList());
+            List<RegionManagerSelectedTypeEnum> leadTypeList = sameCrmList.stream().map(TBCrm::getLeadType).distinct()
+                    .collect(Collectors.toList());
             if (leadTypeList.size() != 1) {
                 throw ExceptionResultEnum.ERROR.exception("客户在服务单元下存在不同的大区经理指定方式");
             }
@@ -850,7 +871,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
             }
         }
         CrmBindResult crmBindResult = new CrmBindResult();
-        crmBindResult.setSimilarCrmIdList(sameCrmList.stream().map(TBCrm::getId).distinct().collect(Collectors.toList()));
+        crmBindResult.setSimilarCrmIdList(
+                sameCrmList.stream().map(TBCrm::getId).distinct().collect(Collectors.toList()));
         crmBindResult.setCanEdit(canEdit);
         if (leadId != null) {
             SysUser leader = sysUserService.getById(leadId);
@@ -877,7 +899,8 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
         return datasource.stream().filter(e -> sopRoleTypeEnum.equals(e.getSopRoleType())).flatMap(e -> {
             UserArchivesDto dto = new UserArchivesDto();
             Long userArchivesId = e.getArchivesId();
-            UserArchivesResult userArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(userArchivesId, null);
+            UserArchivesResult userArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(
+                    userArchivesId, null);
             dto.setUserArchivesId(userArchivesId);
             dto.setUserId(e.getUserId());
             dto.setName(tbUserArchivesService.getById(userArchivesId).getName());