| | |
| | | import org.flowable.engine.repository.ProcessDefinition; |
| | | import org.flowable.engine.runtime.ProcessInstance; |
| | | import org.flowable.task.api.Task; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.support.Kv; |
| | |
| | | private final HistoryService historyService; |
| | | |
| | | @Override |
| | | public R<BladeFlow> startProcess(FlowTaskUserC flowTaskUserC){ |
| | | public R<BladeFlow> startProcess(FlowTaskDTO flowTaskUserC){ |
| | | String modelKey = flowTaskUserC.getModelKey(); |
| | | String templateId = flowTaskUserC.getTemplateId(); |
| | | |
| | |
| | | } |
| | | |
| | | //对比配置的审核人员和流程中节点是否一致,可能存在流程节点变更了,多了或者少了节点,但是配置审核人员的节点没有变 |
| | | List<Map<String,String>> processTasks = flowEngineService.getNodeByFlowableKey(modelKey); |
| | | for (Map<String,String> mi:processTasks){ |
| | | String taskId = mi.get(flowEngineService.getTaskIdString()); |
| | | if(!taskIdSet.contains(taskId)){ |
| | | throw new ServiceException("流程已重新部署,节点已改变,请设置审核人员!"); |
| | | } |
| | | } |
| | | if(taskIdSet.size()!=processTasks.size()){ |
| | | throw new ServiceException("流程已重新部署,节点已改变,请设置审核人员!"); |
| | | } |
| | | // List<Map<String,String>> processTasks = flowEngineService.getNodeByFlowableKey(modelKey); |
| | | // for (Map<String,String> mi:processTasks){ |
| | | // String taskId = mi.get(flowEngineService.getTaskIdString()); |
| | | // if(!taskIdSet.contains(taskId)){ |
| | | // throw new ServiceException("流程已重新部署,节点已改变,请设置审核人员!"); |
| | | // } |
| | | // } |
| | | // if(taskIdSet.size()!=processTasks.size()){ |
| | | // throw new ServiceException("流程已重新部署,节点已改变,请设置审核人员!"); |
| | | // } |
| | | |
| | | //流程中文件、变量等 |
| | | //do.. |
| | |
| | | BladeFlow flow = new BladeFlow(); |
| | | flow.setProcessInstanceId(processInstance.getId()); |
| | | |
| | | nextFlowNode("next","039ac1d8-0c1e-11ee-bebb-5c3a4570456d"); |
| | | return R.data(flow); |
| | | } |
| | | |
| | | public static String NODE_NOW = "now"; |
| | | public static String NODE_NEXT = "next"; |
| | | /** |
| | | * 获取任务节点 |
| | | * |
| | | * @param node 查询节点选择 |
| | | * @param processInstanceId 流程实例id |
| | | */ |
| | | public void nextFlowNode(String node, String processInstanceId) { |
| | | public FlowTaskDTO nextFlowNode(String node, String processInstanceId) { |
| | | FlowTaskDTO flowTaskDTO = new FlowTaskDTO(); |
| | | List<FlowTaskDTO> taskList = new ArrayList<>();//节点按钮 |
| | | flowTaskDTO.setToTasks(taskList); |
| | | |
| | | Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).active().singleResult(); |
| | | |
| | | ExecutionEntity ee = (ExecutionEntity) runtimeService.createExecutionQuery() |
| | | .executionId(task.getExecutionId()).singleResult(); |
| | | // 当前审批节点 |
| | | String crruentActivityId = ee.getActivityId(); |
| | | BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); |
| | | FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(crruentActivityId); |
| | | |
| | | //这个实例的所有节点 |
| | | ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); |
| | | Map<String, Object> processVariables = processInstance.getProcessVariables();//所有参数 |
| | | flowTaskDTO.setVars(processVariables); |
| | | |
| | | String modelKey = processInstance.getProcessDefinitionKey(); |
| | | List<FlowTaskDTO> mis = flowEngineService.getNodeByFlowableKey(modelKey); |
| | | |
| | | // 输出连线 |
| | | List<SequenceFlow> outFlows = flowNode.getOutgoingFlows(); |
| | | for (SequenceFlow sequenceFlow : outFlows) { |
| | | //当前审批节点 |
| | | if ("now".equals(node)) { |
| | | if (NODE_NOW.equals(node)) { |
| | | FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement(); |
| | | System.out.println("当前节点: id=" + sourceFlowElement.getId() + ",name=" + sourceFlowElement.getName()); |
| | | } else if ("next".equals(node)) { |
| | | } else if (NODE_NEXT.equals(node)) { |
| | | // 下一个审批节点 |
| | | FlowElement targetFlow = sequenceFlow.getTargetFlowElement(); |
| | | if (targetFlow instanceof UserTask) { |
| | | System.out.println("下一节点: id=" + targetFlow.getId() + ",name=" + targetFlow.getName()); |
| | | } |
| | | // 如果下个审批节点为结束节点 |
| | | if (targetFlow instanceof EndEvent) { |
| | | System.out.println("下一节点为结束节点:id=" + targetFlow.getId() + ",name=" + targetFlow.getName()); |
| | | // 如果下个审批节点为排他网关 |
| | | if (targetFlow instanceof ExclusiveGateway) { |
| | | |
| | | ExclusiveGateway exclusiveGateway = (ExclusiveGateway) targetFlow; |
| | | List<SequenceFlow> exclusiveGatewayOutgoingFlows = exclusiveGateway.getOutgoingFlows(); |
| | | for (SequenceFlow nexti:exclusiveGatewayOutgoingFlows){ |
| | | String conditionExpression = nexti.getConditionExpression();//condition |
| | | String taskId = nexti.getTargetRef();//taskId |
| | | String name = nexti.getName();//toName,驳回、同意 |
| | | |
| | | for (FlowTaskDTO flowTaskUserCi:mis){ |
| | | if(taskId.equals(flowTaskUserCi.getTaskId())){ |
| | | flowTaskUserCi.setCondition(conditionExpression); |
| | | if(conditionExpression.split("=").length>1) { |
| | | flowTaskUserCi.setConditionKey(conditionExpression.split("=")[0]); |
| | | flowTaskUserCi.setConditionValue(conditionExpression.split("=")[1]); |
| | | } |
| | | flowTaskUserCi.setToName(name); |
| | | flowTaskUserCi.setToTaskId(taskId); |
| | | flowTaskUserCi.setToTaskName(flowTaskUserCi.getTaskName()); |
| | | taskList.add(flowTaskUserCi); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | return flowTaskDTO; |
| | | } |
| | | } |