Skip to content

Commit 86bedc5

Browse files
committed
add merge flow
1 parent c161a37 commit 86bedc5

File tree

40 files changed

+153
-44
lines changed

40 files changed

+153
-44
lines changed

example/example-app/example-app-cmd-domain/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-app</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-app/example-app-cmd-meta/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-app</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-app/example-app-query/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-app</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-example</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212
<packaging>pom</packaging>

example/example-domain/example-domain-leave/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-domain</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-domain/example-domain-user/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-domain</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-domain/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-example</artifactId>
8-
<version>3.3.70</version>
8+
<version>3.4.0</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

example/example-infra/example-infra-flow/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>example-infra</artifactId>
8-
<version>3.3.70</version>
8+
<version>3.4.0</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static FlowNodeEntity convert(FlowNode flowNode, long workId){
2121
entity.setCode(flowNode.getCode());
2222
entity.setName(flowNode.getName());
2323
entity.setEditable(flowNode.isEditable());
24+
entity.setMergeable(flowNode.isMergeable());
2425
entity.setCreateTime(flowNode.getCreateTime());
2526
entity.setType(flowNode.getType().name());
2627
entity.setTimeout(flowNode.getTimeout());
@@ -52,6 +53,7 @@ public static FlowNode convert(FlowNodeEntity entity){
5253
ApprovalType.parser(entity.getApprovalType()),
5354
new OperatorMatcher(entity.getOperatorMatcher()),
5455
entity.getEditable(),
56+
entity.getMergeable(),
5557
entity.getCreateTime(),
5658
entity.getUpdateTime(),
5759
entity.getTimeout(),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static FlowRecordEntity convert(FlowRecord flowRecord) {
2121
entity.setWorkId(flowRecord.getWorkId());
2222
entity.setProcessId(flowRecord.getProcessId());
2323
entity.setNodeCode(flowRecord.getNodeCode());
24+
entity.setMergeable(flowRecord.isMergeable());
2425
entity.setTitle(flowRecord.getTitle());
2526
entity.setCurrentOperatorId(flowRecord.getCurrentOperator().getUserId());
2627
entity.setFlowType(flowRecord.getFlowType().name());
@@ -71,6 +72,7 @@ public static FlowRecord convert(FlowRecordEntity entity, FlowOperatorRepository
7172
flowRecord.setWorkId(entity.getWorkId());
7273
flowRecord.setProcessId(entity.getProcessId());
7374
flowRecord.setNodeCode(entity.getNodeCode());
75+
flowRecord.setMergeable(entity.getMergeable());
7476
flowRecord.setTitle(entity.getTitle());
7577
flowRecord.setCurrentOperator(flowUserRepository.getFlowOperatorById(entity.getCurrentOperatorId()));
7678
flowRecord.setFlowType(FlowType.parser(entity.getFlowType()));

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public class FlowNodeEntity {
6767
*/
6868
private Boolean editable;
6969

70+
/**
71+
* 是否合并审批
72+
*/
73+
private Boolean mergeable;
74+
7075
/**
7176
* 创建时间
7277
*/

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public class FlowRecordEntity {
4141
*/
4242
private String nodeCode;
4343

44+
/**
45+
* 是否可合并
46+
*/
47+
private Boolean mergeable;
48+
4449
/**
4550
* 流程标题
4651
*/

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@ public interface FlowRecordEntityRepository extends FastRepository<FlowRecordEnt
2323
@Query(value = "select r from FlowRecordEntity r where r.flowType = 'TODO' and r.flowStatus = 'RUNNING' and r.processId = ?1")
2424
List<FlowRecordEntity> findTodoFlowRecordByProcessId(String processId);
2525

26-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' order by r.id desc")
26+
@Query(value = "select r from FlowRecordEntity r" +
27+
" LEFT JOIN (select min(m.id) as id from FlowRecordEntity m where m.currentOperatorId = ?1 and m.flowType = 'TODO' and m.flowStatus = 'RUNNING' and m.mergeable = true ) debup " +
28+
"on r.id = debup.id" +
29+
" where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING'" +
30+
" and (r.mergeable !=true or debup.id is NOT null ) order by r.id desc")
2731
Page<FlowRecordEntity> findTodoByOperatorId(long operatorId, PageRequest pageRequest);
2832

33+
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.workCode = ?2 and r.nodeCode = ?3" +
34+
" and r.mergeable = true and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' order by r.id desc")
35+
List<FlowRecordEntity> findMergeFlowRecordById(long currentOperatorId,String workCode, String nodeCode);
36+
2937
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.workCode = ?2 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' order by r.id desc")
3038
Page<FlowRecordEntity> findTodoByOperatorIdAndWorkCode(long operatorId, String workCode, PageRequest pageRequest);
3139

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public List<FlowRecord> findFlowRecordByProcessId(String processId) {
4848
return flowRecordEntityRepository.findFlowRecordEntityByProcessId(processId).stream().map(item->FlowRecordConvertor.convert(item,flowOperatorRepository)).toList();
4949
}
5050

51+
@Override
52+
public List<FlowRecord> findMergeFlowRecordById(String workCode, String nodeCode, long currentOperatorId) {
53+
return flowRecordEntityRepository.findMergeFlowRecordById(currentOperatorId,workCode,nodeCode).stream().map(item->FlowRecordConvertor.convert(item,flowOperatorRepository)).toList();
54+
}
55+
5156
@Override
5257
public List<FlowRecord> findTodoFlowRecordByProcessId(String processId) {
5358
return flowRecordEntityRepository.findTodoFlowRecordByProcessId(processId)

example/example-infra/example-infra-jpa/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>example-infra</artifactId>
8-
<version>3.3.70</version>
8+
<version>3.4.0</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

example/example-infra/example-infra-security/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>example-infra</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

example/example-infra/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-example</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212
<packaging>pom</packaging>

example/example-interface/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-example</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</version>
1010
</parent>
1111

1212
<artifactId>example-interface</artifactId>

example/example-server/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-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.70</version>
8+
<version>3.4.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</parent>
2020

2121
<artifactId>springboot-example</artifactId>
22-
<version>3.3.70</version>
22+
<version>3.4.0</version>
2323

2424
<name>springboot-example</name>
2525
<description>springboot-example project for Spring Boot</description>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>com.codingapi.springboot</groupId>
1414
<artifactId>springboot-parent</artifactId>
15-
<version>3.3.70</version>
15+
<version>3.4.0</version>
1616

1717
<url>https://github.com/codingapi/springboot-framewrok</url>
1818
<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
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-parent</artifactId>
9-
<version>3.3.70</version>
9+
<version>3.4.0</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>3.3.70</version>
8+
<version>3.4.0</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>3.3.70</version>
9+
<version>3.4.0</version>
1010
</parent>
1111

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

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,43 +73,47 @@ public FlowWork build() {
7373

7474
public class Nodes {
7575

76-
public Nodes node(String id, String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, long timeout, TitleGenerator titleGenerator, ErrTrigger errTrigger, boolean editable, List<FlowButton> buttons) {
77-
FlowNode node = new FlowNode(id, name, code, view, NodeType.parser(code), approvalType, titleGenerator, operatorMatcher, timeout, errTrigger, editable, buttons);
76+
public Nodes node(String id, String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, long timeout, TitleGenerator titleGenerator, ErrTrigger errTrigger, boolean editable, boolean mergeable, List<FlowButton> buttons) {
77+
FlowNode node = new FlowNode(id, name, code, view, NodeType.parser(code), approvalType, titleGenerator, operatorMatcher, timeout, errTrigger, editable,mergeable, buttons);
7878
work.addNode(node);
7979
return this;
8080
}
8181

8282
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, long timeout, boolean editable) {
83-
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, timeout, TitleGenerator.defaultTitleGenerator(), null, editable, null);
83+
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, timeout, TitleGenerator.defaultTitleGenerator(), null, editable,false, null);
8484
}
8585

86-
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, long timeout, boolean editable, List<FlowButton> buttons) {
87-
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, timeout, TitleGenerator.defaultTitleGenerator(), null, editable, buttons);
86+
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, long timeout, boolean editable,boolean mergeable) {
87+
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, timeout, TitleGenerator.defaultTitleGenerator(), null, editable,mergeable, null);
88+
}
89+
90+
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, long timeout, boolean editable,boolean mergeable, List<FlowButton> buttons) {
91+
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, timeout, TitleGenerator.defaultTitleGenerator(), null, editable,mergeable, buttons);
8892
}
8993

9094

91-
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, boolean editable) {
92-
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, 0, TitleGenerator.defaultTitleGenerator(), null, editable, null);
95+
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, boolean editable,boolean mergeable) {
96+
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, 0, TitleGenerator.defaultTitleGenerator(), null, editable,mergeable, null);
9397
}
9498

