瀏覽代碼

教务处sop修改

wangliang 1 年之前
父節點
當前提交
e7d1122b55

File diff suppressed because it is too large
+ 14 - 11
sop-api/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java


+ 6 - 16
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -566,24 +566,14 @@ public class ActivitiServiceImpl implements ActivitiService {
                 }
             }
         } else if (Objects.nonNull(flowId)) {
-            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW
-                    || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW
-                    || tfCustomFlow.getType() == TFCustomTypeEnum.QUALITY_PROBLEM_FLOW) {
-                taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
-                map = this.getFlowFormPropertie(map, taskList, flowResult, tfCustomFlow);
-            }
+            taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
+            map = this.getFlowFormPropertie(map, taskList, flowResult, tfCustomFlow);
         } else {
-            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW
-                    || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW
-                    || tfCustomFlow.getType() == TFCustomTypeEnum.QUALITY_PROBLEM_FLOW) {
-                taskList = taskService.createTaskQuery().taskId(String.valueOf(taskId)).list();
-                map = this.getFlowFormPropertie(map, taskList, flowResult, tfCustomFlow);
-            }
+            taskList = taskService.createTaskQuery().taskId(String.valueOf(taskId)).list();
+            map = this.getFlowFormPropertie(map, taskList, flowResult, tfCustomFlow);
         }
-        map.put(SystemConstant.FLOW_DEPLOYMENT_ID, tfCustomFlow.getFlowDeploymentId());
-        map.put(SystemConstant.ID, tfCustomFlow.getId());
         if (Objects.nonNull(crmNo)) {
-            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(null,null, crmNo);
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(null, null, crmNo);
             if (Objects.nonNull(crmProjectResult)) {
                 map.put(SystemConstant.CRM_INFO, crmProjectResult);
             }
@@ -1074,7 +1064,7 @@ public class ActivitiServiceImpl implements ActivitiService {
 
         CrmProjectResult crmProjectResult = null;
         if (Objects.nonNull(tfCustomFlowEntity.getCrmNo())) {
-            crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),null,
+            crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(), null,
                     tfCustomFlowEntity.getCrmNo());
         }
         return new FlowViewResult(flowId, tfFlowApprove.getStatus(), tfCustomFlowEntity.getCode(), taskIdList,

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

@@ -85,4 +85,12 @@ public interface TBCrmDetailService extends IService<TBCrmDetail> {
      * @return
      */
     public boolean sopDelete(Long id);
+
+    /**
+     * 根据sopNo查询派单明细
+     *
+     * @param sopNo
+     * @return
+     */
+    public TBCrmDetail findBySopNo(String sopNo);
 }

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

@@ -135,11 +135,10 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @param tfCustomFlow
      * @param tfCustomFlowEntity
      * @param tfFlowApprove
-     * @param tbSopInfoDetail
      * @param crmNo
      */
     public void sopSystemApprove(TFCustomFlow tfCustomFlow, TFCustomFlowEntity tfCustomFlowEntity,
-            TFFlowApprove tfFlowApprove, TBSopInfoDetail tbSopInfoDetail, String crmNo) throws InterruptedException;
+            TFFlowApprove tfFlowApprove, String crmNo) throws InterruptedException;
 
     /**
      * 保存提醒/延时任务

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

@@ -1,6 +1,7 @@
 package com.qmth.sop.business.service.impl;
 
 import com.alibaba.excel.EasyExcel;
+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;
@@ -299,4 +300,15 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
         //todo 补上流程信息
         return tbCrmDetailService.removeById(tbCrmDetail.getId());
     }
+
+    /**
+     * 根据sopNo查询派单明细
+     *
+     * @param sopNo
+     * @return
+     */
+    @Override
+    public TBCrmDetail findBySopNo(String sopNo) {
+        return tbCrmDetailService.getOne(new QueryWrapper<TBCrmDetail>().lambda().eq(TBCrmDetail::getSopNo, sopNo));
+    }
 }

