调整征信维护为征信对象直接入库

This commit is contained in:
wkc
2026-03-24 15:05:02 +08:00
parent 6b0c83024e
commit fa9673c8c4
13 changed files with 238 additions and 115 deletions

View File

@@ -6,68 +6,76 @@
<select id="selectCreditInfoPage" resultType="com.ruoyi.info.collection.domain.vo.CreditInfoListVO">
SELECT
s.staff_id,
s.name,
s.id_card,
d.dept_name,
debt_agg.query_date,
COALESCE(debt_agg.person_name, neg.person_name) AS name,
credit_keys.person_id AS id_card,
COALESCE(debt_agg.query_date, neg.query_date) AS query_date,
IFNULL(debt_agg.debt_count, 0) AS debt_count,
IFNULL(debt_agg.debt_total_amount, 0) AS debt_total_amount,
IFNULL(neg.civil_cnt, 0) AS civil_cnt,
IFNULL(neg.enforce_cnt, 0) AS enforce_cnt,
IFNULL(neg.adm_cnt, 0) AS adm_cnt
FROM ccdi_base_staff s
LEFT JOIN sys_dept d ON s.dept_id = d.dept_id
FROM (
SELECT person_id
FROM ccdi_debts_info
GROUP BY person_id
UNION
SELECT person_id
FROM ccdi_credit_negative_info
GROUP BY person_id
) credit_keys
LEFT JOIN (
SELECT
person_id,
MAX(person_name) AS person_name,
MAX(query_date) AS query_date,
COUNT(*) AS debt_count,
SUM(debt_total_amount) AS debt_total_amount
FROM ccdi_debts_info
GROUP BY person_id
) debt_agg ON debt_agg.person_id = s.id_card
LEFT JOIN ccdi_credit_negative_info neg ON neg.person_id = s.id_card
) debt_agg ON debt_agg.person_id = credit_keys.person_id
LEFT JOIN ccdi_credit_negative_info neg ON neg.person_id = credit_keys.person_id
<where>
AND (debt_agg.person_id IS NOT NULL OR neg.person_id IS NOT NULL)
<if test="query != null and query.name != null and query.name != ''">
AND s.name LIKE CONCAT('%', #{query.name}, '%')
</if>
<if test="query != null and query.staffId != null and query.staffId != ''">
AND CAST(s.staff_id AS CHAR) = #{query.staffId}
AND COALESCE(debt_agg.person_name, neg.person_name) LIKE CONCAT('%', #{query.name}, '%')
</if>
<if test="query != null and query.idCard != null and query.idCard != ''">
AND s.id_card LIKE CONCAT('%', #{query.idCard}, '%')
AND credit_keys.person_id LIKE CONCAT('%', #{query.idCard}, '%')
</if>
</where>
ORDER BY debt_agg.query_date DESC, s.staff_id DESC
ORDER BY COALESCE(debt_agg.query_date, neg.query_date) DESC, credit_keys.person_id DESC
</select>
<select id="selectCreditInfoSummaryByPersonId" resultType="com.ruoyi.info.collection.domain.vo.CreditInfoListVO">
SELECT
s.staff_id,
s.name,
s.id_card,
d.dept_name,
debt_agg.query_date,
COALESCE(debt_agg.person_name, neg.person_name) AS name,
credit_keys.person_id AS id_card,
COALESCE(debt_agg.query_date, neg.query_date) AS query_date,
IFNULL(debt_agg.debt_count, 0) AS debt_count,
IFNULL(debt_agg.debt_total_amount, 0) AS debt_total_amount,
IFNULL(neg.civil_cnt, 0) AS civil_cnt,
IFNULL(neg.enforce_cnt, 0) AS enforce_cnt,
IFNULL(neg.adm_cnt, 0) AS adm_cnt
FROM ccdi_base_staff s
LEFT JOIN sys_dept d ON s.dept_id = d.dept_id
FROM (
SELECT person_id
FROM ccdi_debts_info
GROUP BY person_id
UNION
SELECT person_id
FROM ccdi_credit_negative_info
GROUP BY person_id
) credit_keys
LEFT JOIN (
SELECT
person_id,
MAX(person_name) AS person_name,
MAX(query_date) AS query_date,
COUNT(*) AS debt_count,
SUM(debt_total_amount) AS debt_total_amount
FROM ccdi_debts_info
GROUP BY person_id
) debt_agg ON debt_agg.person_id = s.id_card
LEFT JOIN ccdi_credit_negative_info neg ON neg.person_id = s.id_card
WHERE s.id_card = #{personId}
) debt_agg ON debt_agg.person_id = credit_keys.person_id
LEFT JOIN ccdi_credit_negative_info neg ON neg.person_id = credit_keys.person_id
WHERE credit_keys.person_id = #{personId}
LIMIT 1
</select>