update 流程部署-增加节点复制逻辑

This commit is contained in:
liao
2023-11-22 16:44:31 +08:00
parent 287a9c3488
commit aa7e05f22a
2 changed files with 90 additions and 39 deletions
@@ -3,6 +3,8 @@ package com.jero.modules.activiti.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.activiti.entity.ProcessModelNode;
import com.jero.modules.activiti.mapper.ProcessModelNodeMapper;
import com.jero.modules.activiti.process.fb.common.ProcessDefinitionKey;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -13,6 +15,7 @@ import com.jero.modules.activiti.entity.ProcessNode;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
*
@@ -20,6 +23,7 @@ import java.util.List;
*@date 2023-09-26 15:12
*/
@Service
@Slf4j
public class ProcessNodeService extends ServiceImpl<ProcessNodeMapper, ProcessNode> {
@Resource
private ProcessModelNodeMapper processModelNodeMapper;
@@ -43,7 +47,47 @@ public class ProcessNodeService extends ServiceImpl<ProcessNodeMapper, ProcessNo
node.setProcessDefinitionId(processDefinitionId);
processNodeList.add(node);
}
this.saveBatch(processNodeList);
// 对流程节点做一下特殊处理
List<ProcessNode> viewNodeList = getViewNodeList(processNodeList, processDefinitionId);
this.saveBatch(viewNodeList);
}
/**
* @Author: liao
* @Date: 2023/11/22 16:39
* @Description: 对流程节点做一下特殊处理
**/
private List<ProcessNode> getViewNodeList(List<ProcessNode> processNodeList, String processDefinitionId) {
String[] parts = processDefinitionId.split(":");
String definitionKey = parts[0];
Integer version = Integer.valueOf(parts[1]) - 1;
LambdaQueryWrapper<ProcessNode> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(ProcessNode::getProcessDefinitionId, definitionKey + ":" + version);
List<ProcessNode> oldNodeList = list(queryWrapper);
List<String> nodeNameList = oldNodeList.stream()
.map(ProcessNode::getNodeName).distinct().collect(Collectors.toList());
// 给前端展示的节点
List<ProcessNode> viewNodeList = oldNodeList.stream()
.filter(node -> node.getIsView() == 1).collect(Collectors.toList());
viewNodeList.forEach(viewNode -> {
viewNode.setProcessDefinitionId(processDefinitionId);
viewNode.setId(null);
});
for (ProcessNode processNode : processNodeList) {
// 如果旧列表里面不存在这个名字,即为新增节点
if (!nodeNameList.contains(processNode.getNodeName())) {
viewNodeList.add(processNode);
}
}
return viewNodeList;
}
public List<ProcessNode> getNodeList(String processDefinitionId, String processInstanceId) {
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<bpmn:process id="fb-standard-consultation" name="标准征求意见流程" isExecutable="true">
<bpmn:process id="fb-standard-consultation" name="标准征求意见流程" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_1d5objw</bpmn:outgoing>
</bpmn:startEvent>
@@ -144,6 +144,7 @@
<activiti:taskListener class="com.jero.modules.activiti.process.fb.listener.BusinessKeyListener" event="create" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_19vxot3</bpmn:incoming>
<bpmn:incoming>Flow_06kgad6</bpmn:incoming>
<bpmn:outgoing>Flow_1125yee</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_19vxot3" sourceRef="sub_process_1" targetRef="engineer_start_end" />
@@ -161,6 +162,7 @@
</bpmn:sequenceFlow>
<bpmn:subProcess id="sub_process_3">
<bpmn:incoming>Flow_0jjkrst</bpmn:incoming>
<bpmn:outgoing>Flow_06kgad6</bpmn:outgoing>
<bpmn:multiInstanceLoopCharacteristics activiti:collection="departLeaderList" activiti:elementVariable="departLeader">
<bpmn:completionCondition xsi:type="bpmn:tFormalExpression">${nrOfInstances== nrOfCompletedInstances}</bpmn:completionCondition>
</bpmn:multiInstanceLoopCharacteristics>
@@ -234,6 +236,7 @@
<bpmn:sequenceFlow id="Flow_0jjkrst" name="驳回" sourceRef="Gateway_0pd0196" targetRef="sub_process_3">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${!passThird}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="Flow_06kgad6" sourceRef="sub_process_3" targetRef="engineer_start_end" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="fb-standard-consultation">
@@ -244,12 +247,6 @@
<dc:Bounds x="160" y="360" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0pd0196_di" bpmnElement="Gateway_0pd0196" isMarkerVisible="true">
<dc:Bounds x="1715" y="375" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_07yr7ob_di" bpmnElement="Event_07yr7ob">
<dc:Bounds x="1822" y="382" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0mj9ddw_di" bpmnElement="sub_process_1" isExpanded="true">
<dc:Bounds x="320" y="40" width="1120" height="690" />
</bpmndi:BPMNShape>
@@ -274,10 +271,6 @@
<dc:Bounds x="890" y="420" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_18s4mik" bpmnElement="module_owner_end_2">
<dc:Bounds x="1060" y="340" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1pip97n_di" bpmnElement="sub_process_2" isExpanded="true">
<dc:Bounds x="680" y="100" width="660" height="210" />
</bpmndi:BPMNShape>
@@ -325,6 +318,10 @@
<dc:Bounds x="730" y="530" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_18s4mik" bpmnElement="module_owner_end_2">
<dc:Bounds x="1060" y="340" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1gv6jmb_di" bpmnElement="Flow_1gv6jmb">
<di:waypoint x="378" y="400" />
<di:waypoint x="430" y="400" />
@@ -388,25 +385,18 @@
<dc:Bounds x="1560" y="360" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0pd0196_di" bpmnElement="Gateway_0pd0196" isMarkerVisible="true">
<dc:Bounds x="1715" y="375" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_07yr7ob_di" bpmnElement="Event_07yr7ob">
<dc:Bounds x="1822" y="382" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0qqp5sb_di" bpmnElement="sub_process_3" isExpanded="true">
<dc:Bounds x="1490" y="480" width="838" height="310" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0eapre1_di" bpmnElement="Event_0eapre1">
<dc:Bounds x="1510" y="582" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_19cqaly" bpmnElement="reject">
<dc:Bounds x="1578" y="560" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_07vxc54_di" bpmnElement="Event_07vxc54">
<dc:Bounds x="2260" y="582" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_1pq4fen_di" bpmnElement="Gateway_1pq4fen" isMarkerVisible="true">
<dc:Bounds x="2163" y="575" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0vnihbs_di" bpmnElement="Gateway_0vnihbs" isMarkerVisible="true">
<dc:Bounds x="1723" y="575" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_00so089" bpmnElement="module_owner_end_3">
<dc:Bounds x="1828" y="560" width="100" height="80" />
<bpmndi:BPMNLabel />
@@ -415,17 +405,30 @@
<dc:Bounds x="1998" y="560" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_1pq4fen_di" bpmnElement="Gateway_1pq4fen" isMarkerVisible="true">
<dc:Bounds x="2163" y="575" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_07vxc54_di" bpmnElement="Event_07vxc54">
<dc:Bounds x="2260" y="582" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_19cqaly" bpmnElement="reject">
<dc:Bounds x="1578" y="560" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0vnihbs_di" bpmnElement="Gateway_0vnihbs" isMarkerVisible="true">
<dc:Bounds x="1723" y="575" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_0k4hx5w" bpmnElement="depart_leader_collect_3">
<dc:Bounds x="1828" y="660" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_07p5ivp_di" bpmnElement="Flow_07p5ivp">
<di:waypoint x="1546" y="600" />
<di:waypoint x="1578" y="600" />
<bpmndi:BPMNEdge id="Flow_0mdmcs5_di" bpmnElement="Flow_0mdmcs5">
<di:waypoint x="1928" y="600" />
<di:waypoint x="1998" y="600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ybap2u_di" bpmnElement="Flow_1ybap2u">
<di:waypoint x="1678" y="600" />
<di:waypoint x="1723" y="600" />
<bpmndi:BPMNEdge id="Flow_0flbibd_di" bpmnElement="Flow_0flbibd">
<di:waypoint x="2098" y="600" />
<di:waypoint x="2163" y="600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ta4894_di" bpmnElement="Flow_1ta4894">
<di:waypoint x="2213" y="600" />
@@ -434,10 +437,6 @@
<dc:Bounds x="2222" y="582" width="23" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0flbibd_di" bpmnElement="Flow_0flbibd">
<di:waypoint x="2098" y="600" />
<di:waypoint x="2163" y="600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ft2poj_di" bpmnElement="Flow_1ft2poj">
<di:waypoint x="2188" y="575" />
<di:waypoint x="2188" y="510" />
@@ -447,6 +446,14 @@
<dc:Bounds x="2024" y="492" width="22" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_07p5ivp_di" bpmnElement="Flow_07p5ivp">
<di:waypoint x="1546" y="600" />
<di:waypoint x="1578" y="600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ybap2u_di" bpmnElement="Flow_1ybap2u">
<di:waypoint x="1678" y="600" />
<di:waypoint x="1723" y="600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1vn8jk5_di" bpmnElement="Flow_1vn8jk5">
<di:waypoint x="1773" y="600" />
<di:waypoint x="1828" y="600" />
@@ -462,10 +469,6 @@
<dc:Bounds x="1761" y="660" width="33" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0mdmcs5_di" bpmnElement="Flow_0mdmcs5">
<di:waypoint x="1928" y="600" />
<di:waypoint x="1998" y="600" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_132k5wt_di" bpmnElement="Flow_132k5wt">
<di:waypoint x="1928" y="700" />
<di:waypoint x="2278" y="700" />
@@ -501,6 +504,10 @@
<dc:Bounds x="1747" y="449" width="21" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_06kgad6_di" bpmnElement="Flow_06kgad6">
<di:waypoint x="1610" y="480" />
<di:waypoint x="1610" y="440" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>