95-
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, boolean editable, List<FlowButton> buttons) {
96-
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, 0, TitleGenerator.defaultTitleGenerator(), null, editable, buttons);
99+
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, boolean editable,boolean mergeable, List<FlowButton> buttons) {
100+
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, 0, TitleGenerator.defaultTitleGenerator(), null, editable,mergeable, buttons);
97101
}
98102

99103
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, List<FlowButton> buttons) {
100-
return node(name, code, view, approvalType, operatorMatcher, true, buttons);
104+
return node(name, code, view, approvalType, operatorMatcher, true,false, buttons);
101105
}
102106

103107
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher) {
104-
return node(name, code, view, approvalType, operatorMatcher, true, null);
108+
return node(name, code, view, approvalType, operatorMatcher, true,false, null);
105109
}
106110

107-
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, ErrTrigger errTrigger, boolean editable, List<FlowButton> buttons) {
108-
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, 0, TitleGenerator.defaultTitleGenerator(), errTrigger, editable, buttons);
111+
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, ErrTrigger errTrigger, boolean editable,boolean mergeable, List<FlowButton> buttons) {
112+
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, 0, TitleGenerator.defaultTitleGenerator(), errTrigger, editable,mergeable, buttons);
109113
}
110114

111-
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, ErrTrigger errTrigger, boolean editable) {
112-
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, 0, TitleGenerator.defaultTitleGenerator(), errTrigger, editable, null);
115+
public Nodes node(String name, String code, String view, ApprovalType approvalType, OperatorMatcher operatorMatcher, ErrTrigger errTrigger, boolean editable,boolean mergeable) {
116+
return node(RandomGenerator.generateUUID(), name, code, view, approvalType, operatorMatcher, 0, TitleGenerator.defaultTitleGenerator(), errTrigger, editable,mergeable, null);
113117
}
114118

115119

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private void loadNodes() {
4848
String titleGenerator = properties.getString("titleGenerator");
4949
String name = properties.getString("name");
5050
boolean editable = properties.getBoolean("editable");
51+
boolean mergeable = properties.getBoolean("mergeable");
5152
String view = properties.getString("view");
5253
String type = properties.getString("type");
5354
String approvalType = properties.getString("approvalType");
@@ -59,7 +60,7 @@ private void loadNodes() {
5960
buttons = properties.getJSONArray("buttons").toJavaList(FlowButton.class);
6061
}
6162
FlowNode flowNode = new FlowNode(id, name, code, view, NodeType.parser(type), ApprovalType.parser(approvalType), new TitleGenerator(titleGenerator),
62-
new OperatorMatcher(operatorMatcher), timeout, StringUtils.hasLength(errTrigger) ? new ErrTrigger(errTrigger) : null, editable, buttons);
63+
new OperatorMatcher(operatorMatcher), timeout, StringUtils.hasLength(errTrigger) ? new ErrTrigger(errTrigger) : null, editable,mergeable, buttons);
6364
flowNodes.add(flowNode);
6465
}
6566
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ public class FlowNode {
7777
*/
7878
private boolean editable;
7979

80+
/**
81+
* 是否合并记录
82+
* <p>
83+
* 如果为true,则表示该节点可以合并记录
84+
*/
85+
private boolean mergeable;
86+
8087
/**
8188
* 创建时间
8289
*/
@@ -147,6 +154,7 @@ public FlowNodeSerializable toSerializable() {
147154
this.approvalType,
148155
this.operatorMatcher.getScript(),
149156
this.editable,
157+
this.mergeable,
150158
this.createTime,
151159
this.updateTime,
152160
this.timeout,
@@ -167,6 +175,7 @@ public FlowNode(String id,
167175
long timeout,
168176
ErrTrigger errTrigger,
169177
boolean editable,
178+
boolean mergeable,
170179
List<FlowButton> buttons) {
171180
this.id = id;
172181
this.code = code;
@@ -181,6 +190,7 @@ public FlowNode(String id,
181190
this.errTrigger = errTrigger;
182191
this.timeout = timeout;
183192
this.editable = editable;
193+
this.mergeable = mergeable;
184194
this.buttons = buttons;
185195
}
186196

@@ -229,6 +239,7 @@ public FlowRecord createRecord(long workId,
229239
FlowRecord record = new FlowRecord();
230240
record.setProcessId(processId);
231241
record.setNodeCode(this.code);
242+
record.setMergeable(this.mergeable);
232243
record.setCreateTime(System.currentTimeMillis());
233244
record.setWorkId(workId);
234245
record.setWorkCode(workCode);

0 commit comments

Comments
 (0)