@ -152,82 +152,71 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</where>
</select>
</select>
<select id= "selectEquMonitorList" parameterType= "EquBaseQueryDto " resultType= "MonitorListDto" >
<select id= "selectEquMonitorListById " parameterType= "string " resultType= "MonitorListDto" >
SELECT
SELECT
b.id,
b.id,
b.name,
b.name,
b.ip,
t.name as equType,
m.name as manufacture,
b.version,
b.version,
b.device_level,
b.device_level AS deviceLevel ,
b.location,
b.location,
b.status,
b.status,
g.cpu_utilization,
g.cpu_utilization AS cpuUtilization ,
g.health,
g.health,
g.fan_speed,
g.fan_speed AS fanSpeed,
b.failure_frequency,
g.cont_work_period AS contWorkPeriod,
b.equ_image
b.failure_frequency AS failureFrequency,
-- 新增列:统计未处理告警数量
(SELECT COUNT(1)
FROM alert_message a
WHERE a.equ_id = b.id AND a.status = 'HANDLED') AS unhandledAlertCount
FROM equ_base b
FROM equ_base b
LEFT JOIN equ_gather g ON b.id = g.equ_id
LEFT JOIN equ_gather g ON b.id = g.equ_id
<where >
LEFT JOIN equ_type t ON b.equ_type = t.id
g.cpu_utilization is not null
LEFT JOIN equ_manu m ON b.manufacture = m.id
<if test= "equType != null and equType != ''" >
where b.id = #{id}
AND b.equ_type = #{equType}
AND g.cpu_utilization is not null
</if>
<if test= "equName != null and equName != ''" >
AND b.name LIKE concat('%', #{equName}, '%')
</if>
<if test= "location != null and location != ''" >
AND b.location = #{location}
</if>
<if test= "manufacture != null and manufacture != ''" >
AND b.manufacture = #{manufacture}
</if>
<if test= "inCharge != null" >
AND b.in_charge = #{inCharge}
</if>
<if test= "status != null" >
AND b.status = #{status}
</if>
<if test= "minTime != null" >
AND b.create_date <![CDATA[>=]]> #{minTime}
</if>
<if test= "maxTime != null" >
AND b.create_date <![CDATA[<=]]> #{maxTime}
</if>
<if test= "health != null" >
AND g.health <![CDATA[>=]]> #{health}
</if>
</where>
ORDER BY g.gather_time desc limit 1
ORDER BY g.gather_time desc limit 1
</select>
</select>
<select id= "selectEquMonitorById" parameterType= "string" resultType= "MonitorLastDto" >
<select id= "selectEquMonitorById" parameterType= "string" resultType= "MonitorLastDto" >
SELECT
SELECT
g.cont_work_period,
g.cont_work_period AS contWorkPeriod,
b.equ_image AS equImage,
b.id,
b.id,
b.name,
b.name,
b.version,
b.version,
b.device_level,
b.device_level AS deviceLevel,
t.name as equ_type,
t.name as equType,
b.status,
m.name as manufacture,
m.name as manufacture,
s.name as supplier_id,
s.name as supplierId,
#b.release_date,
s.contact_by AS ContactBy,
s.contact_way AS ContactWay,
b.warranty,
b.warranty,
m.contact_by as manufacture,
m.contact_way as manufacture,
b.ip,
b.ip,
b.location,
b.location,
b.install_date,
b.install_date AS installDate,
#b.service_time,
b.in_charge AS inCharge,
b.in_charge,
b.failure_frequency,
b.failure_frequency AS failureFrequency,
#b.repair_frequency,
-- 新增列:统计未处理告警数量
#b.service_time/warranty AS aging,
(SELECT COUNT(1)
g.fan_speed,
FROM alert_message a
g.cpu_utilization,
WHERE a.equ_id = b.id AND a.status = 'HANDLED') AS unhandledAlertCount,
g.memory_utilization,
g.health
g.fan_speed AS fanSpeed,
g.cpu_utilization AS cpuUtilization,
g.memory_utilization AS memoryUtilization,
g.temperature,
g.health,
g.vol_in AS volIn,
g.vol_out AS volOut
FROM equ_base b
FROM equ_base b
LEFT JOIN equ_manu m ON b.manufacture = m.id
LEFT JOIN equ_manu m ON b.manufacture = m.id
@ -241,11 +230,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY g.gather_time desc limit 1
ORDER BY g.gather_time desc limit 1
</select>
</select>
<select id= "selectEquMonitorByIdToList" parameterType= "com.alops.system.domain.dto.EquBaseQueryDto" resultType= "map" > SELECT
<select id= "selectEquMonitorByIdToList" parameterType= "com.alops.system.domain.dto.EquBaseQueryDto" resultType= "map" >
SELECT
-- 从 equ_gather 表中获取需要填充到List中的数据
-- 从 equ_gather 表中获取需要填充到List中的数据
g.temperature AS temperature_value,
g.temperature AS temperature_value,
g.vol_in AS involtage_value,
g.memory_utilization AS memory_value,
g.vol_out AS outvoltage_value,
g.cpu_utilization AS cpu_value,
g.health AS health_value,
g.gather_time AS gather_time
g.gather_time AS gather_time
FROM equ_base b
FROM equ_base b
@ -253,8 +244,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN equ_type t ON b.equ_type = t.id
LEFT JOIN equ_type t ON b.equ_type = t.id
LEFT JOIN equ_gather g ON b.id = g.equ_id
LEFT JOIN equ_gather g ON b.id = g.equ_id
where g.cpu_utilization is not null
where b.id = #{id}
and b.id = #{id}
-- 添加时间范围约束
-- 添加时间范围约束
and g.gather_time BETWEEN #{minTime} AND #{maxTime}
and g.gather_time BETWEEN #{minTime} AND #{maxTime}