Browse Source

细节修改

wangliang 1 year ago
parent
commit
e03159ed29

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmDetailServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.bean.dto.CrmDetailImportDto;
 import com.qmth.sop.business.bean.params.CrmDetailSopParam;
 import com.qmth.sop.business.bean.params.SopPublishParam;
@@ -77,6 +78,9 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
     @Resource
     TBDingService tbDingService;
 
+    @Resource
+    ActivitiService activitiService;
+
     /**
      * 查找派单sop信息
      *
@@ -398,6 +402,14 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
             if (sopStatus == SopStatusEnum.START) {
                 throw ExceptionResultEnum.ERROR.exception("该条sop状态已改变,请刷新页面");
             }
+            if (Objects.nonNull(tbCrmDetail.getSopNo())) {
+                TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
+                        new QueryWrapper<TFCustomFlowEntity>().lambda()
+                                .eq(TFCustomFlowEntity::getCode, tbCrmDetail.getSopNo()));
+                Optional.ofNullable(tfCustomFlowEntity)
+                        .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+                activitiService.flowEnd(tfCustomFlowEntity.getFlowId());
+            }
         }
         boolean result = tbCrmDetailService.removeById(tbCrmDetail.getId());
         int count = tbCrmDetailService.count(

+ 25 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -998,10 +998,34 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 } else {
                     Objects.requireNonNull(crmProjectResult.getRegionManagerId(), "未设置大区经理");
                     try {
+                        if (currFlowTaskResult.getSetup().intValue() == 4) {
+                            List<Long> projectUserList = crmProjectResult.getProjectManagerList().stream()
+                                    .map(s -> s.getUserId()).collect(Collectors.toList());
+                            if (!org.apache.commons.collections4.CollectionUtils.isEqualCollection(
+                                    Arrays.asList(crmProjectResult.getRegionManagerId()), projectUserList)) {
+                                approveUserIds.addAll(projectUserList.stream().map(s -> String.valueOf(s))
+                                        .collect(Collectors.toList()));
+                            } else {
+                                approveUserIds.add(crmProjectResult.getRegionManagerId().toString());
+                            }
+                        } else {
+                            approveUserIds.add(crmProjectResult.getRegionManagerId().toString());
+                        }
                         tbUserArchivesService.findByUserId(crmProjectResult.getRegionManagerId());
                         List<AllocationParam> allocationParams = new ArrayList<>();
                         allocationParams.add(new AllocationParam(SopRoleTypeEnum.PROJECT_MANAGER,
-                                Arrays.asList(crmProjectResult.getRegionManagerId()), "[系统]"));
+                                approveUserIds.stream().map(s -> Long.parseLong(s)).collect(Collectors.toList()),
+                                "[系统]"));
+                        if (!CollectionUtils.isEmpty(crmProjectResult.getEngineerList())) {
+                            allocationParams.add(new AllocationParam(SopRoleTypeEnum.ENGINEER,
+                                    crmProjectResult.getEngineerList().stream().map(s -> s.getUserId())
+                                            .collect(Collectors.toList()), "[系统]"));
+                        }
+                        if (!CollectionUtils.isEmpty(crmProjectResult.getRegionCoordinatorList())) {
+                            allocationParams.add(new AllocationParam(SopRoleTypeEnum.REGION_COORDINATOR,
+                                    Arrays.asList(crmProjectResult.getRegionCoordinatorList().get(0).getUserId()),
+                                    "[系统]"));
+                        }
                         tbUserArchivesAllocationService.editCrmAllocation(
                                 new UserArchivesAllocationParam(allocationParams, crmDetailId));
                     } catch (Exception e) {
@@ -1013,7 +1037,6 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                             ResultUtil.error("人员档案里未找到派单号[" + crmProjectResult.getCrmNo() + "]大区经理角色");
                         }
                     }
-                    approveUserIds.add(crmProjectResult.getRegionManagerId().toString());
                 }
             }
         } else if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop流程待审核人