diff --git a/example/example-app/example-app-cmd-domain/pom.xml b/example/example-app/example-app-cmd-domain/pom.xml index a4958f91..fed73aed 100644 --- a/example/example-app/example-app-cmd-domain/pom.xml +++ b/example/example-app/example-app-cmd-domain/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.32 + 3.4.33 ../pom.xml diff --git a/example/example-app/example-app-cmd-meta/pom.xml b/example/example-app/example-app-cmd-meta/pom.xml index 4059e771..a71ccb69 100644 --- a/example/example-app/example-app-cmd-meta/pom.xml +++ b/example/example-app/example-app-cmd-meta/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.32 + 3.4.33 ../pom.xml diff --git a/example/example-app/example-app-query/pom.xml b/example/example-app/example-app-query/pom.xml index 803d1bed..2b758019 100644 --- a/example/example-app/example-app-query/pom.xml +++ b/example/example-app/example-app-query/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.32 + 3.4.33 ../pom.xml diff --git a/example/example-app/pom.xml b/example/example-app/pom.xml index f73355d9..4227aab5 100644 --- a/example/example-app/pom.xml +++ b/example/example-app/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.32 + 3.4.33 ../pom.xml pom diff --git a/example/example-domain/example-domain-leave/pom.xml b/example/example-domain/example-domain-leave/pom.xml index eb3896d5..f332ad8b 100644 --- a/example/example-domain/example-domain-leave/pom.xml +++ b/example/example-domain/example-domain-leave/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.32 + 3.4.33 ../pom.xml diff --git a/example/example-domain/example-domain-user/pom.xml b/example/example-domain/example-domain-user/pom.xml index ab9b9c3d..3273f1f5 100644 --- a/example/example-domain/example-domain-user/pom.xml +++ b/example/example-domain/example-domain-user/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.32 + 3.4.33 ../pom.xml diff --git a/example/example-domain/pom.xml b/example/example-domain/pom.xml index ecaee85c..24301a72 100644 --- a/example/example-domain/pom.xml +++ b/example/example-domain/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-example - 3.4.32 + 3.4.33 ../pom.xml 4.0.0 diff --git a/example/example-infra/example-infra-flow/pom.xml b/example/example-infra/example-infra-flow/pom.xml index 86fb582a..b381a935 100644 --- a/example/example-infra/example-infra-flow/pom.xml +++ b/example/example-infra/example-infra-flow/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.32 + 3.4.33 ../pom.xml diff --git a/example/example-infra/example-infra-jpa/pom.xml b/example/example-infra/example-infra-jpa/pom.xml index 88e06217..5ca959fd 100644 --- a/example/example-infra/example-infra-jpa/pom.xml +++ b/example/example-infra/example-infra-jpa/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.32 + 3.4.33 ../pom.xml diff --git a/example/example-infra/example-infra-security/pom.xml b/example/example-infra/example-infra-security/pom.xml index b1fd9d22..1f151193 100644 --- a/example/example-infra/example-infra-security/pom.xml +++ b/example/example-infra/example-infra-security/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-infra - 3.4.32 + 3.4.33 ../pom.xml diff --git a/example/example-infra/pom.xml b/example/example-infra/pom.xml index 4e1c56e7..ff8663f0 100644 --- a/example/example-infra/pom.xml +++ b/example/example-infra/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.32 + 3.4.33 ../pom.xml pom diff --git a/example/example-interface/pom.xml b/example/example-interface/pom.xml index 7689b9fe..a569408f 100644 --- a/example/example-interface/pom.xml +++ b/example/example-interface/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.32 + 3.4.33 example-interface diff --git a/example/example-server/pom.xml b/example/example-server/pom.xml index 42885df6..89de8082 100644 --- a/example/example-server/pom.xml +++ b/example/example-server/pom.xml @@ -5,7 +5,7 @@ springboot-example com.codingapi.springboot - 3.4.32 + 3.4.33 4.0.0 diff --git a/example/pom.xml b/example/pom.xml index e601bca9..48e5b351 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -19,7 +19,7 @@ springboot-example - 3.4.32 + 3.4.33 springboot-example springboot-example project for Spring Boot diff --git a/pom.xml b/pom.xml index 008a30e2..83cf0ce3 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.codingapi.springboot springboot-parent - 3.4.32 + 3.4.33 https://github.com/codingapi/springboot-framewrok springboot-parent diff --git a/springboot-starter-data-authorization/pom.xml b/springboot-starter-data-authorization/pom.xml index 0f4ffbfd..152578fe 100644 --- a/springboot-starter-data-authorization/pom.xml +++ b/springboot-starter-data-authorization/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-parent - 3.4.32 + 3.4.33 springboot-starter-data-authorization diff --git a/springboot-starter-data-fast/pom.xml b/springboot-starter-data-fast/pom.xml index 043e621b..4e20e9f6 100644 --- a/springboot-starter-data-fast/pom.xml +++ b/springboot-starter-data-fast/pom.xml @@ -5,7 +5,7 @@ springboot-parent com.codingapi.springboot - 3.4.32 + 3.4.33 4.0.0 diff --git a/springboot-starter-flow/pom.xml b/springboot-starter-flow/pom.xml index 1e3fac06..17132254 100644 --- a/springboot-starter-flow/pom.xml +++ b/springboot-starter-flow/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.32 + 3.4.33 springboot-starter-flow diff --git a/springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/FlowNodeService.java b/springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/FlowNodeService.java index cb9513cf..58e3cfb4 100644 --- a/springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/FlowNodeService.java +++ b/springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/FlowNodeService.java @@ -176,7 +176,8 @@ private FlowNode matcherNextNode(FlowNode flowNode, boolean back) { String preCode = FlowNode.CODE_START; if (flowRecord.getPreId() != 0) { FlowRecord preRecord = flowRecordRepository.getFlowRecordById(flowRecord.getPreId()); - if (preRecord != null) { + // 退回节点时,需要过滤历史退回的记录数据 + if (preRecord != null && !preRecord.isReject()) { preCode = preRecord.getNodeCode(); while (preCode.equals(flowRecord.getNodeCode())) { preRecord = flowRecordRepository.getFlowRecordById(preRecord.getPreId()); diff --git a/springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/flow/Leave.java b/springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/flow/Leave.java index 1a19f3a1..e665189f 100644 --- a/springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/flow/Leave.java +++ b/springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/flow/Leave.java @@ -5,7 +5,9 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +@Slf4j @Setter @Getter @NoArgsConstructor @@ -25,4 +27,10 @@ public Leave(String title, int days) { this.days = days; } + + public boolean get(String key){ + log.info("get->{}",key); + return false; + } + } diff --git a/springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/test/FlowRejectTest.java b/springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/test/FlowRejectTest.java index 76ff3d7a..21473f96 100644 --- a/springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/test/FlowRejectTest.java +++ b/springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/test/FlowRejectTest.java @@ -456,4 +456,135 @@ void reject4(){ assertEquals(6, snapshots.size()); } + + + /** + * 指定撤回到发起节点,进行撤回测试 + */ + @Test + void reject5(){ + PageRequest pageRequest = PageRequest.of(0, 1000); + + User user = new User("张飞"); + userRepository.save(user); + + User dept = new User("刘备"); + userRepository.save(dept); + + User manager = new User("赵云"); + userRepository.save(manager); + + User boss = new User("诸葛亮"); + userRepository.save(boss); + + + FlowWork flowWork = FlowWorkBuilder.builder(user) + .title("请假流程") + .nodes() + .node("开始节点", "start", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher()) + .node("部门领导审批", "dept", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(dept.getUserId())) + .node("分管领导审批", "manager", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(manager.getUserId())) + .node("总经理审批", "boss", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(boss.getUserId())) + .node("结束节点", "over", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher()) + .relations() + .relation("开始节点-部门领导审批", "start", "dept") + .relation("部门领导审批-分管领导审批", "dept", "manager") + .relation("分管领导审批-总经理审批", "manager", "boss") + .relation("总经理审批-结束节点", "boss", "over") + .relation("分管领导审批-发起人", "manager", "start",new OutTrigger("def run(content){return content.getBindData().get(\"isStart\")}"),1,true) + .relation("总经理审批-发起人", "boss", "start",new OutTrigger("def run(content){return content.getBindData().get(\"isStart\")}"),1,true) + .build(); + + flowWorkRepository.save(flowWork); + + String workCode = flowWork.getCode(); + + Leave leave = new Leave("我要出去看看",6); + leaveRepository.save(leave); + + // 创建流程 + flowService.startFlow(workCode, user, leave, "发起流程"); + + // 查看我的待办 + List userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent(); + assertEquals(1, userTodos.size()); + + // 提交流程 + FlowRecord userTodo = userTodos.get(0); + flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意")); + + // 查看部门经理的待办 + List deptTodos = flowRecordRepository.findTodoByOperatorId(dept.getUserId(), pageRequest).getContent(); + assertEquals(1, deptTodos.size()); + + // 提交部门经理的审批 + FlowRecord deptTodo = deptTodos.get(0); + flowService.submitFlow(deptTodo.getId(), dept, leave, Opinion.pass("同意")); + + // 查看分管经理的待办 + List managerTodos = flowRecordRepository.findTodoByOperatorId(manager.getUserId(), pageRequest).getContent(); + assertEquals(1, managerTodos.size()); + + // 分管领导的审批 + FlowRecord managerTodo = managerTodos.get(0); + flowService.submitFlow(managerTodo.getId(), manager, leave, Opinion.pass("同意")); + + // 查看老板的待办 + List bossTodos = flowRecordRepository.findTodoByOperatorId(boss.getUserId(), pageRequest).getContent(); + assertEquals(1, bossTodos.size()); + + // 提交老板的审批 + FlowRecord bossTodo = bossTodos.get(0); + flowService.submitFlow(bossTodo.getId(), boss, leave, Opinion.reject("不同意,最多让你请假3天")); + + // 查看所有流程 + List records = flowRecordRepository.findAll(pageRequest).getContent(); + assertEquals(5, records.size()); + + managerTodos = flowRecordRepository.findTodoByOperatorId(manager.getUserId(), pageRequest).getContent(); + assertEquals(1, managerTodos.size()); + + managerTodo = managerTodos.get(0); + flowService.submitFlow(managerTodo.getId(), manager, leave, Opinion.reject("我也不同意")); + + // 用户修改确认 + userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent(); + assertEquals(1, userTodos.size()); + + // 用户调整为3天 + leave.setDays(3); + // 提交流程 + userTodo = userTodos.get(0); + flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意")); + + deptTodos = flowRecordRepository.findTodoByOperatorId(dept.getUserId(), pageRequest).getContent(); + assertEquals(1, deptTodos.size()); + + // 提交部门经理的审批 + deptTodo = deptTodos.get(0); + flowService.submitFlow(deptTodo.getId(), dept, leave, Opinion.pass("同意")); + + managerTodos = flowRecordRepository.findTodoByOperatorId(manager.getUserId(), pageRequest).getContent(); + assertEquals(1, managerTodos.size()); + + managerTodo = managerTodos.get(0); + flowService.submitFlow(managerTodo.getId(), manager, leave, Opinion.pass("同意")); + + bossTodos = flowRecordRepository.findTodoByOperatorId(boss.getUserId(), pageRequest).getContent(); + assertEquals(1, bossTodos.size()); + + bossTodo = bossTodos.get(0); + flowService.submitFlow(bossTodo.getId(), boss, leave, Opinion.pass("同意")); + + records = flowRecordRepository.findAll(pageRequest).getContent(); + assertEquals(9, records.size()); + + // 查看所有流程是否都已经结束 + assertTrue(records.stream().allMatch(FlowRecord::isFinish)); + + List snapshots = flowBindDataRepository.findAll(); + assertEquals(10, snapshots.size()); + } + + } diff --git a/springboot-starter-security/pom.xml b/springboot-starter-security/pom.xml index 81ebff51..612c5a06 100644 --- a/springboot-starter-security/pom.xml +++ b/springboot-starter-security/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.32 + 3.4.33 springboot-starter-security diff --git a/springboot-starter/pom.xml b/springboot-starter/pom.xml index 5d47f07f..2ef4bd5a 100644 --- a/springboot-starter/pom.xml +++ b/springboot-starter/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-parent - 3.4.32 + 3.4.33 springboot-starter