243 lines
9.5 KiB
XML
243 lines
9.5 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.bsd.pjcloud.admin.mapper.SysUserFaceMapper">
|
|
<resultMap id="sysUserFaceMap" type="com.bsd.pjcloud.admin.api.entity.SysUserFaceEntity">
|
|
<id property="id" column="id"/>
|
|
<result property="userId" column="user_id"/>
|
|
<result property="rejectReason" column="reject_reason"/>
|
|
<result property="faceImg" column="face_img"/>
|
|
<result property="qualityScore" column="quality_score"/>
|
|
<result property="qualityStatus" column="quality_status"/>
|
|
<result property="qualityCheckedAt" column="quality_checked_at"/>
|
|
<result property="qualityErrorCode" column="quality_error_code"/>
|
|
<result property="qualityDeviceId" column="quality_device_id"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="delFlag" column="del_flag"/>
|
|
<result property="tenantId" column="tenant_id"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectA">
|
|
select a.id,
|
|
a.auto_code,
|
|
a.user_id,
|
|
a.process_id,
|
|
a.process_status,
|
|
a.reject_reason,
|
|
a.face_img,
|
|
a.quality_score,
|
|
a.quality_status,
|
|
a.quality_checked_at,
|
|
a.quality_error_code,
|
|
a.quality_device_id,
|
|
a.create_by,
|
|
a.create_time,
|
|
a.update_by,
|
|
a.update_time,
|
|
a.del_flag,
|
|
a.tenant_id,
|
|
a.process_time,
|
|
</sql>
|
|
|
|
<sql id="whereA">
|
|
a.del_flag = '0'
|
|
<if test="pa.userId != null">
|
|
and a.user_id = #{pa.userId}
|
|
</if>
|
|
<if test="pa.userIds != null and pa.userIds.size() != 0">
|
|
and a.user_id in
|
|
<foreach collection="pa.userIds" item="userId" open="(" separator="," close=")">
|
|
#{userId}
|
|
</foreach>
|
|
</if>
|
|
<if test="pa.processStatus != null">
|
|
and a.process_status = #{pa.processStatus}
|
|
</if>
|
|
<if test="pa.processStatuses != null and pa.processStatuses.size() != 0">
|
|
and a.process_status in
|
|
<foreach collection="pa.processStatuses" item="status" open="(" separator="," close=")">
|
|
#{status}
|
|
</foreach>
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="scopePageList" resultType="com.bsd.pjcloud.admin.api.vo.SysUserFaceVo">
|
|
<include refid="selectA"/>
|
|
u.name as username,
|
|
u.avatar as userAvatar,
|
|
u.phone as userMobile,
|
|
u.dept_id as userDeptId,
|
|
u.dept_id as deptId,
|
|
d.name as deptName
|
|
from sys_user_face a
|
|
left join sys_user u on u.user_id = a.user_id and u.del_flag = '0'
|
|
left join sys_dept d on d.dept_id = u.dept_id and d.del_flag = '0'
|
|
<where>
|
|
<include refid="whereA"/>
|
|
<if test="pa.username != null and pa.username != ''">
|
|
and u.name LIKE CONCAT('%', #{pa.username}, '%')
|
|
</if>
|
|
<if test="pa.phone != null and pa.phone != ''">
|
|
and u.phone LIKE CONCAT('%', #{pa.phone}, '%')
|
|
</if>
|
|
</where>
|
|
order by a.create_time desc , a.id desc
|
|
</select>
|
|
|
|
<select id="selectMaxNumericAutoCode" resultType="java.lang.Long">
|
|
select coalesce(max(cast(auto_code as unsigned)), 0)
|
|
from sys_user_face
|
|
where auto_code regexp '^[0-9]+$'
|
|
</select>
|
|
|
|
<select id="countDuplicateAutoCodes" resultType="java.lang.Long">
|
|
select count(0)
|
|
from (
|
|
select cast(auto_code as unsigned) as numeric_auto_code
|
|
from sys_user_face
|
|
where auto_code regexp '^[0-9]+$'
|
|
group by cast(auto_code as unsigned)
|
|
having count(0) > 1
|
|
) duplicate_codes
|
|
</select>
|
|
|
|
<select id="countSyncDuplicateAutoCodes" resultType="java.lang.Long">
|
|
select count(0)
|
|
from (
|
|
select cast(a.auto_code as unsigned) as numeric_auto_code
|
|
from sys_user_face a
|
|
inner join sys_user u on u.user_id = a.user_id and u.del_flag = '0'
|
|
inner join sys_dept d on d.dept_id = u.dept_id and d.del_flag = '0'
|
|
where a.del_flag = '0'
|
|
and a.process_status = #{processStatus}
|
|
and a.auto_code regexp '^[0-9]+$'
|
|
and d.dept_id in
|
|
<foreach collection="deptIds" item="deptId" open="(" close=")" separator=",">
|
|
#{deptId}
|
|
</foreach>
|
|
group by cast(a.auto_code as unsigned)
|
|
having count(0) > 1
|
|
) duplicate_codes
|
|
</select>
|
|
|
|
<select id="selectSyncSnapshotMaxId" resultType="java.lang.Long">
|
|
select coalesce(max(a.id), 0)
|
|
from sys_user_face a
|
|
inner join sys_user u on u.user_id = a.user_id and u.del_flag = '0'
|
|
where a.del_flag = '0'
|
|
and a.process_status = #{processStatus}
|
|
and u.dept_id in
|
|
<foreach collection="deptIds" item="deptId" open="(" close=")" separator=",">
|
|
#{deptId}
|
|
</foreach>
|
|
<if test="userId != null">
|
|
and a.user_id = #{userId}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="listSyncSnapshotRecords" resultType="com.bsd.pjcloud.admin.api.vo.SysUserFaceSyncRecordVo">
|
|
select a.id,
|
|
a.auto_code as sampleId,
|
|
a.user_id as userId,
|
|
u.name as username,
|
|
d.dept_id as deptId,
|
|
d.name as deptName,
|
|
a.face_img as faceImg,
|
|
coalesce(a.update_time, a.create_time) as sourceUpdatedAt
|
|
from sys_user_face a
|
|
inner join sys_user u on u.user_id = a.user_id and u.del_flag = '0'
|
|
inner join sys_dept d on d.dept_id = u.dept_id and d.del_flag = '0'
|
|
where a.del_flag = '0'
|
|
and a.process_status = #{processStatus}
|
|
and a.id > #{afterId}
|
|
and a.id <= #{snapshotMaxId}
|
|
and d.dept_id in
|
|
<foreach collection="deptIds" item="deptId" open="(" close=")" separator=",">
|
|
#{deptId}
|
|
</foreach>
|
|
<if test="userId != null">
|
|
and a.user_id = #{userId}
|
|
</if>
|
|
order by a.id asc
|
|
limit #{fetchSize}
|
|
</select>
|
|
|
|
<select id="listStatusCounts" resultType="com.bsd.pjcloud.admin.api.vo.SysUserFaceStatusCountVo">
|
|
select user_id as userId,
|
|
sum(case when process_status = #{availableStatus} then 1 else 0 end) as availableCount,
|
|
sum(case when process_status = #{pendingStatus} then 1 else 0 end) as pendingCount
|
|
from sys_user_face
|
|
where del_flag = '0'
|
|
and user_id in
|
|
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
|
#{userId}
|
|
</foreach>
|
|
and process_status in (#{availableStatus}, #{pendingStatus})
|
|
group by user_id
|
|
</select>
|
|
|
|
<select id="groupConcatFaces" resultType="com.bsd.pjcloud.admin.api.vo.SysUserFaceVo">
|
|
select a.user_id, group_concat(a.face_img) as faceImgs
|
|
from sys_user_face a
|
|
<where>
|
|
del_flag = '0'
|
|
<if test="pa.userIds != null and pa.userIds.size() != 0">
|
|
and user_id in
|
|
<foreach collection="pa.userIds" index="index" item="v" open="(" separator="," close=")">
|
|
#{v}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
GROUP BY a.user_id
|
|
</select>
|
|
|
|
<select id="allPageJoin" resultType="com.bsd.pjcloud.admin.api.vo.SysUserFaceVo">
|
|
<include refid="selectA"/>
|
|
u.name as username,
|
|
u.phone as userMobile,
|
|
u.avatar as userAvatar,
|
|
d.dept_id as deptId,
|
|
d.name as deptName
|
|
from sys_user_face a
|
|
inner join sys_user u on u.user_id = a.user_id and u.del_flag = '0'
|
|
inner join sys_dept d on d.dept_id = u.dept_id and d.del_flag = '0'
|
|
<where>
|
|
<if test="pa.userId != null">
|
|
and a.user_id = #{pa.userId}
|
|
</if>
|
|
<if test="pa.userIds != null and pa.userIds.size() != 0">
|
|
and a.user_id in
|
|
<foreach collection="pa.userIds" item="v" open="(" close=")" separator=",">
|
|
#{v}
|
|
</foreach>
|
|
</if>
|
|
<if test="pa.processStatus != null">
|
|
and a.process_status = #{pa.processStatus}
|
|
</if>
|
|
<if test="pa.isProcessIdNotNull != null and pa.isProcessIdNotNull == true ">
|
|
and a.process_id is not null
|
|
</if>
|
|
<if test="pa.deptIds != null and pa.deptIds.size() != 0">
|
|
<choose>
|
|
<when test="pa.isInclude != null and pa.isInclude == true">
|
|
and d.dept_id IN
|
|
</when>
|
|
<when test="pa.isInclude != null and pa.isInclude == false">
|
|
and d.dept_id NOT IN
|
|
</when>
|
|
<otherwise>
|
|
and d.dept_id IN
|
|
</otherwise>
|
|
</choose>
|
|
<foreach collection="pa.deptIds" item="v" open="(" close=")" separator=",">
|
|
#{v}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
order by a.create_time desc, a.id desc
|
|
</select>
|
|
</mapper>
|