隐患排查APP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
3.3 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hisense.hiatmp.base.mapper.HighDangerMapper">
<select id="getStatusCounts" resultType="com.hisense.hiatmp.model.common.HighDangerBaseNum">
SELECT 'Unconfirmed' AS status, SUM(CASE WHEN hdb.status = '0' THEN 1 ELSE 0 END) AS count
FROM tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status
WHERE hdb.handle_dept = #{cdepartmentid}
UNION ALL
SELECT 'UnderInvestigation' AS status, SUM(CASE WHEN hdb.status = '10' THEN 1 ELSE 0 END) AS count
FROM tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status
WHERE hdb.handle_dept = #{cdepartmentid}
UNION ALL
SELECT 'InGovernance' AS status, SUM(CASE WHEN hdb.status = '20' THEN 1 ELSE 0 END) AS count
FROM tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status
WHERE hdb.handle_dept = #{cdepartmentid}
UNION ALL
SELECT 'Tracking' AS status, SUM(CASE WHEN hdb.status = '30' THEN 1 ELSE 0 END) AS count
FROM tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status
WHERE hdb.handle_dept = #{cdepartmentid}
UNION ALL
SELECT 'NonHazard' AS status, SUM(CASE WHEN hdb.status = '50' THEN 1 ELSE 0 END) AS count
FROM tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status
WHERE hdb.handle_dept = #{cdepartmentid}
</select>
<select id="getHigDangerDealt" resultType="com.hisense.hiatmp.model.common.HighDangerBase">
SELECT
*
FROM
tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id
AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601'
AND et.enumvalue = hdb.status
WHERE
hdb.handle_dept = #{cdepartmentid}
AND hdb.status = #{statuss}
</select>
</mapper>