Commit f4a9ecae authored by KeYong's avatar KeYong

修改bug

parent 2c86bdef
......@@ -7450,100 +7450,93 @@ WHERE
DROP VIEW IF EXISTS `v_fire_equip_alarm_fss_top5_3small`;
CREATE ALGORITHM = UNDEFINED DEFINER = `root` @`%` SQL SECURITY DEFINER VIEW `v_fire_equip_alarm_fss_top5_3small` AS
SELECT
ifnull(`a`.`fightSysName`, NULL) AS `fightSysName`,
ifnull(`a`.`fightSysCode`, NULL) AS `fightSysCode`,
ifnull(`a`.`fightSysId`, NULL) AS `fightSysId`,
ifnull(`a`.`report_date`, NULL) AS `reportDate`,
a.equipName,
sum(`a`.`total`) AS `total`
FROM
(
SELECT
`rd`.`index_type` AS `indxKey`,
`rd`.`index_name` AS `index_name`,
`rd`.`equipment_specific_name` AS `equipName`,
count(
DISTINCT `rd`.`equipment_specific_id`
) AS `total`,
`rd`.`report_date` AS `report_date`,
`fs`.`name` AS `fightSysName`,
`fs`.`code` AS `fightSysCode`,
`fs`.`id` AS `fightSysId`,
rd.equipment_specific_id AS equipId
FROM
(
`wl_equipment_alarm_report_day` `rd`
LEFT JOIN `f_fire_fighting_system` `fs` ON (
(
0 <> find_in_set(
`fs`.`id`,
`rd`.`system_ids`
)
)
)
)
WHERE
(
(
(curdate() - INTERVAL 30 DAY) <= cast(`rd`.`report_date` AS date)
)
AND (
-- 此处需要更改为换流变的系统code
`fs`.`code` = '011023306003010000000129'
)
AND (
(
`rd`.`index_type` LIKE '%Fault'
)
OR (
`rd`.`index_type` LIKE '%FireAlarm'
)
OR (
`rd`.`index_type` LIKE '%Shield'
)
)
AND (`rd`.`value` = 'true')
)
GROUP BY
`rd`.`equipment_specific_id`,
`rd`.`report_date`
) `a`
GROUP BY a.equipId
ORDER BY total DESC
LIMIT 5;
ifnull( `a`.`fightSysName`, NULL ) AS `fightSysName`,
ifnull( `a`.`fightSysCode`, NULL ) AS `fightSysCode`,
ifnull( `a`.`fightSysId`, NULL ) AS `fightSysId`,
ifnull( `a`.`report_date`, NULL ) AS `reportDate`,
`a`.`equipName` AS `equipName`,
sum( `a`.`total` ) AS `total`
FROM
(
SELECT
`rd`.`index_type` AS `indxKey`,
`rd`.`index_name` AS `index_name`,
`we`.`name` AS `equipName`,
count( DISTINCT `rd`.`equipment_specific_id` ) AS `total`,
`rd`.`report_date` AS `report_date`,
`fs`.`name` AS `fightSysName`,
`fs`.`code` AS `fightSysCode`,
`fs`.`id` AS `fightSysId`,
`rd`.`equipment_id` AS `equipId`
FROM
((
`wl_equipment_alarm_report_day` `rd`
LEFT JOIN `f_fire_fighting_system` `fs` ON ((
0 <> find_in_set( `fs`.`id`, `rd`.`system_ids` ))))
LEFT JOIN `wl_equipment` `we` ON ((
`we`.`id` = `rd`.`equipment_id`
)))
WHERE
(((
curdate() - INTERVAL 30 DAY
) <= cast( `rd`.`report_date` AS date ))
AND ( `fs`.`code` = '011023306003010000000129' )
AND ((
`rd`.`index_type` LIKE '%Fault'
)
OR ( `rd`.`index_type` LIKE '%FireAlarm' )
OR ( `rd`.`index_type` LIKE '%Shield' )))
GROUP BY
`rd`.`equipment_specific_id`,
`rd`.`report_date`
) `a`
GROUP BY
`a`.`equipId`
ORDER BY
`total` DESC
LIMIT 5;
-- 换流变水喷雾系统3小设备状态统计视图
DROP VIEW IF EXISTS `v_fire_equip_alarm_fss_3small`;
CREATE ALGORITHM = UNDEFINED DEFINER = `root` @`%` SQL SECURITY DEFINER VIEW `v_fire_equip_alarm_fss_3small` AS
SELECT
b.id AS `id`,
b.equipName,
( CASE WHEN b.totalNum > 0 THEN '异常' ELSE '正常' END ) `status`,
b.totalNum AS totalNum
FROM
(
SELECT
wesl.id AS `id`,
a.equipName,
count( wesl.id ) AS totalNum
`b`.`speId` AS `id`,
`b`.`equipName` AS `equipName`,(
CASE
WHEN ( `b`.`totalNum` > 0 ) THEN
'异常' ELSE '正常'
END
) AS `status`,
`b`.`totalNum` AS `totalNum`
FROM
(
SELECT
wes.`name` AS equipName,
wed.equipment_id AS equipmentId
`a`.`speId` AS `speId`,
`a`.`equipName` AS `equipName`,
count(wesl.equipment_specific_id) as totalNum
FROM
wl_equipment_specific wes
LEFT JOIN wl_equipment_detail wed ON wed.id = wes.equipment_detail_id
WHERE
--此处需要更改为水喷雾系统id
FIND_IN_SET( '1619086103649', wes.system_id ) > 0
GROUP BY
wed.equipment_id
) a
LEFT JOIN wl_equipment_specific_alarm_log wesl ON wesl.equipment_id = a.equipmentId
GROUP BY
a.equipmentId
) b;
(
SELECT
`wes`.`id` AS `speId`,
`wed`.`equipment_name` AS `equipName`,
`wed`.`equipment_id` AS `equipmentId`
FROM
(
`wl_equipment_specific` `wes`
LEFT JOIN `wl_equipment_detail` `wed` ON ((
`wed`.`id` = `wes`.`equipment_detail_id`
)))
WHERE
( find_in_set( '1657264678908', `wes`.`system_id` ) > 0 )
GROUP BY
`wed`.`equipment_id`
) `a`
LEFT JOIN `wl_equipment_specific_alarm_log` `wesl` ON `wesl`.`equipment_specific_id` = `a`.`speId`
GROUP BY
`a`.`equipmentId`
) b
ORDER BY
`b`.`totalNum` DESC;
-- 换流变水喷雾系统4小设备状态统计视图
DROP VIEW IF EXISTS `v_fire_equip_status_fss`;
......@@ -7674,8 +7667,7 @@ FROM
`rd`.`index_type` LIKE '%Fault'
)
OR ( `rd`.`index_type` LIKE '%FireAlarm' )
OR ( `rd`.`index_type` LIKE '%Shield' ))
AND ( `rd`.`value` = 'true' ))
OR ( `rd`.`index_type` LIKE '%Shield' )))
GROUP BY
`rd`.`equipment_specific_id`,
`rd`.`report_date`,
......
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