feat(video): 添加巡检任务记录关联任务ID功能
- 在巡检任务记录表中新增 task_id 字段并建立关联关系 - 移除巡检任务实体中的冗余 recordId 字段及相关映射配置- 更新数据库查询语句以适配新的字段结构 - 为 InspectionTaskRecord 实体类增加 taskId 属性及对应 getter/setter 方法- 新增根据任务ID查询记录列表的接口方法 - 修改 MyBatis 映射文件支持 task_id 的增删改查操作 - 调整 toString 方法输出内容以包含 taskId 信息
This commit is contained in:
@@ -34,6 +34,16 @@ public class InspectionTaskRecordController extends BaseController {
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/** 根据任务ID查询列表 */
|
||||
@GetMapping("/listByTask/{taskId}")
|
||||
public TableDataInfo listByTask(@PathVariable("taskId") Long taskId) {
|
||||
startPage();
|
||||
InspectionTaskRecord query = new InspectionTaskRecord();
|
||||
query.setTaskId(taskId);
|
||||
List<InspectionTaskRecord> list = recordService.selectInspectionTaskRecordList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/** 导出 */
|
||||
@Log(title = "巡检任务记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
|
||||
@@ -18,10 +18,6 @@ public class InspectionTask extends BaseEntity {
|
||||
/** 巡检任务ID */
|
||||
private Long taskId;
|
||||
|
||||
/** 最近记录ID */
|
||||
@Excel(name = "记录ID")
|
||||
private Long recordId;
|
||||
|
||||
/** 任务名称 */
|
||||
@Excel(name = "任务名称")
|
||||
private String taskName;
|
||||
@@ -82,13 +78,6 @@ public class InspectionTask extends BaseEntity {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public Long getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
public void setRecordId(Long recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
@@ -190,7 +179,6 @@ public class InspectionTask extends BaseEntity {
|
||||
public String toString() {
|
||||
return "InspectionTask{" +
|
||||
"taskId=" + taskId +
|
||||
", recordId=" + recordId +
|
||||
", taskName='" + taskName + '\'' +
|
||||
", deviceId=" + deviceId +
|
||||
", deviceName='" + deviceName + '\'' +
|
||||
|
||||
@@ -18,6 +18,10 @@ public class InspectionTaskRecord extends BaseEntity {
|
||||
/** 记录ID,主键 */
|
||||
private Long recordId;
|
||||
|
||||
/** 任务ID(关联巡检任务表) */
|
||||
@Excel(name = "任务ID")
|
||||
private Long taskId;
|
||||
|
||||
/** 执行时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "执行时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@@ -112,10 +116,19 @@ public class InspectionTaskRecord extends BaseEntity {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Long getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(Long taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InspectionTaskRecord{" +
|
||||
"recordId=" + recordId +
|
||||
", taskId=" + taskId +
|
||||
", executeTime=" + executeTime +
|
||||
", duration=" + duration +
|
||||
", accessory='" + accessory + '\'' +
|
||||
|
||||
@@ -6,7 +6,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<resultMap type="InspectionTask" id="InspectionTaskResult">
|
||||
<result property="taskId" column="task_id" />
|
||||
<result property="recordId" column="record_id" />
|
||||
<result property="taskName" column="task_name" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="deviceName" column="device_name" />
|
||||
@@ -26,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInspectionTaskVo">
|
||||
select task_id, record_id, task_name, device_id, device_name, cron_expression, duration,
|
||||
select task_id, task_name, device_id, device_name, cron_expression, duration,
|
||||
threshold, enable_detection, status, execute_count, alarm_count,
|
||||
last_execute_time, remark, create_by, create_time, update_by, update_time
|
||||
from v_inspection_task
|
||||
@@ -54,7 +53,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into v_inspection_task
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="taskName != null and taskName != ''">task_name,</if>
|
||||
<if test="recordId != null">record_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="deviceName != null">device_name,</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">cron_expression,</if>
|
||||
@@ -71,7 +69,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="taskName != null and taskName != ''">#{taskName},</if>
|
||||
<if test="recordId != null">#{recordId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="deviceName != null">#{deviceName},</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">#{cronExpression},</if>
|
||||
@@ -92,7 +89,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update v_inspection_task
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="taskName != null and taskName != ''">task_name = #{taskName},</if>
|
||||
<if test="recordId != null">record_id = #{recordId},</if>
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="deviceName != null">device_name = #{deviceName},</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">cron_expression = #{cronExpression},</if>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
<resultMap id="InspectionTaskRecordResult" type="com.ruoyi.video.domain.InspectionTaskRecord">
|
||||
<id property="recordId" column="record_id"/>
|
||||
<result property="taskId" column="task_id"/>
|
||||
<result property="executeTime" column="execute_time"/>
|
||||
<result property="duration" column="duration"/>
|
||||
<result property="accessory" column="accessory"/>
|
||||
@@ -20,7 +21,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRecordColumns">
|
||||
select record_id, execute_time, duration, accessory, result, status,
|
||||
select record_id, task_id, execute_time, duration, accessory, result, status,
|
||||
create_by, create_time, update_by, update_time, del_flag, remark
|
||||
from v_inspection_task_record
|
||||
</sql>
|
||||
@@ -28,6 +29,7 @@
|
||||
<select id="selectInspectionTaskRecordList" parameterType="com.ruoyi.video.domain.InspectionTaskRecord" resultMap="InspectionTaskRecordResult">
|
||||
<include refid="selectRecordColumns"/>
|
||||
<where>
|
||||
<if test="taskId != null"> and task_id = #{taskId}</if>
|
||||
<if test="status != null"> and status = #{status}</if>
|
||||
<if test="executeTime != null"> and date(execute_time) = date(#{executeTime})</if>
|
||||
<if test="accessory != null and accessory != ''"> and accessory like concat('%', #{accessory}, '%')</if>
|
||||
@@ -44,6 +46,7 @@
|
||||
<insert id="insertInspectionTaskRecord" parameterType="com.ruoyi.video.domain.InspectionTaskRecord" useGeneratedKeys="true" keyProperty="recordId">
|
||||
insert into v_inspection_task_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="taskId != null">task_id,</if>
|
||||
<if test="executeTime != null">execute_time,</if>
|
||||
<if test="duration != null">duration,</if>
|
||||
<if test="accessory != null">accessory,</if>
|
||||
@@ -57,6 +60,7 @@
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="taskId != null">#{taskId},</if>
|
||||
<if test="executeTime != null">#{executeTime},</if>
|
||||
<if test="duration != null">#{duration},</if>
|
||||
<if test="accessory != null">#{accessory},</if>
|
||||
@@ -74,6 +78,7 @@
|
||||
<update id="updateInspectionTaskRecord" parameterType="com.ruoyi.video.domain.InspectionTaskRecord">
|
||||
update v_inspection_task_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="taskId != null">task_id = #{taskId},</if>
|
||||
<if test="executeTime != null">execute_time = #{executeTime},</if>
|
||||
<if test="duration != null">duration = #{duration},</if>
|
||||
<if test="accessory != null">accessory = #{accessory},</if>
|
||||
|
||||
@@ -1277,6 +1277,7 @@ INSERT INTO `v_inspection_task` VALUES (5, '垃圾巡检测试', 3, '192.168.1.2
|
||||
DROP TABLE IF EXISTS `v_inspection_task_record`;
|
||||
CREATE TABLE `v_inspection_task_record` (
|
||||
`record_id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录ID,主键',
|
||||
`task_id` bigint NOT NULL COMMENT '关联的巡检任务ID',
|
||||
`execute_time` datetime NOT NULL COMMENT '执行时间',
|
||||
`duration` int NULL DEFAULT NULL COMMENT '执行时长(秒)',
|
||||
`accessory` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附件路径,可存储相关图片或文件',
|
||||
|
||||
Reference in New Issue
Block a user