factorySql="select fi.id,fi.depart_id,d.depart_name, fi.pro_longitude,fi.pro_latitude ,d.depart_type from sys_factory_info fi ,sys_depart d where fi.depart_id = d.id and d.depart_type =-1";
(select t.depart_name from sys_depart t where t.id = a.depart_id ) 'depart_name',
(
select sum(fiv.item_value)/10000 from f_report_itemv fiv ,f_report_item fi
where fi.report_id = '2119ecbf53a1d2d0708258ff67cfd9e1' and item_code= 'CSL' and fiv.reit_id =fi.id and a.depart_id = fiv.depart_id and fiv.data_time like '2024%'
) 'ysjsl',
(
select sum(fiv.item_value)/10000 from f_report_itemv fiv ,f_report_item fi
where fi.report_id = '2119ecbf53a1d2d0708258ff67cfd9e1' and item_code= 'CSL' and fiv.reit_id =fi.id and a.depart_id = fiv.depart_id and fiv.data_time like '2023%'
) 'tqysjsl',
(select sum(fiv.item_value)/10000 from f_report_itemv fiv ,f_report_item fi
where fi.report_id = '3a243d5715b9e1a3753c180872ca0df9' and item_code= 'DLHJ' and fiv.reit_id =fi.id and a.depart_id = fiv.depart_id and fiv.data_time like '2024%' ) 'ydh',
sum( IF ( ( `d`.`item_code` = 'yslwcbl' ), `a`.`item_value`, NULL ) ) AS `yslwcbl`, -- 月水量完成比例
sum( IF ( ( `d`.`item_code` = 'ysjsldyqntqyy' ), `a`.`item_value`, NULL ) ) AS `ysjsldyqntqyy`, -- 月实际水量低于去年同期原因
sum( IF ( ( `d`.`item_code` = 'qntqsfsl' ), `a`.`item_value`, NULL ) ) AS `qntqsfsl`, -- 去年同期收费水量
sum( IF ( ( `d`.`item_code` = 'ysfsl' ), `a`.`item_value`, NULL ) ) AS `ysfsl`, -- 月收费水量
sum( IF ( ( `d`.`item_code` = 'bnsjdh' ), `a`.`item_value`, NULL ) ) AS `bnsjdh`,-- 本年实际电耗
sum( IF ( ( `d`.`item_code` = 'sldyyqyy' ), `a`.`item_value`, NULL ) ) AS `sldyyqyy`,-- 收费水量对比变化率
sum( IF ( ( `d`.`item_code` = 'dhgyqntqyy' ), `a`.`item_value`, NULL ) ) AS `dhgyqntqyy`, -- 电耗高于去年同期原因
sum( IF ( ( `d`.`item_code` = 'yyf' ), `a`.`item_value`, NULL ) ) AS `yyf`, -- 月药费
sum( IF ( ( `d`.`item_code` = 'yhgyqntqyy' ), `a`.`item_value`, NULL ) ) AS `yhgyqntqyy`, -- 药耗高于去年同期原因
sum( IF ( ( `d`.`item_code` = 'dhcmbzyy' ), `a`.`item_value`, NULL ) ) AS `dhcmbzyy`, -- 电耗超目标值原因
sum( IF ( ( `d`.`item_code` = 'yhcyqyy' ), `a`.`item_value`, NULL ) ) AS `yhcyqyy` -- 药耗超预期原因
FROM
( (SELECT reit_id,item_value,depart_id
FROM f_report_itemv
WHERE
data_time LIKE '2024%'
AND reit_id IN (
'1818936216687595521',
'1818936217375461377',
'1818936218109464577',
'1818936218910576642',
'1818936219120291842',
'1818936219854295042',
'1818936220017872897',
'1818936220353417218',
'1818936220571521025',
'1818936220739293185',
'1818936220890288130' )
) `a`
LEFT JOIN `f_report_item` `d` ON ( ( `a`.`reit_id` = `d`.`id` ) )
LEFT JOIN `report_target_config` tc ON ( ( `tc`.`depart_id` = `a`.`depart_id` ) )