Skip to content

Commit fe137f4

Browse files
committed
fix bug
1 parent 4a059b9 commit fe137f4

File tree

5 files changed

+51
-21
lines changed

5 files changed

+51
-21
lines changed

admin-ui/src/pages/flow/record/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ const FlowRecordPage = () => {
4949
dataIndex: 'id',
5050
search: false
5151
},
52+
{
53+
title: 'pre编号',
54+
dataIndex: 'preId',
55+
search: false
56+
},
5257
{
5358
title: '流程编号',
5459
dataIndex: 'processId',

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static FlowRecordEntity convert(FlowRecord flowRecord, UserRepository use
2424
entity.setTitle(flowRecord.getTitle());
2525
entity.setCurrentOperatorId(flowRecord.getCurrentOperatorId());
2626
entity.setFlowType(flowRecord.getFlowType().name());
27-
if(flowRecord.getFlowSourceDirection()!= null){
27+
if (flowRecord.getFlowSourceDirection() != null) {
2828
entity.setFlowSourceDirection(flowRecord.getFlowSourceDirection().name());
2929
}
3030
entity.setCreateTime(flowRecord.getCreateTime());
@@ -48,6 +48,10 @@ public static FlowRecordEntity convert(FlowRecord flowRecord, UserRepository use
4848
entity.setSnapshotId(flowRecord.getSnapshotId());
4949
entity.setRead(flowRecord.isRead());
5050
entity.setInterfere(flowRecord.isInterfere());
51+
entity.setInterferedOperatorId(flowRecord.getInterferedOperatorId());
52+
if (flowRecord.isInterfere() && flowRecord.getInterferedOperatorId() > 0) {
53+
entity.setInterferedOperatorName(userRepository.getUserById(flowRecord.getInterferedOperatorId()).getName());
54+
}
5155
entity.setReadTime(flowRecord.getReadTime());
5256
return entity;
5357
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ public class FlowRecordEntity {
130130
*/
131131
private Boolean interfere;
132132

133+
/**
134+
* 被干预的用户
135+
*/
136+
private Long interferedOperatorId;
137+
138+
/**
139+
* 被干预的用户
140+
*/
141+
private String interferedOperatorName;
142+
133143
/**
134144
* 已读时间
135145
*/

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import com.codingapi.springboot.flow.bind.BindDataSnapshot;
44
import com.codingapi.springboot.flow.domain.FlowNode;
55
import com.codingapi.springboot.flow.domain.Opinion;
6+
import com.codingapi.springboot.flow.em.FlowSourceDirection;
67
import com.codingapi.springboot.flow.em.FlowStatus;
78
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;
@@ -89,7 +89,7 @@ public class FlowRecord {
8989
*/
9090
private long createOperatorId;
9191
/**
92-
* 审批意见
92+
* 审批意见 (为办理时为空)
9393
*/
9494
private Opinion opinion;
9595
/**
@@ -121,6 +121,11 @@ public class FlowRecord {
121121
*/
122122
private boolean interfere;
123123

124+
/**
125+
* 被干预的用户
126+
*/
127+
private long interferedOperatorId;
128+
124129
/**
125130
* 已读时间
126131
*/
@@ -193,17 +198,18 @@ public void submitStateVerify() {
193198
/**
194199
* 提交流程
195200
*
196-
* @param flowOperator 操作者
197-
* @param snapshot 绑定数据
198-
* @param opinion 意见
199-
* @param flowSourceDirection 流转方式
201+
* @param flowOperator 操作者
202+
* @param snapshot 绑定数据
203+
* @param opinion 意见
204+
* @param flowSourceDirection 流转方式
200205
*/
201206
public void submitRecord(IFlowOperator flowOperator, BindDataSnapshot snapshot, Opinion opinion, FlowSourceDirection flowSourceDirection) {
202207
if (!flowOperator.isFlowManager()) {
203208
if (flowOperator.getUserId() != this.currentOperatorId) {
204209
throw new IllegalArgumentException("current operator is not match");
205210
}
206211
} else {
212+
this.interferedOperatorId = this.currentOperatorId;
207213
this.currentOperatorId = flowOperator.getUserId();
208214
this.interfere = true;
209215
}
@@ -250,6 +256,8 @@ public void transferToTodo(String title, IFlowOperator operator) {
250256
this.title = title;
251257
this.opinion = null;
252258
this.flowSourceDirection = null;
259+
this.interfere = false;
260+
this.interferedOperatorId = 0;
253261
this.currentOperatorId = operator.getUserId();
254262
}
255263

@@ -319,6 +327,7 @@ public boolean isPass() {
319327

320328
/**
321329
* 匹配操作者
330+
*
322331
* @param currentOperator 当前操作者
323332
*/
324333
public void matcherOperator(IFlowOperator currentOperator) {
@@ -329,6 +338,7 @@ public void matcherOperator(IFlowOperator currentOperator) {
329338

330339
/**
331340
* 是否是当前操作者
341+
*
332342
* @param operator 操作者
333343
* @return 是否是当前操作者
334344
*/
@@ -370,6 +380,7 @@ public FlowRecord copy() {
370380
record.setSnapshotId(this.snapshotId);
371381
record.setRead(this.read);
372382
record.setInterfere(this.interfere);
383+
record.setInterferedOperatorId(this.interferedOperatorId);
373384
record.setReadTime(this.readTime);
374385
return record;
375386
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/FlowService.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ public void submitFlow(long recordId, IFlowOperator currentOperator, IBindData b
382382
}
383383
flowRecord.submitStateVerify();
384384

385+
// 非流程管理员需要核验身份
385386
if (!currentOperator.isFlowManager()) {
386387
flowRecord.matcherOperator(currentOperator);
387388
}
@@ -494,6 +495,7 @@ public void submitFlow(long recordId, IFlowOperator currentOperator, IBindData b
494495
* @param historyRecords 历史记录
495496
*/
496497
private void createNextRecord(FlowWork flowWork, FlowSourceDirection flowSourceDirection, FlowNode flowNode, String processId, IFlowOperator createOperator, IFlowOperator currentOperator, BindDataSnapshot snapshot, Opinion opinion, FlowRecord flowRecord, List<FlowRecord> historyRecords){
498+
long preId = flowRecord.getId();
497499
// 拥有退出条件 或审批通过时,匹配下一节点
498500
if (flowWork.hasBackRelation() || flowSourceDirection== FlowSourceDirection.PASS) {
499501

@@ -517,13 +519,7 @@ private void createNextRecord(FlowWork flowWork, FlowSourceDirection flowSourceD
517519
}
518520
flowRecordService.changeCurrentOperator(flowOperator);
519521

520-
List<FlowRecord> records = flowRecordService.createRecord(flowRecord.getId(), nextNode);
521-
flowRecordRepository.save(records);
522-
523-
for (FlowRecord record : records) {
524-
IFlowOperator pushOperator = flowOperatorRepository.getFlowOperatorById(record.getCurrentOperatorId());
525-
EventPusher.push(new FlowApprovalEvent(FlowApprovalEvent.STATE_TODO, record, pushOperator,flowWork));
526-
}
522+
this.createNexRecordList(flowRecordService,preId,nextNode,flowWork);
527523

528524
} else {
529525
IFlowOperator flowOperator;
@@ -543,20 +539,24 @@ private void createNextRecord(FlowWork flowWork, FlowSourceDirection flowSourceD
543539
if (nextNode == null) {
544540
throw new IllegalArgumentException("next node not found");
545541
}
546-
List<FlowRecord> records = flowRecordService.createRecord(preRecord.getId(), nextNode);
547-
flowRecordRepository.save(records);
548-
549-
for (FlowRecord record : records) {
550-
IFlowOperator pushOperator = flowOperatorRepository.getFlowOperatorById(record.getCurrentOperatorId());
551-
EventPusher.push(new FlowApprovalEvent(FlowApprovalEvent.STATE_TODO, record, pushOperator,flowWork));
552-
}
542+
this.createNexRecordList(flowRecordService,preId,nextNode,flowWork);
553543
}
554544

555545
int eventState = flowSourceDirection== FlowSourceDirection.PASS ? FlowApprovalEvent.STATE_PASS : FlowApprovalEvent.STATE_REJECT;
556546
EventPusher.push(new FlowApprovalEvent(eventState, flowRecord, currentOperator,flowWork));
557547

558548
}
559549

550+
private void createNexRecordList(FlowRecordService flowRecordService,long preId,FlowNode nextNode,FlowWork flowWork){
551+
List<FlowRecord> records = flowRecordService.createRecord(preId, nextNode);
552+
flowRecordRepository.save(records);
553+
554+
for (FlowRecord record : records) {
555+
IFlowOperator pushOperator = flowOperatorRepository.getFlowOperatorById(record.getCurrentOperatorId());
556+
EventPusher.push(new FlowApprovalEvent(FlowApprovalEvent.STATE_TODO, record, pushOperator,flowWork));
557+
}
558+
}
559+
560560

561561
/**
562562
* 撤回流程

0 commit comments

Comments
 (0)