Skip to content

Commit d0c097e

Browse files
committed
fix skipIfSameApprover reject bug
1 parent b750706 commit d0c097e

File tree

11 files changed

+98
-8
lines changed

11 files changed

+98
-8
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<groupId>com.codingapi.springboot</groupId>
1717
<artifactId>springboot-parent</artifactId>
18-
<version>2.9.34</version>
18+
<version>2.9.35</version>
1919

2020
<url>https://github.com/codingapi/springboot-framewrok</url>
2121
<name>springboot-parent</name>

springboot-starter-data-authorization/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.9.34</version>
9+
<version>2.9.35</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-data-authorization</artifactId>

springboot-starter-data-fast/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>2.9.34</version>
8+
<version>2.9.35</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-flow/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.9.34</version>
9+
<version>2.9.35</version>
1010
</parent>
1111

1212
<name>springboot-starter-flow</name>

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/pojo/FlowResult.java

+3
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ public boolean isOver() {
4141
return records.stream().allMatch(FlowRecord::isOverNode);
4242
}
4343

44+
public boolean isStart() {
45+
return records.stream().allMatch(FlowRecord::isStartNode);
46+
}
4447
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/record/FlowRecord.java

+4
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,8 @@ public boolean isStartRecord() {
451451
public boolean isOverNode() {
452452
return this.nodeCode.equals(FlowNode.CODE_OVER);
453453
}
454+
455+
public boolean isStartNode() {
456+
return this.nodeCode.equals(FlowNode.CODE_START);
457+
}
454458
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/impl/FlowSubmitService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private void pushEvent(FlowRecord flowRecord, int eventState) {
231231
*/
232232
public FlowResult submitFlow() {
233233
FlowResult flowResult = this.submitCurrentFlow();
234-
if (this.isSkipIfSameApprover() && !flowResult.isOver()) {
234+
if (this.isSkipIfSameApprover() && !flowResult.isOver() && !flowResult.isStart()) {
235235
List<FlowRecord> flowRecords = flowResult.matchRecordByOperator(currentOperator);
236236
FlowResult result = flowResult;
237237
if (!flowRecords.isEmpty()) {

springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/test/FlowTest.java

+83
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,89 @@ void postponedAndUrgeTest() {
713713

714714
}
715715

716+
/**
717+
* 一直退回的测试
718+
*/
719+
@Test
720+
void rejectAllTest() {
721+
PageRequest pageRequest = PageRequest.of(0, 1000);
722+
723+
User user = new User("张飞");
724+
userRepository.save(user);
725+
726+
User dept = new User("刘备");
727+
userRepository.save(dept);
728+
729+
User boss = new User("诸葛亮");
730+
userRepository.save(boss);
731+
732+
FlowWork flowWork = FlowWorkBuilder.builder(user)
733+
.title("请假流程")
734+
.skipIfSameApprover(true)
735+
.nodes()
736+
.node("开始节点", "start", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
737+
.node("部门领导审批", "dept", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(user.getUserId()))
738+
.node("办公室领导审批", "office", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(dept.getUserId()))
739+
.node("总经理审批", "manager", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(boss.getUserId()))
740+
.node("结束节点", "over", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
741+
.relations()
742+
.relation("部门领导审批", "start", "dept")
743+
.relation("办公室领导审批", "dept", "office")
744+
.relation("总经理审批", "office", "manager")
745+
.relation("结束节点", "manager", "over")
746+
.build();
747+
748+
flowWorkRepository.save(flowWork);
749+
750+
String workCode = flowWork.getCode();
751+
752+
Leave leave = new Leave("我要出去看看");
753+
leaveRepository.save(leave);
754+
755+
// 创建流程
756+
flowService.startFlow(workCode, user, leave, "发起流程");
757+
758+
// 查看我的待办
759+
List<FlowRecord> userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
760+
assertEquals(1, userTodos.size());
761+
762+
// 提交流程
763+
FlowRecord userTodo = userTodos.get(0);
764+
765+
// 查看流程详情
766+
FlowDetail flowDetail = flowService.detail(userTodo.getId());
767+
assertEquals("我要出去看看", ((Leave) flowDetail.getBindData()).getTitle());
768+
assertTrue(flowDetail.getFlowRecord().isUnRead());
769+
770+
771+
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意"));
772+
773+
// 查看部门经理的待办
774+
List<FlowRecord> deptTodos = flowRecordRepository.findTodoByOperatorId(dept.getUserId(), pageRequest).getContent();
775+
assertEquals(1, deptTodos.size());
776+
777+
// 提交部门经理的审批
778+
FlowRecord deptTodo = deptTodos.get(0);
779+
flowService.submitFlow(deptTodo.getId(), dept, leave, Opinion.reject("不同意"));
780+
781+
userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
782+
assertEquals(1, userTodos.size());
783+
784+
// 提交流程
785+
userTodo = userTodos.get(0);
786+
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.reject("不同意"));
787+
788+
userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
789+
assertEquals(1, userTodos.size());
790+
791+
userTodo = userTodos.get(0);
792+
793+
System.out.println(userTodo.getNodeCode());
794+
795+
assertEquals("start", userTodo.getNodeCode());
796+
}
797+
798+
716799
/**
717800
* 部门拒绝再提交测试
718801
*/

springboot-starter-security/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>2.9.34</version>
9+
<version>2.9.35</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security</artifactId>

springboot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-parent</artifactId>
8-
<version>2.9.34</version>
8+
<version>2.9.35</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
------------------------------------------------------
2-
CodingApi SpringBoot-Starter 2.9.34
2+
CodingApi SpringBoot-Starter 2.9.35
33
springboot version (${spring-boot.version})
44
------------------------------------------------------

0 commit comments

Comments
 (0)