+ 193 - 138
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 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.DataPermissionDto;
 import com.qmth.sop.business.bean.dto.OrgUserNameDto;
+import com.qmth.sop.business.bean.dto.UserArchivesDto;
 import com.qmth.sop.business.bean.params.*;
 import com.qmth.sop.business.bean.result.*;
 import com.qmth.sop.business.entity.*;
@@ -18,6 +20,7 @@ import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.*;
 import com.qmth.sop.common.util.GsonUtil;
 import com.qmth.sop.common.util.JacksonUtil;
+import com.qmth.sop.common.util.ResultUtil;
 import com.qmth.sop.common.util.ServletUtil;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.task.IdentityLink;
@@ -105,10 +108,13 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     TBDeviceDeliveryService tbDeviceDeliveryService;
 
     @Resource
-    TBUserArchivesService tbUserArchivesService;
+    TBSopLogService tbSopLogService;
 
     @Resource
-    TBSopLogService tbSopLogService;
+    TBCrmDetailService tbCrmDetailService;
+
+    @Resource
+    TBUserArchivesService tbUserArchivesService;
 
     /**
      * 查询动态sop表名是否存在
@@ -272,8 +278,9 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 sopPublishParam.getCrmDetailId(), sopPublishParam.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
+        Objects.requireNonNull(crmProjectResult.getRegionManagerId(), "未设置大区经理");
         if (CollectionUtils.isEmpty(crmProjectResult.getProjectManagerList())) {
-            throw ExceptionResultEnum.ERROR.exception("未设置大区经理");
+            throw ExceptionResultEnum.ERROR.exception("未设置项目经理");
         }
         if (CollectionUtils.isEmpty(crmProjectResult.getEngineerList())) {
             throw ExceptionResultEnum.ERROR.exception("未设置工程师");
@@ -466,14 +473,14 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 new QueryWrapper<TBSopInfo>().lambda().eq(TBSopInfo::getSopNo, tfCustomFlowEntity.getCode()));
         Optional.ofNullable(tbSopInfo).orElseThrow(() -> ExceptionResultEnum.SOP_INFO_NO_DATA.exception());
 
-        TBSopInfoDetail tbSopInfoDetail = tbSopInfoDetailService.getOne(
-                new QueryWrapper<TBSopInfoDetail>().lambda().eq(TBSopInfoDetail::getSopInfoId, tbSopInfo.getId()));
-        Optional.ofNullable(tbSopInfoDetail).orElseThrow(() -> ExceptionResultEnum.SOP_DETAIL_INFO_NO_DATA.exception());
+        //        TBSopInfoDetail tbSopInfoDetail = tbSopInfoDetailService.getOne(
+        //                new QueryWrapper<TBSopInfoDetail>().lambda().eq(TBSopInfoDetail::getSopInfoId, tbSopInfo.getId()));
+        //        Optional.ofNullable(tbSopInfoDetail).orElseThrow(() -> ExceptionResultEnum.SOP_DETAIL_INFO_NO_DATA.exception());
 
         //更新表单信息
-        FlowTaskResult flowTaskResult = JSONObject.parseObject(flowApproveParam.getFormProperties(),
-                FlowTaskResult.class);
-        Long engineerUserId = null;
+        //        FlowTaskResult flowTaskResult = JSONObject.parseObject(flowApproveParam.getFormProperties(),
+        //                FlowTaskResult.class);
+        //        Long engineerUserId = null;
         //        if (flowTaskResult.getSetup().intValue() == 1) {
         //            //            Long regionUserId = null;
         //            String assistantEngineerUserIds = null;
@@ -487,32 +494,41 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         //        } else {
         //            engineerUserId = Long.parseLong(taskApproveUserList.get(0));
         //        }
+        TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
+        Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
+                tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
+        Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
+
         if (flowApproveParam.getApprove() == FlowApprovePassEnum.PASS
                 || flowApproveParam.getApprove() == FlowApprovePassEnum.START) {
-            List<String> approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResult,
-                    tbSopInfoDetail, Long.parseLong(task.getProcessInstanceId()));
+            //            List<String> approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResult,
+            //                    tbSopInfoDetail, Long.parseLong(task.getProcessInstanceId()));
+            //            flowApproveParam.setApproveUserIds(approveUserIds);
+            FlowTaskResult flowTaskResultOne = this.getFormProperties(tfCustomFlowEntity, 1);
+            FlowTaskResult currFlowTaskResult = JSONObject.parseObject(flowApproveParam.getFormProperties(),
+                    FlowTaskResult.class);
+            List<String> approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResultOne,
+                    currFlowTaskResult, crmProjectResult);
             flowApproveParam.setApproveUserIds(approveUserIds);
         }
 
-        if (flowTaskResult.getSetup().intValue() == 3) {//内审时要set全部值
-            FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
-            FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(
-                    GsonUtil.toJson(flowResult.getSetupMap().get(flowTaskResult.getTaskKey())), FlowTaskResult.class);
-            List<FlowFormWidgetResult> flowFormWidgetResultList = currFlowTaskResult.getFormProperty();
-            Map<String, FlowFormWidgetResult> flowTaskResultMap = flowTaskResult.getFormProperty().stream().collect(
-                    Collectors.toMap(FlowFormWidgetResult::getFormId, Function.identity(), (dto1, dto2) -> dto1));
-            for (FlowFormWidgetResult f : flowFormWidgetResultList) {
-                if (flowTaskResultMap.containsKey(f.getFormId())) {
-                    f.setValue(flowTaskResultMap.get(f.getFormId()).getValue());
-                }
-            }
-            flowTaskResult.setFormProperty(flowFormWidgetResultList);
-            flowApproveParam.setFormProperties(JacksonUtil.parseJson(flowTaskResult));
-        }
-
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(), null,
-                tfCustomFlowEntity.getCrmNo());
-        Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
+        //        if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW
+        //                && flowTaskResult.getSetup().intValue() == 3) {//内审时要set全部值
+        //            FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+        //            FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(
+        //                    GsonUtil.toJson(flowResult.getSetupMap().get(flowTaskResult.getTaskKey())), FlowTaskResult.class);
+        //            List<FlowFormWidgetResult> flowFormWidgetResultList = currFlowTaskResult.getFormProperty();
+        //            Map<String, FlowFormWidgetResult> flowTaskResultMap = flowTaskResult.getFormProperty().stream().collect(
+        //                    Collectors.toMap(FlowFormWidgetResult::getFormId, Function.identity(), (dto1, dto2) -> dto1));
+        //            for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+        //                if (flowTaskResultMap.containsKey(f.getFormId())) {
+        //                    f.setValue(flowTaskResultMap.get(f.getFormId()).getValue());
+        //                }
+        //            }
+        //            flowTaskResult.setFormProperty(flowFormWidgetResultList);
+        //            flowApproveParam.setFormProperties(JacksonUtil.parseJson(flowTaskResult));
+        //        }
 
         String oldFlowProcessVar = tfCustomFlowEntity.getFlowProcessVar();
         Map<String, Object> map = activitiService.taskApprove(flowApproveParam);
@@ -539,9 +555,11 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         tbSopInfo.updateInfo(sysUser.getId());
         tbSopInfoService.updateById(tbSopInfo);
 
-        //如果下一步审批是大区经理内审并且区域协调人和大区经理为同一人时,后台自动审批
-        tbSopInfoService.sopSystemApprove(tfCustomFlow, tfCustomFlowEntity, tfFlowApprove, tbSopInfoDetail,
-                flowApproveParam.getCrmNo());
+        //        //如果下一步审批是大区经理内审并且区域协调人和大区经理为同一人时,后台自动审批
+        //        if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+        //            tbSopInfoService.sopSystemApprove(tfCustomFlow, tfCustomFlowEntity, tfFlowApprove,
+        //                    flowApproveParam.getCrmNo());
+        //        }
         return true;
     }
 
@@ -821,21 +839,21 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
      * @param tfCustomFlow
      * @param tfCustomFlowEntity
      * @param tfFlowApprove
-     * @param tbSopInfoDetail
      * @param crmNo
      * @throws InterruptedException
      */
     @Override
     @Transactional
     public void sopSystemApprove(TFCustomFlow tfCustomFlow, TFCustomFlowEntity tfCustomFlowEntity,
-            TFFlowApprove tfFlowApprove, TBSopInfoDetail tbSopInfoDetail, String crmNo) throws InterruptedException {
+            TFFlowApprove tfFlowApprove, String crmNo) throws InterruptedException {
         //如果下一步审批是内审并且区域协调人和大区经理为同一人时,后台自动审批
         if (tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END
-                && tfFlowApprove.getStatus() == FlowStatusEnum.AUDITING && tfFlowApprove.getSetup().intValue() == 3
-                && tbSopInfoDetail.getLeadId().longValue() == tbSopInfoDetail.getRegionUserId().longValue()) {
-            Task taskNew = taskService.createTaskQuery().processInstanceId(String.valueOf(tfFlowApprove.getFlowId()))
-                    .taskAssignee(String.valueOf(tbSopInfoDetail.getLeadId())).singleResult();
-            Optional.ofNullable(taskNew).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
+                && tfFlowApprove.getStatus() == FlowStatusEnum.AUDITING && tfFlowApprove.getSetup().intValue() == 3) {
+            //TODO 研究生SOP待修改
+            //                && tbSopInfoDetail.getLeadId().longValue() == tbSopInfoDetail.getRegionUserId().longValue()) {
+            //            Task taskNew = taskService.createTaskQuery().processInstanceId(String.valueOf(tfFlowApprove.getFlowId()))
+            //                    .taskAssignee(String.valueOf(tbSopInfoDetail.getLeadId())).singleResult();
+            //            Optional.ofNullable(taskNew).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
 
             FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
             LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
@@ -865,10 +883,11 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                     }
                 }
             }
