feat(flow): 集成流程引擎控制巡检任务执行

- 在 GlobalException 中添加对原始异常的支持,实现错误链路追踪
- 为巡检任务和任务实例实体增加任务配置ID和检测任务ID字段
- 更新数据映射文件以同步数据库结构变更
- 在任务实例服务中注入流程控制服务并实现执行、暂停、停止和恢复功能
- 优化任务上下文管理器中的终端ID空值处理逻辑
- 移除终端ID非空校验并调整相关业务逻辑
- 重构任务执行VO类以支持流程引擎调用参数传递
This commit is contained in:
lixiaolong 2026-06-02 16:53:07 +08:00
parent 8e4c122f9a
commit 68b2698614
15 changed files with 90 additions and 48 deletions

View File

@ -3,63 +3,55 @@ package com.cmvr.common.exception;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
/** /**
* 全局异常 * 全局自定义业务异常
*
* @author cmvrIot
*/ */
public class GlobalException extends RuntimeException public class GlobalException extends RuntimeException {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /** 前端展示提示信息 */
* 错误提示
*/
private String message; private String message;
/** 后端详细错误信息(数据库/原始异常详情) */
/**
* 错误明细内部调试错误
*
* {@link CommonResult#getDetailMessage()} 一致的设计
*/
private String detailMessage; private String detailMessage;
/** // 空构造序列化使用
* 空构造方法避免反序列化问题 public GlobalException() {
*/
public GlobalException()
{
} }
public GlobalException(String message) // 单纯提示信息
{ public GlobalException(String message) {
this.message = message; this.message = message;
} }
// 占位符格式化提示
public GlobalException(String template, Object... params) { public GlobalException(String template, Object... params) {
this.message = StrUtil.format(template, params); this.message = StrUtil.format(template, params);
} }
// 重点支持 提示+原始异常对应 throw new GlobalException("任务执行失败", e);
public GlobalException(String message, Throwable cause) {
super(cause); // 绑定原始异常栈日志可打全堆栈
this.message = message;
if (cause != null) {
this.detailMessage = cause.getMessage();
}
}
public String getDetailMessage() public String getDetailMessage() {
{
return detailMessage; return detailMessage;
} }
public GlobalException setDetailMessage(String detailMessage) public GlobalException setDetailMessage(String detailMessage) {
{
this.detailMessage = detailMessage; this.detailMessage = detailMessage;
return this; return this;
} }
@Override @Override
public String getMessage() public String getMessage() {
{
return message; return message;
} }
public GlobalException setMessage(String message) public GlobalException setMessage(String message) {
{
this.message = message; this.message = message;
return this; return this;
} }
} }

View File

@ -45,6 +45,6 @@ public class InspectionTask extends BaseEntity
/** 任务id */ /** 任务id */
@Excel(name = "任务id") @Excel(name = "任务id")
@ApiModelProperty("任务id") @ApiModelProperty("任务id")
private String teTaskConfigId; private String taskConfigId;
} }

View File

@ -52,4 +52,8 @@ public class InspectionTaskInstance extends BaseEntity
@ApiModelProperty("结束时间") @ApiModelProperty("结束时间")
private Date endTime; private Date endTime;
@Excel(name = "检测任务id")
@ApiModelProperty("检测任务id")
private String taskInsId;
} }

View File

@ -90,4 +90,8 @@ public class InspectionTaskInstanceVo extends BaseEntity
@ApiModelProperty("修改人昵称") @ApiModelProperty("修改人昵称")
private String updateByName; private String updateByName;
@Excel(name = "检测任务id")
@ApiModelProperty("检测任务id")
private String taskInsId;
} }

View File

@ -53,4 +53,9 @@ public class InspectionTaskVo extends BaseEntity
@ApiModelProperty("修改人昵称") @ApiModelProperty("修改人昵称")
private String updateByName; private String updateByName;
/** 任务id */
@Excel(name = "任务id")
@ApiModelProperty("任务id")
private String taskConfigId;
} }

View File

