hd_real_name/target/classes/mappers/person/CertificateMapper.xml

1142 lines
50 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.person.dao.CertificateDao">
<insert id="addCertificateType">
INSERT INTO `bm_certificate_type` ( NAME, is_upload, remark,certificate_version,review_num,one_review_interval,
two_review_interval,three_review_interval)
VALUES(#{name},#{isUpload},#{remark},#{certificateVersion},#{recheckNum},#{recheckInterval1},#{recheckInterval2},#{recheckInterval3})
</insert>
<insert id="batchInsertPostAndCertificate" parameterType="arraylist">
insert into bm_certificate_post(certificate_id,post_id)
values
<foreach collection="list" item="param" separator=",">
(#{param.certificateId},#{param.postId})
</foreach>
</insert>
<insert id="addWorkerCertificate" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
INSERT INTO `bm_worker_certificate`(`id_number`, `certificate_id`, `start_date`,`stop_date`,
<if test="oneReviewTime != null and oneReviewTime != '' and oneReviewTime != 'null' ">
one_review_time,
</if>
<if test="twoReviewTime != null and twoReviewTime != '' and twoReviewTime != 'null' ">
two_review_time,
</if>
<if test="threeReviewTime != null and threeReviewTime != '' and threeReviewTime != 'null' ">
three_review_time,
</if>
`is_active`)
VALUES ( #{idNumber}, #{certificateId}, #{startDate},#{stopDate},
<if test="oneReviewTime != null and oneReviewTime != '' and oneReviewTime != 'null' ">
#{oneReviewTime},
</if>
<if test="twoReviewTime != null and twoReviewTime != '' and twoReviewTime != 'null' ">
#{twoReviewTime},
</if>
<if test="threeReviewTime != null and threeReviewTime != '' and threeReviewTime != 'null' ">
#{threeReviewTime},
</if>
'1');
</insert>
<insert id="addTeamCertificate">
INSERT INTO bm_certificate_team_type(team_type_id, certificate_id, certificate_num)
VALUES ( #{teamTypeId},#{certificateId},#{certificateNum})
</insert>
<update id="updateCertificateType">
UPDATE `bm_certificate_type`
SET NAME = #{name},
is_upload = #{isUpload},
remark = #{remark},
certificate_version = #{certificateVersion},review_num = #{recheckNum},one_review_interval = #{recheckInterval1},
two_review_interval = #{recheckInterval2},three_review_interval = #{recheckInterval3}
WHERE
id = #{id}
</update>
<update id="saveCertificateUploadFile">
update `bm_worker_certificate` set
<if test="uploadType == 1">
certificate_file = #{certificateFile}
</if>
<if test="uploadType == 2">
certificate_type_file = #{certificateFile}
</if>
<if test="uploadType == 3">
one_review_upload_time = #{times},
one_review_user_id = #{userId},
one_review_file = #{certificateFile}
</if>
<if test="uploadType == 4">
two_review_upload_time = #{times},
two_review_user_id = #{userId},
two_review_file = #{certificateFile}
</if>
<if test="uploadType == 5">
three_review_upload_time = #{times},
three_review_user_id = #{userId},
three_review_file = #{certificateFile}
</if>
where `id` = #{id} and `is_active` = '1'
</update>
<update id="updateWorkerCertificate">
update `bm_worker_certificate` set
`certificate_id` = #{certificateId},
`start_date` = #{startDate},
`stop_date` = #{stopDate}
<if test="oneReviewTime != null and oneReviewTime != '' and oneReviewTime != 'null' ">
,one_review_time = #{oneReviewTime}
</if>
<if test="twoReviewTime != null and twoReviewTime != '' and twoReviewTime != 'null' ">
,two_review_time = #{twoReviewTime}
</if>
<if test="threeReviewTime != null and threeReviewTime != '' and threeReviewTime != 'null' ">
,three_review_time = #{threeReviewTime}
</if>
WHERE `id` = #{id} and `is_active` = '1'
</update>
<update id="checkCertificateStatus">
update bm_worker_certificate bwc set
<if test="params.statusType == 0">
bwc.status = #{params.status},
bwc.remark = #{params.remark}
</if>
<if test="params.statusType == 1">
bwc.one_review_status = #{params.status},
bwc.one_review_remark = #{params.remark}
</if>
<if test="params.statusType == 2">
bwc.two_review_status = #{params.status},
bwc.two_review_remark = #{params.remark}
</if>
where bwc.id = #{params.id}
</update>
<update id="updIsFreezeTypeById">
UPDATE bm_worker_certificate bwc SET bwc.is_freeze = '0'
WHERE bwc.id_number = #{idNumber}
</update>
<update id="updFreezeTypeById">
UPDATE bm_worker_certificate bwc SET bwc.is_freeze = '1'
WHERE bwc.id_number = #{idNumber}
</update>
<update id="updTeamCertificateNum">
UPDATE bm_certificate_team_type
SET certificate_num = #{certificateNum}
WHERE id = #{id}
</update>
<delete id="delCertificateTypeById">
UPDATE `bm_certificate_type` SET
is_active = '0'
WHERE
id = #{id}
</delete>
<delete id="deleteBeforeBindingMsg">
delete from bm_certificate_post where post_id = #{postId}
</delete>
<delete id="delSingleWorkCertificate">
UPDATE `bm_worker_certificate` SET
is_active = '0'
WHERE
id = #{id}
</delete>
<delete id="delTeamCertificateNum">
DELETE
FROM bm_certificate_team_type
WHERE id = #{id}
</delete>
<select id="getCertificateTypeListCount" resultType="java.lang.Integer">
SELECT
count(1)
FROM
`bm_certificate_type`
WHERE is_active = '1'
<if test="params != null and params !=''">
<if test="params.keyWord != null and params.keyWord !=''">
and instr(name,#{params.keyWord}) &gt; 0
</if>
</if>
</select>
<select id="getCertificateTypeList" resultType="com.bonus.gzrn.rnbmw.person.entity.CertificateTypeBean">
SELECT
id,
NAME,
is_upload AS isUpload,
remark,
upload_time AS uploadTime,
update_time AS updateTime,
certificate_version as certificateVersion,
review_num as recheckNum,
one_review_interval as recheckInterval1,
two_review_interval as recheckInterval2,
three_review_interval as recheckInterval3
FROM
`bm_certificate_type`
WHERE is_active = '1'
<if test="params != null and params !=''">
<if test="params.keyWord != null and params.keyWord !=''">
and instr(name,#{params.keyWord}) &gt; 0
</if>
</if>
limit #{offset}, #{limit}
</select>
<select id="getCertificateTypeById" resultType="com.bonus.gzrn.rnbmw.person.entity.CertificateTypeBean">
SELECT
id,
NAME,
is_upload AS isUpload,
remark,
upload_time AS uploadTime,
update_time AS updateTime,
certificate_version as certificateVersion,
review_num as recheckNum,
one_review_interval as recheckInterval1,
two_review_interval as recheckInterval2,
three_review_interval as recheckInterval3
FROM
`bm_certificate_type`
WHERE id = #{id} and is_active = '1'
</select>
<select id="getWorkCertificateSettingListCount" resultType="java.lang.Integer">
SELECT
count(1)
FROM
bm_certificate_type bct
WHERE bct.is_active = '1'
<if test="params != null and params !=''">
<if test="params.keyWord != null and params.keyWord !=''">
and instr(bct.`NAME`,#{params.keyWord}) &gt; 0
</if>
</if>
</select>
<select id="getWorkCertificateSettingList"
resultType="com.bonus.gzrn.rnbmw.person.entity.CertificateTypeBean">
SELECT
bct.id,
bct.`NAME`,
bct.is_upload as isUpload,
IF
( bcp.id IS NOT NULL, '1', '0' ) AS isCheck
FROM
bm_certificate_type bct
LEFT JOIN bm_certificate_post bcp ON bcp.certificate_id = bct.id and bcp.post_id = #{params.postId}
WHERE bct.is_active = '1'
<if test="params != null and params !=''">
<if test="params.keyWord != null and params.keyWord !=''">
and instr(bct.`NAME`,#{params.keyWord}) &gt; 0
</if>
</if>
GROUP BY bct.id
ORDER BY isCheck desc
limit #{offset}, #{limit}
</select>
<select id="getWorkPostList" resultType="com.bonus.gzrn.rnbmw.person.entity.WorkPostTreeBean">
SELECT
sdd.id,
CONCAT(sdd.`name`,'(',count(bcp.id),')') as name,
0 AS parentId,
count(bcp.id) as num
FROM
sys_dic_detail sdd
LEFT JOIN bm_certificate_post bcp
ON bcp.post_id = sdd.id and bcp.is_active = '1'
WHERE
dic_type = 3
<if test="id != null and id !=''">
AND id = #{id}
</if>
AND sdd.is_active = '1'
GROUP BY sdd.id
ORDER BY num DESC
</select>
<select id="getWorkerCertificateListCount" resultType="java.lang.Integer">
select count(1) from
(SELECT
bp.ID AS proId,
bp.NAME AS proName,
bw.NAME AS NAME,
bwr.ID_NUMBER AS idNumber,
sdd.id AS postId,
sdd.NAME AS postName,
GROUP_CONCAT(DISTINCT bct.`name` ) AS certificateName,
IFNULL(GROUP_CONCAT(DISTINCT bct2.`name`),'无') AS uploadCertificateName
FROM
bm_worker_record bwr
LEFT JOIN bm_project bp ON bwr.PROJECT_ID = bp.ID
LEFT JOIN pm_company pc ON bp.company_id = pc.ID
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwr.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID
AND sdd.dic_type = 3
LEFT JOIN bm_certificate_post bcp ON bcp.post_id = bwr.POST_ID
LEFT JOIN bm_certificate_type bct ON bcp.certificate_id = bct.id
LEFT JOIN bm_worker_certificate bwc ON bwc.id_number = bwr.ID_NUMBER
AND bwc.IS_ACTIVE = '1'
LEFT JOIN bm_certificate_type bct2 ON bwc.certificate_id = bct2.ID
WHERE 1=1
<if test="params != null and params !=''">
<if test="params.companyId != null and params.companyId !=''">
and bp.company_id = #{params.companyId}
</if>
<if test="params.proId != null and params.proId !=''">
and bp.id = #{params.proId}
</if>
<if test="params.name !=null and params.name !=''">
and bw.`NAME` like CONCAT('%',#{params.name},'%')
</if>
<if test="params.idNumber !=null and params.idNumber !=''">
and instr(bw.`id_number`,#{params.idNumber}) &gt; 0
</if>
<if test="params.postName !=null and params.postName !=''">
and instr(sdd.NAME,#{params.postName}) &gt; 0
</if>
</if>
GROUP BY
bwr.ID_NUMBER) a
</select>
<select id="getWorkerCertificateList" resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateBean">
SELECT
bp.ID AS proId,
bp.NAME AS proName,
bw.NAME AS NAME,
bwr.ID_NUMBER AS idNumber,
sdd.id AS postId,
sdd.NAME AS postName,
GROUP_CONCAT(DISTINCT bct.`name` ) AS certificateName,
IFNULL(GROUP_CONCAT(DISTINCT bct2.`name`),'无') AS uploadCertificateName
FROM
bm_worker_record bwr
LEFT JOIN bm_project bp ON bwr.PROJECT_ID = bp.ID
LEFT JOIN pm_company pc ON bp.company_id = pc.ID
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwr.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID
AND sdd.dic_type = 3
LEFT JOIN bm_certificate_post bcp ON bcp.post_id = bwr.POST_ID
LEFT JOIN bm_certificate_type bct ON bcp.certificate_id = bct.id
LEFT JOIN bm_worker_certificate bwc ON bwc.id_number = bwr.ID_NUMBER
AND bwc.IS_ACTIVE = '1'
LEFT JOIN bm_certificate_type bct2 ON bwc.certificate_id = bct2.ID
WHERE 1=1
<if test="params != null and params !=''">
<if test="params.companyId != null and params.companyId !=''">
and bp.company_id = #{params.companyId}
</if>
<if test="params.proId != null and params.proId !=''">
and bp.id = #{params.proId}
</if>
<if test="params.name !=null and params.name !=''">
and bw.`NAME` like CONCAT('%',#{params.name},'%')
</if>
<if test="params.idNumber !=null and params.idNumber !=''">
and instr(bw.`id_number`,#{params.idNumber}) &gt; 0
</if>
<if test="params.postName !=null and params.postName !=''">
and instr(sdd.NAME,#{params.postName}) &gt; 0
</if>
</if>
GROUP BY
bwr.ID_NUMBER
limit #{offset}, #{limit}
</select>
<select id="getPostBindingCertificate" resultType="com.bonus.gzrn.rnbmw.person.entity.CertificateTypeBean">
SELECT
bct.id,
CONCAT(bct.NAME,IFNULL(CONCAT("(",bct.certificate_version,")"),"")) as `name`,
is_upload AS isUpload,
bcp.id as orderFiled,
bct.remark,
bct.certificate_version as certificateVersion,
bct.review_num as recheckNum,
bct.one_review_interval as recheckInterval1,
bct.two_review_interval as recheckInterval2,
bct.three_review_interval as recheckInterval3
FROM
bm_certificate_type bct
LEFT JOIN bm_certificate_post bcp ON bct.id = bcp.certificate_id and bcp.post_id = #{postId} AND bcp.is_active =
'1'
WHERE
1=1
<if test="id != null and id !=''">
and bct.id = #{id}
</if>
AND bct.is_active = '1'
ORDER BY bcp.id desc
</select>
<select id="getSingleWorkerCertificateListCount" resultType="java.lang.Integer">
SELECT
count(1)
FROM
bm_worker_certificate bwc
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER
LEFT JOIN bm_worker_record bwr ON bw.ID_NUMBER = bwr.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID
AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bwr.PROJECT_ID = bp.ID
LEFT JOIN pm_company pc ON bp.company_id = pc.ID
LEFT JOIN bm_certificate_type bct ON bwc.certificate_id = bct.id
WHERE
bwc.id_number = #{params.idNumber}
and bwc.is_active = '1'
</select>
<select id="getSingleWorkerCertificateList"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT
bwc.id,
bw.NAME,
bwc.id_number AS idNumber,
sdd.id AS postId,
sdd.NAME AS postName,
bct.id AS certificateId,
bct.`name` AS certificateName,
bwc.start_date AS startDate,
bwc.stop_date AS stopDate,
bwc.one_review_time as oneReviewTime,
bwc.two_review_time as twoReviewTime,
bwc.three_review_time as threeReviewTime,
bwc.certificate_file AS certificateFile,
bwc.certificate_type_file AS certificateTypeFile
FROM
bm_worker_certificate bwc
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER
LEFT JOIN bm_worker_record bwr ON bw.ID_NUMBER = bwr.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID
AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bwr.PROJECT_ID = bp.ID
LEFT JOIN pm_company pc ON bp.company_id = pc.ID
LEFT JOIN bm_certificate_type bct ON bwc.certificate_id = bct.id
WHERE
bwc.id_number = #{params.idNumber}
and bwc.is_active = '1'
limit #{offset}, #{limit}
</select>
<select id="getWorkerCertificateStatisticCount" resultType="java.lang.Integer">
select count(1) from
(SELECT
IF(TIMESTAMPDIFF(MONTH,DATE_FORMAT(NOW(), '%Y-%m-%d'),bwc.stop_date)&gt;5,'有效',
IF(TIMESTAMPDIFF(DAY,DATE_FORMAT(NOW(), '%Y-%m-%d'),bwc.stop_date)&lt;0,'过期','预警')) as remind
FROM
bm_worker_certificate bwc
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id AND bct.is_active = '1'
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER AND bw.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.ID_NUMBER = bw.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bp.ID = bwr.PROJECT_ID
WHERE bwc.is_active = '1'
<if test="params != null and params !=''">
<if test="params.companyId != null and params.companyId !=''">
and bp.company_id = #{params.companyId}
</if>
<if test="params.proId != null and params.proId !=''">
and bp.id = #{params.proId}
</if>
<if test="params.postName !=null and params.postName !=''">
and sdd.`name` like CONCAT('%',#{params.postName},'%')
</if>
<if test="params.idNumber !=null and params.idNumber !=''">
and bw.`id_number` = #{params.idNumber}
</if>
<if test="params.certificateName !=null and params.certificateName !=''">
and bct.name = #{params.certificateName}
</if>
</if>
) a
<where>
<if test="params != null and params !=''">
<if test="params.remind !=null and params.remind !='' and params.remind !='全部' ">
and a.remind = #{params.remind}
</if>
</if>
</where>
</select>
<!-- 人员出场后,持证统计中不显示 -->
<select id="getWorkerCertificateStatistic"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
select * from (
select *,
IF(oneReviewTime = '无需复审' OR oneReviewTime = '已全部复审',
IF(TIMESTAMPDIFF(MONTH,DATE_FORMAT(NOW(), '%Y-%m-%d'),stopDate)>5,'有效',
IF(TIMESTAMPDIFF(DAY,DATE_FORMAT(NOW(), '%Y-%m-%d'),stopDate)&lt;0,'过期','预警')),
IF(TIMESTAMPDIFF(MONTH,DATE_FORMAT(NOW(), '%Y-%m-%d'),oneReviewTime)>5,'有效',
IF(TIMESTAMPDIFF(DAY,DATE_FORMAT(NOW(), '%Y-%m-%d'),oneReviewTime)&lt;0,'过期','预警')))
as remind
from (
SELECT
bp.`name` as proName,
bw.`NAME`,
bw.phone,
bwc.ID_NUMBER as idNumber,
sdd.`name` as postName,
bct.name AS certificateName,
bwc.start_date as startDate,
bwc.stop_date as stopDate,
IF(bwc.one_review_time is null,'无需复审',IF(bwc.one_review_user_id is null,bwc.one_review_time,
IF(bwc.two_review_time is null,'已全部复审',IF(bwc.two_review_user_id is null,bwc.two_review_time,
IF(bwc.three_review_time is null,'已全部复审',IF(bwc.three_review_user_id is null,bwc.three_review_time,'已全部复审'))))))
as oneReviewTime,
bwc.certificate_file as certificateFile,
bwc.certificate_type_file as certificateTypeFile,
if(bwr.ein_status = '1','在职','离职') as onJob
FROM
bm_worker_certificate bwc
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id AND bct.is_active = '1'
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER AND bw.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.ID_NUMBER = bw.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bp.ID = bwr.PROJECT_ID
WHERE bwc.is_active = '1'
<if test="params != null and params !=''">
<if test="params.proId != null and params.proId !=''">
and bp.id = #{params.proId}
</if>
<if test="params.postName !=null and params.postName !=''">
and sdd.`name` like CONCAT('%',#{params.postName},'%')
</if>
<if test="params.certificateName !=null and params.certificateName !=''">
and bct.name = #{params.certificateName}
</if>
</if>
)yyy
) a
<where>
<if test="params != null and params !=''">
<if test="params.remind !=null and params.remind !='' and params.remind !='全部' ">
and a.remind = #{params.remind}
</if>
</if>
</where>
limit #{offset}, #{limit}
</select>
<select id="getIsExistWorkerCertificate" resultType="java.lang.Integer">
SELECT
count( 1 )
FROM
bm_worker_certificate
WHERE
certificate_id = #{id}
AND is_active = '1'
</select>
<select id="getWorkerCertificateRecheckCount" resultType="java.lang.Integer">
select count(1) from (
select *,
IF(oneReviewTime = '无需复审' OR oneReviewTime = '已全部复审',
'已复审',
IF(TIMESTAMPDIFF(MONTH,DATE_FORMAT(NOW(), '%Y-%m-%d'),oneReviewTime)>5,'有效',
IF(TIMESTAMPDIFF(DAY,DATE_FORMAT(NOW(), '%Y-%m-%d'),oneReviewTime)&lt;0,'过期','预警')))
as remind
from (
SELECT
bp.`name` as proName,
bw.`NAME`,
bwc.ID_NUMBER as idNumber,
sdd.`name` as postName,
bw.phone,
bct.name AS certificateName,
IF(bwc.one_review_time is null,'无需复审',IF(bwc.one_review_user_id is null,bwc.one_review_time,
IF(bwc.two_review_time is null,'已全部复审',IF(bwc.two_review_user_id is null,bwc.two_review_time,
IF(bwc.three_review_time is null,'已全部复审',IF(bwc.three_review_user_id is null,bwc.three_review_time,'已全部复审'))))))
as oneReviewTime,
IF(bwc.one_review_file is not null,'附件','无') as recheckFile
FROM
bm_worker_certificate bwc
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id AND bct.is_active = '1'
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER AND bw.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.ID_NUMBER = bw.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bp.ID = bwr.PROJECT_ID
WHERE bwc.is_active = '1'
<if test="params != null and params !=''">
<if test="params.companyId != null and params.companyId !=''">
and bp.company_id = #{params.companyId}
</if>
<if test="params.proId != null and params.proId !=''">
and bp.id = #{params.proId}
</if>
<if test="params.postName !=null and params.postName !=''">
and sdd.`name` like CONCAT('%',#{params.postName},'%')
</if>
<if test="params.idNumber !=null and params.idNumber !=''">
and bw.`id_number` = #{params.idNumber}
</if>
<if test="params.certificateName !=null and params.certificateName !=''">
and bct.name = #{params.certificateName}
</if>
</if>
)yyy
) a
<where>
<if test="params != null and params !=''">
<if test="params.remind !=null and params.remind !='' and params.remind !='全部' ">
and a.remind = #{params.remind}
</if>
</if>
</where>
</select>
<select id="getWorkerCertificateRecheck"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
select * from (
select *,
IF(oneReviewTime = '无需复审','无需复审',
IF(oneReviewTime = '已全部复审','已复审',
IF(TIMESTAMPDIFF(MONTH,DATE_FORMAT(NOW(), '%Y-%m-%d'),oneReviewTime)>5,'未到复审时间',
IF(TIMESTAMPDIFF(DAY,DATE_FORMAT(NOW(), '%Y-%m-%d'),oneReviewTime)&lt;0,'过期','待复审'))
)) AS remind
from (
SELECT
bwc.id,
bp.`name` as proName,
bw.`NAME`,
bwc.ID_NUMBER as idNumber,
sdd.`name` as postName,
bw.phone,
bct.name AS certificateName,
IF(bwc.one_review_time is null,'无需复审',IF(bwc.one_review_user_id is null,bwc.one_review_time,
IF(bwc.two_review_time is null,'已全部复审',IF(bwc.two_review_user_id is null,bwc.two_review_time,
IF(bwc.three_review_time is null,'已全部复审',IF(bwc.three_review_user_id is null,bwc.three_review_time,'已全部复审'))))))
as oneReviewTime,
IF(bwc.one_review_time is null,'无需复审',IF(bwc.one_review_user_id is null,'第一次复审',
IF(bwc.two_review_time is null,'已全部复审',IF(bwc.two_review_user_id is null,'第二次复审',
IF(bwc.three_review_time is null,'已全部复审',IF(bwc.three_review_user_id is null,'第三次复审','已全部复审'))))))
as reviewNum,
IF(bwc.one_review_file is not null,'附件','无') as recheckFile
FROM
bm_worker_certificate bwc
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id AND bct.is_active = '1'
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER AND bw.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.ID_NUMBER = bw.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bp.ID = bwr.PROJECT_ID
WHERE bwc.is_active = '1'
<if test="params != null and params !=''">
<if test="params.companyId != null and params.companyId !=''">
and bp.company_id = #{params.companyId}
</if>
<if test="params.proId != null and params.proId !=''">
and bp.id = #{params.proId}
</if>
<if test="params.postName !=null and params.postName !=''">
and sdd.`name` like CONCAT('%',#{params.postName},'%')
</if>
<if test="params.idNumber !=null and params.idNumber !=''">
and bw.`id_number` = #{params.idNumber}
</if>
<if test="params.certificateName !=null and params.certificateName !=''">
and bct.name = #{params.certificateName}
</if>
</if>
)yyy
) a
<where>
<if test="params != null and params !=''">
<if test="params.remind !=null and params.remind !='' and params.remind !='全部' ">
and a.remind = #{params.remind}
</if>
</if>
</where>
limit #{offset}, #{limit}
</select>
<select id="getWorkerCertificateRecheckPhoto"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT
CONCAT(
IF
( one_review_file IS NULL, '', one_review_file ),
IF
( two_review_file IS NULL, '', CONCAT( ',', two_review_file ) ),
IF
( three_review_file IS NULL, '', CONCAT( ',', three_review_file ) )
) AS files,
CONCAT(
IF
( one_review_upload_time IS NULL, '', one_review_upload_time ),
IF
( two_review_upload_time IS NULL, '', CONCAT( ',', two_review_upload_time ) ),
IF
( three_review_upload_time IS NULL, '', CONCAT( ',', three_review_upload_time ) )
) AS times
FROM
bm_worker_certificate
WHERE
id = #{id}
</select>
<select id="getWorkerCertificateRecheckData"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT
bwc.id,
bw.NAME,
bwc.id_number AS idNumber,
sdd.id AS postId,
sdd.NAME AS postName,
bct.id AS certificateId,
bct.`name` AS certificateName,
bwc.start_date AS startDate,
bwc.stop_date AS stopDate,
bwc.one_review_time as oneReviewTime,
bwc.two_review_time as twoReviewTime,
bwc.three_review_time as threeReviewTime,
bwc.certificate_file AS certificateFile,
bwc.certificate_type_file AS certificateTypeFile,
bwc.one_review_file as oneFile,
bwc.two_review_file as twoFile,
bwc.three_review_file as threeFile
FROM
bm_worker_certificate bwc
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER
LEFT JOIN bm_worker_record bwr ON bw.ID_NUMBER = bwr.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID
AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bwr.PROJECT_ID = bp.ID
LEFT JOIN pm_company pc ON bp.company_id = pc.ID
LEFT JOIN bm_certificate_type bct ON bwc.certificate_id = bct.id
WHERE
bwc.id = #{id}
and bwc.is_active = '1'
</select>
<select id="getCertificateListStatusCount" resultType="java.lang.Integer">
SELECT
count(bwc.id)
FROM
bm_worker_certificate bwc
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER
LEFT JOIN bm_worker_record bwr ON bw.ID_NUMBER = bwr.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID
AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bwr.PROJECT_ID = bp.ID
LEFT JOIN pm_company pc ON bp.company_id = pc.ID
LEFT JOIN bm_certificate_type bct ON bwc.certificate_id = bct.id
WHERE
bwc.is_active = '1'
<if test="params.name !=null and params.name !=''">
and bw.NAME = #{params.name}
</if>
<if test="params.idNumber !=null and params.idNumber !=''">
and bwc.id_number = #{params.idNumber}
</if>
<if test="params.status !=null and params.status !=''">
and (bwc.status = #{params.status}
or bwc.one_review_status = #{params.oneReviewStatus}
or bwc.two_review_status = #{params.twoReviewStatus}
)
</if>
</select>
<select id="getCertificateListStatus"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT
bwc.id,
bw.NAME,
bwc.id_number AS idNumber,
bw.phone,
sdd.id AS postId,
sdd.NAME AS postName,
bct.id AS certificateId,
CONCAT( bct.`name`, '(', bct.certificate_version, ')' ) AS certificateName,
bp.NAME AS proName,
bct.review_num AS reviewNumber,
bwc.`status`,
bwc.remark,
bwc.certificate_file,
bwc.one_review_status,
bwc.one_review_remark,
bwc.one_review_file as oneFile,
bwc.two_review_status,
bwc.two_review_remark,
bwc.two_review_file as twoFile
FROM
bm_worker_certificate bwc
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER
LEFT JOIN bm_worker_record bwr ON bw.ID_NUMBER = bwr.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID
AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bwr.PROJECT_ID = bp.ID
LEFT JOIN pm_company pc ON bp.company_id = pc.ID
LEFT JOIN bm_certificate_type bct ON bwc.certificate_id = bct.id
WHERE
bwc.is_active = '1'
<if test="params.name !=null and params.name !=''">
and bw.NAME = #{params.name}
</if>
<if test="params.idNumber !=null and params.idNumber !=''">
and bwc.id_number = #{params.idNumber}
</if>
<if test="params.status !=null and params.status !=''">
and (bwc.status = #{params.status}
or bwc.one_review_status = #{params.oneReviewStatus}
or bwc.two_review_status = #{params.twoReviewStatus}
)
</if>
limit #{offset}, #{limit}
</select>
<select id="getCertificateTypeByName" resultType="java.lang.Integer">
select count(1) from `bm_certificate_type` where `name` = #{name} and certificate_version = #{certificateVersion} and is_active = '1'
</select>
<select id="getFrozenCertificateListCount" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM (
SELECT
bw.`NAME` AS name,
bwc.ID_NUMBER AS idNumber,
sdd.`name` AS postName,
bw.phone AS phone,
GROUP_CONCAT(bct.name) AS certificateName,
GROUP_CONCAT(bwc.certificate_file) AS certificateFile,
bwc.is_freeze AS freeze,
bp.`name` AS proName,
bwr.ein_status AS einStatus,
bwr.exit_time AS exitTime,
bwc.is_freeze AS isFreeze
FROM
bm_worker_certificate bwc
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id AND bct.is_active = '1'
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER AND bw.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.ID_NUMBER = bw.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bp.ID = bwr.PROJECT_ID
WHERE bwc.is_active = '1' AND bwc.is_freeze = '1'
<if test="params != null and params !=''">
<if test="params.keyWord !=null and params.keyWord !=''">
and (
bw.`NAME` like concat ('%',#{params.keyWord},'%') or
bwc.ID_NUMBER like concat ('%',#{params.keyWord},'%')
)
</if>
<if test="params.einStauts == 0 or params.einStauts =='0'">
and bwr.ein_status = #{params.einStauts}
</if>
<if test="params.einStauts == 1 or params.einStauts =='1'">
and bwr.ein_status = #{params.einStauts} AND (bwr.exit_time = '' OR bwr.exit_time IS NULL)
</if>
</if>
GROUP BY bwc.ID_NUMBER
) a
</select>
<select id="getFrozenCertificateList" resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT
bw.`NAME` AS name,
bwc.ID_NUMBER AS idNumber,
sdd.`name` AS postName,
bw.phone AS phone,
GROUP_CONCAT(bct.name) AS certificateName,
GROUP_CONCAT(bwc.certificate_file) AS certificateFile,
bwc.is_freeze AS isFreeze,
bp.`name` AS proName,
bwr.ein_status AS einStatus,
bwr.exit_time AS exitTime,
bwc.is_freeze AS isFreeze
FROM
bm_worker_certificate bwc
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id AND bct.is_active = '1'
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwc.ID_NUMBER AND bw.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.ID_NUMBER = bw.ID_NUMBER
LEFT JOIN sys_dic_detail sdd ON sdd.id = bwr.POST_ID AND sdd.dic_type = 3
LEFT JOIN bm_project bp ON bp.ID = bwr.PROJECT_ID
WHERE bwc.is_active = '1' AND bwc.is_freeze = '1'
<if test="params != null and params !=''">
<if test="params.keyWord !=null and params.keyWord !=''">
and (
bw.`NAME` like concat ('%',#{params.keyWord},'%') or
bwc.ID_NUMBER like concat ('%',#{params.keyWord},'%')
)
</if>
<if test="params.einStauts == 0 or params.einStauts =='0'">
and bwr.ein_status = #{params.einStauts}
</if>
<if test="params.einStauts == 1 or params.einStauts =='1'">
and bwr.ein_status = #{params.einStauts} AND (bwr.exit_time = '' OR bwr.exit_time IS NULL)
</if>
</if>
GROUP BY bwc.ID_NUMBER
limit #{offset}, #{limit}
</select>
<select id="getTeamCertificateConfigureListCount" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM (
SELECT
bctt.id AS id,bct.`name` AS certificateName,bctt.certificate_num AS certificateNum
FROM bm_certificate_team_type bctt
LEFT JOIN bm_sub_team_type bstt ON bstt.ID = bctt.team_type_id
LEFT JOIN bm_certificate_type bct ON bct.id = bctt.certificate_id
WHERE 1 = 1
<if test="params != null and params !=''">
<if test="params.keyWord !=null and params.keyWord !=''">
and bct.`name` like concat ('%',#{params.keyWord},'%')
</if>
<if test="params.teamId !=null and params.teamId !=''">
and bctt.team_type_id = #{params.teamId}
</if>
</if>
) a
</select>
<select id="getTeamCertificateConfigureList"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT
bctt.id AS id,bct.`name` AS certificateName,bctt.certificate_num AS certificateNum
FROM bm_certificate_team_type bctt
LEFT JOIN bm_sub_team_type bstt ON bstt.ID = bctt.team_type_id
LEFT JOIN bm_certificate_type bct ON bct.id = bctt.certificate_id
WHERE 1 = 1
<if test="params != null and params !=''">
<if test="params.keyWord !=null and params.keyWord !=''">
and bct.`name` like concat ('%',#{params.keyWord},'%')
</if>
<if test="params.teamId !=null and params.teamId !=''">
and bctt.team_type_id = #{params.teamId}
</if>
</if>
</select>
<select id="getTeamCertificateList" resultType="com.bonus.gzrn.rnbmw.person.entity.WorkPostTreeBean">
SELECT
bstt.ID,
CONCAT(bstt.`NAME`,'(',if(SUM(bctt.certificate_num) IS NULL,0,SUM(bctt.certificate_num)),')') as name,
0 AS parentId
FROM bm_sub_team_type bstt
LEFT JOIN bm_certificate_team_type bctt ON bctt.team_type_id = bstt.ID AND bstt.IS_ACTIVE = '1'
WHERE bstt.IS_ACTIVE = '1'
GROUP BY bstt.ID
ORDER BY bctt.certificate_num DESC
</select>
<select id="getCertificateSelect"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT bct.id,bct.`name`
FROM bm_certificate_type bct
WHERE bct.is_active = '1'
GROUP BY bct.id
</select>
<select id="getTeamCertificateStatisticCount" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM (
SELECT
aa.*,
GROUP_CONCAT(bct.`name`) as haveCer
FROM
(
SELECT
bst.id as teamId,
bst.name as teamName,
bsty.ID AS teamTypeId,
bsty.name as teamTypeName,
bs.SUB_NAME as subName,
COUNT(DISTINCT bwr.ID_NUMBER) as einNum,
GROUP_CONCAT(DISTINCT bwr.ID_NUMBER) as idNumbers,
GROUP_CONCAT(DISTINCT CONCAT(bct.`name`,'(',bctt.certificate_num,')')) as needCer
FROM
bm_sub_team bst
LEFT JOIN bm_subcontractor bs ON bs.id = bst.SUB_ID and bs.is_active = '1'
LEFT JOIN bm_sub_team_type bsty ON bsty.id = bst.team_type_id and bsty.is_active = '1'
LEFT JOIN bm_certificate_team_type bctt ON bctt.team_type_id = bsty.id and bctt.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bctt.certificate_id and bct.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.TEAM_ID = bst.id and bwr.ein_status = '1' and bwr.is_active = '1'
WHERE bst.is_active = '1'
GROUP BY bst.ID HAVING einNum > 0
) aa LEFT JOIN bm_worker_certificate bwc ON FIND_IN_SET(bwc.ID_NUMBER,aa.idNumbers) and bwc.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id and bct.is_active = '1'
WHERE 1 = 1
<if test="params != null and params !=''">
<if test="params.teamTypeId != '' and params.teamTypeId != null">
AND aa.teamTypeId = #{params.teamTypeId}
</if>
<if test="params.teamName != '' and params.teamName != null">
AND aa.teamName like CONCAT('%',#{params.teamName},'%')
</if>
<if test="params.subName != '' and params.subName != null">
AND aa.subName like CONCAT('%',#{params.subName},'%')
</if>
</if>
GROUP BY aa.idNumbers
UNION
SELECT
bst.id as teamId,
bst.name as teamName,
bsty.ID AS teamTypeId,
bsty.name as teamTypeName,
bs.SUB_NAME as subName,
COUNT(DISTINCT bwr.ID_NUMBER) as einNum,
GROUP_CONCAT(DISTINCT bwr.ID_NUMBER) as idNumbers,
GROUP_CONCAT(DISTINCT CONCAT(bct.`name`,'(',bctt.certificate_num,')')) as needCer,
null as haveCer
FROM
bm_sub_team bst
LEFT JOIN bm_subcontractor bs ON bs.id = bst.SUB_ID and bs.is_active = '1'
LEFT JOIN bm_sub_team_type bsty ON bsty.id = bst.team_type_id and bsty.is_active = '1'
LEFT JOIN bm_certificate_team_type bctt ON bctt.team_type_id = bsty.id and bctt.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bctt.certificate_id and bct.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.TEAM_ID = bst.id and bwr.ein_status = '1' and bwr.is_active = '1'
WHERE bst.is_active = '1'
<if test="params != null and params !=''">
<if test="params.teamTypeId != '' and params.teamTypeId != null">
AND bsty.ID = #{params.teamTypeId}
</if>
<if test="params.teamName != '' and params.teamName != null">
AND bst.`NAME` like CONCAT('%',#{params.teamName},'%')
</if>
<if test="params.subName != '' and params.subName != null">
AND bs.SUB_NAME like CONCAT('%',#{params.subName},'%')
</if>
</if>
GROUP BY bst.ID HAVING einNum = 0
) c
</select>
<select id="getTeamCertificateStatistic"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT
aa.*,
GROUP_CONCAT(bct.`name`) as haveCer
FROM
(
SELECT
bst.id as teamId,
bst.name as teamName,
bsty.ID AS teamTypeId,
bsty.name as teamTypeName,
bs.SUB_NAME as subName,
COUNT(DISTINCT bwr.ID_NUMBER) as einNum,
GROUP_CONCAT(DISTINCT bwr.ID_NUMBER) as idNumbers,
GROUP_CONCAT(DISTINCT CONCAT(bct.`name`,'(',bctt.certificate_num,')')) as needCer
FROM
bm_sub_team bst
LEFT JOIN bm_subcontractor bs ON bs.id = bst.SUB_ID and bs.is_active = '1'
LEFT JOIN bm_sub_team_type bsty ON bsty.id = bst.team_type_id and bsty.is_active = '1'
LEFT JOIN bm_certificate_team_type bctt ON bctt.team_type_id = bsty.id and bctt.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bctt.certificate_id and bct.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.TEAM_ID = bst.id and bwr.ein_status = '1' and bwr.is_active = '1'
WHERE bst.is_active = '1'
GROUP BY bst.ID HAVING einNum > 0
) aa LEFT JOIN bm_worker_certificate bwc ON FIND_IN_SET(bwc.ID_NUMBER,aa.idNumbers) and bwc.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id and bct.is_active = '1'
WHERE 1 = 1
<if test="params != null and params !=''">
<if test="params.teamTypeId != '' and params.teamTypeId != null">
AND aa.teamTypeId = #{params.teamTypeId}
</if>
<if test="params.teamName != '' and params.teamName != null">
AND aa.teamName like CONCAT('%',#{params.teamName},'%')
</if>
<if test="params.subName != '' and params.subName != null">
AND aa.subName like CONCAT('%',#{params.subName},'%')
</if>
</if>
GROUP BY aa.idNumbers
UNION
SELECT
bst.id as teamId,
bst.name as teamName,
bsty.ID AS teamTypeId,
bsty.name as teamTypeName,
bs.SUB_NAME as subName,
COUNT(DISTINCT bwr.ID_NUMBER) as einNum,
GROUP_CONCAT(DISTINCT bwr.ID_NUMBER) as idNumbers,
GROUP_CONCAT(DISTINCT CONCAT(bct.`name`,'(',bctt.certificate_num,')')) as needCer,
null as haveCer
FROM
bm_sub_team bst
LEFT JOIN bm_subcontractor bs ON bs.id = bst.SUB_ID and bs.is_active = '1'
LEFT JOIN bm_sub_team_type bsty ON bsty.id = bst.team_type_id and bsty.is_active = '1'
LEFT JOIN bm_certificate_team_type bctt ON bctt.team_type_id = bsty.id and bctt.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bctt.certificate_id and bct.is_active = '1'
LEFT JOIN bm_worker_record bwr ON bwr.TEAM_ID = bst.id and bwr.ein_status = '1' and bwr.is_active = '1'
WHERE bst.is_active = '1'
<if test="params != null and params !=''">
<if test="params.teamTypeId != '' and params.teamTypeId != null">
AND bsty.ID = #{params.teamTypeId}
</if>
<if test="params.teamName != '' and params.teamName != null">
AND bst.`NAME` like CONCAT('%',#{params.teamName},'%')
</if>
<if test="params.subName != '' and params.subName != null">
AND bs.SUB_NAME like CONCAT('%',#{params.subName},'%')
</if>
</if>
GROUP BY bst.ID HAVING einNum = 0
</select>
<select id="getTeamTypeName" resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT
bstt.ID AS id,bstt.`NAME` AS name
FROM bm_sub_team_type bstt
WHERE bstt.IS_ACTIVE = '1'
GROUP BY bstt.ID
</select>
<select id="getTeamCertificateDetialsCount" resultType="java.lang.Integer">
select count(1)
from (
SELECT
aa.*,
GROUP_CONCAT(bct.`name`) as haveCer
FROM
(
SELECT
bw.`NAME` AS name,bw.ID_NUMBER AS idNumber,bp.`name` proName,bw.phone AS phone,bst.ID AS teamId,GROUP_CONCAT(bct.`name`) AS needCer
FROM
bm_sub_team bst
LEFT JOIN bm_worker_record bwr ON bwr.TEAM_ID = bst.id and bwr.ein_status = '1' and bwr.is_active = '1'
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwr.ID_NUMBER AND bw.IS_ACTIVE = '1'
LEFT JOIN bm_project bp ON bp.ID = bwr.PROJECT_ID AND bp.is_active = '1'
LEFT JOIN bm_sub_team_type bsty ON bsty.id = bst.team_type_id and bsty.is_active = '1'
LEFT JOIN bm_certificate_team_type bctt ON bctt.team_type_id = bsty.id and bctt.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bctt.certificate_id and bct.is_active = '1'
WHERE bst.is_active = '1'
GROUP BY bwr.ID_NUMBER
) aa
LEFT JOIN bm_worker_certificate bwc ON bwc.id_number = aa.idNumber and bwc.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id and bct.is_active = '1'
WHERE 1 = 1
<if test="params != null and params !=''">
<if test="params.teamId != '' and params.teamId != null">
AND aa.teamId = #{params.teamId}
</if>
</if>
GROUP BY aa.idNumber
) s
</select>
<select id="getTeamCertificateDetials"
resultType="com.bonus.gzrn.rnbmw.person.entity.WorkerCertificateUploadBean">
SELECT
aa.*,
GROUP_CONCAT(bct.`name`) as haveCer
FROM
(
SELECT
bw.`NAME` AS name,
bw.ID_NUMBER AS idNumber,
bp.`name` proName,
bw.phone AS phone,
bst.ID AS teamId,
GROUP_CONCAT(bct.`name`) AS needCer
FROM
bm_sub_team bst
LEFT JOIN bm_worker_record bwr ON bwr.TEAM_ID = bst.id and bwr.ein_status = '1' and bwr.is_active = '1'
LEFT JOIN bm_worker bw ON bw.ID_NUMBER = bwr.ID_NUMBER AND bw.IS_ACTIVE = '1'
LEFT JOIN bm_project bp ON bp.ID = bwr.PROJECT_ID AND bp.is_active = '1'
LEFT JOIN bm_sub_team_type bsty ON bsty.id = bst.team_type_id and bsty.is_active = '1'
LEFT JOIN bm_certificate_team_type bctt ON bctt.team_type_id = bsty.id and bctt.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bctt.certificate_id and bct.is_active = '1'
WHERE bst.is_active = '1'
GROUP BY bwr.ID_NUMBER
) aa
LEFT JOIN bm_worker_certificate bwc ON bwc.id_number = aa.idNumber and bwc.is_active = '1'
LEFT JOIN bm_certificate_type bct ON bct.id = bwc.certificate_id and bct.is_active = '1'
WHERE 1 = 1
<if test="params != null and params !=''">
<if test="params.teamId != '' and params.teamId != null">
AND aa.teamId = #{params.teamId}
</if>
</if>
GROUP BY aa.idNumber
</select>
</mapper>