Skip to content

Commit 6e14073

Browse files
committed
update 3.3.62
1 parent f46eaf4 commit 6e14073

File tree

23 files changed

+214
-24
lines changed

23 files changed

+214
-24
lines changed

example/example-application/pom.xml

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

example/example-domain/pom.xml

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

example/example-infra-flow/pom.xml

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

example/example-infra-jpa/pom.xml

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

example/example-server/pom.xml

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

example/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</parent>
1818

1919
<artifactId>springboot-example</artifactId>
20-
<version>3.3.61</version>
20+
<version>3.3.62</version>
2121

2222
<name>springboot-example</name>
2323
<description>springboot-example project for Spring Boot</description>

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>3.3.61</version>
18+
<version>3.3.62</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
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-parent</artifactId>
9-
<version>3.3.61</version>
9+
<version>3.3.62</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>3.3.61</version>
8+
<version>3.3.62</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>3.3.61</version>
9+
<version>3.3.62</version>
1010
</parent>
1111

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

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/domain/FlowNode.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ public FlowRecord createRecord(long workId,
216216
String title,
217217
IFlowOperator createOperator,
218218
IFlowOperator currentOperator,
219-
BindDataSnapshot snapshot
219+
BindDataSnapshot snapshot,
220+
boolean isWaiting
220221
) {
221222

222223
// 当前操作者存在委托人时,才需要寻找委托人
@@ -239,7 +240,7 @@ public FlowRecord createRecord(long workId,
239240
record.setPreId(preId);
240241
record.setTitle(title);
241242
record.setTimeoutTime(this.loadTimeoutTime());
242-
record.setFlowType(FlowType.TODO);
243+
record.setFlowType(isWaiting? FlowType.WAITING : FlowType.TODO);
243244
record.setErrMessage(null);
244245
record.setSnapshotId(snapshot.getId());
245246
return record;

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/domain/Opinion.java

+16
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public class Opinion {
3333
public static final int RESULT_REJECT = 3;
3434
// 审批结果 抄送
3535
public static final int RESULT_CIRCULATE = 4;
36+
// 审批结果 等待
37+
public static final int RESULT_WAITING = 5;
38+
// 审批结果 唤醒
39+
public static final int RESULT_NOTIFY = 6;
3640

3741
/**
3842
* 审批意见
@@ -88,6 +92,14 @@ public static Opinion transfer(String advice) {
8892
return new Opinion(advice, RESULT_TRANSFER, TYPE_DEFAULT);
8993
}
9094

95+
public static Opinion waiting(String advice) {
96+
return new Opinion(advice, RESULT_WAITING, TYPE_DEFAULT);
97+
}
98+
99+
public static Opinion notify(String advice) {
100+
return new Opinion(advice, RESULT_NOTIFY, TYPE_DEFAULT);
101+
}
102+
91103
public static Opinion unSignAutoSuccess() {
92104
return new Opinion("非会签自动审批", RESULT_PASS, TYPE_AUTO);
93105
}
@@ -104,6 +116,10 @@ public boolean isSuccess() {
104116
return result == RESULT_PASS;
105117
}
106118

119+
public boolean isWaiting() {
120+
return result == RESULT_WAITING;
121+
}
122+
107123
public boolean isReject() {
108124
return result == RESULT_REJECT;
109125
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/em/FlowType.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ public enum FlowType {
2020
/**
2121
* 转办
2222
*/
23-
TRANSFER;
23+
TRANSFER,
24+
/**
25+
* 等待执行
26+
*/
27+
WAITING;
2428

2529

2630
public static FlowType parser(String type){

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

+7
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,13 @@ public boolean isFinish() {
321321
return this.flowStatus == FlowStatus.FINISH;
322322
}
323323

324+
/**
325+
* 是否等待
326+
*/
327+
public boolean isWaiting() {
328+
return this.flowType == FlowType.WAITING;
329+
}
330+
324331
/**
325332
* 是否是待办
326333
*/

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void bindHistoryRecords(List<FlowRecord> historyRecords) {
4040
* 解析当前的审批方向
4141
*/
4242
public void loadFlowSourceDirection() {
43-
if (opinion.isSuccess()) {
43+
if (opinion.isSuccess() || opinion.isWaiting()) {
4444
flowSourceDirection = FlowSourceDirection.PASS;
4545
}
4646
if (opinion.isReject()) {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private List<FlowRecord> createNextRecord() {
262262
String recordTitle = nextNode.generateTitle(flowSession);
263263
recordList = new ArrayList<>();
264264
for (IFlowOperator operator : operators) {
265-
FlowRecord record = nextNode.createRecord(workId, flowWork.getCode(), processId, preId, recordTitle, createOperator, operator, snapshot);
265+
FlowRecord record = nextNode.createRecord(workId, flowWork.getCode(), processId, preId, recordTitle, createOperator, operator, snapshot, opinion.isWaiting());
266266
recordList.add(record);
267267
}
268268
}
@@ -292,7 +292,7 @@ private List<FlowRecord> errMatcher(FlowNode currentNode, IFlowOperator currentO
292292
for (IFlowOperator operator : operators) {
293293
FlowSession content = new FlowSession(flowRecord, flowWork, currentNode, createOperator, operator, snapshot.toBindData(), opinion, historyRecords);
294294
String recordTitle = currentNode.generateTitle(content);
295-
FlowRecord record = currentNode.createRecord(flowWork.getId(), flowWork.getCode(), processId, preId, recordTitle, createOperator, operator, snapshot);
295+
FlowRecord record = currentNode.createRecord(flowWork.getId(), flowWork.getCode(), processId, preId, recordTitle, createOperator, operator, snapshot,opinion.isWaiting());
296296
recordList.add(record);
297297
}
298298
return recordList;
@@ -310,7 +310,7 @@ private List<FlowRecord> errMatcher(FlowNode currentNode, IFlowOperator currentO
310310
if (!matcherOperators.isEmpty()) {
311311
for (IFlowOperator matcherOperator : matcherOperators) {
312312
String recordTitle = node.generateTitle(content);
313-
FlowRecord record = node.createRecord(flowWork.getId(), flowWork.getCode(), processId, preId, recordTitle, createOperator, matcherOperator, snapshot);
313+
FlowRecord record = node.createRecord(flowWork.getId(), flowWork.getCode(), processId, preId, recordTitle, createOperator, matcherOperator, snapshot, opinion.isWaiting());
314314
recordList.add(record);
315315
}
316316
}

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

+11
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,17 @@ public FlowResult submitFlow(long recordId, IFlowOperator currentOperator, IBind
229229
}
230230

231231

232+
/**
233+
* 唤醒流程
234+
* @param processId 流程实例id
235+
* @param currentOperator 当前操作者
236+
*/
237+
public void notifyFlow(String processId,IFlowOperator currentOperator) {
238+
FlowNotifyService flowNotifyService = new FlowNotifyService(processId, currentOperator, flowServiceRepositoryHolder);
239+
flowNotifyService.notifyFlow();
240+
}
241+
242+
232243
/**
233244
* 自定义事件
234245
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.codingapi.springboot.flow.service.impl;
2+
3+
import com.codingapi.springboot.flow.bind.BindDataSnapshot;
4+
import com.codingapi.springboot.flow.domain.FlowWork;
5+
import com.codingapi.springboot.flow.em.FlowType;
6+
import com.codingapi.springboot.flow.event.FlowApprovalEvent;
7+
import com.codingapi.springboot.flow.record.FlowRecord;
8+
import com.codingapi.springboot.flow.repository.FlowBindDataRepository;
9+
import com.codingapi.springboot.flow.repository.FlowProcessRepository;
10+
import com.codingapi.springboot.flow.repository.FlowRecordRepository;
11+
import com.codingapi.springboot.flow.repository.FlowWorkRepository;
12+
import com.codingapi.springboot.flow.service.FlowServiceRepositoryHolder;
13+
import com.codingapi.springboot.flow.user.IFlowOperator;
14+
import com.codingapi.springboot.framework.event.EventPusher;
15+
import org.springframework.transaction.annotation.Transactional;
16+
17+
import java.util.List;
18+
19+
@Transactional
20+
public class FlowNotifyService {
21+
22+
private final String processId;
23+
private final IFlowOperator currentOperator;
24+
private final FlowRecordRepository flowRecordRepository;
25+
private final FlowBindDataRepository flowBindDataRepository;
26+
private final FlowWorkRepository flowWorkRepository;
27+
private final FlowProcessRepository flowProcessRepository;
28+
29+
30+
public FlowNotifyService(String processId, IFlowOperator currentOperator, FlowServiceRepositoryHolder flowServiceRepositoryHolder) {
31+
this.processId = processId;
32+
this.currentOperator = currentOperator;
33+
this.flowRecordRepository = flowServiceRepositoryHolder.getFlowRecordRepository();
34+
this.flowBindDataRepository = flowServiceRepositoryHolder.getFlowBindDataRepository();
35+
this.flowWorkRepository = flowServiceRepositoryHolder.getFlowWorkRepository();
36+
this.flowProcessRepository = flowServiceRepositoryHolder.getFlowProcessRepository();
37+
}
38+
39+
40+
/**
41+
* 获取流程设计对象
42+
*/
43+
public FlowWork loadFlowWork(FlowRecord flowRecord) {
44+
FlowWork flowWork = flowProcessRepository.getFlowWorkByProcessId(flowRecord.getProcessId());
45+
if (flowWork == null) {
46+
flowWork = flowWorkRepository.getFlowWorkByCode(flowRecord.getWorkCode());
47+
}
48+
if (flowWork == null) {
49+
throw new IllegalArgumentException("flow work not found");
50+
}
51+
flowWork.enableValidate();
52+
53+
return flowWork;
54+
}
55+
56+
/**
57+
* 流程通知
58+
*/
59+
public void notifyFlow() {
60+
List<FlowRecord> flowRecords = flowRecordRepository.findFlowRecordByProcessId(processId);
61+
List<FlowRecord> waitingRecords = flowRecords.stream().filter(FlowRecord::isWaiting).toList();
62+
for (FlowRecord flowRecord : waitingRecords) {
63+
if (flowRecord.isOperator(currentOperator)) {
64+
flowRecord.setFlowType(FlowType.TODO);
65+
flowRecordRepository.update(flowRecord);
66+
67+
BindDataSnapshot snapshot = flowBindDataRepository.getBindDataSnapshotById(flowRecord.getSnapshotId());
68+
69+
FlowWork flowWork = this.loadFlowWork(flowRecord);
70+
71+
EventPusher.push(new FlowApprovalEvent(FlowApprovalEvent.STATE_TODO,
72+
flowRecord,
73+
flowRecord.getCurrentOperator(),
74+
flowWork,
75+
snapshot.toBindData()
76+
), true);
77+
}
78+
}
79+
}
80+
}

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private void updateFinishFlowRecord() {
208208
}
209209

210210
// 保存流程记录
211-
private void saveFlowRecords(List<FlowRecord> flowRecords) {
211+
private void saveNextFlowRecords(List<FlowRecord> flowRecords) {
212212
flowServiceRepositoryHolder.getFlowRecordRepository().save(flowRecords);
213213
}
214214

@@ -312,15 +312,17 @@ private FlowResult submitCurrentFlow() {
312312
}
313313

314314
// 保存流程记录
315-
this.saveFlowRecords(nextRecords);
315+
this.saveNextFlowRecords(nextRecords);
316316

317317
// 推送审批事件消息
318318
int eventState = flowSourceDirection == FlowSourceDirection.PASS ? FlowApprovalEvent.STATE_PASS : FlowApprovalEvent.STATE_REJECT;
319319
this.pushEvent(flowRecord, eventState);
320320

321321
// 推送待办事件消息
322322
for (FlowRecord record : nextRecords) {
323-
this.pushEvent(record, FlowApprovalEvent.STATE_TODO);
323+
if(record.isTodo()) {
324+
this.pushEvent(record, FlowApprovalEvent.STATE_TODO);
325+
}
324326
}
325327

326328
return new FlowResult(flowWork, nextRecords);

0 commit comments

Comments
 (0)