Skip to content

Commit a763dcc

Browse files
committed
fix audit bug
1 parent af4f3e5 commit a763dcc

28 files changed

Lines changed: 283 additions & 128 deletions

File tree

flow-engine-framework/src/main/java/com/codingapi/flow/action/actions/RejectAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.codingapi.flow.event.FlowRecordTodoEvent;
99
import com.codingapi.flow.event.IFlowEvent;
1010
import com.codingapi.flow.exception.FlowStateException;
11-
import com.codingapi.flow.exception.FlowValidationException;
1211
import com.codingapi.flow.node.IFlowNode;
1312
import com.codingapi.flow.record.FlowRecord;
1413
import com.codingapi.flow.script.action.RejectActionScript;

flow-engine-framework/src/main/java/com/codingapi/flow/backup/WorkflowBackup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public WorkflowBackup(Workflow workflow) {
4747
this.workCode = workflow.getCode();
4848
this.workTitle = workflow.getTitle();
4949
this.createTime = System.currentTimeMillis();
50-
this.workVersion = workflow.getCreatedTime();
50+
this.workVersion = workflow.getUpdatedTime();
5151
}
5252

5353

flow-engine-framework/src/main/java/com/codingapi/flow/form/FlowForm.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public static FlowForm fromMap(Map<String, Object> map) {
6969
fieldMeta.setType(DataType.valueOf((String) field.get("type")));
7070
fieldMeta.setRequired(Boolean.TRUE.equals(field.get("required")));
7171
fieldMeta.setDefaultValue((String) field.get("defaultValue"));
72+
fieldMeta.setPlaceholder((String) field.get("placeholder"));
7273
fieldMeta.setTooltip((String) field.get("tooltip"));
7374
fieldMeta.setHelp((String) field.get("help"));
7475
fieldList.add(fieldMeta);

flow-engine-framework/src/main/java/com/codingapi/flow/pojo/response/ProcessNode.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,30 @@ public class ProcessNode {
4949
*/
5050
private int state;
5151

52+
5253
/**
5354
* 节点审批人
5455
*/
5556
private List<FlowOperatorBody> operators;
5657

5758

58-
public boolean isHistory(){
59+
public boolean isHistory() {
5960
return this.state == STATE_HISTORY;
6061
}
6162

63+
private ProcessNode(IFlowNode flowNode) {
64+
this.state = STATE_HISTORY;
65+
this.operators = new ArrayList<>();
66+
this.nodeType = flowNode.getType();
67+
this.nodeName = flowNode.getName();
68+
this.nodeId = flowNode.getId();
69+
}
70+
71+
public static ProcessNode createEndNode(Workflow workflow) {
72+
IFlowNode endNode = workflow.getEndNode();
73+
return new ProcessNode(endNode);
74+
}
75+
6276
public ProcessNode(FlowRecord flowRecord, Workflow workflow) {
6377
this.nodeId = flowRecord.getNodeId();
6478
IFlowNode flowNode = workflow.getFlowNode(this.nodeId);
@@ -92,7 +106,7 @@ public void setCurrentState() {
92106

93107
@Override
94108
public boolean equals(Object target) {
95-
if(target instanceof ProcessNode) {
109+
if (target instanceof ProcessNode) {
96110
ProcessNode targetNode = (ProcessNode) target;
97111
return targetNode.getNodeId().equals(this.getNodeId());
98112
}
@@ -122,7 +136,11 @@ public static class FlowOperatorBody {
122136
private String signKey;
123137

124138
/**
125-
* 审批记录
139+
* 审批动作
140+
*/
141+
private String actionName;
142+
/**
143+
* 审批人
126144
*/
127145
private FlowOperator flowOperator;
128146
/**
@@ -134,6 +152,7 @@ public FlowOperatorBody(FlowRecord flowRecord) {
134152
this.advice = flowRecord.getAdvice();
135153
this.signKey = flowRecord.getSignKey();
136154
this.approveTime = flowRecord.getCreateTime();
155+
this.actionName = flowRecord.getActionName();
137156
this.flowOperator = new FlowOperator(flowRecord.getCurrentOperatorId(), flowRecord.getCurrentOperatorName());
138157
}
139158

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ public class FlowRecord {
103103
*/
104104
private String actionType;
105105

106+
/**
107+
* 动作名称
108+
*/
109+
private String actionName;
110+
106111
/**
107112
* 审批意见
108113
*/
@@ -161,11 +166,11 @@ public class FlowRecord {
161166
private boolean notify;
162167

163168
/**
164-
* 节点状态 | 待办、已办
169+
* 节点状态 | 待办 0、已办 1
165170
*/
166171
private int recordState;
167172
/**
168-
* 流程状态 | 运行中已完成、异常、删除
173+
* 流程状态 | 运行中 0、终止 1 已完成 2、异常 3、删除 4
169174
*/
170175
private int flowState;
171176
/**
@@ -277,6 +282,7 @@ public FlowRecord(FlowSession flowSession, int nodeOrder) {
277282
this.recordState = SATE_RECORD_TODO;
278283
this.actionId = action.id();
279284
this.actionType = action.type();
285+
this.actionName = action.title();
280286

281287
this.currentOperatorId = currentOperator.getUserId();
282288
this.currentOperatorName = currentOperator.getName();
@@ -406,6 +412,7 @@ public void update(FlowSession flowSession, boolean pass) {
406412
this.formData = flowSession.getFormData().toMapData();
407413
this.actionId = flowAction.id();
408414
this.actionType = flowAction.type();
415+
this.actionName = flowAction.title();
409416
this.readable = true;
410417
this.readTime = System.currentTimeMillis();
411418
this.updateTime = System.currentTimeMillis();

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

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,39 @@ private void loadWorkflow() {
8282
public List<ProcessNode> processNodes() {
8383
long backupId = 0;
8484
if (this.flowRecord != null) {
85-
backupId = this.flowRecord.getWorkBackupId();
86-
// 查询历史记录
87-
List<FlowRecord> historyRecords = flowRecordRepository.findBeforeRecords(flowRecord.getProcessId(), flowRecord.getId());
88-
for (FlowRecord historyRecord : historyRecords) {
89-
ProcessNode processNode = new ProcessNode(historyRecord, this.workflow);
90-
nodeList.add(processNode);
85+
// 如果当前记录已结束,则不查询后续流程
86+
if(this.flowRecord.isDone()){
87+
88+
List<FlowRecord> historyRecords = flowRecordRepository.findProcessRecords(this.flowRecord.getProcessId());
89+
for (FlowRecord historyRecord : historyRecords) {
90+
ProcessNode processNode = new ProcessNode(historyRecord, this.workflow);
91+
nodeList.add(processNode);
92+
}
93+
94+
if(this.flowRecord.isFinish()){
95+
nodeList.add(ProcessNode.createEndNode(this.workflow));
96+
}
97+
98+
return this.nodeList;
99+
}else {
100+
backupId = this.flowRecord.getWorkBackupId();
101+
// 查询历史记录
102+
List<FlowRecord> historyRecords = flowRecordRepository.findBeforeRecords(flowRecord.getProcessId(), flowRecord.getId());
103+
for (FlowRecord historyRecord : historyRecords) {
104+
ProcessNode processNode = new ProcessNode(historyRecord, this.workflow);
105+
nodeList.add(processNode);
106+
}
91107
}
92108
}
93109

110+
this.loadNextNode(backupId);
111+
112+
return this.nodeList;
113+
}
114+
115+
116+
private void loadNextNode(long backupId){
117+
94118
ActionManager actionManager = currentNode.actionManager();
95119
IFlowAction flowAction = actionManager.getAction(PassAction.class);
96120
FormData formData = new FormData(this.workflow.getForm());
@@ -112,7 +136,6 @@ public List<ProcessNode> processNodes() {
112136
List<ProcessNode> nextNodes = nextNodeLoader.loadNextNode(flowSession);
113137

114138
this.nodeList.addAll(nextNodes);
115-
return this.nodeList;
116139
}
117140

118141

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
@@ -26,6 +26,7 @@ public static FlowRecord convert(FlowRecordEntity entity) {
2626
entity.getProcessId(),
2727
entity.getActionId(),
2828
entity.getActionType(),
29+
entity.getActionName(),
2930
entity.getAdvice(),
3031
entity.getSignKey(),
3132
entity.getCurrentOperatorId(),
@@ -77,6 +78,7 @@ public static FlowRecordEntity convert(FlowRecord record) {
7778
entity.setProcessId(record.getProcessId());
7879
entity.setActionId(record.getActionId());
7980
entity.setActionType(record.getActionType());
81+
entity.setActionName(record.getActionName());
8082
entity.setAdvice(record.getAdvice());
8183
entity.setSignKey(record.getSignKey());
8284
entity.setCurrentOperatorId(record.getCurrentOperatorId());

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public class FlowRecordEntity {
7070
*/
7171
private String actionType;
7272

73+
/**
74+
* 动作名称
75+
*/
76+
private String actionName;
77+
7378
/**
7479
* 审批意见
7580
*/

frontend/apps/app-pc/src/pages/todo.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const TodoPage: React.FC = () => {
1616

1717
const [selectVisible, setSelectVisible] = React.useState(false);
1818
const [approvalVisible, setApprovalVisible] = React.useState(false);
19+
const [reviewVisible, setReviewVisible] = React.useState(false);
1920
const [workflowCode, setWorkflowCode] = React.useState<string>('');
2021
const [currentRecordId, setCurrentRecordId] = React.useState<string>('');
2122
const [currentTab, setCurrentTab] = React.useState<string>('todo');
@@ -80,11 +81,24 @@ const TodoPage: React.FC = () => {
8081
<a
8182
onClick={() => {
8283
setCurrentRecordId(record.recordId);
84+
setReviewVisible(false);
8385
setApprovalVisible(true);
8486
}}
8587
>办理</a>
8688
</Space>
8789
)
90+
}else {
91+
return (
92+
<Space>
93+
<a
94+
onClick={() => {
95+
setCurrentRecordId(record.recordId);
96+
setReviewVisible(true);
97+
setApprovalVisible(true);
98+
}}
99+
>详情</a>
100+
</Space>
101+
)
88102
}
89103

90104
}
@@ -185,6 +199,7 @@ const TodoPage: React.FC = () => {
185199
type={'primary'}
186200
onClick={() => {
187201
setCurrentRecordId('');
202+
setReviewVisible(false);
188203
setSelectVisible(true);
189204
}}>发起流程</Button>
190205
)
@@ -207,6 +222,7 @@ const TodoPage: React.FC = () => {
207222
workflowCode={workflowCode}
208223
open={approvalVisible}
209224
recordId={currentRecordId}
225+
review={reviewVisible}
210226
onClose={() => {
211227
setApprovalVisible(false);
212228
reloadCurrentTab();

frontend/packages/flow-pc/flow-pc-approval/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@flow-engine/flow-pc-form": "workspace:*",
3232
"@reduxjs/toolkit": "^2.11.2",
3333
"antd": "^6.2.1",
34+
"dayjs": "^1.11.19",
3435
"immer": "^11.1.3",
3536
"react-redux": "^9.2.0"
3637
},

0 commit comments

Comments
 (0)