Skip to content

Commit ac787c1

Browse files
committed
fix reject back operator
1 parent 6ee0ebe commit ac787c1

File tree

9 files changed

+126
-38
lines changed

9 files changed

+126
-38
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
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.15</version>
18+
<version>2.9.16</version>
1919

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

springboot-starter-data-authorization/pom.xml

Lines changed: 1 addition & 1 deletion
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.15</version>
9+
<version>2.9.16</version>
1010
</parent>
1111

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

springboot-starter-data-fast/pom.xml

Lines changed: 1 addition & 1 deletion
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.15</version>
8+
<version>2.9.16</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-flow/pom.xml

Lines changed: 1 addition & 1 deletion
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.15</version>
9+
<version>2.9.16</version>
1010
</parent>
1111

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

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import lombok.Getter;
1919

2020
import java.util.ArrayList;
21+
import java.util.Collections;
2122
import java.util.List;
2223
import java.util.stream.Collectors;
2324

@@ -29,6 +30,7 @@ public class FlowNodeService {
2930
@Getter
3031
private FlowNode nextNode;
3132
private IFlowOperator nextOperator;
33+
private IFlowOperator backOperator;
3234

3335
private final FlowOperatorRepository flowOperatorRepository;
3436
private final FlowRecordRepository flowRecordRepository;
@@ -116,6 +118,7 @@ public void loadDefaultBackNode(long parentRecordId) {
116118
}
117119
this.nextNode = nextNode;
118120
this.nextOperator = flowOperator;
121+
this.backOperator = flowOperator;
119122
}
120123

121124

@@ -138,6 +141,7 @@ public void loadCustomBackNode(FlowNode flowNode, long parentRecordId) {
138141
}
139142
this.nextNode = nextNode;
140143
this.nextOperator = flowOperator;
144+
this.backOperator = flowOperator;
141145
}
142146

143147

@@ -239,10 +243,16 @@ private List<FlowRecord> createNextRecord() {
239243
historyRecords);
240244

