Selaa lähdekoodia

研究生内审修改

wangliang 10 kuukautta sitten
vanhempi
commit
92f575b599

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

@@ -122,7 +122,7 @@ public class ActivitiServiceImpl implements ActivitiService {
     TSJobRemindService tsJobRemindService;
 
     @Resource
-    TBDeviceDeliveryService tbDeviceDeliveryService;
+    SysUserRoleService sysUserRoleService;
 
     @Resource
     TBCrmDetailService tbCrmDetailService;
@@ -133,6 +133,9 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Resource
     ActivitiService activitiService;
 
+    @Resource
+    TBUserArchivesService tbUserArchivesService;
+
     /**
      * 根据deploymentId查找processDefinitionId
      *
@@ -825,17 +828,17 @@ public class ActivitiServiceImpl implements ActivitiService {
             TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(flowId);
             TFCustomFlow tfCustomFlow = tfCustomFlowService.findById(tfCustomFlowEntity.gettFCustomFlowId());
 
-            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW && tfFlowApprove.getSetup().intValue() >= 4
-                    && tfFlowApprove.getSetup().intValue() < 8) {
-                FlowTaskResult flowTaskResultDeviceOut = tbSopInfoService.getFormProperties(tfCustomFlowEntity, 4);
-                tbDeviceDeliveryService.updateDeviceRelated(flowTaskResultDeviceOut, tfCustomFlowEntity.getCode(), null,
-                        sysUser.getId(), false);
-            } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW
-                    && tfFlowApprove.getSetup().intValue() >= 4) {
-                FlowTaskResult flowTaskResultDeviceOut = tbSopInfoService.getFormProperties(tfCustomFlowEntity, 4);
-                tbDeviceDeliveryService.updateDeviceRelated(flowTaskResultDeviceOut, tfCustomFlowEntity.getCode(),
-                        DeviceDeliveryStatusEnum.RECEIVE, sysUser.getId(), true);
-            }
+            //            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW && tfFlowApprove.getSetup().intValue() >= 4
+            //                    && tfFlowApprove.getSetup().intValue() < 8) {
+            //                FlowTaskResult flowTaskResultDeviceOut = tbSopInfoService.getFormProperties(tfCustomFlowEntity, 4);
+            //                tbDeviceDeliveryService.updateDeviceRelated(flowTaskResultDeviceOut, tfCustomFlowEntity.getCode(), null,
+            //                        sysUser.getId(), false);
+            //            } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW
+            //                    && tfFlowApprove.getSetup().intValue() >= 4) {
+            //                FlowTaskResult flowTaskResultDeviceOut = tbSopInfoService.getFormProperties(tfCustomFlowEntity, 4);
+            //                tbDeviceDeliveryService.updateDeviceRelated(flowTaskResultDeviceOut, tfCustomFlowEntity.getCode(),
+            //                        DeviceDeliveryStatusEnum.RECEIVE, sysUser.getId(), true);
+            //            }
 
             FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
             LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
@@ -1007,13 +1010,6 @@ public class ActivitiServiceImpl implements ActivitiService {
                 }
             }
         }
-        if (tfCustomFlow.getType() == TFCustomTypeEnum.QUALITY_PROBLEM_FLOW && Objects.nonNull(currFlowTaskResult) && (
-                currFlowTaskResult.getSetup().intValue() == 3 || currFlowTaskResult.getSetup().intValue() == 4)) {
-            List<FlowFormWidgetResult> flowFormWidgetResultList = currFlowTaskResult.getFormProperty();
-            for (FlowFormWidgetResult f : flowFormWidgetResultList) {
-                f.setValue(null);
-            }
-        }
 
         CrmProjectResult crmProjectResult = null;
         if (Objects.nonNull(tfCustomFlowEntity.getCrmNo())) {
@@ -1022,6 +1018,82 @@ public class ActivitiServiceImpl implements ActivitiService {
                     Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getSopNo() : null,
                     Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null, tfCustomFlowEntity.getCrmNo());
         }
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+            if (Objects.nonNull(currFlowTaskResult) && currFlowTaskResult.getSetup().intValue() == 3) {
+                List<Task> taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).list();
+                List<FlowFormWidgetResult> flowFormWidgetResultListNew = new ArrayList<>();
+                if (!CollectionUtils.isEmpty(taskList) && taskList.size() > 1) {
+                    SopRoleTypeCompositeEnum sopRoleTypeCompositeEnum = null;
+                    jump:
+                    for (Task task : taskList) {
+                        if (task.getAssignee().equals(sysUser.getId().toString())) {
+                            if (Objects.equals(crmProjectResult.getRegionManagerId().toString(),
+                                    task.getAssignee())) {//大区经理
+                                sopRoleTypeCompositeEnum = SopRoleTypeCompositeEnum.REGION_MANAGER;
+                            } else if (Objects.equals(
+                                    crmProjectResult.getProjectManagerList().get(0).getUserId().toString(),
+                                    task.getAssignee())) {
+                                sopRoleTypeCompositeEnum = SopRoleTypeCompositeEnum.PROJECT_MANAGER;
+                            }
+                        }
+                    }
+                    List<FlowFormWidgetResult> flowFormWidgetResultList = currFlowTaskResult.getFormProperty();
+                    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);
+                            }
+                            flowFormWidgetResultListNew.add(f);
+                        }
+                    }
+                } else if (!CollectionUtils.isEmpty(taskList) && taskList.size() == 1) {
+                    SopRoleTypeCompositeEnum sopRoleTypeCompositeEnum = null;
+                    jump:
+                    for (Task task : taskList) {
+                        if (task.getAssignee().equals(sysUser.getId().toString())) {
+                            if (Objects.equals(crmProjectResult.getRegionManagerId().toString(),
+                                    task.getAssignee())) {//大区经理
+                                sopRoleTypeCompositeEnum = SopRoleTypeCompositeEnum.REGION_MANAGER;
+                            } else if (Objects.equals(
+                                    crmProjectResult.getProjectManagerList().get(0).getUserId().toString(),
+                                    task.getAssignee())) {
+                                sopRoleTypeCompositeEnum = SopRoleTypeCompositeEnum.PROJECT_MANAGER;
+                            }
+                        }
+                    }
+                    List<FlowFormWidgetResult> flowFormWidgetResultList = currFlowTaskResult.getFormProperty();
+                    for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+                        if (Objects.nonNull(sopRoleTypeCompositeEnum) && !Objects.equals(f.getRoleType(),
+                                sopRoleTypeCompositeEnum.name())) {
+                            f.setReadable(true);
+                            f.setWritable(false);
+                        }
+                        flowFormWidgetResultListNew.add(f);
+                    }
+                }
+                if (!CollectionUtils.isEmpty(flowFormWidgetResultListNew)) {
+                    currFlowTaskResult.setFormProperty(flowFormWidgetResultListNew);
+                }
+            }
+        } else if (tfCustomFlow.getType() == TFCustomTypeEnum.QUALITY_PROBLEM_FLOW && Objects.nonNull(
+                currFlowTaskResult) && (currFlowTaskResult.getSetup().intValue() == 3
+                || currFlowTaskResult.getSetup().intValue() == 4)) {
+            List<FlowFormWidgetResult> flowFormWidgetResultList = currFlowTaskResult.getFormProperty();
+            for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+                f.setValue(null);
+            }
+        }
         return new FlowViewResult(flowId, tfFlowApprove.getStatus(), tfCustomFlowEntity.getCode(), taskIdList,
                 flowTaskHistoryList, currFlowTaskResult, flowApproveHistoryList, crmProjectResult,
                 flowFormSuggestionJiaResultList, flowFormSuggestionYiResultList);

+ 37 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -671,6 +671,8 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
+        FlowTaskResult flowTaskResult = JSONObject.parseObject(flowApproveParam.getFormProperties(),
+                FlowTaskResult.class);
         if (flowApproveParam.getApprove() == FlowApprovePassEnum.PASS
                 || flowApproveParam.getApprove() == FlowApprovePassEnum.START) {
             FlowTaskResult flowTaskResultOne = this.getFormProperties(tfCustomFlowEntity, 1);
@@ -681,6 +683,22 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             flowApproveParam.setApproveUserIds(approveUserIds);
         }
 
+        if (flowTaskResult.getSetup().intValue() == 3) {//内审时要set全部值
+            FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+            FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(
+                    GsonUtil.toJson(flowResult.getSetupMap().get(flowTaskResult.getTaskKey())), FlowTaskResult.class);
+            List<FlowFormWidgetResult> flowFormWidgetResultList = currFlowTaskResult.getFormProperty();
+            Map<String, FlowFormWidgetResult> flowTaskResultMap = flowTaskResult.getFormProperty().stream().collect(
+                    Collectors.toMap(FlowFormWidgetResult::getFormId, Function.identity(), (dto1, dto2) -> dto1));
+            for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+                if (flowTaskResultMap.containsKey(f.getFormId())) {
+                    f.setValue(flowTaskResultMap.get(f.getFormId()).getValue());
+                }
+            }
+            flowTaskResult.setFormProperty(flowFormWidgetResultList);
+            flowApproveParam.setFormProperties(JacksonUtil.parseJson(flowTaskResult));
+        }
+
         String oldFlowProcessVar = tfCustomFlowEntity.getFlowProcessVar();
         Map<String, Object> map = activitiService.taskApprove(flowApproveParam);
         if (flowApproveParam.getApprove() != FlowApprovePassEnum.DRAFT) {
@@ -1000,8 +1018,8 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     public List<String> getNextApproveUserIds(TFCustomTypeEnum type, FlowTaskResult flowTaskResult,
             FlowTaskResult currFlowTaskResult, CrmProjectResult crmProjectResult, Long crmDetailId) {
         List<String> approveUserIds = new ArrayList<>();
-        ServiceScopeEnum scopeEnum = tbSopInfoService.findServiceScope(type, flowTaskResult);
         if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
+            ServiceScopeEnum scopeEnum = tbSopInfoService.findServiceScope(type, flowTaskResult);
             if (Objects.nonNull(scopeEnum) && scopeEnum == ServiceScopeEnum.SCAN_MARK) {//扫描+阅卷,12345是项目经理
                 for (UserArchivesDto u : crmProjectResult.getProjectManagerList()) {
                     approveUserIds.add(u.getUserId().toString());
@@ -1056,7 +1074,24 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 }
             }
         } else if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop流程待审核人
-
+            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()));
+            } else {
+                approveUserIds = crmProjectResult.getProjectManagerList().stream()
+                        .map(s -> String.valueOf(s.getUserId())).collect(Collectors.toList());
+            }
         }
         return approveUserIds;
     }
@@ -1517,8 +1552,6 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                     break;
                 }
             }
-        } else if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop流程待审核人
-
         }
         return scopeEnum;
     }

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

@@ -144,10 +144,10 @@ 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 THIRD_SERVICE_REGION_CB = "third_service_region_cb";
+//    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";//设备出库时间
     public static final String DEVICE_OUT_TABLE = "device_out_table";//设备出库