Browse Source

研究生内审修改

wangliang 10 months ago
parent
commit
e596bfe525

+ 37 - 5
sop-api/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -6,12 +6,11 @@ import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.params.SopAllocationParam;
 import com.qmth.sop.business.bean.params.SopInfoListParam;
 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.FormWidgetMetadataResult;
-import com.qmth.sop.business.entity.SysUser;
-import com.qmth.sop.business.entity.TDFormWidgetMetadata;
-import com.qmth.sop.business.service.TBSopInfoService;
-import com.qmth.sop.business.service.TDFormWidgetMetadataService;
+import com.qmth.sop.business.entity.*;
+import com.qmth.sop.business.service.*;
 import com.qmth.sop.common.annotation.OperationLog;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
@@ -28,6 +27,8 @@ import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
 
 /**
  * <p>
@@ -51,6 +52,21 @@ public class TBSopInfoController {
     @Resource
     ActivitiService activitiService;
 
+    @Resource
+    TFCustomFlowService tfCustomFlowService;
+
+    @Resource
+    TFCustomFlowEntityService tfCustomFlowEntityService;
+
+    @Resource
+    TFFlowApproveService tfFlowApproveService;
+
+    @Resource
+    TBCrmService tbCrmService;
+
+    @Resource
+    TBCrmDetailService tbCrmDetailService;
+
     @ApiOperation(value = "sop元数据查询")
     @RequestMapping(value = "/metadata/list", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = FormWidgetMetadataResult.class) })
@@ -116,7 +132,23 @@ public class TBSopInfoController {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        return ResultUtil.ok(tbSopInfoService.sopAllocation(sopAllocationParam));
+        Boolean result = tbSopInfoService.sopAllocation(sopAllocationParam);
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(sopAllocationParam.getFlowId());
+        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+        TFCustomFlow tfCustomFlow = tfCustomFlowService.findById(tfCustomFlowEntity.gettFCustomFlowId());
+        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+
+        if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+            TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
+            Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
+            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(tfCustomFlowEntity.getFlowId());
+            Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
+                    tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
+            tbSopInfoService.sopSystemApprove(tfCustomFlow, tfCustomFlowEntity, tfFlowApprove, crmProjectResult,
+                    tbCrmDetail.getCrmNo(), tbCrmDetail.getId());
+        }
+        return ResultUtil.ok(result);
     }
 
     @ApiOperation(value = "sop删除")

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

@@ -764,6 +764,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             } else {
                 if (!Objects.equals(task.getAssignee(), String.valueOf(userId))) {
                     replace = true;
+                    oldUserId = task.getAssignee();
                     taskService.setAssignee(String.valueOf(taskId), String.valueOf(userId));
                 }
             }
@@ -1042,19 +1043,11 @@ public class ActivitiServiceImpl implements ActivitiService {
                     for (FlowFormWidgetResult f : flowFormWidgetResultList) {
                         if (Objects.nonNull(sopRoleTypeCompositeEnum)) {
                             if (Objects.nonNull(sopRoleTypeCompositeEnum) && Objects.equals(f.getRoleType(),
-                                    sopRoleTypeCompositeEnum.name()) && (Objects.isNull(f.getValue()) || Objects.equals(
-                                    f.getValue(), "{\"value\":null}") || Objects.equals(f.getValue(), "{\"value\":[]}"))
-                                    && (sopRoleTypeCompositeEnum == SopRoleTypeCompositeEnum.REGION_MANAGER
-                                    || sopRoleTypeCompositeEnum == SopRoleTypeCompositeEnum.PROJECT_MANAGER)) {
-                                f.setReadable(false);
-                                f.setWritable(true);
-                                f.setRequired(true);
-                            } else {
-                                f.setReadable(true);
-                                f.setWritable(false);
-                                f.setRequired(false);
+                                    sopRoleTypeCompositeEnum.name()) && (
+                                    sopRoleTypeCompositeEnum == SopRoleTypeCompositeEnum.REGION_MANAGER
+                                            || sopRoleTypeCompositeEnum == SopRoleTypeCompositeEnum.PROJECT_MANAGER)) {
+                                flowFormWidgetResultListNew.add(f);
                             }
-                            flowFormWidgetResultListNew.add(f);
                         }
                     }
                 } else if (!CollectionUtils.isEmpty(taskList) && taskList.size() == 1) {
@@ -1065,6 +1058,13 @@ public class ActivitiServiceImpl implements ActivitiService {
                             if (Objects.equals(crmProjectResult.getRegionManagerId().toString(),
                                     task.getAssignee())) {//大区经理
                                 sopRoleTypeCompositeEnum = SopRoleTypeCompositeEnum.REGION_MANAGER;
+                                TFFlowLog tfFlowLog = tfFlowLogService.findByLastFlowLog(flowId,
+                                        FlowApproveOperationEnum.APPROVE);
+                                if (tfFlowLog.getApproveId().longValue() == sysUser.getId().longValue()
+                                        && tfFlowLog.getApproveSetup().intValue() == 3 && Objects.equals(
+                                        tfFlowLog.getApproveRemark(), SystemConstant.SYSTEM_AUTO_APPROVE)) {
+                                    sopRoleTypeCompositeEnum = SopRoleTypeCompositeEnum.PROJECT_MANAGER;
+                                }
                             } else if (Objects.equals(
                                     crmProjectResult.getProjectManagerList().get(0).getUserId().toString(),
                                     task.getAssignee())) {

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TFFlowLogMapper.java

@@ -33,6 +33,14 @@ public interface TFFlowLogMapper extends BaseMapper<TFFlowLog> {
      */
     TFFlowLog findByLastFlowLog(@Param("flowId") Long flowId);
 
