133 lines
4.9 KiB
XML
133 lines
4.9 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.zcloud.certificate.persistence.mapper.UserCertificateMapper">
|
||
|
|
|
||
|
|
|
||
|
|
<select id="selectPageWithUser" resultType="com.zcloud.certificate.persistence.dataobject.UserCertificateDO">
|
||
|
|
SELECT
|
||
|
|
uc.*,
|
||
|
|
u.username AS userName,
|
||
|
|
u.employment_flag AS employmentStatus,
|
||
|
|
d.name AS departmentName,
|
||
|
|
p.corpinfo_name AS corpinfoName,
|
||
|
|
p.post_name AS postName
|
||
|
|
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
|
||
|
|
WHERE 1=1
|
||
|
|
<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 != ''">
|
||
|
|
AND u.username LIKE CONCAT('%', #{params.likeUserName}, '%')
|
||
|
|
</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>
|
||
|
|
<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>
|
||
|
|
|
||
|
|
ORDER BY uc.create_time DESC
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="selectUserNamesByUserIds" resultType="com.zcloud.certificate.persistence.dataobject.UserDO">
|
||
|
|
SELECT
|
||
|
|
u.id AS userId,
|
||
|
|
u.name AS userName,
|
||
|
|
d.name AS departmentName,
|
||
|
|
p.corpinfo_name AS corpinfoName,
|
||
|
|
p.post_name AS postName,
|
||
|
|
u.employment_flag AS employmentStatus
|
||
|
|
FROM
|
||
|
|
user u
|
||
|
|
LEFT JOIN
|
||
|
|
department d ON d.id = u.department_id
|
||
|
|
LEFT JOIN
|
||
|
|
post p ON p.id = u.post_id
|
||
|
|
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,
|
||
|
|
COALESCE(SUM(CASE WHEN uc.type = 1 THEN 1 ELSE 0 END), 0) AS specialWorkCertCount,
|
||
|
|
COALESCE(SUM(CASE WHEN uc.type = 2 THEN 1 ELSE 0 END), 0) AS specialEquipmentCertCount,
|
||
|
|
COALESCE(SUM(CASE WHEN uc.type = 3 THEN 1 ELSE 0 END), 0) AS principalCertCount,
|
||
|
|
COALESCE(SUM(CASE WHEN uc.type = 4 THEN 1 ELSE 0 END), 0) AS safetyManagerCertCount
|
||
|
|
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 (
|
||
|
|
(#{params.corpType} = 0 AND ci.type IN (0,1))
|
||
|
|
OR (#{params.corpType} = 1 AND ci.type IN (3,4,5))
|
||
|
|
)
|
||
|
|
</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
|
||
|
|
ORDER BY ci.corp_order ASC, ci.id ASC
|
||
|
|
</select>
|
||
|
|
</mapper>
|
||
|
|
|