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

570 lines
25 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.bonus.project.mapper.OutsourcingProMapper">
<select id="selectPostList" resultType="com.bonus.project.domain.Project">
select
(@rowNum := @rowNum + 1) as exportId,
ppi.pro_id as proId,
ppi.pro_name as proName,
ppi.pro_user_name as proLeader,
ppi.pro_user_phone as proLeaderPhone,
sdd.dict_label as proType,
ppi.plan_start_time as startDate,
ppi.plan_end_time as endDate,
sdd1.dict_label as proStatus,
ppi.create_user as createPerson,
ppi.create_time as createTime
from (select @rowNum := 0) r,pt_project_info ppi
left join sys_dict_data sdd on sdd.dict_value = ppi.pro_type and sdd.dict_type = 'sys_pro_type' and
sdd.status = '0'
left join sys_dict_data sdd1 on sdd1.dict_value = ppi.pro_status and sdd1.dict_type = 'sys_pro_status' and
sdd1.status = '0'
where ppi.is_outsource = #{isOutsourcing} and ppi.is_active = '1' and ppi.pro_status != '1'
<if test="proName != null and proName != ''">
and ppi.pro_name like concat('%', #{proName}, '%')
</if>
<if test="proLeader != null and proLeader != ''">
and ppi.pro_user_name like concat('%', #{proLeader}, '%')
</if>
<if test="createPerson != null and createPerson != ''">
and ppi.create_user like concat('%', #{createPerson}, '%')
</if>
<if test="proType != null and proType != ''">
and ppi.pro_type = #{proType}
</if>
<if test="startDate != null and startDate != '' ">
and DATE(ppi.create_time) between #{startDate} and #{endDate}
</if>
<if test="proStatus != null and proStatus != ''">
and ppi.pro_status = #{proStatus}
</if>
order by ppi.create_time desc
</select>
<select id="listSupervisor" resultType="com.bonus.project.domain.SupervisoryUnit">
select
psi.sup_id as id,
ppi.pro_name as proName,
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,
psi.comm_user_name as directorsName,
psi.comm_user_phone as directorsPhone
from pt_sup_info psi
left join lk_pro_sup lps on psi.uuid = lps.sup_uuid
left join pt_project_info ppi on lps.pro_id = ppi.pro_id
where psi.is_active = '1'
<if test="proId != null and proId != ''">
and lps.pro_id = #{proId}
</if>
<if test="supUuid != null and supUuid != ''">
and psi.uuid = #{supUuid}
</if>
</select>
<select id="listSupervisorPerson" 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,
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 (select sup_persion_id,pro_id,sup_uuid,uuid 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'
<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>
</select>
<select id="listSupervisorPersonById" resultType="com.bonus.project.domain.SupervisorPerson">
select sup_name as name,
if(sex = '0', '男', '女') as sex,
age,
phone,
id_card as idCard,
psp.post as postName,
face_path as faceUrl,
psp.create_time as createTime,
psp.sup_user_id as id,
lsp.uuid as uuid
from pt_sup_person psp
left join lk_sup_person lsp on psp.sup_user_id = lsp.sup_persion_id
where psp.is_active = '1'
and uuid = #{uuid}
</select>
<select id="selectConArr" resultType="com.bonus.project.domain.ContractorEntity">
select
pci.cont_id as id,
pci.uuid,
pci.cont_name as consName,
pci.cont_address as address,
pci.legal_name as corporateName,
pci.legal_phone as corporatePhone,
pci.sup_code as socialUnifiedCreditCode
from pt_cont_info pci
left join lk_pro_cont lpc on pci.uuid = lpc.cont_uuid
where pci.is_active = '1' and lpc.pro_id = #{proId}
</select>
<select id="getConsDetailsInfo" resultType="com.bonus.common.core.web.domain.AjaxResult">
select
pci.cont_id as id,
pci.uuid,
pci.cont_name as consName,
pci.cont_address as address,
pci.legal_name as corporateName,
pci.legal_phone as corporatePhone,
pci.sup_code as socialUnifiedCreditCode,
lpc.admission_date as admissionDate,
lpc.departure_date as departureDate,
pci.comm_usert_name as leaderName,
pci.comm_usert_phone as leaderPhone
from pt_cont_info pci
left join lk_pro_cont lpc on lpc.cont_uuid = pci.uuid
LEFT JOIN pt_project_info ppi on ppi.pro_id = lpc.pro_id
where pci.is_active = '1' and pci.uuid = #{consUuid} and lpc.pro_id = #{proId}
</select>
<select id="getSubList" resultType="com.bonus.project.domain.listOfSubcontractors">
select
psc.sub_id as id,
lcs.pro_id as proId,
lcs.cont_uuid as consUuid,
lcs.sup_uuid as supUuid,
lcs.sub_uuid as subUuid,
lcs.uuid as uuid,
psc.sub_name as subName,
psc.sub_address as address,
psc.legal_name as corporateName,
psc.legal_phone as corporatePhone,
psc.sub_code as socialUnifiedCreditCode,
psc.sub_user_name as subPrincipal,
psc.sub_user_phone as subPrincipalPhone,
lcs.admission_date as admissionDate,
lcs.departure_date as departureDate,
case when (lcs.into_status = '3' and lcs.out_status != '3') then '已入场'
when (lcs.out_status = '3') then '已出场' else '未入场' end as status
from pt_sub_info psc
left join lk_cont_sub lcs on psc.uuid = lcs.sub_uuid
where psc.is_active = '1' and lcs.pro_id = #{proId}
and lcs.cont_uuid = #{consUuid}
<if test="subName != null and subName != ''">
and psc.sub_name like concat('%', #{subName}, '%')
</if>
<if test="status != null and status != ''">
<if test="status == '1' or status == 1">
and lcs.into_status = '3' and lcs.out_status != '3'
</if>
<if test="status == '2' or status == 2">
and lcs.out_status = '3'
</if>
</if>
<if test="startDate != null and startDate != ''">
and psc.create_time between #{startDate} and #{endDate}
</if>
</select>
<select id="getProProfile" resultType="com.bonus.project.domain.ProMaterial">
select
pmt.material_name as fileName,
pmt.material_path as filePath,
pmt.material_type as fileType,
pmt.create_time as createTime,
pmt.create_user as name,
pmt.material_size as fileSize
from pt_pro_material pmt
where pmt.pro_id = #{proId} and pmt.is_active = '1'
<if test="name != null and name != ''">
and pmt.create_user like concat('%', #{name}, '%')
</if>
<if test="fileName != null and fileName != ''">
and pmt.material_name like concat('%', #{fileName}, '%')
</if>
<if test="startDate != null and startDate != ''">
and pmt.create_time between #{startDate} and #{endDate}
</if>
</select>
<select id="getConsPersonList" resultType="com.bonus.project.domain.SubPerson">
select
(@rowNum := @rowNum + 1) as exportId,
pcp.cons_user_id as id,
re.uuid as uuid,
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 faceUrl,
re.admission_date as admissionDate,
re.departure_date as departureDate,
ppi.pro_name as proName
from (select @rowNum := 0) r,pt_cons_person pcp
left join (select cons_persion_id,pro_id,cont_uuid,sub_uuid,uuid,admission_date,departure_date from
lk_cont_person lcp where
lcp.pro_id = #{proId})re on re.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 pt_project_info ppi on re.pro_id = ppi.pro_id
where pcp.is_active = '1' and re.cont_uuid =#{consUuid}
and (re.sub_uuid is null or re.sub_uuid = '')
<if test="name != null and name != ''">
and pcp.cons_name like concat('%', #{name}, '%')
</if>
<if test="admissionDate != null and admissionDate != ''">
and re.admission_date between #{admissionDate} and #{departureDate}
</if>
<if test="status == '1' or status == 1">
having admissionDate is not null and departureDate is null
</if>
<if test="status == '2' or status == 2">
having departureDate is not null
</if>
</select>
<select id="getConsEquipList" resultType="com.bonus.project.domain.Equipment">
select
(@rowNum := @rowNum + 1) as exportId,
ppt.tools_id as id,
ppt.uuid as uuid,
ppt.tools_name as equipName,
ppt.tools_model as model,
ppt.tools_unit as unit,
ppt.tools_num as num,
if(ppt.tools_type = '1','普通设备','特殊设备') as equipType,
ppt.detection_time as detectionTime,
ppt.is_detection as isForceDetection,
ppt.admission_date as approachDate
from (select @rowNum := 0) r,pt_pro_tools ppt
where ppt.is_active = '1' and ppt.pro_id = #{proId} and ppt.cont_uuid = #{consUuid}
<if test="equipName != null and equipName != ''">
and ppt.tools_name like concat('%', #{equipName}, '%')
</if>
</select>
<select id="getConsMaterialsList" resultType="com.bonus.project.domain.ProMaterial">
select
(@rowNum := @rowNum + 1) as exportId,
pci.information_id as id,
pci.information_name as fileName,
pci.information_path as filePath,
pci.information_size as fileSize,
pci.create_time as createTime,
pci.information_user_name as name
from (select @rowNum := 0) r, pt_cons_information pci
left join lk_cont_file lcf on lcf.uuid = pci.uuid
where pci.is_active = '1' and lcf.pro_id = #{proId} and lcf.cont_uuid =#{consUuid}
and pci.from_type = '5' and pci.information_type = '5'
<if test="fileName != null and fileName != ''">
and pci.information_name like concat('%', #{fileName}, '%')
</if>
<if test="name != null and name != ''">
and pci.information_user_name like concat('%', #{name}, '%')
</if>
<if test="startDate != null and startDate != ''">
and pci.create_time between #{startDate} and #{endDate}
</if>
</select>
<select id="getConstructionPersonnelDetails" resultType="com.bonus.project.domain.SubPerson">
select pcp.cons_user_id as id,
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.work_type as workType,
pcp.face_path as faceUrl,
lcp.admission_date as admissionDate,
lcp.departure_date as departureDate,
lcp.uuid ,
if(lcp.admission_date is null and lcp.departure_date is null, '未入场', if(lcp.admission_date is not null
and
lcp.departure_date is null,
'已入场', '已离场')) as status
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'
where pcp.is_active = '1'
and lcp.uuid = #{uuid}
</select>
<select id="getFile" resultType="com.bonus.common.entity.SysFileInfo">
select information_id as id,
information_name as fileName,
information_path as filePath,
information_name as name,
information_path as url,
information_size as fileSize,
DATE(upload_time) as updateTime,
DATE(create_time) as createTime
from pt_cons_information pci
where is_active = '1'
and from_type = #{fromType}
and information_type = #{informationType}
and uuid = #{uuid}
</select>
<select id="getEquipDetails" resultType="com.bonus.project.domain.Equipment">
select
ppt.tools_id as id,
ppt.tools_name as equipName,
ppt.tools_model as model,
ppt.tools_unit as unit,
ppt.tools_num as num,
ppt.uuid,
ppt.tools_type as equipType,
ppt.detection_time as detectionTime,
ppt.is_detection as isForceDetection,
ppt.next_detection_time as nextDetectionTime,
ppt.admission_date as approachDate
from pt_pro_tools ppt
where ppt.tools_id = #{id}
</select>
<select id="getSubDetailsInfo" resultType="com.bonus.common.core.web.domain.AjaxResult">
select
psc.sub_name as subName,
psc.sub_address as address,
psc.legal_name as corporateName,
psc.legal_phone as corporatePhone,
psc.sub_code as socialUnifiedCreditCode,
lcs.admission_date as admissionDate,
lcs.departure_date as departureDate,
lcs.task_id_out as taskId,
lcs.exit_reason as exitReason,
lcs.exit_reason as reason,
ppi.pro_user_name as leaderName,
ppi.pro_user_phone as leaderPhone
from pt_sub_info psc
left join lk_cont_sub lcs on psc.uuid = lcs.sub_uuid
LEFT JOIN pt_project_info ppi on ppi.pro_id = lcs.pro_id
where psc.is_active = '1' and lcs.uuid = #{uuid}
</select>
<select id="getSubPersonList" resultType="com.bonus.project.domain.SubPerson">
select
(@rowNum := @rowNum + 1) as exportId,
pcp.cons_user_id as id,
pcp.cons_name as name,
if(pcp.sex = '0','男','女') as sex,
re.uuid as uuid,
re.pro_id as proId,
re.cont_uuid as consUuid,
re.sub_uuid as subUuid,
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 faceUrl,
re.admission_date as admissionDate,
re.departure_date as departureDate,
ppi.pro_name as proName,
if(re.admission_date is null and re.departure_date is null, '未入场', if(re.admission_date is not null
and
re.departure_date is null,
'已入场', '已离场')) as status
from (select @rowNum := 0) r,pt_cons_person pcp
left join
(select cons_persion_id,pro_id,cont_uuid,sub_uuid,uuid,admission_date,departure_date,is_exist_file from
lk_cont_person lcp
<if test="userType != '00'">
where lcp.pro_id = #{proId}
<if test="userType != '01'">
and lcp.cont_uuid = #{consUuid}
</if>
</if>
)re on re.cons_persion_id = pcp.cons_user_id
left join pt_project_info ppi on re.pro_id = ppi.pro_id
left join sys_dict_data sdd on sdd.dict_value = pcp.post and sdd.dict_type = 'sys_cons_post' and sdd.status =
'0'
where pcp.is_active = '1'
<if test="consUuid != null and consUuid != ''">
and re.cont_uuid = #{consUuid}
</if>
<if test="fileIsActive!=null and fileIsActive!=''">
and re.is_exist_file=#{fileIsActive}
</if>
<if test="subUuid != null and subUuid != ''">
and re.sub_uuid = #{subUuid}
</if>
<if test="name != null and name != ''">
and pcp.cons_name like concat('%', #{name}, '%')
</if>
<if test="admissionDate != null and admissionDate != ''">
and re.admission_date between #{admissionDate} and #{departureDate}
</if>
<if test="status == '1' or status == 1">
having admissionDate is not null and departureDate is null
</if>
<if test="status == '0' or status == 0">
having departureDate is not null
</if>
</select>
<select id="getSubPersonnelDetails" resultType="com.bonus.project.domain.SubPerson">
select pcp.cons_user_id as id,
lcp.uuid,
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.work_type as workType,
pcp.face_path as faceUrl,
lcp.admission_date as admissionDate,
lcp.departure_date as departureDate,
lcp.exit_reason as reason,
if(lcp.admission_date is null and lcp.departure_date is null, '未入场', if(lcp.admission_date is not null
and
lcp.departure_date is null,
'已入场', '已离场')) as status
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'
where pcp.is_active = '1' and lcp.uuid = #{uuid}
</select>
<select id="getUnitPersonFile" resultType="com.bonus.common.entity.SysFileInfo">
select information_id as id,
information_name as fileName,
information_path as filePath,
information_name as name,
information_path as url,
information_size as fileSize,
DATE(upload_time) as updateTime,
DATE(create_time) as createTime
from pt_cons_information pci
where is_active = '1'
and from_type = #{fromType}
and information_type = #{informationType}
and uuid = #{uuid}
</select>
<select id="getProNum" resultType="java.lang.String">
select count(1) from pt_project_info where (pro_status = '3' or pro_status = '2') and is_active = '1'
</select>
<select id="getPersonNum" resultType="java.lang.String">
SELECT
count(lcp.uuid)
FROM
lk_cont_person lcp
LEFT JOIN pt_project_info ppi ON lcp.pro_id = ppi.pro_id
LEFT JOIN pt_cons_person pcp ON lcp.cons_persion_id = pcp.cons_user_id
WHERE
pcp.is_active = '1'
AND ppi.is_active = '1' and lcp.into_status = '3' and lcp.out_status != '3'
AND (ppi.pro_status = '3' or ppi.pro_status = '2')
<if test="proId != null and proId != ''">
and lcp.pro_id = #{proId}
</if>
</select>
<select id="getSpecialPersonNum" resultType="java.lang.String">
SELECT
count(lcp.uuid)
FROM
lk_cont_person lcp
LEFT JOIN pt_project_info ppi ON lcp.pro_id = ppi.pro_id
LEFT JOIN pt_cons_person pcp ON lcp.cons_persion_id = pcp.cons_user_id
WHERE
pcp.is_active = '1'
AND ppi.is_active = '1' and lcp.into_status = '3' and lcp.out_status != '3'
AND ppi.pro_status = '3' and pcp.post = '1'
<if test="proId != null and proId != ''">
and lcp.pro_id = #{proId}
</if>
</select>
<select id="getEquipNum" resultType="java.lang.String">
SELECT
sum( ppt.tools_num )
FROM
pt_pro_tools ppt
LEFT JOIN pt_project_info ppi ON ppt.pro_id = ppi.pro_id
WHERE
ppt.is_active = '1' and ppi.is_active = '1'
AND ppt.STATUS = '3'
AND (ppi.pro_status = '3' or ppi.pro_status = '2')
<if test="proId != null and proId != ''">
and ppt.pro_id = #{proId}
</if>
</select>
<select id="getSpecialEquipNum" resultType="java.lang.String">
select sum(ppt.tools_num) from pt_pro_tools ppt
left join pt_project_info ppi on ppt.pro_id = ppi.pro_id
where ppt.is_active = '1' and ppi.is_active = '1' and ppt.tools_type = '2' and ppt.status = '3'
and (ppi.pro_status = '3' or ppi.pro_status = '2')
<if test="proId != null and proId != ''">
and ppt.pro_id = #{proId}
</if>
</select>
<select id="getProList" resultType="com.bonus.project.domain.IndexBean">
select
pro_id as id,
pro_name as proName,
if(pro_status = '3','在建中','筹备中') as proStatus
from pt_project_info
where is_active = '1' and (pro_status = '3' or pro_status = '2')
<if test="proId != null and proId != ''">
and pro_id = #{proId}
</if>
</select>
<insert id="addAnnotations" parameterType="com.bonus.project.domain.SubPerson">
insert into pt_check_mark(uuid,task_id,mark_type,mark_user_id)
values (
#{uuid},
#{taskId},
#{type},
#{userId}
)
</insert>
<select id="getAnnotationsByTaskIdAndUserId" resultType="string" >
select uuid from pt_check_mark where task_id = #{taskId} and mark_user_id = #{userId}
<if test="type != null">
and mark_type = #{type}
</if>
</select>
<select id="getIdCardByPhone" resultType="java.lang.String">
select id_card
from sys_user
where del_flag=0 and user_name=#{phone}
limit 1
</select>
</mapper>