Skip to content

Commit 1d6e281

Browse files
committed
add FlowDirection
1 parent f07c3ce commit 1d6e281

File tree

12 files changed

+118
-110
lines changed

12 files changed

+118
-110
lines changed

example/example-infra-flow/src/main/java/com/codingapi/example/convert/FlowRecordConvertor.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import com.codingapi.example.entity.FlowRecordEntity;
44
import com.codingapi.example.repository.UserRepository;
55
import com.codingapi.springboot.flow.domain.Opinion;
6+
import com.codingapi.springboot.flow.em.FlowSourceDirection;
67
import com.codingapi.springboot.flow.em.FlowStatus;
7-
import com.codingapi.springboot.flow.em.RecodeType;
8+
import com.codingapi.springboot.flow.em.FlowType;
89
import com.codingapi.springboot.flow.record.FlowRecord;
910

1011
public class FlowRecordConvertor {
@@ -22,8 +23,10 @@ public static FlowRecordEntity convert(FlowRecord flowRecord, UserRepository use
2223
entity.setNodeCode(flowRecord.getNodeCode());
2324
entity.setTitle(flowRecord.getTitle());
2425
entity.setCurrentOperatorId(flowRecord.getCurrentOperatorId());
25-
entity.setRecodeType(flowRecord.getRecodeType().name());
26-
entity.setPass(flowRecord.isPass());
26+
entity.setFlowType(flowRecord.getFlowType().name());
27+
if(flowRecord.getFlowSourceDirection()!= null){
28+
entity.setFlowSourceDirection(flowRecord.getFlowSourceDirection().name());
29+
}
2730
entity.setCreateTime(flowRecord.getCreateTime());
2831
entity.setUpdateTime(flowRecord.getUpdateTime());
2932
entity.setFinishTime(flowRecord.getFinishTime());
@@ -63,8 +66,8 @@ public static FlowRecord convert(FlowRecordEntity entity) {
6366
flowRecord.setNodeCode(entity.getNodeCode());
6467
flowRecord.setTitle(entity.getTitle());
6568
flowRecord.setCurrentOperatorId(entity.getCurrentOperatorId());
66-
flowRecord.setRecodeType(RecodeType.parser(entity.getRecodeType()));
67-
flowRecord.setPass(entity.getPass());
69+
flowRecord.setFlowType(FlowType.parser(entity.getFlowType()));
70+
flowRecord.setFlowSourceDirection(FlowSourceDirection.parser(entity.getFlowSourceDirection()));
6871
flowRecord.setCreateTime(entity.getCreateTime());
6972
flowRecord.setUpdateTime(entity.getUpdateTime());
7073
flowRecord.setFinishTime(entity.getFinishTime());

example/example-infra-flow/src/main/java/com/codingapi/example/entity/FlowRecordEntity.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,14 @@ public class FlowRecordEntity {
5050
private String currentOperatorName;
5151

5252
/**
53-
* 节点状态 | 待办、已办
53+
* 节点类型 | 待办、已办、转办
5454
*/
55-
private String recodeType;
55+
private String flowType;
5656

5757
/**
58-
* 流转产生方式
59-
* 流程是退回产生的还是通过产生的
58+
* 流转产生方式 | 同意、拒绝、转办
6059
*/
61-
private Boolean pass;
60+
private String flowSourceDirection;
6261

6362
/**
6463
* 创建时间

example/example-infra-flow/src/main/java/com/codingapi/example/jpa/FlowRecordEntityRepository.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ public interface FlowRecordEntityRepository extends FastRepository<FlowRecordEnt
1919
List<FlowRecordEntity> findFlowRecordEntityByProcessId(String processId);
2020

2121

22-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.recodeType = 'TODO' and r.flowStatus = 'RUNNING' order by r.createTime desc")
22+
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' order by r.createTime desc")
2323
Page<FlowRecordEntity> findTodoByOperatorId(long operatorId,PageRequest pageRequest);
2424

25-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.recodeType = 'DONE' order by r.createTime desc")
25+
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'DONE' order by r.createTime desc")
2626
Page<FlowRecordEntity> findDoneByOperatorId(long operatorId, PageRequest pageRequest);
2727

2828
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.preId = 0 and r.nodeCode = 'start' order by r.createTime desc")
2929
Page<FlowRecordEntity> findInitiatedByOperatorId(long operatorId, PageRequest pageRequest);
3030

31-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.recodeType = 'TODO' and r.flowStatus = 'RUNNING' and r.timeoutTime >0 and r.timeoutTime < ?2 order by r.createTime desc")
31+
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' and r.timeoutTime >0 and r.timeoutTime < ?2 order by r.createTime desc")
3232
Page<FlowRecordEntity> findTimeoutTodoByOperatorId(long operatorId,long currentTime, PageRequest pageRequest);
3333

34-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.recodeType = 'TODO' and r.flowStatus = 'RUNNING' and r.postponedCount > 0 order by r.createTime desc")
34+
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' and r.postponedCount > 0 order by r.createTime desc")
3535
Page<FlowRecordEntity> findPostponedTodoByOperatorId(long operatorId, PageRequest pageRequest);
3636

37-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.recodeType = 'TODO' and r.flowStatus = 'RUNNING' order by r.createTime desc")
37+
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' order by r.createTime desc")
3838
List<FlowRecordEntity> findTodoFlowRecordByProcessId(String processId);
3939
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public List<? extends IFlowOperator> loadFlowNodeOperator(FlowContent flowConten
186186
* @param currentOperator 当前操作者
187187
* @param snapshot 快照数据
188188
* @param opinion 审批意见
189-
* @param flowDirection 流程方式
189+
* @param flowSourceDirection 流程方式
190190
* @return 流程记录
191191
*/
192192
public FlowRecord createRecord(long workId,
@@ -197,7 +197,7 @@ public FlowRecord createRecord(long workId,
197197
IFlowOperator currentOperator,
198198
BindDataSnapshot snapshot,
199199
Opinion opinion,
200-
FlowDirection flowDirection) {
200+
FlowSourceDirection flowSourceDirection) {
201201

202202
// 当前操作者存在委托人时,才需要寻找委托人
203203
IFlowOperator flowOperator = currentOperator;
@@ -219,9 +219,9 @@ public FlowRecord createRecord(long workId,
219219
record.setCurrentOperatorId(flowOperator.getUserId());
220220
record.setPreId(preId);
221221
record.setTitle(title);
222-
record.setFlowDirection(flowDirection);
222+
record.setFlowSourceDirection(flowSourceDirection);
223223
record.setTimeoutTime(this.loadTimeoutTime());
224-
record.setRecodeType(RecodeType.TODO);
224+
record.setFlowType(FlowType.TODO);
225225
record.setErrMessage(null);
226226
record.setSnapshotId(snapshot.getId());
227227
return record;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.codingapi.springboot.flow.em;
22

3+
/**
4+
* 审批类型:会签与非会签
5+
*/
36
public enum ApprovalType {
47

58
/**

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

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.codingapi.springboot.flow.em;
2+
3+
/**
4+
* 流程来源的方式
5+
* 包括 同意、拒绝、转办
6+
*/
7+
public enum FlowSourceDirection {
8+
9+
/**
10+
* 同意
11+
*/
12+
PASS,
13+
/**
14+
* 拒绝
15+
*/
16+
REJECT,
17+
/**
18+
*
19+
*/
20+
TRANSFER;
21+
22+
public static FlowSourceDirection parser(String type){
23+
for(FlowSourceDirection flowSourceDirection :values()){
24+
if(flowSourceDirection.name().equalsIgnoreCase(type)){
25+
return flowSourceDirection;
26+
}
27+
}
28+
return null;
29+
}
30+
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.codingapi.springboot.flow.em;
22

33
/**
4-
* 流转类型
4+
* 流程的类型
55
*/
6-
public enum RecodeType {
6+
public enum FlowType {
77

88
/**
99
* 待办
@@ -19,10 +19,10 @@ public enum RecodeType {
1919
TRANSFER;
2020

2121

22-
public static RecodeType parser(String type){
23-
for(RecodeType recodeType:values()){
24-
if(recodeType.name().equalsIgnoreCase(type)){
25-
return recodeType;
22+
public static FlowType parser(String type){
23+
for(FlowType flowType :values()){
24+
if(flowType.name().equalsIgnoreCase(type)){
25+
return flowType;
2626
}
2727
}
2828
return TODO;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.codingapi.springboot.flow.em;
22

3+
/**
4+
* 节点类型
5+
*/
36
public enum NodeType {
47

58
/**

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import com.codingapi.springboot.flow.domain.FlowNode;
55
import com.codingapi.springboot.flow.domain.Opinion;
66
import com.codingapi.springboot.flow.em.FlowStatus;
7-
import com.codingapi.springboot.flow.em.RecodeType;
8-
import com.codingapi.springboot.flow.em.FlowDirection;
7+
import com.codingapi.springboot.flow.em.FlowType;
8+
import com.codingapi.springboot.flow.em.FlowSourceDirection;
99
import com.codingapi.springboot.flow.user.IFlowOperator;
1010
import lombok.Getter;
1111
import lombok.Setter;
@@ -51,13 +51,13 @@ public class FlowRecord {
5151
/**
5252
* 节点状态 | 待办、已办
5353
*/
54-
private RecodeType recodeType;
54+
private FlowType flowType;
5555

5656
/**
5757
* 流转产生方式
5858
* 流程是退回产生的还是通过产生的
5959
*/
60-
private FlowDirection flowDirection;
60+
private FlowSourceDirection flowSourceDirection;
6161

6262
/**
6363
* 创建时间
@@ -185,7 +185,7 @@ public void submitStateVerify() {
185185
if (flowStatus == FlowStatus.FINISH) {
186186
throw new IllegalArgumentException("flow is finish");
187187
}
188-
if (recodeType == RecodeType.DONE) {
188+
if (flowType == FlowType.DONE) {
189189
throw new IllegalArgumentException("flow is done");
190190
}
191191
}
@@ -196,9 +196,9 @@ public void submitStateVerify() {
196196
* @param flowOperator 操作者
197197
* @param snapshot 绑定数据
198198
* @param opinion 意见
199-
* @param flowDirection 流转方式
199+
* @param flowSourceDirection 流转方式
200200
*/
201-
public void submitRecord(IFlowOperator flowOperator, BindDataSnapshot snapshot, Opinion opinion, FlowDirection flowDirection) {
201+
public void submitRecord(IFlowOperator flowOperator, BindDataSnapshot snapshot, Opinion opinion, FlowSourceDirection flowSourceDirection) {
202202
if (!flowOperator.isFlowManager()) {
203203
if (flowOperator.getUserId() != this.currentOperatorId) {
204204
throw new IllegalArgumentException("current operator is not match");
@@ -208,8 +208,8 @@ public void submitRecord(IFlowOperator flowOperator, BindDataSnapshot snapshot,
208208
this.interfere = true;
209209
}
210210
this.read();
211-
this.flowDirection = flowDirection;
212-
this.recodeType = RecodeType.DONE;
211+
this.flowSourceDirection = flowSourceDirection;
212+
this.flowType = FlowType.DONE;
213213
this.updateTime = System.currentTimeMillis();
214214
this.snapshotId = snapshot.getId();
215215
this.bindClass = snapshot.getClazzName();
@@ -224,8 +224,8 @@ public void transfer(IFlowOperator flowOperator, BindDataSnapshot snapshot, Opin
224224
throw new IllegalArgumentException("current operator is not match");
225225
}
226226
this.read();
227-
this.flowDirection = FlowDirection.TRANSFER;
228-
this.recodeType = RecodeType.TRANSFER;
227+
this.flowSourceDirection = FlowSourceDirection.TRANSFER;
228+
this.flowType = FlowType.TRANSFER;
229229
this.updateTime = System.currentTimeMillis();
230230
this.snapshotId = snapshot.getId();
231231
this.bindClass = snapshot.getClazzName();
@@ -241,15 +241,15 @@ public void transfer(IFlowOperator flowOperator, BindDataSnapshot snapshot, Opin
241241
*/
242242
public void transferToTodo(String title, IFlowOperator operator) {
243243
this.id = 0;
244-
this.recodeType = RecodeType.TODO;
244+
this.flowType = FlowType.TODO;
245245
this.flowStatus = FlowStatus.RUNNING;
246246
this.postponedCount = 0;
247247
this.updateTime = 0;
248248
this.readTime = 0;
249249
this.read = false;
250250
this.title = title;
251251
this.opinion = null;
252-
this.flowDirection = null;
252+
this.flowSourceDirection = null;
253253
this.currentOperatorId = operator.getUserId();
254254
}
255255

@@ -261,9 +261,9 @@ public void transferToTodo(String title, IFlowOperator operator) {
261261
*/
262262
public void unSignAutoDone(IFlowOperator flowOperator, BindDataSnapshot snapshot) {
263263
this.read();
264-
this.flowDirection = FlowDirection.PASS;
264+
this.flowSourceDirection = FlowSourceDirection.PASS;
265265
this.currentOperatorId = flowOperator.getUserId();
266-
this.recodeType = RecodeType.DONE;
266+
this.flowType = FlowType.DONE;
267267
this.updateTime = System.currentTimeMillis();
268268
this.snapshotId = snapshot.getId();
269269
this.bindClass = snapshot.getClazzName();
@@ -284,7 +284,7 @@ public void finish() {
284284
* 是否已审批
285285
*/
286286
public boolean isDone() {
287-
return this.recodeType == RecodeType.DONE;
287+
return this.flowType == FlowType.DONE;
288288
}
289289

290290
/**
@@ -298,7 +298,7 @@ public boolean isFinish() {
298298
* 是否是待办
299299
*/
300300
public boolean isTodo() {
301-
return this.recodeType == RecodeType.TODO && this.flowStatus == FlowStatus.RUNNING;
301+
return this.flowType == FlowType.TODO && this.flowStatus == FlowStatus.RUNNING;
302302
}
303303

304304
/**
@@ -307,7 +307,7 @@ public boolean isTodo() {
307307
* @return 是否是转交
308308
*/
309309
public boolean isTransfer() {
310-
return this.recodeType == RecodeType.TRANSFER;
310+
return this.flowType == FlowType.TRANSFER;
311311
}
312312

313313
/**
@@ -327,7 +327,7 @@ public void matcherOperator(IFlowOperator currentOperator) {
327327
* 撤回流程
328328
*/
329329
public void recall() {
330-
this.recodeType = RecodeType.TODO;
330+
this.flowType = FlowType.TODO;
331331
this.updateTime = System.currentTimeMillis();
332332
}
333333

@@ -342,8 +342,8 @@ public FlowRecord copy() {
342342
record.setNodeCode(this.nodeCode);
343343
record.setTitle(this.title);
344344
record.setCurrentOperatorId(this.currentOperatorId);
345-
record.setRecodeType(this.recodeType);
346-
record.setFlowDirection(this.flowDirection);
345+
record.setFlowType(this.flowType);
346+
record.setFlowSourceDirection(this.flowSourceDirection);
347347
record.setCreateTime(this.createTime);
348348
record.setUpdateTime(this.updateTime);
349349
record.setFinishTime(this.finishTime);

0 commit comments

Comments
 (0)