feat(video): 添加设备名称字段并优化巡检任务关联查询

- 在 Device 实体类中新增 deviceName 字段及其 getter/setter 方法
- 更新 DeviceMapper.xml,支持 device_name 字段的查询、插入和更新操作
- 修改 InspectionTask 实体类,增加 deviceIp 字段用于联查返回设备 IP
- 调整 InspectionTaskMapper.xml,通过左连接获取设备名称与 IP 信息- 移除冗余的 device_name 插入与更新逻辑
- 注释掉旧有的设备信息设置代码,避免重复赋值
- 更新 toString 方法以包含新的 deviceName 属性
This commit is contained in:
2025-10-09 09:54:40 +08:00
parent 99a8a943bc
commit 98042b237c
5 changed files with 48 additions and 19 deletions

View File

@@ -6,6 +6,7 @@
<resultMap type="Device" id="DeviceResult">
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="ip" column="ip" />
<result property="type" column="type" />
<result property="userName" column="user_name" />
@@ -23,12 +24,13 @@
</resultMap>
<sql id="selectDeviceVo">
select device_id, ip, type, user_name, password, url, mediaKey, enabledFlv, enabledHls, mode, create_by, create_time, update_by, update_time, remark from v_device
select device_id, device_name, ip, type, user_name, password, url, mediaKey, enabledFlv, enabledHls, mode, create_by, create_time, update_by, update_time, remark from v_device
</sql>
<select id="selectDeviceList" parameterType="Device" resultMap="DeviceResult">
<include refid="selectDeviceVo"/>
<where>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="ip != null and ip != ''"> and ip = #{ip}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
@@ -49,6 +51,7 @@
<insert id="insertDevice" parameterType="Device" useGeneratedKeys="true" keyProperty="deviceId">
insert into v_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="ip != null and ip != ''">ip,</if>
<if test="type != null and type != ''">type,</if>
<if test="userName != null and userName != ''">user_name,</if>
@@ -65,6 +68,7 @@
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="ip != null and ip != ''">#{ip},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="userName != null and userName != ''">#{userName},</if>
@@ -85,6 +89,7 @@
<update id="updateDevice" parameterType="Device">
update v_device
<trim prefix="SET" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="ip != null and ip != ''">ip = #{ip},</if>
<if test="type != null and type != ''">type = #{type},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>