(SELECT wei.emergency_level FROM wl_equipment_index wei LEFT JOIN wl_equipment_specific_index wesi ON wei.id = wesi.equipment_index_id WHERE wesi.equipment_specific_id = wes.id AND wesi.equipment_index_key = wes.realtime_iot_index_key) as level,
wes.code as code ,
wes.name,
IFNULL(wes.realtime_iot_index_name, '暂无信号') AS status,
CASE
WHEN (SELECT is_alarm FROM wl_equipment_specific_index wesi WHERE wesi.equipment_specific_id = wes.id AND wesi.equipment_index_key = wes.realtime_iot_index_key ) = 1 AND wes.realtime_iot_index_value = 'true' THEN 1
ELSE 0
END AS alarm
FROM
wl_equipment_specific wes
JOIN f_equipment_fire_equipment fire ON wes.id = fire.fire_equipment_id
WHERE
(
wes.equipment_code LIKE concat( '92044300', '%')
OR wes.equipment_code LIKE concat( '92040100', '%')
)
<iftest="code != null and code!='' ">
AND fire.equipment_id = (SELECT id FROM f_equipment WHERE `code` = #{code})
</if>
AND wes.biz_org_code LIKE CONCAT( #{bizOrgCode}, '%')
(SELECT wei.emergency_level FROM wl_equipment_index wei LEFT JOIN wl_equipment_specific_index wesi ON wei.id = wesi.equipment_index_id WHERE wesi.equipment_specific_id = wes.id AND wesi.equipment_index_key = wes.realtime_iot_index_key) as level,
(SELECT wei.emergency_level FROM wl_equipment_index wei LEFT JOIN wl_equipment_specific_index wesi ON wei.id = wesi.equipment_index_id WHERE wesi.equipment_specific_id = wes.id AND wesi.equipment_index_key = wes.realtime_iot_index_key) as level,
wes.code as code ,
wes.code as code ,
...
@@ -1420,6 +1445,7 @@
...
@@ -1420,6 +1445,7 @@
IF (wlesal.clean_time IS NOT NULL, '已消除', '未消除' ) cleanStatus,
IF (wlesal.clean_time IS NOT NULL, '已消除', '未消除' ) cleanStatus,
wlesal.equipment_index_id AS fireEquipmentIndexId,
wlesal.equipment_index_id AS fireEquipmentIndexId,
wlesal.equipment_specific_code AS code,
wlesal.equipment_specific_code AS code,
fs.code AS systemCode,
wlesal.equipment_specific_index_key AS fireEquipmentSpecificIndexKey,
wlesal.equipment_specific_index_key AS fireEquipmentSpecificIndexKey,
wlesal.equipment_specific_index_name AS fireEquipmentSpecificIndexName,
wlesal.equipment_specific_index_name AS fireEquipmentSpecificIndexName,
wlesal.emergency_level_color AS emergencyLevelColor,
wlesal.emergency_level_color AS emergencyLevelColor,
...
@@ -1454,11 +1480,11 @@
...
@@ -1454,11 +1480,11 @@
<iftest='createDate != null and createDate == "1"'>
<iftest='createDate != null and createDate == "1"'>
AND wlesal.create_date LIKE CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d' ), '%' )
AND wlesal.create_date LIKE CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d' ), '%' )
</if>
</if>
<iftest='startDate != null and startDate == ""'>
<iftest="startDate != null and startDate != ''">
AND wlesal.create_date >= DATE_FORMAT( ${startDate}, '%Y-%m-%d %H:%i:%s' )
AND wlesal.create_date >= DATE_FORMAT( #{startDate}, '%Y-%m-%d %H:%i:%s' )
</if>
</if>
<iftest='endDate != null and endDate == ""'>
<iftest="endDate != null and endDate != ''">
AND DATE_FORMAT( ${endDate}, '%Y-%m-%d %H:%i:%s' ) >= wlesal.create_date
AND DATE_FORMAT( #{endDate}, '%Y-%m-%d %H:%i:%s' ) >= wlesal.create_date
</if>
</if>
<iftest="systemCode != null and systemCode != ''">
<iftest="systemCode != null and systemCode != ''">
and fs.code = #{systemCode}
and fs.code = #{systemCode}
...
@@ -1534,10 +1560,10 @@
...
@@ -1534,10 +1560,10 @@
<iftest='createDate != null and createDate == "1"'>
<iftest='createDate != null and createDate == "1"'>
AND wlesal.create_date LIKE CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d' ), '%' )
AND wlesal.create_date LIKE CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d' ), '%' )
</if>
</if>
<iftest='startDate != null and startDate == ""'>
<iftest="startDate != null and startDate != ''">
AND wlesal.create_date >= DATE_FORMAT( ${startDate}, '%Y-%m-%d %H:%i:%s' )
AND wlesal.create_date >= DATE_FORMAT( ${startDate}, '%Y-%m-%d %H:%i:%s' )
</if>
</if>
<iftest='endDate != null and endDate == ""'>
<iftest="endDate != null and endDate != ''">
AND DATE_FORMAT( ${endDate}, '%Y-%m-%d %H:%i:%s' ) >= wlesal.create_date
AND DATE_FORMAT( ${endDate}, '%Y-%m-%d %H:%i:%s' ) >= wlesal.create_date
</if>
</if>
<iftest="systemCode != null and systemCode != ''">
<iftest="systemCode != null and systemCode != ''">
IFNULL(temp1.alarmEquipNum,0) AS alarmEquipNum, temp1.type_code,temp.code
IFNULL(temp1.alarmEquipNum,0) AS alarmEquipNum, temp1.type_code,temp.code
FROM
FROM
...
@@ -4281,12 +4281,6 @@
...
@@ -4281,12 +4281,6 @@
FROM wl_equipment_alarm_report_day report
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code
where report.equipment_code = a.code
and FIND_IN_SET(a.system_id,report.system_ids)
and FIND_IN_SET(a.system_id,report.system_ids)
and( report.index_type LIKE CONCAT('%','FireAlarm','%')
or report.index_type LIKE CONCAT('%','Fault','%')
or report.index_type LIKE CONCAT('%','Shield','%')
or report.index_type LIKE CONCAT('%','Open','%')
or report.index_type LIKE CONCAT('%','OilLeak','%')
or report.index_type LIKE CONCAT('%','Alarm','%') )
and report.index_true_num > 0 and report.report_date >= #{startDate} and
and report.index_true_num > 0 and report.report_date >= #{startDate} and
report.report_date <= #{endDate}) as exepctionNum
report.report_date <= #{endDate}) as exepctionNum
FROM(
FROM(
...
@@ -4294,7 +4288,7 @@
...
@@ -4294,7 +4288,7 @@
s.id as system_id,
s.id as system_id,
equipment.code,
equipment.code,
equipment.name,
equipment.name,
count(1) AS num
(select count(1) from wl_equipment_specific s where FIND_IN_SET( #{systemId}, s.system_id ) AND equipment.is_iot = 1 and s.equipment_code = equipment.code ) AS num
FROM
FROM
wl_equipment_specific spec
wl_equipment_specific spec
LEFT JOIN wl_equipment_detail detail ON spec.equipment_detail_id = detail.id
LEFT JOIN wl_equipment_detail detail ON spec.equipment_detail_id = detail.id
...
@@ -4358,23 +4352,21 @@
...
@@ -4358,23 +4352,21 @@
)temp1 on temp.system_id = temp1.systemId and temp.code = temp1.code
)temp1 on temp.system_id = temp1.systemId and temp.code = temp1.code
group by code, type_code
group by code, type_code
ORDER BY temp.name
ORDER BY temp.name ) d where type_code is not null
a.`name`, IFNULL( a.nowLevel, '--' ) AS nowLevel, a.id, IFNULL( a.image, '' ) AS image, a.unit, a.minLevel AS minLevel, a.maxLevel AS maxLevel, (
a.`name`,
IFNULL( a.nowLevel, '--' ) AS nowLevel,
a.id,
IFNULL( a.image, '' ) AS image,
a.unit,
a.minLevel AS minLevel,
a.maxLevel AS maxLevel,
(
CASE
CASE
WHEN a.nowLevel IS NULL
WHEN a.nowLevel IS NULL
OR a.minLevel IS NULL THEN '--'
OR a.minLevel IS NULL THEN
WHEN a.minLevel - a.nowLevel > 0 THEN '缺水'
'--'
ELSE '正常'
WHEN a.minLevel - a.nowLevel > 0 THEN
END ) AS levelStatus, 'foamTank' AS type
'缺水' ELSE '正常'
END
) AS levelStatus,
'foamTank' AS type
FROM
FROM
(
(
SELECT
SELECT
ed.`name`, es.iot_code, es.id, ec.image, ei.unit, max( CASE WHEN ei.equipment_index_key = 'CAFS_FoamTank_FoamTankLevel' THEN ei.`value` END ) AS nowLevel, max( CASE WHEN fi.field_name = 'minLevel' THEN fi.field_value END ) AS minLevel, max( CASE WHEN fi.field_name = 'maxLevel' THEN fi.field_value END ) AS maxLevel
ed.`name`,
es.iot_code,
es.id,
ec.image,
ei.unit,
max( CASE WHEN ei.equipment_index_key = 'CAFS_FoamTank_FoamTankLevel' THEN ei.`value` END ) AS nowLevel,
max( CASE WHEN fi.field_name = 'minLevel' THEN fi.field_value END ) AS minLevel,
max( CASE WHEN fi.field_name = 'maxLevel' THEN fi.field_value END ) AS maxLevel
FROM
FROM
wl_equipment_specific es
wl_equipment_specific es
LEFT JOIN wl_equipment_detail ed ON
LEFT JOIN wl_equipment_detail ed ON es.equipment_detail_id = ed.id
es.equipment_detail_id = ed.id
LEFT JOIN wl_equipment_specific_index ei ON es.id = ei.equipment_specific_id
LEFT JOIN wl_equipment_specific_index ei ON
LEFT JOIN wl_equipment e ON e.id = ed.equipment_id
es.id = ei.equipment_specific_id
LEFT JOIN wl_equipment_category ec ON e.category_id = ec.id
LEFT JOIN wl_equipment e ON
LEFT JOIN wl_form_instance_equip fi ON fi.instance_id = es.id
e.id = ed.equipment_id
LEFT JOIN wl_equipment_category ec ON
e.category_id = ec.id
LEFT JOIN wl_form_instance_equip fi ON
fi.instance_id = es.id
WHERE
WHERE
ed.`code` LIKE '92031900%'
ed.`code` LIKE '92031900%'
AND es.biz_org_code LIKE concat(#{bizOrgCode}, '%')
AND es.biz_org_code LIKE concat( #{bizOrgCode}, '%')
AND es.iot_code IS NOT NULL
AND es.iot_code IS NOT NULL GROUP BY es.id ) a UNION ALL
GROUP BY
es.id ) a
UNION ALL
SELECT
SELECT
a.`name`, IFNULL( a.nowLevel, '--' ) AS nowLevel, a.id, IFNULL( a.image, '' ) AS image, 'M' AS unit, a.minLevel AS minLevel, a.maxLevel AS maxLevel, (
a.`name`,
IFNULL( a.nowLevel, '--' ) AS nowLevel,
a.id,
IFNULL( a.image, '' ) AS image,
a.unit AS unit,
a.minLevel AS minLevel,
a.maxLevel AS maxLevel,
(
CASE
CASE
WHEN a.nowLevel IS NULL
WHEN a.nowLevel IS NULL
OR a.minLevel IS NULL THEN '--'
OR a.minLevel IS NULL THEN
WHEN a.minLevel - a.nowLevel > 0 THEN '缺水'
'--'
ELSE '正常'
WHEN a.minLevel - a.nowLevel > 0 THEN
END ) AS levelStatus, a.type AS type
'缺水' ELSE '正常'
END
) AS levelStatus,
'waterTank' AS type
FROM
FROM
(
(
SELECT
SELECT
r.`name`, IFNULL( rp.min_water_level, 0 ) AS minLevel, IFNULL( rp.max_water_level, 0 ) AS maxLevel, (
ed.`name`,
SELECT
es.iot_code,
FORMAT( avg( IFNULL( ei.`value`, 0 ) ), 2 )
es.id,
FROM
ec.image,
wl_equipment_specific_index ei
ei.unit,
WHERE
max( CASE WHEN ei.equipment_index_key = 'CAFS_WaterTank_WaterTankLevel' THEN ei.`value` END ) AS nowLevel,