feat(robot): 添加机器人地图名称字段并支持任务类型查询
- 在 InspectionRobotMapper.xml 中添加 robotMapName 字段映射 - 修改数据库查询语句以包含 map_source_name 作为 robot_map_name - 在 InspectionTaskInstanceMapper.xml 中添加任务类型查询条件 - 为 InspectionTaskInstanceQuery DTO 添加 taskType 属性 - 在 TeFlowiseController 中添加流程控制相关依赖注入 - 实现任务实例执行和终止功能,包括运行参数配置和流程控制 - 添加任务实例 ID 列表管理以支持任务启停操作
This commit is contained in:
parent
33507dc475
commit
fdd6019a77
@ -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<String> 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("执行指令")
|
||||
|
||||
@ -25,4 +25,7 @@ public class InspectionTaskInstanceQuery {
|
||||
@ApiModelProperty("多状态集合,in查询用:0待执行 1执行中 2已完成 3已取消 4执行失败 5已暂停")
|
||||
private List<Integer> statusList;
|
||||
|
||||
@ApiModelProperty("任务类型")
|
||||
private String taskType;
|
||||
|
||||
}
|
||||
@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="port" column="port" />
|
||||
<result property="currentMapId" column="current_map_id" />
|
||||
<result property="currentMapName" column="current_map_name" />
|
||||
<result property="robotMapName" column="robot_map_name" />
|
||||
<result property="status" column="status" />
|
||||
<result property="batteryLevel" column="battery_level" />
|
||||
<result property="currentPosition" column="current_position" />
|
||||
@ -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 <!-- 创建人关联用户 -->
|
||||
|
||||
@ -157,6 +157,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="(statusList == null or statusList.size() == 0) and status != null">
|
||||
and ti.status = #{status}
|
||||
</if>
|
||||
<!-- 任务类型 -->
|
||||
<if test="taskType != null and taskType != ''">
|
||||
and t.task_type = #{taskType}
|
||||
</if>
|
||||
</where>
|
||||
order by ti.create_time desc
|
||||
</select>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user