Pārlūkot izejas kodu

自定义流程接口新增

wangliang 3 gadi atpakaļ
vecāks
revīzija
c3b327e0be

+ 9 - 55
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -28,11 +28,9 @@ import org.activiti.engine.HistoryService;
 import org.activiti.engine.RepositoryService;
 import org.activiti.engine.RuntimeService;
 import org.activiti.engine.TaskService;
-import org.activiti.engine.impl.RepositoryServiceImpl;
 import org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior;
 import org.activiti.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
 import org.activiti.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
-import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
 import org.activiti.engine.repository.Deployment;
 import org.activiti.engine.repository.DeploymentBuilder;
 import org.activiti.engine.runtime.ProcessInstance;
@@ -263,14 +261,11 @@ public class ActivitiServiceImpl implements ActivitiService {
             throw ExceptionResultEnum.ERROR.exception("正在终止中,请稍候再试!");
         }
         try {
-            Task task = taskService.createTaskQuery().processInstanceId(flowId).singleResult();
             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-//            runtimeService.deleteProcessInstance(flowId, FlowApproveSetupEnum.END.getTitle());
             ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
             //流程审批
             TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), examTask.getSchoolId());
             if (Objects.isNull(tfFlowApprove)) {
-                int count = sysUserService.countByTeachingRoomId(examTask.getTeachingRoomId());
                 tfFlowApprove = new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), FlowStatusEnum.END, sysUser.getId());
             } else {
                 tfFlowApprove.setStatus(FlowStatusEnum.END);
@@ -285,18 +280,6 @@ public class ActivitiServiceImpl implements ActivitiService {
             tfFlowLog.setApproveSetup(FlowApproveSetupEnum.END.getSetup());
             tfFlowLogService.save(tfFlowLog);
 
-            if (Objects.nonNull(task)) {
-                String processDefinitionId = historyService.createHistoricProcessInstanceQuery().processInstanceId(flowId).singleResult().getProcessDefinitionId();
-                ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionId);
-                //获取当前流程节点
-                String currActivityId = task.getTaskDefinitionKey();
-                BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
-                FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
-                if (currFlow instanceof UserTask) {
-                    UserTask userTask = (UserTask) currFlow;
-                    //流程审批记录
-                }
-            }
             //命题任务修改
 //            examTask.setFlowId(null);
             examTask.setStatus(ExamStatusEnum.STAGE);
@@ -773,44 +756,15 @@ public class ActivitiServiceImpl implements ActivitiService {
      */
     @Override
     public List<FlowTaskResult> getTaskAll(String flowId) {
-        ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
-        if (examTask.getFlowId().longValue() != SystemConstant.convertIdToLong(flowId).longValue()) {
-            TExamTaskFlow tExamTaskFlow = tExamTaskFlowService.findByRootLevel(SystemConstant.convertIdToLong(flowId));
-            Optional.ofNullable(tExamTaskFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到任何流程信息"));
-            flowId = String.valueOf(tExamTaskFlow.getFlowId());
-        }
-        String processDefinitionId = historyService.createHistoricProcessInstanceQuery().processInstanceId(flowId).singleResult().getProcessDefinitionId();
-        ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionId);
-        BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
-        Process process = bpmnModel.getProcessById(processDefinitionEntity.getKey());
-        Collection<FlowElement> flowElements = process.getFlowElements();
-        List<FlowTaskResult> flowTaskResultList = new ArrayList<>();
-        for (FlowElement flowElement : flowElements) {
-            //假设是任务节点
-            if (flowElement instanceof UserTask) {
-                UserTask userTask = (UserTask) flowElement;
-                if (Objects.nonNull(userTask)) {
-                    FlowApproveSetupEnum flowApproveSetupEnum = FlowApproveSetupEnum.convertToInstance(userTask.getId());
-                    flowTaskResultList.add(new FlowTaskResult(Long.parseLong(flowId), userTask.getName(), flowApproveSetupEnum.getId(), flowApproveSetupEnum.getSetup()));
-                }
-            } else if (flowElement instanceof CallActivity) {
-                CallActivity callActivity = (CallActivity) flowElement;
-                String processDefinitionIdSub = examTaskService.getProcessDefinitionIdByMaxVersion(callActivity.getCalledElement());
-                ProcessDefinitionEntity processDefinitionEntitySub = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionIdSub);
-                BpmnModel bpmnModelSub = repositoryService.getBpmnModel(processDefinitionIdSub);
-                Process processSub = bpmnModelSub.getProcessById(processDefinitionEntitySub.getKey());
-                Collection<FlowElement> flowElementsSubs = processSub.getFlowElements();
-                for (FlowElement flowElementSub : flowElementsSubs) {
-                    //假设是任务节点
-                    if (flowElementSub instanceof UserTask) {
-                        UserTask userTask = (UserTask) flowElementSub;
-                        if (Objects.nonNull(userTask)) {
-                            FlowApproveSetupEnum flowApproveSetupEnum = FlowApproveSetupEnum.convertToInstance(userTask.getId());
-                            flowTaskResultList.add(new FlowTaskResult(Long.parseLong(flowId), userTask.getName(), flowApproveSetupEnum.getId(), flowApproveSetupEnum.getSetup()));
-                        }
-                    }
-                }
-            }
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(SystemConstant.convertIdToLong(flowId));
+        Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
+        Map<String, FlowTaskResult> setupMap = (Map<String, FlowTaskResult>) flowProcessVarMap.get(SystemConstant.SETUP_MAP);
+        List<FlowTaskResult> flowTaskResultList = new ArrayList<>(setupMap.size());
+        Gson gson = new Gson();
+        for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
+            FlowTaskResult FlowTaskResult = gson.fromJson(gson.toJson(entry.getValue()), FlowTaskResult.class);
+            FlowTaskResult.setFlowId(SystemConstant.convertIdToLong(flowId));
+            flowTaskResultList.add(FlowTaskResult);
         }
         return flowTaskResultList;
     }

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

@@ -290,13 +290,13 @@ public class TFCustomFlowController {
         return ResultUtil.ok(activitiService.getTaskAll(flowId));
     }
 
-    @ApiOperation(value = "获取所有流程节点待审批人")
-    @ApiResponses({@ApiResponse(code = 200, message = "流程节点待审批人", response = FlowTaskApprovePeopleAllResult.class)})
-    @RequestMapping(value = "/task/approver/people_all", method = RequestMethod.POST)
-    public Result taskApproverPeopleAll(@ApiParam(value = "课程编码", required = false) @RequestParam(required = false) String courseCode,
-                                        @ApiParam(value = "流程节点id", required = false) @RequestParam(required = false) String taskId) {
-        return ResultUtil.ok(activitiService.taskApproverPeopleAll(courseCode, taskId));
-    }
+//    @ApiOperation(value = "获取所有流程节点待审批人")
+//    @ApiResponses({@ApiResponse(code = 200, message = "流程节点待审批人", response = FlowTaskApprovePeopleAllResult.class)})
+//    @RequestMapping(value = "/task/approver/people_all", method = RequestMethod.POST)
+//    public Result taskApproverPeopleAll(@ApiParam(value = "课程编码", required = false) @RequestParam(required = false) String courseCode,
+//                                        @ApiParam(value = "流程节点id", required = false) @RequestParam(required = false) String taskId) {
+//        return ResultUtil.ok(activitiService.taskApproverPeopleAll(courseCode, taskId));
+//    }
 
     @ApiOperation(value = "流程节点转他人审批")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
@@ -314,12 +314,12 @@ public class TFCustomFlowController {
         return ResultUtil.ok(activitiService.taskApproverExchangePeople(taskId, realName));
     }
 
-    @ApiOperation(value = "获取提交记录")
-    @ApiResponses({@ApiResponse(code = 200, message = "流程提交记录", response = FlowTaskApprovePeopleAllResult.class)})
-    @RequestMapping(value = "/task/approver/submit/list", method = RequestMethod.POST)
-    public Result taskApproverSubmitList(@ApiParam(value = "考试任务id", required = true) @RequestParam String examTaskId) {
-        return ResultUtil.ok(activitiService.taskApproverSubmitList(examTaskId));
-    }
+//    @ApiOperation(value = "获取提交记录")
+//    @ApiResponses({@ApiResponse(code = 200, message = "流程提交记录", response = FlowTaskApprovePeopleAllResult.class)})
+//    @RequestMapping(value = "/task/approver/submit/list", method = RequestMethod.POST)
+//    public Result taskApproverSubmitList(@ApiParam(value = "考试任务id", required = true) @RequestParam String examTaskId) {
+//        return ResultUtil.ok(activitiService.taskApproverSubmitList(examTaskId));
+//    }
 
     @ApiOperation(value = "获取当前流程节点信息")
     @ApiResponses({@ApiResponse(code = 200, message = "流程提交记录", response = FlowTaskApprovePeopleAllResult.class)})