refactor(inspection): 优化巡检任务日志数据结构
- 将数据库表字段 waypoint_id 和 waypoint_name 替换为 item_id - 将进度字段从字符串类型改为 DECIMAL(5,2) 类型并保留2位小数 - 在代码中实现进度数值四舍五入保留2位小数的计算逻辑 - 更新实体类 InspectionTaskLog 的字段映射和注释 - 修改 MyBatis 映射文件中的字段引用和 SQL 查询语句 - 调整批量插入操作的数据字段映射关系
This commit is contained in:
parent
43e491c0b6
commit
be8b306eef
@ -42,13 +42,9 @@ public class InspectionTaskLog extends BaseEntity
|
||||
@ApiModelProperty("任务ID")
|
||||
private String taskId;
|
||||
|
||||
@Excel(name = "点位ID")
|
||||
@ApiModelProperty("点位ID")
|
||||
private String waypointId;
|
||||
|
||||
@Excel(name = "点位名称")
|
||||
@ApiModelProperty("点位名称")
|
||||
private String waypointName;
|
||||
@Excel(name = "检查项id")
|
||||
@ApiModelProperty("检查项id")
|
||||
private String itemId;
|
||||
|
||||
@Excel(name = "节点ID")
|
||||
@ApiModelProperty("节点ID")
|
||||
@ -76,7 +72,7 @@ public class InspectionTaskLog extends BaseEntity
|
||||
|
||||
@Excel(name = "进度")
|
||||
@ApiModelProperty("执行进度(百分比)")
|
||||
private String progress;
|
||||
private Double progress;
|
||||
|
||||
@Excel(name = "日志时间")
|
||||
@ApiModelProperty("日志时间")
|
||||
|
||||
@ -119,20 +119,20 @@ public class InspectionFlowExecutionListener implements FlowExecutionListener {
|
||||
|
||||
String info = event.getEventType() == FlowExecutionEvent.EventType.NODE_STARTED ? "开始执行" : "执行完成";
|
||||
String logId = UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
// 四舍五入保留2位小数
|
||||
progress = Math.round(progress * 100) / 100.0;
|
||||
// 保存日志到数据库
|
||||
InspectionTaskLog taskLog = InspectionTaskLog.builder()
|
||||
.id(logId)
|
||||
.taskInstanceId(taskInstance.getId())
|
||||
.taskId(taskInstance.getTaskId())
|
||||
.waypointId(itemId)
|
||||
.waypointName(event.getNodeName())
|
||||
.itemId(itemId)
|
||||
.nodeId(nodeId)
|
||||
.nodeName(event.getNodeName())
|
||||
.logType(InspectionLogTypeEnum.TEXT.getCode())
|
||||
.logContent("节点【" + event.getNodeName() + "】" + info)
|
||||
.status(targetStatus)
|
||||
.progress(String.format("%.2f", progress))
|
||||
.progress(progress)
|
||||
.logTime(now)
|
||||
.build();
|
||||
|
||||
|
||||
@ -8,8 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="id" column="id" />
|
||||
<result property="taskInstanceId" column="task_instance_id" />
|
||||
<result property="taskId" column="task_id" />
|
||||
<result property="waypointId" column="waypoint_id" />
|
||||
<result property="waypointName" column="waypoint_name" />
|
||||
<result property="itemId" column="item_id" />
|
||||
<result property="nodeId" column="node_id" />
|
||||
<result property="nodeName" column="node_name" />
|
||||
<result property="logType" column="log_type" />
|
||||
@ -27,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInspectionTaskLogVo">
|
||||
select id, task_instance_id, task_id, waypoint_id, waypoint_name, node_id, node_name,
|
||||
select id, task_instance_id, task_id, item_id, node_id, node_name,
|
||||
log_type, log_content, media_url, status, progress, log_time, extra_info,
|
||||
create_by, create_time, update_by, update_time, remark
|
||||
from inspection_task_log
|
||||
@ -41,14 +40,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="batchInsertInspectionTaskLog">
|
||||
insert into inspection_task_log(
|
||||
id, task_instance_id, task_id, waypoint_id, waypoint_name, node_id, node_name,
|
||||
id, task_instance_id, task_id, item_id, node_id, node_name,
|
||||
log_type, log_content, media_url, status, progress, log_time, extra_info,
|
||||
create_by, create_time, remark
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.taskInstanceId}, #{item.taskId}, #{item.waypointId},
|
||||
#{item.waypointName}, #{item.nodeId}, #{item.nodeName},
|
||||
#{item.id}, #{item.taskInstanceId}, #{item.taskId}, #{item.itemId},
|
||||
#{item.nodeId}, #{item.nodeName},
|
||||
#{item.logType}, #{item.logContent}, #{item.mediaUrl}, #{item.status},
|
||||
#{item.progress}, #{item.logTime}, #{item.extraInfo},
|
||||
#{item.createBy}, #{item.createTime}, #{item.remark}
|
||||
|
||||
@ -155,15 +155,14 @@ CREATE TABLE `inspection_task_log` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键ID',
|
||||
`task_instance_id` varchar(64) DEFAULT NULL COMMENT '任务实例ID',
|
||||
`task_id` varchar(64) DEFAULT NULL COMMENT '任务ID',
|
||||
`waypoint_id` varchar(64) DEFAULT NULL COMMENT '点位ID',
|
||||
`waypoint_name` varchar(255) DEFAULT NULL COMMENT '点位名称',
|
||||
`item_id` varchar(64) DEFAULT NULL COMMENT '检测项id',
|
||||
`node_id` varchar(64) DEFAULT NULL COMMENT '节点ID',
|
||||
`node_name` varchar(255) DEFAULT NULL COMMENT '节点名称',
|
||||
`log_type` int(11) DEFAULT '1' COMMENT '日志类型(1文字 2图片 3视频 4音频)',
|
||||
`log_content` text COMMENT '日志内容/文字描述',
|
||||
`media_url` varchar(500) DEFAULT NULL COMMENT '媒体文件URL(图片/视频/音频)',
|
||||
`status` int(11) DEFAULT '1' COMMENT '执行状态(0待执行 1执行中 2已完成 3已取消 4执行失败 5已暂停)',
|
||||
`progress` varchar(20) DEFAULT NULL COMMENT '执行进度(百分比)',
|
||||
`progress` DECIMAL(5,2) DEFAULT NULL COMMENT '执行进度(百分比,保留2位小数)',
|
||||
`log_time` datetime DEFAULT NULL COMMENT '日志时间',
|
||||
`extra_info` text COMMENT '扩展信息(JSON格式)',
|
||||
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user