diff --git a/flowlong-core/src/main/java/com/aizuda/bpm/engine/ProcessModelCache.java b/flowlong-core/src/main/java/com/aizuda/bpm/engine/ProcessModelCache.java index e082cd08..9550d6ca 100644 --- a/flowlong-core/src/main/java/com/aizuda/bpm/engine/ProcessModelCache.java +++ b/flowlong-core/src/main/java/com/aizuda/bpm/engine/ProcessModelCache.java @@ -39,8 +39,18 @@ public interface ProcessModelCache { * @return JSON BPM 模型 */ default ProcessModel model() { + return this.model(false); + } + + /** + * JSON BPM 模型 + * + * @param redeploy 重新部署 true 是 false 否 + * @return JSON BPM 模型 + */ + default ProcessModel model(boolean redeploy) { String modelContent = this.getModelContent(); Assert.isEmpty(modelContent, "The process modelContent is Empty."); - return FlowLongContext.parseProcessModel(modelContent, this.modelCacheKey(), false); + return FlowLongContext.parseProcessModel(modelContent, this.modelCacheKey(), redeploy); } } diff --git a/flowlong-core/src/main/java/com/aizuda/bpm/engine/core/FlowLongEngineImpl.java b/flowlong-core/src/main/java/com/aizuda/bpm/engine/core/FlowLongEngineImpl.java index 04fbec54..8427c88c 100644 --- a/flowlong-core/src/main/java/com/aizuda/bpm/engine/core/FlowLongEngineImpl.java +++ b/flowlong-core/src/main/java/com/aizuda/bpm/engine/core/FlowLongEngineImpl.java @@ -84,7 +84,7 @@ public Optional startProcessInstance(FlwProcess process, FlowCreato if (log.isDebugEnabled()) { log.debug("start process instanceId={}", flwInstance.getId()); } - return new Execution(this, process.model(), flowCreator, flwInstance, args); + return new Execution(this, process.model(true), flowCreator, flwInstance, args); }); } diff --git a/flowlong-core/src/main/java/com/aizuda/bpm/engine/entity/FlwProcess.java b/flowlong-core/src/main/java/com/aizuda/bpm/engine/entity/FlwProcess.java index 8cb9b5fe..e423fb44 100644 --- a/flowlong-core/src/main/java/com/aizuda/bpm/engine/entity/FlwProcess.java +++ b/flowlong-core/src/main/java/com/aizuda/bpm/engine/entity/FlwProcess.java @@ -122,6 +122,8 @@ public Optional executeStartModel(FlowLongContext flowLongContext, Assert.isTrue(ModelHelper.checkDuplicateNodeKeys(nodeModel), "There are duplicate node keys present"); // 回调执行创建实例 Execution execution = function.apply(nodeModel); + // 重新渲染逻辑节点 + nodeModel = execution.getProcessModel().getNodeConfig(); // 创建首个审批任务 flowLongContext.createTask(execution, nodeModel); // 当前执行实例 diff --git a/flowlong-spring-boot-starter/src/test/java/test/mysql/TestCcToCondition.java b/flowlong-spring-boot-starter/src/test/java/test/mysql/TestCcToCondition.java index 0cce9d04..d9ebe79d 100644 --- a/flowlong-spring-boot-starter/src/test/java/test/mysql/TestCcToCondition.java +++ b/flowlong-spring-boot-starter/src/test/java/test/mysql/TestCcToCondition.java @@ -3,11 +3,16 @@ */ package test.mysql; +import com.aizuda.bpm.engine.FlowDataTransfer; +import com.aizuda.bpm.engine.model.DynamicAssignee; +import com.aizuda.bpm.engine.model.NodeAssignee; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -24,13 +29,27 @@ public void before() { @Test public void test() { + String ccNodeKey = "k002"; // 抄送 + List assigneeList = Arrays.asList( + // 动态抄送给:用户01、用户02、用户03 + NodeAssignee.ofFlowCreator(testCreator), + NodeAssignee.ofFlowCreator(test2Creator) + ); + + // 传输动态节点处理人 + Map dataMap = new HashMap() {{ + put(ccNodeKey, DynamicAssignee.assigneeUserList(assigneeList)); + }}; + + FlowDataTransfer.dynamicAssignee(dataMap); + // 启动指定流程定义ID启动流程实例 Map args = new HashMap<>(); - args.put("day", 8); + args.put("day", 5); flowLongEngine.startInstanceById(processId, testCreator, args).ifPresent(instance -> { // 领导审批,自动抄送,流程结束 - this.executeActiveTasks(instance.getId(), test3Creator); + this.executeActiveTasks(instance.getId(), test2Creator); }); } diff --git a/flowlong-spring-boot-starter/src/test/resources/test/ccToCondition.json b/flowlong-spring-boot-starter/src/test/resources/test/ccToCondition.json index 1fd9fb7b..e2750fc5 100644 --- a/flowlong-spring-boot-starter/src/test/resources/test/ccToCondition.json +++ b/flowlong-spring-boot-starter/src/test/resources/test/ccToCondition.json @@ -67,35 +67,40 @@ "conditionMode": 1, "conditionList": [], "childNode": { - "nodeName": "直接主管审批", + "nodeName": "短期不用审核但要抄送", "nodeKey": "k007", - "type": 1, - "setType": 2, - "nodeAssigneeList": [], - "examineLevel": 1, - "directorLevel": 1, - "selectMode": 1, - "termAuto": false, - "term": 0, - "termMode": 1, - "examineMode": 1, - "directorMode": 0 + "type": 2, + "userSelectFlag": true, + "nodeAssigneeList": [ + { + "id": "test004", + "name": "李四" + } + ] } } ], "childNode": { - "nodeName": "抄送人", + "nodeName": "最后的审批", "nodeKey": "k008", - "type": 2, - "userSelectFlag": true, + "type": 1, + "setType": 1, "nodeAssigneeList": [ { "id": "test002", "name": "何秀英" } - ] + ], + "examineLevel": 1, + "directorLevel": 1, + "selectMode": 1, + "termAuto": false, + "term": 0, + "termMode": 1, + "examineMode": 1, + "directorMode": 0 } } } } -} \ No newline at end of file +}