87 lines
3.4 KiB
XML
87 lines
3.4 KiB
XML
|
|
<?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.ruoyi.info.collection.mapper.CcdiCreditInfoQueryMapper">
|
||
|
|
|
||
|
|
<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,
|
||
|
|
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
|
||
|
|
LEFT JOIN (
|
||
|
|
SELECT
|
||
|
|
person_id,
|
||
|
|
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>
|
||
|
|
<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}
|
||
|
|
</if>
|
||
|
|
<if test="query != null and query.idCard != null and query.idCard != ''">
|
||
|
|
AND s.id_card LIKE CONCAT('%', #{query.idCard}, '%')
|
||
|
|
</if>
|
||
|
|
<if test="query != null and query.maintained == '1'">
|
||
|
|
AND (debt_agg.person_id IS NOT NULL OR neg.person_id IS NOT NULL)
|
||
|
|
</if>
|
||
|
|
<if test="query != null and query.maintained == '0'">
|
||
|
|
AND debt_agg.person_id IS NULL
|
||
|
|
AND neg.person_id IS NULL
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
ORDER BY debt_agg.query_date DESC, s.staff_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,
|
||
|
|
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
|
||
|
|
LEFT JOIN (
|
||
|
|
SELECT
|
||
|
|
person_id,
|
||
|
|
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}
|
||
|
|
LIMIT 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectLatestQueryDate" resultType="java.time.LocalDate">
|
||
|
|
SELECT MAX(query_date)
|
||
|
|
FROM ccdi_debts_info
|
||
|
|
WHERE person_id = #{personId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
</mapper>
|