feat(video): 添加巡检任务记录功能及相关接口
- 在 InspectionTask 实体中新增 recordId 字段及其 getter/setter 方法 - 更新 InspectionTask 的 toString 方法以包含 recordId - 修改 InspectionTaskMapper.xml,增加 record_id 的映射和查询字段 - 新增巡检任务记录实体类 InspectionTaskRecord 及其相关属性与方法 - 创建巡检任务记录的控制器、服务层和数据访问层(Controller, Service, Mapper)- 实现巡检任务记录的增删改查接口,并支持导出 Excel 功能 - 配置 MyBatis XML 映射文件,完成数据库操作语句的编写
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package com.ruoyi.video.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.video.domain.InspectionTaskRecord;
|
||||
import com.ruoyi.video.service.InspectionTaskRecordService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 巡检任务记录Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/video/inspectionRecord")
|
||||
public class InspectionTaskRecordController extends BaseController {
|
||||
|
||||
private final InspectionTaskRecordService recordService;
|
||||
|
||||
public InspectionTaskRecordController(InspectionTaskRecordService recordService) {
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/** 列表 */
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(InspectionTaskRecord record) {
|
||||
startPage();
|
||||
List<InspectionTaskRecord> list = recordService.selectInspectionTaskRecordList(record);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/** 导出 */
|
||||
@Log(title = "巡检任务记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, InspectionTaskRecord record) {
|
||||
List<InspectionTaskRecord> list = recordService.selectInspectionTaskRecordList(record);
|
||||
ExcelUtil<InspectionTaskRecord> util = new ExcelUtil<>(InspectionTaskRecord.class);
|
||||
util.exportExcel(response, list, "巡检任务记录数据");
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
@GetMapping(value = "/{recordId}")
|
||||
public AjaxResult getInfo(@PathVariable("recordId") Long recordId) {
|
||||
return success(recordService.selectInspectionTaskRecordById(recordId));
|
||||
}
|
||||
|
||||
/** 新增 */
|
||||
@Log(title = "巡检任务记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody InspectionTaskRecord record) {
|
||||
return toAjax(recordService.insertInspectionTaskRecord(record));
|
||||
}
|
||||
|
||||
/** 修改 */
|
||||
@Log(title = "巡检任务记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody InspectionTaskRecord record) {
|
||||
return toAjax(recordService.updateInspectionTaskRecord(record));
|
||||
}
|
||||
|
||||
/** 删除(批量) */
|
||||
@Log(title = "巡检任务记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{recordIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] recordIds) {
|
||||
return toAjax(recordService.deleteInspectionTaskRecordByIds(recordIds));
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,10 @@ public class InspectionTask extends BaseEntity {
|
||||
/** 巡检任务ID */
|
||||
private Long taskId;
|
||||
|
||||
/** 最近记录ID */
|
||||
@Excel(name = "记录ID")
|
||||
private Long recordId;
|
||||
|
||||
/** 任务名称 */
|
||||
@Excel(name = "任务名称")
|
||||
private String taskName;
|
||||
@@ -78,6 +82,14 @@ 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;
|
||||
}
|
||||
@@ -178,6 +190,7 @@ public class InspectionTask extends BaseEntity {
|
||||
public String toString() {
|
||||
return "InspectionTask{" +
|
||||
"taskId=" + taskId +
|
||||
", recordId=" + recordId +
|
||||
", taskName='" + taskName + '\'' +
|
||||
", deviceId=" + deviceId +
|
||||
", deviceName='" + deviceName + '\'' +
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.ruoyi.video.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 巡检任务记录对象 v_inspection_task_record
|
||||
*
|
||||
* @author generated
|
||||
* @date 2025-09-30
|
||||
*/
|
||||
public class InspectionTaskRecord extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 记录ID,主键 */
|
||||
private Long recordId;
|
||||
|
||||
/** 执行时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "执行时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date executeTime;
|
||||
|
||||
/** 执行时长(秒) */
|
||||
@Excel(name = "执行时长(秒)")
|
||||
private Integer duration;
|
||||
|
||||
/** 附件路径 */
|
||||
@Excel(name = "附件路径")
|
||||
private String accessory;
|
||||
|
||||
/** 巡检结果详情 */
|
||||
@Excel(name = "巡检结果")
|
||||
private String result;
|
||||
|
||||
/** 执行状态(0=成功,1=失败,2=部分成功) */
|
||||
@Excel(name = "执行状态", readConverterExp = "0=成功,1=失败,2=部分成功")
|
||||
private Integer status;
|
||||
|
||||
/** 删除标志(0=存在 2=删除) */
|
||||
private String delFlag;
|
||||
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
public Long getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
public void setRecordId(Long recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public Date getExecuteTime() {
|
||||
return executeTime;
|
||||
}
|
||||
|
||||
public void setExecuteTime(Date executeTime) {
|
||||
this.executeTime = executeTime;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getAccessory() {
|
||||
return accessory;
|
||||
}
|
||||
|
||||
public void setAccessory(String accessory) {
|
||||
this.accessory = accessory;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InspectionTaskRecord{" +
|
||||
"recordId=" + recordId +
|
||||
", executeTime=" + executeTime +
|
||||
", duration=" + duration +
|
||||
", accessory='" + accessory + '\'' +
|
||||
", result='" + result + '\'' +
|
||||
", status=" + status +
|
||||
", delFlag='" + delFlag + '\'' +
|
||||
", remark='" + remark + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.ruoyi.video.mapper;
|
||||
|
||||
import com.ruoyi.video.domain.InspectionTaskRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 巡检任务记录Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface InspectionTaskRecordMapper {
|
||||
/**
|
||||
* 查询巡检任务记录
|
||||
*/
|
||||
InspectionTaskRecord selectInspectionTaskRecordByRecordId(Long recordId);
|
||||
|
||||
/**
|
||||
* 查询巡检任务记录列表
|
||||
*/
|
||||
List<InspectionTaskRecord> selectInspectionTaskRecordList(InspectionTaskRecord record);
|
||||
|
||||
/**
|
||||
* 新增巡检任务记录
|
||||
*/
|
||||
int insertInspectionTaskRecord(InspectionTaskRecord record);
|
||||
|
||||
/**
|
||||
* 修改巡检任务记录
|
||||
*/
|
||||
int updateInspectionTaskRecord(InspectionTaskRecord record);
|
||||
|
||||
/**
|
||||
* 删除巡检任务记录
|
||||
*/
|
||||
int deleteInspectionTaskRecordByRecordId(Long recordId);
|
||||
|
||||
/**
|
||||
* 批量删除巡检任务记录
|
||||
*/
|
||||
int deleteInspectionTaskRecordByRecordIds(Long[] recordIds);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ruoyi.video.service;
|
||||
|
||||
import com.ruoyi.video.domain.InspectionTaskRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 巡检任务记录服务接口
|
||||
*/
|
||||
public interface InspectionTaskRecordService {
|
||||
|
||||
/** 查询列表 */
|
||||
List<InspectionTaskRecord> selectInspectionTaskRecordList(InspectionTaskRecord record);
|
||||
|
||||
/** 按ID查询 */
|
||||
InspectionTaskRecord selectInspectionTaskRecordById(Long recordId);
|
||||
|
||||
/** 新增 */
|
||||
int insertInspectionTaskRecord(InspectionTaskRecord record);
|
||||
|
||||
/** 修改 */
|
||||
int updateInspectionTaskRecord(InspectionTaskRecord record);
|
||||
|
||||
/** 批量删除 */
|
||||
int deleteInspectionTaskRecordByIds(Long[] recordIds);
|
||||
|
||||
/** 删除单条 */
|
||||
int deleteInspectionTaskRecordById(Long recordId);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.ruoyi.video.service.impl;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.video.domain.InspectionTaskRecord;
|
||||
import com.ruoyi.video.mapper.InspectionTaskRecordMapper;
|
||||
import com.ruoyi.video.service.InspectionTaskRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class InspectionTaskRecordServiceImpl implements InspectionTaskRecordService {
|
||||
|
||||
@Autowired
|
||||
private InspectionTaskRecordMapper recordMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<InspectionTaskRecord> selectInspectionTaskRecordList(InspectionTaskRecord record) {
|
||||
return recordMapper.selectInspectionTaskRecordList(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectionTaskRecord selectInspectionTaskRecordById(Long recordId) {
|
||||
return recordMapper.selectInspectionTaskRecordByRecordId(recordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertInspectionTaskRecord(InspectionTaskRecord record) {
|
||||
if (record.getExecuteTime() == null) {
|
||||
record.setExecuteTime(DateUtils.getNowDate());
|
||||
}
|
||||
record.setCreateTime(DateUtils.getNowDate());
|
||||
return recordMapper.insertInspectionTaskRecord(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateInspectionTaskRecord(InspectionTaskRecord record) {
|
||||
record.setUpdateTime(DateUtils.getNowDate());
|
||||
return recordMapper.updateInspectionTaskRecord(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteInspectionTaskRecordByIds(Long[] recordIds) {
|
||||
return recordMapper.deleteInspectionTaskRecordByRecordIds(recordIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteInspectionTaskRecordById(Long recordId) {
|
||||
return recordMapper.deleteInspectionTaskRecordByRecordId(recordId);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ 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" />
|
||||
@@ -25,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInspectionTaskVo">
|
||||
select task_id, task_name, device_id, device_name, cron_expression, duration,
|
||||
select task_id, record_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
|
||||
@@ -35,19 +36,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectInspectionTaskVo"/>
|
||||
<where>
|
||||
<if test="taskName != null and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="deviceId != null"> and device_id = #{deviceId}</if>
|
||||
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="enableDetection != null and enableDetection != ''"> and enable_detection = #{enableDetection}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectInspectionTaskByTaskId" parameterType="Long" resultMap="InspectionTaskResult">
|
||||
<include refid="selectInspectionTaskVo"/>
|
||||
where task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectEnabledInspectionTaskList" resultMap="InspectionTaskResult">
|
||||
<include refid="selectInspectionTaskVo"/>
|
||||
where status = '0'
|
||||
@@ -58,6 +54,7 @@ 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>
|
||||
@@ -74,6 +71,7 @@ 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>
|
||||
@@ -94,6 +92,7 @@ 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>
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.video.mapper.InspectionTaskRecordMapper">
|
||||
|
||||
<resultMap id="InspectionTaskRecordResult" type="com.ruoyi.video.domain.InspectionTaskRecord">
|
||||
<id property="recordId" column="record_id"/>
|
||||
<result property="executeTime" column="execute_time"/>
|
||||
<result property="duration" column="duration"/>
|
||||
<result property="accessory" column="accessory"/>
|
||||
<result property="result" column="result"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRecordColumns">
|
||||
select record_id, execute_time, duration, accessory, result, status,
|
||||
create_by, create_time, update_by, update_time, del_flag, remark
|
||||
from v_inspection_task_record
|
||||
</sql>
|
||||
|
||||
<select id="selectInspectionTaskRecordList" parameterType="com.ruoyi.video.domain.InspectionTaskRecord" resultMap="InspectionTaskRecordResult">
|
||||
<include refid="selectRecordColumns"/>
|
||||
<where>
|
||||
<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>
|
||||
<if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectInspectionTaskRecordByRecordId" parameterType="long" resultMap="InspectionTaskRecordResult">
|
||||
<include refid="selectRecordColumns"/>
|
||||
where record_id = #{recordId}
|
||||
</select>
|
||||
|
||||
<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="executeTime != null">execute_time,</if>
|
||||
<if test="duration != null">duration,</if>
|
||||
<if test="accessory != null">accessory,</if>
|
||||
<if test="result != null">result,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
create_time,
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
update_time,
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="executeTime != null">#{executeTime},</if>
|
||||
<if test="duration != null">#{duration},</if>
|
||||
<if test="accessory != null">#{accessory},</if>
|
||||
<if test="result != null">#{result},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
now(),
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
now(),
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateInspectionTaskRecord" parameterType="com.ruoyi.video.domain.InspectionTaskRecord">
|
||||
update v_inspection_task_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="executeTime != null">execute_time = #{executeTime},</if>
|
||||
<if test="duration != null">duration = #{duration},</if>
|
||||
<if test="accessory != null">accessory = #{accessory},</if>
|
||||
<if test="result != null">result = #{result},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
update_time = now(),
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where record_id = #{recordId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteInspectionTaskRecordByRecordId" parameterType="long">
|
||||
delete from v_inspection_task_record where record_id = #{recordId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteInspectionTaskRecordByRecordIds" parameterType="string">
|
||||
delete from v_inspection_task_record where record_id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user