-            activitiService.taskApprove(new FlowApproveParam(Long.parseLong(taskNew.getId()), FlowApprovePassEnum.PASS,
-                    this.getNextApproveUserIds(tfCustomFlow.getType(), nextFlowTaskResult, tbSopInfoDetail,
-                            tfCustomFlowEntity.getFlowId()), crmNo, SystemConstant.SYSTEM_AUTO_APPROVE,
-                    JacksonUtil.parseJson(nextFlowTaskResult)));
+            //TODO 研究生SOP待修改
+            //            activitiService.taskApprove(new FlowApproveParam(Long.parseLong(taskNew.getId()), FlowApprovePassEnum.PASS,
+            //                    this.getNextApproveUserIds(tfCustomFlow.getType(), nextFlowTaskResult, tbSopInfoDetail,
+            //                            tfCustomFlowEntity.getFlowId()), crmNo, SystemConstant.SYSTEM_AUTO_APPROVE,
+            //                    JacksonUtil.parseJson(nextFlowTaskResult)));
         }
     }
 
@@ -877,110 +896,145 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
      *
      * @param type
      * @param flowTaskResult
-     * @param tbSopInfoDetail
-     * @param flowId
+     * @param crmProjectResult
      * @return
      */
     public List<String> getNextApproveUserIds(TFCustomTypeEnum type, FlowTaskResult flowTaskResult,
-            TBSopInfoDetail tbSopInfoDetail, Long flowId) {
-        List<String> approveUserIds = null;
+            FlowTaskResult currFlowTaskResult, CrmProjectResult crmProjectResult) {
+        List<String> approveUserIds = new ArrayList<>();
         if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
-            if (flowTaskResult.getSetup().intValue() == 1) {
-                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getRegionUserId()));
-            } else if (flowTaskResult.getSetup().intValue() == 2) {
-                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()),
-                        String.valueOf(tbSopInfoDetail.getEngineerUserId()));
-            } else if (flowTaskResult.getSetup().intValue() == 3) {
-                List<Task> taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
-                if (!CollectionUtils.isEmpty(taskList) && taskList.size() == 1) {
-                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()));
-                } else {
-                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()),
-                            String.valueOf(tbSopInfoDetail.getEngineerUserId()));
-                }
-            } else {
-                if (flowTaskResult.getSetup().intValue() >= 8 && tbSopInfoDetail.getAfterRegionToEnginess()) {
-                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getRegionUserId()));
-                } else {
-                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+            List<FlowFormWidgetResult> flowFormWidgetResultList = flowTaskResult.getFormProperty();
+            ServiceScopeEnum scopeEnum = null;
+            for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+                if (f.getFormId().contains(ProcessLimitedEnum.SERVICE_SCOPE_RADIO.getKey())) {
+                    JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                    String value = jsonObject.getString(SystemConstant.VALUE);
+                    scopeEnum = ServiceScopeEnum.valueOf(value);
+                    break;
                 }
             }