241245
long workId = flowWork.getId();
242-
List<? extends IFlowOperator> operators = nextNode.loadFlowNodeOperator(flowSession, flowOperatorRepository);
246+
List<? extends IFlowOperator> operators = null;
247+
if (this.backOperator == null) {
248+
operators = nextNode.loadFlowNodeOperator(flowSession, flowOperatorRepository);
249+
} else {
250+
operators = Collections.singletonList(this.backOperator);
251+
}
243252
List<Long> customOperatorIds = opinion.getOperatorIds();
244253
if (customOperatorIds != null && !customOperatorIds.isEmpty()) {
245-
operators = operators.stream().filter(operator -> customOperatorIds.contains(operator.getUserId())).collect(Collectors.toList());
254+
operators = operators.stream()
255+
.filter(operator -> customOperatorIds.contains(operator.getUserId())).collect(Collectors.toList());
246256
if (operators.size() != customOperatorIds.size()) {
247257
throw new IllegalArgumentException("operator not match.");
248258
}

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

Lines changed: 107 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,113 @@ void unSignTest(){
124124
}
125125

126126

127+
/**
128+
* 多人非会签拒绝测试
129+
*/
130+
@Test
131+
void unSignRejectTest(){
132+
PageRequest pageRequest = PageRequest.of(0, 1000);
133+
134+
User caocao = new User("曹操");
135+
userRepository.save(caocao);
136+
User lvBu = new User("吕布");
137+
userRepository.save(lvBu);
138+
User zhaoYun = new User("赵云");
139+
userRepository.save(zhaoYun);
140+
141+
User user = new User("张飞");
142+
userRepository.save(user);
143+
144+
User dept = new User("刘备");
145+
userRepository.save(dept);
146+
147+
User boss = new User("诸葛亮");
148+
userRepository.save(boss);
149+
150+
FlowWork flowWork = FlowWorkBuilder.builder(user)
151+
.title("请假流程")
152+
.nodes()
153+
.node("开始节点", "start", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
154+
.node("部门领导审批", "dept", "default", ApprovalType.UN_SIGN,
155+
OperatorMatcher.specifyOperatorMatcher(dept.getUserId(),caocao.getUserId(),lvBu.getUserId(),zhaoYun.getUserId()))
156+
.node("总经理审批", "manager", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(boss.getUserId()))
157+
.node("结束节点", "over", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
158+
.relations()
159+
.relation("部门领导审批", "start", "dept")
160+
.relation("总经理审批", "dept", "manager")
161+
.relation("结束节点", "manager", "over")
162+
.build();
163+
164+
flowWorkRepository.save(flowWork);
165+
166+
String workCode = flowWork.getCode();
167+
168+
Leave leave = new Leave("我要出去看看");
169+
leaveRepository.save(leave);
170+
171+
// 创建流程
172+
flowService.startFlow(workCode, user, leave, "发起流程");
173+
174+
// 查看我的待办
175+
List<FlowRecord> userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
176+
assertEquals(1, userTodos.size());
177+
178+
// 提交流程
179+
FlowRecord userTodo = userTodos.get(0);
180+
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意").specify(lvBu.getUserId()));
181+
182+
// 查看部门经理的待办
183+
List<FlowRecord> deptTodos = flowRecordRepository.findTodoByOperatorId(dept.getUserId(), pageRequest).getContent();
184+
assertEquals(0, deptTodos.size());
185+
186+
// 查看部门刘备经理的待办
187+
List<FlowRecord> lvBuTodos = flowRecordRepository.findTodoByOperatorId(lvBu.getUserId(), pageRequest).getContent();
188+
assertEquals(1, lvBuTodos.size());
189+
190+
// 提交部门经理的审批
191+
FlowRecord lvBuTodo = lvBuTodos.get(0);
192+
flowService.submitFlow(lvBuTodo.getId(), lvBu, leave, Opinion.pass("同意"));
193+
194+
// 查看总经理的待办
195+
List<FlowRecord> bossTodos = flowRecordRepository.findTodoByOperatorId(boss.getUserId(), pageRequest).getContent();
196+
assertEquals(1, bossTodos.size());
197+
198+
// 提交总经理的审批
199+
FlowRecord bossTodo = bossTodos.get(0);
200+
flowService.submitFlow(bossTodo.getId(), boss, leave, Opinion.reject("不同意"));
201+
202+
// 查看所有流程
203+
List<FlowRecord> records = flowRecordRepository.findAll(pageRequest).getContent();;
204+
assertEquals(4, records.size());
205+
206+
lvBuTodos = flowRecordRepository.findTodoByOperatorId(lvBu.getUserId(), pageRequest).getContent();
207+
assertEquals(1, lvBuTodos.size());
208+
209+
// 提交部门经理的审批
210+
lvBuTodo = lvBuTodos.get(0);
211+
flowService.submitFlow(lvBuTodo.getId(), lvBu, leave, Opinion.pass("同意"));
212+
213+
214+
bossTodos = flowRecordRepository.findTodoByOperatorId(boss.getUserId(), pageRequest).getContent();
215+
assertEquals(1, bossTodos.size());
216+
217+
// 提交总经理的审批
218+
bossTodo = bossTodos.get(0);
219+
flowService.submitFlow(bossTodo.getId(), boss, leave, Opinion.pass("行吧"));
220+
221+
userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
222+
assertEquals(0, userTodos.size());
223+
224+
records = flowRecordRepository.findAll(pageRequest).getContent();
225+
assertEquals(5, records.size());
226+
// 查看所有流程是否都已经结束
227+
assertTrue(records.stream().allMatch(FlowRecord::isFinish));
228+
229+
List<BindDataSnapshot> snapshots = flowBindDataRepository.findAll();
230+
assertEquals(6, snapshots.size());
231+
232+
}
233+
127234

128235
/**
129236
* 多人会签测试
@@ -495,35 +602,6 @@ void signTrySubmitTest(){
495602
List<FlowRecord> bossTodos = flowRecordRepository.findTodoByOperatorId(boss.getUserId(), pageRequest).getContent();
496603
assertEquals(1, bossTodos.size());
497604

498-
// // 查看部门经理 吕布 的待办
499-
// List<FlowRecord> lvbuTodos = flowRecordRepository.findTodoByOperatorId(lvBu.getUserId(), pageRequest).getContent();
500-
// assertEquals(1, lvbuTodos.size());
501-
//
502-
// // 提交部门经理 吕布 的审批
503-
// FlowRecord lvbuTodo = lvbuTodos.get(0);
504-
// flowService.submitFlow(lvbuTodo.getId(), lvBu, leave, Opinion.pass("吕布同意"));
505-
//
506-
//
507-
// // 查看部门经理 赵云 的待办
508-
// List<FlowRecord> zhaoYunTodos = flowRecordRepository.findTodoByOperatorId(zhaoYun.getUserId(), pageRequest).getContent();
509-
// assertEquals(1, zhaoYunTodos.size());
510-
//
511-
// // 提交部门经理 赵云 的审批
512-
// FlowRecord zhaoYunTodo = zhaoYunTodos.get(0);
513-
// flowService.submitFlow(zhaoYunTodo.getId(), zhaoYun, leave, Opinion.pass("赵云同意"));
514-
//
515-
//
516-
// // 查看部门经理 曹操 的待办
517-
// List<FlowRecord> caocaoTodos = flowRecordRepository.findTodoByOperatorId(caocao.getUserId(), pageRequest).getContent();
518-
// assertEquals(1, caocaoTodos.size());
519-
//
520-
// // 提交部门经理 曹操 的审批
521-
// FlowRecord caocaoTodo = caocaoTodos.get(0);
522-
// flowService.submitFlow(caocaoTodo.getId(), caocao, leave, Opinion.pass("曹操同意"));
523-
//
524-
// bossTodos = flowRecordRepository.findTodoByOperatorId(boss.getUserId(), pageRequest).getContent();
525-
// assertEquals(1, bossTodos.size());
526-
527605
// 提交总经理的审批
528606
FlowRecord bossTodo = bossTodos.get(0);
529607
flowService.submitFlow(bossTodo.getId(), boss, leave, Opinion.pass("同意"));

springboot-starter-security/pom.xml

Lines changed: 1 addition & 1 deletion
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.15</version>
9+
<version>2.9.16</version>
1010
</parent>
1111

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

springboot-starter/pom.xml

Lines changed: 1 addition & 1 deletion
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.15</version>
8+
<version>2.9.16</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
------------------------------------------------------
2-
CodingApi SpringBoot-Starter 2.9.15
2+
CodingApi SpringBoot-Starter 2.9.16
33
springboot version (${spring-boot.version})
44
------------------------------------------------------

0 commit comments

Comments
 (0)