<?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="cn.com.basic.security.entity.SecurityAnalyse">
|
<!-- 保安数量 -->
|
<select id="selectSecurityCount" resultType="java.lang.Integer" parameterType="java.util.List">
|
select count(id) count from se_personnel
|
where age is not null and org_id in
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<!-- 保安奖励数量 -->
|
<select id="selectRewardCount" resultType="java.lang.Integer" parameterType="java.util.Map">
|
SELECT COUNT(rp.id) count FROM `se_reward_punishment_info` rp JOIN se_personnel p ON p.id = rp.personnel_id
|
WHERE rp.type = 0 AND org_id IN
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<!-- 保安惩罚数量 -->
|
<select id="selectPunishmentCount" resultType="java.lang.Integer" parameterType="java.util.List">
|
SELECT COUNT(rp.id) count FROM `se_reward_punishment_info` rp JOIN se_personnel p ON p.id = rp.personnel_id
|
WHERE rp.type = 1 AND org_id IN
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<!-- 保安公司数量 -->
|
<select id="selectCompanyCount" resultType="java.lang.Integer" parameterType="java.util.List">
|
SELECT count(*) count FROM (
|
SELECT assignment_company_name FROM `se_personnel` WHERE org_id IN
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
GROUP BY assignment_company_name
|
)temp
|
</select>
|
|
<!-- 年龄分布 -->
|
<select id="selectAgeAnalyse" resultType="cn.com.basic.security.entity.SecurityAnalyse" parameterType="java.util.List">
|
select nnd title,count(id) item1 from(
|
select id,
|
case
|
when age>=18 and age <![CDATA[ <= ]]> 19 then '18-19岁'
|
when age>=20 and age <![CDATA[ <= ]]> 29 then '20-29岁'
|
when age>=30 and age <![CDATA[ <= ]]> 39 then '30-39岁'
|
when age>=40 and age <![CDATA[ <= ]]> 49 then '40-49岁'
|
when age>=50 and age <![CDATA[ <= ]]> 59 then '50-59岁'
|
end as nnd from se_personnel
|
where age is not null and org_id in
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
)a group by nnd
|
</select>
|
|
<!-- 学历分布 -->
|
<select id="selectEducationAnalyse" resultType="cn.com.basic.security.entity.SecurityAnalyse" parameterType="java.util.List">
|
SELECT education title,COUNT(id) item1 FROM `se_personnel`
|
WHERE org_id IN
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
GROUP BY education
|
</select>
|
|
<!-- 地域分布 -->
|
<select id="selectRegionAnalyse" resultType="cn.com.basic.security.entity.SecurityAnalyse" parameterType="java.util.List">
|
SELECT c.name title,COUNT(p.id) item1 FROM `se_personnel` p JOIN canton c ON c.id = p.province
|
WHERE p.org_id IN
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
GROUP BY p.province ORDER BY c.id ASC
|
</select>
|
|
<!-- 公司奖惩分布 -->
|
<select id="selectCompanyRewardPunishmentAnalyse" resultType="cn.com.basic.security.entity.SecurityAnalyse" parameterType="java.util.List">
|
SELECT temp2.title,
|
max(case temp2.type when 0 then temp2.item else 0 end) item1,
|
max(case temp2.type when 1 then temp2.item else 0 end) item2
|
FROM (SELECT temp.assignment_company_name title ,COUNT(temp.personnel_id) item,temp.type FROM (
|
SELECT rp.personnel_id,p.`name`,assignment_company_name,p.org_id,rp.type FROM se_personnel p
|
JOIN se_reward_punishment_info rp ON p.id = rp.personnel_id
|
|
WHERE p.org_id IN
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
) temp
|
GROUP BY assignment_company_name,type)temp2 GROUP BY temp2.title
|
</select>
|
|
|
<!-- 学校奖惩分布 -->
|
<select id="selectSchoolRewardPunishmentAnalyse" resultType="cn.com.basic.security.entity.SecurityAnalyse" parameterType="java.util.List">
|
SELECT temp2.title,
|
max(case temp2.type when 0 then temp2.item else 0 end) item1,
|
max(case temp2.type when 1 then temp2.item else 0 end) item2
|
FROM
|
|
(SELECT temp.orgName title ,COUNT(temp.id) item,temp.type,temp.org_id FROM (
|
|
SELECT rp.id,rp.personnel_id,p.`name`,p.org_id,rp.type,o.name orgName FROM se_personnel p
|
JOIN se_reward_punishment_info rp ON p.id = rp.personnel_id
|
JOIN t_sys_organization o ON o.id = p.org_id
|
|
WHERE p.org_id IN
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
) temp
|
GROUP BY orgName,type) temp2
|
|
GROUP BY temp2.title
|
</select>
|
|
|
|
</mapper>
|