From fdd6019a77bd4f4e9ee93fe1d8a38a3d0271de62 Mon Sep 17 00:00:00 2001 From: lixiaolong <702156524@qq.com> Date: Mon, 15 Jun 2026 16:46:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(robot):=20=E6=B7=BB=E5=8A=A0=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E4=BA=BA=E5=9C=B0=E5=9B=BE=E5=90=8D=E7=A7=B0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=B9=B6=E6=94=AF=E6=8C=81=E4=BB=BB=E5=8A=A1=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 InspectionRobotMapper.xml 中添加 robotMapName 字段映射 - 修改数据库查询语句以包含 map_source_name 作为 robot_map_name - 在 InspectionTaskInstanceMapper.xml 中添加任务类型查询条件 - 为 InspectionTaskInstanceQuery DTO 添加 taskType 属性 - 在 TeFlowiseController 中添加流程控制相关依赖注入 - 实现任务实例执行和终止功能,包括运行参数配置和流程控制 - 添加任务实例 ID 列表管理以支持任务启停操作 --- .../controller/test/TeFlowiseController.java | 50 ++++++++++++++++++- .../dto/InspectionTaskInstanceQuery.java | 3 ++ .../inspection/InspectionRobotMapper.xml | 3 +- .../InspectionTaskInstanceMapper.xml | 4 ++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/test/TeFlowiseController.java b/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/test/TeFlowiseController.java index c2700a2..871492f 100644 --- a/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/test/TeFlowiseController.java +++ b/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/test/TeFlowiseController.java @@ -1,14 +1,22 @@ package com.cmvr.web.controller.test; +import com.alibaba.fastjson2.JSONObject; import com.cmvr.common.core.controller.BaseController; import com.cmvr.common.core.domain.AjaxResult; +import com.cmvr.test.flow.control.FlowControlService; +import com.cmvr.test.flow.runtime.engine.FlowTaskRuntimeService; +import com.cmvr.test.flow.runtime.operator.edge.ti.TiTouchOperateService; import com.cmvr.test.model.vo.FlowiseActionRequestVO; import com.cmvr.test.model.vo.FlowiseChatRequestVO; import com.cmvr.test.model.vo.FlowiseStartRequestVO; +import com.cmvr.test.model.vo.TeTaskExecuteNormalVO; +import com.cmvr.test.service.FlowActionExecutorService; import com.cmvr.test.service.FlowiseActionService; +import com.google.gson.JsonObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -16,6 +24,9 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; +import java.util.List; + @Api(tags = "测试--flowise服务") @RestController @RequestMapping("/flowise") @@ -23,11 +34,37 @@ import org.springframework.web.bind.annotation.RestController; public class TeFlowiseController extends BaseController { private final FlowiseActionService flowiseActionService; + private final FlowTaskRuntimeService flowTaskRuntimeService; + private final FlowControlService flowControlService; + private final FlowActionExecutorService flowActionExecutorService; + private final TiTouchOperateService tiTouchOperateService; + private final List taskInstIdList = new ArrayList<>(); @ApiOperation("调用flowise") @PostMapping("/start") public AjaxResult start(@RequestBody FlowiseStartRequestVO request) { - return AjaxResult.ok(flowiseActionService.start(request)); + TeTaskExecuteNormalVO taskExecuteNormalVO = new TeTaskExecuteNormalVO(); + + JSONObject runParams = new JSONObject(); + runParams.put("5bb26d52e1861c6936f3c3149eaf17e8", new JsonObject()); + runParams.getJSONObject("5bb26d52e1861c6936f3c3149eaf17e8").put("test", request.getQuestion()); + + taskExecuteNormalVO.builder() + .taskId("b6ab5ffff783d9b25d0dc34f13be222d") + .terminalId("18749f257ff902643bc1ea6ab33f8b04") + .runParams(JSONObject.from(runParams)); + if (!taskInstIdList.isEmpty()) { + try { + taskInstIdList.forEach(flowControlService::stop); + } catch (Exception e) { + // 忽略 + } + taskInstIdList.clear(); + } + String insId = flowTaskRuntimeService.executeTask(taskExecuteNormalVO); + taskInstIdList.add(insId); + return AjaxResult.success(); +// return AjaxResult.ok(flowiseActionService.start(request)); } @ApiOperation("根据chatId查询执行结果") @@ -39,7 +76,16 @@ public class TeFlowiseController extends BaseController { @ApiOperation("终止flowise") @GetMapping("/abort") public AjaxResult abort() { - return AjaxResult.ok(flowiseActionService.abort()); + if (!taskInstIdList.isEmpty()) { + try { + taskInstIdList.forEach(flowControlService::stop); + } catch (Exception e) { + // 忽略 + } + taskInstIdList.clear(); + } + return AjaxResult.success(); +// return AjaxResult.ok(flowiseActionService.abort()); } @ApiOperation("执行指令") diff --git a/cmvr-iot-inspection/src/main/java/com/cmvr/inspection/domain/dto/InspectionTaskInstanceQuery.java b/cmvr-iot-inspection/src/main/java/com/cmvr/inspection/domain/dto/InspectionTaskInstanceQuery.java index 36807f4..0ddd38e 100644 --- a/cmvr-iot-inspection/src/main/java/com/cmvr/inspection/domain/dto/InspectionTaskInstanceQuery.java +++ b/cmvr-iot-inspection/src/main/java/com/cmvr/inspection/domain/dto/InspectionTaskInstanceQuery.java @@ -25,4 +25,7 @@ public class InspectionTaskInstanceQuery { @ApiModelProperty("多状态集合,in查询用:0待执行 1执行中 2已完成 3已取消 4执行失败 5已暂停") private List statusList; + @ApiModelProperty("任务类型") + private String taskType; + } \ No newline at end of file diff --git a/cmvr-iot-inspection/src/main/resources/mapper/inspection/InspectionRobotMapper.xml b/cmvr-iot-inspection/src/main/resources/mapper/inspection/InspectionRobotMapper.xml index 6808884..552a937 100644 --- a/cmvr-iot-inspection/src/main/resources/mapper/inspection/InspectionRobotMapper.xml +++ b/cmvr-iot-inspection/src/main/resources/mapper/inspection/InspectionRobotMapper.xml @@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -150,7 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" r.ip_address, r.port, r.current_map_id, m.map_name as current_map_name, r.status, r.battery_level, r.current_position, r.terminal_id, - u1.nick_name as create_by_name, u2.nick_name as update_by_name + u1.nick_name as create_by_name, u2.nick_name as update_by_name, m.map_source_name as robot_map_name from inspection_robot r left join inspection_map m on r.current_map_id = m.id left join sys_user u1 on r.create_by = u1.user_name diff --git a/cmvr-iot-inspection/src/main/resources/mapper/inspection/InspectionTaskInstanceMapper.xml b/cmvr-iot-inspection/src/main/resources/mapper/inspection/InspectionTaskInstanceMapper.xml index 2e43e2f..8b2aad8 100644 --- a/cmvr-iot-inspection/src/main/resources/mapper/inspection/InspectionTaskInstanceMapper.xml +++ b/cmvr-iot-inspection/src/main/resources/mapper/inspection/InspectionTaskInstanceMapper.xml @@ -157,6 +157,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and ti.status = #{status} + + + and t.task_type = #{taskType} + order by ti.create_time desc