33import com .codingapi .flow .action .ActionDisplay ;
44import com .codingapi .flow .action .ActionType ;
55import com .codingapi .flow .action .BaseAction ;
6+ import com .codingapi .flow .context .ActionResponseContext ;
67import com .codingapi .flow .event .FlowRecordDoneEvent ;
78import com .codingapi .flow .event .FlowRecordTodoEvent ;
89import com .codingapi .flow .event .IFlowEvent ;
910import com .codingapi .flow .manager .NodeStrategyManager ;
1011import com .codingapi .flow .node .BaseAuditNode ;
1112import com .codingapi .flow .node .IFlowNode ;
13+ import com .codingapi .flow .node .nodes .ManualNode ;
1214import com .codingapi .flow .operator .IFlowOperator ;
15+ import com .codingapi .flow .pojo .response .NodeOption ;
1316import com .codingapi .flow .record .FlowRecord ;
1417import com .codingapi .flow .session .FlowSession ;
1518import com .codingapi .flow .session .IRepositoryHolder ;
@@ -71,10 +74,25 @@ public void run(FlowSession flowSession) {
7174 List <FlowRecord > recordList = new ArrayList <>();
7275 FlowRecord currentRecord = flowSession .getCurrentRecord ();
7376 IFlowNode currentNode = flowSession .getCurrentNode ();
77+
78+ // 如果下节点为手动节点时,提交流程时需要先选择节点
79+ List <IFlowNode > nextNodes = flowSession .matchNextNodes ();
80+ if (nextNodes != null && nextNodes .size () == 1 ) {
81+ IFlowNode nextNode = nextNodes .get (0 );
82+ if (nextNode .getType ().equalsIgnoreCase (ManualNode .NODE_TYPE )) {
83+ IFlowNode manulNode = flowSession .getAdvice ().getManualNode ();
84+ if (manulNode == null && nextNode .blocks () != null ) {
85+ List <NodeOption > options = nextNode .blocks ().stream ().map (NodeOption ::new ).toList ();
86+ ActionResponseContext .getInstance ().set (options );
87+ return ;
88+ }
89+ }
90+ }
91+
7492 boolean isFinish = currentNode .isFinish (flowSession );
7593 currentRecord .update (flowSession , true );
7694 // 添加流程结束事件
77- flowEvents .add (new FlowRecordDoneEvent (currentRecord ,flowSession .isMock ()));
95+ flowEvents .add (new FlowRecordDoneEvent (currentRecord , flowSession .isMock ()));
7896 recordList .add (currentRecord );
7997
8098 // 激活下一个按顺序审批的记录数据
@@ -85,7 +103,7 @@ public void run(FlowSession flowSession) {
85103 if (record .getNodeOrder () == currentRecord .getNodeOrder () + 1 ) {
86104 record .show ();
87105 recordList .add (record );
88- flowEvents .add (new FlowRecordTodoEvent (record ,flowSession .isMock ()));
106+ flowEvents .add (new FlowRecordTodoEvent (record , flowSession .isMock ()));
89107 }
90108 }
91109 }
@@ -98,7 +116,7 @@ public void run(FlowSession flowSession) {
98116 notifyRecord .notifyRecord (flowSession .updateSession (forwardOperator ));
99117 // 如果不存储这个记录,若下一流程是结束流程时,无法更新流程状态为结束状态。
100118 repositoryHolder .saveRecord (notifyRecord );
101- flowEvents .add (new FlowRecordDoneEvent (notifyRecord ,flowSession .isMock ()));
119+ flowEvents .add (new FlowRecordDoneEvent (notifyRecord , flowSession .isMock ()));
102120 }
103121
104122 // 是否委托记录
@@ -109,17 +127,17 @@ public void run(FlowSession flowSession) {
109127 rebackRecord .clearDelegate ();
110128
111129 recordList .add (rebackRecord );
112- flowEvents .add (new FlowRecordTodoEvent (rebackRecord ,flowSession .isMock ()));
130+ flowEvents .add (new FlowRecordTodoEvent (rebackRecord , flowSession .isMock ()));
113131 } else {
114132 this .triggerNode (flowSession , (triggerSession ) -> {
115133 List <FlowRecord > records = this .generateRecords (triggerSession );
116134 if (!records .isEmpty ()) {
117135 for (FlowRecord record : records ) {
118136 if (record .isShow ()) {
119137 if (record .isNotify ()) {
120- flowEvents .add (new FlowRecordDoneEvent (record ,flowSession .isMock ()));
138+ flowEvents .add (new FlowRecordDoneEvent (record , flowSession .isMock ()));
121139 } else {
122- flowEvents .add (new FlowRecordTodoEvent (record ,flowSession .isMock ()));
140+ flowEvents .add (new FlowRecordTodoEvent (record , flowSession .isMock ()));
123141 }
124142 }
125143 }
0 commit comments