فهرست منبع

新增派单sop发布

wangliang 1 سال پیش
والد
کامیت
f900fe28e0

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

@@ -4474,8 +4474,8 @@ 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 (23, 'TEXT', 'FORM', 'mobile_number', 'mobile_number', '电话', 'STRING', 1, 0, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, 6, NULL, NULL, 'OFFICE_SOP_FLOW', 1, 0, NULL, NULL, 1, 6);
 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 (24, 'DATE', 'FORM', 'scan_start_time', 'scan_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, 7);
 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_paper_start_time', 'mark_paper_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_paper_end_time', 'mark_paper_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 (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 (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);

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

@@ -105,7 +105,8 @@ public class TBCrmDetailController {
     @RequestMapping(value = "/sop/publish", method = RequestMethod.POST)
     @OperationLog(logType = LogTypeEnum.EDIT)
     @ApiResponses({ @ApiResponse(code = 200, message = "派单明细sop发布", response = EditResult.class) })
-    public Result sopPublish(@ApiParam(value = "派单明细sopId", required = true) @RequestParam Long id) {
+    public Result sopPublish(@ApiParam(value = "派单明细sopId", required = true) @RequestParam Long id)
+            throws InterruptedException {
         return ResultUtil.ok(tbCrmDetailService.sopPublish(id));
     }
 

+ 11 - 12
sop-api/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -3,7 +3,6 @@ package com.qmth.sop.server.api;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
-import com.qmth.sop.business.bean.params.SopApplyParam;
 import com.qmth.sop.business.bean.params.SopInfoListParam;
 import com.qmth.sop.business.bean.params.SopSaveParam;
 import com.qmth.sop.business.bean.result.FlowResult;
@@ -68,17 +67,17 @@ public class TBSopInfoController {
         return ResultUtil.ok(tdFormWidgetMetadataService.save(formWidgetMetadataList));
     }
 
-    @ApiOperation(value = "sop申请")
-    @RequestMapping(value = "/apply", method = RequestMethod.POST)
-    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
-    @OperationLog(logType = LogTypeEnum.UN_KNOW)
-    public Result apply(@Valid @ApiParam(value = "sop申请信息", required = true) @RequestBody SopApplyParam sopApplyParam,
-            BindingResult bindingResult) throws InterruptedException {
-        if (bindingResult.hasErrors()) {
-            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
-        }
-        return ResultUtil.ok(tbSopInfoService.sopApply(sopApplyParam));
-    }
+//    @ApiOperation(value = "sop申请")
+//    @RequestMapping(value = "/apply", method = RequestMethod.POST)
+//    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
+//    @OperationLog(logType = LogTypeEnum.UN_KNOW)
+//    public Result apply(@Valid @ApiParam(value = "sop申请信息", required = true) @RequestBody SopApplyParam sopApplyParam,
+//            BindingResult bindingResult) throws InterruptedException {
+//        if (bindingResult.hasErrors()) {
+//            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+//        }
+//        return ResultUtil.ok(tbSopInfoService.sopApply(sopApplyParam));
+//    }
 
     @ApiOperation(value = "sop填报")
     @RequestMapping(value = "/approve", method = RequestMethod.POST)

+ 18 - 5
sop-business/src/main/java/com/qmth/sop/business/bean/params/FlowApproveParam.java

@@ -52,7 +52,16 @@ public class FlowApproveParam implements Serializable {
 
     }
 
-    public FlowApproveParam(String flowDeploymentId, FlowApprovePassEnum approve, List<String> approveUserIds, String crmNo, String formProperties) {
+    public FlowApproveParam(FlowApproveParam flowApproveParam) {
+        this.flowDeploymentId = flowApproveParam.getFlowDeploymentId();
+        this.approve = flowApproveParam.getApprove();
+        this.approveUserIds = flowApproveParam.getApproveUserIds();
+        this.crmNo = flowApproveParam.getCrmNo();
+        this.formProperties = flowApproveParam.getFormProperties();
+    }
+
+    public FlowApproveParam(String flowDeploymentId, FlowApprovePassEnum approve, List<String> approveUserIds,
+            String crmNo, String formProperties) {
         this.flowDeploymentId = flowDeploymentId;
         this.approve = approve;
         this.approveUserIds = approveUserIds;
@@ -60,14 +69,16 @@ public class FlowApproveParam implements Serializable {
         this.formProperties = formProperties;
     }
 
-    public FlowApproveParam(String flowDeploymentId, FlowApprovePassEnum approve, List<String> approveUserIds, String crmNo) {
+    public FlowApproveParam(String flowDeploymentId, FlowApprovePassEnum approve, List<String> approveUserIds,
+            String crmNo) {
         this.flowDeploymentId = flowDeploymentId;
         this.approve = approve;
         this.approveUserIds = approveUserIds;
         this.crmNo = crmNo;
     }
 
-    public FlowApproveParam(String flowDeploymentId, FlowApprovePassEnum approve, String formProperties, List<String> approveUserIds, String crmNo) {
+    public FlowApproveParam(String flowDeploymentId, FlowApprovePassEnum approve, String formProperties,
+            List<String> approveUserIds, String crmNo) {
         this.flowDeploymentId = flowDeploymentId;
         this.approve = approve;
         this.formProperties = formProperties;
@@ -75,7 +86,8 @@ public class FlowApproveParam implements Serializable {
         this.crmNo = crmNo;
     }
 
-    public FlowApproveParam(Long taskId, FlowApprovePassEnum approve, List<String> approveUserIds, String crmNo, String approveRemark) {
+    public FlowApproveParam(Long taskId, FlowApprovePassEnum approve, List<String> approveUserIds, String crmNo,
+            String approveRemark) {
         this.taskId = taskId;
         this.approve = approve;
         this.approveUserIds = approveUserIds;
@@ -83,7 +95,8 @@ public class FlowApproveParam implements Serializable {
         this.approveRemark = approveRemark;
     }
 
-    public FlowApproveParam(Long taskId, FlowApprovePassEnum approve, List<String> approveUserIds, String crmNo, String approveRemark, String formProperties) {
+    public FlowApproveParam(Long taskId, FlowApprovePassEnum approve, List<String> approveUserIds, String crmNo,
+            String approveRemark, String formProperties) {
         this.taskId = taskId;
         this.approve = approve;
         this.approveUserIds = approveUserIds;

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

@@ -1,9 +1,11 @@
 package com.qmth.sop.business.bean.params;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.qmth.sop.common.enums.FlowApprovePassEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * @Description: sop发布param
@@ -14,11 +16,25 @@ import java.io.Serializable;
  */
 @JsonInclude(JsonInclude.Include.NON_NULL)
 public class SopPublishParam extends FlowApproveParam implements Serializable {
+
     private static final long serialVersionUID = 1L;
 
     @ApiModelProperty(value = "sop单号")
     private String sopNo;
 
+    public SopPublishParam() {
+
+    }
+
+    public SopPublishParam(String crmNo, String flowDeploymentId, FlowApprovePassEnum approve, String formProperties,
+            List<String> approveUserIds) {
+        setCrmNo(crmNo);
+        setFlowDeploymentId(flowDeploymentId);
+        setApprove(approve);
+        setFormProperties(formProperties);
+        setApproveUserIds(approveUserIds);
+    }
+
     public String getSopNo() {
         return sopNo;
     }

+ 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);
+    public boolean sopPublish(Long id) throws InterruptedException;
 
     /**
      * 派单明细sop删除

+ 30 - 17
sop-business/src/main/java/com/qmth/sop/business/service/TBSopInfoService.java

@@ -2,12 +2,14 @@ package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.sop.business.bean.params.*;
+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.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.FlowApprovePassEnum;
 
 import java.util.List;
 import java.util.Map;
@@ -52,13 +54,22 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      */
     int selectDynamicSop(String tableName, String flowDeploymentId, Long flowId);
 
+    //    /**
+    //     * sop发布信息
+    //     *
+    //     * @param sopPublishParam
+    //     * @return
+    //     */
+    //    @Deprecated
+    //    Boolean sopPublish(SopPublishParam sopPublishParam) throws InterruptedException;
+
     /**
      * sop发布信息
      *
      * @param sopPublishParam
      * @return
      */
-    Boolean sopPublish(SopPublishParam sopPublishParam) throws InterruptedException;
+    String sopPublish(SopPublishParam sopPublishParam) throws InterruptedException;
 
     /**
      * sop申请信息
@@ -66,7 +77,8 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @param sopApplyParam
      * @return
      */
-    Boolean sopApply(SopApplyParam sopApplyParam) throws InterruptedException;
+    //    @Deprecated
+    //    Boolean sopApply(SopApplyParam sopApplyParam) throws InterruptedException;
 
     /**
      * sop填报信息
@@ -84,19 +96,20 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      */
     IPage<Map> list(SopInfoListParam sopInfoListParam);
 
-    /**
-     * sop申请或发布
-     *
-     * @param sopNo
-     * @param crmNo
-     * @param flowDeploymentId
-     * @param approve
-     * @param formProperties
-     * @return
-     * @throws InterruptedException
-     */
-    public Boolean sopApplyOrPublish(String sopNo, String crmNo, String flowDeploymentId, FlowApprovePassEnum approve,
-            String formProperties) throws InterruptedException;
+    //    /**
+    //     * sop申请或发布
+    //     *
+    //     * @param sopNo
+    //     * @param crmNo
+    //     * @param flowDeploymentId
+    //     * @param approve
+    //     * @param formProperties
+    //     * @return
+    //     * @throws InterruptedException
+    //     */
+    //    @Deprecated
+    //    public Boolean sopApplyOrPublish(String sopNo, String crmNo, String flowDeploymentId, FlowApprovePassEnum approve,
+    //            String formProperties) throws InterruptedException;
 
     /**
      * 根据crmNo查询在途的sop信息

+ 9 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmDetailServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.sop.business.bean.dto.CrmDetailImportDto;
 import com.qmth.sop.business.bean.params.CrmDetailSopParam;
+import com.qmth.sop.business.bean.params.SopPublishParam;
 import com.qmth.sop.business.bean.result.CrmProjectResult;
 import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
 import com.qmth.sop.business.entity.*;
@@ -58,6 +59,9 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
     @Resource
     TDFormWidgetService tdFormWidgetService;
 
+    @Resource
+    TBSopInfoService tbSopInfoService;
+
     /**
      * 查找派单sop信息
      *
@@ -252,7 +256,7 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
      */
     @Override
     @Transactional
-    public boolean sopPublish(Long id) {
+    public boolean sopPublish(Long id) throws InterruptedException {
         TBCrmDetail tbCrmDetail = tbCrmDetailService.getById(id);
         Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
 
@@ -263,6 +267,10 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
         tbCrmDetail.updateStatus(CrmStatusEnum.PUBLISH, sysUser.getId());
 
         //发布流程
+        TFCustomFlow tfCustomFlow = tbCrmDetailService.queryCustomFlow(tbCrmDetail.getCrmNo());
+        SopPublishParam sopPublishParam = new SopPublishParam(tbCrmDetail.getCrmNo(),
+                tfCustomFlow.getFlowDeploymentId(), FlowApprovePassEnum.START, null, null);
+        tbSopInfoService.sopPublish(sopPublishParam);
         return tbCrmDetailService.updateById(tbCrmDetail);
     }
 

+ 293 - 218
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -232,45 +232,113 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         return this.baseMapper.selectDynamicSop(tableName, flowDeploymentId, flowId);
     }
 
+    //    /**
+    //     * sop发布信息
+    //     *
+    //     * @param sopPublishParam
+    //     * @return
+    //     * @throws InterruptedException
+    //     */
+    //    @Override
+    //    @Transactional
+    //    @Deprecated
+    //    public Boolean sopPublish(SopPublishParam sopPublishParam) throws InterruptedException {
+    //        Optional.ofNullable(sopPublishParam.getCrmNo())
+    //                .orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空"));
+    ////        if (sopPublishParam.getApprove() != FlowApprovePassEnum.DRAFT) {
+    ////            throw ExceptionResultEnum.PARAMS_ERROR.exception("sop发布只能为草稿");
+    ////        }
+    //        return tbSopInfoService.sopApplyOrPublish(sopPublishParam.getSopNo(), sopPublishParam.getCrmNo(),
+    //                sopPublishParam.getFlowDeploymentId(), sopPublishParam.getApprove(),
+    //                sopPublishParam.getFormProperties());
+    //    }
+
     /**
      * sop发布信息
      *
      * @param sopPublishParam
      * @return
-     * @throws InterruptedException
      */
     @Override
     @Transactional
-    public Boolean sopPublish(SopPublishParam sopPublishParam) throws InterruptedException {
-        Optional.ofNullable(sopPublishParam.getCrmNo())
-                .orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空"));
-        if (sopPublishParam.getApprove() != FlowApprovePassEnum.DRAFT) {
-            throw ExceptionResultEnum.PARAMS_ERROR.exception("sop发布只能为草稿");
+    public String sopPublish(SopPublishParam sopPublishParam) throws InterruptedException {
+        Objects.requireNonNull(sopPublishParam.getCrmNo(), "crm编号不能为空");
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(sopPublishParam.getSopNo(),
+                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"));
+
+        TBService tbService = tbServiceService.getById(crmProjectResult.getServiceUnitId());
+        Optional.ofNullable(tbService).orElseThrow(() -> ExceptionResultEnum.SERVICE_NO_DATA.exception());
+        Optional.ofNullable(tbService.getStatus()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("服务单元状态为空"));
+
+        if (Objects.isNull(tbService.getEnable()) || !tbService.getEnable()) {
+            throw ExceptionResultEnum.ERROR.exception("服务单元已作废");
+        }
+        if (tbService.getStatus() != ServiceStatusEnum.PUBLISH) {
+            throw ExceptionResultEnum.ERROR.exception("只有发布状态的服务单元才能新增sop");
         }
-        return tbSopInfoService.sopApplyOrPublish(sopPublishParam.getSopNo(), sopPublishParam.getCrmNo(),
-                sopPublishParam.getFlowDeploymentId(), sopPublishParam.getApprove(),
-                sopPublishParam.getFormProperties());
-    }
 
-    /**
-     * sop申请信息
-     *
-     * @param sopApplyParam
-     * @return
-     */
-    @Override
-    @Transactional
-    public Boolean sopApply(SopApplyParam sopApplyParam) throws InterruptedException {
-        Optional.ofNullable(sopApplyParam.getCrmNo())
-                .orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空"));
-        if (sopApplyParam.getApprove() != FlowApprovePassEnum.START
-                && sopApplyParam.getApprove() != FlowApprovePassEnum.DRAFT) {
-            throw ExceptionResultEnum.PARAMS_ERROR.exception("sop申请只能为提交或草稿");
+        TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda()
+                .eq(TFCustomFlow::getFlowDeploymentId, sopPublishParam.getFlowDeploymentId()));
+        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+        TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, tfCustomFlow.getType());
+        Optional.ofNullable(maxTfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+        if (maxTfCustomFlow.getVersion().intValue() != tfCustomFlow.getVersion().intValue()) {//说明版本发生变化
+            BeanUtils.copyProperties(maxTfCustomFlow, tfCustomFlow);
         }
-        return tbSopInfoService.sopApplyOrPublish(sopApplyParam.getSopNo(), sopApplyParam.getCrmNo(),
-                sopApplyParam.getFlowDeploymentId(), sopApplyParam.getApprove(), sopApplyParam.getFormProperties());
+
+        if (tfCustomFlow.getType() != TFCustomTypeEnum.OFFICE_SOP_FLOW
+                && tfCustomFlow.getType() != TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+            throw ExceptionResultEnum.ERROR.exception("sop流程类型错误");
+        }
+        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);
+
+        TBSopInfo tbSopInfo = new TBSopInfo(sopPublishParam.getCrmNo(), tfCustomFlowEntity.getCode(),
+                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);
+        tbSopInfoService.save(tbSopInfo);
+        return tfCustomFlowEntity.getCode();
     }
 
+    //    /**
+    //     * sop申请信息
+    //     *
+    //     * @param sopApplyParam
+    //     * @return
+    //     */
+    //    @Override
+    //    @Transactional
+    //    @Deprecated
+    //    public Boolean sopApply(SopApplyParam sopApplyParam) throws InterruptedException {
+    //        Optional.ofNullable(sopApplyParam.getCrmNo())
+    //                .orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空"));
+    //        if (sopApplyParam.getApprove() != FlowApprovePassEnum.START
+    //                && sopApplyParam.getApprove() != FlowApprovePassEnum.DRAFT) {
+    //            throw ExceptionResultEnum.PARAMS_ERROR.exception("sop申请只能为提交或草稿");
+    //        }
+    //        return tbSopInfoService.sopApplyOrPublish(sopApplyParam.getSopNo(), sopApplyParam.getCrmNo(),
+    //                sopApplyParam.getFlowDeploymentId(), sopApplyParam.getApprove(), sopApplyParam.getFormProperties());
+    //    }
+
     /**
      * sop填报信息
      *
@@ -837,105 +905,106 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     //        return map;
     //    }
 
-    /**
-     * sop申请或发布
-     *
-     * @param sopNo
-     * @param crmNo
-     * @param flowDeploymentId
-     * @param approve
-     * @param formProperties
-     * @return
-     * @throws InterruptedException
-     */
-    @Override
-    @Transactional
-    public Boolean sopApplyOrPublish(String sopNo, String crmNo, String flowDeploymentId, FlowApprovePassEnum approve,
-            String formProperties) throws InterruptedException {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(sopNo, crmNo);
-        Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
-        Optional.ofNullable(crmProjectResult.getRegionManagerId())
-                .orElseThrow(() -> ExceptionResultEnum.ERROR.exception("该派单号[" + crmNo + "]未设置大区经理"));
-
-        TBService tbService = tbServiceService.getById(crmProjectResult.getServiceUnitId());
-        Optional.ofNullable(tbService).orElseThrow(() -> ExceptionResultEnum.SERVICE_NO_DATA.exception());
-        Optional.ofNullable(tbService.getStatus()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("服务单元状态为空"));
-
-        if (Objects.isNull(tbService.getEnable()) || !tbService.getEnable()) {
-            throw ExceptionResultEnum.ERROR.exception("服务单元已作废");
-        }
-        if (tbService.getStatus() != ServiceStatusEnum.PUBLISH) {
-            throw ExceptionResultEnum.ERROR.exception("只有发布状态的服务单元才能新增sop");
-        }
-
-        TFCustomFlow tfCustomFlow = null;
-        TBSopInfoDetail tbSopInfoDetail = null;
-        List<String> approveUserIds = new ArrayList<>();
-        if (approve == FlowApprovePassEnum.DRAFT) {
-            approveUserIds.add(String.valueOf(crmProjectResult.getRegionManagerId()));
-        } else if (approve == FlowApprovePassEnum.START) {
-            Optional.ofNullable(formProperties)
-                    .orElseThrow(() -> ExceptionResultEnum.FLOW_FORM_PROPERTIES_IS_NULL.exception());
-
-            tfCustomFlow = tfCustomFlowService.getOne(
-                    new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
-            Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
-            TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, tfCustomFlow.getType());
-            Optional.ofNullable(maxTfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
-            if (maxTfCustomFlow.getVersion().intValue() != tfCustomFlow.getVersion().intValue()) {//说明版本发生变化
-                BeanUtils.copyProperties(maxTfCustomFlow, tfCustomFlow);
-            }
-
-            if (tfCustomFlow.getType() != TFCustomTypeEnum.OFFICE_SOP_FLOW
-                    && tfCustomFlow.getType() != TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
-                throw ExceptionResultEnum.ERROR.exception("sop流程类型错误");
-            }
-
-            FlowTaskResult flowTaskResult = JSONObject.parseObject(formProperties, FlowTaskResult.class);
-            //            Map<String, Object> map = this.getApproveUserIds(flowTaskResult);
-            //            Long regionUserId = (Long) map.get(SystemConstant.REGION_USER_ID);
-            //            Long engineerUserId = (Long) map.get(SystemConstant.ENGINEER_USER_ID);
-            //            String assistantEngineerUserIds = (String) map.get(SystemConstant.ASSISTANT_ENGINEER_USER_ID);
-            //            tbSopInfoDetail = new TBSopInfoDetail(crmProjectResult.getRegionManagerId(), regionUserId, engineerUserId,
-            //                    assistantEngineerUserIds);
-            approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResult, tbSopInfoDetail, null);
-        }
-
-        Map<String, Object> map = activitiService.taskApprove(
-                new FlowApproveParam(flowDeploymentId, approve, approveUserIds, crmNo, formProperties));
-        if (approve != FlowApprovePassEnum.DRAFT) {
-            map.put(SystemConstant.CRM_INFO, crmProjectResult);
-            map.put(SystemConstant.SOP_ID, null);
-            map.put(SystemConstant.SOURCE, "sopApplyOrPublish");
-            tbSopInfoService.saveJobRemind(map);
-        }
-
-        tfCustomFlow = Objects.isNull(tfCustomFlow) ? (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM) : tfCustomFlow;
-        TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
-
-        TBSopInfo tbSopInfo = new TBSopInfo(crmNo, tfCustomFlowEntity.getCode(), crmProjectResult.getServiceUnitId(),
-                crmProjectResult.getCustomId(), crmProjectResult.getProductId(), tfCustomFlow.getType(),
-                SopStatusEnum.valueOf(approve.name()), sysUser.getId());
-        if (Objects.isNull(tbSopInfoDetail)) {
-            tbSopInfoDetail = new TBSopInfoDetail(tbSopInfo.getId(), crmProjectResult.getRegionManagerId());
-        } else {
-            tbSopInfoDetail.setSopInfoId(tbSopInfo.getId());
-        }
-        tbSopInfoDetailService.save(tbSopInfoDetail);
-        TBSopPlanDateLog tbSopPlanDateLog = tbSopPlanDateLogService.getOne(new QueryWrapper<TBSopPlanDateLog>().lambda()
-                .eq(TBSopPlanDateLog::getFlowId, tfCustomFlowEntity.getFlowId())
-                .orderByDesc(TBSopPlanDateLog::getCreateTime).last(" limit 1 "));
-        if (Objects.nonNull(tbSopPlanDateLog)) {
-            tbSopPlanDateLog.setSopId(tbSopInfo.getId());
-            tbSopPlanDateLogService.updateById(tbSopPlanDateLog);
-        }
-
-        tfCustomFlowEntity.setObjId(tbSopInfo.getId());
-        tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
-        tbCrmService.updateCrmStatus(crmNo, CrmStatusEnum.PUBLISH);
-        return tbSopInfoService.save(tbSopInfo);
-    }
+    //    /**
+    //     * sop申请或发布
+    //     *
+    //     * @param sopNo
+    //     * @param crmNo
+    //     * @param flowDeploymentId
+    //     * @param approve
+    //     * @param formProperties
+    //     * @return
+    //     * @throws InterruptedException
+    //     */
+    //    @Override
+    //    @Transactional
+    //    @Deprecated
+    //    public Boolean sopApplyOrPublish(String sopNo, String crmNo, String flowDeploymentId, FlowApprovePassEnum approve,
+    //            String formProperties) throws InterruptedException {
+    //        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+    //        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(sopNo, crmNo);
+    //        Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
+    //        Optional.ofNullable(crmProjectResult.getRegionManagerId())
+    //                .orElseThrow(() -> ExceptionResultEnum.ERROR.exception("该派单号[" + crmNo + "]未设置大区经理"));
+    //
+    //        TBService tbService = tbServiceService.getById(crmProjectResult.getServiceUnitId());
+    //        Optional.ofNullable(tbService).orElseThrow(() -> ExceptionResultEnum.SERVICE_NO_DATA.exception());
+    //        Optional.ofNullable(tbService.getStatus()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("服务单元状态为空"));
+    //
+    //        if (Objects.isNull(tbService.getEnable()) || !tbService.getEnable()) {
+    //            throw ExceptionResultEnum.ERROR.exception("服务单元已作废");
+    //        }
+    //        if (tbService.getStatus() != ServiceStatusEnum.PUBLISH) {
+    //            throw ExceptionResultEnum.ERROR.exception("只有发布状态的服务单元才能新增sop");
+    //        }
+    //
+    //        TFCustomFlow tfCustomFlow = null;
+    //        TBSopInfoDetail tbSopInfoDetail = null;
+    //        List<String> approveUserIds = new ArrayList<>();
+    //        if (approve == FlowApprovePassEnum.DRAFT) {
+    //            approveUserIds.add(String.valueOf(crmProjectResult.getRegionManagerId()));
+    //        } else if (approve == FlowApprovePassEnum.START) {
+    //            Optional.ofNullable(formProperties)
+    //                    .orElseThrow(() -> ExceptionResultEnum.FLOW_FORM_PROPERTIES_IS_NULL.exception());
+    //
+    //            tfCustomFlow = tfCustomFlowService.getOne(
+    //                    new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
+    //            Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+    //            TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, tfCustomFlow.getType());
+    //            Optional.ofNullable(maxTfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+    //            if (maxTfCustomFlow.getVersion().intValue() != tfCustomFlow.getVersion().intValue()) {//说明版本发生变化
+    //                BeanUtils.copyProperties(maxTfCustomFlow, tfCustomFlow);
+    //            }
+    //
+    //            if (tfCustomFlow.getType() != TFCustomTypeEnum.OFFICE_SOP_FLOW
+    //                    && tfCustomFlow.getType() != TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+    //                throw ExceptionResultEnum.ERROR.exception("sop流程类型错误");
+    //            }
+    //
+    //            FlowTaskResult flowTaskResult = JSONObject.parseObject(formProperties, FlowTaskResult.class);
+    //            //            Map<String, Object> map = this.getApproveUserIds(flowTaskResult);
+    //            //            Long regionUserId = (Long) map.get(SystemConstant.REGION_USER_ID);
+    //            //            Long engineerUserId = (Long) map.get(SystemConstant.ENGINEER_USER_ID);
+    //            //            String assistantEngineerUserIds = (String) map.get(SystemConstant.ASSISTANT_ENGINEER_USER_ID);
+    //            //            tbSopInfoDetail = new TBSopInfoDetail(crmProjectResult.getRegionManagerId(), regionUserId, engineerUserId,
+    //            //                    assistantEngineerUserIds);
+    //            approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResult, tbSopInfoDetail, null);
+    //        }
+    //
+    //        Map<String, Object> map = activitiService.taskApprove(
+    //                new FlowApproveParam(flowDeploymentId, approve, approveUserIds, crmNo, formProperties));
+    //        if (approve != FlowApprovePassEnum.DRAFT) {
+    //            map.put(SystemConstant.CRM_INFO, crmProjectResult);
+    //            map.put(SystemConstant.SOP_ID, null);
+    //            map.put(SystemConstant.SOURCE, "sopApplyOrPublish");
+    //            tbSopInfoService.saveJobRemind(map);
+    //        }
+    //
+    //        tfCustomFlow = Objects.isNull(tfCustomFlow) ? (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM) : tfCustomFlow;
+    //        TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
+    //
+    //        TBSopInfo tbSopInfo = new TBSopInfo(crmNo, tfCustomFlowEntity.getCode(), crmProjectResult.getServiceUnitId(),
+    //                crmProjectResult.getCustomId(), crmProjectResult.getProductId(), tfCustomFlow.getType(),
+    //                SopStatusEnum.valueOf(approve.name()), sysUser.getId());
+    //        if (Objects.isNull(tbSopInfoDetail)) {
+    //            tbSopInfoDetail = new TBSopInfoDetail(tbSopInfo.getId(), crmProjectResult.getRegionManagerId());
+    //        } else {
+    //            tbSopInfoDetail.setSopInfoId(tbSopInfo.getId());
+    //        }
+    //        tbSopInfoDetailService.save(tbSopInfoDetail);
+    //        TBSopPlanDateLog tbSopPlanDateLog = tbSopPlanDateLogService.getOne(new QueryWrapper<TBSopPlanDateLog>().lambda()
+    //                .eq(TBSopPlanDateLog::getFlowId, tfCustomFlowEntity.getFlowId())
+    //                .orderByDesc(TBSopPlanDateLog::getCreateTime).last(" limit 1 "));
+    //        if (Objects.nonNull(tbSopPlanDateLog)) {
+    //            tbSopPlanDateLog.setSopId(tbSopInfo.getId());
+    //            tbSopPlanDateLogService.updateById(tbSopPlanDateLog);
+    //        }
+    //
+    //        tfCustomFlowEntity.setObjId(tbSopInfo.getId());
+    //        tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
+    //        tbCrmService.updateCrmStatus(crmNo, CrmStatusEnum.PUBLISH);
+    //        return tbSopInfoService.save(tbSopInfo);
+    //    }
 
     /**
      * 保存提醒/延时任务
@@ -967,93 +1036,99 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             Long processLimitedTime = null;
             String execField = null;
             if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop
-                if (tfFlowApprove.getSetup().intValue() == 2) {//项目关键信息
-                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
-                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
-                            ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey());
-                    execField = ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey();
-                    tbSopInfoService.saveSopPlanDate(flowTaskResult, sopId, tfCustomFlowEntity.getFlowId(),
-                            sysUser.getId());
-                } else if (tfFlowApprove.getSetup().intValue() == 3) {//内审
-                    processLimitedTime = tfFlowApprove.getUpdateTime();
-                    execField = ProcessLimitedEnum.APPROVE_RADIO.getKey();
-                } else if (tfFlowApprove.getSetup().intValue() == 5) {//扫描准备
-                    String source = (String) map.get(SystemConstant.SOURCE);
-                    if (Objects.nonNull(source) && !Objects.equals(source, "save")) {
-                        tbSopInfoService.sopDeviceInOutSave(map, 4);
-                    }
-                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
-                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
-                            ProcessLimitedEnum.SCAN_START_TIME.getKey());
-                    execField = ProcessLimitedEnum.SCAN_START_TIME.getKey();
-                } else if (tfFlowApprove.getSetup().intValue() == 7) {//校验收尾
-                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
-                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
-                            ProcessLimitedEnum.SCAN_END_TIME.getKey());
-                    execField = ProcessLimitedEnum.SCAN_END_TIME.getKey();
-                } else if (tfFlowApprove.getSetup().intValue() == 8) {//设备入库登记
-                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
-                    String source = (String) map.get(SystemConstant.SOURCE);
-                    //审批过程中,如果外包服务范围为"仅扫描",则释放实施工程师资源,后续有区域协调人兼任
-                    if (Objects.nonNull(source) && Objects.equals(source, "sopApprove")) {
-                        List<FlowFormWidgetResult> formProperty = flowTaskResult.getFormProperty();
-                        Long engineerUserId = null;
-                        for (FlowFormWidgetResult f : formProperty) {
-                            if (f.getFormId().contains(SystemConstant.THIRD_SERVICE_REGION_CB) && Objects.nonNull(
-                                    f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
-                                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
-                                String value = jsonObject.getString(SystemConstant.VALUE);
-                                if (Objects.nonNull(value) && Objects.nonNull(sopId) && value.equals("SCAN")) {
-                                    TBSopInfoDetail tbSopInfoDetail = tbSopInfoDetailService.getOne(
-                                            new QueryWrapper<TBSopInfoDetail>().lambda()
-                                                    .eq(TBSopInfoDetail::getSopInfoId, sopId));
-                                    engineerUserId = tbSopInfoDetail.getEngineerUserId();
-                                    tbSopInfoDetail.setAfterRegionToEnginess(true);
-                                    tbSopInfoDetailService.updateById(tbSopInfoDetail);
-                                    break;
-                                }
-                            }
-                        }
-                        if (Objects.nonNull(engineerUserId)) {
-                            List<Map<String, Object>> sopPassageMap = this.findSopPassage(null);
-                            if (!CollectionUtils.isEmpty(sopPassageMap)) {
-                                for (Map m : sopPassageMap) {
-                                    String engineerUserStr =
-                                            Objects.nonNull(m) && Objects.nonNull(m.get("engineerUserIds")) ?
-                                                    m.get("engineerUserIds").toString() :
-                                                    null;
-                                    if (Objects.nonNull(engineerUserStr)) {
-                                        String[] strs = engineerUserStr.split(",");
-                                        Set<String> set = new HashSet<>(Arrays.asList(strs));
-                                        if (!set.contains(engineerUserId)) {
-                                            TBUserArchives tbUserArchives = tbUserArchivesService.findByUserId(
-                                                    engineerUserId);
-                                            if (Objects.nonNull(tbUserArchives)) {
-                                                tbUserArchives.setStatus(UserArchivesStatusEnum.FREE);
-                                                tbUserArchives.updateInfo(sysUser.getId());
-                                                tbUserArchivesService.updateById(tbUserArchives);
-                                            }
-                                        }
-                                        break;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
-                            ProcessLimitedEnum.SERVICE_FINISH_PLAN_DATE.getKey());
-                    execField = ProcessLimitedEnum.SERVICE_FINISH_PLAN_DATE.getKey();
-                } else if (tfFlowApprove.getSetup().intValue() == 9) {//评卷准备
-                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
-                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
-                            ProcessLimitedEnum.MARK_START_TIME.getKey());
-                    execField = ProcessLimitedEnum.MARK_START_TIME.getKey();
-                } else if (tfFlowApprove.getSetup().intValue() == 10) {//评卷收尾
-                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
-                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
-                            ProcessLimitedEnum.MARK_END_TIME.getKey());
-                    execField = ProcessLimitedEnum.MARK_END_TIME.getKey();
-                }
+                FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
+                processLimitedTime = tfFlowApprove.getUpdateTime();
+                execField = ProcessLimitedEnum.FLOW_TASK.getKey();
+                tbSopInfoService.saveSopPlanDate(flowTaskResult, sopId, tfCustomFlowEntity.getFlowId(),
+                        sysUser.getId());
+
+                //                if (tfFlowApprove.getSetup().intValue() == 2) {//项目关键信息
+                //                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
+                //                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
+                //                            ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey());
+                //                    execField = ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey();
+                //                    tbSopInfoService.saveSopPlanDate(flowTaskResult, sopId, tfCustomFlowEntity.getFlowId(),
+                //                            sysUser.getId());
+                //                } else if (tfFlowApprove.getSetup().intValue() == 3) {//内审
+                //                    processLimitedTime = tfFlowApprove.getUpdateTime();
+                //                    execField = ProcessLimitedEnum.APPROVE_RADIO.getKey();
+                //                } else if (tfFlowApprove.getSetup().intValue() == 5) {//扫描准备
+                //                    String source = (String) map.get(SystemConstant.SOURCE);
+                //                    if (Objects.nonNull(source) && !Objects.equals(source, "save")) {
+                //                        tbSopInfoService.sopDeviceInOutSave(map, 4);
+                //                    }
+                //                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
+                //                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
+                //                            ProcessLimitedEnum.SCAN_START_TIME.getKey());
+                //                    execField = ProcessLimitedEnum.SCAN_START_TIME.getKey();
+                //                } else if (tfFlowApprove.getSetup().intValue() == 7) {//校验收尾
+                //                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
+                //                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
+                //                            ProcessLimitedEnum.SCAN_END_TIME.getKey());
+                //                    execField = ProcessLimitedEnum.SCAN_END_TIME.getKey();
+                //                } else if (tfFlowApprove.getSetup().intValue() == 8) {//设备入库登记
+                //                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
+                //                    String source = (String) map.get(SystemConstant.SOURCE);
+                //                    //审批过程中,如果外包服务范围为"仅扫描",则释放实施工程师资源,后续有区域协调人兼任
+                //                    if (Objects.nonNull(source) && Objects.equals(source, "sopApprove")) {
+                //                        List<FlowFormWidgetResult> formProperty = flowTaskResult.getFormProperty();
+                //                        Long engineerUserId = null;
+                //                        for (FlowFormWidgetResult f : formProperty) {
+                //                            if (f.getFormId().contains(SystemConstant.THIRD_SERVICE_REGION_CB) && Objects.nonNull(
+                //                                    f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+                //                                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                //                                String value = jsonObject.getString(SystemConstant.VALUE);
+                //                                if (Objects.nonNull(value) && Objects.nonNull(sopId) && value.equals("SCAN")) {
+                //                                    TBSopInfoDetail tbSopInfoDetail = tbSopInfoDetailService.getOne(
+                //                                            new QueryWrapper<TBSopInfoDetail>().lambda()
+                //                                                    .eq(TBSopInfoDetail::getSopInfoId, sopId));
+                //                                    engineerUserId = tbSopInfoDetail.getEngineerUserId();
+                //                                    tbSopInfoDetail.setAfterRegionToEnginess(true);
+                //                                    tbSopInfoDetailService.updateById(tbSopInfoDetail);
+                //                                    break;
+                //                                }
+                //                            }
+                //                        }
+                //                        if (Objects.nonNull(engineerUserId)) {
+                //                            List<Map<String, Object>> sopPassageMap = this.findSopPassage(null);
+                //                            if (!CollectionUtils.isEmpty(sopPassageMap)) {
+                //                                for (Map m : sopPassageMap) {
+                //                                    String engineerUserStr =
+                //                                            Objects.nonNull(m) && Objects.nonNull(m.get("engineerUserIds")) ?
+                //                                                    m.get("engineerUserIds").toString() :
+                //                                                    null;
+                //                                    if (Objects.nonNull(engineerUserStr)) {
+                //                                        String[] strs = engineerUserStr.split(",");
+                //                                        Set<String> set = new HashSet<>(Arrays.asList(strs));
+                //                                        if (!set.contains(engineerUserId)) {
+                //                                            TBUserArchives tbUserArchives = tbUserArchivesService.findByUserId(
+                //                                                    engineerUserId);
+                //                                            if (Objects.nonNull(tbUserArchives)) {
+                //                                                tbUserArchives.setStatus(UserArchivesStatusEnum.FREE);
+                //                                                tbUserArchives.updateInfo(sysUser.getId());
+                //                                                tbUserArchivesService.updateById(tbUserArchives);
+                //                                            }
+                //                                        }
+                //                                        break;
+                //                                    }
+                //                                }
+                //                            }
+                //                        }
+                //                    }
+                //                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
+                //                            ProcessLimitedEnum.SERVICE_FINISH_PLAN_DATE.getKey());
+                //                    execField = ProcessLimitedEnum.SERVICE_FINISH_PLAN_DATE.getKey();
+                //                } else if (tfFlowApprove.getSetup().intValue() == 9) {//评卷准备
+                //                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
+                //                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
+                //                            ProcessLimitedEnum.MARK_START_TIME.getKey());
+                //                    execField = ProcessLimitedEnum.MARK_START_TIME.getKey();
+                //                } else if (tfFlowApprove.getSetup().intValue() == 10) {//评卷收尾
+                //                    FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
+                //                    processLimitedTime = this.getProcessLimitedTime(flowTaskResult,
+                //                            ProcessLimitedEnum.MARK_END_TIME.getKey());
+                //                    execField = ProcessLimitedEnum.MARK_END_TIME.getKey();
+                //                }
             } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop
                 if (tfFlowApprove.getSetup().intValue() == 2) {//项目关键信息
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
@@ -1427,19 +1502,19 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         Long serviceFinishPlanEndDate = this.getProcessLimitedTime(flowTaskResult,
                 ProcessLimitedEnum.SERVICE_FINISH_PLAN_DATE.getKey());
         if (Objects.nonNull(serviceFinishPlanBeginDate)) {
-            TBSopPlanDateLog tbSopPlanDateLog = tbSopPlanDateLogService.getOne(
+            TBSopPlanDateLog tbSopPlanDateLogDb = tbSopPlanDateLogService.getOne(
                     new QueryWrapper<TBSopPlanDateLog>().lambda().eq(TBSopPlanDateLog::getFlowId, flowId)
                             .orderByDesc(TBSopPlanDateLog::getCreateTime).last(" limit 1 "));
-            if (Objects.isNull(tbSopPlanDateLog)) {
-                tbSopPlanDateLog = new TBSopPlanDateLog(sopId, flowId, serviceFinishPlanBeginDate,
+            if (Objects.isNull(tbSopPlanDateLogDb)) {
+                tbSopPlanDateLogDb = new TBSopPlanDateLog(sopId, flowId, serviceFinishPlanBeginDate,
                         serviceFinishPlanEndDate, userId);
-                tbSopPlanDateLogService.save(tbSopPlanDateLog);
+                tbSopPlanDateLogService.save(tbSopPlanDateLogDb);
             } else {
                 TBSopPlanDateLog tbSopPlanDateLogNew = new TBSopPlanDateLog();
-                BeanUtils.copyProperties(tbSopPlanDateLog, tbSopPlanDateLogNew);
+                BeanUtils.copyProperties(tbSopPlanDateLogDb, tbSopPlanDateLogNew);
                 tbSopPlanDateLogNew.setBeginTime(serviceFinishPlanBeginDate);
                 tbSopPlanDateLogNew.setEndTime(serviceFinishPlanEndDate);
-                if (!tbSopPlanDateLogNew.equals(tbSopPlanDateLog)) {
+                if (!tbSopPlanDateLogNew.equals(tbSopPlanDateLogDb)) {
                     tbSopPlanDateLogNew.updateInfo(userId);
                     tbSopPlanDateLogService.save(tbSopPlanDateLogNew);
                 }

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

@@ -25,7 +25,9 @@ public enum ProcessLimitedEnum {
 
     SERVICE_FINISH_PLAN_BEGIN_DATE("service_finish_plan_begin_date", "现场服务完成进场计划时间"),
 
-    ENV_DEPLOYMENT_TIME("env_deployment_time", "环境部署时间");
+    ENV_DEPLOYMENT_TIME("env_deployment_time", "环境部署时间"),
+
+    FLOW_TASK("flowTask", "流程待办");
 
     private String key;