-        } else if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop流程待审核人
-            if (flowTaskResult.getSetup().intValue() == 1) {
-                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getRegionUserId()));
-            } else if (flowTaskResult.getSetup().intValue() == 2) {
-                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()),
-                        String.valueOf(tbSopInfoDetail.getEngineerUserId()));
-            } else if (flowTaskResult.getSetup().intValue() == 3) {
-                List<Task> taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
-                if (!CollectionUtils.isEmpty(taskList) && taskList.size() == 1) {
-                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()));
+            if (Objects.nonNull(scopeEnum) && scopeEnum == ServiceScopeEnum.SCAN_MARK) {//扫描+阅卷,12345是项目经理
+                for (UserArchivesDto u : crmProjectResult.getProjectManagerList()) {
+                    approveUserIds.add(u.getUserId().toString());
+                }
+            } else if (Objects.nonNull(scopeEnum) && scopeEnum == ServiceScopeEnum.SCAN) {
+                if (currFlowTaskResult.getSetup().intValue() < 3) {
+                    for (UserArchivesDto u : crmProjectResult.getProjectManagerList()) {
+                        approveUserIds.add(u.getUserId().toString());
+                    }
                 } else {
-                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()),
-                            String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+                    //todo 需要调用曹子轩项目经理变更的方法
+                    Objects.requireNonNull(crmProjectResult.getRegionManagerId(), "未设置大区经理");
+                    try {
+                        tbUserArchivesService.findByUserId(crmProjectResult.getRegionManagerId());
+                    } catch (Exception e) {
+                        log.error(SystemConstant.LOG_ERROR, e);
+                        if (e instanceof ApiException) {
+                            ResultUtil.error((ApiException) e, ((ApiException) e).getCode(),
+                                    "人员档案里未找到派单号[" + crmProjectResult.getCrmNo() + "]大区经理角色");
+                        } else {
+                            ResultUtil.error("人员档案里未找到派单号[" + crmProjectResult.getCrmNo() + "]大区经理角色");
+                        }
+                    }
+                    approveUserIds.add(crmProjectResult.getRegionManagerId().toString());
                 }
