Skip to content

Commit 63ce4f3

Browse files
committed
fix flow service
1 parent c88ed6f commit 63ce4f3

File tree

28 files changed

+221
-126
lines changed

28 files changed

+221
-126
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.47</version>
8+
<version>3.3.48</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.47</version>
8+
<version>3.3.48</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.47</version>
8+
<version>3.3.48</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.47</version>
8+
<version>3.3.48</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.47</version>
8+
<version>3.3.48</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.47</version>
20+
<version>3.3.48</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.47</version>
18+
<version>3.3.48</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.47</version>
9+
<version>3.3.48</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.47</version>
8+
<version>3.3.48</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.47</version>
9+
<version>3.3.48</version>
1010
</parent>
1111

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

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/build/FlowWorkBuilder.java

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public FlowWorkBuilder postponedMax(int postponedMax) {
4141
return this;
4242
}
4343

44+
public FlowWorkBuilder skipIfSameApprover(boolean skipIfSameApprover) {
45+
this.work.setSkipIfSameApprover(skipIfSameApprover);
46+
return this;
47+
}
48+
4449
public FlowWorkBuilder title(String title) {
4550
this.work.setTitle(title);
4651
return this;

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

+7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ public class FlowWork {
6060
*/
6161
private boolean enable;
6262

63+
/**
64+
* 是否跳过相同审批人,默认为false
65+
*/
66+
@Setter
67+
private boolean skipIfSameApprover;
68+
6369
/**
6470
* 最大延期次数
6571
*/
@@ -226,6 +232,7 @@ public FlowWorkSerializable toSerializable() {
226232
createTime,
227233
updateTime,
228234
enable,
235+
skipIfSameApprover,
229236
postponedMax,
230237
schema,
231238
nodes.stream().map(FlowNode::toSerializable).collect(Collectors.toCollection(ArrayList::new)),

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/serializable/FlowWorkSerializable.java

+7
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ public class FlowWorkSerializable implements Serializable {
6868
@Setter
6969
private boolean enable;
7070

71+
/**
72+
* 是否跳过相同审批人,默认为false
73+
*/
74+
@Setter
75+
private boolean skipIfSameApprover;
76+
7177
/**
7278
* 最大延期次数
7379
*/
@@ -139,6 +145,7 @@ public FlowWork toFlowWork(FlowOperatorRepository flowOperatorRepository) {
139145
createTime,
140146
updateTime,
141147
enable,
148+
skipIfSameApprover,
142149
postponedMax,
143150
flowNodes,
144151
relations.stream().map((item) -> item.toFlowRelation(flowNodes)).toList(),

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

+6-13
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
public class FlowRecordVerifyService {
1717

1818
// constructor params
19-
private final long recordId;
2019
@Getter
2120
private final IFlowOperator currentOperator;
2221

@@ -30,7 +29,7 @@ public class FlowRecordVerifyService {
3029
@Getter
3130
private FlowNode flowNode;
3231
@Getter
33-
private FlowRecord flowRecord;
32+
private final FlowRecord flowRecord;
3433

3534
public FlowRecordVerifyService(FlowRecordRepository flowRecordRepository,
3635
FlowProcessRepository flowProcessRepository,
@@ -40,7 +39,11 @@ public FlowRecordVerifyService(FlowRecordRepository flowRecordRepository,
4039
this.flowProcessRepository = flowProcessRepository;
4140

4241
this.currentOperator = currentOperator;
43-
this.recordId = recordId;
42+
FlowRecord flowRecord = flowRecordRepository.getFlowRecordById(recordId);
43+
if (flowRecord == null) {
44+
throw new IllegalArgumentException("flow record not found");
45+
}
46+
this.flowRecord = flowRecord;
4447
}
4548

4649

@@ -132,16 +135,6 @@ public void verifyTargetOperatorIsNotCurrentOperator(IFlowOperator targetOperato
132135
}
133136

134137

135-
/**
136-
* 获取流程记录对象
137-
*/
138-
public void loadFlowRecord() {
139-
FlowRecord flowRecord = flowRecordRepository.getFlowRecordById(recordId);
140-
if (flowRecord == null) {
141-
throw new IllegalArgumentException("flow record not found");
142-
}
143-
this.flowRecord = flowRecord;
144-
}
145138

146139
/**
147140
* 获取流程设计对象

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.codingapi.springboot.flow.bind.IBindData;
44
import com.codingapi.springboot.flow.domain.Opinion;
55
import com.codingapi.springboot.flow.pojo.FlowDetail;
6-
import com.codingapi.springboot.flow.pojo.FlowSubmitResult;
76
import com.codingapi.springboot.flow.pojo.FlowResult;
7+
import com.codingapi.springboot.flow.pojo.FlowSubmitResult;
88
import com.codingapi.springboot.flow.repository.*;
99
import com.codingapi.springboot.flow.result.MessageResult;
1010
import com.codingapi.springboot.flow.service.impl.*;
@@ -21,7 +21,6 @@ public class FlowService {
2121

2222
private final FlowDetailService flowDetailService;
2323
private final FlowStartService flowStartService;
24-
private final FlowSubmitService flowSubmitService;
2524
private final FlowCustomEventService flowCustomEventService;
2625
private final FlowRecallService flowRecallService;
2726
private final FlowTrySubmitService flowTrySubmitService;
@@ -30,16 +29,18 @@ public class FlowService {
3029
private final FlowPostponedService flowPostponedService;
3130
private final FlowUrgeService flowUrgeService;
3231

32+
private final FlowServiceRepositoryHolder flowServiceRepositoryHolder;
33+
3334

3435
public FlowService(FlowWorkRepository flowWorkRepository,
3536
FlowRecordRepository flowRecordRepository,
3637
FlowBindDataRepository flowBindDataRepository,
3738
FlowOperatorRepository flowOperatorRepository,
3839
FlowProcessRepository flowProcessRepository,
3940
FlowBackupRepository flowBackupRepository) {
41+
this.flowServiceRepositoryHolder = new FlowServiceRepositoryHolder(flowWorkRepository, flowRecordRepository, flowBindDataRepository, flowOperatorRepository, flowProcessRepository, flowBackupRepository);
4042
this.flowDetailService = new FlowDetailService(flowWorkRepository, flowRecordRepository, flowBindDataRepository, flowOperatorRepository, flowProcessRepository);
4143
this.flowStartService = new FlowStartService(flowWorkRepository, flowRecordRepository, flowBindDataRepository, flowOperatorRepository, flowProcessRepository, flowBackupRepository);
42-
this.flowSubmitService = new FlowSubmitService(flowRecordRepository, flowBindDataRepository, flowOperatorRepository, flowProcessRepository);
4344
this.flowCustomEventService = new FlowCustomEventService(flowRecordRepository, flowProcessRepository);
4445
this.flowRecallService = new FlowRecallService(flowRecordRepository, flowProcessRepository);
4546
this.flowTrySubmitService = new FlowTrySubmitService(flowRecordRepository, flowBindDataRepository, flowOperatorRepository, flowProcessRepository, flowWorkRepository, flowBackupRepository);
@@ -209,7 +210,8 @@ public FlowSubmitResult trySubmitFlow(String workCode, IFlowOperator currentOper
209210
* @param opinion 审批意见
210211
*/
211212
public FlowResult submitFlow(long recordId, IFlowOperator currentOperator, IBindData bindData, Opinion opinion) {
212-
return flowSubmitService.submitFlow(recordId, currentOperator, bindData, opinion);
213+
FlowSubmitService flowSubmitService = new FlowSubmitService(recordId, currentOperator, bindData, opinion, flowServiceRepositoryHolder);
214+
return flowSubmitService.submitFlow();
213215
}
214216

215217

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.codingapi.springboot.flow.service;
2+
3+
import com.codingapi.springboot.flow.repository.*;
4+
import lombok.Getter;
5+
6+
@Getter
7+
public class FlowServiceRepositoryHolder {
8+
9+
private final FlowWorkRepository flowWorkRepository;
10+
private final FlowRecordRepository flowRecordRepository;
11+
private final FlowBindDataRepository flowBindDataRepository;
12+
private final FlowOperatorRepository flowOperatorRepository;
13+
private final FlowProcessRepository flowProcessRepository;
14+
private final FlowBackupRepository flowBackupRepository;
15+
16+
public FlowServiceRepositoryHolder(FlowWorkRepository flowWorkRepository,
17+
FlowRecordRepository flowRecordRepository,
18+
FlowBindDataRepository flowBindDataRepository,
19+
FlowOperatorRepository flowOperatorRepository,
20+
FlowProcessRepository flowProcessRepository,
21+
FlowBackupRepository flowBackupRepository){
22+
this.flowWorkRepository = flowWorkRepository;
23+
this.flowRecordRepository = flowRecordRepository;
24+
this.flowBindDataRepository = flowBindDataRepository;
25+
this.flowOperatorRepository = flowOperatorRepository;
26+
this.flowProcessRepository = flowProcessRepository;
27+
this.flowBackupRepository = flowBackupRepository;
28+
}
29+
}

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

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public class FlowCustomEventService {
3636
public MessageResult customFlowEvent(long recordId, IFlowOperator currentOperator, String buttonId, IBindData bindData, Opinion opinion) {
3737
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowRecordRepository, flowProcessRepository, recordId, currentOperator);
3838

39-
// 加载流程
40-
flowRecordVerifyService.loadFlowRecord();
4139
// 验证流程的提交状态
4240
flowRecordVerifyService.verifyFlowRecordSubmitState();
4341
// 验证当前操作者

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

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public FlowDetail detail(long recordId, IFlowOperator currentOperator) {
3939
flowProcessRepository,
4040
recordId, currentOperator);
4141

42-
flowRecordVerifyService.loadFlowRecord();
4342
flowRecordVerifyService.setFlowRecordRead();
4443
flowRecordVerifyService.loadFlowWork();
4544

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

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public void postponed(long recordId, IFlowOperator currentOperator, long time) {
2727
flowProcessRepository,
2828
recordId, currentOperator);
2929

30-
flowRecordVerifyService.loadFlowRecord();
3130
flowRecordVerifyService.verifyFlowRecordSubmitState();
3231
flowRecordVerifyService.verifyFlowRecordCurrentOperator();
3332
flowRecordVerifyService.loadFlowWork();

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

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public void recall(long recordId, IFlowOperator currentOperator) {
3030
flowProcessRepository,
3131
recordId, currentOperator);
3232

33-
flowRecordVerifyService.loadFlowRecord();
3433
flowRecordVerifyService.verifyFlowRecordCurrentOperator();
3534
flowRecordVerifyService.loadFlowWork();
3635
flowRecordVerifyService.loadFlowNode();

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

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public void save(long recordId, IFlowOperator currentOperator, IBindData bindDat
3030
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowRecordRepository,
3131
flowProcessRepository,
3232
recordId, currentOperator);
33-
flowRecordVerifyService.loadFlowRecord();
3433
flowRecordVerifyService.verifyFlowRecordSubmitState();
3534
flowRecordVerifyService.verifyFlowRecordCurrentOperator();
3635
flowRecordVerifyService.loadFlowWork();

0 commit comments

Comments
 (0)