2025-01-16 16:16:53 +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.bonus.project.mapper.SupervisionUnitMapper" >
<insert id= "insertPersonEnterInfo" useGeneratedKeys= "true" keyProperty= "id" >
insert into pt_sup_person(sup_name,id_card,sex,age,phone,post,face_path,is_active)
values(#{name},#{idCard},#{sex},#{age},#{phone},#{postName},#{faceUrl},'1')
</insert>
<insert id= "insertUserInfo" useGeneratedKeys= "true" keyProperty= "id" >
insert into
sys_user(parent_uuid,dept_id,user_name,nick_name,password,id_card,user_type,phonenumber,status,del_flag,login_type,create_by,sex)
values(#{supUuid},#{deptId},#{phone},#{name},#{password},#{idCard},'05',#{phone},'1','0','1,2,3',#{createUserId},#{sex})
</insert>
<insert id= "addLinkRelation" >
INSERT INTO lk_sup_person (pro_id, uuid, sup_uuid,sup_persion_id, status)
VALUES (#{proId}, #{uuid}, #{supUuid},#{id}, '0')
</insert>
<insert id= "addFileInfo" >
insert into pt_cons_information(pro_id, uuid, from_type, information_type, information_path, information_name,
information_size, information_user_id, information_user_name, is_active)
values(#{proId}, #{uuid}, #{fromType}, #{informationType}, #{filePath}, #{fileName}, #{fileSize},
#{createUserId}, #{createUser}, '1')
</insert>
<insert id= "insertRoleLink" >
insert into sys_user_role(user_id, role_id)
values(#{id}, #{roleId})
</insert>
<update id= "updateSupervisionUnit" >
2025-02-10 18:18:55 +08:00
update pt_sup_info_data
2025-01-16 16:16:53 +08:00
set sup_name = #{unitName},
sup_address = #{unitAddress},
legal_name = #{corporateName},
legal_phone = #{corporatePhone},
sup_code = #{socialUnifiedCreditCode}
2025-02-10 18:18:55 +08:00
where id = #{supId}
2025-01-16 16:16:53 +08:00
</update>
<update id= "updateLinkRelation" >
update lk_pro_sup
set status = #{status}
where pro_id = #{proId} and sup_uuid = #{supUuid}
</update>
2025-03-27 14:30:26 +08:00
<select id= "getLinkStatus" resultType= "java.lang.String" >
select status
from lk_pro_sup
where pro_id = #{proId} and sup_uuid = #{supUuid}
</select>
2025-01-16 16:16:53 +08:00
<update id= "updatePersonEnterInfo" >
update pt_sup_person
<set >
<if test= "name != null and name != ''" >
sup_name = #{name},
</if>
<if test= "idCard != null and idCard != ''" >
id_card = #{idCard},
</if>
<if test= "sex != null and sex != ''" >
sex = #{sex},
</if>
<if test= "age != null" >
age = #{age},
</if>
<if test= "phone != null and phone != ''" >
phone = #{phone},
</if>
<if test= "postName != null and postName != ''" >
post = #{postName},
</if>
<if test= "faceUrl != null and faceUrl != ''" >
face_path = #{faceUrl},
</if>
</set>
where sup_user_id = #{id}
</update>
<update id= "updateSupIsExist" >
update lk_sup_person
set is_exist_file = '1'
where uuid = #{uuid}
</update>
2025-02-10 18:18:55 +08:00
<update id= "updateUnitUser" >
update pt_sup_info
set comm_user_name=#{directorsName}
where sup_id=#{supId}
</update>
<update id= "updateUserInfo" >
update sys_user
set nick_name=#{directorsName}
where user_id=#{commUserId}
</update>
<update id= "updateProUserInfo" >
update pt_project_info
set sup_user_name=#{directorsName}
where sup_user_id=#{supId}
</update>
2025-01-16 16:16:53 +08:00
<delete id= "deleteSupervisionUnitById" >
2025-02-10 18:18:55 +08:00
update pt_sup_info_data set is_active = '0' where id in
<foreach item= "addressId" collection= "array" open= "(" separator= "," close= ")" >
#{addressId}
</foreach>
</delete>
<delete id= "delSupervisionUnitUser" >
2025-01-16 16:16:53 +08:00
update pt_sup_info set is_active = '0' where sup_id in
<foreach item= "addressId" collection= "array" open= "(" separator= "," close= ")" >
#{addressId}
</foreach>
</delete>
2025-02-13 16:36:47 +08:00
<delete id= "delUser" >
delete from sys_user where id_card = #{idCard} and phonenumber = #{phone} and del_flag = '0'
</delete>
<delete id= "delPtSupPerson" >
2025-05-27 18:22:57 +08:00
delete from lk_sup_person where pro_id = #{proId} and sup_uuid = #{supUuid} and sup_persion_id = #{userId}
2025-02-13 18:03:17 +08:00
</delete>
<delete id= "delLkSupPerson" >
2025-02-14 15:48:21 +08:00
delete from pt_sup_person where sup_user_id = #{supId} and is_active = 1
2025-02-13 16:36:47 +08:00
</delete>
2025-03-27 14:30:26 +08:00
<update id= "deleteUserById" >
update sys_user set del_flag = '2' where user_id=#{userId}
</update>
2025-01-16 16:16:53 +08:00
<select id= "listSupervisionUnit" resultType= "com.bonus.project.domain.SupervisionUnit" >
select (@rowNum := @rowNum + 1) as exportId,
2025-02-10 18:18:55 +08:00
psi.id as supId,
2025-01-16 16:16:53 +08:00
psi.uuid as supUuid,
psi.sup_name as unitName,
psi.sup_address as unitAddress,
psi.legal_name as corporateName,
psi.legal_phone as corporatePhone,
psi.sup_code as socialUnifiedCreditCode,
2025-02-10 18:18:55 +08:00
IFNULL(us.num ,0) userNum,
IFNULL(pro.num ,0) status
from (select @rowNum := 0) r,
pt_sup_info_data psi
2025-01-16 16:16:53 +08:00
left join (
2025-02-10 18:18:55 +08:00
select count(1) num , sup_unit_id
from pt_project_info
2025-02-11 16:04:00 +08:00
where sup_unit_id is not null and sup_unit_id!='' and is_active=1
2025-02-10 18:18:55 +08:00
GROUP BY sup_unit_id
)pro on pro.sup_unit_id=psi.id
left join(
select count(1) num ,unit_id
FROM pt_sup_info
2025-02-11 16:04:00 +08:00
where is_active=1
2025-02-10 18:18:55 +08:00
GROUP BY unit_id
)us on us.unit_id=psi.id
2025-01-16 16:16:53 +08:00
where psi.is_active = 1
<if test= "unitName != null and unitName != ''" >
and psi.sup_name like concat('%',#{unitName},'%')
</if>
</select>
2025-02-10 18:18:55 +08:00
<select id= "listSupervisionUnitUser" resultType= "com.bonus.project.domain.SupervisionUnit" >
select (@rowNum := @rowNum + 1) as exportId,
2025-02-11 16:04:00 +08:00
sup_id supId,
comm_user_id commUserId,
comm_user_name directorsName,
comm_user_phone directorsPhone,
comm_user_code commUserCode,
IFNULL(pro.num,0) status
2025-02-10 18:18:55 +08:00
from (select @rowNum := 0) r,
2025-02-11 16:04:00 +08:00
pt_sup_info psi
left join (
select count(1) num , sup_user_id
from pt_project_info
where sup_user_id is not null and sup_user_id!='' and is_active=1
GROUP BY sup_user_id
)pro on pro.sup_user_id=psi.sup_id
2025-02-10 18:18:55 +08:00
where is_active=1 and unit_id=#{unitId}
<if test= "directorsName != null and directorsName != ''" >
2025-02-11 16:04:00 +08:00
and comm_user_name like concat('%',#{directorsName},'%')
2025-02-10 18:18:55 +08:00
</if>
</select>
2025-01-16 16:16:53 +08:00
<select id= "listSupEntry" resultType= "com.bonus.project.domain.SupervisionOfAdmission" >
SELECT
psi.sup_id as supId,
psi.uuid as supUuid,
ppi.pro_name as proName,
psi.sup_name as supName,
psi.sup_code as supCode,
psi.legal_name as legalName,
psi.legal_phone as legalPhone,
2025-02-14 16:55:56 +08:00
#{dataType} as status,
2025-01-16 16:16:53 +08:00
lps.status as intoStatus,
lps.task_id as taskId,
lps.proc_inst_id as procInsId,
ppi.pro_id as proId
FROM lk_pro_sup lps
LEFT JOIN pt_sup_info psi ON lps.sup_uuid = psi.uuid AND psi.is_active = '1'
LEFT JOIN pt_project_info ppi ON lps.pro_id = ppi.pro_id AND ppi.is_active = '1'
WHERE lps.status != '0'
<if test= "status != null and status != '' and status != 1 and status != '1' and status != '2' and status != 2 " >
AND lps.status = #{status}
</if>
2025-02-14 16:55:56 +08:00
<if test= 'dataType==1' >
AND lps.proc_inst_id IN (
<foreach collection= "proInsId" item= "item" separator= "," >
#{item}
</foreach>
)
</if>
<if test= "status==2 or status=='2'" >
and lps.status = #{status}
</if>
2025-01-16 16:16:53 +08:00
<if test= "proName != null and proName != ''" >
2025-04-02 10:18:06 +08:00
AND ppi.pro_name like concat('%',#{proName},'%')
2025-01-16 16:16:53 +08:00
</if>
<if test= "supName != null and supName != ''" >
2025-05-27 10:37:03 +08:00
AND ppi.sup_unit_name like concat('%',#{supName},'%')
2025-01-16 16:16:53 +08:00
</if>
<if test= "proId != null and proId != ''" >
AND ppi.pro_id = #{proId}
</if>
</select>
<select id= "isExistUser" resultType= "java.lang.Integer" >
select count(1) from sys_user where phonenumber = #{phone} and del_flag = '0'
</select>
<select id= "getDeptId" resultType= "java.lang.String" >
select dept_id from sys_dept where type = '1' and del_flag = '0'
</select>
<select id= "getRoleId" resultType= "java.lang.String" >
select role_id from sys_role where role_key = 'sup_person' and del_flag = '0'
</select>
2025-02-10 18:18:55 +08:00
<select id= "getUnitNameById" resultType= "java.lang.Integer" >
select count(1)
from pt_sup_info_data
where is_active=1 and id!=#{supId} and sup_name=#{supName}
</select>
<select id= "getSupProNum" resultType= "com.bonus.project.domain.Project" >
select pro_id proId,sup_unit_name supervisorUnit
from pt_project_info
where is_active=1 and sup_unit_id=#{id}
</select>
<select id= "getSupProUserNum" resultType= "com.bonus.project.domain.Project" >
select pro_id proId,sup_user_name supervisorUnit
from pt_project_info
where is_active=1 and sup_user_id=#{id}
</select>
<select id= "getUserMapper" resultType= "java.lang.Integer" >
select count(1)
from pt_sup_info
where is_active=1 and unit_id=#{id}
</select>
2025-02-13 18:03:17 +08:00
<select id= "getsupUserId" resultType= "java.lang.Integer" >
2025-02-14 15:48:21 +08:00
select sup_persion_id
from lk_sup_person
2025-05-27 18:22:57 +08:00
where pro_id = #{proId} and sup_uuid = #{supUuid} and sup_persion_id = #{userId}
2025-02-13 18:03:17 +08:00
</select>
2025-03-27 14:30:26 +08:00
<select id= "getUserIdBySupId" resultType= "java.lang.String" >
select comm_user_id userId
from pt_sup_info
where sup_id=#{supId}
</select>
2025-05-27 18:22:57 +08:00
<select id= "getPtSupPerson" resultType= "com.bonus.project.domain.SupervisorPerson" >
select
(@rowNum := @rowNum + 1) as exportId,
lsp.pro_id as proId,
lsp.sup_uuid as supUuid,
lsp.uuid as uuid,
lsp.status as status,
2025-05-29 18:13:44 +08:00
lsp.into_status as intoStatus,
lsp.out_status as outStatus,
lsp.task_id_into as taskId,
lsp.proc_inst_id_into as procInsId,
2025-05-27 18:22:57 +08:00
sup_user_id as id,
sup_name as name,
if(sex = '0','男','女') as sex,
age,
phone,
id_card as idCard,
sdd.dict_label as postName,
face_path as faceUrl
from (select @rowNum := 0) r,pt_sup_person psp
2025-05-29 18:13:44 +08:00
left join (select sup_persion_id,pro_id,sup_uuid,uuid,status,into_status,out_status,task_id_into,proc_inst_id_into from lk_sup_person lpsp where lpsp.pro_id = #{proId}) lsp
2025-05-27 18:22:57 +08:00
on
psp.sup_user_id = lsp.sup_persion_id
left join sys_dict_data sdd on sdd.dict_value = psp.post and sdd.dict_type = 'sys_sup_post' and sdd.status = '0'
2025-06-03 09:46:26 +08:00
where psp.is_active = '1' and lsp.status = '0'
2025-05-27 18:22:57 +08:00
<if test= "supId != null and supId != ''" >
and lsp.sup_uuid = (select uuid from pt_sup_info where
sup_id = #{supId})
</if>
<if test= "supUuid != null and supUuid != ''" >
and lsp.sup_uuid = #{supUuid}
</if>
<if test= "supervisorName != null and supervisorName != ''" >
and psp.sup_name like concat('%', #{supervisorName}, '%')
</if>
<if test= "name != null and name != ''" >
and psp.sup_name like concat('%', #{name}, '%')
</if>
2025-05-29 18:13:44 +08:00
<if test= "intoStatus != null and intoStatus != ''" >
and lsp.into_status = #{intoStatus}
</if>
2025-05-27 18:22:57 +08:00
</select>
2025-05-29 18:13:44 +08:00
<select id= "getPtSupPersonAll" resultType= "com.bonus.project.domain.SupervisorPerson" >
2025-05-27 18:22:57 +08:00
select
(@rowNum := @rowNum + 1) as exportId,
lsp.pro_id as proId,
lsp.sup_uuid as supUuid,
lsp.uuid as uuid,
lsp.status as status,
2025-05-29 18:13:44 +08:00
lsp.into_status as intoStatus,
lsp.out_status as outStatus,
lsp.task_id_into as taskId,
lsp.proc_inst_id_into as procInsId,
2025-05-27 18:22:57 +08:00
sup_user_id as id,
sup_name as name,
if(sex = '0','男','女') as sex,
age,
phone,
id_card as idCard,
sdd.dict_label as postName,
face_path as faceUrl
from (select @rowNum := 0) r,pt_sup_person psp
left join lk_sup_person lsp
on
psp.sup_user_id = lsp.sup_persion_id
left join sys_dict_data sdd on sdd.dict_value = psp.post and sdd.dict_type = 'sys_sup_post' and sdd.status = '0'
2025-06-03 09:46:26 +08:00
where psp.is_active = '1' and lsp.status = '0'
2025-05-29 18:13:44 +08:00
<if test= "supId != null and supId != ''" >
and lsp.sup_uuid = (select uuid from pt_sup_info where
sup_id = #{supId})
</if>
<if test= "supervisorName != null and supervisorName != ''" >
and psp.sup_name like concat('%', #{supervisorName}, '%')
</if>
<if test= "name != null and name != ''" >
and psp.sup_name like concat('%', #{name}, '%')
</if>
<if test= "intoStatus != null and intoStatus != ''" >
and lsp.into_status = #{intoStatus}
</if>
</select>
<select id= "getPtSupPersonInto" resultType= "com.bonus.project.domain.SupervisorPerson" >
select
lsp.pro_id as proId,
lsp.sup_uuid as supUuid,
lsp.uuid as uuid,
lsp.status as status,
lsp.into_status as intoStatus,
lsp.out_status as outStatus,
lsp.task_id_out as taskId,
lsp.proc_inst_id_out as procInsId,
sup_user_id as id,
sup_name as name,
if(sex = '0','男','女') as sex,
age,
phone,
id_card as idCard,
sdd.dict_label as postName,
face_path as faceUrl
from pt_sup_person psp
left join (select sup_persion_id,pro_id,sup_uuid,uuid,status,into_status,out_status,proc_inst_id_out,task_id_out from lk_sup_person lpsp where lpsp.pro_id = #{proId}) lsp
on
psp.sup_user_id = lsp.sup_persion_id
left join sys_dict_data sdd on sdd.dict_value = psp.post and sdd.dict_type = 'sys_sup_post' and sdd.status = '0'
where psp.is_active = '1' and lsp.into_status='3' and lsp.out_status in ('0','5')
2025-05-27 18:22:57 +08:00
<if test= "supId != null and supId != ''" >
and lsp.sup_uuid = (select uuid from pt_sup_info where
sup_id = #{supId})
</if>
2025-05-29 18:13:44 +08:00
<if test= "supUuid != null and supUuid != ''" >
and lsp.sup_uuid = #{supUuid}
</if>
2025-05-27 18:22:57 +08:00
<if test= "supervisorName != null and supervisorName != ''" >
and psp.sup_name like concat('%', #{supervisorName}, '%')
</if>
<if test= "name != null and name != ''" >
and psp.sup_name like concat('%', #{name}, '%')
</if>
2025-05-29 18:13:44 +08:00
<if test= "outStatus != null and outStatus != ''" >
and lsp.out_status = #{outStatus}
</if>
</select>
<select id= "getPtSupPersonIntoAll" resultType= "com.bonus.project.domain.SupervisorPerson" >
select
lsp.pro_id as proId,
lsp.sup_uuid as supUuid,
lsp.uuid as uuid,
lsp.status as status,
lsp.into_status as intoStatus,
lsp.out_status as outStatus,
lsp.task_id_out as taskId,
lsp.proc_inst_id_out as procInsId,
sup_user_id as id,
sup_name as name,
if(sex = '0','男','女') as sex,
age,
phone,
id_card as idCard,
sdd.dict_label as postName,
face_path as faceUrl
from pt_sup_person psp
left join lk_sup_person lsp
on
psp.sup_user_id = lsp.sup_persion_id
left join sys_dict_data sdd on sdd.dict_value = psp.post and sdd.dict_type = 'sys_sup_post' and sdd.status = '0'
where psp.is_active = '1' and lsp.into_status='3' and lsp.out_status in ('0','5')
<if test= "supId != null and supId != ''" >
and lsp.sup_uuid = (select uuid from pt_sup_info where
sup_id = #{supId})
</if>
<if test= "supervisorName != null and supervisorName != ''" >
and psp.sup_name like concat('%', #{supervisorName}, '%')
</if>
<if test= "name != null and name != ''" >
and psp.sup_name like concat('%', #{name}, '%')
</if>
<if test= "outStatus != null and outStatus != ''" >
and lsp.out_status = #{outStatus}
</if>
</select>
<select id= "getPtSupPersonOut" resultType= "com.bonus.project.domain.SupervisorPerson" >
select
lsp.pro_id as proId,
lsp.sup_uuid as supUuid,
lsp.uuid as uuid,
lsp.status as status,
lsp.into_status as intoStatus,
lsp.out_status as outStatus,
lsp.task_id_out as taskId,
lsp.proc_inst_id_out as procInsId,
sup_user_id as id,
sup_name as name,
if(sex = '0','男','女') as sex,
age,
phone,
id_card as idCard,
sdd.dict_label as postName,
face_path as faceUrl
from pt_sup_person psp
left join (select sup_persion_id,pro_id,sup_uuid,uuid,status,into_status,out_status,task_id_out,proc_inst_id_out from lk_sup_person lpsp where lpsp.pro_id = #{proId}) lsp
on
psp.sup_user_id = lsp.sup_persion_id
left join sys_dict_data sdd on sdd.dict_value = psp.post and sdd.dict_type = 'sys_sup_post' and sdd.status = '0'
where psp.is_active = '1' and lsp.out_status in ('1','2','3','4')
<if test= "supId != null and supId != ''" >
and lsp.sup_uuid = (select uuid from pt_sup_info where
sup_id = #{supId})
</if>
<if test= "supUuid != null and supUuid != ''" >
and lsp.sup_uuid = #{supUuid}
</if>
<if test= "supervisorName != null and supervisorName != ''" >
and psp.sup_name like concat('%', #{supervisorName}, '%')
</if>
<if test= "name != null and name != ''" >
and psp.sup_name like concat('%', #{name}, '%')
</if>
<if test= "outStatus != null and outStatus != ''" >
and lsp.out_status = #{outStatus}
</if>
</select>
<select id= "getPtSupPersonOutAll" resultType= "com.bonus.project.domain.SupervisorPerson" >
select
lsp.pro_id as proId,
lsp.sup_uuid as supUuid,
lsp.uuid as uuid,
lsp.status as status,
lsp.into_status as intoStatus,
lsp.out_status as outStatus,
lsp.task_id_out as taskId,
lsp.proc_inst_id_out as procInsId,
sup_user_id as id,
sup_name as name,
if(sex = '0','男','女') as sex,
age,
phone,
id_card as idCard,
sdd.dict_label as postName,
face_path as faceUrl
from pt_sup_person psp
left join lk_sup_person lsp
on
psp.sup_user_id = lsp.sup_persion_id
left join sys_dict_data sdd on sdd.dict_value = psp.post and sdd.dict_type = 'sys_sup_post' and sdd.status = '0'
where psp.is_active = '1' and lsp.out_status in ('1','2','3','4')
<if test= "supId != null and supId != ''" >
and lsp.sup_uuid = (select uuid from pt_sup_info where
sup_id = #{supId})
</if>
<if test= "supervisorName != null and supervisorName != ''" >
and psp.sup_name like concat('%', #{supervisorName}, '%')
</if>
<if test= "name != null and name != ''" >
and psp.sup_name like concat('%', #{name}, '%')
</if>
<if test= "outStatus != null and outStatus != ''" >
and lsp.out_status = #{outStatus}
</if>
</select>
<select id= "getPtSupPersonList" resultType= "com.bonus.project.domain.SupervisorPerson" >
select
lsp.pro_id as proId,
lsp.sup_uuid as supUuid,
lsp.uuid as uuid,
lsp.status as status,
lsp.into_status as intoStatus,
lsp.out_status as outStatus,
<if test= "type == '出场'" >
lsp.task_id_out as taskId,
lsp.proc_inst_id_out as procInsId,
</if>
<if test= "type == '入场'" >
lsp.task_id_into as taskId,
lsp.proc_inst_id_into as procInsId,
</if>
sup_user_id as id,
sup_name as name,
if(sex = '0','男','女') as sex,
age,
phone,
id_card as idCard,
sdd.dict_label as postName,
face_path as faceUrl
from pt_sup_person psp
left join lk_sup_person lsp
on
psp.sup_user_id = lsp.sup_persion_id
left join sys_dict_data sdd on sdd.dict_value = psp.post and sdd.dict_type = 'sys_sup_post' and sdd.status = '0'
where psp.is_active = '1'
<if test= "supervisorName != null and supervisorName != ''" >
and psp.sup_name like concat('%', #{supervisorName}, '%')
</if>
<if test= "name != null and name != ''" >
and psp.sup_name like concat('%', #{name}, '%')
</if>
<if test= "type == '入场'" >
<if test= "status != null and status != '' and status != 1 and status != '1' and status != '2' and status != 2 " >
and lsp.into_status = #{status}
</if>
<if test= "status==2 or status=='2'" >
and lsp.into_status = #{status}
</if>
<if test= 'dataType==1' >
AND lsp.proc_inst_id_into IN (
<foreach collection= "proInsId" item= "item" separator= "," >
#{item}
</foreach>
)
</if>
</if>
<if test= "type == '出场'" >
and lsp.out_status != '0' and lsp.into_status = '3'
<if test= "status != null and status != '' and status != 1 and status != '1' and status != '2' and status != 2 " >
and lsp.out_status = #{status}
</if>
<if test= "status==2 or status=='2'" >
and lsp.out_status = #{status}
</if>
<if test= 'dataType==1' >
AND lsp.proc_inst_id_out IN (
<foreach collection= "proInsId" item= "item" separator= "," >
#{item}
</foreach>
)
</if>
</if>
2025-05-27 18:22:57 +08:00
</select>
2025-03-27 14:30:26 +08:00
2025-02-10 18:18:55 +08:00
2025-05-27 10:37:03 +08:00
</mapper>