+    /**
+     * 查询最后一条日志审批记录
+     *
+     * @param flowId
+     * @return
+     */
+    TFFlowLog findByLastFlowApproveOperationLog(@Param("flowId") Long flowId, @Param("approveOperation") String approveOperation);
+
     /**
      * 查询最后一条日志审批记录
      *

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

@@ -68,6 +68,21 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      */
     Boolean sopApprove(FlowApproveParam flowApproveParam) throws InterruptedException;
 
+    /**
+     * 系统自动审批
+     *
+     * @param tfCustomFlow
+     * @param tfCustomFlowEntity
+     * @param tfFlowApprove
+     * @param crmProjectResult
+     * @param crmNo
+     * @param crmDetailId
+     * @throws InterruptedException
+     */
+    public void sopSystemApprove(TFCustomFlow tfCustomFlow, TFCustomFlowEntity tfCustomFlowEntity,
+            TFFlowApprove tfFlowApprove, CrmProjectResult crmProjectResult, String crmNo, Long crmDetailId)
+            throws InterruptedException;
+
     /**
      * sop管理列表
      *
@@ -197,6 +212,21 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      */
     Boolean updateFlowSetupOne(Long flowId, Long crmDetailId, List<String> engineerUserIdList);
 
+    /**
+     * 更新流程信息
+     *
+     * @param allocationParamList
+     * @param tfCustomFlow
+     * @param tfCustomFlowEntity
+     * @param tfFlowApprove
+     * @param tbCrmDetail
+     * @return
+     * @throws InterruptedException
+     */
+    Boolean updateFlowInfo(List<AllocationParam> allocationParamList, TFCustomFlow tfCustomFlow,
+            TFCustomFlowEntity tfCustomFlowEntity, TFFlowApprove tfFlowApprove, TBCrmDetail tbCrmDetail)
+            throws InterruptedException;
+
     /**
      * 查询服务范围
      *

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

@@ -33,6 +33,14 @@ public interface TFFlowLogService extends IService<TFFlowLog> {
      */
     TFFlowLog findByLastFlowLog(Long flowId);
 
