yanghb
2025-05-07 bf8f34752cc7584193d490cd6c1fe5850d31a269
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?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.bussiness.mapper.PlacementApplyRecordMapper">
 
    <select id="queryMainData" resultType="com.ruoyi.bussiness.object.response.screen.ScreenResponse">
        SELECT
            -- 本季度补偿金额
            COALESCE(SUM(CASE
                             WHEN FIND_IN_SET(#{month},t1.cycle) and t2.`status` = 1
                                 THEN t1.quarter_pay_amount
                             ELSE 0 END), 0) AS monthCompensationAmount,
 
            -- 本季度补偿金额
            COALESCE(SUM(CASE
                             WHEN FIND_IN_SET(#{lastMonth},cycle)
                                 THEN t1.quarter_pay_amount
                             ELSE 0 END), 0) AS lastMonthCompensationAmount,
 
            -- 本季度补偿金额
            COALESCE(SUM(CASE
                             WHEN FIND_IN_SET(#{nextMonth},cycle)
                                 THEN t1.quarter_pay_amount
                             ELSE 0 END), 0) AS nextMonthCompensationAmount,
 
            -- 总户数(根据查询中所有涉及到的 placement_batch_id 汇总)
            -- 总户数(根据查询中所有涉及到的 placement_batch_id 汇总)
            COALESCE(
                    ( SELECT count(1)
 
                      FROM t_placement_apply_record t1
                               JOIN t_placement_apply t2 ON t1.placement_apply_id = t2.id
                      WHERE t2.status = 1
 
                    ), 0) AS houseHoldCount
 
        FROM t_placement_batch_household t1
                 JOIN t_placement_batch t2 ON t1.placement_batch_id = t2.id
        WHERE t2.status = 1
    </select>
    
    <select id="countPassIdCard" resultType="int" >
        select ifnull(count(1),0) as `count`
        FROM t_placement_apply_record t1
        left JOIN t_placement_apply t2 ON t1.placement_apply_id = t2.id
        where t2.status = 1 and t1.id_card = #{idCard}
    </select>
 
    <select id="getRecordsByCardIds" resultType="com.ruoyi.bussiness.domain.PlacementApplyRecord">
        select t1.*
        FROM t_placement_apply_record t1
        JOIN t_placement_apply t2 ON t1.placement_apply_id = t2.id
        WHERE t2.status = 1
        and t1.id_card in
        <foreach collection="idCards" item="card" open="(" separator="," close=")">
            #{card}
        </foreach>
    </select>
 
    <select id="countError" resultType="java.util.Map">
        SELECT street,(id_card_exists_warn+id_card_no_warn+wait_family_names_warn+wait_family_names_no_warn+
                       wait_family_area_warn+compensation_amount_warn+compensation_sum_warn+quarter_pay_amount_warn+subsidy_amount_warn) as errorNum,
               sum(id_card_exists_warn+id_card_no_warn+wait_family_names_warn+wait_family_names_no_warn) as settleNum,
               sum(wait_family_area_warn) as areaNum,
               sum(compensation_sum_warn+quarter_pay_amount_warn+subsidy_amount_warn) compensationNum
 
        FROM t_placement_apply_record where placement_apply_id = #{applyId}
        GROUP BY street
    </select>
    
    <select id="getRecordsByCardId" resultType="com.ruoyi.bussiness.domain.PlacementApplyRecord">
        select t1.*
        FROM t_placement_apply_record t1
                 JOIN t_placement_apply t2 ON t1.placement_apply_id = t2.id
        WHERE t2.status = 1
        and t1.id_card  = #{idCard} limit 1
    </select>
</mapper>