Просмотр исходного кода

研究生流程人员各种时间修改

wangliang 10 месяцев назад
Родитель
Сommit
8190576b49

+ 10 - 36
sop-api/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -6,11 +6,13 @@ 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.*;
-import com.qmth.sop.business.service.*;
+import com.qmth.sop.business.entity.SysUser;
+import com.qmth.sop.business.entity.TBSopInfo;
+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.common.annotation.OperationLog;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
@@ -27,8 +29,6 @@ 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>
@@ -52,21 +52,6 @@ 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) })
@@ -133,21 +118,7 @@ public class TBSopInfoController {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
         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());
-        }
+        tbSopInfoService.sopProxySystemApprove(sopAllocationParam.getFlowId(), null);
         return ResultUtil.ok(result);
     }
 
@@ -190,7 +161,10 @@ public class TBSopInfoController {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        return ResultUtil.ok(tbSopInfoService.sopSave(sopSaveParam));
+        Boolean result = tbSopInfoService.sopSave(sopSaveParam);
+        TBSopInfo tbSopInfo = tbSopInfoService.getById(sopSaveParam.getId());
+        tbSopInfoService.sopProxySystemApprove(null, tbSopInfo.getSopNo());
+        return ResultUtil.ok(result);
     }
 
     @ApiOperation(value = "sopUsers")

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

@@ -83,6 +83,14 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
             TFFlowApprove tfFlowApprove, CrmProjectResult crmProjectResult, String crmNo, Long crmDetailId)
             throws InterruptedException;
 
