fix: 获取当前循环对象和下标

This commit is contained in:
stream 2026-03-18 09:23:16 +08:00
parent 264eb3e5ad
commit 596d8ceb29

View File

@ -19,16 +19,17 @@ public class FlowGetCurrentObjNodeHandler implements FlowNodeTypeHandler {
public TaskNodeExecuteResult handle(TaskNodeExecuteMessage message) {
try {
JSONObject inputParams = message.getInputParams();
JSONArray jsonArray = inputParams.getJSONArray("array");
List<Integer> iterations = message.getIterations();
int last = CollUtil.getLast(iterations) - 1;
Object o = jsonArray.get(last);
JSONObject output = new JSONObject();
output.put("index", last);
output.put("object", o);
if (CollUtil.isNotEmpty(jsonArray) && last >= 0) {
output.put("object", jsonArray.get(last));
}
return TaskNodeExecuteResult.success(output);