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.

227 lines
11 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">
<resultMap id="BaseResultMap" type="com.daqing.framework.domain.guarantee.DgComplianceInvestigation">
<id column="id" property="id" />
<result column="company_id" property="companyId" />
<result column="user_id" property="userId" />
<result column="role_id" property="roleId" />
<result column="business_id" property="businessId" />
<result column="file_url" property="fileUrl" />
<result column="opinion" property="opinion" />
<result column="operation_status" property="operationStatus" />
<result column="audit_status" property="auditStatus" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<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_company_customer AS cc
ON a.company_id = cc.id
4 years ago
LEFT JOIN crms_customer AS c
ON c.id = cc.customer_id
LEFT JOIN dg_business_process_status AS b
ON b.business_id = a.id
4 years ago
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}
4 years ago
</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_company_customer AS cc
ON a.company_id = cc.id
LEFT JOIN crms_customer AS c
ON c.id = cc.customer_id
LEFT JOIN dg_business_process_status AS b
ON b.business_id = a.id
WHERE c.del_or_not = 0
4 years ago
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}
4 years ago
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}
4 years ago
</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>
4 years ago
<!-- 根据业务id获取当前数据的审核状态 -->
<select id="getAuditStatusByBusinessId" resultType="integer">
SELECT audit_status FROM dg_compliance_investigation WHERE business_id = #{businessId} AND role_id = #{roleId}
4 years ago
</select>
<!-- 根据id查询合规调查表详情 -->
<select id="queryDgComplianceInvestigation" parameterType="integer" resultType="com.daqing.framework.domain.guarantee.DgComplianceInvestigation">
SELECT file_url,opinion AS opinion
FROM dg_compliance_investigation
4 years ago
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}
4 years ago
</update>
4 years ago
<!-- 根据业务id和角色id获取担保id,用于获取担保信息 -->
4 years ago
<select id="getGuaranteeId" resultType="integer">
SELECT id FROM dg_guarantee_assign_user WHERE business_id = #{businessId} AND role_id = #{roleId}
</select>
4 years ago
<!-- 根据业务id和角色id获取资产id,用于获取资产信息 -->
4 years ago
<select id="getDgAssetsInvestigationId" resultType="integer">
SELECT id FROM dg_assets_investigation WHERE business_id = #{businessId} AND role_id = #{roleId}
</select>
4 years ago
<!-- 根据业务id和角色id判断工作会该条数据是否存在 -->
<select id="countWorkConferenceConsider" resultType="integer">
SELECT COUNT(id) FROM dg_work_conference_consider WHERE business_id = #{businessId} AND role_id = #{roleId}
</select>
<!-- 根据业务id和角色id判断合规调查该条数据是否存在 -->
<select id="countComplianceInvestigation" resultType="integer">
SELECT COUNT(id) FROM dg_compliance_investigation WHERE business_id = #{businessId} AND role_id = #{roleId}
</select>
4 years ago
<!-- 更新工作会的审核状态和操作状态 -->
<update id="updateWorkConferenceConsider">
UPDATE dg_work_conference_consider SET audit_status = #{auditStatus},operation_status = #{operationStatus}
WHERE business_id = #{businessId} AND role_id = #{roleId}
</update>
4 years ago
<!-- 根据业务id获取业务流程表中的最新操作角色名称(dept_name字段) -->
<select id="getAuditProcessLatestProcessIdByBusinessId" parameterType="integer" resultType="integer">
SELECT process_id FROM dg_audit_process WHERE business_id = #{businessId}
4 years ago
AND create_time = (SELECT MAX(create_time) FROM dg_audit_process WHERE business_id = #{businessId})
</select>
4 years ago
<!-- 根据id绑定用户id -->
<update id="updateDgComplianceInvestigationUserIdById">
UPDATE dg_compliance_investigation SET user_id = #{userId} WHERE id = #{id}
</update>
<!-- 根据业务id获取当前业务的信息专员、资产专员以及AB角的用户id -->
<select id="getAttacheAndABByBusinessId" parameterType="integer" resultType="com.daqing.framework.domain.guarantee.po.AttacheAndABUserIdPO">
SELECT (SELECT id FROM dg_guarantee_assign_user WHERE business_id = #{businessId} AND role_id = 59) AS a_user_id,
(SELECT id FROM dg_guarantee_assign_user WHERE business_id = #{businessId} AND role_id = 60) AS b_user_id,
a.id,m.id
FROM dg_assets_investigation AS a
LEFT JOIN dg_message_investigation AS m
ON a.business_id = m.business_id
WHERE a.role_id = 63
AND m.role_id = 66
AND a.business_id = #{businessId}
</select>
<select id="selectComplianceList" resultType="com.daqing.financial.guarantee.model.response.DgNoticeListResponse">
SELECT au.id,au.role_id,ai.business_code,au.create_time
FROM dg_compliance_investigation au
left join dg_apply_amount_info ai on au.business_id = ai.id
<where>
au.role_id in
<foreach collection="roleIdlist" open="(" separator="," close=")" item="id">
#{id}
</foreach>
<if test="userId != null and userId != ''">
AND (au.user_id =#{userId} or au.user_id is null or au.user_id ='')
</if>
AND au.operation_status=1
</where>
</select>
<!-- 根据业务id获取C角名称 -->
<select id="getCUserId" parameterType="integer" resultType="integer">
SELECT user_id FROM dg_compliance_investigation WHERE business_id = #{businessId} AND role_id = 69
</select>
</mapper>