Skip to content

Commit 74fdbea

Browse files
committed
fix #30
1 parent 99ff55e commit 74fdbea

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

flow-engine-framework/src/main/java/com/codingapi/flow/context/RepositoryHolderContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private void saveTodoMargeRecords() {
228228
} else {
229229
todoMargeRecord.update(flowRecord);
230230
if (flowRecord.isMergeable()) {
231-
todoMargeRecord.addMargeCount();
231+
todoMargeRecord.addMergeCount();
232232
}
233233
}
234234
flowTodoRecords.add(todoMargeRecord);
@@ -267,8 +267,8 @@ private void removeTodoMergeRecords() {
267267
for (FlowTodoMerge margeRelation : margeRelations) {
268268
if (margeRelation.isRecord(flowRecord.getId())) {
269269
flowTodoMergeRepository.remove(margeRelation);
270-
todoMargeRecord.divMargeCount();
271-
if (todoMargeRecord.hasMargeCount()) {
270+
todoMargeRecord.divMergeCount();
271+
if (todoMargeRecord.hasMergeCount()) {
272272
flowTodoRecordRepository.save(todoMargeRecord);
273273
} else {
274274
flowTodoRecordRepository.remove(todoMargeRecord);

flow-engine-framework/src/main/java/com/codingapi/flow/record/FlowTodoRecord.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import lombok.Setter;
66

77
/**
8-
* 待办记录数据,所有的待办列表
8+
* 待办记录数据,所有的待办列表(自动合并记录)
99
*/
1010
@Getter
1111
@AllArgsConstructor
1212
public class FlowTodoRecord {
1313

1414
/**
15-
* 合并记录id
15+
* 待办记录id (todoId,无业务属性,流程处理还是通过recordId来处理)
1616
*/
1717
@Setter
1818
private long id;
@@ -81,6 +81,7 @@ public class FlowTodoRecord {
8181

8282
/**
8383
* 合并记录数量
84+
* 当 {@link FlowTodoRecord#mergeable} 为true时,该字段有效,否则为0
8485
*/
8586
private int margeCount;
8687

@@ -101,11 +102,12 @@ public class FlowTodoRecord {
101102

102103

103104
public FlowTodoRecord(FlowRecord flowRecord) {
104-
this.update(flowRecord);
105+
this.update(flowRecord);
106+
this.margeCount = flowRecord.isMergeable() ? 1 : 0;
105107
}
106108

107109

108-
public void update(FlowRecord flowRecord){
110+
public void update(FlowRecord flowRecord) {
109111
this.processId = flowRecord.getProcessId();
110112
this.workBackupId = flowRecord.getWorkBackupId();
111113
this.workCode = flowRecord.getWorkCode();
@@ -124,20 +126,29 @@ public void update(FlowRecord flowRecord){
124126
this.timeoutTime = flowRecord.getTimeoutTime();
125127
}
126128

127-
public void addMargeCount(){
128-
if(this.mergeable) {
129+
/**
130+
* 添加合并记录数量
131+
*/
132+
public void addMergeCount() {
133+
if (this.mergeable) {
129134
this.margeCount++;
130135
}
131136
}
132137

133-
public void divMargeCount(){
134-
if(this.mergeable) {
138+
/**
139+
* 减去合并记录数量
140+
*/
141+
public void divMergeCount() {
142+
if (this.mergeable) {
135143
this.margeCount--;
136144
}
137145
}
138146

139-
public boolean hasMargeCount(){
140-
return this.mergeable && this.margeCount >= 0;
147+
/**
148+
* 是否有合并记录数量
149+
*/
150+
public boolean hasMergeCount() {
151+
return this.mergeable && this.margeCount > 0;
141152
}
142153

143154
}

0 commit comments

Comments
 (0)