Skip to content

Commit 8ede604

Browse files
committed
fix node record
1 parent 913a130 commit 8ede604

14 files changed

Lines changed: 123 additions & 34 deletions

File tree

flow-engine-framework/src/main/java/com/codingapi/flow/node/nodes/EndNode.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ public List<FlowRecord> generateCurrentRecords(FlowSession session) {
4242

4343
@Override
4444
public void fillNewRecord(FlowSession session, FlowRecord flowRecord) {
45-
flowRecord.setTitle("over");
46-
flowRecord.setCurrentOperatorId(-1);
47-
45+
flowRecord.over();
4846
IFlowAction currentAction = session.getCurrentAction();
4947
// 标记当前流程结束
5048
FlowRecord latestRecord = session.getCurrentRecord();

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public class FlowRecord {
5959
* 节点类型
6060
*/
6161
private String nodeType;
62+
63+
/**
64+
* 节点名称
65+
*/
66+
private String nodeName;
67+
6268
/**
6369
* 来源id
6470
*/
@@ -254,6 +260,7 @@ public FlowRecord(FlowSession flowSession, int nodeOrder) {
254260
this.workBackupId = flowSession.getBackupId();
255261
this.nodeId = flowSession.getCurrentNodeId();
256262
this.nodeType = flowSession.getCurrentNodeType();
263+
this.nodeName = flowSession.getCurrentNodeName();
257264
this.formData = flowSession.getFormData().toMapData();
258265
this.nodeOrder = nodeOrder;
259266
this.processId = RandomUtils.generateStringId();
@@ -580,4 +587,21 @@ public FlowSession createFlowSession( Workflow workflow,
580587
advice
581588
);
582589
}
590+
591+
/**
592+
* 设置为已读
593+
*/
594+
public void read() {
595+
this.readTime = System.currentTimeMillis();
596+
}
597+
598+
/**
599+
* 流程结束
600+
*/
601+
public void over() {
602+
this.title = "-";
603+
this.readTime = System.currentTimeMillis();
604+
this.currentOperatorId = -1;
605+
this.recordState = SATE_RECORD_DONE;
606+
}
583607
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public class FlowTodoRecord {
4040
*/
4141
private String nodeType;
4242

43+
/**
44+
* 节点名称
45+
*/
46+
private String nodeName;
47+
4348
/**
4449
* 消息标题
4550
*/
@@ -113,6 +118,7 @@ public void update(FlowRecord flowRecord) {
113118
this.workCode = flowRecord.getWorkCode();
114119
this.nodeId = flowRecord.getNodeId();
115120
this.nodeType = flowRecord.getNodeType();
121+
this.nodeName = flowRecord.getNodeName();
116122
this.title = flowRecord.getTitle();
117123
this.readTime = flowRecord.getReadTime();
118124
this.currentOperatorId = flowRecord.getCurrentOperatorId();

flow-engine-framework/src/main/java/com/codingapi/flow/service/impl/FlowDetailService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public FlowContent detail() {
5151
throw FlowNotFoundException.workflow(flowRecord.getWorkBackupId() + " not found");
5252
}
5353
Workflow workflow = workflowBackup.toWorkflow();
54+
55+
if(!flowRecord.isReadable()){
56+
flowRecord.read();
57+
RepositoryHolderContext.getInstance().saveRecord(flowRecord);
58+
}
59+
5460
return new FlowContentFactory(workflow, flowRecord,currentOperator).create();
5561
}
5662
}

flow-engine-framework/src/main/java/com/codingapi/flow/session/FlowSession.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ public String getCurrentNodeType() {
177177
return currentNode.getType();
178178
}
179179

180+
public String getCurrentNodeName() {
181+
return currentNode.getName();
182+
}
183+
180184
/**
181185
* 获取下一节点列表
182186
*

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static FlowRecord convert(FlowRecordEntity entity) {
1717
entity.getWorkCode(),
1818
entity.getNodeId(),
1919
entity.getNodeType(),
20+
entity.getNodeName(),
2021
entity.getFromId(),
2122
entity.getParentId(),
2223
mapConvertor.convertToEntityAttribute(entity.getFormData()),
@@ -67,6 +68,7 @@ public static FlowRecordEntity convert(FlowRecord record) {
6768
entity.setWorkCode(record.getWorkCode());
6869
entity.setNodeId(record.getNodeId());
6970
entity.setNodeType(record.getNodeType());
71+
entity.setNodeName(record.getNodeName());
7072
entity.setFromId(record.getFromId());
7173
entity.setParentId(record.getParentId());
7274
entity.setFormData(mapConvertor.convertToDatabaseColumn(record.getFormData()));

flow-engine-starter-infra/src/main/java/com/codingapi/flow/infra/convert/FlowTodoRecordConvertor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static FlowTodoRecord convert(FlowTodoRecordEntity entity){
1616
entity.getWorkCode(),
1717
entity.getNodeId(),
1818
entity.getNodeType(),
19+
entity.getNodeName(),
1920
entity.getTitle(),
2021
entity.getReadTime(),
2122
entity.getCurrentOperatorId(),
@@ -46,6 +47,7 @@ public static FlowTodoRecordEntity convert(FlowTodoRecord record){
4647
entity.setWorkCode(record.getWorkCode());
4748
entity.setNodeId(record.getNodeId());
4849
entity.setNodeType(record.getNodeType());
50+
entity.setNodeName(record.getNodeName());
4951
entity.setTitle(record.getTitle());
5052
entity.setReadTime(record.getReadTime());
5153
entity.setCurrentOperatorId(record.getCurrentOperatorId());

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public class FlowRecordEntity {
2929
* 节点类型
3030
*/
3131
private String nodeType;
32+
/**
33+
* 节点名称
34+
*/
35+
private String nodeName;
3236
/**
3337
* 来源id
3438
*/

flow-engine-starter-infra/src/main/java/com/codingapi/flow/infra/entity/FlowTodoRecordEntity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public class FlowTodoRecordEntity {
3838
* 节点类型
3939
*/
4040
private String nodeType;
41+
/**
42+
* 节点名称
43+
*/
44+
private String nodeName;
4145

4246
/**
4347
* 消息标题

flow-engine-starter-infra/src/main/java/com/codingapi/flow/infra/pojo/FlowRecordContent.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public class FlowRecordContent {
3131
*/
3232
private String nodeType;
3333

34+
/**
35+
* 节点名称
36+
*/
37+
private String nodeName;
38+
3439
/**
3540
* 消息标题
3641
*/
@@ -112,6 +117,7 @@ public static FlowRecordContent convert(FlowTodoRecordEntity todoRecord){
112117
content.setWorkCode(todoRecord.getWorkCode());
113118
content.setNodeId(todoRecord.getNodeId());
114119
content.setNodeType(todoRecord.getNodeType());
120+
content.setNodeName(todoRecord.getNodeName());
115121
content.setTitle(todoRecord.getTitle());
116122
content.setReadTime(todoRecord.getReadTime());
117123
content.setCurrentOperatorId(todoRecord.getCurrentOperatorId());
@@ -138,6 +144,7 @@ public static FlowRecordContent convert(FlowRecordEntity record){
138144
content.setWorkCode(record.getWorkCode());
139145
content.setNodeId(record.getNodeId());
140146
content.setNodeType(record.getNodeType());
147+
content.setNodeName(record.getNodeName());
141148
content.setTitle(record.getTitle());
142149
content.setReadTime(record.getReadTime());
143150
content.setCurrentOperatorId(record.getCurrentOperatorId());

0 commit comments

Comments
 (0)