Skip to content

Commit 61e2fe2

Browse files
committed
fix trySubmit
1 parent b9569fc commit 61e2fe2

File tree

15 files changed

+73
-26
lines changed

15 files changed

+73
-26
lines changed

admin-ui/src/pages/flow/work/index.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ModalForm,
66
PageContainer,
77
ProForm,
8-
ProFormDigit,
8+
ProFormDigit, ProFormSwitch,
99
ProFormText, ProFormTextArea,
1010
ProTable
1111
} from "@ant-design/pro-components";
@@ -254,6 +254,12 @@ const FlowPage = () => {
254254
]}
255255
/>
256256

257+
<ProFormSwitch
258+
name={"skipIfSameApprover"}
259+
tooltip={"是否跳过相同审批人,默认为否"}
260+
label={"是否跳过相同审批人"}
261+
/>
262+
257263
</ModalForm>
258264

259265

example/example-application/src/main/java/com/codingapi/example/pojo/cmd/FlowWorkCmd.java

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static class CreateRequest{
1616
private String code;
1717
private String description;
1818
private int postponedMax;
19+
private boolean skipIfSameApprover;
1920

2021

2122
public String getUsername(){

example/example-application/src/main/java/com/codingapi/example/router/FlowWorkRouter.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,21 @@ public void save(FlowWorkCmd.CreateRequest request) {
2929
User user = userRepository.getUserByUsername(request.getUsername());
3030
long id = request.getId();
3131
if (id == 0) {
32-
FlowWork flowWork = new FlowWork(request.getCode(),request.getTitle(), request.getDescription(), request.getPostponedMax(), user);
32+
FlowWork flowWork = new FlowWork(
33+
request.getCode(),
34+
request.getTitle(),
35+
request.getDescription(),
36+
request.isSkipIfSameApprover(),
37+
request.getPostponedMax(),
38+
user);
3339
flowWorkRepository.save(flowWork);
3440
} else {
3541
FlowWorkEntity flowWork = flowWorkEntityRepository.getFlowWorkEntityById(id);
3642
flowWork.setTitle(request.getTitle());
3743
flowWork.setCode(request.getCode());
3844
flowWork.setDescription(request.getDescription());
3945
flowWork.setPostponedMax(request.getPostponedMax());
46+
flowWork.setSkipIfSameApprover(request.isSkipIfSameApprover());
4047
flowWork.setUpdateTime(System.currentTimeMillis());
4148
flowWorkEntityRepository.save(flowWork);
4249
}

example/example-infra-flow/src/main/java/com/codingapi/example/repository/FlowProcessRepositoryImpl.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public FlowWork getFlowWorkByProcessId(String processId) {
3131
return null;
3232
}
3333
FlowBackup flowBackup = flowBackupRepository.getFlowBackupById(flowProcess.getBackupId());
34-
return flowBackup.resume(flowOperatorRepository);
34+
if(flowBackup!=null) {
35+
return flowBackup.resume(flowOperatorRepository);
36+
}
37+
return null;
3538
}
3639
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public FlowWork copy(){
133133
}
134134

135135

136-
public FlowWork(String code,String title, String description, int postponedMax, IFlowOperator createUser) {
136+
public FlowWork(String code,String title, String description,boolean skipIfSameApprover, int postponedMax, IFlowOperator createUser) {
137137
this.title = title;
138138
this.code = code;
139139
this.description = description;
@@ -144,6 +144,7 @@ public FlowWork(String code,String title, String description, int postponedMax,
144144
this.nodes = new ArrayList<>();
145145
this.relations = new ArrayList<>();
146146
this.enable = false;
147+
this.skipIfSameApprover = skipIfSameApprover;
147148
}
148149

149150

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

+17-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.codingapi.springboot.flow.record.FlowRecord;
66
import com.codingapi.springboot.flow.repository.FlowProcessRepository;
77
import com.codingapi.springboot.flow.repository.FlowRecordRepository;
8+
import com.codingapi.springboot.flow.repository.FlowWorkRepository;
89
import com.codingapi.springboot.flow.user.IFlowOperator;
910
import lombok.Getter;
1011

@@ -22,6 +23,7 @@ public class FlowRecordVerifyService {
2223
// register repository
2324
final FlowRecordRepository flowRecordRepository;
2425
final FlowProcessRepository flowProcessRepository;
26+
final FlowWorkRepository flowWorkRepository;
2527

2628
// load Object
2729
@Getter
@@ -31,10 +33,13 @@ public class FlowRecordVerifyService {
3133
@Getter
3234
private final FlowRecord flowRecord;
3335

34-
public FlowRecordVerifyService(FlowRecordRepository flowRecordRepository,
35-
FlowProcessRepository flowProcessRepository,
36-
long recordId,
37-
IFlowOperator currentOperator) {
36+
public FlowRecordVerifyService(
37+
FlowWorkRepository flowWorkRepository,
38+
FlowRecordRepository flowRecordRepository,
39+
FlowProcessRepository flowProcessRepository,
40+
long recordId,
41+
IFlowOperator currentOperator) {
42+
this.flowWorkRepository = flowWorkRepository;
3843
this.flowRecordRepository = flowRecordRepository;
3944
this.flowProcessRepository = flowProcessRepository;
4045

@@ -46,13 +51,16 @@ public FlowRecordVerifyService(FlowRecordRepository flowRecordRepository,
4651
this.flowRecord = flowRecord;
4752
}
4853

49-
public FlowRecordVerifyService(FlowRecordRepository flowRecordRepository,
54+
public FlowRecordVerifyService(FlowWorkRepository flowWorkRepository,
55+
FlowRecordRepository flowRecordRepository,
5056
FlowProcessRepository flowProcessRepository,
5157
FlowRecord flowRecord,
5258
FlowWork flowWork,
5359
IFlowOperator currentOperator) {
60+
this.flowWorkRepository = flowWorkRepository;
5461
this.flowRecordRepository = flowRecordRepository;
5562
this.flowProcessRepository = flowProcessRepository;
63+
5664
this.currentOperator = currentOperator;
5765
this.flowRecord = flowRecord;
5866
this.flowWork = flowWork;
@@ -149,8 +157,11 @@ public void verifyTargetOperatorIsNotCurrentOperator(IFlowOperator targetOperato
149157
* 获取流程设计对象
150158
*/
151159
public void loadFlowWork() {
152-
if(this.flowWork ==null) {
160+
if (this.flowWork == null) {
153161
FlowWork flowWork = flowProcessRepository.getFlowWorkByProcessId(flowRecord.getProcessId());
162+
if (flowWork == null) {
163+
flowWork = flowWorkRepository.getFlowWorkByCode(flowRecord.getWorkCode());
164+
}
154165
if (flowWork == null) {
155166
throw new IllegalArgumentException("flow work not found");
156167
}

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public FlowService(FlowWorkRepository flowWorkRepository,
3838
FlowBackupRepository flowBackupRepository) {
3939
this.flowServiceRepositoryHolder = new FlowServiceRepositoryHolder(flowWorkRepository, flowRecordRepository, flowBindDataRepository, flowOperatorRepository, flowProcessRepository, flowBackupRepository);
4040
this.flowDetailService = new FlowDetailService(flowWorkRepository, flowRecordRepository, flowBindDataRepository, flowOperatorRepository, flowProcessRepository);
41-
this.flowCustomEventService = new FlowCustomEventService(flowRecordRepository, flowProcessRepository);
42-
this.flowRecallService = new FlowRecallService(flowRecordRepository, flowProcessRepository);
43-
this.flowSaveService = new FlowSaveService(flowRecordRepository, flowBindDataRepository, flowProcessRepository);
44-
this.flowTransferService = new FlowTransferService(flowRecordRepository, flowBindDataRepository, flowProcessRepository);
45-
this.flowPostponedService = new FlowPostponedService(flowRecordRepository, flowProcessRepository);
46-
this.flowUrgeService = new FlowUrgeService(flowRecordRepository, flowProcessRepository);
41+
this.flowCustomEventService = new FlowCustomEventService(flowWorkRepository,flowRecordRepository, flowProcessRepository);
42+
this.flowRecallService = new FlowRecallService(flowWorkRepository,flowRecordRepository, flowProcessRepository);
43+
this.flowSaveService = new FlowSaveService(flowWorkRepository,flowRecordRepository, flowBindDataRepository, flowProcessRepository);
44+
this.flowTransferService = new FlowTransferService(flowWorkRepository,flowRecordRepository, flowBindDataRepository, flowProcessRepository);
45+
this.flowPostponedService = new FlowPostponedService(flowWorkRepository,flowRecordRepository, flowProcessRepository);
46+
this.flowUrgeService = new FlowUrgeService(flowWorkRepository,flowRecordRepository, flowProcessRepository);
4747
}
4848

4949
/**

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.codingapi.springboot.flow.record.FlowRecord;
99
import com.codingapi.springboot.flow.repository.FlowProcessRepository;
1010
import com.codingapi.springboot.flow.repository.FlowRecordRepository;
11+
import com.codingapi.springboot.flow.repository.FlowWorkRepository;
1112
import com.codingapi.springboot.flow.result.MessageResult;
1213
import com.codingapi.springboot.flow.service.FlowRecordVerifyService;
1314
import com.codingapi.springboot.flow.user.IFlowOperator;
@@ -21,6 +22,7 @@
2122
@AllArgsConstructor
2223
public class FlowCustomEventService {
2324

25+
private final FlowWorkRepository flowWorkRepository;
2426
private final FlowRecordRepository flowRecordRepository;
2527
private final FlowProcessRepository flowProcessRepository;
2628

@@ -34,7 +36,7 @@ public class FlowCustomEventService {
3436
* @param opinion 审批意见
3537
*/
3638
public MessageResult customFlowEvent(long recordId, IFlowOperator currentOperator, String buttonId, IBindData bindData, Opinion opinion) {
37-
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowRecordRepository, flowProcessRepository, recordId, currentOperator);
39+
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowWorkRepository,flowRecordRepository, flowProcessRepository, recordId, currentOperator);
3840

3941
// 验证流程的提交状态
4042
flowRecordVerifyService.verifyFlowRecordSubmitState();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class FlowDetailService {
3535
*/
3636
public FlowDetail detail(long recordId, IFlowOperator currentOperator) {
3737

38-
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowRecordRepository,
38+
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowWorkRepository,flowRecordRepository,
3939
flowProcessRepository,
4040
recordId, currentOperator);
4141

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
@AllArgsConstructor
1313
public class FlowPostponedService {
1414

15+
private final FlowWorkRepository flowWorkRepository;
1516
private final FlowRecordRepository flowRecordRepository;
1617
private final FlowProcessRepository flowProcessRepository;
1718

@@ -23,7 +24,7 @@ public class FlowPostponedService {
2324
* @param time 延期时间
2425
*/
2526
public void postponed(long recordId, IFlowOperator currentOperator, long time) {
26-
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowRecordRepository,
27+
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowWorkRepository,flowRecordRepository,
2728
flowProcessRepository,
2829
recordId, currentOperator);
2930

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
@AllArgsConstructor
1717
public class FlowRecallService {
1818

19+
private final FlowWorkRepository flowWorkRepository;
1920
private final FlowRecordRepository flowRecordRepository;
2021
private final FlowProcessRepository flowProcessRepository;
2122

@@ -26,7 +27,9 @@ public class FlowRecallService {
2627
* @param currentOperator 当前操作者
2728
*/
2829
public void recall(long recordId, IFlowOperator currentOperator) {
29-
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowRecordRepository,
30+
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(
31+
flowWorkRepository,
32+
flowRecordRepository,
3033
flowProcessRepository,
3134
recordId, currentOperator);
3235

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@AllArgsConstructor
1515
public class FlowSaveService {
1616

17+
private final FlowWorkRepository flowWorkRepository;
1718
private final FlowRecordRepository flowRecordRepository;
1819
private final FlowBindDataRepository flowBindDataRepository;
1920
private final FlowProcessRepository flowProcessRepository;
@@ -27,7 +28,8 @@ public class FlowSaveService {
2728
* @param advice 审批意见
2829
*/
2930
public void save(long recordId, IFlowOperator currentOperator, IBindData bindData, String advice) {
30-
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowRecordRepository,
31+
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowWorkRepository,
32+
flowRecordRepository,
3133
flowProcessRepository,
3234
recordId, currentOperator);
3335
flowRecordVerifyService.verifyFlowRecordSubmitState();

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public FlowSubmitService(long recordId,
5555
this.currentOperator = currentOperator;
5656
this.bindData = bindData;
5757
this.opinion = opinion;
58-
this.flowRecordVerifyService = new FlowRecordVerifyService(flowServiceRepositoryHolder.getFlowRecordRepository(),
58+
this.flowRecordVerifyService = new FlowRecordVerifyService(
59+
flowServiceRepositoryHolder.getFlowWorkRepository(),
60+
flowServiceRepositoryHolder.getFlowRecordRepository(),
5961
flowServiceRepositoryHolder.getFlowProcessRepository(),
6062
recordId,
6163
currentOperator);
@@ -73,7 +75,9 @@ public FlowSubmitService(FlowRecord flowRecord,
7375
this.currentOperator = currentOperator;
7476
this.bindData = bindData;
7577
this.opinion = opinion;
76-
this.flowRecordVerifyService = new FlowRecordVerifyService(flowServiceRepositoryHolder.getFlowRecordRepository(),
78+
this.flowRecordVerifyService = new FlowRecordVerifyService(
79+
flowServiceRepositoryHolder.getFlowWorkRepository(),
80+
flowServiceRepositoryHolder.getFlowRecordRepository(),
7781
flowServiceRepositoryHolder.getFlowProcessRepository(),
7882
flowRecord,
7983
flowWork,
@@ -221,6 +225,7 @@ private void pushEvent(FlowRecord flowRecord, int eventState) {
221225

222226
/**
223227
* 提交流程 根据流程的是否跳过相同审批人来判断是否需要继续提交
228+
*
224229
* @return 流程结果
225230
*/
226231
public FlowResult submitFlow() {
@@ -242,6 +247,7 @@ public FlowResult submitFlow() {
242247

243248
/**
244249
* 提交当前流程
250+
*
245251
* @return 流程结果
246252
*/
247253
private FlowResult submitCurrentFlow() {
@@ -370,6 +376,6 @@ public FlowSubmitResult trySubmitFlow() {
370376

371377
// 是否跳过相同审批人
372378
public boolean isSkipIfSameApprover() {
373-
return flowWork.isSkipIfSameApprover();
379+
return flowWork.isSkipIfSameApprover() && !nextNode.isOverNode();
374380
}
375381
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
@AllArgsConstructor
2323
public class FlowTransferService {
2424

25+
private final FlowWorkRepository flowWorkRepository;
2526
private final FlowRecordRepository flowRecordRepository;
2627
private final FlowBindDataRepository flowBindDataRepository;
2728
private final FlowProcessRepository flowProcessRepository;
@@ -38,7 +39,7 @@ public class FlowTransferService {
3839
*/
3940
public void transfer(long recordId, IFlowOperator currentOperator, IFlowOperator targetOperator, IBindData bindData, String advice) {
4041

41-
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowRecordRepository,
42+
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowWorkRepository,flowRecordRepository,
4243
flowProcessRepository,
4344
recordId, currentOperator);
4445

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
public class FlowUrgeService {
1818

1919

20+
private final FlowWorkRepository flowWorkRepository;
2021
private final FlowRecordRepository flowRecordRepository;
2122
private final FlowProcessRepository flowProcessRepository;
2223

@@ -27,7 +28,9 @@ public class FlowUrgeService {
2728
* @param currentOperator 当前操作者
2829
*/
2930
public void urge(long recordId, IFlowOperator currentOperator) {
30-
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(flowRecordRepository,
31+
FlowRecordVerifyService flowRecordVerifyService = new FlowRecordVerifyService(
32+
flowWorkRepository,
33+
flowRecordRepository,
3134
flowProcessRepository,
3235
recordId, currentOperator);
3336
flowRecordVerifyService.loadFlowWork();

0 commit comments

Comments
 (0)