-            } else {
-                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getEngineerUserId()));
             }
+            //            if (flowTaskResult.getSetup().intValue() == 1) {
+            //                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getRegionUserId()));
+            //            } else if (flowTaskResult.getSetup().intValue() == 2) {
+            //                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()),
+            //                        String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+            //            } else if (flowTaskResult.getSetup().intValue() == 3) {
+            //                List<Task> taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
+            //                if (!CollectionUtils.isEmpty(taskList) && taskList.size() == 1) {
+            //                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()));
+            //                } else {
+            //                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()),
+            //                            String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+            //                }
+            //            } else {
+            //                if (flowTaskResult.getSetup().intValue() >= 8 && tbSopInfoDetail.getAfterRegionToEnginess()) {
+            //                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getRegionUserId()));
+            //                } else {
+            //                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+            //                }
+            //            }
+        } else if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop流程待审核人
+            //            if (flowTaskResult.getSetup().intValue() == 1) {
+            //                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getRegionUserId()));
+            //            } else if (flowTaskResult.getSetup().intValue() == 2) {
+            //                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()),
+            //                        String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+            //            } else if (flowTaskResult.getSetup().intValue() == 3) {
+            //                List<Task> taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
+            //                if (!CollectionUtils.isEmpty(taskList) && taskList.size() == 1) {
+            //                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()));
+            //                } else {
+            //                    approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()),
+            //                            String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+            //                }
+            //            } else {
+            //                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+            //            }
         }
         return approveUserIds;
     }
 
