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:
@@ -14,6 +14,8 @@ public class Device extends BaseEntity {
|
||||
private Long deviceId;
|
||||
@Excel(name = "IP地址")
|
||||
private String ip;
|
||||
@Excel(name = "设备名称")
|
||||
private String deviceName;
|
||||
@Excel(
|
||||
name = "设备类型(1=haikan,2=dahua)"
|
||||
)
|
||||
@@ -51,7 +53,7 @@ public class Device extends BaseEntity {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Device{deviceId=" + this.deviceId + ", ip='" + this.ip + "', type='" + this.type + "', mediaKey='" + this.mediaKey + "', userName='" + this.userName + "', password='" + this.password + "', url='" + this.url + "', enabledFlv='" + this.enabledFlv + "', enabledHls='" + this.enabledHls + "', mode='" + this.mode + "'}";
|
||||
return "Device{deviceId=" + this.deviceId + ", deviceName='" + this.deviceName + "', ip='" + this.ip + "', type='" + this.type + "', mediaKey='" + this.mediaKey + "', userName='" + this.userName + "', password='" + this.password + "', url='" + this.url + "', enabledFlv='" + this.enabledFlv + "', enabledHls='" + this.enabledHls + "', mode='" + this.mode + "'}";
|
||||
}
|
||||
|
||||
public Long getDeviceId() {
|
||||
@@ -62,6 +64,14 @@ public class Device extends BaseEntity {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return this.ip;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* 巡检任务对象 v_inspection_task
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-09-27
|
||||
*/
|
||||
@@ -22,9 +22,12 @@ public class InspectionTask extends BaseEntity {
|
||||
/** 设备ID */
|
||||
private Long deviceId;
|
||||
|
||||
/** 设备名称 */
|
||||
/** 设备名称(联查返回) */
|
||||
private String deviceName;
|
||||
|
||||
/** 设备IP(联查返回) */
|
||||
private String deviceIp;
|
||||
|
||||
/** Cron表达式 */
|
||||
private String cronExpression;
|
||||
|
||||
@@ -57,11 +60,11 @@ public class InspectionTask extends BaseEntity {
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
|
||||
public void setTaskId(Long taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
@@ -94,6 +97,14 @@ public class InspectionTask extends BaseEntity {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceIp() {
|
||||
return deviceIp;
|
||||
}
|
||||
|
||||
public void setDeviceIp(String deviceIp) {
|
||||
this.deviceIp = deviceIp;
|
||||
}
|
||||
|
||||
public void setCronExpression(String cronExpression) {
|
||||
this.cronExpression = cronExpression;
|
||||
}
|
||||
|
||||
@@ -88,11 +88,11 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
||||
inspectionTask.setAlarmCount(0L);
|
||||
|
||||
// 获取设备信息
|
||||
Device device = deviceService.selectDeviceByDeviceId(inspectionTask.getDeviceId());
|
||||
|
||||
if (device != null) {
|
||||
inspectionTask.setDeviceName(device.getIp());
|
||||
}
|
||||
// Device device = deviceService.selectDeviceByDeviceId(inspectionTask.getDeviceId());
|
||||
//
|
||||
// if (device != null) {
|
||||
// inspectionTask.setDeviceName(device.getIp());
|
||||
// }
|
||||
|
||||
return inspectionTaskMapper.insertInspectionTask(inspectionTask);
|
||||
}
|
||||
@@ -457,7 +457,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
||||
alarm.setTaskId(task.getTaskId());
|
||||
alarm.setTaskName(task.getTaskName());
|
||||
alarm.setDeviceId(task.getDeviceId());
|
||||
alarm.setDeviceName(task.getDeviceName());
|
||||
// alarm.setDeviceName(task.getDeviceName());
|
||||
alarm.setAlarmType(best.getLabel());
|
||||
// 这里需要转换double为float
|
||||
alarm.setAlarmLevel(getAlarmLevel((float)best.getConfidence()));
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<result property="taskName" column="task_name" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="deviceName" column="device_name" />
|
||||
<result property="deviceIp" column="device_ip" />
|
||||
<result property="cronExpression" column="cron_expression" />
|
||||
<result property="duration" column="duration" />
|
||||
<result property="threshold" column="threshold" />
|
||||
@@ -26,10 +27,15 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInspectionTaskVo">
|
||||
select task_id, task_name, device_id, device_name, cron_expression, duration,
|
||||
threshold, enable_detection, status, execute_count, alarm_count,
|
||||
last_execute_time, model_name, remark, create_by, create_time, update_by, update_time
|
||||
from v_inspection_task
|
||||
select
|
||||
t.task_id, t.task_name, t.device_id,
|
||||
t.cron_expression, t.duration,
|
||||
t.threshold, t.enable_detection, t.status, t.execute_count, t.alarm_count,
|
||||
t.last_execute_time, t.model_name, t.remark, t.create_by, t.create_time, t.update_by, t.update_time,
|
||||
d.device_name as device_name,
|
||||
d.ip as device_ip
|
||||
from v_inspection_task t
|
||||
left join v_device d on t.device_id = d.device_id
|
||||
</sql>
|
||||
|
||||
<select id="selectInspectionTaskList" parameterType="InspectionTask" resultMap="InspectionTaskResult">
|
||||
@@ -37,7 +43,7 @@
|
||||
<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="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
|
||||
<if test="deviceName != null and deviceName != ''"> and d.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>
|
||||
<if test="modelName != null and modelName != ''"> and model_name = #{modelName}</if>
|
||||
@@ -61,7 +67,6 @@
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="taskName != null and taskName != ''">task_name,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="deviceName != null">device_name,</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">cron_expression,</if>
|
||||
<if test="duration != null">duration,</if>
|
||||
<if test="threshold != null">threshold,</if>
|
||||
@@ -78,7 +83,6 @@
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="taskName != null and taskName != ''">#{taskName},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="deviceName != null">#{deviceName},</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">#{cronExpression},</if>
|
||||
<if test="duration != null">#{duration},</if>
|
||||
<if test="threshold != null">#{threshold},</if>
|
||||
@@ -99,7 +103,6 @@
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="taskName != null and taskName != ''">task_name = #{taskName},</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>
|
||||
<if test="duration != null">duration = #{duration},</if>
|
||||
<if test="threshold != null">threshold = #{threshold},</if>
|
||||
|
||||
Reference in New Issue
Block a user