| | |
| | | * @param currentNodeDefId |
| | | * @return |
| | | */ |
| | | public List<FormDetailVO> getBeforeNodeDefId(String processDefId, String currentNodeDefId, ISysFormService sysFormService) { |
| | | public List<FormDetailVO> getBeforeNodeDefId(String processDefId, String currentNodeDefId, ISysFormService sysFormService, Boolean needInitCurrentForm) { |
| | | // 获取流程定义 |
| | | ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionId(processDefId) |
| | |
| | | formDetailVO.setBeforeNodeName(currentElement.getName()); |
| | | formDetailVO.setCurrent(Boolean.TRUE); |
| | | |
| | | SysForm sysForm = sysFormService.selectSysFormById(Long.parseLong(currentElement.getFormKey())); |
| | | if (Objects.isNull(sysForm)) { |
| | | throw new RuntimeException("该流程绑定的表单不存在或已被删除"); |
| | | } |
| | | Map<String, Object> data = new HashMap<>(1); |
| | | data.put(ProcessConstants.TASK_FORM_KEY, JSONObject.parseObject(sysForm.getFormContent())); |
| | | if (needInitCurrentForm) { |
| | | SysForm sysForm = sysFormService.selectSysFormById(Long.parseLong(currentElement.getFormKey())); |
| | | if (Objects.isNull(sysForm)) { |
| | | throw new RuntimeException("该流程绑定的表单不存在或已被删除"); |
| | | } |
| | | Map<String, Object> data = new HashMap<>(1); |
| | | data.put(ProcessConstants.TASK_FORM_KEY, JSONObject.parseObject(sysForm.getFormContent())); |
| | | |
| | | formDetailVO.setFormJsonObj(data); |
| | | formDetailVO.setFormJsonObj(data); |
| | | } |
| | | |
| | | defKeys.add(formDetailVO); |
| | | } |
| | | this.before(currentElement, defKeys); |
| | |
| | | * @param currentElement |
| | | * @param defKeys |
| | | */ |
| | | private void before(UserTask currentElement, List<FormDetailVO> defKeys) { |
| | | if (! CollectionUtils.isEmpty(currentElement.getIncomingFlows())) { |
| | | for (SequenceFlow incomingFlow : currentElement.getIncomingFlows()) { |
| | | if (! (incomingFlow.getSourceFlowElement() instanceof UserTask)) { |
| | | // 不包含开始节点 |
| | | if (! (incomingFlow.getSourceFlowElement() instanceof StartEvent)) { |
| | | before((UserTask) (incomingFlow.getSourceFlowElement()), defKeys); |
| | | private void before(FlowElement currentElement, List<FormDetailVO> defKeys) { |
| | | if (currentElement instanceof UserTask) { |
| | | UserTask userTask = (UserTask) currentElement; |
| | | if (! CollectionUtils.isEmpty(userTask.getIncomingFlows())) { |
| | | for (SequenceFlow incomingFlow : userTask.getIncomingFlows()) { |
| | | if (incomingFlow.getSourceFlowElement() instanceof UserTask) { |
| | | FormDetailVO formDetailVO = new FormDetailVO(); |
| | | formDetailVO.setBeforeNodeDefId(incomingFlow.getSourceFlowElement().getId()); |
| | | formDetailVO.setBeforeNodeName(incomingFlow.getSourceFlowElement().getName()); |
| | | defKeys.add(formDetailVO); |
| | | } else { |
| | | before(incomingFlow.getSourceFlowElement(), defKeys); |
| | | } |
| | | } else { |
| | | FormDetailVO formDetailVO = new FormDetailVO(); |
| | | formDetailVO.setBeforeNodeDefId(incomingFlow.getSourceFlowElement().getId()); |
| | | formDetailVO.setBeforeNodeName(incomingFlow.getSourceFlowElement().getName()); |
| | | defKeys.add(formDetailVO); |
| | | } |
| | | } |
| | | } else if (currentElement instanceof Gateway ){ |
| | | Gateway gateway = (Gateway) currentElement; |
| | | if (! CollectionUtils.isEmpty(gateway.getIncomingFlows())) { |
| | | for (SequenceFlow incomingFlow : gateway.getIncomingFlows()) { |
| | | if (incomingFlow.getSourceFlowElement() instanceof UserTask) { |
| | | FormDetailVO formDetailVO = new FormDetailVO(); |
| | | formDetailVO.setBeforeNodeDefId(incomingFlow.getSourceFlowElement().getId()); |
| | | formDetailVO.setBeforeNodeName(incomingFlow.getSourceFlowElement().getName()); |
| | | defKeys.add(formDetailVO); |
| | | } else { |
| | | before(incomingFlow.getSourceFlowElement(), defKeys); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // if (! CollectionUtils.isEmpty(currentElement.getIncomingFlows())) { |
| | | // for (SequenceFlow incomingFlow : currentElement.getIncomingFlows()) { |
| | | // if (! (incomingFlow.getSourceFlowElement() instanceof UserTask)) { |
| | | // // 不包含开始节点、并行网关、互斥网关,// TODO 还需要排除其它特殊类型 |
| | | // if (! (incomingFlow.getSourceFlowElement() instanceof StartEvent) && ! (incomingFlow.getSourceFlowElement() instanceof ParallelGateway) && ! (incomingFlow.getSourceFlowElement() instanceof ExclusiveGateway)) { |
| | | // before((UserTask) (incomingFlow.getSourceFlowElement()), defKeys); |
| | | // } |
| | | // } else { |
| | | // FormDetailVO formDetailVO = new FormDetailVO(); |
| | | // formDetailVO.setBeforeNodeDefId(incomingFlow.getSourceFlowElement().getId()); |
| | | // formDetailVO.setBeforeNodeName(incomingFlow.getSourceFlowElement().getName()); |
| | | // defKeys.add(formDetailVO); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | } |