nxdt-system/bonus-modules/bonus-project/src/main/resources/mapper/system/SubMapper.xml

176 lines
7.2 KiB
XML
Raw Normal View History

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.SubMapper">
<insert id="addUser" keyProperty="id" useGeneratedKeys="true">
insert into sys_user(user_name, dept_id, id_card, nick_name, phonenumber, password, user_type, parent_uuid,
status, del_flag, create_by, create_time, login_type)
values (#{subPrincipalPhone}, #{deptId}, #{subIdCard}, #{subPrincipal}, #{subPrincipalPhone}, #{password},
'03', #{uuid}, '0', '0', #{createPerson}, #{createTime}, '1,2,3')
</insert>
<insert id="addInfo">
insert into pt_sub_info(uuid, cont_name, sub_name, sub_address, legal_name, legal_phone,
sub_code, sub_user_id, sub_user_name, sub_user_phone, create_id,
create_user, is_active)
values (#{uuid}, #{consName}, #{subName}, #{address},
#{corporateName}, #{corporatePhone}, #{socialUnifiedCreditCode}, #{id},
#{subPrincipal}, #{subPrincipalPhone}, #{createPersonId}, #{createPerson}, '1')
</insert>
<insert id="addLink">
insert into lk_cont_sub(uuid, cont_uuid, pro_id, sup_uuid, sub_uuid)
values (#{uuid}, #{consUuid}, #{proId}, #{supUuid}, #{subUuid})
</insert>
<insert id="addRoleUserLink">
insert into sys_user_role(user_id, role_id)
values (#{id}, '8')
</insert>
2025-01-22 15:08:21 +08:00
<insert id="addSubPersonToPcp" useGeneratedKeys="true" keyProperty="id">
insert into pt_cons_person(cons_name,phone,id_card,is_active)
values(#{name},#{phone},#{idCard},'1')
</insert>
<insert id="addSubPersonToLk">
insert into lk_cont_person(cons_persion_id,cont_uuid,sub_uuid,pro_id,is_exist_file,uuid)
values(#{id},#{consUuid},#{subUuid},#{proId},'0',#{uuid})
</insert>
2025-01-16 16:16:53 +08:00
<delete id="delSub">
update pt_sub_info
set is_active = '0'
where sub_id = #{id}
</delete>
2025-01-22 15:08:21 +08:00
<delete id="delSubPersonToPcp">
delete
from pt_cons_person
where cons_user_id = (select cons_persion_id
from lk_cont_person
where uuid = (select uuid from pt_sub_info where sub_id = #{id}))
</delete>
<delete id="delSubPersonToLk">
delete
from lk_cont_person
where uuid = (select uuid from pt_sub_info where sub_id = #{id})
</delete>
2025-01-16 16:16:53 +08:00
<select id="checkIsExistSubName" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM pt_sub_info psi
left join lk_cont_sub lck
on lck.uuid = psi.uuid
WHERE psi.sub_name = #{subName}
and psi.sub_code = #{socialUnifiedCreditCode}
and lck.pro_id = #{proId}
and lck.cont_uuid = #{consUuid}
</select>
<select id="enterPersonList" resultType="com.bonus.project.domain.SubPerson">
select
ppi.pro_name as proName,
pci.cont_name as consName,
psi.sub_name as subName,
lcp.uuid as uuid,
lcp.cont_uuid as contUuid,
lcp.cont_uuid as consUuid,
lcp.sub_uuid as subUuid,
lcp.pro_id as proId,
pcp.cons_name as name,
if(pcp.sex = 0,'男','女') as sex,
pcp.age as age,
pcp.phone as phone,
pcp.native as nativePlace,
pcp.id_card as idCard,
pcp.nation as nation,
pcp.home_address as homeAddress,
pcp.address as currentAddress,
sdd.dict_label as postName,
pcp.work_type as specialJobType,
pcp.face_path as facePath,
2025-02-14 16:55:56 +08:00
sdd1.dict_label as statusName,
2025-01-16 16:16:53 +08:00
<if test="type == '出场'">
lcp.task_id_out as taskId,
lcp.proc_inst_id_out as procInsId,
lcp.out_status as intoStatus,
</if>
<if test="type == '入场'">
lcp.task_id as taskId,
lcp.proc_inst_id as procInsId,
lcp.into_status as intoStatus,
</if>
2025-02-14 16:55:56 +08:00
#{dataType} as status
2025-01-16 16:16:53 +08:00
from pt_cons_person pcp
left join lk_cont_person lcp on lcp.cons_persion_id = pcp.cons_user_id
left join sys_dict_data sdd on sdd.dict_value = pcp.post and sdd.dict_type = 'sys_cons_post' and sdd.status ='0'
left join sys_dict_data sdd1 on sdd1.dict_value = lcp.into_status and sdd1.dict_type = 'sys_approval_state' and
sdd1.status ='0'
left join pt_project_info ppi on ppi.pro_id = lcp.pro_id and ppi.is_active = '1'
left join pt_cont_info pci on pci.uuid = lcp.cont_uuid and pci.is_active = '1'
left join pt_sub_info psi on psi.uuid = lcp.sub_uuid and pci.is_active = '1'
where pcp.is_active = '1'
<if test="userType != '00' ">
and lcp.pro_id = #{proId}
</if>
<if test="name != null and name != '' ">
and pcp.cons_name like concat('%',#{name},'%')
</if>
<if test="proName != null and proName != '' ">
and lcp.pro_id = #{proName}
</if>
<if test="consName != null and consName != '' ">
and lcp.cont_uuid = #{consName}
</if>
<if test="subName != null and subName != '' ">
and lcp.sub_uuid = #{subName}
</if>
<if test="consUuid != null and consUuid != '' ">
and lcp.cont_uuid = #{consUuid}
</if>
<if test="enterType == '承包-分包审核' || enterType == '业主-分包审核'">
and lcp.sub_uuid is not null and lcp.sub_uuid != ''
</if>
<if test="enterType == '承包审核'">
and (lcp.sub_uuid IS NULL OR lcp.sub_uuid = '')
</if>
<if test="type == '入场'">
<if test="status != null and status != '' and status != 1 and status != '1' and status != '2' and status != 2 ">
and lcp.into_status = #{status}
</if>
2025-02-14 16:55:56 +08:00
<if test="status==2 or status=='2'">
and lpc.into_status = #{status}
</if>
<if test='dataType==1'>
AND lcp.proc_inst_id IN (
<foreach collection="proInsId" item="item" separator=",">
#{item}
</foreach>
)
</if>
2025-01-16 16:16:53 +08:00
</if>
<if test="type == '出场'">
and lcp.out_status != '0' and lcp.into_status = '3'
<if test="status != null and status != '' and status != 1 and status != '1' and status != '2' and status != 2 ">
and lcp.out_status = #{status}
</if>
2025-02-14 16:55:56 +08:00
<if test="status==2 or status=='2'">
and lpc.out_status = #{status}
</if>
<if test='dataType==1'>
AND lcp.proc_inst_id_out IN (
<foreach collection="proInsId" item="item" separator=",">
#{item}
</foreach>
)
</if>
2025-01-16 16:16:53 +08:00
</if>
2025-02-14 16:55:56 +08:00
2025-01-16 16:16:53 +08:00
</select>
<select id="checkIsExistPersonName" resultType="com.bonus.system.api.domain.SysUser">
SELECT user_id as userId,
id_card as idCard
FROM sys_user
where phonenumber = #{subPrincipalPhone}
and del_flag = '0'
</select>
</mapper>