Commit 1531fe5b authored by 耿迪迪's avatar 耿迪迪

数据监测取最新数据问题修改 gengdidi

parent 1c132af4
...@@ -86,8 +86,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -86,8 +86,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectRealtimeDataList" parameterType="DeviceReportDataForm" resultMap="TDeviceReportDataResultVo"> <select id="selectRealtimeDataList" parameterType="DeviceReportDataForm" resultMap="TDeviceReportDataResultVo">
select SELECT
max(t.report_time) report_time, *
FROM
(
SELECT
t.report_time,
t.device_report_data_id, t.device_report_data_id,
t.device_num, t.device_num,
t.standard_condition_accumulation, t.standard_condition_accumulation,
...@@ -105,22 +109,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -105,22 +109,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.device_code, d.device_code,
d.device_type, d.device_type,
d.device_model, d.device_model,
CASE (SELECT COUNT(DISTINCT alarm.device_id) FROM t_device_alarm alarm WHERE alarm.device_id = d.device_id AND alarm.end_time IS NULL) CASE (
WHEN 0 THEN '正常' SELECT
ELSE '报警' COUNT(DISTINCT alarm.device_id)
END as device_status FROM
from t_device_report_data t t_device_alarm alarm
LEFT JOIN t_device_info d on t.device_num = d.iot_no WHERE
alarm.device_id = d.device_id
AND alarm.end_time IS NULL
)
WHEN 0 THEN
'正常'
ELSE
'报警'
END AS device_status
FROM
t_device_report_data t
LEFT JOIN t_device_info d ON t.device_num = d.iot_no
WHERE
(
d.device_type = '3'
OR d.device_type = '4'
)
ORDER BY t.create_time DESC
)data
<where> <where>
<if test="deviceCode != null and deviceCode != ''"> and d.device_code like concat('%',#{deviceCode},'%')</if> <if test="deviceCode != null and deviceCode != ''"> and data.device_code like concat('%',#{deviceCode},'%')</if>
<if test="deviceType != null and deviceType != ''"> and d.device_type = #{deviceType}</if> <if test="deviceType != null and deviceType != ''"> and data.device_type = #{deviceType}</if>
<if test="deviceType == null "> and (d.device_type = '3' or d.device_type = '4')</if> <if test="deviceType == null "> and (data.device_type = '3' or data.device_type = '4')</if>
<if test="startReportTime != null "> and t.report_time &gt;= #{startReportTime}</if> <if test="startReportTime != null "> and data.create_time &gt;= #{startReportTime}</if>
<if test="endReportTime != null "> and t.report_time &lt;= #{endReportTime}</if> <if test="endReportTime != null "> and data.create_time &lt;= #{endReportTime}</if>
<if test="communicationStatus != null and communicationStatus != ''"> and t.communication_status = #{communicationStatus}</if> <if test="communicationStatus != null and communicationStatus != ''"> and data.communication_status = #{communicationStatus}</if>
<if test="deviceStatus != null and deviceStatus != ''"> and t.device_status = #{deviceStatus}</if> <if test="deviceStatus != null and deviceStatus != ''"> and data.device_status = #{deviceStatus}</if>
</where> </where>
group by d.device_id GROUP BY data.device_id
</select> </select>
<select id="selectTDeviceReportDataByDeviceNum" parameterType="String" resultMap="TDeviceReportDataResult"> <select id="selectTDeviceReportDataByDeviceNum" parameterType="String" resultMap="TDeviceReportDataResult">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment