2026-01-08 09:09:47 +08:00
|
|
|
<?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.zcloud.certificate.persistence.mapper.UserCertificateMapper">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectPageWithUser" resultType="com.zcloud.certificate.persistence.dataobject.UserCertificateDO">
|
|
|
|
|
SELECT
|
|
|
|
|
uc.*,
|
2026-02-03 10:00:23 +08:00
|
|
|
u.name AS userName,
|
2026-01-08 09:09:47 +08:00
|
|
|
u.employment_flag AS employmentStatus,
|
|
|
|
|
d.name AS departmentName,
|
|
|
|
|
p.corpinfo_name AS corpinfoName,
|
2026-02-03 10:00:23 +08:00
|
|
|
uc.post_name AS postName,
|
|
|
|
|
uc.type_name AS typeName
|
2026-01-08 09:09:47 +08:00
|
|
|
FROM
|
|
|
|
|
user_certificate uc
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
user u ON u.id = uc.user_id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
department d ON d.id = u.department_id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
post p ON p.id = u.post_id
|
2026-02-10 09:20:00 +08:00
|
|
|
WHERE
|
|
|
|
|
uc.delete_enum = 'false'
|
|
|
|
|
|
|
|
|
|
<if test="params.eqType != null and params.eqType != ''">
|
|
|
|
|
AND uc.type = #{params.eqType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.eqCorpinfoId != null and params.eqCorpinfoId != ''">
|
|
|
|
|
AND uc.corpinfo_id = #{params.eqCorpinfoId}
|
|
|
|
|
</if>
|
2026-01-08 09:09:47 +08:00
|
|
|
<if test="params.tenantId != null">
|
|
|
|
|
AND uc.tenant_id = #{params.tenantId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.orgId != null">
|
|
|
|
|
AND uc.org_id = #{params.orgId}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="params.likeUserName != null and params.likeUserName != ''">
|
2026-01-27 09:09:42 +08:00
|
|
|
AND u.name LIKE CONCAT('%', #{params.likeUserName}, '%')
|
2026-01-08 09:09:47 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="params.eqIndustryCategoryCode != null and params.eqIndustryCategoryCode != ''">
|
|
|
|
|
AND uc.industry_category_code = #{params.eqIndustryCategoryCode}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.eqIndustryOperatingItemsCode != null and params.eqIndustryOperatingItemsCode != ''">
|
|
|
|
|
AND uc.industry_operating_items_code = #{params.eqIndustryOperatingItemsCode}
|
|
|
|
|
</if>
|
2026-02-05 08:31:42 +08:00
|
|
|
<if test="params.eqAssignmentCategoryCode != null and params.eqAssignmentCategoryCode != ''">
|
|
|
|
|
AND uc.assignment_category_code = #{params.eqAssignmentCategoryCode}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.eqAssignmentOperatingItemsCode != null and params.eqAssignmentOperatingItemsCode != ''">
|
|
|
|
|
AND uc.assignment_operating_items_code = #{params.eqAssignmentOperatingItemsCode}
|
|
|
|
|
</if>
|
2026-01-08 11:50:49 +08:00
|
|
|
<if test="params.likePostName != null and params.likePostName != ''">
|
|
|
|
|
AND uc.post_name LIKE CONCAT('%', #{params.likePostName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.eqUserId != null and params.eqUserId != ''">
|
|
|
|
|
AND uc.user_id = #{params.eqUserId}
|
|
|
|
|
</if>
|
2026-01-08 09:09:47 +08:00
|
|
|
|
|
|
|
|
ORDER BY uc.create_time DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
2026-01-14 09:21:21 +08:00
|
|
|
<select id="selectPageUser" resultType="com.zcloud.certificate.persistence.dataobject.UserCertificateDO">
|
|
|
|
|
SELECT
|
|
|
|
|
uc.*,
|
2026-01-20 09:26:56 +08:00
|
|
|
u.username AS userName,
|
|
|
|
|
u.name AS name,
|
2026-01-14 09:21:21 +08:00
|
|
|
u.employment_flag AS employmentStatus,
|
|
|
|
|
d.name AS departmentName,
|
|
|
|
|
p.corpinfo_name AS corpinfoName,
|
2026-02-03 10:00:23 +08:00
|
|
|
uc.post_name AS postName,
|
|
|
|
|
uc.type_name AS typeName
|
2026-01-14 09:21:21 +08:00
|
|
|
FROM
|
|
|
|
|
user_certificate uc
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
user u ON u.id = uc.user_id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
department d ON d.id = u.department_id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
post p ON p.id = u.post_id
|
2026-02-10 09:20:00 +08:00
|
|
|
WHERE
|
|
|
|
|
uc.delete_enum = 'false'
|
2026-01-14 09:21:21 +08:00
|
|
|
|
|
|
|
|
<if test="params.likeUserName != null and params.likeUserName != ''">
|
2026-01-27 09:09:42 +08:00
|
|
|
AND u.name LIKE CONCAT('%', #{params.likeUserName}, '%')
|
2026-01-14 09:21:21 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="params.eqIndustryCategoryCode != null and params.eqIndustryCategoryCode != ''">
|
|
|
|
|
AND uc.industry_category_code = #{params.eqIndustryCategoryCode}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.eqIndustryOperatingItemsCode != null and params.eqIndustryOperatingItemsCode != ''">
|
|
|
|
|
AND uc.industry_operating_items_code = #{params.eqIndustryOperatingItemsCode}
|
|
|
|
|
</if>
|
2026-02-05 08:31:42 +08:00
|
|
|
<if test="params.eqAssignmentCategoryCode != null and params.eqAssignmentCategoryCode != ''">
|
|
|
|
|
AND uc.assignment_category_code = #{params.eqAssignmentCategoryCode}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.eqAssignmentOperatingItemsCode != null and params.eqAssignmentOperatingItemsCode != ''">
|
|
|
|
|
AND uc.assignment_operating_items_code = #{params.eqAssignmentOperatingItemsCode}
|
|
|
|
|
</if>
|
2026-01-14 09:21:21 +08:00
|
|
|
<if test="params.eqType != null and params.eqType != ''">
|
|
|
|
|
AND uc.type = #{params.eqType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.eqCorpinfoId != null and params.eqCorpinfoId != ''">
|
|
|
|
|
AND uc.corpinfo_id = #{params.eqCorpinfoId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.likePostName != null and params.likePostName != ''">
|
|
|
|
|
AND uc.post_name LIKE CONCAT('%', #{params.likePostName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.eqUserId != null and params.eqUserId != ''">
|
|
|
|
|
AND uc.user_id = #{params.eqUserId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.inType != null and params.inType.size() > 0">
|
|
|
|
|
AND uc.type IN
|
|
|
|
|
<foreach collection="params.inType" item="type" open="(" separator="," close=")">
|
|
|
|
|
#{type}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
ORDER BY uc.create_time DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
2026-01-08 09:09:47 +08:00
|
|
|
|
2026-01-08 11:50:49 +08:00
|
|
|
<select id="selectUserNamesByUserIds" resultType="com.zcloud.certificate.domain.model.UserBasicInfo">
|
2026-01-08 09:09:47 +08:00
|
|
|
SELECT
|
|
|
|
|
u.id AS userId,
|
2026-02-02 14:34:38 +08:00
|
|
|
u.username AS userName,
|
2026-01-20 09:26:56 +08:00
|
|
|
u.name AS name,
|
2026-01-08 09:09:47 +08:00
|
|
|
d.name AS departmentName,
|
2026-01-29 15:24:10 +08:00
|
|
|
c.corp_name AS corpinfoName,
|
2026-01-27 11:37:46 +08:00
|
|
|
COALESCE(NULLIF(u.post_name, ''), p.post_name) AS postName,
|
2026-01-08 09:09:47 +08:00
|
|
|
u.employment_flag AS employmentStatus
|
|
|
|
|
FROM
|
2026-01-29 15:24:10 +08:00
|
|
|
`user` u
|
2026-01-08 09:09:47 +08:00
|
|
|
LEFT JOIN
|
|
|
|
|
department d ON d.id = u.department_id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
post p ON p.id = u.post_id
|
2026-01-29 15:24:10 +08:00
|
|
|
LEFT JOIN
|
|
|
|
|
corp_info c on u.corpinfo_id = c.id
|
2026-01-08 09:09:47 +08:00
|
|
|
WHERE
|
|
|
|
|
u.id IN
|
|
|
|
|
<foreach item="userId" index="index" collection="userIds" open="(" separator="," close=")">
|
|
|
|
|
#{userId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectCorpCertificateStatPage"
|
|
|
|
|
resultType="com.zcloud.certificate.persistence.dataobject.UserCertificateStatDO">
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
ci.id AS corpinfoId,
|
|
|
|
|
ci.corp_name AS corpName,
|
2026-01-15 15:32:37 +08:00
|
|
|
COALESCE(SUM(CASE WHEN uc.type = 'tezhongzuoye' THEN 1 ELSE 0 END), 0) AS specialWorkCertCount,
|
|
|
|
|
COALESCE(SUM(CASE WHEN uc.type = 'tzsbczry' THEN 1 ELSE 0 END), 0) AS specialEquipmentCertCount,
|
|
|
|
|
COALESCE(SUM(CASE WHEN uc.type = 'zyfzr' THEN 1 ELSE 0 END), 0) AS principalCertCount,
|
|
|
|
|
COALESCE(SUM(CASE WHEN uc.type = 'aqscglry' THEN 1 ELSE 0 END), 0) AS safetyManagerCertCount
|
2026-01-08 09:09:47 +08:00
|
|
|
FROM
|
|
|
|
|
corp_info ci
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
user_certificate uc
|
|
|
|
|
ON
|
|
|
|
|
uc.corpinfo_id = ci.id
|
|
|
|
|
AND
|
|
|
|
|
uc.delete_enum = 'false'
|
|
|
|
|
<if test="params.tenantId != null">
|
|
|
|
|
AND uc.tenant_id = #{params.tenantId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.orgId != null">
|
|
|
|
|
AND uc.org_id = #{params.orgId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.env != null and params.env != ''">
|
|
|
|
|
AND uc.env = #{params.env}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
WHERE 1 = 1
|
|
|
|
|
AND ci.delete_enum = 'false'
|
|
|
|
|
|
|
|
|
|
<if test="params.tenantId != null">
|
|
|
|
|
AND ci.tenant_id = #{params.tenantId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.orgId != null">
|
|
|
|
|
AND ci.org_id = #{params.orgId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.env != null and params.env != ''">
|
|
|
|
|
AND ci.env = #{params.env}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.useFlag != null">
|
|
|
|
|
AND ci.use_flag = #{params.useFlag}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="params.corpType != null">
|
|
|
|
|
AND (
|
2026-02-02 14:34:38 +08:00
|
|
|
(#{params.corpType} = 0 AND ci.type IN (0,1,6))
|
|
|
|
|
OR (#{params.corpType} = 1 AND ci.type IN (3,4,5))
|
2026-01-08 09:09:47 +08:00
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="params.corpName != null and params.corpName != ''">
|
|
|
|
|
AND ci.corp_name LIKE CONCAT('%', #{params.corpName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
GROUP BY ci.id, ci.corp_name
|
2026-03-06 11:29:57 +08:00
|
|
|
ORDER BY ci.corp_order ASC
|
2026-01-08 09:09:47 +08:00
|
|
|
</select>
|
2026-03-17 09:43:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="certifiedPersonnelListPage" resultType="com.zcloud.certificate.persistence.dataobject.UserCerDO">
|
|
|
|
|
select
|
|
|
|
|
d.name as department_name,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN c.type IN (3,4, 5) THEN u.post_name
|
|
|
|
|
ELSE p.post_name
|
|
|
|
|
END AS post_name,
|
|
|
|
|
u.id,
|
|
|
|
|
u.user_id,
|
|
|
|
|
u.username,
|
|
|
|
|
u.name,
|
|
|
|
|
u.corpinfo_id,
|
|
|
|
|
u.main_corp_flag,
|
|
|
|
|
u.user_type,
|
|
|
|
|
u.department_id,
|
|
|
|
|
u.post_id,
|
|
|
|
|
u.role_id,
|
|
|
|
|
u.email,
|
|
|
|
|
u.phone,
|
|
|
|
|
u.personnel_type,
|
|
|
|
|
u.personnel_type_name,
|
|
|
|
|
u.nation,
|
|
|
|
|
u.nation_name,
|
|
|
|
|
u.user_id_card,
|
|
|
|
|
u.user_avatar_url,
|
|
|
|
|
u.current_address,
|
|
|
|
|
u.location_address,
|
|
|
|
|
u.rank_level,
|
|
|
|
|
u.rank_level_name,
|
|
|
|
|
u.sort,
|
|
|
|
|
u.version,
|
|
|
|
|
u.create_id,
|
|
|
|
|
u.create_name,
|
|
|
|
|
u.create_time,
|
|
|
|
|
u.update_id,
|
|
|
|
|
u.update_name,
|
|
|
|
|
u.update_time,
|
|
|
|
|
u.remarks,
|
|
|
|
|
u.delete_enum,
|
|
|
|
|
u.tenant_id,
|
|
|
|
|
u.org_id,
|
|
|
|
|
u.env,
|
|
|
|
|
u.department_leader_flag,
|
|
|
|
|
u.deputy_leader_flag,
|
|
|
|
|
u.cultural_level,
|
|
|
|
|
u.cultural_level_name,
|
|
|
|
|
u.marital_status,
|
|
|
|
|
u.marital_status_name,
|
|
|
|
|
u.political_affiliation,
|
|
|
|
|
u.political_affiliation_name,
|
|
|
|
|
u.employment_flag,
|
|
|
|
|
u.flow_flag,
|
|
|
|
|
GROUP_CONCAT(uc.type SEPARATOR ',') AS certificateType,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN LENGTH(FROM_BASE64(u.user_id_card)) > 0
|
|
|
|
|
AND MOD(SUBSTRING(FROM_BASE64(u.user_id_card), 17, 1), 2) = 1 THEN
|
|
|
|
|
'男'
|
|
|
|
|
WHEN LENGTH(FROM_BASE64(u.user_id_card)) > 0
|
|
|
|
|
AND MOD(SUBSTRING(FROM_BASE64(u.user_id_card), 17, 1), 2) = 0 THEN
|
|
|
|
|
'女'
|
|
|
|
|
END AS sex,
|
|
|
|
|
|
|
|
|
|
CASE
|
|
|
|
|
WHEN LENGTH(FROM_BASE64(u.user_id_card)) > 0 THEN
|
|
|
|
|
(YEAR(NOW()) - SUBSTRING(FROM_BASE64(u.user_id_card), 7, 4)) ELSE NULL
|
|
|
|
|
END AS age,
|
|
|
|
|
|
|
|
|
|
cast(substring(FROM_BASE64(u.user_id_card), 7, 8) AS DATE) AS birthday
|
|
|
|
|
from user u
|
|
|
|
|
left join corp_info c on c.id = u.corpinfo_id
|
|
|
|
|
left join department d on d.id = u.department_id
|
|
|
|
|
left join post p on p.id = u.post_id
|
|
|
|
|
left join user_certificate uc on uc .user_id = u.id and uc.delete_enum = 'false'
|
|
|
|
|
<where>
|
|
|
|
|
u.delete_enum = 'false'
|
|
|
|
|
and uc.id is not null
|
|
|
|
|
<if test="params.noMain != null and params.noMain != ''">
|
|
|
|
|
and u.id != u.corpinfo_id
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.corpinfoId != null and params.corpinfoId != ''">
|
|
|
|
|
and c.id = #{params.corpinfoId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.corpinfoUuid != null and params.corpinfoUuid != ''">
|
|
|
|
|
and c.corpinfo_id = #{params.corpinfoUuid}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.departmentId != null and params.departmentId != ''">
|
|
|
|
|
and d.id = #{params.departmentId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.postId != null and params.postId != ''">
|
|
|
|
|
and p.id = #{params.postId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.username != null and params.username != ''">
|
|
|
|
|
and u.username = #{params.username}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.name != null and params.name != ''">
|
|
|
|
|
and u.name = #{params.name}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="params.certificateType != null and params.certificateType.size() > 0">
|
|
|
|
|
AND uc.type IN
|
|
|
|
|
<foreach collection="params.certificateType" item="type" open="(" separator="," close=")">
|
|
|
|
|
#{type}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
group by u.id
|
|
|
|
|
order by u.sort asc,u.create_time desc
|
|
|
|
|
</select>
|
2026-01-08 09:09:47 +08:00
|
|
|
</mapper>
|
|
|
|
|
|