新增涉疑交易明细查询导出并补充对手方证件信息

This commit is contained in:
wkc
2026-03-27 17:31:11 +08:00
parent 5e968c8716
commit cf36b5f05a
28 changed files with 961 additions and 5 deletions

View File

@@ -25,6 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="customerAccountNo" column="CUSTOMER_ACCOUNT_NO" />
<result property="customerBank" column="customer_bank" />
<result property="customerReference" column="customer_reference" />
<result property="customerCertNo" column="customer_cert_no" />
<result property="customerSocialCreditCode" column="customer_social_credit_code" />
<result property="userMemo" column="USER_MEMO" />
<result property="bankComments" column="BANK_COMMENTS" />
<result property="bankTrxNumber" column="BANK_TRX_NUMBER" />
@@ -51,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LE_ACCOUNT_NAME, LE_ACCOUNT_NO, ACCOUNTING_DATE_ID, ACCOUNTING_DATE,
TRX_DATE, CURRENCY, AMOUNT_DR, AMOUNT_CR, AMOUNT_BALANCE,
CASH_TYPE, CUSTOMER_LE_ID, CUSTOMER_ACCOUNT_NAME, CUSTOMER_ACCOUNT_NO,
customer_bank, customer_reference, USER_MEMO, BANK_COMMENTS,
customer_bank, customer_reference, customer_cert_no, customer_social_credit_code, USER_MEMO, BANK_COMMENTS,
BANK_TRX_NUMBER, BANK, TRX_FLAG, TRX_TYPE, EXCEPTION_TYPE,
internal_flag, batch_id, batch_sequence, CREATE_DATE, created_by,
meta_json, no_balance, begin_balance, end_balance,
@@ -383,7 +385,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LE_ACCOUNT_NAME, LE_ACCOUNT_NO, ACCOUNTING_DATE_ID, ACCOUNTING_DATE,
TRX_DATE, CURRENCY, AMOUNT_DR, AMOUNT_CR, AMOUNT_BALANCE,
CASH_TYPE, CUSTOMER_LE_ID, CUSTOMER_ACCOUNT_NAME, CUSTOMER_ACCOUNT_NO,
customer_bank, customer_reference, USER_MEMO, BANK_COMMENTS,
customer_bank, customer_reference, customer_cert_no, customer_social_credit_code, USER_MEMO, BANK_COMMENTS,
BANK_TRX_NUMBER, BANK, TRX_FLAG, TRX_TYPE, EXCEPTION_TYPE,
internal_flag, batch_id, batch_sequence, CREATE_DATE, created_by,
meta_json, no_balance, begin_balance, end_balance,
@@ -395,7 +397,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.leAccountName}, #{item.leAccountNo}, #{item.accountingDateId}, #{item.accountingDate},
#{item.trxDate}, #{item.currency}, #{item.amountDr}, #{item.amountCr}, #{item.amountBalance},
#{item.cashType}, #{item.customerLeId}, #{item.customerAccountName}, #{item.customerAccountNo},
#{item.customerBank}, #{item.customerReference}, #{item.userMemo}, #{item.bankComments},
#{item.customerBank}, #{item.customerReference}, #{item.customerCertNo}, #{item.customerSocialCreditCode}, #{item.userMemo}, #{item.bankComments},
#{item.bankTrxNumber}, #{item.bank}, #{item.trxFlag}, #{item.trxType}, #{item.exceptionType},
#{item.internalFlag}, #{item.batchId}, #{item.batchSequence}, #{item.createDate}, #{item.createdBy},
#{item.metaJson}, #{item.noBalance}, #{item.beginBalance}, #{item.endBalance},

View File

