浏览代码

新增派单sop发布

wangliang 1 年之前
父节点
当前提交
32a503f522

+ 1 - 1
sop-api/install/mysql/init/init.sql

@@ -4462,7 +4462,7 @@ INSERT INTO `t_d_form_widget` (`id`, `code`, `type`, `form_id`, `form_name`, `ti
 INSERT INTO `t_d_form_widget` (`id`, `code`, `type`, `form_id`, `form_name`, `title`, `input_type`, `required`, `readable`, `writable`, `visable`, `scale`, `length`, `binding`, `data_grid`, `tips`, `format`, `span`, `sub_title`, `options`, `flow_type`, `form_setup`, `handle`, `form_group`, `role_type`, `create_id`, `create_time`) VALUES (25, 'DATE', 'FORM', 'scan_end_time', 'scan_end_time', '扫描结束时间', 'LONG', 1, 1, 0, 1, NULL, NULL, NULL, NULL, NULL, 'yyyy-MM-dd', 6, NULL, NULL, 'OFFICE_SOP_FLOW', 1, 1, NULL, NULL, 1, 8);
 INSERT INTO `t_d_form_widget` (`id`, `code`, `type`, `form_id`, `form_name`, `title`, `input_type`, `required`, `readable`, `writable`, `visable`, `scale`, `length`, `binding`, `data_grid`, `tips`, `format`, `span`, `sub_title`, `options`, `flow_type`, `form_setup`, `handle`, `form_group`, `role_type`, `create_id`, `create_time`) VALUES (26, 'DATE', 'FORM', 'mark_start_time', 'mark_start_time', '阅卷参数检查时间', 'LONG', 1, 1, 0, 1, NULL, NULL, NULL, NULL, NULL, 'yyyy-MM-dd', 6, NULL, NULL, 'OFFICE_SOP_FLOW', 1, 1, NULL, NULL, 1, 9);
 INSERT INTO `t_d_form_widget` (`id`, `code`, `type`, `form_id`, `form_name`, `title`, `input_type`, `required`, `readable`, `writable`, `visable`, `scale`, `length`, `binding`, `data_grid`, `tips`, `format`, `span`, `sub_title`, `options`, `flow_type`, `form_setup`, `handle`, `form_group`, `role_type`, `create_id`, `create_time`) VALUES (27, 'DATE', 'FORM', 'mark_end_time', 'mark_end_time', '阅卷收尾检查时间', 'LONG', 1, 1, 0, 1, NULL, NULL, NULL, NULL, NULL, 'yyyy-MM-dd', 6, NULL, NULL, 'OFFICE_SOP_FLOW', 1, 1, NULL, NULL, 1, 10);
-INSERT INTO `t_d_form_widget` (`id`, `code`, `type`, `form_id`, `form_name`, `title`, `input_type`, `required`, `readable`, `writable`, `visable`, `scale`, `length`, `binding`, `data_grid`, `tips`, `format`, `span`, `sub_title`, `options`, `flow_type`, `form_setup`, `handle`, `form_group`, `role_type`, `create_id`, `create_time`) VALUES (28, 'MULTIPLE_SELECT', 'FORM', 'engineer_users_id', 'engineer_users_id', '工程师', 'STRING', 1, 1, 0, 1, NULL, NULL, NULL, NULL, NULL, NULL, 12, NULL, NULL, 'OFFICE_SOP_FLOW', 1, 0, NULL, 'REGION_MANAGER,REGION_COORDINATOR,EFFECT_ENGINEER,ASSISTANT_ENGINEER', 1, 11);
+INSERT INTO `t_d_form_widget` (`id`, `code`, `type`, `form_id`, `form_name`, `title`, `input_type`, `required`, `readable`, `writable`, `visable`, `scale`, `length`, `binding`, `data_grid`, `tips`, `format`, `span`, `sub_title`, `options`, `flow_type`, `form_setup`, `handle`, `form_group`, `role_type`, `create_id`, `create_time`) VALUES (28, 'MULTIPLE_SELECT', 'FORM', 'engineer_users_id', 'engineer_users_id', '工程师', 'ARRAY', 1, 1, 0, 1, NULL, NULL, NULL, NULL, NULL, NULL, 12, NULL, NULL, 'OFFICE_SOP_FLOW', 1, 0, NULL, 'REGION_MANAGER,REGION_COORDINATOR,EFFECT_ENGINEER,ASSISTANT_ENGINEER', 1, 11);
 INSERT INTO `t_d_form_widget` (`id`, `code`, `type`, `form_id`, `form_name`, `title`, `input_type`, `required`, `readable`, `writable`, `visable`, `scale`, `length`, `binding`, `data_grid`, `tips`, `format`, `span`, `sub_title`, `options`, `flow_type`, `form_setup`, `handle`, `form_group`, `role_type`, `create_id`, `create_time`) VALUES (29, 'SIGN', 'FORM', 'sign_region', 'sign_region', '添加签名', 'STRING', 1, 0, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, 6, NULL, NULL, 'OFFICE_SOP_FLOW', 1, 0, 1, NULL, 1, 12);
 INSERT INTO `t_d_form_widget` (`id`, `code`, `type`, `form_id`, `form_name`, `title`, `input_type`, `required`, `readable`, `writable`, `visable`, `scale`, `length`, `binding`, `data_grid`, `tips`, `format`, `span`, `sub_title`, `options`, `flow_type`, `form_setup`, `handle`, `form_group`, `role_type`, `create_id`, `create_time`) VALUES (30, 'FORM_GROUP_TITLE', 'FORM', 'import_data_title', 'import_data_title', '导入数据', 'STRING', 1, 1, 0, 1, NULL, NULL, NULL, NULL, NULL, NULL, 12, NULL, NULL, 'OFFICE_SOP_FLOW', 2, 0, NULL, NULL, 1, 1);
 INSERT INTO `t_d_form_widget` (`id`, `code`, `type`, `form_id`, `form_name`, `title`, `input_type`, `required`, `readable`, `writable`, `visable`, `scale`, `length`, `binding`, `data_grid`, `tips`, `format`, `span`, `sub_title`, `options`, `flow_type`, `form_setup`, `handle`, `form_group`, `role_type`, `create_id`, `create_time`) VALUES (31, 'CHECKBOX', 'FORM', 'data_same', 'data_same', '导入数据', 'STRING', 1, 0, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, 6, NULL, '[{\"value\":\"true\",\"label\":\"导入数据与原始数据是否一致\"}]', 'OFFICE_SOP_FLOW', 2, 0, NULL, NULL, 1, 1);

+ 1 - 1
sop-api/src/main/java/com/qmth/sop/server/api/TBCrmDetailController.java

@@ -162,7 +162,7 @@ public class TBCrmDetailController {
         } finally {
             memoryLock.unlock(SystemConstant.LOCK_CRM_DETAIL_SOP_PUBLISH_PREFIX + id);
         }
-        return ResultUtil.ok();
+        return ResultUtil.ok(result);
     }
 
     @ApiOperation(value = "派单明细sop删除")

+ 1 - 1
sop-api/src/main/java/com/qmth/sop/server/api/TBUserArchivesAllocationController.java

@@ -108,7 +108,7 @@ public class TBUserArchivesAllocationController {
     @RequestMapping(value = "/publish", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "发布成功", response = Result.class)})
     @OperationLog(logType = LogTypeEnum.UPDATE)
-    public Result publishCrmSop(@ApiParam(value = "派单号", required = true) @RequestParam String crmNo) throws InterruptedException {
+    public Result publishCrmSop(@ApiParam(value = "派单号", required = true) @RequestParam String crmNo) throws Exception {
         tbUserArchivesAllocationService.publishSop(crmNo);
         return ResultUtil.ok();
     }

二进制
sop-api/src/main/resources/officeSopFlow.zip


+ 212 - 134
sop-business/src/main/java/com/qmth/sop/business/activiti/listener/ProcessEventListener.java

@@ -7,7 +7,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.sop.business.bean.dto.FlowRejectSequenceDto;
 import com.qmth.sop.business.bean.result.*;
 import com.qmth.sop.business.entity.*;
-import com.qmth.sop.business.service.*;
+import com.qmth.sop.business.service.SysMessageService;
+import com.qmth.sop.business.service.TFCustomFlowEntityService;
+import com.qmth.sop.business.service.TFCustomFlowService;
+import com.qmth.sop.business.service.TSJobRemindService;
 import com.qmth.sop.business.util.SmsSendUtil;
 import com.qmth.sop.common.contant.SpringContextHolder;
 import com.qmth.sop.common.contant.SystemConstant;
@@ -41,127 +44,159 @@ import java.util.*;
  */
 @Component
 public class ProcessEventListener implements ActivitiEventListener, Serializable {
+
     private final static Logger log = LoggerFactory.getLogger(ProcessEventListener.class);
 
     @Override
     public void onEvent(ActivitiEvent event) {
         switch (event.getType()) {
-            case PROCESS_STARTED:
-                // 流程启动
-                log.info("流程启动_PROCESS_STARTED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
-                break;
-            case PROCESS_COMPLETED:
-                // 流程结束
-                log.info("流程结束_PROCESS_COMPLETED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
-                HistoryService historyService = SpringContextHolder.getBean(HistoryService.class);
+        case PROCESS_STARTED:
+            // 流程启动
+            log.info("流程启动_PROCESS_STARTED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}",
+                    event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
+            break;
+        case PROCESS_COMPLETED:
+            // 流程结束
+            log.info("流程结束_PROCESS_COMPLETED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}",
+                    event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
+            HistoryService historyService = SpringContextHolder.getBean(HistoryService.class);
 
-                List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(event.getProcessInstanceId()).list();
-                if (!CollectionUtils.isEmpty(historicVariableInstanceList)) {
-                    TFCustomFlow tfCustomFlow = null;
-                    TFCustomFlowEntity tfCustomFlowEntity = null;
-                    TFFlowApprove tfFlowApprove = null;
-                    TFFlowLog tfFlowLog = null;
-                    for (HistoricVariableInstance h : historicVariableInstanceList) {
-                        if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_CUSTOM)) {
-                            tfCustomFlow = (TFCustomFlow) h.getValue();
-                            Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
-                        }
-                        if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_ENTITY)) {
-                            tfCustomFlowEntity = (TFCustomFlowEntity) h.getValue();
-                            Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
-                        }
-                        if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_APPROVE)) {
-                            tfFlowApprove = (TFFlowApprove) h.getValue();
-                            Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
-                        }
-                        if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_APPROVE_LOG)) {
-                            tfFlowLog = (TFFlowLog) h.getValue();
-                            Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_LOG_NO_DATA.exception());
-                        }
+            List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery()
+                    .processInstanceId(event.getProcessInstanceId()).list();
+            if (!CollectionUtils.isEmpty(historicVariableInstanceList)) {
+                TFCustomFlow tfCustomFlow = null;
+                TFCustomFlowEntity tfCustomFlowEntity = null;
+                TFFlowApprove tfFlowApprove = null;
+                TFFlowLog tfFlowLog = null;
+                for (HistoricVariableInstance h : historicVariableInstanceList) {
+                    if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_CUSTOM)) {
+                        tfCustomFlow = (TFCustomFlow) h.getValue();
+                        Optional.ofNullable(tfCustomFlow)
+                                .orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+                    }
+                    if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_ENTITY)) {
+                        tfCustomFlowEntity = (TFCustomFlowEntity) h.getValue();
+                        Optional.ofNullable(tfCustomFlowEntity)
+                                .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+                    }
+                    if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_APPROVE)) {
+                        tfFlowApprove = (TFFlowApprove) h.getValue();
+                        Optional.ofNullable(tfFlowApprove)
+                                .orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
+                    }
+                    if (Objects.equals(h.getVariableName(), SystemConstant.FLOW_APPROVE_LOG)) {
+                        tfFlowLog = (TFFlowLog) h.getValue();
+                        Optional.ofNullable(tfFlowLog)
+                                .orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_LOG_NO_DATA.exception());
                     }
-                    this.sendFlowFinishSms(tfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove.getStatus(), tfFlowLog);
                 }
-                break;
-            case TASK_CREATED:
-                log.info("流程任务创建_TASK_CREATED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
-                TaskService taskService = SpringContextHolder.getBean(TaskService.class);
-                ActivitiEntityEvent activitiEntityEvent = (ActivitiEntityEvent) event;
-                if (activitiEntityEvent.getEntity() instanceof Task) {
-                    Task task = (Task) activitiEntityEvent.getEntity();
-                    if (Objects.nonNull(task)) {
-                        TFCustomFlow tfCustomFlow = (TFCustomFlow) taskService.getVariable(task.getId(), SystemConstant.FLOW_CUSTOM);
-                        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
-
-                        TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) taskService.getVariable(task.getId(), SystemConstant.FLOW_ENTITY);
-                        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+                this.sendFlowFinishSms(tfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove.getStatus(),
+                        tfFlowLog);
+            }
+            break;
+        case TASK_CREATED:
+            log.info("流程任务创建_TASK_CREATED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}",
+                    event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
+            TaskService taskService = SpringContextHolder.getBean(TaskService.class);
+            ActivitiEntityEvent activitiEntityEvent = (ActivitiEntityEvent) event;
+            if (activitiEntityEvent.getEntity() instanceof Task) {
+                Task task = (Task) activitiEntityEvent.getEntity();
+                if (Objects.nonNull(task)) {
+                    TFCustomFlow tfCustomFlow = (TFCustomFlow) taskService.getVariable(task.getId(),
+                            SystemConstant.FLOW_CUSTOM);
+                    if (Objects.nonNull(tfCustomFlow)) {
+                        TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) taskService.getVariable(
+                                task.getId(), SystemConstant.FLOW_ENTITY);
+                        Optional.ofNullable(tfCustomFlowEntity)
+                                .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
 
-                        TFFlowApprove tfFlowApprove = (TFFlowApprove) taskService.getVariable(task.getId(), SystemConstant.FLOW_APPROVE);
-                        Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
+                        TFFlowApprove tfFlowApprove = (TFFlowApprove) taskService.getVariable(task.getId(),
+                                SystemConstant.FLOW_APPROVE);
+                        Optional.ofNullable(tfFlowApprove)
+                                .orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
-                        TFFlowLog tfFlowLog = (TFFlowLog) taskService.getVariable(task.getId(), SystemConstant.FLOW_APPROVE_LOG);
-                        Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_LOG_NO_DATA.exception());
+                        TFFlowLog tfFlowLog = (TFFlowLog) taskService.getVariable(task.getId(),
+                                SystemConstant.FLOW_APPROVE_LOG);
+                        Optional.ofNullable(tfFlowLog)
+                                .orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_LOG_NO_DATA.exception());
 
                         //此处统一流程节点保存延期预警任务
-                        if ((tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW)
+                        if ((tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW
+                                || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW)
                                 && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.DRAFT
                                 && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.END
                                 && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.FINISH) {
                             if (Objects.nonNull(task.getAssignee())) {
-                                this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), Long.parseLong(task.getAssignee()));
+                                this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(),
+                                        Long.parseLong(task.getAssignee()));
                             } else {
                                 List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
                                 if (!CollectionUtils.isEmpty(identityLinkList)) {
                                     for (IdentityLink i : identityLinkList) {
-                                        this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), Long.parseLong(i.getUserId()));
+                                        this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity,
+                                                task.getName(), Long.parseLong(i.getUserId()));
                                     }
                                 }
                             }
                         }
                     }
                 }
-                break;
-            case TASK_COMPLETED:
-                // 任务被完成了。它会在ENTITY_DELETE事件之前触发。当任务是流程一部分时,事件会在流程继续运行之前, 后续事件将是ACTIVITY_COMPLETE,对应着完成任务的节点。
-                log.info("流程任务完成_TASK_COMPLETED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
-                taskService = SpringContextHolder.getBean(TaskService.class);
-                TSJobRemindService jobRemindService = SpringContextHolder.getBean(TSJobRemindService.class);
-                activitiEntityEvent = (ActivitiEntityEvent) event;
-                if (activitiEntityEvent.getEntity() instanceof Task) {
-                    Task task = (Task) activitiEntityEvent.getEntity();
-                    if (Objects.nonNull(task)) {
-                        TFCustomFlow tfCustomFlow = (TFCustomFlow) taskService.getVariable(task.getId(), SystemConstant.FLOW_CUSTOM);
-                        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+            }
+            break;
+        case TASK_COMPLETED:
+            // 任务被完成了。它会在ENTITY_DELETE事件之前触发。当任务是流程一部分时,事件会在流程继续运行之前, 后续事件将是ACTIVITY_COMPLETE,对应着完成任务的节点。
+            log.info("流程任务完成_TASK_COMPLETED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}",
+                    event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
+            taskService = SpringContextHolder.getBean(TaskService.class);
+            TSJobRemindService jobRemindService = SpringContextHolder.getBean(TSJobRemindService.class);
+            activitiEntityEvent = (ActivitiEntityEvent) event;
+            if (activitiEntityEvent.getEntity() instanceof Task) {
+                Task task = (Task) activitiEntityEvent.getEntity();
+                if (Objects.nonNull(task)) {
+                    TFCustomFlow tfCustomFlow = (TFCustomFlow) taskService.getVariable(task.getId(),
+                            SystemConstant.FLOW_CUSTOM);
+                    Optional.ofNullable(tfCustomFlow)
+                            .orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
 
-                        TFFlowLog tfFlowLog = (TFFlowLog) taskService.getVariable(task.getId(), SystemConstant.FLOW_APPROVE_LOG);
-                        Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_LOG_NO_DATA.exception());
+                    TFFlowLog tfFlowLog = (TFFlowLog) taskService.getVariable(task.getId(),
+                            SystemConstant.FLOW_APPROVE_LOG);
+                    Optional.ofNullable(tfFlowLog)
+                            .orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_LOG_NO_DATA.exception());
 
-                        if ((tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) && tfFlowLog.getApproveSetup().intValue() > 1) {//流程提交不需要提醒
-                            //任务完成后统一设置延期预警任务enable为false
-                            jobRemindService.updateJobRemind(Long.parseLong(task.getId()));
-                        }
+                    if ((tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW
+                            || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW)
+                            && tfFlowLog.getApproveSetup().intValue() > 1) {//流程提交不需要提醒
+                        //任务完成后统一设置延期预警任务enable为false
+                        jobRemindService.updateJobRemind(Long.parseLong(task.getId()));
                     }
                 }
-                break;
-            case ENTITY_CREATED:
-                activitiEntityEvent = (ActivitiEntityEvent) event;
-                if (activitiEntityEvent.getEntity() instanceof ResourceEntity) {
-                    ResourceEntity resourceEntity = (ResourceEntity) activitiEntityEvent.getEntity();
-                    log.info("ENTITY_CREATED,id:{},name:{},deploymentId:{},persistentState:{}", resourceEntity.getId(), resourceEntity.getName(), resourceEntity.getDeploymentId(), resourceEntity.getPersistentState());
-                    String xml = new String(resourceEntity.getBytes(), StandardCharsets.UTF_8);
-                    if (resourceEntity.getName().endsWith(SystemConstant.BPMN_PREFIX)) {
-                        parseXml(xml, resourceEntity);
-                    } else {
-//                        log.info("ENTITY_CREATED,data:{}", data);
-                        SystemConstant.FLOW_MAP.add(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + resourceEntity.getName(), xml);
-                        if (SystemConstant.FLOW_MAP.containsKey(resourceEntity.getDeploymentId() + SystemConstant.BPMN_PREFIX)) {
-                            parseXml(SystemConstant.FLOW_MAP.get(resourceEntity.getDeploymentId() + SystemConstant.BPMN_PREFIX).get(0), resourceEntity);
-                        }
+            }
+            break;
+        case ENTITY_CREATED:
+            activitiEntityEvent = (ActivitiEntityEvent) event;
+            if (activitiEntityEvent.getEntity() instanceof ResourceEntity) {
+                ResourceEntity resourceEntity = (ResourceEntity) activitiEntityEvent.getEntity();
+                log.info("ENTITY_CREATED,id:{},name:{},deploymentId:{},persistentState:{}", resourceEntity.getId(),
+                        resourceEntity.getName(), resourceEntity.getDeploymentId(),
+                        resourceEntity.getPersistentState());
+                String xml = new String(resourceEntity.getBytes(), StandardCharsets.UTF_8);
+                if (resourceEntity.getName().endsWith(SystemConstant.BPMN_PREFIX)) {
+                    parseXml(xml, resourceEntity);
+                } else {
+                    //                        log.info("ENTITY_CREATED,data:{}", data);
+                    SystemConstant.FLOW_MAP.add(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE
+                            + resourceEntity.getName(), xml);
+                    if (SystemConstant.FLOW_MAP.containsKey(
+                            resourceEntity.getDeploymentId() + SystemConstant.BPMN_PREFIX)) {
+                        parseXml(SystemConstant.FLOW_MAP.get(
+                                resourceEntity.getDeploymentId() + SystemConstant.BPMN_PREFIX).get(0), resourceEntity);
                     }
                 }
-                break;
-            default:
-//                log.info("default->type:{},ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getType(), event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
-                break;
+            }
+            break;
+        default:
+            //                log.info("default->type:{},ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getType(), event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
+            break;
         }
     }
 
@@ -177,9 +212,9 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
      * @param resourceEntity
      */
     protected void parseXml(String xml, ResourceEntity resourceEntity) {
-//        log.info("ENTITY_CREATED,xml:{}", xml);
+        //        log.info("ENTITY_CREATED,xml:{}", xml);
         try {
-//            TDFormWidgetService tdFormWidgetService = SpringContextHolder.getBean(TDFormWidgetService.class);
+            //            TDFormWidgetService tdFormWidgetService = SpringContextHolder.getBean(TDFormWidgetService.class);
             Document doc = DocumentHelper.parseText(xml);
             Element rootElement = doc.getRootElement();
             // 通过element对象的elementIterator方法获取迭代器
@@ -191,13 +226,13 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                 Element element = (Element) iterator.next();
                 List<Attribute> attributes = element.attributes();
                 for (Attribute attr : attributes) {
-//                    log.info("属性:{},---值:{}", attr.getName(), attr.getValue());
-                    if (Objects.equals(attr.getName(), SystemConstant.ID) &&
-                            (Objects.equals(attr.getValue(), TFCustomTypeEnum.OFFICE_SOP_FLOW.name())
-                                    || Objects.equals(attr.getValue(), TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW.name())
-                                    || Objects.equals(attr.getValue(), TFCustomTypeEnum.DING_EXCEPTION_FLOW.name())
-                                    || Objects.equals(attr.getValue(), TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW.name())
-                                    || Objects.equals(attr.getValue(), TFCustomTypeEnum.QUALITY_PROBLEM_FLOW.name()))) {
+                    //                    log.info("属性:{},---值:{}", attr.getName(), attr.getValue());
+                    if (Objects.equals(attr.getName(), SystemConstant.ID) && (
+                            Objects.equals(attr.getValue(), TFCustomTypeEnum.OFFICE_SOP_FLOW.name()) || Objects.equals(
+                                    attr.getValue(), TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW.name()) || Objects.equals(
+                                    attr.getValue(), TFCustomTypeEnum.DING_EXCEPTION_FLOW.name()) || Objects.equals(
+                                    attr.getValue(), TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW.name()) || Objects.equals(
+                                    attr.getValue(), TFCustomTypeEnum.QUALITY_PROBLEM_FLOW.name()))) {
                         customTypeEnum = TFCustomTypeEnum.valueOf(attr.getValue());
                         break;
                     }
@@ -207,11 +242,13 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                     FlowTaskResult flowTaskResult = new FlowTaskResult();
                     Element node = (Element) itt.next();
                     attributes = node.attributes();
-//                    log.info("节点:{},---值:{}", node.getName(), node.getStringValue());
-                    if (Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(node.getName(), SystemConstant.START_EVENT) || Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
+                    //                    log.info("节点:{},---值:{}", node.getName(), node.getStringValue());
+                    if (Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(node.getName(),
+                            SystemConstant.START_EVENT) || Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
                         for (Attribute attr : attributes) {
-//                            log.info("节点属性:{},---节点值:{}", attr.getName(), attr.getValue());
-                            if (Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
+                            //                            log.info("节点属性:{},---节点值:{}", attr.getName(), attr.getValue());
+                            if (Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(
+                                    node.getName(), SystemConstant.END_EVENT)) {
                                 if (Objects.equals(attr.getName(), SystemConstant.ID)) {
                                     flowTaskResult.setTaskKey(attr.getValue());
                                     String[] strs = attr.getValue().split("_");
@@ -219,22 +256,39 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                                     setupMap.put(attr.getValue(), flowTaskResult);
                                 } else if (Objects.equals(attr.getName(), SystemConstant.NAME)) {
                                     flowTaskResult.setTaskName(attr.getValue());
-                                } else if (Objects.equals(attr.getName(), SystemConstant.FORM_KEY) && SystemConstant.FLOW_MAP.containsKey(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + attr.getValue())) {
-                                    if (Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
+                                } else if (Objects.equals(attr.getName(), SystemConstant.FORM_KEY)
+                                        && SystemConstant.FLOW_MAP.containsKey(
+                                        resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE
+                                                + attr.getValue())) {
+                                    if (Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(
+                                            node.getName(), SystemConstant.END_EVENT)) {
                                         flowTaskResult.setFormKey(attr.getValue());
                                         //从数据库取
-//                                        List<FlowFormWidgetResult> listData = tdFormWidgetService.flowWidgetQuery(customTypeEnum, flowTaskResult.getSetup());
-                                        List<String> list = SystemConstant.FLOW_MAP.get(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + attr.getValue());
+                                        //                                        List<FlowFormWidgetResult> listData = tdFormWidgetService.flowWidgetQuery(customTypeEnum, flowTaskResult.getSetup());
+                                        List<String> list = SystemConstant.FLOW_MAP.get(
+                                                resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE
+                                                        + attr.getValue());
                                         String data = list.get(list.size() - 1);
-                                        List<FlowFormWidgetResult> listData = JSONArray.parseArray(data, FlowFormWidgetResult.class);
+                                        List<FlowFormWidgetResult> listData = JSONArray.parseArray(data,
+                                                FlowFormWidgetResult.class);
                                         for (FlowFormWidgetResult f : listData) {
                                             String[] strs = flowTaskResult.getTaskKey().split("_");
-                                            f.setFormId(f.getFormId() + SystemConstant.FLOW_FORM_ID_UNDERLINE + Integer.parseInt(strs[strs.length - 1]));
-                                            f.setFormName(f.getFormName() + SystemConstant.FLOW_FORM_ID_UNDERLINE + Integer.parseInt(strs[strs.length - 1]));
+                                            f.setFormId(f.getFormId() + SystemConstant.FLOW_FORM_ID_UNDERLINE
+                                                    + Integer.parseInt(strs[strs.length - 1]));
+                                            f.setFormName(f.getFormName() + SystemConstant.FLOW_FORM_ID_UNDERLINE
+                                                    + Integer.parseInt(strs[strs.length - 1]));
                                             if (!CollectionUtils.isEmpty(f.getTablePropList())) {
                                                 for (FlowTablePropResult t : f.getTablePropList()) {
-                                                    t.setTdId(t.getWidgetId() + SystemConstant.FLOW_FORM_ID_UNDERLINE + Integer.parseInt(strs[strs.length - 1]) + SystemConstant.FLOW_FORM_ID_UNDERLINE + t.getTdId() + SystemConstant.FLOW_FORM_ID_UNDERLINE + Integer.parseInt(strs[strs.length - 1]));
-                                                    t.setTdName(t.getWidgetId() + SystemConstant.FLOW_FORM_ID_UNDERLINE + Integer.parseInt(strs[strs.length - 1]) + SystemConstant.FLOW_FORM_ID_UNDERLINE + t.getTdName() + SystemConstant.FLOW_FORM_ID_UNDERLINE + Integer.parseInt(strs[strs.length - 1]));
+                                                    t.setTdId(t.getWidgetId() + SystemConstant.FLOW_FORM_ID_UNDERLINE
+                                                            + Integer.parseInt(strs[strs.length - 1])
+                                                            + SystemConstant.FLOW_FORM_ID_UNDERLINE + t.getTdId()
+                                                            + SystemConstant.FLOW_FORM_ID_UNDERLINE + Integer.parseInt(
+                                                            strs[strs.length - 1]));
+                                                    t.setTdName(t.getWidgetId() + SystemConstant.FLOW_FORM_ID_UNDERLINE
+                                                            + Integer.parseInt(strs[strs.length - 1])
+                                                            + SystemConstant.FLOW_FORM_ID_UNDERLINE + t.getTdName()
+                                                            + SystemConstant.FLOW_FORM_ID_UNDERLINE + Integer.parseInt(
+                                                            strs[strs.length - 1]));
                                                 }
                                             }
                                         }
@@ -242,16 +296,21 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                                     }
                                 }
                             } else {
-                                List<String> list = SystemConstant.FLOW_MAP.get(resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE + attr.getValue());
+                                List<String> list = SystemConstant.FLOW_MAP.get(
+                                        resourceEntity.getDeploymentId() + SystemConstant.FLOW_FORM_ID_SPACE
+                                                + attr.getValue());
                                 if (!CollectionUtils.isEmpty(list)) {
                                     String data = list.get(list.size() - 1);
                                     if (Objects.nonNull(data)) {
                                         JSONObject jsonObject = JSONObject.parseObject(data);
-                                        if (Objects.nonNull(jsonObject.getJSONObject(SystemConstant.ARRROVE_REJECT_MAP))) {
-                                            JSONObject object = jsonObject.getJSONObject(SystemConstant.ARRROVE_REJECT_MAP);
+                                        if (Objects.nonNull(
+                                                jsonObject.getJSONObject(SystemConstant.ARRROVE_REJECT_MAP))) {
+                                            JSONObject object = jsonObject.getJSONObject(
+                                                    SystemConstant.ARRROVE_REJECT_MAP);
                                             approveRejectMap = new LinkedHashMap<>(object.size());
                                             for (Map.Entry<String, Object> entry : object.entrySet()) {
-                                                approveRejectMap.put(entry.getKey(), (List<FlowRejectSequenceDto>) entry.getValue());
+                                                approveRejectMap.put(entry.getKey(),
+                                                        (List<FlowRejectSequenceDto>) entry.getValue());
                                             }
                                         }
                                     }
@@ -261,9 +320,11 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                     }
                 }
             }
-            List<Map.Entry<String, FlowTaskResult>> entryList = new ArrayList<Map.Entry<String, FlowTaskResult>>(setupMap.entrySet());
+            List<Map.Entry<String, FlowTaskResult>> entryList = new ArrayList<Map.Entry<String, FlowTaskResult>>(
+                    setupMap.entrySet());
             //比较器
             Collections.sort(entryList, new Comparator<Map.Entry<String, FlowTaskResult>>() {
+
                 @Override
                 public int compare(Map.Entry<String, FlowTaskResult> o1, Map.Entry<String, FlowTaskResult> o2) {
                     if (o2.getValue().getSetup() < o1.getValue().getSetup()) {
@@ -288,13 +349,17 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                 }
                 setupMap.put(tmpEntry.getKey(), flowTaskResult);
             }
-            FlowResult flowResult = new FlowResult(resourceEntity.getDeploymentId(), resourceEntity.getName(), setupMap);
-//            log.info("flowResult:{}", JacksonUtil.parseJson(flowResult));
+            FlowResult flowResult = new FlowResult(resourceEntity.getDeploymentId(), resourceEntity.getName(),
+                    setupMap);
+            //            log.info("flowResult:{}", JacksonUtil.parseJson(flowResult));
             TFCustomFlowService tfCustomFlowService = SpringContextHolder.getBean(TFCustomFlowService.class);
-            TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowResult.getFlowDeploymentId()));
+            TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda()
+                    .eq(TFCustomFlow::getFlowDeploymentId, flowResult.getFlowDeploymentId()));
             if (Objects.isNull(tfCustomFlow)) {
-                TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, flowResult.getFlowName(), customTypeEnum);
-                tfCustomFlow = new TFCustomFlow(null, flowResult.getFlowName(), customTypeEnum, flowResult.getFlowDeploymentId(), TFCustomModelTypeEnum.USER_FIXED);
+                TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, flowResult.getFlowName(),
+                        customTypeEnum);
+                tfCustomFlow = new TFCustomFlow(null, flowResult.getFlowName(), customTypeEnum,
+                        flowResult.getFlowDeploymentId(), TFCustomModelTypeEnum.USER_FIXED);
                 flowResult.setId(tfCustomFlow.getId());
                 if (Objects.nonNull(maxTfCustomFlow)) {
                     tfCustomFlow.setVersion(maxTfCustomFlow.getVersion() + 1);
@@ -324,12 +389,16 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
      * @param taskName
      * @param userId
      */
-    protected void sendSopFlowDoneSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, String taskName, Long userId) {
+    protected void sendSopFlowDoneSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, String taskName,
+            Long userId) {
         SmsSendUtil smsSendUtil = SpringContextHolder.getBean(SmsSendUtil.class);
-        TFCustomFlowEntityService tfCustomFlowEntityService = SpringContextHolder.getBean(TFCustomFlowEntityService.class);
-        FlowTaskSmsResult flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(tfCustomFlowEntity.getId(), userId);
+        TFCustomFlowEntityService tfCustomFlowEntityService = SpringContextHolder.getBean(
+                TFCustomFlowEntityService.class);
+        FlowTaskSmsResult flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(
+                tfCustomFlowEntity.getId(), userId);
         if (Objects.isNull(flowTaskSmsResult)) {
-            flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(tfCustomFlowEntity.getCrmNo(), userId);
+            flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(tfCustomFlowEntity.getCrmNo(),
+                    userId);
         }
         Optional.ofNullable(flowTaskSmsResult).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
         Map<String, Object> templateParam = new HashMap<>();
@@ -348,13 +417,17 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
      * @param status
      * @param tfFlowLog
      */
-    protected void sendFlowFinishSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, FlowStatusEnum status, TFFlowLog tfFlowLog) {
+    protected void sendFlowFinishSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity,
+            FlowStatusEnum status, TFFlowLog tfFlowLog) {
         SmsSendUtil smsSendUtil = SpringContextHolder.getBean(SmsSendUtil.class);
         SysMessageService sysMessageService = SpringContextHolder.getBean(SysMessageService.class);
-        TFCustomFlowEntityService tfCustomFlowEntityService = SpringContextHolder.getBean(TFCustomFlowEntityService.class);
+        TFCustomFlowEntityService tfCustomFlowEntityService = SpringContextHolder.getBean(
+                TFCustomFlowEntityService.class);
 
-        if ((type == TFCustomTypeEnum.DING_EXCEPTION_FLOW || type == TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW) && status == FlowStatusEnum.FINISH) {//流程结束发送短信
-            FlowTaskMsgResult flowTaskMsgResult = tfCustomFlowEntityService.getFlowTaskRemindMsgInfo(tfCustomFlowEntity.getId(), tfCustomFlowEntity.getCreateId());
+        if ((type == TFCustomTypeEnum.DING_EXCEPTION_FLOW || type == TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW)
+                && status == FlowStatusEnum.FINISH) {//流程结束发送短信
+            FlowTaskMsgResult flowTaskMsgResult = tfCustomFlowEntityService.getFlowTaskRemindMsgInfo(
+                    tfCustomFlowEntity.getId(), tfCustomFlowEntity.getCreateId());
             Optional.ofNullable(flowTaskMsgResult).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
 
             SysMessage sysMessage = null;
@@ -364,15 +437,19 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
             if (type == TFCustomTypeEnum.DING_EXCEPTION_FLOW) {//考勤异常
                 content = MessageEnum.NOTICE_OF_DING_EXCEPTION.getTemplate();
                 content = content.replaceAll("\\$\\{userName\\}", flowTaskMsgResult.getRealName());
-                content = content.replaceAll("\\$\\{dingDate\\}", DateUtil.format(new Date(flowTaskMsgResult.getApplyTime()), SystemConstant.DEFAULT_DATE_PATTERN));
+                content = content.replaceAll("\\$\\{dingDate\\}",
+                        DateUtil.format(new Date(flowTaskMsgResult.getApplyTime()),
+                                SystemConstant.DEFAULT_DATE_PATTERN));
                 content = content.replaceAll("\\$\\{approveRemark\\}", tfFlowLog.getApproveRemark());
 
                 configKey = SystemConstant.SMS_FLOW_DING_EXCEPTION_FINISH_CODE;
-                templateParam.put("dingDate", DateUtil.format(new Date(flowTaskMsgResult.getApplyTime()), SystemConstant.DEFAULT_DATE_PATTERN));
+                templateParam.put("dingDate", DateUtil.format(new Date(flowTaskMsgResult.getApplyTime()),
+                        SystemConstant.DEFAULT_DATE_PATTERN));
                 templateParam.put("approveRemark", tfFlowLog.getApproveRemark());
 
                 sysMessage = new SysMessage(tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(),
-                        MessageTypeEnum.EXCEPTION_APPROVE, type.name(), flowTaskMsgResult.getServiceId(), tfCustomFlowEntity.getCreateId(), content,tfCustomFlowEntity.getCreateId());
+                        MessageTypeEnum.EXCEPTION_APPROVE, type.name(), flowTaskMsgResult.getServiceId(),
+                        tfCustomFlowEntity.getCreateId(), content, tfCustomFlowEntity.getCreateId());
             } else if (type == TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW) {//项目计划变更
                 content = MessageEnum.NOTICE_OF_PROJECT_EXCHANGE.getTemplate();
                 content = content.replaceAll("\\$\\{userName\\}", flowTaskMsgResult.getRealName());
@@ -386,7 +463,8 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                 templateParam.put("exchangeType", flowTaskMsgResult.getExchangeType().getTitle());
 
                 sysMessage = new SysMessage(tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(),
-                        MessageTypeEnum.SYSTEM_PLAN_CHANGE, type.name(), flowTaskMsgResult.getServiceId(), tfCustomFlowEntity.getCreateId(), content,tfCustomFlowEntity.getCreateId());
+                        MessageTypeEnum.SYSTEM_PLAN_CHANGE, type.name(), flowTaskMsgResult.getServiceId(),
+                        tfCustomFlowEntity.getCreateId(), content, tfCustomFlowEntity.getCreateId());
             }
             //发送消息
             sysMessageService.saveSysMessage(Arrays.asList(sysMessage));

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopPublishParam.java

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: sop发布param
@@ -42,6 +43,17 @@ public class SopPublishParam extends FlowApproveParam implements Serializable {
         setApproveUserIds(approveUserIds);
     }
 
+    public SopPublishParam(String crmNo, Long crmDetailId, String flowDeploymentId, FlowApprovePassEnum approve,
+            String formProperties, List<String> approveUserIds, Map<String, Object> var) {
+        setCrmNo(crmNo);
+        this.crmDetailId = crmDetailId;
+        setFlowDeploymentId(flowDeploymentId);
+        setApprove(approve);
+        setFormProperties(formProperties);
+        setApproveUserIds(approveUserIds);
+        setVar(var);
+    }
+
     public Long getCrmDetailId() {
         return crmDetailId;
     }

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

@@ -76,7 +76,7 @@ public interface TBCrmDetailService extends IService<TBCrmDetail> {
      * @param id
      * @return
      */
-    public boolean sopPublish(Long id) throws InterruptedException;
+    public boolean sopPublish(Long id) throws Exception;
 
     /**
      * 派单明细sop删除

+ 18 - 3
sop-business/src/main/java/com/qmth/sop/business/service/TBSopInfoService.java

@@ -6,10 +6,12 @@ import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.params.SopInfoListParam;
 import com.qmth.sop.business.bean.params.SopPublishParam;
 import com.qmth.sop.business.bean.params.SopSaveParam;
+import com.qmth.sop.business.bean.result.CrmProjectResult;
 import com.qmth.sop.business.bean.result.FlowResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.bean.result.SopInfoResult;
 import com.qmth.sop.business.entity.*;
+import com.qmth.sop.common.enums.TFCustomTypeEnum;
 
 import java.util.List;
 import java.util.Map;
@@ -69,7 +71,7 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @param sopPublishParam
      * @return
      */
-    String sopPublish(SopPublishParam sopPublishParam) throws InterruptedException;
+    String sopPublish(SopPublishParam sopPublishParam) throws Exception;
 
     /**
      * sop申请信息
@@ -153,10 +155,11 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @param sopId
      * @param flowId
      * @param userId
+     * @param type
      * @throws InterruptedException
      */
-    public void saveSopPlanDate(FlowTaskResult flowTaskResult, Long sopId, Long flowId, Long userId)
-            throws InterruptedException;
+    public void saveSopPlanDate(FlowTaskResult flowTaskResult, Long sopId, Long flowId, Long userId,
+            TFCustomTypeEnum type) throws InterruptedException;
 
     /**
      * sop保存设备信息
@@ -201,4 +204,16 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @return
      */
     public FlowTaskResult getFormProperties(TFCustomFlowEntity tfCustomFlowEntity, Integer setup);
+
+    /**
+     * 设置流程第一步值
+     *
+     * @param sopPublishParam
+     * @param tfCustomFlow
+     * @param crmProjectResult
+     * @return
+     * @throws Exception
+     */
+    public SopPublishParam setSetupOne(SopPublishParam sopPublishParam, TFCustomFlow tfCustomFlow,
+            CrmProjectResult crmProjectResult) throws Exception;
 }

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

@@ -80,7 +80,7 @@ public interface TBUserArchivesAllocationService extends IService<TBUserArchives
      *
      * @param crmNo crmNo
      */
-    void publishSop(String crmNo) throws InterruptedException;
+    void publishSop(String crmNo) throws Exception;
 
     /**
      * crm派单 sop流程撤销发布

+ 13 - 3
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmDetailServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcel;
 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;
@@ -62,6 +63,9 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
     @Resource
     TBSopInfoService tbSopInfoService;
 
+    @Resource
+    ActivitiService activitiService;
+
     /**
      * 查找派单sop信息
      *
@@ -256,7 +260,7 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
      */
     @Override
     @Transactional
-    public boolean sopPublish(Long id) throws InterruptedException {
+    public boolean sopPublish(Long id) throws Exception {
         TBCrmDetail tbCrmDetail = tbCrmDetailService.getById(id);
         Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
 
@@ -266,11 +270,17 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         tbCrmDetail.updateStatus(CrmStatusEnum.PUBLISH, sysUser.getId());
 
+        TBCrm tbCrm = tbCrmService.findByCrmNo(tbCrmDetail.getCrmNo());
         //发布流程
         TFCustomFlow tfCustomFlow = tbCrmDetailService.queryCustomFlow(tbCrmDetail.getCrmNo());
+        Map<String, Object> var = new HashMap<>();
+        var.put(SystemConstant.CRM_DETAIL, tbCrmDetail);
+        var.put(SystemConstant.PROCESS_VAR, tbCrm.getProcessVar());
+
         SopPublishParam sopPublishParam = new SopPublishParam(tbCrmDetail.getCrmNo(), tbCrmDetail.getId(),
-                tfCustomFlow.getFlowDeploymentId(), FlowApprovePassEnum.START, null, null);
-        tbSopInfoService.sopPublish(sopPublishParam);
+                tfCustomFlow.getFlowDeploymentId(), FlowApprovePassEnum.DRAFT, null, null, var);
+        String sopNo = tbSopInfoService.sopPublish(sopPublishParam);
+        tbCrmDetail.setSopNo(sopNo);
         return tbCrmDetailService.updateById(tbCrmDetail);
     }
 

+ 116 - 30
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -261,18 +261,27 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
      */
     @Override
     @Transactional
-    public String sopPublish(SopPublishParam sopPublishParam) throws InterruptedException {
+    public String sopPublish(SopPublishParam sopPublishParam) throws Exception {
         Objects.requireNonNull(sopPublishParam.getCrmNo(), "crm编号不能为空");
+
+        if (sopPublishParam.getApprove() != FlowApprovePassEnum.DRAFT) {
+            throw ExceptionResultEnum.PARAMS_ERROR.exception("sop发布只能为草稿");
+        }
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopPublishParam.getSopNo(),null,
-                sopPublishParam.getCrmNo());
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopPublishParam.getSopNo(),
+                sopPublishParam.getCrmDetailId(), sopPublishParam.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
-        //todo 项目经理、工程师待验证
-        //        Optional.ofNullable(crmProjectResult.getRegionManagerId())
-        //                .orElseThrow(() -> ExceptionResultEnum.ERROR.exception("该派单号[" + crmNo + "]未设置大区经理"));
-        //TODO 测试人员
-        sopPublishParam.setApproveUserIds(Arrays.asList("517302850875817984"));
+        if (CollectionUtils.isEmpty(crmProjectResult.getProjectManagerList())) {
+            throw ExceptionResultEnum.ERROR.exception("未设置大区经理");
+        }
+        if (CollectionUtils.isEmpty(crmProjectResult.getEngineerList())) {
+            throw ExceptionResultEnum.ERROR.exception("未设置工程师");
+        }
+        List<String> approveUserIds = new ArrayList<>(crmProjectResult.getProjectManagerList().size());
+        crmProjectResult.getProjectManagerList().stream().peek(e -> approveUserIds.add(e.getUserId().toString()))
+                .collect(Collectors.toList());
+        sopPublishParam.setApproveUserIds(approveUserIds);
 
         TBService tbService = tbServiceService.getById(crmProjectResult.getServiceUnitId());
         Optional.ofNullable(tbService).orElseThrow(() -> ExceptionResultEnum.SERVICE_NO_DATA.exception());
@@ -298,9 +307,8 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 && tfCustomFlow.getType() != TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
             throw ExceptionResultEnum.ERROR.exception("sop流程类型错误");
         }
+        sopPublishParam = tbSopInfoService.setSetupOne(sopPublishParam, tfCustomFlow, crmProjectResult);
         Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(sopPublishParam));
-        map.put(SystemConstant.CRM_INFO, crmProjectResult);
-
         tfCustomFlow = Objects.isNull(tfCustomFlow) ? (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM) : tfCustomFlow;
         TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
 
@@ -308,10 +316,6 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 crmProjectResult.getServiceUnitId(), crmProjectResult.getCustomId(), crmProjectResult.getProductId(),
                 tfCustomFlow.getType(), SopStatusEnum.valueOf(sopPublishParam.getApprove().name()), sysUser.getId());
 
-        map.put(SystemConstant.CRM_INFO, crmProjectResult);
-        map.put(SystemConstant.SOP_ID, tbSopInfo.getId());
-        tbSopInfoService.saveJobRemind(map);
-
         tfCustomFlowEntity.setObjId(tbSopInfo.getId());
         tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
         tbCrmService.updateCrmStatus(sopPublishParam.getCrmNo(), CrmStatusEnum.PUBLISH);
@@ -319,6 +323,79 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         return tfCustomFlowEntity.getCode();
     }
 
+    /**
+     * 设置流程第一步值
+     *
+     * @param sopPublishParam
+     * @param tfCustomFlow
+     * @param crmProjectResult
+     * @throws Exception
+     */
+    public SopPublishParam setSetupOne(SopPublishParam sopPublishParam, TFCustomFlow tfCustomFlow,
+            CrmProjectResult crmProjectResult) throws Exception {
+        Map<String, Object> propertiesMap = activitiService.formPropertiesGet(sopPublishParam.getFlowDeploymentId(),
+                null, null, false, sopPublishParam.getCrmNo());
+        Map<String, Object> var = sopPublishParam.getVar();
+        TBCrmDetail tbCrmDetail = (TBCrmDetail) var.get(SystemConstant.CRM_DETAIL);
+        String processVar = (String) var.get(SystemConstant.PROCESS_VAR);
+        if (!CollectionUtils.isEmpty(propertiesMap)) {
+            FlowTaskResult flowTaskResult = (FlowTaskResult) propertiesMap.get(SystemConstant.FORM_PROPERTIES);
+            List<FlowFormWidgetResult> flowFormWidgetResultList = flowTaskResult.getFormProperty();
+            if (!CollectionUtils.isEmpty(flowFormWidgetResultList)) {
+                if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {
+                    List<FlowFormWidgetResult> flowFormWidgetResults = JSONArray.parseArray(processVar,
+                            FlowFormWidgetResult.class);
+                    Map<Long, FlowFormWidgetResult> flowFormWidgetResultMap = flowFormWidgetResults.stream().collect(
+                            Collectors.toMap(FlowFormWidgetResult::getId, Function.identity(), (dto1, dto2) -> dto1));
+                    for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+                        if (flowFormWidgetResultMap.containsKey(f.getId())) {
+                            f.setValue(flowFormWidgetResultMap.get(f.getId()).getValue());
+                        } else if (Objects.nonNull(tbCrmDetail.getContacts()) && f.getFormId()
+                                .contains(ProcessLimitedEnum.CONTACTS.getKey())) {
+                            JSONObject jsonObject = new JSONObject();
+                            jsonObject.put(SystemConstant.VALUE, tbCrmDetail.getContacts());
+                            f.setValue(jsonObject.toJSONString());
+                        } else if (Objects.nonNull(tbCrmDetail.getMobileNumber()) && f.getFormId()
+                                .contains(ProcessLimitedEnum.MOBILE_NUMBER.getKey())) {
+                            JSONObject jsonObject = new JSONObject();
+                            jsonObject.put(SystemConstant.VALUE, tbCrmDetail.getMobileNumber());
+                            f.setValue(jsonObject.toJSONString());
+                        } else if (f.getFormId().contains(ProcessLimitedEnum.SERVICE_SCOPE_RADIO.getKey())) {
+                            JSONObject jsonObject = new JSONObject();
+                            jsonObject.put(SystemConstant.VALUE, tbCrmDetail.getServiceScope());
+                            f.setValue(jsonObject.toJSONString());
+                        } else if (f.getFormId().contains(ProcessLimitedEnum.SCAN_START_TIME.getKey())) {
+                            JSONObject jsonObject = new JSONObject();
+                            jsonObject.put(SystemConstant.VALUE, tbCrmDetail.getScanStartTime());
+                            f.setValue(jsonObject.toJSONString());
+                        } else if (f.getFormId().contains(ProcessLimitedEnum.SCAN_END_TIME.getKey())) {
+                            JSONObject jsonObject = new JSONObject();
+                            jsonObject.put(SystemConstant.VALUE, tbCrmDetail.getScanEndTime());
+                            f.setValue(jsonObject.toJSONString());
+                        } else if (f.getFormId().contains(ProcessLimitedEnum.MARK_START_TIME.getKey())) {
+                            JSONObject jsonObject = new JSONObject();
+                            jsonObject.put(SystemConstant.VALUE, tbCrmDetail.getMarkPaperStartTime());
+                            f.setValue(jsonObject.toJSONString());
+                        } else if (f.getFormId().contains(ProcessLimitedEnum.MARK_END_TIME.getKey())) {
+                            JSONObject jsonObject = new JSONObject();
+                            jsonObject.put(SystemConstant.VALUE, tbCrmDetail.getMarkPaperEndTime());
+                            f.setValue(jsonObject.toJSONString());
+                        } else if (f.getFormId().contains(ProcessLimitedEnum.ENGINEER_USERS_ID.getKey())) {
+                            List<String> list = new ArrayList<>(crmProjectResult.getEngineerList().size());
+                            crmProjectResult.getEngineerList().stream().peek(s -> list.add(s.getUserId().toString()))
+                                    .collect(Collectors.toList());
+                            JSONObject jsonObject = new JSONObject();
+                            jsonObject.put(SystemConstant.VALUE, list);
+                            f.setValue(jsonObject.toJSONString());
+                        }
+                    }
+                }
+                sopPublishParam.setFormProperties(JacksonUtil.parseJson(flowTaskResult));
+            }
+        }
+        return sopPublishParam;
+    }
+
     //    /**
     //     * sop申请信息
     //     *
@@ -433,7 +510,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             flowApproveParam.setFormProperties(JacksonUtil.parseJson(flowTaskResult));
         }
 
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),null,
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(), null,
                 tfCustomFlowEntity.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
@@ -775,15 +852,15 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 for (FlowFormWidgetResult f : flowFormWidgetResultList) {
                     if (f.getFormId().contains(SystemConstant.APPROVE_RADIO_REGION)) {
                         JSONObject jsonObject = new JSONObject();
-                        jsonObject.put("value", "1");
+                        jsonObject.put(SystemConstant.VALUE, "1");
                         f.setValue(jsonObject.toString());
                     } else if (f.getFormId().contains(SystemConstant.APPROVE_REMARK_REGION)) {
                         JSONObject jsonObject = new JSONObject();
-                        jsonObject.put("value", SystemConstant.SYSTEM_AUTO_APPROVE);
+                        jsonObject.put(SystemConstant.VALUE, SystemConstant.SYSTEM_AUTO_APPROVE);
                         f.setValue(jsonObject.toString());
                     } else if (f.getFormId().contains(SystemConstant.SIGN_REGION)) {
                         JSONObject jsonObject = new JSONObject();
-                        jsonObject.put("value", "https://sop-file.qmth.com.cn/logo/logo.png");
+                        jsonObject.put(SystemConstant.VALUE, "https://sop-file.qmth.com.cn/logo/logo.png");
                         f.setValue(jsonObject.toString());
                     }
                 }
@@ -1039,9 +1116,8 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
                 processLimitedTime = tfFlowApprove.getUpdateTime();
                 execField = ProcessLimitedEnum.FLOW_TASK.getKey();
-                tbSopInfoService.saveSopPlanDate(flowTaskResult, sopId, tfCustomFlowEntity.getFlowId(),
-                        sysUser.getId());
-
+                tbSopInfoService.saveSopPlanDate(flowTaskResult, sopId, tfCustomFlowEntity.getFlowId(), sysUser.getId(),
+                        tfCustomFlow.getType());
                 //                if (tfFlowApprove.getSetup().intValue() == 2) {//项目关键信息
                 //                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
                 //                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
@@ -1136,7 +1212,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                             ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey());
                     execField = ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey();
                     tbSopInfoService.saveSopPlanDate(flowTaskResult, sopId, tfCustomFlowEntity.getFlowId(),
-                            sysUser.getId());
+                            sysUser.getId(), tfCustomFlow.getType());
                 } else if (tfFlowApprove.getSetup().intValue() == 3) {//内审
                     processLimitedTime = tfFlowApprove.getUpdateTime();
                     execField = ProcessLimitedEnum.APPROVE_RADIO.getKey();
@@ -1324,7 +1400,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         }
         flowResultNew.setSetupMap(setupMapNew);
 
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),null,
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(), null,
                 tfCustomFlowEntity.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
@@ -1377,7 +1453,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         tfCustomFlowEntity.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
         if (tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END) {
             Map<String, Object> map = new HashMap<>();
-            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),null,
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(), null,
                     tfCustomFlowEntity.getCrmNo());
             Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
@@ -1410,7 +1486,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
 
             FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
             tbSopInfoService.saveSopPlanDate(flowTaskResult, tbSopInfo.getId(), tfCustomFlowEntity.getFlowId(),
-                    sysUser.getId());
+                    sysUser.getId(), tfCustomFlow.getType());
 
             //新增sop日志
             if (!Objects.equals(oldFlowProcessVar, tfCustomFlowEntity.getFlowProcessVar())) {
@@ -1493,14 +1569,24 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
      * @param sopId
      * @param flowId
      * @param userId
+     * @param type
      */
     @Override
     @Transactional
-    public void saveSopPlanDate(FlowTaskResult flowTaskResult, Long sopId, Long flowId, Long userId) {
-        Long serviceFinishPlanBeginDate = this.getProcessLimitedTime(flowTaskResult,
-                ProcessLimitedEnum.SERVICE_FINISH_PLAN_BEGIN_DATE.getKey());
-        Long serviceFinishPlanEndDate = this.getProcessLimitedTime(flowTaskResult,
-                ProcessLimitedEnum.SERVICE_FINISH_PLAN_DATE.getKey());
+    public void saveSopPlanDate(FlowTaskResult flowTaskResult, Long sopId, Long flowId, Long userId,
+            TFCustomTypeEnum type) {
+        Long serviceFinishPlanBeginDate = null, serviceFinishPlanEndDate = null;
+        if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+            serviceFinishPlanBeginDate = this.getProcessLimitedTime(flowTaskResult,
+                    ProcessLimitedEnum.SERVICE_FINISH_PLAN_BEGIN_DATE.getKey());
+            serviceFinishPlanEndDate = this.getProcessLimitedTime(flowTaskResult,
+                    ProcessLimitedEnum.SERVICE_FINISH_PLAN_DATE.getKey());
+        } else if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW) {
+            serviceFinishPlanBeginDate = this.getProcessLimitedTime(flowTaskResult,
+                    ProcessLimitedEnum.SCAN_START_TIME.getKey());
+            serviceFinishPlanEndDate = this.getProcessLimitedTime(flowTaskResult,
+                    ProcessLimitedEnum.MARK_END_TIME.getKey());
+        }
         if (Objects.nonNull(serviceFinishPlanBeginDate)) {
             TBSopPlanDateLog tbSopPlanDateLogDb = tbSopPlanDateLogService.getOne(
                     new QueryWrapper<TBSopPlanDateLog>().lambda().eq(TBSopPlanDateLog::getFlowId, flowId)

+ 126 - 100
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesAllocationServiceImpl.java

@@ -37,28 +37,40 @@ import java.util.stream.Stream;
  * @since 2023-08-01
  */
 @Service
-public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchivesAllocationMapper, TBUserArchivesAllocation> implements TBUserArchivesAllocationService {
+public class TBUserArchivesAllocationServiceImpl
+        extends ServiceImpl<TBUserArchivesAllocationMapper, TBUserArchivesAllocation>
+        implements TBUserArchivesAllocationService {
+
     @Resource
     private TBServiceService tbServiceService;
+
     @Resource
     private TBCrmService tbCrmService;
+
     @Resource
     private SysRoleService sysRoleService;
+
     @Resource
     private SysUserRoleService sysUserRoleService;
+
     @Resource
     private TBUserArchivesService tbUserArchivesService;
+
     @Resource
     private TBSopInfoService tbSopInfoService;
+
     @Resource
     private TFCustomFlowService tfCustomFlowService;
+
     @Resource
     private ActivitiService activitiService;
+
     @Resource
     private SysUserService sysUserService;
 
     @Override
-    public IPage<UserArchivesAllocationResult> findCrmAllocationPage(Long serviceUnitId, String province, String city, String area, String customName, Integer gap, Long regionId, Integer pageNumber, Integer pageSize) {
+    public IPage<UserArchivesAllocationResult> findCrmAllocationPage(Long serviceUnitId, String province, String city,
+            String area, String customName, Integer gap, Long regionId, Integer pageNumber, Integer pageSize) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         Long userId = requestUser.getId();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(userId);
@@ -67,11 +79,13 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
         city = SystemConstant.translateSpecificSign(city);
         area = SystemConstant.translateSpecificSign(area);
         customName = SystemConstant.translateSpecificSign(customName);
-        return this.baseMapper.findCrmAllocationPage(new Page<>(pageNumber, pageSize), serviceUnitId, province, city, area, customName, gap, regionId, dpr);
+        return this.baseMapper.findCrmAllocationPage(new Page<>(pageNumber, pageSize), serviceUnitId, province, city,
+                area, customName, gap, regionId, dpr);
     }
 
     @Override
-    public UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, String province, String city, String area, String customName, Integer gap, Long regionId) {
+    public UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, String province,
+            String city, String area, String customName, Integer gap, Long regionId) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         Long userId = requestUser.getId();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(userId);
@@ -80,18 +94,22 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
         city = SystemConstant.translateSpecificSign(city);
         area = SystemConstant.translateSpecificSign(area);
         customName = SystemConstant.translateSpecificSign(customName);
-        List<UserArchivesAllocationResult> list = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, province, city, area, customName, gap, null, null,regionId, dpr);
-        Integer publishedCrmCount = Math.toIntExact(list.stream().filter(e -> CrmStatusEnum.PUBLISH.equals(e.getCrmStatus())).count());
+        List<UserArchivesAllocationResult> list = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, province,
+                city, area, customName, gap, null, null, regionId, dpr);
+        Integer publishedCrmCount = Math.toIntExact(
+                list.stream().filter(e -> CrmStatusEnum.PUBLISH.equals(e.getCrmStatus())).count());
         Integer totalCrmCount = list.size();
 
         Integer coordinatorQuota = list.stream().mapToInt(UserArchivesAllocationResult::getCoordinatorQuota).sum();
-        Integer coordinatorDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getCoordinatorDistributed).sum();
+        Integer coordinatorDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getCoordinatorDistributed)
+                .sum();
 
         Integer effectQuota = list.stream().mapToInt(UserArchivesAllocationResult::getEffectQuota).sum();
         Integer effectDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getEffectDistributed).sum();
 
         Integer assistantQuota = list.stream().mapToInt(UserArchivesAllocationResult::getAssistantQuota).sum();
-        Integer assistantDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getAssistantDistributed).sum();
+        Integer assistantDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getAssistantDistributed)
+                .sum();
 
         UserArchivesAllocationSubTotalResult result = new UserArchivesAllocationSubTotalResult();
         result.setPublishedCrmCount(publishedCrmCount);
@@ -126,18 +144,16 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
         }
         TBCrm tbCrm = tbCrmList.get(0);
 
-        List<TBUserArchivesAllocation> dbList = this.list(new QueryWrapper<TBUserArchivesAllocation>()
-                .lambda()
-                .eq(TBUserArchivesAllocation::getCrmNo, crmNo));
+        List<TBUserArchivesAllocation> dbList = this.list(
+                new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, crmNo));
 
-//        if (dbList.stream().anyMatch(e -> Objects.nonNull(e.getSopNo()))) {
-//            throw ExceptionResultEnum.ERROR.exception("已发布的派单不能调配");
-//        }
+        //        if (dbList.stream().anyMatch(e -> Objects.nonNull(e.getSopNo()))) {
+        //            throw ExceptionResultEnum.ERROR.exception("已发布的派单不能调配");
+        //        }
 
         // 新增关系
         List<AllocationParam> allocationParamList = userArchivesAllocationParam.getAllocationParams();
 
-
         List<TBUserArchivesAllocation> tbUserArchivesAllocationList = new ArrayList<>();
         // 处理实施工程师或助理工程师
         if (CollectionUtils.isNotEmpty(allocationParamList)) {
@@ -148,16 +164,18 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
                 if (Objects.isNull(role)) {
                     throw ExceptionResultEnum.ERROR.exception("认证角色不存在");
                 } else {
-                    if (!RoleTypeEnum.EFFECT_ENGINEER.equals(role.getType()) && !RoleTypeEnum.ASSISTANT_ENGINEER.equals(role.getType())) {
-                        throw ExceptionResultEnum.ERROR.exception(String.format("认证角色类型为[%s]不属于[%s]或[%s]",
-                                role.getType().getDesc(),
-                                RoleTypeEnum.EFFECT_ENGINEER.getDesc(),
-                                RoleTypeEnum.ASSISTANT_ENGINEER.getDesc()));
+                    if (!RoleTypeEnum.EFFECT_ENGINEER.equals(role.getType()) && !RoleTypeEnum.ASSISTANT_ENGINEER.equals(
+                            role.getType())) {
+                        throw ExceptionResultEnum.ERROR.exception(
+                                String.format("认证角色类型为[%s]不属于[%s]或[%s]", role.getType().getDesc(),
+                                        RoleTypeEnum.EFFECT_ENGINEER.getDesc(),
+                                        RoleTypeEnum.ASSISTANT_ENGINEER.getDesc()));
                     }
                 }
 
                 for (Long userId : userIdList) {
-                    List<Long> sysRoleIdList = sysUserRoleService.listRoleByUserId(userId).stream().map(BaseEntity::getId).distinct().collect(Collectors.toList());
+                    List<Long> sysRoleIdList = sysUserRoleService.listRoleByUserId(userId).stream()
+                            .map(BaseEntity::getId).distinct().collect(Collectors.toList());
                     if (!sysRoleIdList.contains(roleId)) {
                         throw ExceptionResultEnum.ERROR.exception("所选用户不包含认证角色[" + role.getType().getDesc() + "]");
                     }
@@ -168,8 +186,9 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
                             throw ExceptionResultEnum.ERROR.exception("人员占用状态异常");
                         }
                         if (!occupiedCrm.stream().map(TBCrm::getCrmNo).collect(Collectors.toList()).contains(crmNo)) {
-                            throw ExceptionResultEnum.ERROR.exception(String.format("工程师[%s]已经被派单号为[%s]的派单占用,请先将工程师从派单中移出",
-                                    tbUserArchives.getName(), occupiedCrm.stream().map(TBCrm::getCrmNo).collect(Collectors.joining())));
+                            throw ExceptionResultEnum.ERROR.exception(
+                                    String.format("工程师[%s]已经被派单号为[%s]的派单占用,请先将工程师从派单中移出", tbUserArchives.getName(),
+                                            occupiedCrm.stream().map(TBCrm::getCrmNo).collect(Collectors.joining())));
                         }
                     }
                     TBUserArchivesAllocation tbUserArchivesAllocation = new TBUserArchivesAllocation();
@@ -184,18 +203,17 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
 
         // 更新区域负责人
         UpdateWrapper<TBCrm> coordinatorUpdateWrapper = new UpdateWrapper<>();
-        coordinatorUpdateWrapper.lambda()
-                .set(TBCrm::getRegionCoordinatorId, regionUserId)
+        coordinatorUpdateWrapper.lambda().set(TBCrm::getRegionCoordinatorId, regionUserId)
                 .eq(TBCrm::getId, tbCrm.getId());
         tbCrmService.update(coordinatorUpdateWrapper);
 
         // 新增前删除派单关系
         if (CollectionUtils.isNotEmpty(dbList)) {
             // 删除关系前先将工程师状态更改为空闲
-            List<Long> engineerDbIdList = dbList.stream().map(TBUserArchivesAllocation::getArchivesId).distinct().collect(Collectors.toList());
+            List<Long> engineerDbIdList = dbList.stream().map(TBUserArchivesAllocation::getArchivesId).distinct()
+                    .collect(Collectors.toList());
             UpdateWrapper<TBUserArchives> archivesUpdateWrapper = new UpdateWrapper<>();
-            archivesUpdateWrapper.lambda()
-                    .set(TBUserArchives::getStatus, UserArchivesStatusEnum.FREE)
+            archivesUpdateWrapper.lambda().set(TBUserArchives::getStatus, UserArchivesStatusEnum.FREE)
                     .in(TBUserArchives::getId, engineerDbIdList);
             tbUserArchivesService.update(archivesUpdateWrapper);
 
@@ -203,13 +221,12 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
             this.removeByIds(dbList.stream().map(TBUserArchivesAllocation::getId).collect(Collectors.toList()));
         }
 
-
         if (CollectionUtils.isNotEmpty(tbUserArchivesAllocationList)) {
             // 新增前先将工程师的状态设置为非空闲
-            List<Long> engineerAddIdLIst = tbUserArchivesAllocationList.stream().map(TBUserArchivesAllocation::getArchivesId).distinct().collect(Collectors.toList());
+            List<Long> engineerAddIdLIst = tbUserArchivesAllocationList.stream()
+                    .map(TBUserArchivesAllocation::getArchivesId).distinct().collect(Collectors.toList());
             UpdateWrapper<TBUserArchives> archivesUpdateWrapper = new UpdateWrapper<>();
-            archivesUpdateWrapper.lambda()
-                    .set(TBUserArchives::getStatus, UserArchivesStatusEnum.OCCUPIED)
+            archivesUpdateWrapper.lambda().set(TBUserArchives::getStatus, UserArchivesStatusEnum.OCCUPIED)
                     .in(TBUserArchives::getId, engineerAddIdLIst);
             tbUserArchivesService.update(archivesUpdateWrapper);
 
@@ -226,7 +243,8 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
 
         if (regionCoordinatorId != null && regionCoordinatorId > 0) {
 
-            UserArchivesResult userArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(null, regionCoordinatorId);
+            UserArchivesResult userArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(null,
+                    regionCoordinatorId);
             if (Objects.nonNull(userArchivesResult)) {
                 // 为空是大区经理兼任的情况 不处理
                 CrmArchivesAllocationResult region = new CrmArchivesAllocationResult();
@@ -241,7 +259,8 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
                 list.add(region);
             }
         }
-        return list.stream().peek(e -> e.setRoleResult(sysRoleService.findRoleInfoByArchivesType(e.getType()))).collect(Collectors.toList());
+        return list.stream().peek(e -> e.setRoleResult(sysRoleService.findRoleInfoByArchivesType(e.getType())))
+                .collect(Collectors.toList());
     }
 
     @Transactional
@@ -249,7 +268,8 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
     public void autoEditCrmAllocationBatch(AutoAllocationParam autoAllocationParam) {
         Long serviceUnitId = autoAllocationParam.getServiceUnitId();
         List<Long> crmIdList = autoAllocationParam.getCrmIdList();
-        List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, null, null, null, null, null, crmIdList, CrmStatusEnum.UN_PUBLISH, null,null);
+        List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId,
+                null, null, null, null, null, crmIdList, CrmStatusEnum.UN_PUBLISH, null, null);
         // crm按照差额倒序
         crmSourceList = crmSourceList.stream().filter(e -> e.getUnDistributed() > 0)
                 .sorted(Comparator.comparing(UserArchivesAllocationResult::getUnDistributed).reversed())
@@ -272,34 +292,28 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
             // 该派单已经分配的人员名单
             List<CrmArchivesAllocationResult> crmArchivesAllocationResultList = this.findAllocationByCrmNo(crmNo);
             // 区域协调人
-            List<CrmArchivesAllocationResult> coordinatorList = crmArchivesAllocationResultList
-                    .stream()
-                    .filter(e -> RoleTypeEnum.REGION_COORDINATOR.equals(e.getType()))
-                    .collect(Collectors.toList());
+            List<CrmArchivesAllocationResult> coordinatorList = crmArchivesAllocationResultList.stream()
+                    .filter(e -> RoleTypeEnum.REGION_COORDINATOR.equals(e.getType())).collect(Collectors.toList());
             // 实施工程师
-            List<CrmArchivesAllocationResult> effectList = crmArchivesAllocationResultList
-                    .stream()
-                    .filter(e -> RoleTypeEnum.EFFECT_ENGINEER.equals(e.getType()))
-                    .collect(Collectors.toList());
+            List<CrmArchivesAllocationResult> effectList = crmArchivesAllocationResultList.stream()
+                    .filter(e -> RoleTypeEnum.EFFECT_ENGINEER.equals(e.getType())).collect(Collectors.toList());
             // 助理工程师
-            List<CrmArchivesAllocationResult> assistantList = crmArchivesAllocationResultList
-                    .stream()
-                    .filter(e -> RoleTypeEnum.ASSISTANT_ENGINEER.equals(e.getType()))
-                    .collect(Collectors.toList());
+            List<CrmArchivesAllocationResult> assistantList = crmArchivesAllocationResultList.stream()
+                    .filter(e -> RoleTypeEnum.ASSISTANT_ENGINEER.equals(e.getType())).collect(Collectors.toList());
 
             // 可分配的人力资源
-            List<ArchivesSourceResult> effectFree = tbUserArchivesService.findFreeEngineerSourceByType(RoleTypeEnum.EFFECT_ENGINEER, null)
-                    .stream()
+            List<ArchivesSourceResult> effectFree = tbUserArchivesService.findFreeEngineerSourceByType(
+                            RoleTypeEnum.EFFECT_ENGINEER, null).stream()
                     .filter(e -> province.equals(e.getProvince()) && city.equals(e.getCity()))
                     .collect(Collectors.toList());
 
-            List<ArchivesSourceResult> assistantFree = tbUserArchivesService.findFreeEngineerSourceByType(RoleTypeEnum.ASSISTANT_ENGINEER, null)
-                    .stream()
+            List<ArchivesSourceResult> assistantFree = tbUserArchivesService.findFreeEngineerSourceByType(
+                            RoleTypeEnum.ASSISTANT_ENGINEER, null).stream()
                     .filter(e -> province.equals(e.getProvince()) && city.equals(e.getCity()))
                     .collect(Collectors.toList());
 
-            List<ArchivesSourceResult> coordinatorFree = tbUserArchivesService.findFreeCoordinatorByServiceId(serviceUnitId, null, true)
-                    .stream()
+            List<ArchivesSourceResult> coordinatorFree = tbUserArchivesService.findFreeCoordinatorByServiceId(
+                            serviceUnitId, null, true).stream()
                     .filter(e -> province.equals(e.getProvince()) && city.equals(e.getCity()))
                     .collect(Collectors.toList());
 
@@ -307,24 +321,25 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
 
             // 先分实施工程师
             if (effectUnDistributed > 0) {
-                SysRole effectRole = sysRoleService.list(new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.EFFECT_ENGINEER)).get(0);
+                SysRole effectRole = sysRoleService.list(
+                        new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.EFFECT_ENGINEER)).get(0);
                 Long effectRoleId = effectRole.getId();
                 List<Long> userIdList = new ArrayList<>();
                 if (CollectionUtils.isNotEmpty(coordinatorList)) {
                     // 实施工程师和区域协调人同供应商,实施工程师和crm客户同城市
                     CrmArchivesAllocationResult coordinator = coordinatorList.get(0);
                     Long supplierId = coordinator.getSupplierId();
-                    effectFree = effectFree.stream()
-                            .filter(e -> supplierId.equals(e.getSupplierId()))
-                            .limit(effectUnDistributed)
-                            .collect(Collectors.toList());
-                    userIdList.addAll(effectFree.stream().map(ArchivesSourceResult::getUserId).distinct().collect(Collectors.toList()));
+                    effectFree = effectFree.stream().filter(e -> supplierId.equals(e.getSupplierId()))
+                            .limit(effectUnDistributed).collect(Collectors.toList());
+                    userIdList.addAll(effectFree.stream().map(ArchivesSourceResult::getUserId).distinct()
+                            .collect(Collectors.toList()));
                     this.addDistributeTemp(effectList, effectFree);
                 } else {
                     // 不存在区域协调人,实施工程师和crm客户同城市,且实施工程师尽可能集中在同一个供应商中
 
                     // 供应商和实施工程师数量键值对
-                    Map<Long, Integer> supplierMap = effectFree.stream().collect(Collectors.toMap(ArchivesSourceResult::getSupplierId, e -> 1, Integer::sum));
+                    Map<Long, Integer> supplierMap = effectFree.stream()
+                            .collect(Collectors.toMap(ArchivesSourceResult::getSupplierId, e -> 1, Integer::sum));
                     supplierMap = SystemConstant.sortMapByValues(supplierMap);
                     for (Long supplierId : supplierMap.keySet()) {
                         Integer count = supplierMap.get(supplierId);
@@ -332,15 +347,19 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
                         List<ArchivesSourceResult> cell;
                         if (effectDivide > 0) {
                             // 该供应商的不够分配配额
-                            cell = effectFree.stream().filter(e -> supplierId.equals(e.getSupplierId())).limit(count).collect(Collectors.toList());
-                            userIdList.addAll(cell.stream().map(ArchivesSourceResult::getUserId).distinct().collect(Collectors.toList()));
+                            cell = effectFree.stream().filter(e -> supplierId.equals(e.getSupplierId())).limit(count)
+                                    .collect(Collectors.toList());
+                            userIdList.addAll(cell.stream().map(ArchivesSourceResult::getUserId).distinct()
+                                    .collect(Collectors.toList()));
                             this.addDistributeTemp(effectList, cell);
                             // 进入下一个供应商循环
                             effectUnDistributed = effectUnDistributed - count;
                         } else {
                             // 该供应商的足够分配配额
-                            cell = effectFree.stream().filter(e -> supplierId.equals(e.getSupplierId())).limit(effectUnDistributed).collect(Collectors.toList());
-                            userIdList.addAll(cell.stream().map(ArchivesSourceResult::getUserId).distinct().collect(Collectors.toList()));
+                            cell = effectFree.stream().filter(e -> supplierId.equals(e.getSupplierId()))
+                                    .limit(effectUnDistributed).collect(Collectors.toList());
+                            userIdList.addAll(cell.stream().map(ArchivesSourceResult::getUserId).distinct()
+                                    .collect(Collectors.toList()));
                             this.addDistributeTemp(effectList, cell);
                             break;
                         }
@@ -353,10 +372,13 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
             }
             // 再分助理工程师
             if (assistantUnDistributed > 0) {
-                SysRole assistantRole = sysRoleService.list(new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.ASSISTANT_ENGINEER)).get(0);
+                SysRole assistantRole = sysRoleService.list(
+                                new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.ASSISTANT_ENGINEER))
+                        .get(0);
                 Long assistantRoleId = assistantRole.getId();
                 List<Long> userIdList = new ArrayList<>();
-                Map<Long, Integer> supplierMap = assistantFree.stream().collect(Collectors.toMap(ArchivesSourceResult::getSupplierId, e -> 1, Integer::sum));
+                Map<Long, Integer> supplierMap = assistantFree.stream()
+                        .collect(Collectors.toMap(ArchivesSourceResult::getSupplierId, e -> 1, Integer::sum));
                 supplierMap = SystemConstant.sortMapByValues(supplierMap);
                 for (Long supplierId : supplierMap.keySet()) {
                     Integer count = supplierMap.get(supplierId);
@@ -364,14 +386,18 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
                     List<ArchivesSourceResult> cell;
                     if (assistantDivide > 0) {
                         // 该供应商的不够分配配额
-                        cell = assistantFree.stream().filter(e -> supplierId.equals(e.getSupplierId())).limit(count).collect(Collectors.toList());
-                        userIdList.addAll(cell.stream().map(ArchivesSourceResult::getUserId).distinct().collect(Collectors.toList()));
+                        cell = assistantFree.stream().filter(e -> supplierId.equals(e.getSupplierId())).limit(count)
+                                .collect(Collectors.toList());
+                        userIdList.addAll(cell.stream().map(ArchivesSourceResult::getUserId).distinct()
+                                .collect(Collectors.toList()));
                         this.addDistributeTemp(assistantList, cell);
                         assistantUnDistributed = assistantUnDistributed - count;
                     } else {
                         // 该供应商的足够分配配额
-                        cell = assistantFree.stream().filter(e -> supplierId.equals(e.getSupplierId())).limit(assistantUnDistributed).collect(Collectors.toList());
-                        userIdList.addAll(cell.stream().map(ArchivesSourceResult::getUserId).distinct().collect(Collectors.toList()));
+                        cell = assistantFree.stream().filter(e -> supplierId.equals(e.getSupplierId()))
+                                .limit(assistantUnDistributed).collect(Collectors.toList());
+                        userIdList.addAll(cell.stream().map(ArchivesSourceResult::getUserId).distinct()
+                                .collect(Collectors.toList()));
                         this.addDistributeTemp(assistantList, cell);
                         break;
                     }
@@ -387,7 +413,8 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
             if (coordinatorUnDistributed > 0) {
                 if (CollectionUtils.isNotEmpty(effectList)) {
                     // 存在已经分配的实施工程师
-                    List<Long> supplierIdList = effectList.stream().map(CrmArchivesAllocationResult::getSupplierId).distinct().collect(Collectors.toList());
+                    List<Long> supplierIdList = effectList.stream().map(CrmArchivesAllocationResult::getSupplierId)
+                            .distinct().collect(Collectors.toList());
                     if (supplierIdList.size() == 1) {
                         Long supplierId = supplierIdList.get(0);
                         List<ArchivesSourceResult> coordinator = coordinatorFree.stream()
@@ -419,7 +446,7 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
     }
 
     @Override
-    public void publishSop(String crmNo) throws InterruptedException {
+    public void publishSop(String crmNo) throws Exception {
         TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
         Long serviceUnitId = tbCrm.getServiceId();
         if (serviceUnitId == null || serviceUnitId == 0) {
@@ -431,7 +458,8 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
         Long crmId = tbCrm.getId();
         List<Long> crmIdList = new ArrayList<>();
         crmIdList.add(crmId);
-        List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, null, null, null, null, null, crmIdList, null, null,null);
+        List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId,
+                null, null, null, null, null, crmIdList, null, null, null);
         if (CollectionUtils.isEmpty(crmSourceList)) {
             throw ExceptionResultEnum.ERROR.exception("未找到派单信息");
         } else if (crmSourceList.size() > 1) {
@@ -453,30 +481,28 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
         List<TFCustomFlow> tfCustomFlowList = tfCustomFlowService.findFlowDeploymentList();
         String flowDeploymentId = null;
         switch (productType) {
-            case OFFICE:
-                List<String> ofl = tfCustomFlowList.stream()
-                        .filter(e -> e.getType().equals(TFCustomTypeEnum.OFFICE_SOP_FLOW))
-                        .map(TFCustomFlow::getFlowDeploymentId)
-                        .collect(Collectors.toList());
-                if (CollectionUtils.isEmpty(ofl)) {
-                    throw ExceptionResultEnum.ERROR.exception("发布失败,未找到教务处SOP部署信息");
-                } else if (ofl.size() > 1) {
-                    throw ExceptionResultEnum.ERROR.exception("发布失败,教务处SOP部署信息异常");
-                }
-                flowDeploymentId = ofl.get(0);
-                break;
-            case CLOUD_MARK:
-                List<String> cfl = tfCustomFlowList.stream()
-                        .filter(e -> e.getType().equals(TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW))
-                        .map(TFCustomFlow::getFlowDeploymentId)
-                        .collect(Collectors.toList());
-                if (CollectionUtils.isEmpty(cfl)) {
-                    throw ExceptionResultEnum.ERROR.exception("发布失败,未找到研究生SOP部署信息");
-                } else if (cfl.size() > 1) {
-                    throw ExceptionResultEnum.ERROR.exception("发布失败,研究生SOP部署信息异常");
-                }
-                flowDeploymentId = cfl.get(0);
-                break;
+        case OFFICE:
+            List<String> ofl = tfCustomFlowList.stream()
+                    .filter(e -> e.getType().equals(TFCustomTypeEnum.OFFICE_SOP_FLOW))
+                    .map(TFCustomFlow::getFlowDeploymentId).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(ofl)) {
+                throw ExceptionResultEnum.ERROR.exception("发布失败,未找到教务处SOP部署信息");
+            } else if (ofl.size() > 1) {
+                throw ExceptionResultEnum.ERROR.exception("发布失败,教务处SOP部署信息异常");
+            }
+            flowDeploymentId = ofl.get(0);
+            break;
+        case CLOUD_MARK:
+            List<String> cfl = tfCustomFlowList.stream()
+                    .filter(e -> e.getType().equals(TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW))
+                    .map(TFCustomFlow::getFlowDeploymentId).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(cfl)) {
+                throw ExceptionResultEnum.ERROR.exception("发布失败,未找到研究生SOP部署信息");
+            } else if (cfl.size() > 1) {
+                throw ExceptionResultEnum.ERROR.exception("发布失败,研究生SOP部署信息异常");
+            }
+            flowDeploymentId = cfl.get(0);
+            break;
         }
         SopPublishParam sopPublishParam = new SopPublishParam();
         sopPublishParam.setCrmNo(crmNo);
@@ -505,9 +531,9 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
     @Override
     public SopRoleTypeEnum findRoleTypeByUserCrm(Long userId, String crmNo) {
         SopRoleTypeEnum result = null;
-        List<TBUserArchivesAllocation> tbUserArchivesAllocationList = this.list(new QueryWrapper<TBUserArchivesAllocation>().lambda()
-                .eq(TBUserArchivesAllocation::getUserId, userId)
-                .eq(TBUserArchivesAllocation::getCrmNo, crmNo));
+        List<TBUserArchivesAllocation> tbUserArchivesAllocationList = this.list(
+                new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getUserId, userId)
+                        .eq(TBUserArchivesAllocation::getCrmNo, crmNo));
         if (!org.springframework.util.CollectionUtils.isEmpty(tbUserArchivesAllocationList)) {
             TBUserArchivesAllocation tbUserArchivesAllocation = tbUserArchivesAllocationList.get(0);
             result = tbUserArchivesAllocation.getSopRoleType();

+ 2 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -346,6 +346,8 @@ public class SystemConstant {
     public static final String CRM_INFO = "crmInfo";
     public static final String SOP_ID = "sopId";
     public static final String SOURCE = "source";
+    public static final String CRM_DETAIL = "crmDetail";
+    public static final String PROCESS_VAR = "processVar";
 
     /**
      * 锁

+ 9 - 1
sop-common/src/main/java/com/qmth/sop/common/enums/ProcessLimitedEnum.java

@@ -27,7 +27,15 @@ public enum ProcessLimitedEnum {
 
     ENV_DEPLOYMENT_TIME("env_deployment_time", "环境部署时间"),
 
-    FLOW_TASK("flowTask", "流程待办");
+    FLOW_TASK("flow_task", "流程待办"),
+
+    SERVICE_SCOPE_RADIO("service_scope_radio", "服务范围"),
+
+    CONTACTS("contacts", "联系人"),
+
+    MOBILE_NUMBER("mobile_number", "电话"),
+
+    ENGINEER_USERS_ID("engineer_users_id", "工程师");
 
     private String key;