(select count(1) from ehs_enterprise e where e.area_id = d.dict_value and e.create_time>= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' )) thisUnitNum,
-- (select count(1) from ehs_enterprise e where e.area_id = d.dict_value and e.create_time>= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' )) thisUnitNum,
(select count(1) from ehs_enterprise e where e.area_id = d.dict_value) totalUnitNum,
(SELECT count(1) FROM ehs_enterprise e WHERE e.area_id = d.dict_value AND e.create_time BETWEEN DATE_FORMAT( #{targetTime}, '%Y-%m-01 00:00:00' ) AND CONCAT(LAST_DAY(#{targetTime}), ' 23:59:59')) thisUnitNum,
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) THEN r.hd_count ELSE 0 END ) 'thisReportNum',
(select count(1) from ehs_enterprise e where e.area_id = d.dict_value) totalUnitNum,
-- sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) THEN r.hd_count ELSE 0 END ) 'thisReportNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL AND r.check_time BETWEEN DATE_FORMAT( #{targetTime}, '%Y-%m-01 00:00:00' ) AND CONCAT(LAST_DAY(#{targetTime}), ' 23:59:59') THEN r.hd_count ELSE 0 END ) 'thisReportNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN r.hd_count ELSE 0 END ) 'totalReportNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN r.hd_count ELSE 0 END ) 'totalReportNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) and r.status = 10 THEN r.hd_count ELSE 0 END ) 'thisHaveNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) and r.status = 10 THEN r.hd_count ELSE 0 END ) 'thisHaveNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN r.hd_count ELSE 0 END ) 'totalHaveNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN r.hd_count ELSE 0 END ) 'totalHaveNum',
@ -164,7 +166,7 @@ SELECT
FROM
FROM
ehs_hidden_danger
ehs_hidden_danger
WHERE
WHERE
DATE_FORMAT( NOW(), '%Y-%m' ) = DATE_FORMAT( check_time, '%Y-%m' )) r ON r.dept_id = d.dept_id
DATE_FORMAT( #{targetTime}, '%Y-%m' ) = DATE_FORMAT( check_time, '%Y-%m' )) r ON r.dept_id = d.dept_id
GROUP BY
GROUP BY
d.dept_id,
d.dept_id,
d.dept_name
d.dept_name
@ -183,6 +185,7 @@ SELECT
LEFT JOIN sys_dict_data d ON e.enterprise_type = d.dict_value
LEFT JOIN sys_dict_data d ON e.enterprise_type = d.dict_value
AND d.dict_type = 'enterprise_type'
AND d.dict_type = 'enterprise_type'
<where>
<where>
AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m')
<iftest="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
<iftest="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
</where>
</where>
GROUP BY
GROUP BY
@ -199,6 +202,7 @@ SELECT
LEFT JOIN sys_dict_data d ON e.economic_type = d.dict_value
LEFT JOIN sys_dict_data d ON e.economic_type = d.dict_value
AND d.dict_type = 'economic_type'
AND d.dict_type = 'economic_type'
<where>
<where>
AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m')
<iftest="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
<iftest="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
</where>
</where>
GROUP BY
GROUP BY
@ -215,6 +219,7 @@ SELECT
LEFT JOIN sys_dict_data d ON e.enterprise_scale = d.dict_value
LEFT JOIN sys_dict_data d ON e.enterprise_scale = d.dict_value
AND d.dict_type = 'enterprise_scale'
AND d.dict_type = 'enterprise_scale'
<where>
<where>
AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m')
<iftest="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
<iftest="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
</where>
</where>
GROUP BY
GROUP BY
@ -246,6 +251,7 @@ SELECT
LEFT JOIN sys_dict_data d ON e.status = d.dict_value
LEFT JOIN sys_dict_data d ON e.status = d.dict_value
AND d.dict_type = 'hidden_danger_status'
AND d.dict_type = 'hidden_danger_status'
<where>
<where>
AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m')
<iftest="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
<iftest="deptId != null and deptId != ''">and dept_id = #{deptId}</if>