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

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

parent 1c132af4
......@@ -86,41 +86,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectRealtimeDataList" parameterType="DeviceReportDataForm" resultMap="TDeviceReportDataResultVo">
select
max(t.report_time) report_time,
t.device_report_data_id,
t.device_num,
t.standard_condition_accumulation,
t.working_condition_accumulation,
t.residual_quantity,
t.standard_condition_flow,
t.working_condition_flow,
t.temperature,
t.pressure,
t.communication_status,
t.create_time,
t.update_time,
d.device_id,
d.device_name,
d.device_code,
d.device_type,
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)
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
SELECT
*
FROM
(
SELECT
t.report_time,
t.device_report_data_id,
t.device_num,
t.standard_condition_accumulation,
t.working_condition_accumulation,
t.residual_quantity,
t.standard_condition_flow,
t.working_condition_flow,
t.temperature,
t.pressure,
t.communication_status,
t.create_time,
t.update_time,
d.device_id,
d.device_name,
d.device_code,
d.device_type,
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
)
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>
<if test="deviceCode != null and deviceCode != ''"> and d.device_code like concat('%',#{deviceCode},'%')</if>
<if test="deviceType != null and deviceType != ''"> and d.device_type = #{deviceType}</if>
<if test="deviceType == null "> and (d.device_type = '3' or d.device_type = '4')</if>
<if test="startReportTime != null "> and t.report_time &gt;= #{startReportTime}</if>
<if test="endReportTime != null "> and t.report_time &lt;= #{endReportTime}</if>
<if test="communicationStatus != null and communicationStatus != ''"> and t.communication_status = #{communicationStatus}</if>
<if test="deviceStatus != null and deviceStatus != ''"> and t.device_status = #{deviceStatus}</if>
<if test="deviceCode != null and deviceCode != ''"> and data.device_code like concat('%',#{deviceCode},'%')</if>
<if test="deviceType != null and deviceType != ''"> and data.device_type = #{deviceType}</if>
<if test="deviceType == null "> and (data.device_type = '3' or data.device_type = '4')</if>
<if test="startReportTime != null "> and data.create_time &gt;= #{startReportTime}</if>
<if test="endReportTime != null "> and data.create_time &lt;= #{endReportTime}</if>
<if test="communicationStatus != null and communicationStatus != ''"> and data.communication_status = #{communicationStatus}</if>
<if test="deviceStatus != null and deviceStatus != ''"> and data.device_status = #{deviceStatus}</if>
</where>
group by d.device_id
GROUP BY data.device_id
</select>
<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