You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
9.1 KiB

<?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.daqing.financial.guarantee.mapper.DgLoanCommitteeConsiderMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.daqing.framework.domain.guarantee.DgLoanCommitteeConsider">
<id column="id" property="id"/>
<result column="company_id" property="companyId"/>
<result column="consider_id" property="considerId"/>
<result column="status" property="status"/>
<result column="agreed_items" property="agreedItems"/>
<result column="additional_items" property="additionalItems"/>
<result column="loan_money" property="loanMoney"/>
<result column="loan_tern" property="loanTern"/>
<result column="agree_person" property="agreePerson"/>
<result column="disagree_person" property="disagreePerson"/>
<result column="file" property="file"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<select id="list" resultType="com.daqing.financial.guarantee.model.response.DgLoanCommitteeConsiderResponse">
SELECT a.id AS business_id,a.business_code AS business_code,a.business_type AS business_type,a.apply_amount AS apply_amount,
a.apply_time AS apply_time,a.create_time AS create_time,c.name AS name,c.phone AS phone,l.operating_status
AS operating_status,l.status AS status,l.id AS id,l.role_id AS role_id,b.business_status AS business_status
FROM dg_loan_committee_consider AS l
LEFT JOIN dg_apply_amount_info AS a
ON a.id = l.business_id
left join dg_business_company c on c.business_id = a.id
/* LEFT JOIN crms_company_customer AS cc
ON a.company_id = cc.id
LEFT JOIN crms_customer AS c
ON cc.customer_id = c.id*/
LEFT JOIN dg_business_process_status AS b
ON b.business_id = a.id
WHERE /*c.del_or_not = 0*/
/*AND*/ (l.consider_id = #{userId} OR l.consider_id IS NULL)
AND l.role_id IN
<foreach collection="roleIds" open="(" separator="," close=")" item="roleId">
#{roleId}
</foreach>
<if test="codeOrName != null and codeOrName != ''">
AND (a.business_code LIKE CONCAT('%',#{codeOrName},'%') OR c.name LIKE CONCAT('%',#{codeOrName},'%'))
</if>
ORDER BY a.create_time DESC
</select>
<select id="excelList" resultType="com.daqing.financial.guarantee.model.response.DgLoanCommitteeConsiderResponse">
SELECT a.business_code AS business_code,a.business_type AS business_type,a.apply_amount AS apply_amount,
a.apply_time AS apply_time,a.create_time AS create_time,c.name AS name,c.phone AS phone,l.operating_status
AS operating_status,l.status AS status,b.business_status AS business_status
FROM dg_loan_committee_consider AS l
LEFT JOIN dg_apply_amount_info AS a
ON a.id = l.business_id
left join dg_business_company c on c.business_id = a.id
/* LEFT JOIN crms_company_customer AS cc
ON a.company_id = cc.id
LEFT JOIN crms_customer AS c
ON cc.customer_id = c.id*/
LEFT JOIN dg_business_process_status AS b
ON b.business_id = a.id
WHERE /*c.del_or_not = 0*/
/*AND*/ l.id IN
<foreach collection="ids" open="(" separator="," close=")" item="id">
#{id}
</foreach>
ORDER BY a.create_time DESC
</select>
<update id="check">
UPDATE dg_loan_committee_consider
SET consider_id = #{userId},status = #{status},operating_status = #{operatingStatus},create_time = #{date},
agreed_items = #{lr.agreedItems},additional_items = #{lr.additionalItems},loan_money = #{lr.loanMoney},
loan_tern = #{lr.loanTern},agree_person = #{lr.agreePerson},disagree_person = #{lr.disagreePerson},
file = #{lr.fileUrl},passing_time = #{lr.passingTime}
WHERE id = #{lr.id}
</update>
<!-- 保存抽取的所有的评委名单 -->
<update id="TheJudgesDrawn">
UPDATE dg_loan_committee_consider
SET all_person = #{allPerson}
WHERE business_id = #{businessId}
</update>
<!-- 获取评委名单 -->
<select id="getJudges" parameterType="integer" resultType="string">
SELECT all_person FROM dg_loan_committee_consider WHERE id = #{id}
</select>
<!-- 获取AB角、资产调查、信息调查、合规调查的审批意见、审批人和时间 -->
<select id="getAuditOpinion" parameterType="integer" resultType="com.daqing.framework.domain.guarantee.po.AuditOpinionPO">
SELECT a.apply_content AS a_audit_opinion,a.emp_id AS a_emp_id,a.update_time AS a_time,
b.apply_content AS b_audit_opinion,b.emp_id AS b_emp_id,b.update_time AS b_time,
ass.apply_content AS asset_audit_opinion,ass.emp_id AS asset_emp_id,ass.update_time AS asset_time,
m.remark AS message_audit_opinion,m.emp_id AS message_emp_id,m.update_time AS message_time,
c.opinion AS regulation_audit_opinion,c.user_id AS regulation_emp_id,c.update_time AS regulation_time
FROM dg_assets_investigation AS ass
LEFT JOIN dg_message_investigation AS m
ON ass.business_id = m.business_id
LEFT JOIN dg_compliance_investigation AS c
ON c.business_id = ass.business_id
LEFT JOIN (SELECT business_id,emp_id,apply_content,update_time FROM dg_guarantee_assign_user
WHERE business_id = #{businessId} AND role_id = 59) AS a
ON ass.business_id = a.business_id
LEFT JOIN (SELECT business_id,emp_id,apply_content,update_time FROM dg_guarantee_assign_user
WHERE business_id = #{businessId} AND role_id = 60) AS b
ON ass.business_id = b.business_id
WHERE ass.business_id = #{businessId}
AND ass.role_id = 64
AND m.role_id = 67
AND c.role_id = 70
</select>
<select id="query" parameterType="integer" resultType="com.daqing.framework.domain.guarantee.DgLoanCommitteeConsider">
SELECT agreed_items,additional_items,loan_money,loan_tern,agree_person,disagree_person,file,passing_time,refuse_opinion
FROM dg_loan_committee_consider
WHERE id = #{id}
</select>
<select id="getDgLoanCommitteeConsider" parameterType="integer" resultType="com.daqing.framework.domain.guarantee.DgLoanCommitteeConsider">
SELECT business_id,company_id FROM dg_loan_committee_consider WHERE id = #{id}
</select>
<!-- 改变所有业务id相同的审核状态,用于拒绝或者驳回 -->
<update id="updateAuditStatusByBusinessId">
UPDATE dg_loan_committee_consider SET status = #{status} WHERE business_id = #{businessId}
</update>
<!-- 根据id改变当前数据的操作状态 -->
<update id="updateOperationStatusById">
UPDATE dg_loan_committee_consider SET operating_status = #{operatingStatus},refuse_opinion = #{refuseOpinion} WHERE id = #{id}
</update>
<!-- 根据id获取当前数据的审核状态 -->
<select id="getAuditStatus" parameterType="integer" resultType="integer">
SELECT status FROM dg_loan_committee_consider WHERE id = #{id}
</select>
<!-- 根据业务id和角色id更新担保函数据 -->
<update id="updateGuaranteeLetterAssignUser">
UPDATE dg_guarantee_letter_assign_user SET status = #{auditStatus},operating_status = #{operatingStatus},audit_opinion = #{auditOpinion}
WHERE business_id = #{businessId} AND role_id = #{roleId}
</update>
<!-- 根据id绑定用户id -->
<update id="updateLoanCommitteeConsiderUserIdById">
UPDATE dg_loan_committee_consider SET consider_id = #{userId} WHERE id = #{id}
</update>
<!-- 根据业务id和角色id判断该条数据是否存在 -->
<select id="countGuaranteeLetterAssignUser" resultType="integer">
SELECT COUNT(id) FROM dg_guarantee_letter_assign_user WHERE business_id = #{businessId} AND role_id = #{roleId}
</select>
<select id="selectLoanCommitteeList" resultType="com.daqing.financial.guarantee.model.response.DgNoticeListResponse">
SELECT au.id,au.role_id,au.company_id,au.business_id,ai.business_code,ai.business_type,ai.apply_amount,ai.apply_time,au.create_time,
au.status,au.operating_status,cc.name,cc.phone,ps.business_status
FROM dg_loan_committee_consider au
left join dg_apply_amount_info ai on au.business_id = ai.id
left join crms_company_customer ccl on ai.company_id = ccl.id
left join crms_customer cc on cc.id = ccl.customer_id
left JOIN dg_business_process_status ps ON ps.business_id = au.business_id
<where>
au.role_id in
<foreach collection="roleIdlist" open="(" separator="," close=")" item="id">
#{id}
</foreach>
<if test="userId != null and userId != ''">
AND (au.consider_id =#{userId} or au.consider_id is null or au.consider_id ='')
</if>
AND au.operating_status=1
</where>
</select>
</mapper>