-    //    /**
-    //     * 获取审批人
-    //     *
-    //     * @param flowTaskResult
-    //     * @return
-    //     */
-    //    public Map<String, Object> getApproveUserIds(FlowTaskResult flowTaskResult) {
-    //        Map<String, Object> map = new HashMap<>();
-    //        //        Long regionUserId = null, engineerUserId = null;
-    //        //        String assistantEngineerUserIds = null;
-    //        String engineerUsersIds = null;
-    //        List<FlowFormWidgetResult> formProperty = flowTaskResult.getFormProperty();
-    //        for (FlowFormWidgetResult f : formProperty) {
-    //            //            if (f.getFormId().contains(SystemConstant.REGION_USER_ID) && Objects.nonNull(f.getValue())
-    //            //                    && !Objects.equals(f.getValue(), "{\"value\":null}")) {
-    //            //                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
-    //            //                String value = jsonObject.getString(SystemConstant.VALUE);
-    //            //                regionUserId = Long.parseLong(value);
-    //            //            } else if (f.getFormId().contains(SystemConstant.ASSISTANT_ENGINEER_USER_ID) && Objects.nonNull(
-    //            //                    f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
-    //            //                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
-    //            //                JSONArray jsonArray = jsonObject.getJSONArray(SystemConstant.VALUE);
-    //            //                StringJoiner stringJoiner = new StringJoiner(",");
-    //            //                for (int i = 0; i < jsonArray.size(); i++) {
-    //            //                    stringJoiner.add(jsonArray.getString(i));
-    //            //                }
-    //            //                assistantEngineerUserIds = stringJoiner.toString();
-    //            //            }
-    //            //            else if ((f.getFormId().contains(SystemConstant.ENGINEER_USER_ID) && Objects.nonNull(f.getValue()))
-    //            //                    && !Objects.equals(f.getValue(), "{\"value\":null}")) {
-    //            //                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
-    //            //                String value = jsonObject.getString(SystemConstant.VALUE);
-    //            //                engineerUserId = Long.parseLong(value);
-    //            //            }
-    //            if (f.getFormId().contains(SystemConstant.ENGINEER_USERS_ID) && Objects.nonNull(f.getValue())
-    //                    && !Objects.equals(f.getValue(), "{\"value\":null}")) {
-    //                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
-    //                JSONArray jsonArray = jsonObject.getJSONArray(SystemConstant.VALUE);
-    //                StringJoiner stringJoiner = new StringJoiner(",");
-    //                for (int i = 0; i < jsonArray.size(); i++) {
-    //                    stringJoiner.add(jsonArray.getString(i));
+    //        /**
+    //         * 获取审批人
+    //         *
+    //         * @param flowTaskResult
+    //         * @return
+    //         */
+    //        public Map<String, Object> getApproveUserIds(FlowTaskResult flowTaskResult) {
+    //            Map<String, Object> map = new HashMap<>();
+    //            //        Long regionUserId = null, engineerUserId = null;
+    //            //        String assistantEngineerUserIds = null;
+    //            String engineerUsersIds = null;
+    //            List<FlowFormWidgetResult> formProperty = flowTaskResult.getFormProperty();
+    //            for (FlowFormWidgetResult f : formProperty) {
+    //                //            if (f.getFormId().contains(SystemConstant.REGION_USER_ID) && Objects.nonNull(f.getValue())
+    //                //                    && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+    //                //                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+    //                //                String value = jsonObject.getString(SystemConstant.VALUE);
+    //                //                regionUserId = Long.parseLong(value);
+    //                //            } else if (f.getFormId().contains(SystemConstant.ASSISTANT_ENGINEER_USER_ID) && Objects.nonNull(
+    //                //                    f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+    //                //                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+    //                //                JSONArray jsonArray = jsonObject.getJSONArray(SystemConstant.VALUE);
+    //                //                StringJoiner stringJoiner = new StringJoiner(",");
+    //                //                for (int i = 0; i < jsonArray.size(); i++) {
+    //                //                    stringJoiner.add(jsonArray.getString(i));
+    //                //                }
+    //                //                assistantEngineerUserIds = stringJoiner.toString();
+    //                //            }
+    //                //            else if ((f.getFormId().contains(SystemConstant.ENGINEER_USER_ID) && Objects.nonNull(f.getValue()))
+    //                //                    && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+    //                //                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+    //                //                String value = jsonObject.getString(SystemConstant.VALUE);
+    //                //                engineerUserId = Long.parseLong(value);
+    //                //            }
+    //                if (f.getFormId().contains(SystemConstant.ENGINEER_USERS_ID) && Objects.nonNull(f.getValue())
+    //                        && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+    //                    JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+    //                    JSONArray jsonArray = jsonObject.getJSONArray(SystemConstant.VALUE);
+    //                    StringJoiner stringJoiner = new StringJoiner(",");
+    //                    for (int i = 0; i < jsonArray.size(); i++) {
+    //                        stringJoiner.add(jsonArray.getString(i));
+    //                    }
+    //                    engineerUsersIds = stringJoiner.toString();
+    //                }
+    //                if (Objects.nonNull(engineerUsersIds)) {
+    //                    break;
     //                }
