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

人员统计优化

parent eaef1c40
......@@ -1757,131 +1757,81 @@
<select id="getCenterPersonInfoPage" resultType="Map">
SELECT
LEFT (
a.biz_org_code,
18) AS bizOrgCode,
(
CASE
WHEN LENGTH( a.biz_org_code ) > 18 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' ) 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
) 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,
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 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(
IF
((
a.peopleType = '1602'
AND (
SELECT
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'
)
),
1,
0
)) AS ywNotOk,
SUM(
IF
((
a.peopleType = '1602'
AND concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1427', ',', ',|' ), ',' ) > 0
),
1,
0
)) AS ywCJ,
SUM(
IF
((
a.peopleType = '1602'
AND (
SELECT
concat( fp.post_qualification_code, ',' ) REGEXP concat( REPLACE ( '1428', ',', ',|' ), ',' )) > 0
),
1,
0
)) AS ywZJ
FROM
(
SELECT
*
LEFT(a.biz_org_code,18) AS bizOrgCode,
(
CASE WHEN LENGTH(a.biz_org_code) > 18
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')
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
) AS bizOrgName,
ibsi.station_type AS stationType,
SUM(IF(a.peopleType = '1601', 1, 0)) AS fireNum,
SUM(IF(a.peopleType = '1602', 1, 0)) AS ywNum,
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 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(
IF((a.peopleType = '1602' AND (SELECT CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE('1427,1428,1429,1430,1431', ',', ',|'), ',')) > 0), 1, 0)
) AS ywIsOk,
(
SUM(IF(a.peopleType = '1602', 1, 0)) -
SUM(
IF((a.peopleType = '1602' AND (SELECT CONCAT(fp.post_qualification_code, ',') REGEXP CONCAT(REPLACE ('1427,1428,1429,1430,1431', ',', ',|'), ',')) > 0), 1, 0)
)
) AS ywNoCard
FROM
(
SELECT
ou.sequence_nbr,
ou.biz_org_type,
ou.biz_org_name,
ou.biz_org_code,
IFNULL( MAX( CASE WHEN cfi.field_code = 'peopleType' THEN field_value END ), '' ) AS peopleType,
ou.is_delete
FROM
cb_org_usr ou
LEFT JOIN cb_dynamic_form_instance cfi ON ou.sequence_nbr = cfi.instance_id
WHERE
ou.is_delete = '0'
GROUP BY
ou.sequence_nbr
) c
WHERE
c.peopleType IN ( '1601', '1602' )
SELECT
*
FROM
(
SELECT
ou.sequence_nbr,
ou.biz_org_type,
ou.biz_org_name,
ou.biz_org_code,
IFNULL(MAX(CASE WHEN cfi.field_code = 'peopleType' THEN field_value END ), '') AS peopleType,
ou.is_delete
FROM
cb_org_usr ou
LEFT JOIN cb_dynamic_form_instance cfi ON ou.sequence_nbr = cfi.instance_id
WHERE
ou.is_delete = '0'
GROUP BY
ou.sequence_nbr
) c
WHERE
c.peopleType IN ('1601', '1602')
) a
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 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
WHERE
a.biz_org_name IS NOT NULL
AND a.is_delete = 0
AND a.biz_org_type = 'PERSON'
AND fp.is_delete = 0
AND LENGTH( a.biz_org_code ) > 18
<if test='bizOrgCode!=null and bizOrgCode!=""'>
and LEFT(a.biz_org_code,18) like concat (#{bizOrgCode},'%')
</if>
<if test='stationType != null and stationType != ""'>
and ibsi.station_type like concat ('%', #{stationType},'%')
</if>
a.biz_org_name IS NOT NULL
AND a.is_delete = 0
AND a.biz_org_type = 'PERSON'
AND fp.is_delete = 0
AND LENGTH( a.biz_org_code ) > 18
<if test='bizOrgCode!=null and bizOrgCode!=""'>
AND LEFT(a.biz_org_code,18) LIKE CONCAT(#{bizOrgCode},'%')
</if>
<if test='stationType != null and stationType != ""'>
AND ibsi.station_type LIKE CONCAT('%', #{stationType},'%')
</if>
GROUP BY
LEFT (
a.biz_org_code,
18)
LEFT(a.biz_org_code, 18)
</select>
</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