Prechádzať zdrojové kódy

自定义流程接口-转审修复

wangliang 3 rokov pred
rodič
commit
a4297875d3

+ 27 - 16
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -714,44 +714,56 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Override
     @Transactional
     public boolean taskApproverExchange(String userId, String taskId) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        if (Objects.equals(String.valueOf(sysUser.getId()), userId)) {
+            throw ExceptionResultEnum.ERROR.exception("不能转给自己");
+        }
         Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
         Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
         String flowId = task.getProcessInstanceId();
-        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), Long.parseLong((String) ServletUtil.getRequestHeaderSchoolId()));
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), sysUser.getSchoolId());
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到流程状态记录"));
         if (tfFlowApprove.getSetup() <= 0) {
             throw ExceptionResultEnum.ERROR.exception("流程已结束或已终止");
         }
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        if (Objects.nonNull(task) && Objects.nonNull(task.getAssignee()) && Objects.equals(task.getAssignee(), userId)) {
-            throw ExceptionResultEnum.ERROR.exception("不能转给自己");
-        }
-        Task taskUser = taskService.createTaskQuery().taskId(taskId).taskCandidateOrAssigned(userId).singleResult();
-        if (Objects.nonNull(taskUser)) {
-            throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
+
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(tfFlowApprove.getFlowId());
+        Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
+        Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
+        if (Objects.nonNull(tfFlowApprove.getTransferAssignee())) {
+            agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
         }
 
         //获取当前流程节点
         String currActivityId = task.getTaskDefinitionKey();
         BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
         FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
+
         UserTask userTask = null;
         if (currFlow instanceof UserTask) {
             userTask = (UserTask) currFlow;
         }
+
+        Gson gson = new Gson();
         Integer nrOfCompletedInstances = null, nrOfInstances = null;
         boolean multiInstance = false;
-        if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {
+        if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {//会签
             nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_COMPLETED_INSTANCES);
             nrOfInstances = (Integer) taskService.getVariable(task.getId(), DefaultInstanceConvertToMultiInstance.NR_OF_INSTANCES);
             multiInstance = true;
-        }
 
-        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(tfFlowApprove.getFlowId());
-        Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
-        Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
-        if (Objects.nonNull(tfFlowApprove.getTransferAssignee())) {
-            agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
+            CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
+            if (Objects.nonNull(customFlowVarDto)) {
+                List<String> approveIds = customFlowVarDto.getApproveIds();
+                if (Objects.nonNull(approveIds) && approveIds.size() > 0 && approveIds.contains(userId)) {
+                    throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
+                }
+            }
+        } else {//或签
+            Task taskUser = taskService.createTaskQuery().taskId(taskId).taskCandidateOrAssigned(userId).singleResult();
+            if (Objects.nonNull(taskUser)) {
+                throw ExceptionResultEnum.ERROR.exception("该审批人已有审批权限,无需流转");
+            }
         }
 
         ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
@@ -761,7 +773,6 @@ public class ActivitiServiceImpl implements ActivitiService {
 
         //流程流水日志
         TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()), tfFlowJoin.getObjectTable());
-        Gson gson = new Gson();
         CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
         if (customFlowVarDto.getApproveIds().size() == 1) {
             customFlowVarDto.setApproveIds(new ArrayList<>(Arrays.asList(userId)));

+ 15 - 15
distributed-print/src/main/java/com/qmth/distributed/print/api/TFCustomFlowController.java

@@ -145,20 +145,20 @@ public class TFCustomFlowController {
         return ResultUtil.ok(true);
     }
 
-    @ApiOperation(value = "测试启动流程")
-    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
-    @RequestMapping(value = "/testStart", method = RequestMethod.POST)
-    @Transactional
-    public Result testStart(@ApiParam(value = "实体id", required = true) @RequestParam String objectId,
-                            @ApiParam(value = "命题老师id", required = true) @RequestParam String approveId,
-                            @ApiParam(value = "实体表", required = true) @RequestParam TFCustomTypeEnum flowType) {
-        Map<String, Object> map = new HashMap<>();
-        map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> SystemConstant.convertIdToLong(objectId));
-        map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> SystemConstant.convertIdToLong(approveId));
-        map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> flowType);
-        activitiService.customFlowStart(map);
-        return ResultUtil.ok(true);
-    }
+//    @ApiOperation(value = "测试启动流程")
+//    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
+//    @RequestMapping(value = "/testStart", method = RequestMethod.POST)
+//    @Transactional
+//    public Result testStart(@ApiParam(value = "实体id", required = true) @RequestParam String objectId,
+//                            @ApiParam(value = "命题老师id", required = true) @RequestParam String approveId,
+//                            @ApiParam(value = "实体表", required = true) @RequestParam TFCustomTypeEnum flowType) {
+//        Map<String, Object> map = new HashMap<>();
+//        map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> SystemConstant.convertIdToLong(objectId));
+//        map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> SystemConstant.convertIdToLong(approveId));
+//        map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> flowType);
+//        activitiService.customFlowStart(map);
+//        return ResultUtil.ok(true);
+//    }
 
     @ApiOperation(value = "审批流程")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
@@ -207,7 +207,7 @@ public class TFCustomFlowController {
                        @ApiParam(value = "页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
                        @ApiParam(value = "数量", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        return ResultUtil.ok(tfCustomFlowService.list(new Page<>(pageNumber, pageSize), name, SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId()));
+        return ResultUtil.ok(tfCustomFlowService.list(new Page<>(pageNumber, pageSize), name, SystemConstant.getHeadOrUserSchoolId(), null));
     }
 
     @ApiOperation(value = "流程编辑")