🐞 fix: 报告生成-厂界在线调整报警次数统计逻辑
This commit is contained in:
parent
be16d6a901
commit
10ac11005a
|
@ -212,25 +212,25 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- 选择 某年year,每个deptId下的所有设备的每个月的超限次数(ds不在dbz和gbz范围内的行) -->
|
<!-- 选择 某年year,每个deptId下的所有设备的每个月的报警次数(d.zt = '一级报警' OR d.zt = '二级报警') -->
|
||||||
<select id="selectOverLimitCountByYearAndDeptId" parameterType="map" resultType="map">
|
<select id="selectOverLimitCountByYearAndDeptId" parameterType="map" resultType="map">
|
||||||
SELECT d.sn,
|
SELECT d.sn,
|
||||||
td.address,
|
td.address,
|
||||||
p.dept_name as "p",
|
p.dept_name as "p",
|
||||||
pp.dept_name as "pp",
|
pp.dept_name as "pp",
|
||||||
ppp.dept_name as "ppp",
|
ppp.dept_name as "ppp",
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '01' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month1,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '01' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month1,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '02' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month2,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '02' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month2,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '03' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month3,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '03' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month3,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '04' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month4,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '04' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month4,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '05' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month5,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '05' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month5,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '06' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month6,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '06' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month6,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '07' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month7,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '07' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month7,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '08' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month8,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '08' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month8,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '09' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month9,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '09' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month9,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '10' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month10,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '10' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month10,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '11' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month11,
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '11' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month11,
|
||||||
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '12' AND (TO_NUMBER(d.ds) > TO_NUMBER(d.gbz) OR TO_NUMBER(d.ds) < TO_NUMBER(d.dbz)) THEN 1 ELSE 0 END) AS month12
|
SUM(CASE WHEN TO_CHAR(d.report_time, 'MM') = '12' AND (d.zt = '一级报警' OR d.zt = '二级报警') THEN 1 ELSE 0 END) AS month12
|
||||||
FROM th_device_report d
|
FROM th_device_report d
|
||||||
LEFT JOIN th_device td ON d.sn = td.sn
|
LEFT JOIN th_device td ON d.sn = td.sn
|
||||||
LEFT JOIN sys_dept p ON td.dept_id = p.dept_id
|
LEFT JOIN sys_dept p ON td.dept_id = p.dept_id
|
||||||
|
|
Loading…
Reference in New Issue