257 lines
9.7 KiB
XML
257 lines
9.7 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.gzrn.rnbmw.basic.dao.SubContractorDao">
|
||
|
|
<!--分包商查询-->
|
||
|
|
<select id="getSubList" resultType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean">
|
||
|
|
select
|
||
|
|
pc.org_name as orgName,
|
||
|
|
bs.ID as id,
|
||
|
|
bs.SUB_NAME as subName,
|
||
|
|
bs.REPRESENT as represent,
|
||
|
|
bs.RE_CONTACT as reContact,
|
||
|
|
bs.ID_CARD_JUST_NAME as idCardJustName,
|
||
|
|
bs.ID_CARD_JUST_URL as idCardJustURL,
|
||
|
|
bs.ID_CARD_BACK_NAME as idCardBackName,
|
||
|
|
bs.ID_CARD_BACK_URL as idCardBackURL,
|
||
|
|
bs.SIGNATURE_NAME as signatureName,
|
||
|
|
bs.SIGNATURE_URL as signatureURL,
|
||
|
|
bs.SEAL_NAME as sealName,
|
||
|
|
bs.SEAL_URL as sealURL,
|
||
|
|
bs.BUSINESS_NAME as businessName,
|
||
|
|
bs.BUSINESS_URL as businessURL,
|
||
|
|
bs.SAFETY_NAME as safetyName,
|
||
|
|
bs.SAFETY_URL as safetyURL,
|
||
|
|
su.USERNAME as auditor,
|
||
|
|
bs.ADDRESS as address,
|
||
|
|
bs.AUDIT_REMARK as auditRemark,
|
||
|
|
bs.AUDIT_RESULT as auditResult,
|
||
|
|
bs.AUDIT_TIME as auditTime,
|
||
|
|
bs.UPDATE_TIME as updateTime,
|
||
|
|
suser.USERNAME as uploader,
|
||
|
|
bs.UPLOAD_TIME as uploadTime
|
||
|
|
from
|
||
|
|
bm_subcontractor bs
|
||
|
|
LEFT JOIN sys_user suser on suser.ID = bs.UPLOADER
|
||
|
|
LEFT JOIN sys_user su on su.ID=bs.AUDITOR
|
||
|
|
LEFT JOIN pm_company pc ON pc.ID = bs.COMPANY_ID
|
||
|
|
where
|
||
|
|
bs.IS_ACTIVE = 1
|
||
|
|
<if test="params != null and params != ''">
|
||
|
|
<if test="params.subName != null and params.subName != ''">
|
||
|
|
AND bs.SUB_NAME LIKE concat ('%',#{params.subName},'%')
|
||
|
|
</if>
|
||
|
|
<if test="params.represent != null and params.represent != ''">
|
||
|
|
AND bs.REPRESENT LIKE concat ('%',#{params.represent},'%')
|
||
|
|
</if>
|
||
|
|
<if test="params.companyId != null and params.companyId != '' and params.companyId != '-1'">
|
||
|
|
AND bs.COMPANY_ID = #{params.companyId}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</if>
|
||
|
|
GROUP BY bs.name,bs.ID
|
||
|
|
limit #{offset}, #{limit}
|
||
|
|
</select>
|
||
|
|
<!-- 分包商数量查询-->
|
||
|
|
<select id="getSubCount" resultType="java.lang.Integer">
|
||
|
|
SELECT COUNT(*) FROM bm_subcontractor bs
|
||
|
|
LEFT JOIN sys_user suser on suser.ID = bs.UPLOADER
|
||
|
|
where bs.IS_ACTIVE = 1
|
||
|
|
<if test="params != null and params != ''">
|
||
|
|
<if test="params.companyId != null and params.companyId != '' and params.companyId != '-1'">
|
||
|
|
AND bs.COMPANY_ID = #{params.companyId}
|
||
|
|
</if>
|
||
|
|
<if test="params.subName != null and params.subName != ''">
|
||
|
|
AND bs.SUB_NAME LIKE concat ('%',#{params.subName},'%')
|
||
|
|
</if>
|
||
|
|
<if test="params.represent != null and params.represent != ''">
|
||
|
|
AND bs.REPRESENT LIKE concat ('%',#{params.represent},'%')
|
||
|
|
</if>
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--增加分包商-->
|
||
|
|
<insert id="addSub" parameterType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean" useGeneratedKeys="true" keyProperty="id">
|
||
|
|
insert into bm_subcontractor (
|
||
|
|
SUB_NAME,
|
||
|
|
COMPANY_ID,
|
||
|
|
<if test="represent != null and represent != ''">
|
||
|
|
REPRESENT,
|
||
|
|
</if>
|
||
|
|
<if test="reContact != null and reContact != ''">
|
||
|
|
RE_CONTACT,
|
||
|
|
</if>
|
||
|
|
<if test="address != null and address != ''">
|
||
|
|
ADDRESS,
|
||
|
|
</if>
|
||
|
|
IS_ACTIVE
|
||
|
|
)
|
||
|
|
value (
|
||
|
|
#{subName},
|
||
|
|
#{companyId},
|
||
|
|
<if test="represent != null and represent != ''">
|
||
|
|
#{represent},
|
||
|
|
</if>
|
||
|
|
<if test="reContact != null and reContact != ''">
|
||
|
|
#{reContact},
|
||
|
|
</if>
|
||
|
|
<if test="address != null and address != ''">
|
||
|
|
#{address},
|
||
|
|
</if>
|
||
|
|
'1'
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
<!--根据id查找-->
|
||
|
|
<select id="getSubContractorById" resultType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean">
|
||
|
|
select
|
||
|
|
bs.ID,
|
||
|
|
pc.org_name as orgName,
|
||
|
|
bs.`SUB_NAME` as subName,
|
||
|
|
bs.REPRESENT as represent,
|
||
|
|
bs.RE_CONTACT as reContact,
|
||
|
|
bs.BUSINESS_URL as businessUrl,
|
||
|
|
bs.SEAL_URL as sealUrl,
|
||
|
|
bs.SIGNATURE_URL as signatureUrl,
|
||
|
|
bs.SAFETY_URL as safetyUrl,
|
||
|
|
bs.ID_CARD_JUST_URL as idCardJustURL,
|
||
|
|
bs.ID_CARD_BACK_URL as idCardBackURL,
|
||
|
|
bs.UPDATE_TIME as updateTime,
|
||
|
|
bs.IS_ACTIVE as isActive,
|
||
|
|
bs.ADDRESS as address,
|
||
|
|
bs.COMPANY_ID as companyId
|
||
|
|
from bm_subcontractor bs
|
||
|
|
LEFT JOIN pm_company pc ON pc.ID = bs.COMPANY_ID
|
||
|
|
where bs.IS_ACTIVE = '1'
|
||
|
|
AND bs.ID = #{id}
|
||
|
|
</select>
|
||
|
|
<!--修改-->
|
||
|
|
<update id="updateSub" parameterType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean">
|
||
|
|
update bm_subcontractor set
|
||
|
|
`SUB_NAME` = #{subName}
|
||
|
|
<if test="companyId != null and companyId != ''">
|
||
|
|
,COMPANY_ID = #{companyId}
|
||
|
|
</if>
|
||
|
|
<if test="represent != null and represent != ''">
|
||
|
|
,REPRESENT = #{represent}
|
||
|
|
</if>
|
||
|
|
<if test="reContact != null and reContact != ''">
|
||
|
|
,RE_CONTACT = #{reContact}
|
||
|
|
</if>
|
||
|
|
<if test="address != null and address != ''">
|
||
|
|
,ADDRESS = #{address}
|
||
|
|
</if>
|
||
|
|
,UPDATE_TIME = now()
|
||
|
|
WHERE ID = #{id}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<!--删除分包商-->
|
||
|
|
<update id="deleteSub">
|
||
|
|
update bm_subcontractor
|
||
|
|
set IS_ACTIVE = '0'
|
||
|
|
where ID = #{id}
|
||
|
|
</update>
|
||
|
|
<!--根据分包商查询列表-->
|
||
|
|
<select id="getSubContractorList" resultType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean">
|
||
|
|
select ID, `SUB_NAME` as subName
|
||
|
|
from bm_subcontractor
|
||
|
|
where IS_ACTIVE = '1'
|
||
|
|
</select>
|
||
|
|
<!--根据工程查找分包商-->
|
||
|
|
<select id="getSubByProId" parameterType="java.lang.String"
|
||
|
|
resultType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean">
|
||
|
|
select bs.SUB_NAME, bs.ID
|
||
|
|
from bm_sub_pro_relation bspr
|
||
|
|
LEFT JOIN bm_project bp on bp.ID = bspr.pro_id
|
||
|
|
LEFT JOIN bm_subcontractor bs on bs.ID = bspr.sub_id
|
||
|
|
where bspr.pro_id = #{proId}
|
||
|
|
and bs.IS_ACTIVE = 1
|
||
|
|
and bp.is_active = 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--根据分包商找工程-->
|
||
|
|
<select id="getProBySubId" parameterType="java.lang.String"
|
||
|
|
resultType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean">
|
||
|
|
select bp.name as pro_name, bp.ID as pro_id, bs.SUB_NAME, bs.ID
|
||
|
|
from bm_sub_pro_relation bspr
|
||
|
|
LEFT JOIN bm_project bp on bp.ID = bspr.pro_id
|
||
|
|
LEFT JOIN bm_subcontractor bs on bs.ID = bspr.sub_id
|
||
|
|
where bspr.sub_id = #{subId}
|
||
|
|
and bs.IS_ACTIVE = 1
|
||
|
|
and bp.is_active = 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="findByNameAndProId" resultType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean">
|
||
|
|
select distinct sub.ID, sub.`SUB_NAME`,r.pro_id
|
||
|
|
from bm_subcontractor sub
|
||
|
|
LEFT JOIN bm_sub_pro_relation r ON r.sub_id = sub.ID
|
||
|
|
where sub.IS_ACTIVE = 1
|
||
|
|
and sub.SUB_NAME = #{subName}
|
||
|
|
and r.pro_id = #{proId} limit 1
|
||
|
|
</select>
|
||
|
|
<!--修改审核状态-->
|
||
|
|
<update id="updateAuditStatus">
|
||
|
|
update bm_subcontractor set AUDIT_RESULT = #{auditResult},AUDITOR = #{auditor},AUDIT_TIME = #{auditTime}
|
||
|
|
<if test="auditResult != null and auditResult != ''">
|
||
|
|
,AUDIT_REMARK = #{auditRemark}
|
||
|
|
</if>
|
||
|
|
where ID = #{id} and is_active = '1'
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id="insSubContractor" parameterType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean">
|
||
|
|
update bm_subcontractor set
|
||
|
|
ID = #{id}
|
||
|
|
<if test="idCardJustName != null and idCardJustName != ''">
|
||
|
|
,ID_CARD_JUST_NAME = #{idCardJustName}
|
||
|
|
</if>
|
||
|
|
<if test="idCardJustURL != null and idCardJustURL != ''">
|
||
|
|
,ID_CARD_JUST_URL = #{idCardJustURL}
|
||
|
|
</if>
|
||
|
|
<if test="idCardBackName != null and idCardBackName != ''">
|
||
|
|
,ID_CARD_BACK_NAME = #{idCardBackName}
|
||
|
|
</if>
|
||
|
|
<if test="idCardBackURL != null and idCardBackURL != ''">
|
||
|
|
,ID_CARD_BACK_URL = #{idCardBackURL}
|
||
|
|
</if>
|
||
|
|
<if test="signatureName != null and signatureName != ''">
|
||
|
|
,SIGNATURE_NAME = #{signatureName}
|
||
|
|
</if>
|
||
|
|
<if test="signatureURL != null and signatureURL != ''">
|
||
|
|
,SIGNATURE_URL = #{signatureURL}
|
||
|
|
</if>
|
||
|
|
<if test="sealName != null and sealName != ''">
|
||
|
|
,SEAL_NAME = #{sealName}
|
||
|
|
</if>
|
||
|
|
<if test="sealURL != null and sealURL != ''">
|
||
|
|
,SEAL_URL = #{sealURL}
|
||
|
|
</if>
|
||
|
|
<if test="businessName != null and businessName != ''">
|
||
|
|
,BUSINESS_NAME = #{businessName}
|
||
|
|
</if>
|
||
|
|
<if test="businessURL != null and businessURL != ''">
|
||
|
|
,BUSINESS_URL = #{businessURL}
|
||
|
|
</if>
|
||
|
|
<if test="safetyName != null and safetyName != ''">
|
||
|
|
,SAFETY_NAME = #{safetyName}
|
||
|
|
</if>
|
||
|
|
<if test="safetyURL != null and safetyURL != ''">
|
||
|
|
,SAFETY_URL = #{safetyURL}
|
||
|
|
</if>
|
||
|
|
<if test="isActive != null and isActive != ''">
|
||
|
|
,IS_ACTIVE = #{isActive}
|
||
|
|
</if>
|
||
|
|
<if test="uploader != null and uploader != ''">
|
||
|
|
,UPLOADER = #{uploader}
|
||
|
|
</if>
|
||
|
|
,UPDATE_TIME = now()
|
||
|
|
,UPLOAD_TIME = now()
|
||
|
|
WHERE ID = #{id}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="getSubByName" resultType="com.bonus.gzrn.rnbmw.basic.entity.SubContractorBean">
|
||
|
|
SELECT bs.ID as id,bs.SUB_NAME AS subName
|
||
|
|
FROM bm_subcontractor bs
|
||
|
|
WHERE bs.SUB_NAME= #{subName} and bs.IS_ACTIVE = 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
</mapper>
|