feat: 新增获取循环对象节点
This commit is contained in:
parent
f365d94077
commit
264eb3e5ad
@ -11,7 +11,6 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -108,20 +107,4 @@ public class ViCorpusController extends BaseController {
|
||||
public AjaxResult continuousRemove(@RequestBody String[] parentIds) {
|
||||
return toAjax(viCorpusService.deleteViCorpusByParentIds(parentIds));
|
||||
}
|
||||
|
||||
/* @ApiOperation("批量修改")
|
||||
@PreAuthorize("@ss.hasPermi('vi:corpus:edit')")
|
||||
@PostMapping("/updateBatch")
|
||||
public AjaxResult updateBatch(@RequestBody List<ViCorpus> data) {
|
||||
return toAjax(viCorpusService.updateBatch(data));
|
||||
}*/
|
||||
|
||||
/* @ApiOperation("批量新增/修改")
|
||||
@PreAuthorize("@ss.hasPermi('vi:corpus:edit')")
|
||||
@PostMapping("/insertOrUpdateBatch")
|
||||
public AjaxResult insertOrUpdateBatch(@RequestBody List<ViCorpus> data) {
|
||||
return toAjax(viCorpusService.insertOrUpdateBatch(data));
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ public enum ActionEnum {
|
||||
SLEEP("NONE", "SLEEP", "延迟节点"),
|
||||
HTTP("NONE", "HTTP", "HTTP调用"),
|
||||
CODE("NONE", "CODE", "代码执行"),
|
||||
GET_CURRENT_OBJECT("NONE", "GET_CURRENT_OBJECT", "获取当前循环对象"),
|
||||
// AI评估
|
||||
AI_EVALUATION_PRE("AE", "AI_EVALUATION_PRE", "AI评估预处理"),
|
||||
// AI评估
|
||||
|
||||
@ -20,6 +20,7 @@ public enum NodeTypeEnum {
|
||||
SLEEP("sleep"),
|
||||
HTTP("http"),
|
||||
CODE("code"),
|
||||
GET_CURRENT_OBJECT("getCurrentObject"),
|
||||
SUB_END("subEnd"),
|
||||
;
|
||||
|
||||
|
||||
@ -290,6 +290,8 @@ public class FlowModelBuilder {
|
||||
return NodeTypeEnum.HTTP;
|
||||
case "code":
|
||||
return NodeTypeEnum.CODE;
|
||||
case "currentloop":
|
||||
return NodeTypeEnum.GET_CURRENT_OBJECT;
|
||||
default:
|
||||
return NodeTypeEnum.FUNCTION;
|
||||
}
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
package com.cmvr.test.flow.runtime.dispatcher;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cmvr.test.flow.runtime.message.TaskNodeExecuteMessage;
|
||||
import com.cmvr.test.flow.runtime.message.TaskNodeExecuteResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component("GET_CURRENT_OBJECT")
|
||||
public class FlowGetCurrentObjNodeHandler implements FlowNodeTypeHandler {
|
||||
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
return TaskNodeExecuteResult.success(output);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[FLOW][GET_CURRENT_OBJECT] 执行异常", e);
|
||||
return TaskNodeExecuteResult.failure(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.cmvr.test.flow.runtime.engine.support;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cmvr.common.exception.GlobalException;
|
||||
@ -99,7 +100,13 @@ public class FlowNodeParamPreparer {
|
||||
loopCount = ((Number) target).intValue();
|
||||
} else if (target != null) {
|
||||
try {
|
||||
loopCount = Integer.parseInt(target.toString());
|
||||
String string = target.toString();
|
||||
if (string.startsWith("[")) {
|
||||
JSONArray array = JSON.parseArray(string);
|
||||
loopCount = array.size();
|
||||
}else {
|
||||
loopCount = Integer.parseInt(string);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new GlobalException("loopNum 参数格式错误: " + loopNumVal);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user