-    //                engineerUsersIds = stringJoiner.toString();
-    //            }
-    //            if (Objects.nonNull(engineerUsersIds)) {
-    //                break;
     //            }
+    //            //        Optional.ofNullable(regionUserId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("区域协调人不能为空"));
+    //            Optional.ofNullable(engineerUsersIds).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("工程师不能为空"));
+    //            //        map.put(SystemConstant.REGION_USER_ID, regionUserId);
+    //            //        map.put(SystemConstant.ENGINEER_USERS_ID, engineerUsersIds);
+    //            //        map.put(SystemConstant.ASSISTANT_ENGINEER_USER_ID, assistantEngineerUserIds);
+    //            return map;
     //        }
-    //        //        Optional.ofNullable(regionUserId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("区域协调人不能为空"));
-    //        Optional.ofNullable(engineerUsersIds).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("工程师不能为空"));
-    //        //        map.put(SystemConstant.REGION_USER_ID, regionUserId);
-    //        //        map.put(SystemConstant.ENGINEER_USERS_ID, engineerUsersIds);
-    //        //        map.put(SystemConstant.ASSISTANT_ENGINEER_USER_ID, assistantEngineerUserIds);
-    //        return map;
-    //    }
 
     //    /**
     //     * sop申请或发布
@@ -1294,13 +1348,14 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                     tsJobRemindService.saveJobRemind(tsJobRemindList);
                 }
             }
-        } else if (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH) {
-            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop
-                tbSopInfoService.sopDeviceInOutSave(map, 10);
-            } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop
-                tbSopInfoService.sopDeviceInOutSave(map, 11);
-            }
         }
+        //        else if (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH) {
+        //            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop
+        //                tbSopInfoService.sopDeviceInOutSave(map, 10);
+        //            } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop
+        //                tbSopInfoService.sopDeviceInOutSave(map, 11);
+        //            }
+        //        }
     }
 
     /**

Some files were not shown because too many files changed in this diff