|
4 | 4 | import com.codingapi.springboot.flow.bind.IBindData; |
5 | 5 | import com.codingapi.springboot.flow.domain.FlowNode; |
6 | 6 | import com.codingapi.springboot.flow.domain.FlowWork; |
| 7 | +import com.codingapi.springboot.flow.domain.Opinion; |
7 | 8 | import com.codingapi.springboot.flow.record.FlowRecord; |
8 | 9 | import com.codingapi.springboot.flow.user.IFlowOperator; |
9 | 10 | import lombok.Getter; |
|
12 | 13 |
|
13 | 14 |
|
14 | 15 | /** |
15 | | - * 流程详情的阻止对象 |
| 16 | + * 流程详情的阻止对象 |
16 | 17 | */ |
17 | 18 | @Getter |
18 | 19 | public class FlowDetail { |
19 | 20 |
|
| 21 | + /** |
| 22 | + * 当前流程 |
| 23 | + */ |
20 | 24 | private final FlowRecord flowRecord; |
| 25 | + /** |
| 26 | + * 流程设计器 |
| 27 | + */ |
21 | 28 | private final FlowWork flowWork; |
| 29 | + /** |
| 30 | + * 流程节点 |
| 31 | + */ |
22 | 32 | private final FlowNode flowNode; |
| 33 | + /** |
| 34 | + * 历史流程 |
| 35 | + */ |
23 | 36 | private final List<FlowRecord> historyRecords; |
24 | | - private final BindDataSnapshot snapshot; |
| 37 | + /** |
| 38 | + * 绑定数据 |
| 39 | + */ |
25 | 40 | private final IBindData bindData; |
| 41 | + /** |
| 42 | + * 全部的操作人 |
| 43 | + */ |
26 | 44 | private final List<? extends IFlowOperator> operators; |
27 | 45 |
|
| 46 | + /** |
| 47 | + * 创建者 |
| 48 | + */ |
| 49 | + private final IFlowOperator flowCreator; |
| 50 | + |
| 51 | + /** |
| 52 | + * 创建时间 |
| 53 | + */ |
| 54 | + private final long flowCreateTime; |
| 55 | + |
| 56 | + /** |
| 57 | + * 流程的意见 |
| 58 | + */ |
| 59 | + private final List<FlowOpinion> opinions; |
| 60 | + |
| 61 | + |
28 | 62 | public FlowDetail(FlowRecord flowRecord, |
29 | 63 | BindDataSnapshot snapshot, |
30 | 64 | FlowWork flowWork, |
31 | 65 | List<FlowRecord> historyRecords, |
32 | | - List<? extends IFlowOperator> operators) { |
| 66 | + List<? extends IFlowOperator> operators) { |
33 | 67 | this.operators = operators; |
34 | 68 | this.flowRecord = flowRecord; |
35 | | - this.snapshot = snapshot; |
36 | 69 | this.flowWork = flowWork; |
37 | 70 | this.bindData = snapshot.toBindData(); |
38 | | - this.historyRecords = historyRecords; |
| 71 | + this.historyRecords = historyRecords. |
| 72 | + stream(). |
| 73 | + sorted((o1, o2) -> (int) (o1.getCreateTime() - o2.getCreateTime())) |
| 74 | + .toList(); |
| 75 | + this.opinions = historyRecords.stream().map(FlowOpinion::new).toList(); |
| 76 | + this.flowCreator = operators.stream().filter(o -> o.getUserId() == flowRecord.getCreateOperatorId()).findFirst().orElse(null); |
| 77 | + this.flowCreateTime = flowRecord.getCreateTime(); |
39 | 78 | this.flowNode = flowWork.getNodeByCode(flowRecord.getNodeCode()); |
40 | 79 | } |
| 80 | + |
| 81 | + |
| 82 | + @Getter |
| 83 | + public final class FlowOpinion { |
| 84 | + private final long recordId; |
| 85 | + private final Opinion opinion; |
| 86 | + private final IFlowOperator operator; |
| 87 | + private final long createTime; |
| 88 | + |
| 89 | + public FlowOpinion(FlowRecord flowRecord) { |
| 90 | + this.recordId = flowRecord.getId(); |
| 91 | + this.opinion = flowRecord.getOpinion(); |
| 92 | + this.operator = operators.stream().filter(o -> o.getUserId() == flowRecord.getCurrentOperatorId()).findFirst().orElse(null); |
| 93 | + this.createTime = flowRecord.getUpdateTime(); |
| 94 | + } |
| 95 | + } |
| 96 | + |
41 | 97 | } |
0 commit comments