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.
195 lines
7.5 KiB
195 lines
7.5 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.biutag.supervision.mapper.StatisticsGroupMapper"> |
|
|
|
<select id="selectNegativeStatisticsByCity" resultType="com.biutag.supervision.pojo.dto.common.BarItem"> |
|
SELECT |
|
membersName label, |
|
`value` |
|
FROM |
|
negative_group_members m |
|
LEFT JOIN ( |
|
SELECT |
|
second_involve_depart_id, |
|
count( 1 ) `value` |
|
FROM |
|
negative |
|
WHERE |
|
crtTime BETWEEN #{beginTime} AND #{endTime} |
|
GROUP BY |
|
second_involve_depart_id |
|
) n ON m.membersCode = n.second_involve_depart_id |
|
WHERE |
|
groupId = #{groupId} |
|
ORDER BY |
|
`value` DESC |
|
</select> |
|
|
|
<select id="selectNegativePerNumberStatisticsByCity" resultType="com.biutag.supervision.pojo.dto.common.BarItem"> |
|
SELECT |
|
membersName label, |
|
`value` |
|
FROM |
|
negative_group_members m |
|
LEFT JOIN ( |
|
SELECT |
|
second_involve_depart_id, |
|
count( DISTINCT b.blameEmpNo ) `value` |
|
FROM |
|
negative n |
|
JOIN negative_blame b ON n.id = b.negativeId AND b.type = 'personal' |
|
WHERE |
|
n.crtTime BETWEEN #{beginTime} AND #{endTime} |
|
GROUP BY |
|
second_involve_depart_id |
|
) n ON m.membersCode = n.second_involve_depart_id |
|
WHERE |
|
groupId = #{groupId} |
|
ORDER BY |
|
`value` DESC |
|
</select> |
|
|
|
<select id="selectNegativePerCapitaStatisticsByCity" resultType="com.biutag.supervision.pojo.dto.common.BarItem"> |
|
SELECT |
|
membersName label, |
|
CASE WHEN s.police_size + s.aux_size > 0 THEN |
|
ROUND(total / ( s.police_size + s.aux_size ), 1) ELSE 0 END `value` |
|
FROM |
|
negative_group_members m |
|
LEFT JOIN ( |
|
SELECT |
|
second_involve_depart_id, |
|
count( 1 ) total |
|
FROM |
|
negative |
|
WHERE |
|
crtTime BETWEEN #{beginTime} AND #{endTime} |
|
GROUP BY |
|
second_involve_depart_id |
|
) n ON m.membersCode = n.second_involve_depart_id |
|
LEFT JOIN sup_depart_police_size s ON m.membersCode = s.depart_id |
|
WHERE |
|
groupId = #{groupId} |
|
ORDER BY |
|
`value` DESC |
|
</select> |
|
|
|
<sql id="threeDepartLabel"> |
|
CASE WHEN m.groupId IN ('20', '21', '22') |
|
AND NULLIF(TRIM(parent_depart.short_name), '') IS NOT NULL |
|
THEN CONCAT(parent_depart.short_name, '/', m.membersName) |
|
ELSE m.membersName END label |
|
</sql> |
|
|
|
<select id="selectNegativeStatisticsByThree" resultType="com.biutag.supervision.pojo.dto.common.BarItem"> |
|
SELECT |
|
<include refid="threeDepartLabel"/>, |
|
COALESCE(`value`, 0) `value`, |
|
detail_depart.id detailId |
|
FROM |
|
negative_group_members m |
|
INNER JOIN sup_depart detail_depart ON detail_depart.id = m.membersCode AND detail_depart.level = 3 |
|
LEFT JOIN sup_depart parent_depart ON parent_depart.id = detail_depart.pid |
|
LEFT JOIN ( |
|
SELECT |
|
involveDepartId, |
|
count( 1 ) `value` |
|
FROM |
|
negative |
|
WHERE |
|
crtTime BETWEEN #{beginTime} AND #{endTime} |
|
GROUP BY |
|
involveDepartId |
|
) n ON m.membersCode = n.involveDepartId |
|
WHERE |
|
groupId = #{groupId} |
|
ORDER BY |
|
`value` DESC limit 8 |
|
</select> |
|
|
|
<select id="selectNegativePerNumberStatisticsByThree" resultType="com.biutag.supervision.pojo.dto.common.BarItem"> |
|
SELECT |
|
<include refid="threeDepartLabel"/>, |
|
`value`, |
|
detail_depart.id detailId |
|
FROM |
|
negative_group_members m |
|
LEFT JOIN sup_depart detail_depart ON detail_depart.id = m.membersCode |
|
LEFT JOIN sup_depart parent_depart ON parent_depart.id = detail_depart.pid |
|
LEFT JOIN ( |
|
SELECT |
|
three_involve_depart_id, |
|
count( DISTINCT b.blameEmpNo ) `value` |
|
FROM |
|
negative n |
|
JOIN negative_blame b ON n.id = b.negativeId AND b.type = 'personal' |
|
WHERE |
|
n.crtTime BETWEEN #{beginTime} AND #{endTime} |
|
GROUP BY |
|
three_involve_depart_id |
|
) n ON m.membersCode = n.three_involve_depart_id |
|
WHERE |
|
groupId = #{groupId} |
|
ORDER BY |
|
`value` DESC limit 8 |
|
</select> |
|
|
|
<select id="selectNegativePerCapitaStatisticsByThree" resultType="com.biutag.supervision.pojo.dto.common.BarItem"> |
|
SELECT |
|
<include refid="threeDepartLabel"/>, |
|
CASE WHEN s.police_size + s.aux_size > 0 THEN |
|
ROUND(total / ( s.police_size + s.aux_size ), 1) ELSE 0 END `value`, |
|
detail_depart.id detailId |
|
FROM |
|
negative_group_members m |
|
LEFT JOIN sup_depart detail_depart ON detail_depart.id = m.membersCode |
|
LEFT JOIN sup_depart parent_depart ON parent_depart.id = detail_depart.pid |
|
LEFT JOIN ( |
|
SELECT |
|
three_involve_depart_id, |
|
count( 1 ) total |
|
FROM |
|
negative |
|
WHERE |
|
crtTime BETWEEN #{beginTime} AND #{endTime} |
|
GROUP BY |
|
three_involve_depart_id |
|
) n ON m.membersCode = n.three_involve_depart_id |
|
LEFT JOIN sup_depart_police_size s ON m.membersCode = s.depart_id |
|
WHERE |
|
groupId = #{groupId} |
|
ORDER BY |
|
`value` DESC limit 8 |
|
</select> |
|
|
|
<select id="selectNegativeStatistics" resultType="com.biutag.supervision.pojo.dto.common.BarItem"> |
|
SELECT |
|
b.blameName label, |
|
b.blameEmpNo empNo, |
|
count( DISTINCT n.id ) `value`, |
|
CASE WHEN COUNT(DISTINCT NULLIF(TRIM(b.blameIdCode), '')) = 1 |
|
AND COUNT(DISTINCT p.id) = 1 |
|
AND (SELECT COUNT(DISTINCT NULLIF(TRIM(b2.blameIdCode), '')) |
|
FROM negative_blame b2 WHERE b2.blameName = b.blameName) = 1 |
|
THEN MIN(p.id_code) END detailId |
|
FROM |
|
negative n |
|
JOIN negative_blame b ON n.id = b.negativeId |
|
AND b.type = #{type} AND b.ivPersonTypeCode in |
|
<foreach collection="personTypeCode" item="data" open="(" close=")" separator=","> |
|
#{data} |
|
</foreach> |
|
LEFT JOIN sup_police p ON p.id_code = b.blameIdCode AND p.del = 0 |
|
LEFT JOIN sup_depart d ON n.handle_three_depart_id = d.id |
|
WHERE |
|
n.crtTime BETWEEN #{beginTime} AND #{endTime} |
|
AND d.statistics_group_id = #{groupId} |
|
GROUP BY |
|
b.blameEmpNo, |
|
b.blameName |
|
ORDER BY `value` desc LIMIT 8 |
|
</select> |
|
|
|
</mapper>
|
|
|