1313import lombok .Data ;
1414
1515import java .util .ArrayList ;
16+ import java .util .HashMap ;
17+ import java .util .LinkedHashMap ;
1618import java .util .List ;
1719import java .util .Map ;
1820
@@ -146,6 +148,14 @@ public class FlowContent {
146148 */
147149 private FlowOperator currentOperator ;
148150
151+ /**
152+ * 当前节点待审批人员(不含当前操作人)
153+ *
154+ * <p>减签等动作的目标必须来自当前节点实例,不能从宿主用户列表随意选取:合并审批
155+ * 场景下每个流程实例的待审批人集合可能不同,候选人按流程实例维度计算。
156+ */
157+ private List <FlowOperator > currentNodeOperators ;
158+
149159 /**
150160 * 流程状态 | 运行中、已完成、异常、删除
151161 */
@@ -217,13 +227,14 @@ public void pushCurrentNode(FlowSession flowSession) {
217227 if (currentNode != null ) {
218228 ActionManager actionManager = currentNode .actionManager ();
219229 NodeStrategyManager strategyManager = currentNode .strategyManager ();
220- this .actions = actionManager .filterActions (flowSession ). stream (). map ( IFlowAction :: toMap ). toList ( );
221- this .actionList = actionManager .getActions (). stream (). map ( IFlowAction :: toMap ). toList ( );
230+ this .actions = toActionMaps ( actionManager .filterActions (flowSession ));
231+ this .actionList = toActionMaps ( actionManager .getActions ());
222232 this .adviceRequired = strategyManager .isAdviceRequired ();
223233 this .signRequired = strategyManager .isSignRequired ();
224234 this .adviceHidden = strategyManager .isAdviceHidden ();
225235 this .nodeId = currentNode .getId ();
226236 this .nodeName = currentNode .getName ();
237+ this .currentNodeOperators = loadCurrentNodeOperators (flowSession );
227238 this .nodeType = currentNode .getType ();
228239 this .fieldPermissions = strategyManager .getFieldPermissions ();
229240 Map <String , Object > nodeData = currentNode .toMap ();
@@ -233,6 +244,50 @@ public void pushCurrentNode(FlowSession flowSession) {
233244 }
234245 }
235246
247+ /**
248+ * 输出动作配置,并附加运行期能力标记。
249+ *
250+ * <p>{@code batchable} 表示该动作是否支持合并批量提交,由 {@link IFlowAction#batchable()} 声明。
251+ * 该标记只在响应中附加,不写入动作的持久化配置({@link IFlowAction#toMap()})。
252+ */
253+ private static List <Map <String , Object >> toActionMaps (List <IFlowAction > actions ) {
254+ return actions .stream ().map (action -> {
255+ Map <String , Object > data = new HashMap <>(action .toMap ());
256+ data .put ("batchable" , action .batchable ());
257+ return data ;
258+ }).toList ();
259+ }
260+
261+ /**
262+ * 计算当前节点实例中的待审批人员(按人去重,排除当前操作人)。
263+ *
264+ * <p>口径与减签目标解析一致:仅取仍待审批的记录(含顺序审批中尚未激活的隐藏记录),
265+ * 且只取同一流程实例的数据,避免仓储按 {@code (fromId, nodeId)} 查询时混入其他流程实例。
266+ *
267+ * <p>合并审批是多条流程实例的待办聚合展示,各自的待审批人集合可能不同,
268+ * 因此候选人员只能按单条流程记录计算,不能跨流程合并。
269+ */
270+ private List <FlowOperator > loadCurrentNodeOperators (FlowSession flowSession ) {
271+ FlowRecord currentRecord = flowSession .getCurrentRecord ();
272+ List <FlowRecord > currentNodeRecords = flowSession .getCurrentNodeRecords ();
273+ if (currentRecord == null || currentNodeRecords == null ) {
274+ return List .of ();
275+ }
276+ long currentOperatorId = currentRecord .getCurrentOperatorId ();
277+ Map <Long , FlowOperator > operators = new LinkedHashMap <>();
278+ for (FlowRecord record : currentNodeRecords ) {
279+ if (record == null || !currentRecord .getProcessId ().equals (record .getProcessId ())) {
280+ continue ;
281+ }
282+ if (!record .isPendingApproval () || record .getCurrentOperatorId () == currentOperatorId ) {
283+ continue ;
284+ }
285+ operators .putIfAbsent (record .getCurrentOperatorId (),
286+ new FlowOperator (record .getCurrentOperatorId (), record .getCurrentOperatorName ()));
287+ }
288+ return List .copyOf (operators .values ());
289+ }
290+
236291 public void pushWorkflow (Workflow workflow ) {
237292 this .form = workflow .getForm ();
238293 this .workCode = workflow .getCode ();
0 commit comments