@ -8,6 +8,9 @@ import com.cmvr.common.exception.ServiceException;
import com.cmvr.common.utils.SecurityUtils; import com.cmvr.common.utils.SecurityUtils;
import com.cmvr.inspection.domain.vo.InspectionTaskInstanceVo; import com.cmvr.inspection.domain.vo.InspectionTaskInstanceVo;
import com.cmvr.inspection.enums.TaskStatusEnum; import com.cmvr.inspection.enums.TaskStatusEnum;
import com.cmvr.test.flow.control.FlowControlService;
import com.cmvr.test.flow.runtime.engine.FlowTaskRuntimeService;
import com.cmvr.test.model.vo.TeTaskExecuteNormalVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.cmvr.common.utils.DateUtils; import com.cmvr.common.utils.DateUtils;
@ -27,6 +30,11 @@ public class InspectionTaskInstanceServiceImpl extends ServiceImpl<InspectionTas
@Autowired @Autowired
private InspectionTaskInstanceMapper inspectionTaskInstanceMapper; private InspectionTaskInstanceMapper inspectionTaskInstanceMapper;
@Autowired
private FlowTaskRuntimeService flowTaskRuntimeService;
@Autowired
private FlowControlService flowControlService;
/** /**
* 查询巡检任务执行实例视图详情包含关联信息 * 查询巡检任务执行实例视图详情包含关联信息
* *
@ -125,6 +133,8 @@ public class InspectionTaskInstanceServiceImpl extends ServiceImpl<InspectionTas
update.setStartTime(DateUtils.getNowDate()); update.setStartTime(DateUtils.getNowDate());
update.setUpdateTime(DateUtils.getNowDate()); update.setUpdateTime(DateUtils.getNowDate());
update.setUpdateBy(SecurityUtils.getUsername()); update.setUpdateBy(SecurityUtils.getUsername());
// 调用真正的执行
flowTaskRuntimeService.executeTask(TeTaskExecuteNormalVO.builder().taskId(instance.getTaskInsId()).build());
return inspectionTaskInstanceMapper.updateInspectionTaskInstance(update); return inspectionTaskInstanceMapper.updateInspectionTaskInstance(update);
} }
@ -146,6 +156,7 @@ public class InspectionTaskInstanceServiceImpl extends ServiceImpl<InspectionTas
update.setStatus(TaskStatusEnum.PAUSED.getCode()); update.setStatus(TaskStatusEnum.PAUSED.getCode());
update.setUpdateTime(DateUtils.getNowDate()); update.setUpdateTime(DateUtils.getNowDate());
update.setUpdateBy(SecurityUtils.getUsername()); update.setUpdateBy(SecurityUtils.getUsername());
flowControlService.pause(instance.getTaskInsId());
return inspectionTaskInstanceMapper.updateInspectionTaskInstance(update); return inspectionTaskInstanceMapper.updateInspectionTaskInstance(update);
} }
@ -168,6 +179,7 @@ public class InspectionTaskInstanceServiceImpl extends ServiceImpl<InspectionTas
update.setEndTime(DateUtils.getNowDate()); update.setEndTime(DateUtils.getNowDate());
update.setUpdateTime(DateUtils.getNowDate()); update.setUpdateTime(DateUtils.getNowDate());
update.setUpdateBy(SecurityUtils.getUsername()); update.setUpdateBy(SecurityUtils.getUsername());
flowControlService.stop(instance.getTaskInsId());
return inspectionTaskInstanceMapper.updateInspectionTaskInstance(update); return inspectionTaskInstanceMapper.updateInspectionTaskInstance(update);
} }
@ -189,6 +201,7 @@ public class InspectionTaskInstanceServiceImpl extends ServiceImpl<InspectionTas
update.setStatus(TaskStatusEnum.RUNNING.getCode()); update.setStatus(TaskStatusEnum.RUNNING.getCode());
update.setUpdateTime(DateUtils.getNowDate()); update.setUpdateTime(DateUtils.getNowDate());
update.setUpdateBy(SecurityUtils.getUsername()); update.setUpdateBy(SecurityUtils.getUsername());
flowControlService.resume(instance.getTaskInsId());
return inspectionTaskInstanceMapper.updateInspectionTaskInstance(update); return inspectionTaskInstanceMapper.updateInspectionTaskInstance(update);
} }
} }

View File

@ -86,7 +86,7 @@ public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper,
// 同步新增任务 // 同步新增任务
TeTaskConfigInfo teTaskConfigInfo = TeTaskConfigInfo.builder().taskName(inspectionTask.getTaskName()).build(); TeTaskConfigInfo teTaskConfigInfo = TeTaskConfigInfo.builder().taskName(inspectionTask.getTaskName()).build();
teTaskConfigInfoService.insertTeTaskConfigInfo(teTaskConfigInfo); teTaskConfigInfoService.insertTeTaskConfigInfo(teTaskConfigInfo);
inspectionTask.setTeTaskConfigId(teTaskConfigInfo.getId()); inspectionTask.setTaskConfigId(teTaskConfigInfo.getId());
return inspectionTaskMapper.insertInspectionTask(inspectionTask); return inspectionTaskMapper.insertInspectionTask(inspectionTask);
} }
@ -101,7 +101,7 @@ public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper,
{ {
inspectionTask.setUpdateTime(DateUtils.getNowDate()); inspectionTask.setUpdateTime(DateUtils.getNowDate());
inspectionTask.setUpdateBy(SecurityUtils.getUsername()); inspectionTask.setUpdateBy(SecurityUtils.getUsername());
TeTaskConfigInfo teTaskConfigInfo = teTaskConfigInfoService.selectTeTaskConfigInfoById(inspectionTask.getTeTaskConfigId()); TeTaskConfigInfo teTaskConfigInfo = teTaskConfigInfoService.selectTeTaskConfigInfoById(inspectionTask.getTaskConfigId());
teTaskConfigInfo.setTaskName(inspectionTask.getTaskName()); teTaskConfigInfo.setTaskName(inspectionTask.getTaskName());
teTaskConfigInfoService.updateTeTaskConfigInfo(teTaskConfigInfo); teTaskConfigInfoService.updateTeTaskConfigInfo(teTaskConfigInfo);
return inspectionTaskMapper.updateInspectionTask(inspectionTask); return inspectionTaskMapper.updateInspectionTask(inspectionTask);
@ -121,7 +121,7 @@ public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper,
// 批量查询巡检任务 // 批量查询巡检任务
List<InspectionTask> inspectionTasks = this.baseMapper.selectBatchIds(Arrays.asList(ids)); List<InspectionTask> inspectionTasks = this.baseMapper.selectBatchIds(Arrays.asList(ids));
// 批量删除任务 // 批量删除任务
teTaskConfigInfoService.deleteTeTaskConfigInfoByIds(inspectionTasks.stream().map(InspectionTask::getTeTaskConfigId).toArray(String[]::new)); teTaskConfigInfoService.deleteTeTaskConfigInfoByIds(inspectionTasks.stream().map(InspectionTask::getTaskConfigId).toArray(String[]::new));
return inspectionTaskMapper.deleteInspectionTaskByIds(ids); return inspectionTaskMapper.deleteInspectionTaskByIds(ids);
} }
@ -166,7 +166,7 @@ public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper,
// 查询点位 // 查询点位
List<InspectionWaypoint> waypoints = inspectionTaskWaypointMapper.selectWaypointsByTaskId(taskId); List<InspectionWaypoint> waypoints = inspectionTaskWaypointMapper.selectWaypointsByTaskId(taskId);
// 同步任务编排 // 同步任务编排
TeTaskOrchestraVO teTaskOrchestraVO = TeTaskOrchestraVO.builder().taskId(inspectionTask.getTeTaskConfigId()).itemIds(waypoints.stream().map(InspectionWaypoint::getDetectItemId).collect(Collectors.toList())).build(); TeTaskOrchestraVO teTaskOrchestraVO = TeTaskOrchestraVO.builder().taskId(inspectionTask.getTaskConfigId()).itemIds(waypoints.stream().map(InspectionWaypoint::getDetectItemId).collect(Collectors.toList())).build();
teTaskOrchestrationService.insertTeTaskOrchestration(teTaskOrchestraVO); teTaskOrchestrationService.insertTeTaskOrchestration(teTaskOrchestraVO);
return inspectionTaskWaypointMapper.batchInsertTaskWaypoint(list); return inspectionTaskWaypointMapper.batchInsertTaskWaypoint(list);
} }

View File

@ -16,6 +16,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" /> <result property="status" column="status" />
<result property="startTime" column="start_time" /> <result property="startTime" column="start_time" />
<result property="endTime" column="end_time" /> <result property="endTime" column="end_time" />
<result property="createByName" column="create_by_name" />
<result property="updateByName" column="update_by_name" />
<result property="taskInsId" column="task_ins_id" />
</resultMap> </resultMap>
<resultMap type="com.cmvr.inspection.domain.vo.InspectionTaskInstanceVo" id="InspectionTaskInstanceVoResult"> <resultMap type="com.cmvr.inspection.domain.vo.InspectionTaskInstanceVo" id="InspectionTaskInstanceVoResult">
@ -37,10 +40,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="endTime" column="end_time" /> <result property="endTime" column="end_time" />
<result property="createByName" column="create_by_name" /> <result property="createByName" column="create_by_name" />
<result property="updateByName" column="update_by_name" /> <result property="updateByName" column="update_by_name" />
<result property="taskInsId" column="task_ins_id" />
</resultMap> </resultMap>
<sql id="selectInspectionTaskInstanceVo"> <sql id="selectInspectionTaskInstanceVo">
select id, create_by, create_time, update_by, update_time, remark, task_id, robot_id, status, start_time, end_time from inspection_task_instance select id, create_by, create_time, update_by, update_time, remark, task_id, robot_id, status, start_time, end_time, task_ins_id from inspection_task_instance
</sql> </sql>
<select id="selectInspectionTaskInstanceList" parameterType="InspectionTaskInstance" resultMap="InspectionTaskInstanceResult"> <select id="selectInspectionTaskInstanceList" parameterType="InspectionTaskInstance" resultMap="InspectionTaskInstanceResult">
@ -71,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="startTime != null">start_time,</if> <if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if> <if test="endTime != null">end_time,</if>
<if test="taskInsId != null">task_ins_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
@ -84,6 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="startTime != null">#{startTime},</if> <if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if> <if test="endTime != null">#{endTime},</if>
<if test="taskInsId != null">#{taskInsId},</if>
</trim> </trim>
</insert> </insert>
@ -100,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="startTime != null">start_time = #{startTime},</if> <if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if> <if test="endTime != null">end_time = #{endTime},</if>
<if test="taskInsId != null">task_ins_id = #{taskInsId},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
@ -120,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ti.task_id, t.task_name, t.task_code, ti.task_id, t.task_name, t.task_code,
ti.robot_id, r.robot_name, ti.robot_id, r.robot_name,
r.current_map_id as robot_current_map_id, m.map_name, r.current_map_id as robot_current_map_id, m.map_name,
ti.status, ti.start_time, ti.end_time, ti.status, ti.start_time, ti.end_time, ti.task_ins_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
from inspection_task_instance ti from inspection_task_instance ti
left join inspection_task t on ti.task_id = t.id left join inspection_task t on ti.task_id = t.id
@ -141,7 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ti.task_id, t.task_name, t.task_code, ti.task_id, t.task_name, t.task_code,
ti.robot_id, r.robot_name, ti.robot_id, r.robot_name,
r.current_map_id as robot_current_map_id, m.map_name, r.current_map_id as robot_current_map_id, m.map_name,
ti.status, ti.start_time, ti.end_time ti.status, ti.start_time, ti.end_time, ti.task_ins_id
from inspection_task_instance ti from inspection_task_instance ti
left join inspection_task t on ti.task_id = t.id left join inspection_task t on ti.task_id = t.id
left join inspection_robot r on ti.robot_id = r.id left join inspection_robot r on ti.robot_id = r.id

View File

@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="taskCode" column="task_code" /> <result property="taskCode" column="task_code" />
<result property="taskName" column="task_name" /> <result property="taskName" column="task_name" />
<result property="taskType" column="task_type" /> <result property="taskType" column="task_type" />
<result property="taskConfigId" column="task_config_id" />
</resultMap> </resultMap>
<resultMap type="com.cmvr.inspection.domain.vo.InspectionTaskVo" id="InspectionTaskVoResult"> <resultMap type="com.cmvr.inspection.domain.vo.InspectionTaskVo" id="InspectionTaskVoResult">
@ -28,10 +29,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="taskType" column="task_type" /> <result property="taskType" column="task_type" />
<result property="createByName" column="create_by_name" /> <result property="createByName" column="create_by_name" />
<result property="updateByName" column="update_by_name" /> <result property="updateByName" column="update_by_name" />
<result property="taskConfigId" column="task_config_id" />
</resultMap> </resultMap>
<sql id="selectInspectionTaskVo"> <sql id="selectInspectionTaskVo">
select id, create_by, create_time, update_by, update_time, remark, task_code, task_name, task_type from inspection_task select id, create_by, create_time, update_by, update_time, remark, task_code, task_name, task_type, task_config_id from inspection_task
</sql> </sql>
<select id="selectInspectionTaskList" parameterType="InspectionTask" resultMap="InspectionTaskResult"> <select id="selectInspectionTaskList" parameterType="InspectionTask" resultMap="InspectionTaskResult">
@ -60,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="taskCode != null">task_code,</if> <if test="taskCode != null">task_code,</if>
<if test="taskName != null">task_name,</if> <if test="taskName != null">task_name,</if>
<if test="taskType != null">task_type,</if> <if test="taskType != null">task_type,</if>
<if test="taskConfigId != null">task_config_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
@ -71,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="taskCode != null">#{taskCode},</if> <if test="taskCode != null">#{taskCode},</if>
<if test="taskName != null">#{taskName},</if> <if test="taskName != null">#{taskName},</if>
<if test="taskType != null">#{taskType},</if> <if test="taskType != null">#{taskType},</if>
<if test="taskConfigId != null">#{taskConfigId},</if>
</trim> </trim>
</insert> </insert>
@ -85,6 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="taskCode != null">task_code = #{taskCode},</if> <if test="taskCode != null">task_code = #{taskCode},</if>
<if test="taskName != null">task_name = #{taskName},</if> <if test="taskName != null">task_name = #{taskName},</if>
<if test="taskType != null">task_type = #{taskType},</if> <if test="taskType != null">task_type = #{taskType},</if>
<if test="taskConfigId != null">task_config_id = #{taskConfigId},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
@ -102,7 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectInspectionTaskVoList" parameterType="InspectionTask" resultMap="InspectionTaskVoResult"> <select id="selectInspectionTaskVoList" parameterType="InspectionTask" resultMap="InspectionTaskVoResult">
select t.id, t.create_by, t.create_time, t.update_by, t.update_time, t.remark, select t.id, t.create_by, t.create_time, t.update_by, t.update_time, t.remark,
t.task_code, t.task_name, t.task_type, t.task_code, t.task_name, t.task_type, t.task_config_id,
u1.user_name as create_by_name, u2.user_name as update_by_name u1.user_name as create_by_name, u2.user_name as update_by_name
from inspection_task t from inspection_task t
left join sys_user u1 on t.create_by = u1.user_name <!-- 创建人关联用户 --> left join sys_user u1 on t.create_by = u1.user_name <!-- 创建人关联用户 -->

View File

@ -34,7 +34,9 @@ public class TaskContextManager {
*/ */
public void register(TaskContext context) { public void register(TaskContext context) {
instContextMap.put(context.getInstId(), context); instContextMap.put(context.getInstId(), context);
terminalInstMap.put(context.getTerminalId(), context.getInstId()); if (context.getTerminalId() != null) {
terminalInstMap.put(context.getTerminalId(), context.getInstId());
}
context.setTerminalStatus(TerminalStatusEnum.RUNNING); context.setTerminalStatus(TerminalStatusEnum.RUNNING);
log.info("注册任务上下文instId={}, terminalId={}", context.getInstId(), context.getTerminalId()); log.info("注册任务上下文instId={}, terminalId={}", context.getInstId(), context.getTerminalId());
} }
@ -47,7 +49,9 @@ public class TaskContextManager {
if (ctx != null) { if (ctx != null) {
ctx.setTerminalStatus(TerminalStatusEnum.READY); ctx.setTerminalStatus(TerminalStatusEnum.READY);
ctx.setTerminalLocked(false); ctx.setTerminalLocked(false);
terminalInstMap.remove(ctx.getTerminalId()); if (ctx.getTerminalId() != null) {
terminalInstMap.remove(ctx.getTerminalId());
}
log.info("注销任务上下文instId={}, terminalId={}", instId, ctx.getTerminalId()); log.info("注销任务上下文instId={}, terminalId={}", instId, ctx.getTerminalId());
} }
} }

