|
@@ -2,26 +2,18 @@ package com.fjhx.service.process.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.fjhx.constants.FlowConstant;
|
|
|
|
import com.fjhx.constants.FlowExplainConstant;
|
|
import com.fjhx.constants.FlowExplainConstant;
|
|
import com.fjhx.entity.process.ProcessNode;
|
|
import com.fjhx.entity.process.ProcessNode;
|
|
-import com.fjhx.entity.process.ProcessNodeButton;
|
|
|
|
-import com.fjhx.enums.ButtonNameEnum;
|
|
|
|
import com.fjhx.enums.ProcessNodeHandleObjectTypeEnum;
|
|
import com.fjhx.enums.ProcessNodeHandleObjectTypeEnum;
|
|
-import com.fjhx.enums.ProcessNodeTypeEnum;
|
|
|
|
import com.fjhx.mapper.process.ProcessNodeMapper;
|
|
import com.fjhx.mapper.process.ProcessNodeMapper;
|
|
import com.fjhx.params.process.ProcessNodeVo;
|
|
import com.fjhx.params.process.ProcessNodeVo;
|
|
import com.fjhx.service.process.ProcessNodeButtonService;
|
|
import com.fjhx.service.process.ProcessNodeButtonService;
|
|
import com.fjhx.service.process.ProcessNodeService;
|
|
import com.fjhx.service.process.ProcessNodeService;
|
|
import com.fjhx.utils.Assert;
|
|
import com.fjhx.utils.Assert;
|
|
-import org.springblade.core.log.exception.ServiceException;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Map;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -37,17 +29,6 @@ public class ProcessNodeServiceImpl extends ServiceImpl<ProcessNodeMapper, Proce
|
|
@Autowired
|
|
@Autowired
|
|
private ProcessNodeButtonService processNodeButtonService;
|
|
private ProcessNodeButtonService processNodeButtonService;
|
|
|
|
|
|
- public void editNodeList(List<ProcessNode> ProcessNodeList) {
|
|
|
|
-
|
|
|
|
- // 更新节点
|
|
|
|
- updateBatchById(ProcessNodeList);
|
|
|
|
-
|
|
|
|
- // 添加节点按钮
|
|
|
|
- insertNodeButton(ProcessNodeList);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 验证字段
|
|
* 验证字段
|
|
*/
|
|
*/
|
|
@@ -81,173 +62,4 @@ public class ProcessNodeServiceImpl extends ServiceImpl<ProcessNodeMapper, Proce
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 添加节点按钮
|
|
|
|
- */
|
|
|
|
- private void insertNodeButton(List<ProcessNode> processNodeList) {
|
|
|
|
-
|
|
|
|
- Long processTenantId = processNodeList.get(0).getProcessTenantId();
|
|
|
|
- remove(ProcessNode::getProcessTenantId, processTenantId);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // 按父级节点id分组
|
|
|
|
- Map<Long, List<ProcessNode>> ProcessNodeGroupByParentId = processNodeList.stream()
|
|
|
|
- .collect(Collectors.groupingBy(ProcessNode::getParentId));
|
|
|
|
-
|
|
|
|
- // 按节点id分组
|
|
|
|
- Map<Long, List<ProcessNode>> ProcessNodeGroupById = processNodeList.stream()
|
|
|
|
- .collect(Collectors.groupingBy(ProcessNode::getId));
|
|
|
|
-
|
|
|
|
- // 根据节点类型生成功能按钮
|
|
|
|
- List<ProcessNodeButton> processNodeButtonList = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- for (ProcessNode processNode : processNodeList) {
|
|
|
|
-
|
|
|
|
- Integer type = processNode.getType();
|
|
|
|
-
|
|
|
|
- // 获取节点类型枚举值
|
|
|
|
- ProcessNodeTypeEnum processNodeTypeEnum = ProcessNodeTypeEnum.get(type);
|
|
|
|
-
|
|
|
|
- Assert.notEmpty(processNodeTypeEnum, FlowExplainConstant.NODE_UNKNOWN);
|
|
|
|
-
|
|
|
|
- switch (processNodeTypeEnum) {
|
|
|
|
-
|
|
|
|
- case START: // 开始
|
|
|
|
- startHandle(processNodeButtonList, ProcessNodeGroupByParentId, processNode);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case EXAMINED: // 审核
|
|
|
|
- examinedHandle(processNodeButtonList, ProcessNodeGroupById, ProcessNodeGroupByParentId, processNode);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case APPROVAL: // 审批
|
|
|
|
- approvalHandle(processNodeButtonList, ProcessNodeGroupByParentId, processNode);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case HANDLE: // 办理
|
|
|
|
- handle(processNodeButtonList, ProcessNodeGroupByParentId, processNode);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case BRANCH: // 分支
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case END: // 结束
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- processNodeButtonService.saveBatch(processNodeButtonList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 开始节点处理
|
|
|
|
- */
|
|
|
|
- private void startHandle(List<ProcessNodeButton> processNodeButtonList,
|
|
|
|
- Map<Long, List<ProcessNode>> ProcessNodeGroupByParentId,
|
|
|
|
- ProcessNode processNode) {
|
|
|
|
- // 下一步
|
|
|
|
- ProcessNodeButton next = next(ProcessNodeGroupByParentId, processNode, ButtonNameEnum.ADOPT);
|
|
|
|
- processNodeButtonList.add(next);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 审核处理
|
|
|
|
- */
|
|
|
|
- private void examinedHandle(List<ProcessNodeButton> processNodeButtonList,
|
|
|
|
- Map<Long, List<ProcessNode>> ProcessNodeGroupById,
|
|
|
|
- Map<Long, List<ProcessNode>> ProcessNodeGroupByParentId,
|
|
|
|
- ProcessNode processNode) {
|
|
|
|
- // 通过
|
|
|
|
- ProcessNodeButton next = next(ProcessNodeGroupByParentId, processNode, ButtonNameEnum.ADOPT);
|
|
|
|
- processNodeButtonList.add(next);
|
|
|
|
- // 驳回
|
|
|
|
- ProcessNodeButton previous = previous(ProcessNodeGroupById, processNode, ButtonNameEnum.FAIL);
|
|
|
|
- processNodeButtonList.add(previous);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 审批处理
|
|
|
|
- */
|
|
|
|
- private void approvalHandle(List<ProcessNodeButton> processNodeButtonList,
|
|
|
|
- Map<Long, List<ProcessNode>> ProcessNodeGroupByParentId,
|
|
|
|
- ProcessNode processNode) {
|
|
|
|
- // 同意
|
|
|
|
- ProcessNodeButton next = next(ProcessNodeGroupByParentId, processNode, ButtonNameEnum.AGREE);
|
|
|
|
- processNodeButtonList.add(next);
|
|
|
|
- // 驳回
|
|
|
|
- ProcessNodeButton over = over(processNode, ButtonNameEnum.REJECT);
|
|
|
|
- processNodeButtonList.add(over);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 办理处理
|
|
|
|
- */
|
|
|
|
- private void handle(List<ProcessNodeButton> processNodeButtonList,
|
|
|
|
- Map<Long, List<ProcessNode>> ProcessNodeGroupByParentId,
|
|
|
|
- ProcessNode processNode) {
|
|
|
|
- // 完成
|
|
|
|
- ProcessNodeButton next = next(ProcessNodeGroupByParentId, processNode, ButtonNameEnum.complete);
|
|
|
|
- processNodeButtonList.add(next);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 跳转上一节点
|
|
|
|
- */
|
|
|
|
- private ProcessNodeButton previous(Map<Long, List<ProcessNode>> ProcessNodeGroupById,
|
|
|
|
- ProcessNode processNode, ButtonNameEnum buttonNameEnum) {
|
|
|
|
- ProcessNodeButton processNodeButton = createProcessNodeButton(processNode, buttonNameEnum);
|
|
|
|
- // 赋值跳转到上一节点
|
|
|
|
- List<ProcessNode> previousProcessNodeList = ProcessNodeGroupById.get(processNode.getParentId());
|
|
|
|
- if (previousProcessNodeList == null || previousProcessNodeList.size() != 1) {
|
|
|
|
- throw new ServiceException(String.format(FlowExplainConstant.PREVIOUS_ERROR, processNode.getName()));
|
|
|
|
- }
|
|
|
|
- processNodeButton.setJumpNodeId(previousProcessNodeList.get(0).getId());
|
|
|
|
- return processNodeButton;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 跳转下一节点
|
|
|
|
- */
|
|
|
|
- private ProcessNodeButton next(Map<Long, List<ProcessNode>> ProcessNodeGroupByParentId,
|
|
|
|
- ProcessNode processNode, ButtonNameEnum buttonNameEnum) {
|
|
|
|
- ProcessNodeButton processNodeButton = createProcessNodeButton(processNode, buttonNameEnum);
|
|
|
|
-
|
|
|
|
- // 赋值跳转到下一节点
|
|
|
|
- List<ProcessNode> nextProcessNodeList = ProcessNodeGroupByParentId.get(processNode.getId());
|
|
|
|
- if (nextProcessNodeList == null || nextProcessNodeList.size() != 1) {
|
|
|
|
- throw new ServiceException(String.format(FlowExplainConstant.JUMP_EMPTY, processNode.getName()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ProcessNode itemProcessNode = nextProcessNodeList.get(0);
|
|
|
|
- if (itemProcessNode.getType().equals(ProcessNodeTypeEnum.END.getType())) {
|
|
|
|
- processNodeButton.setJumpNodeId(FlowConstant.OVER_PROCESS_FLAG);
|
|
|
|
- } else {
|
|
|
|
- processNodeButton.setJumpNodeId(itemProcessNode.getId());
|
|
|
|
- }
|
|
|
|
- return processNodeButton;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 结束流程
|
|
|
|
- */
|
|
|
|
- private ProcessNodeButton over(ProcessNode processNode, ButtonNameEnum buttonNameEnum) {
|
|
|
|
- ProcessNodeButton processNodeButton = createProcessNodeButton(processNode, buttonNameEnum);
|
|
|
|
- processNodeButton.setJumpNodeId(FlowConstant.OVER_PROCESS_FLAG);
|
|
|
|
- return processNodeButton;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 创建按钮
|
|
|
|
- */
|
|
|
|
- private ProcessNodeButton createProcessNodeButton(ProcessNode processNode, ButtonNameEnum buttonNameEnum) {
|
|
|
|
- ProcessNodeButton processNodeButton = new ProcessNodeButton();
|
|
|
|
- processNodeButton.setProcessTenantId(processNode.getProcessTenantId());
|
|
|
|
- processNodeButton.setProcessNodeId(processNode.getId());
|
|
|
|
- processNodeButton.setProcessNodeCode(processNode.getCode());
|
|
|
|
- processNodeButton.setNameType(buttonNameEnum.getType());
|
|
|
|
- return processNodeButton;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|