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.

140 lines
6.7 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.DgComplianceInvestigationMapper">
<select id="list" resultType="com.daqing.financial.guarantee.model.response.DgComplianceInvestigationResponse">
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,i.operation_status AS
operation_status,i.audit_status AS audit_status,i.id AS iid,i.role_id AS role_id,b.business_status AS business_status
FROM dg_compliance_investigation AS i
LEFT JOIN dg_apply_amount_info AS a
ON a.id = i.business_id
LEFT JOIN crms_customer AS c
ON a.company_id = c.id
LEFT JOIN dg_business_process_status AS b
ON b.business_id = a.id
WHERE c.del_or_not = 0
AND (i.user_id = #{userId} OR i.user_id IS NULL)
AND i.role_id IN
<foreach collection="roleIds" open="(" separator="," close=")" item="roleId">
#{roleId}
</foreach>
<if test="cr.status != null">
AND i.audit_status = #{cr.status}
</if>
<if test="cr.codeOrName != null and cr.codeOrName != ''">
AND (a.business_code LIKE CONCAT('%',#{cr.codeOrName},'%') OR c.name LIKE CONCAT('%',#{cr.codeOrName},'%'))
</if>
ORDER BY a.create_time DESC
</select>
<!-- 将要导出的excel数据列表 -->
<select id="listExcel" resultType="com.daqing.financial.guarantee.model.response.DgComplianceInvestigationResponse">
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,i.operation_status AS
operation_status,i.audit_status AS audit_status,b.business_status AS business_status
FROM dg_compliance_investigation AS i
LEFT JOIN dg_apply_amount_info AS a
ON a.id = i.business_id
LEFT JOIN crms_customer AS c
ON a.company_id = c.id
LEFT JOIN dg_business_process_status AS b
ON b.business_id = a.id
WHERE c.del_or_not = 0
AND i.id IN
<foreach collection="ids" open="(" separator="," close=")" item="id">
#{id}
</foreach>
ORDER BY a.create_time DESC
</select>
<!-- 调查 -->
<update id="survey">
UPDATE dg_compliance_investigation
SET user_id = #{userId},file_url = #{fileUrl},opinion = #{opinion},operation_status = #{operationStatus},audit_status = #{auditStatus},update_time = #{date}
WHERE id = #{iid}
</update>
<!-- 插入数据的样板 -->
<select id="getComplianceInvestigation" parameterType="integer" resultType="com.daqing.framework.domain.guarantee.DgComplianceInvestigation">
SELECT company_id,business_id FROM dg_compliance_investigation WHERE id = #{iid}
</select>
<!-- 指派之后将法规经理与该条数据绑定 -->
<update id="updateAssign">
UPDATE dg_compliance_investigation
SET user_id = #{userId},operation_status = #{operationStatus},audit_status = #{auditStatus}
WHERE id = #{iid}
</update>
<!-- 新增一条指派数据 -->
<insert id="assign" parameterType="com.daqing.framework.domain.guarantee.DgComplianceInvestigation">
INSERT INTO dg_compliance_investigation (company_id,user_id,operation_status,audit_status,create_time,update_time,business_id,role_id)
VALUES (#{dci.companyId},#{dci.userId},#{dci.operationStatus},#{dci.auditStatus},#{dci.createTime},#{dci.updateTime},#{dci.businessId},#{dci.roleId})
</insert>
<!-- 审核 -->
<update id="check">
UPDATE dg_compliance_investigation
SET opinion = #{opinion},audit_status = #{auditStatus},operation_status = #{operationStatus},
update_time = #{date},user_id = #{userId}
WHERE id = #{iid}
</update>
<!-- 上传附件 -->
<update id="uploadAccessory">
UPDATE dg_enclosure_info
SET other_file = #{fileUrl}
WHERE business_id = #{businessId}
</update>
<!-- 调查完之后将指派完的数据更新为待处理 -->
<update id="updateToAudit">
UPDATE dg_compliance_investigation
SET operation_status = #{operationStatus}
WHERE business_id = #{businessId}
AND role_id = #{roleId}
</update>
<!-- 根据业务id获取当前角色对应的数据的操作状态 -->
<select id="getOperationStatusByBusinessId" resultType="integer">
SELECT operation_status FROM dg_compliance_investigation WHERE business_id = #{businessId} AND role_id = #{roleId}
</select>
<!-- 根据id查询合规调查表详情 -->
<select id="queryDgComplianceInvestigation" parameterType="integer" resultType="com.daqing.framework.domain.guarantee.DgComplianceInvestigation">
SELECT file_url,opinion
FROM dg_compliance_investigation
WHERE id = #{iid}
</select>
<!-- 新增一条工作会记录 -->
<insert id="insertWorkConferenceConsider" parameterType="com.daqing.framework.domain.guarantee.DgWorkConferenceConsider">
INSERT INTO dg_work_conference_consider (company_id,business_id,role_id,audit_status,operation_status,create_time,update_time)
VALUES (#{wcc.companyId},#{wcc.businessId},#{wcc.roleId},#{wcc.auditStatus},#{wcc.operationStatus},#{wcc.createTime},#{wcc.updateTime})
</insert>
<!-- 改变所有业务id相同的审核状态,用于拒绝或者驳回 -->
<update id="updateAuditStatusByBusinessId">
UPDATE dg_compliance_investigation SET audit_status = #{auditStatus} WHERE business_id = #{businessId}
</update>
<!-- 根据id改变当前数据的操作状态 -->
<update id="updateOperationStatusById">
UPDATE dg_compliance_investigation SET operation_status = #{operationStatus},opinion = #{opinion} WHERE id = #{id}
</update>
<!-- 根据业务id改变当前数据的业务状态 -->
<update id="updateBusinessStatusByBusinessId">
UPDATE dg_business_process_status SET business_status = #{businessStatus} WHERE business_id = #{businessId}
</update>
<select id="getGuaranteeId" resultType="integer">
SELECT id FROM dg_guarantee_assign_user WHERE business_id = #{businessId} AND role_id = #{roleId}
</select>
<select id="getDgAssetsInvestigationId" resultType="integer">
SELECT id FROM dg_assets_investigation WHERE business_id = #{businessId} AND role_id = #{roleId}
</select>
</mapper>