Commit ca7e9143 authored by 李秀明's avatar 李秀明

人员统计优化

parent eaef1c40
...@@ -1757,90 +1757,42 @@ ...@@ -1757,90 +1757,42 @@
<select id="getCenterPersonInfoPage" resultType="Map"> <select id="getCenterPersonInfoPage" resultType="Map">
SELECT SELECT
LEFT ( LEFT(a.biz_org_code,18) AS bizOrgCode,
a.biz_org_code,
18) AS bizOrgCode,
( (
CASE CASE WHEN LENGTH(a.biz_org_code) > 18
WHEN LENGTH( a.biz_org_code ) > 18 THEN THEN (SELECT cou.biz_org_name FROM cb_org_usr cou WHERE cou.biz_org_code = LEFT(a.biz_org_code, 18) AND cou.biz_org_type = 'COMPANY')
( SELECT cou.biz_org_name FROM cb_org_usr cou WHERE cou.biz_org_code = LEFT ( a.biz_org_code, 18 ) AND ELSE (SELECT cou.biz_org_name FROM cb_org_usr cou WHERE cou.biz_org_code = LEFT(a.biz_org_code, 6) AND cou.biz_org_type = 'COMPANY')
cou.biz_org_type = 'COMPANY' ) ELSE ( SELECT cou.biz_org_name FROM cb_org_usr cou WHERE cou.biz_org_code = LEFT
( a.biz_org_code, 6 ) AND cou.biz_org_type = 'COMPANY' )
END END
) AS bizOrgName, ) AS bizOrgName,
SUM(
IF
( a.peopleType = '1601', 1, 0 )) AS fireNum,
SUM(
IF
( a.peopleType = '1602', 1, 0 )) AS ywNum,
ibsi.station_type AS stationType, ibsi.station_type AS stationType,
SUM(IF(a.peopleType = '1601', 1, 0)) AS fireNum,
SUM(IF(a.peopleType = '1602', 1, 0)) AS ywNum,
SUM( SUM(
IF IF(a.peopleType = '1601' AND (
CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE('1823,1824,1825,1826,1827', ',', ',|'), ',') > 0
OR CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE('1421,1422,1423,1424,1425', ',', ',|'), ',') > 0
OR CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE('1426,1427,1428,1429,1430,1431', ',', ',|'), ',') > 0
),1,0)
) AS fireIsOk,
( (
a.peopleType = '1601' SUM(IF(a.peopleType = '1601', 1, 0)) -
AND (
concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1823,1824,1825,1826,1827', ',', ',|' ), ',') > 0
OR concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1421,1422,1423,1424,1425', ',', ',|' ), ',' ) > 0
OR concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1426,1427,1428,1429,1430,1431', ',', ',|' ), ',' ) > 0
),
1,
0
)) AS fireIsOk,
(
SUM(
IF
( a.peopleType = '1601', 1, 0 )) - SUM(
IF
(
a.peopleType = '1601'
AND (
concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1823,1824,1825,1826,1827', ',', ',|' ), ',') > 0
OR concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1421,1422,1423,1424,1425', ',', ',|' ), ',' ) > 0
OR concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1426,1427,1428,1429,1430,1431', ',', ',|' ), ',' ) > 0
),
1,
0
))
) AS fireNoCard,
SUM( SUM(
IF IF(a.peopleType = '1601' AND (
(( CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE('1823,1824,1825,1826,1827', ',', ',|'), ',') > 0
a.peopleType = '1602' OR CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE('1421,1422,1423,1424,1425', ',', ',|'), ',' ) > 0
AND ( OR CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE('1426,1427,1428,1429,1430,1431', ',', ',|'), ',' ) > 0
SELECT ), 1, 0)
concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1427,1428,1429,1430,1431', ',', ',|' ), ','
)) = 0
OR (
SELECT
concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1427,1428,1429,1430,1431', ',', ',|' ), ','
) IS NULL
AND a.peopleType = '1602'
) )
), ) AS fireNoCard,
1,
0
)) AS ywNotOk,
SUM( SUM(
IF IF((a.peopleType = '1602' AND (SELECT CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE('1427,1428,1429,1430,1431', ',', ',|'), ',')) > 0), 1, 0)
(( ) AS ywIsOk,
a.peopleType = '1602' (
AND concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1427', ',', ',|' ), ',' ) > 0 SUM(IF(a.peopleType = '1602', 1, 0)) -
),
1,
0
)) AS ywCJ,
SUM( SUM(
IF IF((a.peopleType = '1602' AND (SELECT CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE ('1427,1428,1429,1430,1431', ',', ',|'), ',')) > 0), 1, 0)
(( )
a.peopleType = '1602' ) AS ywNoCard
AND (
SELECT
concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1428', ',', ',|' ), ',' )) > 0
),
1,
0
)) AS ywZJ
FROM FROM
( (
SELECT SELECT
...@@ -1852,7 +1804,7 @@ ...@@ -1852,7 +1804,7 @@
ou.biz_org_type, ou.biz_org_type,
ou.biz_org_name, ou.biz_org_name,
ou.biz_org_code, ou.biz_org_code,
IFNULL( MAX( CASE WHEN cfi.field_code = 'peopleType' THEN field_value END ), '' ) AS peopleType, IFNULL(MAX(CASE WHEN cfi.field_code = 'peopleType' THEN field_value END ), '') AS peopleType,
ou.is_delete ou.is_delete
FROM FROM
cb_org_usr ou cb_org_usr ou
...@@ -1863,10 +1815,10 @@ ...@@ -1863,10 +1815,10 @@
ou.sequence_nbr ou.sequence_nbr
) c ) c
WHERE WHERE
c.peopleType IN ( '1601', '1602' ) c.peopleType IN ('1601', '1602')
) a ) a
LEFT JOIN cb_firefighters_post fp ON a.sequence_nbr = fp.org_usr_id LEFT JOIN cb_firefighters_post fp ON a.sequence_nbr = fp.org_usr_id
LEFT JOIN idx_biz_station_info ibsi ON LEFT ( a.biz_org_code, 18 ) = ibsi.biz_org_code LEFT JOIN idx_biz_station_info ibsi ON LEFT (a.biz_org_code, 18) = ibsi.biz_org_code
WHERE WHERE
a.biz_org_name IS NOT NULL a.biz_org_name IS NOT NULL
AND a.is_delete = 0 AND a.is_delete = 0
...@@ -1874,14 +1826,12 @@ ...@@ -1874,14 +1826,12 @@
AND fp.is_delete = 0 AND fp.is_delete = 0
AND LENGTH( a.biz_org_code ) > 18 AND LENGTH( a.biz_org_code ) > 18
<if test='bizOrgCode!=null and bizOrgCode!=""'> <if test='bizOrgCode!=null and bizOrgCode!=""'>
and LEFT(a.biz_org_code,18) like concat (#{bizOrgCode},'%') AND LEFT(a.biz_org_code,18) LIKE CONCAT(#{bizOrgCode},'%')
</if> </if>
<if test='stationType != null and stationType != ""'> <if test='stationType != null and stationType != ""'>
and ibsi.station_type like concat ('%', #{stationType},'%') AND ibsi.station_type LIKE CONCAT('%', #{stationType},'%')
</if> </if>
GROUP BY GROUP BY
LEFT ( LEFT(a.biz_org_code, 18)
a.biz_org_code,
18)
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment