550 lines
26 KiB
XML
550 lines
26 KiB
XML
<?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.bonus.gzrn.rnbmw.certificate.dao.CertificateStatisticsDao">
|
||
<select id="getListCount" resultType="java.lang.Integer">
|
||
select count(1)
|
||
from (
|
||
SELECT
|
||
bw.name AS username,
|
||
bcr.id_number AS idNumber,
|
||
td.`name` AS postName,
|
||
bct.work_type AS workType,
|
||
bct.work_operation AS workOperation,
|
||
bcr.reality_review_date AS reviewDate,
|
||
bcr.valid_start_date AS validStartDate,
|
||
bcr.valid_end_date AS validEndDate,
|
||
bcr.issuing_authority AS issuingAuthority,
|
||
bcr.certificate_photo AS certificatePhoto,
|
||
CONCAT( bcr.valid_start_date, '~', bcr.valid_end_date ) AS validityData,
|
||
if((bcr.valid_start_date < CURRENT_DATE AND bcr.valid_end_date > CURRENT_DATE), '有效', '失效') AS
|
||
certificateStatus,
|
||
bw.PHONE,
|
||
bweh.EIN_TIME as einTime,
|
||
bweh.EXIT_TIME as exitTime
|
||
FROM
|
||
bm_certificate_type_auto bct
|
||
LEFT JOIN (
|
||
SELECT * FROM (
|
||
SELECT * FROM bm_certificate_read ORDER BY valid_end_date DESC limit 999999999
|
||
) a GROUP BY a.id_number, a.certificate_id
|
||
) bcr ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
LEFT JOIN bm_worker bw ON bw.id_number = bweh.id_number AND bw.is_active = '1'
|
||
LEFT JOIN sys_dic_detail td ON td.id = bweh.post_id AND td.is_active = '1'
|
||
LEFT JOIN bm_project bp ON bp.id = bweh.project_id
|
||
left JOIN pm_company po ON po.id = bp.company_id
|
||
WHERE bct.is_hidden = '0'
|
||
AND bct.is_active = '1'
|
||
AND bcr.ID_NUMBER is not null
|
||
<if test="params.onState == 1 or params.onState == '1'">
|
||
AND bweh.EXIT_TIME is null
|
||
</if>
|
||
|
||
<if test="params.onState == 2 or params.onState == '2'">
|
||
AND bweh.EXIT_TIME is not null
|
||
</if>
|
||
|
||
<if test="params.neatenWorkOperation != '' and params.neatenWorkOperation != null">
|
||
AND bct.neaten_work_operation = #{params.neatenWorkOperation}
|
||
</if>
|
||
<if test="params.name != '' and params.name != null and params.name != 'null' ">
|
||
AND (bct.work_type = #{params.name} OR bct.neaten_work_operation = #{params.name})
|
||
</if>
|
||
<if test="params.subComId != '' and params.subComId != null">
|
||
AND po.`id` = #{params.subComId}
|
||
</if>
|
||
<if test="params.proId != '' and params.proId != null">
|
||
AND bp.`id` = #{params.proId}
|
||
</if>
|
||
<if test="params.keyword != '' and params.keyword != null">
|
||
AND (bcr.id_number like concat('%',#{params.keyword},'%') OR bw.`name` like
|
||
concat('%',#{params.keyword},'%'))
|
||
</if>
|
||
<if test="params.postId != '' and params.postId != null">
|
||
AND bweh.post_id like concat('%',#{params.postId},'%')
|
||
</if>
|
||
<if test="params.certificatesState == 1 or params.certificatesState == '1'">
|
||
AND (bcr.valid_start_date < CURRENT_DATE AND bcr.valid_end_date > CURRENT_DATE)
|
||
</if>
|
||
<if test="params.certificatesState == 2 or params.certificatesState == '2'">
|
||
AND (bcr.valid_start_date > CURRENT_DATE OR bcr.valid_end_date < CURRENT_DATE)
|
||
</if>
|
||
<if test="params.certificatesState == 3 or params.certificatesState == '3'">
|
||
AND (DATEDIFF(bcr.reality_review_date, CURRENT_DATE) > 0 AND DATEDIFF(bcr.reality_review_date, CURRENT_DATE) <= 90)
|
||
</if>
|
||
<if test="params.certificatesState == 4 or params.certificatesState == '4'">
|
||
AND (DATEDIFF(bcr.reality_review_date, CURRENT_DATE) > 0 AND DATEDIFF(bcr.reality_review_date, CURRENT_DATE) <= 30)
|
||
</if>
|
||
GROUP BY bcr.id_number,bct.neaten_work_operation
|
||
) a
|
||
</select>
|
||
|
||
<select id="getList" resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT
|
||
bw.name AS username,
|
||
bcr.id_number AS idNumber,
|
||
td.`name` AS postName,
|
||
bct.work_type AS workType,
|
||
bct.work_operation AS workOperation,
|
||
bcr.reality_review_date AS reviewDate,
|
||
bcr.valid_start_date AS validStartDate,
|
||
bcr.valid_end_date AS validEndDate,
|
||
bcr.issuing_authority AS issuingAuthority,
|
||
bcr.certificate_photo AS certificatePhoto,
|
||
CONCAT( bcr.valid_start_date, '~', bcr.valid_end_date ) AS validityData,
|
||
if((bcr.valid_start_date < CURRENT_DATE AND bcr.valid_end_date > CURRENT_DATE), '有效', '失效') AS
|
||
certificateStatus,
|
||
bw.PHONE,
|
||
bweh.EIN_TIME as einTime,
|
||
bweh.EXIT_TIME as exitTime
|
||
FROM
|
||
bm_certificate_type_auto bct
|
||
LEFT JOIN (
|
||
SELECT * FROM (
|
||
SELECT * FROM bm_certificate_read ORDER BY valid_end_date DESC limit 999999999
|
||
) a GROUP BY a.id_number, a.certificate_id
|
||
) bcr ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
LEFT JOIN bm_worker bw ON bw.id_number = bweh.id_number AND bw.is_active = '1'
|
||
LEFT JOIN sys_dic_detail td ON td.id = bweh.post_id AND td.is_active = '1'
|
||
LEFT JOIN bm_project bp ON bp.id = bweh.project_id
|
||
left JOIN pm_company po ON po.id = bp.company_id
|
||
WHERE bct.is_hidden = '0'
|
||
AND bct.is_active = '1'
|
||
AND bcr.ID_NUMBER is not null
|
||
<if test="params.onState == 1 or params.onState == '1'">
|
||
AND bweh.EXIT_TIME is null
|
||
</if>
|
||
|
||
<if test="params.onState == 2 or params.onState == '2'">
|
||
AND bweh.EXIT_TIME is not null
|
||
</if>
|
||
|
||
<if test="params.neatenWorkOperation != '' and params.neatenWorkOperation != null">
|
||
AND bct.neaten_work_operation = #{params.neatenWorkOperation}
|
||
</if>
|
||
<if test="params.name != '' and params.name != null and params.name != 'null' ">
|
||
AND (bct.work_type = #{params.name} OR bct.neaten_work_operation = #{params.name})
|
||
</if>
|
||
<if test="params.subComId != '' and params.subComId != null">
|
||
AND po.`id` = #{params.subComId}
|
||
</if>
|
||
<if test="params.proId != '' and params.proId != null">
|
||
AND bp.`id` = #{params.proId}
|
||
</if>
|
||
<if test="params.keyword != '' and params.keyword != null">
|
||
AND (bcr.id_number like concat('%',#{params.keyword},'%') OR bw.`name` like
|
||
concat('%',#{params.keyword},'%'))
|
||
</if>
|
||
<if test="params.postId != '' and params.postId != null">
|
||
AND bweh.post_id like concat('%',#{params.postId},'%')
|
||
</if>
|
||
<if test="params.certificatesState == 1 or params.certificatesState == '1'">
|
||
AND (bcr.valid_start_date < CURRENT_DATE AND bcr.valid_end_date > CURRENT_DATE)
|
||
</if>
|
||
<if test="params.certificatesState == 2 or params.certificatesState == '2'">
|
||
AND (bcr.valid_start_date > CURRENT_DATE OR bcr.valid_end_date < CURRENT_DATE)
|
||
</if>
|
||
<if test="params.certificatesState == 3 or params.certificatesState == '3'">
|
||
AND (DATEDIFF(bcr.reality_review_date, CURRENT_DATE) > 0 AND DATEDIFF(bcr.reality_review_date, CURRENT_DATE) <= 90)
|
||
</if>
|
||
<if test="params.certificatesState == 4 or params.certificatesState == '4'">
|
||
AND (DATEDIFF(bcr.reality_review_date, CURRENT_DATE) > 0 AND DATEDIFF(bcr.reality_review_date, CURRENT_DATE) <= 30)
|
||
</if>
|
||
GROUP BY bcr.id_number,bct.neaten_work_operation
|
||
limit #{offset}
|
||
, #{limit}
|
||
</select>
|
||
|
||
<select id="getTreeDataTypeOne"
|
||
resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT
|
||
id,
|
||
`name`,
|
||
sum( title ) AS total,
|
||
CONCAT( `name`, '(', sum( title ), ')' ) AS title
|
||
FROM
|
||
(
|
||
SELECT
|
||
bct.id AS id,
|
||
bct.work_type AS NAME,
|
||
COUNT( DISTINCT bweh.id_number ) AS title
|
||
FROM
|
||
bm_certificate_type_auto bct
|
||
LEFT JOIN (
|
||
SELECT * FROM (
|
||
SELECT * FROM bm_certificate_read ORDER BY valid_end_date DESC limit 999999999
|
||
) a GROUP BY a.id_number, a.certificate_id
|
||
) bcr ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
WHERE bct.is_hidden = '0' AND bct.is_active = '1'
|
||
<if test="name != '' and name != null">
|
||
AND (bct.work_type like concat('%',#{name},'%') OR bct.neaten_work_operation like concat('%',#{name},'%'))
|
||
</if>
|
||
GROUP BY bct.work_type,
|
||
bct.neaten_work_operation
|
||
) a
|
||
GROUP BY name
|
||
</select>
|
||
<select id="getTreeDataTypeTwo"
|
||
resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT
|
||
bct.id AS id,
|
||
bct.work_type AS name,
|
||
bct.neaten_work_operation AS neatenWorkOperation,
|
||
CONCAT(bct.neaten_work_operation,'(',COUNT(DISTINCT bweh.id_number), ')') AS title
|
||
FROM
|
||
bm_certificate_type_auto bct
|
||
LEFT JOIN (
|
||
SELECT * FROM (
|
||
SELECT * FROM bm_certificate_read ORDER BY valid_end_date DESC limit 999999999
|
||
) a GROUP BY a.id_number, a.certificate_id
|
||
) bcr ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
WHERE bct.is_hidden = '0' AND bct.is_active = '1'
|
||
<if test="name != '' and name != null">
|
||
AND (bct.work_type like concat('%',#{name},'%') OR bct.neaten_work_operation like concat('%',#{name},'%'))
|
||
</if>
|
||
GROUP BY bct.`neaten_work_operation`
|
||
</select>
|
||
<select id="getTreeDataProOne"
|
||
resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT
|
||
po.id AS id,
|
||
po.org_name as name,
|
||
COUNT( bweh.id_number) AS total,
|
||
CONCAT(po.org_name,'(',COUNT( bweh.id_number), ')') AS title,
|
||
'2' AS nodeType
|
||
FROM
|
||
pm_company po
|
||
LEFT JOIN bm_project bp ON bp.company_id = po.id and bp.is_active = '1'
|
||
LEFT JOIN (
|
||
SELECT bweh.project_id,bweh.id_number,
|
||
bct.work_type,
|
||
bct.`neaten_work_operation`,
|
||
bct.is_hidden,
|
||
bct.is_active
|
||
FROM
|
||
bm_worker_attend_history bweh
|
||
INNER JOIN (
|
||
SELECT * FROM (
|
||
SELECT * FROM bm_certificate_read ORDER BY valid_end_date DESC limit 999999999
|
||
) a GROUP BY a.id_number, a.certificate_id
|
||
) bcr ON bweh.id_number = bcr.id_number
|
||
inner JOIN bm_certificate_type_auto bct ON bcr.certificate_id = bct.id and bct.is_hidden = '0' AND bct.is_active =
|
||
'1'
|
||
where bweh.is_active = '1'
|
||
GROUP BY bcr.id_number,bct.`neaten_work_operation`
|
||
)bweh ON bp.id = bweh.project_id
|
||
WHERE
|
||
po.is_active = '1'
|
||
<if test="name != '' and name != null">
|
||
AND (po.`org_name` like concat('%',#{name},'%') OR bp.`name` like concat('%',#{name},'%'))
|
||
</if>
|
||
GROUP BY po.id
|
||
</select>
|
||
<select id="getTreeDataProTwo"
|
||
resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT
|
||
bp.id AS id,
|
||
bp.`name` AS name,
|
||
po.id AS pid,
|
||
CONCAT( bp.`name`, '(', COUNT( bweh.id_number ), ')' ) AS title,
|
||
'3' AS nodeType
|
||
FROM
|
||
pm_company po
|
||
LEFT JOIN bm_project bp ON bp.company_id = po.id
|
||
AND bp.is_active = '1'
|
||
LEFT JOIN (
|
||
SELECT
|
||
bweh.project_id,
|
||
bweh.id_number,
|
||
bct.work_type,
|
||
bct.`neaten_work_operation`
|
||
FROM
|
||
bm_worker_attend_history bweh
|
||
INNER JOIN (
|
||
SELECT * FROM (
|
||
SELECT * FROM bm_certificate_read ORDER BY valid_end_date DESC limit 999999999
|
||
) a GROUP BY a.id_number, a.certificate_id
|
||
) bcr ON bweh.id_number = bcr.id_number
|
||
INNER JOIN bm_certificate_type_auto bct ON bcr.certificate_id = bct.id
|
||
AND bct.is_hidden = '0'
|
||
AND bct.is_active = '1'
|
||
WHERE
|
||
bweh.is_active = '1'
|
||
GROUP BY bcr.id_number,bct.`neaten_work_operation`
|
||
) bweh ON bp.id = bweh.project_id
|
||
WHERE po.is_active = '1'
|
||
AND bp.id IS NOT NULL
|
||
AND bp.is_active = '1'
|
||
<if test="name != '' and name != null">
|
||
AND (po.`org_name` like concat('%',#{name},'%') OR bp.`name` like concat('%',#{name},'%'))
|
||
</if>
|
||
GROUP BY
|
||
bp.id
|
||
</select>
|
||
|
||
<select id="getPost" resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT id AS id,
|
||
name
|
||
FROM sys_dic_detail
|
||
WHERE dic_type = '3'
|
||
AND is_active = '1'
|
||
</select>
|
||
|
||
<select id="getListWarning" resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT
|
||
*
|
||
FROM(
|
||
SELECT
|
||
bw.name AS username,
|
||
bcr.id_number AS idNumber,
|
||
td.`name` AS postName,
|
||
bct.work_type AS workType,
|
||
bct.work_operation AS workOperation,
|
||
bcr.reality_review_date AS reviewDate,
|
||
bcr.valid_start_date AS validStartDate,
|
||
bcr.valid_end_date AS validEndDate,
|
||
bcr.issuing_authority AS issuingAuthority,
|
||
bcr.certificate_photo AS certificatePhoto,
|
||
CONCAT( bcr.valid_start_date, '~', bcr.valid_end_date ) AS validityData,
|
||
if((bcr.valid_start_date < CURRENT_DATE AND bcr.valid_end_date > CURRENT_DATE), '有效', '失效') AS
|
||
certificateStatus,
|
||
bw.PHONE,
|
||
bweh.EIN_TIME as einTime,
|
||
bweh.EXIT_TIME as exitTime,
|
||
CASE
|
||
WHEN STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') < CURDATE() THEN '已过期'
|
||
WHEN STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND
|
||
LAST_DAY(CURDATE()) THEN '当月过期'
|
||
WHEN STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') > CURDATE()
|
||
AND STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') <= DATE_ADD(CURDATE(), INTERVAL 3 MONTH) THEN '即将过期'
|
||
ELSE '正常'
|
||
END AS riskWarning
|
||
FROM
|
||
bm_certificate_type_auto bct
|
||
LEFT JOIN (
|
||
SELECT * FROM (
|
||
SELECT * FROM bm_certificate_read ORDER BY valid_end_date DESC limit 999999999
|
||
) a GROUP BY a.id_number, a.certificate_id
|
||
) bcr ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
LEFT JOIN bm_worker bw ON bw.id_number = bweh.id_number AND bw.is_active = '1'
|
||
LEFT JOIN sys_dic_detail td ON td.id = bweh.post_id AND td.is_active = '1'
|
||
LEFT JOIN bm_project bp ON bp.id = bweh.project_id
|
||
left JOIN pm_company po ON po.id = bp.company_id
|
||
WHERE bct.is_hidden = '0'
|
||
AND bct.is_active = '1'
|
||
AND SUBSTRING(bcr.valid_end_date, 1, 7) BETWEEN #{params.startTime} AND #{params.endTime}
|
||
<if test="params.onState == 1 or params.onState == '1'">
|
||
AND bweh.EXIT_TIME is null
|
||
</if>
|
||
|
||
<if test="params.onState == 2 or params.onState == '2'">
|
||
AND bweh.EXIT_TIME is not null
|
||
</if>
|
||
GROUP BY bcr.id_number,bct.neaten_work_operation
|
||
) aa
|
||
<where>
|
||
<if test="params.riskWarning != '' and params.riskWarning != null">
|
||
AND riskWarning = #{params.riskWarning}
|
||
</if>
|
||
</where>
|
||
limit #{offset}
|
||
, #{limit}
|
||
</select>
|
||
|
||
<select id="getListWarningCount" resultType="java.lang.Integer">
|
||
select count(*) from (
|
||
SELECT
|
||
*
|
||
FROM(
|
||
SELECT
|
||
bw.name AS username,
|
||
bcr.id_number AS idNumber,
|
||
td.`name` AS postName,
|
||
bct.work_type AS workType,
|
||
bct.work_operation AS workOperation,
|
||
bcr.reality_review_date AS reviewDate,
|
||
bcr.valid_start_date AS validStartDate,
|
||
bcr.valid_end_date AS validEndDate,
|
||
bcr.issuing_authority AS issuingAuthority,
|
||
bcr.certificate_photo AS certificatePhoto,
|
||
CONCAT( bcr.valid_start_date, '~', bcr.valid_end_date ) AS validityData,
|
||
if((bcr.valid_start_date < CURRENT_DATE AND bcr.valid_end_date > CURRENT_DATE), '有效', '失效') AS
|
||
certificateStatus,
|
||
bw.PHONE,
|
||
bweh.EIN_TIME as einTime,
|
||
bweh.EXIT_TIME as exitTime,
|
||
CASE
|
||
WHEN STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') < CURDATE() THEN '已过期'
|
||
WHEN STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND
|
||
LAST_DAY(CURDATE()) THEN '当月过期'
|
||
WHEN STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') > CURDATE()
|
||
AND STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') <= DATE_ADD(CURDATE(), INTERVAL 3 MONTH) THEN '即将过期'
|
||
ELSE '正常'
|
||
END AS riskWarning
|
||
FROM
|
||
bm_certificate_type_auto bct
|
||
LEFT JOIN (
|
||
SELECT * FROM (
|
||
SELECT * FROM bm_certificate_read ORDER BY valid_end_date DESC limit 999999999
|
||
) a GROUP BY a.id_number, a.certificate_id
|
||
) bcr ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
LEFT JOIN bm_worker bw ON bw.id_number = bweh.id_number AND bw.is_active = '1'
|
||
LEFT JOIN sys_dic_detail td ON td.id = bweh.post_id AND td.is_active = '1'
|
||
LEFT JOIN bm_project bp ON bp.id = bweh.project_id
|
||
left JOIN pm_company po ON po.id = bp.company_id
|
||
WHERE bct.is_hidden = '0'
|
||
AND bct.is_active = '1'
|
||
AND SUBSTRING(bcr.valid_end_date, 1, 7) BETWEEN #{params.startTime} AND #{params.endTime}
|
||
<if test="params.onState == 1 or params.onState == '1'">
|
||
AND bweh.EXIT_TIME is null
|
||
</if>
|
||
|
||
<if test="params.onState == 2 or params.onState == '2'">
|
||
AND bweh.EXIT_TIME is not null
|
||
</if>
|
||
GROUP BY bcr.id_number,bct.neaten_work_operation
|
||
) aa
|
||
<where>
|
||
<if test="params.riskWarning != '' and params.riskWarning != null">
|
||
AND riskWarning = #{params.riskWarning}
|
||
</if>
|
||
</where>
|
||
) a
|
||
</select>
|
||
|
||
<select id="getCategoryChart" resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT id,
|
||
`name`,
|
||
sum(title) AS total,
|
||
CONCAT(`name`, '(', sum(title), ')') AS title
|
||
FROM (SELECT bct.id AS id,
|
||
bct.work_type AS NAME,
|
||
COUNT(DISTINCT bweh.id_number) AS title
|
||
FROM bm_certificate_type_auto bct
|
||
LEFT JOIN (SELECT *
|
||
FROM (SELECT *
|
||
FROM bm_certificate_read
|
||
ORDER BY valid_end_date DESC limit 999999999) a
|
||
GROUP BY a.id_number, a.certificate_id) bcr ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh
|
||
ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
WHERE bct.is_hidden = '0'
|
||
AND bct.is_active = '1'
|
||
|
||
GROUP BY bct.work_type,
|
||
bct.neaten_work_operation) a
|
||
GROUP BY name
|
||
ORDER BY total DESC LIMIT 0 , 3
|
||
</select>
|
||
<select id="getStatusChart" resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT (SELECT COALESCE(SUM(total), 0)
|
||
FROM (SELECT id,
|
||
`name`,
|
||
SUM(title) AS total,
|
||
CONCAT(`name`, '(', SUM(title), ')') AS title
|
||
FROM (SELECT bct.id AS id,
|
||
bct.work_type AS NAME,
|
||
COUNT(DISTINCT bweh.id_number) AS title
|
||
FROM bm_certificate_type_auto bct
|
||
LEFT JOIN (SELECT *
|
||
FROM (SELECT *
|
||
FROM bm_certificate_read bcr
|
||
WHERE STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') > CURDATE()
|
||
AND STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') <=
|
||
DATE_ADD(CURDATE(), INTERVAL 3 MONTH)
|
||
ORDER BY valid_end_date DESC LIMIT 999999999) a
|
||
GROUP BY a.id_number, a.certificate_id) bcr
|
||
ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh
|
||
ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
WHERE bct.is_hidden = '0'
|
||
AND bct.is_active = '1'
|
||
GROUP BY bct.work_type, bct.neaten_work_operation) a
|
||
GROUP BY `name`) aa) AS effective,
|
||
|
||
(SELECT COALESCE(SUM(total), 0)
|
||
FROM (SELECT id,
|
||
`name`,
|
||
SUM(title) AS total,
|
||
CONCAT(`name`, '(', SUM(title), ')') AS title
|
||
FROM (SELECT bct.id AS id,
|
||
bct.work_type AS NAME,
|
||
COUNT(DISTINCT bweh.id_number) AS title
|
||
FROM bm_certificate_type_auto bct
|
||
LEFT JOIN (SELECT *
|
||
FROM (SELECT *
|
||
FROM bm_certificate_read bcr
|
||
WHERE STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') < CURDATE()
|
||
ORDER BY valid_end_date DESC LIMIT 999999999) a
|
||
GROUP BY a.id_number, a.certificate_id) bcr
|
||
ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh
|
||
ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
WHERE bct.is_hidden = '0'
|
||
AND bct.is_active = '1'
|
||
GROUP BY bct.work_type, bct.neaten_work_operation) a
|
||
GROUP BY `name`) bb) AS beOverdue,
|
||
|
||
(SELECT COALESCE(SUM(total), 0)
|
||
FROM (SELECT id,
|
||
`name`,
|
||
SUM(title) AS total,
|
||
CONCAT(`name`, '(', SUM(title), ')') AS title
|
||
FROM (SELECT bct.id AS id,
|
||
bct.work_type AS NAME,
|
||
COUNT(DISTINCT bweh.id_number) AS title
|
||
FROM bm_certificate_type_auto bct
|
||
LEFT JOIN (SELECT *
|
||
FROM (SELECT *
|
||
FROM bm_certificate_read bcr
|
||
WHERE STR_TO_DATE(bcr.valid_end_date, '%Y-%m-%d') > CURDATE()
|
||
ORDER BY valid_end_date DESC LIMIT 999999999) a
|
||
GROUP BY a.id_number, a.certificate_id) bcr
|
||
ON bcr.certificate_id = bct.id
|
||
LEFT JOIN bm_worker_attend_history bweh
|
||
ON bweh.id_number = bcr.id_number AND bweh.is_active = '1'
|
||
WHERE bct.is_hidden = '0'
|
||
AND bct.is_active = '1'
|
||
GROUP BY bct.work_type, bct.neaten_work_operation) a
|
||
GROUP BY `name`) cc) AS expiringSoon
|
||
</select>
|
||
|
||
<select id="getWarning" resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT bw.`NAME` as username,
|
||
bb.`NAME`,
|
||
bb.valid_end_date as validEndDate,
|
||
bw.PHONE
|
||
FROM bm_worker bw
|
||
LEFT JOIN (SELECT *
|
||
FROM bm_certificate_read a
|
||
LEFT JOIN bm_certificate_type_auto b on a.certificate_id = b.id
|
||
WHERE valid_end_date = DATE_ADD(CURDATE(), INTERVAL 3 MONTH )
|
||
OR valid_end_date = DATE_ADD(CURDATE(), INTERVAL 6 MONTH )
|
||
GROUP BY id_number,
|
||
certificate_id) bb ON bw.ID_NUMBER = bb.id_number
|
||
WHERE bb.ID_NUMBER is not null
|
||
</select>
|
||
|
||
<select id="getReexamine" resultType="com.bonus.gzrn.rnbmw.certificate.entity.CertificateStatisticsBean">
|
||
SELECT bw.`NAME` as username,
|
||
bb.`NAME`,
|
||
bb.reality_review_date as reviewDate,
|
||
bw.PHONE
|
||
FROM bm_worker bw
|
||
LEFT JOIN (SELECT *
|
||
FROM bm_certificate_read a
|
||
LEFT JOIN bm_certificate_type_auto b on a.certificate_id = b.id
|
||
WHERE reality_review_date = DATE_ADD(CURDATE(), INTERVAL 3 MONTH )
|
||
OR reality_review_date = DATE_ADD(CURDATE(), INTERVAL 6 MONTH )
|
||
GROUP BY id_number,
|
||
certificate_id) bb ON bw.ID_NUMBER = bb.id_number
|
||
WHERE bb.ID_NUMBER is not null
|
||
</select>
|
||
</mapper> |