|
@@ -3,6 +3,7 @@ package com.fjhx.flow.service.flow.impl;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.flow.entity.flow.dto.FlowExampleSelectDto;
|
|
|
+import com.fjhx.flow.entity.flow.dto.FlowNodeDto;
|
|
|
import com.fjhx.flow.entity.flow.po.*;
|
|
|
import com.fjhx.flow.entity.flow.vo.ApprovalRecordVo;
|
|
|
import com.fjhx.flow.entity.flow.vo.FlowExampleVo;
|
|
@@ -11,6 +12,7 @@ import com.fjhx.flow.enums.HandleTypeEnum;
|
|
|
import com.fjhx.flow.enums.NodeTypeEnum;
|
|
|
import com.fjhx.flow.mapper.flow.FlowExampleMapper;
|
|
|
import com.fjhx.flow.service.flow.*;
|
|
|
+import com.ruoyi.common.constant.StatusConstant;
|
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
@@ -124,8 +126,12 @@ public class FlowExampleServiceImpl extends ServiceImpl<FlowExampleMapper, FlowE
|
|
|
// 赋值节点信息以及处理人名称
|
|
|
setNodeInfoAndHandleUserName(recordList, flowDefinitionNodeList);
|
|
|
|
|
|
- // 添加未开始记录
|
|
|
- addNotStarted(recordList, flowExample, flowDefinitionNodeList);
|
|
|
+ Integer status = flowExample.getStatus();
|
|
|
+
|
|
|
+ if (!FlowStatusEnum.PASS.getKey().equals(status) && !FlowStatusEnum.REJECT.getKey().equals(status)) {
|
|
|
+ // 添加未开始记录
|
|
|
+ addNotStarted(recordList, flowDefinitionNodeList, flowExample.getDefinitionNodeId());
|
|
|
+ }
|
|
|
|
|
|
// 获取button列表
|
|
|
List<ApprovalRecordVo.ButtonInfo> buttonInfoList = getButtonInfoList(flowExample, flowDefinitionNodeList);
|
|
@@ -153,6 +159,38 @@ public class FlowExampleServiceImpl extends ServiceImpl<FlowExampleMapper, FlowE
|
|
|
return doSelectExample(dto, wrapper);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ApprovalRecordVo.Record> getFlowNode(FlowNodeDto dto) {
|
|
|
+
|
|
|
+ List<ApprovalRecordVo.Record> recordList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 查找可用流程
|
|
|
+ FlowDefinition flowDefinition = flowDefinitionService.getOne(q -> q
|
|
|
+ .eq(FlowDefinition::getFlowKey, dto.getFlowKey())
|
|
|
+ .eq(FlowDefinition::getCurrentVersion, StatusConstant.YES));
|
|
|
+
|
|
|
+ // 获取流程全部节点
|
|
|
+ List<FlowDefinitionNode> flowDefinitionNodeList = flowDefinitionNodeService.list(
|
|
|
+ q -> q.eq(FlowDefinitionNode::getFlowDefinitionId, flowDefinition.getId()));
|
|
|
+
|
|
|
+ // 查找开始节点
|
|
|
+ FlowDefinitionNode startNode = flowDefinitionNodeList.stream()
|
|
|
+ .filter(item -> item.getNodeType().equals(NodeTypeEnum.START.getKey()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+
|
|
|
+ if (startNode == null) {
|
|
|
+ throw new ServiceException("未找到开始节点");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查找节点
|
|
|
+ addNotStarted(recordList, flowDefinitionNodeList, 0L);
|
|
|
+
|
|
|
+ // 赋值开始节点创作人
|
|
|
+ recordList.get(0).setProcessedUser(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
+
|
|
|
+ return recordList;
|
|
|
+ }
|
|
|
+
|
|
|
private List<ApprovalRecordVo.ButtonInfo> getButtonInfoList(FlowExample flowExample,
|
|
|
List<FlowDefinitionNode> flowDefinitionNodeList) {
|
|
|
|
|
@@ -189,20 +227,15 @@ public class FlowExampleServiceImpl extends ServiceImpl<FlowExampleMapper, FlowE
|
|
|
/**
|
|
|
* 添加未开始记录
|
|
|
*/
|
|
|
- private void addNotStarted(List<ApprovalRecordVo.Record> recordList, FlowExample flowExample,
|
|
|
- List<FlowDefinitionNode> flowDefinitionNodeList) {
|
|
|
-
|
|
|
- Integer status = flowExample.getStatus();
|
|
|
-
|
|
|
- if (FlowStatusEnum.PASS.getKey().equals(status) || FlowStatusEnum.REJECT.getKey().equals(status)) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ private void addNotStarted(List<ApprovalRecordVo.Record> recordList,
|
|
|
+ List<FlowDefinitionNode> flowDefinitionNodeList,
|
|
|
+ Long definitionNodeId) {
|
|
|
|
|
|
// 父节点id map
|
|
|
Map<Long, FlowDefinitionNode> flowDefinitionNodeMap = flowDefinitionNodeList.stream()
|
|
|
.collect(Collectors.toMap(FlowDefinitionNode::getParentId, Function.identity()));
|
|
|
|
|
|
- FlowDefinitionNode nextNode = flowDefinitionNodeMap.get(flowExample.getDefinitionNodeId());
|
|
|
+ FlowDefinitionNode nextNode = flowDefinitionNodeMap.get(definitionNodeId);
|
|
|
|
|
|
while (nextNode != null) {
|
|
|
|