View File

@ -60,9 +60,9 @@ public class FlowTaskRuntimeEntry implements FlowTaskRuntimeService {
JSONObject runParams = taskExecuteTrailVO.getRunParams(); JSONObject runParams = taskExecuteTrailVO.getRunParams();
String terminalId = taskExecuteTrailVO.getTerminalId(); String terminalId = taskExecuteTrailVO.getTerminalId();
if (StrUtil.isEmpty(terminalId)) { if (StrUtil.isEmpty(terminalId)) {
throw new GlobalException("终端ID不能为空"); // throw new GlobalException("终端ID不能为空");
} }
if (taskInstHolder.isTerminalLocked(terminalId)) { if (terminalId != null && taskInstHolder.isTerminalLocked(terminalId)) {
throw new GlobalException("当前终端正在执行其他任务,请稍后再试"); throw new GlobalException("当前终端正在执行其他任务,请稍后再试");
} }

View File

@ -28,6 +28,9 @@ public class FlowExceptionInterceptor implements FlowMsgPreInterceptor {
try { try {
return next.apply(message); return next.apply(message);
} catch (Exception e) { } catch (Exception e) {
log.error("节点执行异常instId={}, nodeId={}, action={}",
message.getInstId(), message.getNodeId(), message.getAction(), e);
if (ExceptionUtil.getRootCause(e) instanceof InterruptedException) { if (ExceptionUtil.getRootCause(e) instanceof InterruptedException) {
log.info("节点被中断退出: {}", message.getNodeId()); log.info("节点被中断退出: {}", message.getNodeId());
return null; return null;
@ -43,9 +46,6 @@ public class FlowExceptionInterceptor implements FlowMsgPreInterceptor {
"执行异常:" + StrUtil.sub(ExceptionUtil.getMessage(e), 0, 480), "执行异常:" + StrUtil.sub(ExceptionUtil.getMessage(e), 0, 480),
message.getIterations() message.getIterations()
); );
log.error("节点执行异常instId={}, nodeId={}, action={}",
message.getInstId(), message.getNodeId(), message.getAction(), e);
throw new GlobalException("任务执行失败", e); throw new GlobalException("任务执行失败", e);
} }
} }

View File

@ -3,12 +3,18 @@ package com.cmvr.test.model.vo;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
@Data @Data
@ApiModel("正常任务执行VO") @ApiModel("正常任务执行VO")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TeTaskExecuteNormalVO { public class TeTaskExecuteNormalVO {
@ApiModelProperty("任务ID") @ApiModelProperty("任务ID")
@NotEmpty(message = "任务ID不能为空") @NotEmpty(message = "任务ID不能为空")

View File

@ -20,7 +20,7 @@ public class TeTaskExecuteTrailVO {
private String flowData; private String flowData;
@ApiModelProperty("终端ID") @ApiModelProperty("终端ID")
@NotEmpty(message = "终端ID不能为空") // @NotEmpty(message = "终端ID不能为空")
private String terminalId; private String terminalId;
@ApiModelProperty(value = "运行时参数") @ApiModelProperty(value = "运行时参数")

View File

@ -55,6 +55,7 @@ CREATE TABLE `inspection_task` (
`task_code` varchar(64) DEFAULT NULL COMMENT '任务编码', `task_code` varchar(64) DEFAULT NULL COMMENT '任务编码',
`task_name` varchar(100) NOT NULL COMMENT '任务名称', `task_name` varchar(100) NOT NULL COMMENT '任务名称',
`task_type` char(1) DEFAULT '1' COMMENT '任务类型(1巡检任务 2讲解任务)', `task_type` char(1) DEFAULT '1' COMMENT '任务类型(1巡检任务 2讲解任务)',
`task_config_id` varchar(64) DEFAULT NULL COMMENT '任务配置ID',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `uk_task_code` (`task_code`) UNIQUE KEY `uk_task_code` (`task_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='巡检任务表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='巡检任务表';
@ -101,6 +102,7 @@ CREATE TABLE `inspection_task_instance` (
`status` char(1) DEFAULT '0' COMMENT '执行状态(0待执行 1执行中 2已完成 3已取消 4执行失败 5已暂停)', `status` char(1) DEFAULT '0' COMMENT '执行状态(0待执行 1执行中 2已完成 3已取消 4执行失败 5已暂停)',
`start_time` datetime DEFAULT NULL COMMENT '开始时间', `start_time` datetime DEFAULT NULL COMMENT '开始时间',
`end_time` datetime DEFAULT NULL COMMENT '结束时间', `end_time` datetime DEFAULT NULL COMMENT '结束时间',
`task_ins_id` varchar(64) DEFAULT NULL COMMENT '检测任务id',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `idx_task_id` (`task_id`), KEY `idx_task_id` (`task_id`),
KEY `idx_robot_id` (`robot_id`), KEY `idx_robot_id` (`robot_id`),