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:
@@ -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