+    /**
+     * 代理自动审批
+     *
+     * @param flowId
+     * @param sopNo
+     */
+    public void sopProxySystemApprove(Long flowId, String sopNo) throws InterruptedException;
+
     /**
      * sop管理列表
      *

+ 133 - 20
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -744,20 +744,66 @@ 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());
+        if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+            if (flowTaskResult.getSetup().intValue() == 2) {
+                List<FlowFormWidgetResult> flowFormWidgetResultList = flowTaskResult.getFormProperty();
+                for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+                    if (f.getFormId().contains(ProcessLimitedEnum.SCAN_START_TIME.getKey()) && Objects.nonNull(
+                            f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+                        JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                        String value = jsonObject.getString(SystemConstant.VALUE);
+                        tbCrmDetail.setScanStartTime(Long.parseLong(value));
+                    } else if (f.getFormId().contains(ProcessLimitedEnum.SCAN_END_TIME.getKey()) && Objects.nonNull(
+                            f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+                        JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                        String value = jsonObject.getString(SystemConstant.VALUE);
+                        tbCrmDetail.setScanEndTime(Long.parseLong(value));
+                        if (Objects.nonNull(tbCrmDetail.getScanStartTime())
+                                && tbCrmDetail.getScanEndTime().longValue() <= tbCrmDetail.getScanStartTime()
+                                .longValue()) {
+                            throw ExceptionResultEnum.ERROR.exception("扫描结束时间不能小于等于扫描开始时间");
+                        }
+                    } else if (f.getFormId().contains(ProcessLimitedEnum.MARK_START_TIME.getKey()) && Objects.nonNull(
+                            f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+                        JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                        String value = jsonObject.getString(SystemConstant.VALUE);
+                        tbCrmDetail.setMarkPaperStartTime(Long.parseLong(value));
+                        if (Objects.nonNull(tbCrmDetail.getScanEndTime())
+                                && tbCrmDetail.getMarkPaperStartTime().longValue() <= tbCrmDetail.getScanEndTime()
+                                .longValue()) {
+                            throw ExceptionResultEnum.ERROR.exception("阅卷开始时间不能小于等于扫描结束时间");
+                        }
+                    } else if (f.getFormId().contains(ProcessLimitedEnum.MARK_END_TIME.getKey()) && Objects.nonNull(
+                            f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+                        JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                        String value = jsonObject.getString(SystemConstant.VALUE);
+                        tbCrmDetail.setMarkPaperEndTime(Long.parseLong(value));
+                        if (Objects.nonNull(tbCrmDetail.getMarkPaperStartTime())
+                                && tbCrmDetail.getMarkPaperEndTime().longValue() <= tbCrmDetail.getMarkPaperStartTime()
+                                .longValue()) {
+                            throw ExceptionResultEnum.ERROR.exception("阅卷结束时间不能小于等于阅卷开始时间");
+                        }
+                    }
+                    tbCrmDetail.updateInfo(sysUser.getId());
+                    tbCrmDetailService.updateById(tbCrmDetail);
                 }
+            } else 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));
             }
-            flowTaskResult.setFormProperty(flowFormWidgetResultList);
-            flowApproveParam.setFormProperties(JacksonUtil.parseJson(flowTaskResult));
         }
 
         String oldFlowProcessVar = tfCustomFlowEntity.getFlowProcessVar();
@@ -856,6 +902,39 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         }
     }
 
+    /**
+     * 代理自动审批
+     *
+     * @param flowId
+     * @param sopNo
+     */
+    @Override
+    @Transactional
+    public void sopProxySystemApprove(Long flowId, String sopNo) throws InterruptedException {
+        TFCustomFlowEntity tfCustomFlowEntity = Objects.nonNull(flowId) ?
+                tfCustomFlowEntityService.findByFlowId(flowId) :
+                tfCustomFlowEntityService.findByCode(sopNo);
+        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());
+
+            if (Objects.nonNull(tfFlowApprove.getStatus()) && (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH
+                    || tfFlowApprove.getStatus() == FlowStatusEnum.END)) {
+                throw ExceptionResultEnum.ERROR.exception("流程已结束,无法自动审批");
+            }
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
+                    tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
+            tbSopInfoService.sopSystemApprove(tfCustomFlow, tfCustomFlowEntity, tfFlowApprove, crmProjectResult,
+                    tbCrmDetail.getCrmNo(), tbCrmDetail.getId());
+        }
+    }
+
     /**
      * sop管理列表
      *
@@ -1265,13 +1344,12 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                             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(),
                         tfCustomFlow.getType());
             } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop
-
+                FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
+                tbSopInfoService.saveSopPlanDate(flowTaskResult, sopId, tfCustomFlowEntity.getFlowId(), sysUser.getId(),
+                        tfCustomFlow.getType());
             }
             if (Objects.nonNull(execField)) {
                 for (Task task : taskList) {
@@ -1415,8 +1493,13 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
         Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
 
-        List<Long> enginessUserIds = new ArrayList<>();
-        FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
+        List<Long> enginessUserIds = new ArrayList<>(), regionCoordinatorUserIds = new ArrayList<>(), projectManagerUserIds = new ArrayList<>();
+        FlowTaskResult flowTaskResult = null;
+        if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {
+            flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
+        } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+            flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
+        }
         List<FlowFormWidgetResult> flowFormWidgetResultList = flowTaskResult.getFormProperty();
         for (FlowFormWidgetResult f : flowFormWidgetResultList) {
             if (f.getFormId().contains(ProcessLimitedEnum.SCAN_START_TIME.getKey()) && Objects.nonNull(f.getValue())
@@ -1460,6 +1543,16 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 for (int i = 0; i < jsonArray.size(); i++) {
                     enginessUserIds.add(Long.parseLong(jsonArray.getString(i)));
                 }
+            } else if (f.getFormId().contains(ProcessLimitedEnum.REGION_COORDINATOR_ID.getKey()) && Objects.nonNull(
+                    f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                String value = jsonObject.getString(SystemConstant.VALUE);
+                regionCoordinatorUserIds.add(Long.parseLong(value));
+            } else if (f.getFormId().contains(ProcessLimitedEnum.PROJECT_MANAGER_ID.getKey()) && Objects.nonNull(
+                    f.getValue()) && !Objects.equals(f.getValue(), "{\"value\":null}")) {
+                JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                String value = jsonObject.getString(SystemConstant.VALUE);
+                projectManagerUserIds.add(Long.parseLong(value));
             }
         }
         if (tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END) {
@@ -1481,8 +1574,11 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             map.put(SystemConstant.SOP_ID, tbSopInfo.getId());
             map.put(SystemConstant.SOURCE, "save");
             tbSopInfoService.saveJobRemind(map);
-            tbSopInfoService.saveSopPlanDate(flowTaskResult, tbSopInfo.getId(), tfCustomFlowEntity.getFlowId(),
-                    sysUser.getId(), tfCustomFlow.getType());
+
+            if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+                tbSopInfoService.saveSopPlanDate(this.getFormProperties(tfCustomFlowEntity, 1), tbSopInfo.getId(),
+                        tfCustomFlowEntity.getFlowId(), sysUser.getId(), tfCustomFlow.getType());
+            }
 
             //新增sop日志
             if (!Objects.equals(oldFlowProcessVar, tfCustomFlowEntity.getFlowProcessVar())) {
@@ -1524,6 +1620,23 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                     tbUserArchivesAllocationService.editCrmAllocation(
                             new UserArchivesAllocationParam(allocationParams, tbCrmDetail.getId()));
                 }
+            } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+                List<AllocationParam> allocationParams = new ArrayList<>();
+                if (!CollectionUtils.isEmpty(projectManagerUserIds)) {
+                    allocationParams.add(
+                            new AllocationParam(SopRoleTypeEnum.PROJECT_MANAGER, projectManagerUserIds, "[系统]"));
+                    tbSopInfoService.sopApproverExchange(tbCrmDetail.getId(), new SopAllocationParam(
+                            new UserArchivesAllocationParam(allocationParams, tbCrmDetail.getId())));
+                }
+                if (!CollectionUtils.isEmpty(enginessUserIds)) {
+                    allocationParams.add(new AllocationParam(SopRoleTypeEnum.ENGINEER, enginessUserIds, "[系统]"));
+                }
+                if (!CollectionUtils.isEmpty(regionCoordinatorUserIds)) {
+                    allocationParams.add(
+                            new AllocationParam(SopRoleTypeEnum.REGION_COORDINATOR, regionCoordinatorUserIds, "[系统]"));
+                }
+                tbUserArchivesAllocationService.editCrmAllocation(
+                        new UserArchivesAllocationParam(allocationParams, tbCrmDetail.getId()));
             }
         }
         if (!tbDingSubmitService.canUpdateDingSetting(tbSopInfo.getSopNo())) {