@@ -33,6 +33,21 @@
select="selectRiskHitTagsByScope"/>
</resultMap>
<resultMap id="SuspiciousTransactionItemResultMap" type="com.ruoyi.ccdi.project.domain.vo.CcdiProjectSuspiciousTransactionItemVO">
<id property="bankStatementId" column="bankStatementId"/>
<result property="trxDate" column="trxDate"/>
<result property="suspiciousPersonName" column="suspiciousPersonName"/>
<result property="relatedPersonName" column="relatedPersonName"/>
<result property="relatedStaffName" column="relatedStaffName"/>
<result property="relatedStaffCode" column="relatedStaffCode"/>
<result property="relationType" column="relationType"/>
<result property="userMemo" column="userMemo"/>
<result property="cashType" column="cashType"/>
<result property="displayAmount" column="displayAmount"/>
<result property="hasModelRuleHit" column="hasModelRuleHit"/>
<result property="hasNameListHit" column="hasNameListHit"/>
</resultMap>
<sql id="digitTableSql">
select 0 as digit
union all select 1
@@ -338,6 +353,243 @@
order by result.staff_name asc, result.staff_id_card asc
</select>
<sql id="suspiciousTransactionBaseSql">
select
bs.bank_statement_id as bankStatementId,
bs.TRX_DATE as trxDate,
bs.USER_MEMO as userMemo,
bs.CASH_TYPE as cashType,
case
when ifnull(bs.AMOUNT_CR, 0) > 0 then bs.AMOUNT_CR
when ifnull(bs.AMOUNT_DR, 0) > 0 then -bs.AMOUNT_DR
else 0
end as displayAmount,
coalesce(relation.relation_name, direct_staff.name, bs.CUSTOMER_ACCOUNT_NAME) as relatedPersonName,
coalesce(family_staff.name, direct_staff.name) as relatedStaffName,
cast(coalesce(family_staff.staff_id, direct_staff.staff_id) as char) as relatedStaffCode,
case
when direct_staff.id_card is not null then '本人'
when relation.relation_type is not null and trim(relation.relation_type) != '' then relation.relation_type
else '关联人'
end as relationType
from ccdi_bank_statement bs
left join ccdi_base_staff direct_staff
on bs.cret_no = direct_staff.id_card
left join ccdi_staff_fmy_relation relation
on relation.status = 1
and relation.relation_cert_no = bs.cret_no
left join ccdi_base_staff family_staff
on relation.person_id = family_staff.id_card
where bs.project_id = #{query.projectId}
and (direct_staff.id_card is not null or relation.person_id is not null)
</sql>
<sql id="suspiciousTransactionModelHitSql">
select distinct
tr.bank_statement_id as bankStatementId
from ccdi_bank_statement_tag_result tr
where tr.project_id = #{query.projectId}
and tr.bank_statement_id is not null
and tr.rule_name like '%可疑%'
</sql>
<sql id="suspiciousTransactionNameHitSql">
select
hits.bankStatementId,
hits.suspiciousPersonName,
hits.matchPriority
from (
select
bs.bank_statement_id as bankStatementId,
intermediary.name as suspiciousPersonName,
1 as matchPriority
from ccdi_bank_statement bs
inner join ccdi_biz_intermediary intermediary
on trim(bs.customer_cert_no) != ''
and intermediary.person_id = bs.customer_cert_no
where bs.project_id = #{query.projectId}
union all
select
bs.bank_statement_id as bankStatementId,
enterprise.enterprise_name as suspiciousPersonName,
2 as matchPriority
from ccdi_bank_statement bs
inner join ccdi_enterprise_base_info enterprise
on trim(bs.customer_social_credit_code) != ''
and enterprise.social_credit_code = bs.customer_social_credit_code
and enterprise.risk_level = '1'
and enterprise.ent_source = 'INTERMEDIARY'
where bs.project_id = #{query.projectId}
union all
select
bs.bank_statement_id as bankStatementId,
intermediary.name as suspiciousPersonName,
3 as matchPriority
from ccdi_bank_statement bs
inner join ccdi_biz_intermediary intermediary
on trim(bs.CUSTOMER_ACCOUNT_NAME) != ''
and intermediary.name = bs.CUSTOMER_ACCOUNT_NAME
where bs.project_id = #{query.projectId}
union all
select
bs.bank_statement_id as bankStatementId,
enterprise.enterprise_name as suspiciousPersonName,
3 as matchPriority
from ccdi_bank_statement bs
inner join ccdi_enterprise_base_info enterprise
on trim(bs.CUSTOMER_ACCOUNT_NAME) != ''
and enterprise.enterprise_name = bs.CUSTOMER_ACCOUNT_NAME
and enterprise.risk_level = '1'
and enterprise.ent_source = 'INTERMEDIARY'
where bs.project_id = #{query.projectId}
) hits
</sql>
<sql id="suspiciousTransactionMergedSql">
select
base.bankStatementId,
base.trxDate,
base.relatedPersonName,
base.relatedStaffName,
base.relatedStaffCode,
base.relationType,
base.userMemo,
base.cashType,
base.displayAmount,
1 as hasModelRuleHit,
0 as hasNameListHit,
null as suspiciousPersonName,
null as matchPriority
from (
<include refid="suspiciousTransactionBaseSql"/>
) base
inner join (
<include refid="suspiciousTransactionModelHitSql"/>
) model_hits on model_hits.bankStatementId = base.bankStatementId
union all
select
base.bankStatementId,
base.trxDate,
base.relatedPersonName,
base.relatedStaffName,
base.relatedStaffCode,
base.relationType,
base.userMemo,
base.cashType,
base.displayAmount,
0 as hasModelRuleHit,
1 as hasNameListHit,
name_hits.suspiciousPersonName,
name_hits.matchPriority
from (
<include refid="suspiciousTransactionBaseSql"/>
) base
inner join (
<include refid="suspiciousTransactionNameHitSql"/>
) name_hits on name_hits.bankStatementId = base.bankStatementId
</sql>
<sql id="suspiciousTransactionAggregatedSql">
select
merged.bankStatementId,
max(merged.trxDate) as trxDate,
coalesce(
substring_index(
min(
case
when merged.suspiciousPersonName is not null and merged.suspiciousPersonName != ''
then concat(lpad(merged.matchPriority, 2, '0'), '|', merged.suspiciousPersonName)
else null
end
),
'|',
-1
),
max(merged.relatedPersonName)
) as suspiciousPersonName,
max(merged.relatedPersonName) as relatedPersonName,
max(merged.relatedStaffName) as relatedStaffName,
max(merged.relatedStaffCode) as relatedStaffCode,
max(merged.relationType) as relationType,
max(merged.userMemo) as userMemo,
max(merged.cashType) as cashType,
max(merged.displayAmount) as displayAmount,
max(merged.hasModelRuleHit) as hasModelRuleHit,
max(merged.hasNameListHit) as hasNameListHit
from (
<include refid="suspiciousTransactionMergedSql"/>
) merged
group by merged.bankStatementId
</sql>
<sql id="suspiciousTransactionFilterSql">
<choose>
<when test="query.suspiciousType == 'NAME_LIST'">
where final_result.hasNameListHit = 1
</when>
<when test="query.suspiciousType == 'MODEL_RULE'">
where final_result.hasModelRuleHit = 1
</when>
<otherwise>
where final_result.hasModelRuleHit = 1 or final_result.hasNameListHit = 1
</otherwise>
</choose>
</sql>
<select id="selectSuspiciousTransactionPage" resultMap="SuspiciousTransactionItemResultMap">
<!-- rule_name like '%可疑%' -->
<!-- ccdi_biz_intermediary -->
<!-- ccdi_enterprise_base_info -->
<!-- group by merged.bankStatementId -->
select
final_result.bankStatementId,
final_result.trxDate,
final_result.suspiciousPersonName,
final_result.relatedPersonName,
final_result.relatedStaffName,
final_result.relatedStaffCode,
final_result.relationType,
final_result.userMemo,
final_result.cashType,
final_result.displayAmount,
final_result.hasModelRuleHit,
final_result.hasNameListHit
from (
<include refid="suspiciousTransactionAggregatedSql"/>
) final_result
<include refid="suspiciousTransactionFilterSql"/>
order by final_result.trxDate desc, final_result.bankStatementId desc
</select>
<select id="selectSuspiciousTransactionList" resultMap="SuspiciousTransactionItemResultMap">
select
final_result.bankStatementId,
final_result.trxDate,
final_result.suspiciousPersonName,
final_result.relatedPersonName,
final_result.relatedStaffName,
final_result.relatedStaffCode,
final_result.relationType,
final_result.userMemo,
final_result.cashType,
final_result.displayAmount,
final_result.hasModelRuleHit,
final_result.hasNameListHit
from (
<include refid="suspiciousTransactionAggregatedSql"/>
) final_result
<include refid="suspiciousTransactionFilterSql"/>
order by final_result.trxDate desc, final_result.bankStatementId desc
</select>
<select id="selectRiskModelNamesByScope" resultType="java.lang.String">
select
json_unquote(json_extract(result.model_hit_summary_json, concat('$[', idx.idx, '].modelName'))) as model_name