+    /**
+     * 查询最后一条日志审批记录(带审批状态)
+     *
+     * @param flowId
+     * @return
+     */
+    TFFlowLog findByLastFlowLog(Long flowId, FlowApproveOperationEnum approveOperation);
+
     /**
      * 查询最后一条日志审批记录
      *

+ 144 - 53
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -470,34 +470,24 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             throws InterruptedException {
         TBCrmDetail tbCrmDetail = tbCrmDetailService.getById(crmDetailId);
         Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
-
         if (Objects.nonNull(tbCrmDetail.getSopNo())) {
             //已发布且状态为草稿的sop可以修改
-            if (tbCrmDetail.getStatus() == CrmStatusEnum.PUBLISH) {
-                FlowStatusEnum flowStatus = tbCrmDetailService.findById(tbCrmDetail.getId());
-                if (Objects.nonNull(flowStatus) && (flowStatus == FlowStatusEnum.FINISH
-                        || flowStatus == FlowStatusEnum.END)) {
-                    throw ExceptionResultEnum.ERROR.exception("流程已结束,无法转审");
-                }
-            }
             TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByCode(tbCrmDetail.getSopNo());
+            Optional.ofNullable(tfCustomFlowEntity)
+                    .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(tfCustomFlowEntity.getFlowId());
+            Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
-            Task task = taskService.createTaskQuery().processInstanceId(tfCustomFlowEntity.getFlowId().toString())
-                    .singleResult();
-            List<AllocationParam> allocationParamList = sopAllocationParam.getAllocationParams();
-            if (!CollectionUtils.isEmpty(allocationParamList)) {
-                for (AllocationParam a : allocationParamList) {
-                    if (a.getSopRoleType() == SopRoleTypeEnum.PROJECT_MANAGER) {
-                        activitiService.taskApproverExchange(a.getUserIdList().get(0), Long.parseLong(task.getId()));
-                    } else if (a.getSopRoleType() == SopRoleTypeEnum.ENGINEER) {
-                        //修改流程one里面的工程师
-                        List<String> engineerUserIdList = a.getUserIdList().stream().map(s -> s.toString())
-                                .collect(Collectors.toList());
-                        tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId(),
-                                engineerUserIdList);
-                    }
+            if (tbCrmDetail.getStatus() == CrmStatusEnum.PUBLISH) {
+                if (Objects.nonNull(tfFlowApprove.getStatus()) && (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH
+                        || tfFlowApprove.getStatus() == FlowStatusEnum.END)) {
+                    throw ExceptionResultEnum.ERROR.exception("流程已结束,无法转审");
                 }
             }
+            TFCustomFlow tfCustomFlow = tfCustomFlowService.findById(tfCustomFlowEntity.gettFCustomFlowId());
+            Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+            tbSopInfoService.updateFlowInfo(sopAllocationParam.getAllocationParams(), tfCustomFlow, tfCustomFlowEntity,
+                    tfFlowApprove, tbCrmDetail);
         }
         return true;
     }
@@ -525,31 +515,21 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     @Transactional
     public Boolean sopAllocation(SopAllocationParam sopAllocationParam) throws InterruptedException {
         TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(sopAllocationParam.getFlowId());
+        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
         TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
-        FlowStatusEnum flowStatus = tbCrmDetailService.findById(
-                Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null);
-        if (Objects.nonNull(flowStatus) && (flowStatus == FlowStatusEnum.FINISH || flowStatus == FlowStatusEnum.END)) {
-            throw ExceptionResultEnum.ERROR.exception("流程已结束,无法分配人员");
-        }
-        Task task = taskService.createTaskQuery().processInstanceId(sopAllocationParam.getFlowId().toString())
-                .singleResult();
-        Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
+        Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(tfCustomFlowEntity.getFlowId());
+        Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
-        List<AllocationParam> allocationParamList = sopAllocationParam.getAllocationParams();
-        if (!CollectionUtils.isEmpty(allocationParamList)) {
-            for (AllocationParam a : allocationParamList) {
-                if (a.getSopRoleType() == SopRoleTypeEnum.PROJECT_MANAGER) {
-                    activitiService.taskApproverExchange(a.getUserIdList().get(0), Long.parseLong(task.getId()));
-                } else if (a.getSopRoleType() == SopRoleTypeEnum.ENGINEER) {
-                    //修改流程one里面的工程师
-                    List<String> engineerUserIdList = a.getUserIdList().stream().map(s -> s.toString())
-                            .collect(Collectors.toList());
-                    tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId(),
-                            engineerUserIdList);
-                }
-            }
-            tbUserArchivesAllocationService.editCrmAllocation(new UserArchivesAllocationParam(sopAllocationParam));
+        if (Objects.nonNull(tfFlowApprove.getStatus()) && (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH
+                || tfFlowApprove.getStatus() == FlowStatusEnum.END)) {
+            throw ExceptionResultEnum.ERROR.exception("流程已结束,无法分配人员");
         }
+        TFCustomFlow tfCustomFlow = tfCustomFlowService.findById(tfCustomFlowEntity.gettFCustomFlowId());
+        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+        tbSopInfoService.updateFlowInfo(sopAllocationParam.getAllocationParams(), tfCustomFlow, tfCustomFlowEntity,
+                tfFlowApprove, tbCrmDetail);
+        tbUserArchivesAllocationService.editCrmAllocation(new UserArchivesAllocationParam(sopAllocationParam));
         return true;
     }
 
@@ -619,6 +599,57 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         return false;
     }
 
+    /**
+     * 更新流程信息
+     *
+     * @param allocationParamList
+     * @param tfCustomFlow
+     * @param tfCustomFlowEntity
+     * @param tfFlowApprove
+     * @param tbCrmDetail
+     * @return
+     * @throws InterruptedException
+     */
+    @Override
+    @Transactional
+    public Boolean updateFlowInfo(List<AllocationParam> allocationParamList, TFCustomFlow tfCustomFlow,
+            TFCustomFlowEntity tfCustomFlowEntity, TFFlowApprove tfFlowApprove, TBCrmDetail tbCrmDetail)
+            throws InterruptedException {
+        List<Task> taskList = taskService.createTaskQuery().processInstanceId(tfCustomFlowEntity.getFlowId().toString())
+                .list();
+        if (CollectionUtils.isEmpty(taskList)) {
+            throw ExceptionResultEnum.FLOW_TASK_NO_DATA.exception();
+        }
+        if (!CollectionUtils.isEmpty(allocationParamList)) {
+            for (AllocationParam a : allocationParamList) {
+                if (a.getSopRoleType() == SopRoleTypeEnum.PROJECT_MANAGER) {
+                    if (taskList.size() == 1) {
+                        activitiService.taskApproverExchange(a.getUserIdList().get(0),
+                                Long.parseLong(taskList.get(0).getId()));
+                    } else {
+                        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(
+                                tfCustomFlowEntity.getCode(), tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
+                        List<Task> taskTempList = taskList.stream().filter(s -> Objects.equals(s.getAssignee(),
+                                        crmProjectResult.getProjectManagerList().get(0).getUserId().toString()))
+                                .collect(Collectors.toList());
+                        if (CollectionUtils.isEmpty(taskTempList)) {
+                            throw ExceptionResultEnum.FLOW_TASK_NO_DATA.exception();
+                        }
+                        activitiService.taskApproverExchange(a.getUserIdList().get(0),
+                                Long.parseLong(taskTempList.get(0).getId()));
+                    }
+                } else if (a.getSopRoleType() == SopRoleTypeEnum.ENGINEER) {
+                    //修改流程one里面的工程师
+                    List<String> engineerUserIdList = a.getUserIdList().stream().map(s -> s.toString())
+                            .collect(Collectors.toList());
+                    tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId(),
+                            engineerUserIdList);
+                }
+            }
+        }
+        return true;
+    }
+
     /**
      * sop填报信息
      *
@@ -723,9 +754,78 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                         SopStatusEnum.START);
         tbSopInfo.updateInfo(sysUser.getId());
         tbSopInfoService.updateById(tbSopInfo);
+
+        //研究生流程,如果下一步审批是大区经理内审并且项目经理和大区经理为同一人时,后台自动审批
+        tbSopInfoService.sopSystemApprove(tfCustomFlow, tfCustomFlowEntity, tfFlowApprove, crmProjectResult,
+                flowApproveParam.getCrmNo(), tbCrmDetail.getId());
         return true;
     }
 
+    /**
+     * sop自动审批
+     *
+     * @param tfCustomFlow
+     * @param tfCustomFlowEntity
+     * @param tfFlowApprove
+     * @param crmProjectResult
+     * @param crmNo
+     * @param crmDetailId
+     * @throws InterruptedException
+     */
+    @Override
+    @Transactional
+    public void sopSystemApprove(TFCustomFlow tfCustomFlow, TFCustomFlowEntity tfCustomFlowEntity,
+            TFFlowApprove tfFlowApprove, CrmProjectResult crmProjectResult, String crmNo, Long crmDetailId)
+            throws InterruptedException {
+        //如果下一步审批是内审并且项目经理和大区经理为同一人时,后台自动审批
+        if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW
+                && tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END
+                && tfFlowApprove.getStatus() == FlowStatusEnum.AUDITING && tfFlowApprove.getSetup().intValue() == 3
+                && crmProjectResult.getRegionManagerId().longValue() == crmProjectResult.getProjectManagerList().get(0)
+                .getUserId().longValue()) {
+            List<Task> taskList = taskService.createTaskQuery()
+                    .processInstanceId(String.valueOf(tfFlowApprove.getFlowId()))
+                    .taskAssignee(String.valueOf(crmProjectResult.getRegionManagerId())).list();
+            if (!CollectionUtils.isEmpty(taskList) && taskList.size() == 2) {
+                Task taskNew = taskList.get(0);
+                FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(),
+                        FlowResult.class);
+                LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+                FlowTaskResult nextFlowTaskResult = null;
+                for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
+                    if (entry.getValue().getSetup().intValue() == 3) {
+                        nextFlowTaskResult = entry.getValue();
+                        break;
+                    }
+                }
+
+                if (Objects.nonNull(nextFlowTaskResult)) {
+                    List<FlowFormWidgetResult> flowFormWidgetResultList = nextFlowTaskResult.getFormProperty();
+                    for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+                        if (f.getFormId().contains(SystemConstant.APPROVE_RADIO_REGION)) {
+                            JSONObject jsonObject = new JSONObject();
+                            jsonObject.put("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);
+                            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");
+                            f.setValue(jsonObject.toString());
+                        }
+                    }
+                }
+                activitiService.taskApprove(
+                        new FlowApproveParam(Long.parseLong(taskNew.getId()), FlowApprovePassEnum.PASS,
+                                this.getNextApproveUserIds(tfCustomFlow.getType(), nextFlowTaskResult,
+                                        nextFlowTaskResult, crmProjectResult, crmDetailId), crmNo,
+                                SystemConstant.SYSTEM_AUTO_APPROVE, JacksonUtil.parseJson(nextFlowTaskResult)));
+            }
+        }
+    }
+
     /**
      * sop管理列表
      *
@@ -929,7 +1029,6 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 sopInfoListParam.getCustomName(), sopInfoListParam.getTaskKey(), sopInfoListParam.getCrmName(),
                 sopInfoListParam.getSopNo(),
                 Objects.nonNull(sopInfoListParam.getDingPlan()) ? sopInfoListParam.getDingPlan().toString() : null);
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         for (Map m : list.getRecords()) {
             String engineerUsersId = (String) m.get("engineer_users_id_1");
             List<Long> userIdList = new ArrayList<>();
@@ -1077,14 +1176,6 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             if (currFlowTaskResult.getSetup().intValue() == 1) {
                 approveUserIds = Arrays.asList(String.valueOf(crmProjectResult.getRegionManagerId()));
             } else if (currFlowTaskResult.getSetup().intValue() == 2) {
-                //                TBCrmDetail tbCrmDetail = tbCrmDetailService.getById(crmDetailId);
-                //                Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
-                //                TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByCode(tbCrmDetail.getSopNo());
-                //                Optional.ofNullable(tfCustomFlowEntity)
-                //                        .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
-                //
-                //                List<Task> taskList = taskService.createTaskQuery()
-                //                        .processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).list();
                 approveUserIds = crmProjectResult.getProjectManagerList().stream()
                         .map(s -> String.valueOf(s.getUserId())).collect(Collectors.toList());
                 approveUserIds.add(String.valueOf(crmProjectResult.getRegionManagerId()));

+ 13 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TFFlowLogServiceImpl.java

@@ -72,6 +72,19 @@ public class TFFlowLogServiceImpl extends ServiceImpl<TFFlowLogMapper, TFFlowLog
         return this.baseMapper.findByLastFlowLog(flowId);
     }
 
+    /**
+     * 查询最后一条日志审批记录(带审批状态)
+     *
+     * @param flowId
+     * @param approveOperation
+     * @return
+     */
+    @Override
+    public TFFlowLog findByLastFlowLog(Long flowId, FlowApproveOperationEnum approveOperation) {
+        return this.baseMapper.findByLastFlowApproveOperationLog(flowId,
+                Objects.nonNull(approveOperation) ? approveOperation.name() : null);
+    }
+
     /**
      * 查询最后一条日志审批记录
      *

+ 10 - 0
sop-business/src/main/resources/mapper/TFFlowLogMapper.xml

@@ -62,6 +62,16 @@
         select * from t_f_flow_log tffl where tffl.flow_id = #{flowId} order by tffl.create_time desc limit 1
     </select>
 
+    <select id="findByLastFlowApproveOperationLog" resultType="com.qmth.sop.business.entity.TFFlowLog">
+        select * from t_f_flow_log tffl
+        <where>
+            tffl.flow_id = #{flowId}
+            <if test="approveOperation != null and approveOperation != ''">
+                and tffl.approve_operation = #{approveOperation}
+            </if>
+        </where> order by tffl.create_time desc limit 1
+    </select>
+
     <select id="findByLastFlowLogApproveUser" resultType="java.lang.String">
         select group_concat(tffl.approve_id) from t_f_flow_log tffl where tffl.flow_id = #{flowId} and tffl.approve_setup > 1
     </select>

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

@@ -144,9 +144,9 @@ public class SystemConstant {
 //    public static final String ENGINEER_USER_ID = "engineer_user_id";
 //    public static final String ASSISTANT_ENGINEER_USER_ID = "assistant_engineer_user_id";
 //    public static final String ENGINEER_USERS_ID = "engineer_users_id";
-//    public static final String APPROVE_RADIO_REGION = "approve_radio_region";
-//    public static final String APPROVE_REMARK_REGION = "approve_remark_region";
-//    public static final String SIGN_REGION = "sign_region";
+    public static final String APPROVE_RADIO_REGION = "approve_radio_region";
+    public static final String APPROVE_REMARK_REGION = "approve_remark_region";
+    public static final String SIGN_REGION = "sign_region";
 //    public static final String THIRD_SERVICE_REGION_CB = "third_service_region_cb";
 
     public static final String DEVICE_OUT_TIME = "device_out_time";//设备出库时间