yanghb
2025-02-18 031748e56f04bf939927fdc54f31df29660d9363
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?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.zzg.system.mapper.state.StateSettlementMapper">
    <select id="listSettleDetail" parameterType="com.zzg.system.domain.bo.SettlementDetailBO"
            resultType="com.zzg.system.domain.vo.SettlementDetailVO">
        SELECT t1.ID AS stateHouseholdId,
        t1.house_using_type AS houseUsingType,
        <!--        t1.street AS street,-->
        <!--               t1.street     as projectStreet,-->
        <!--        为了前端不改接口这里直接 as成旧字段-->
        t1.belonging_street_town as street,
        t1.household_location AS location,
        t1.house_hold_area AS beforeHouseHoldArea,
        t4.*,
        t6.money AS agreementMooney,
        t1.compensation_type as compensationType,
        t4.audit_status as auditStatus,
        t5.id as projectId,
        (SELECT STRING_AGG(owner_name, '|' ORDER BY owner_name) FROM state_household_owner WHERE state_household_id = t1.id) as owner_name
        FROM state_settlement t4
        LEFT JOIN state_household t1 ON t1.ID = t4.state_household_id
        LEFT JOIN state_project t5 ON t5.ID = t1.state_project_id
        LEFT JOIN state_agreement t6 ON t1.ID = t6.state_household_id AND t6.agreement_file_type = 1
        <where>
            and t1.id is not null
            and t4.del_flag != 1
            <if test="settlementDetailBO.auditStatus == null">
                and t4.audit_status is null
            </if>
            <if test="settlementDetailBO.projectId != null and settlementDetailBO.projectId != ''">
                and t5.id = #{settlementDetailBO.projectId}
            </if>
            <if test="settlementDetailBO.auditStatus != null">
                <!-- 9-任务中心查询所有状态 -->
                <if test="settlementDetailBO.auditStatus != 9">
                    AND t4.audit_status = #{settlementDetailBO.auditStatus}
                </if>
                <if test="settlementDetailBO.auditStatus == 9">
                    and t4.audit_status is not null
                </if>
            </if>
            <if test="settlementDetailBO.compensationType != null and settlementDetailBO.compensationType != 0">
                and t1.compensation_type = #{settlementDetailBO.compensationType}
            </if>
            <if test="settlementDetailBO.beforeExchangeStreet != null and settlementDetailBO.beforeExchangeStreet != ''">
                and t1.belonging_street_town like concat('%', #{settlementDetailBO.beforeExchangeStreet}, '%')
            </if>
            <if test="settlementDetailBO.afterExchangeStreet != null and settlementDetailBO.afterExchangeStreet != ''">
                and t4.exchange_street like concat('%', #{settlementDetailBO.afterExchangeStreet}, '%')
            </if>
            <if test="settlementDetailBO.beforeExchangeLocation != null and settlementDetailBO.beforeExchangeLocation != ''">
                and t1.household_location like concat('%', #{settlementDetailBO.beforeExchangeLocation}, '%')
            </if>
            <if test="settlementDetailBO.afterExchangeLocation != null and settlementDetailBO.afterExchangeLocation != ''">
                and t4.exchange_location like concat('%', #{settlementDetailBO.afterExchangeLocation}, '%')
            </if>
            <if test="settlementDetailBO.ownerName != null and settlementDetailBO.ownerName != ''">
                and (SELECT STRING_AGG(owner_name, ',' ORDER BY owner_name) FROM state_household_owner WHERE state_household_id = t1.id) like concat('%', #{settlementDetailBO.ownerName}, '%')
            </if>
            <if test="settlementDetailBO.taskId != null and settlementDetailBO.taskId != ''">
                and t4.task_id = #{settlementDetailBO.taskId}
            </if>
            <if test="settlementDetailBO.batchName != null and settlementDetailBO.batchName != ''">
                and t4.settle_name = #{settlementDetailBO.batchName}
            </if>
        </where>
    </select>
 
    <select id="listSettleUpdateDetail" parameterType="com.zzg.system.domain.bo.SettlementDetailBO"
            resultType="com.zzg.system.domain.vo.SettlementDetailVO">
        SELECT t1.ID AS stateHouseholdId,
        t1.house_using_type AS houseUsingType,
        <!--        t1.street AS street,-->
        <!--               t1.street     as projectStreet,-->
        <!--        为了前端不改接口这里直接 as成旧字段-->
        t1.belonging_street_town as street,
        t1.household_location AS location,
        t1.house_hold_area AS beforeHouseHoldArea,
        t4.*,
        t6.money AS agreementMooney,
        t1.compensation_type as compensationType,
        t4.audit_status as auditStatus,
        t5.id as projectId,
        (SELECT STRING_AGG(owner_name, '|' ORDER BY owner_name) FROM state_household_owner WHERE state_household_id = t1.id) as owner_name
        FROM state_settlement t4
        LEFT JOIN state_household t1 ON t1.ID = t4.state_household_id
        LEFT JOIN state_project t5 ON t5.ID = t1.state_project_id
        LEFT JOIN state_agreement t6 ON t1.ID = t6.state_household_id AND t6.agreement_file_type = 1
        <where>
            and t1.id is not null
            and t4.del_flag != 1
            and ( t4.audit_status is null or t4.audit_status = 0 )
            <if test="settlementDetailBO.projectId != null and settlementDetailBO.projectId != ''">
                and t5.id = #{settlementDetailBO.projectId}
            </if>
            <if test="settlementDetailBO.compensationType != null and settlementDetailBO.compensationType != 0">
                and t1.compensation_type = #{settlementDetailBO.compensationType}
            </if>
            <if test="settlementDetailBO.beforeExchangeStreet != null and settlementDetailBO.beforeExchangeStreet != ''">
                and t1.belonging_street_town like concat('%', #{settlementDetailBO.beforeExchangeStreet}, '%')
            </if>
            <if test="settlementDetailBO.afterExchangeStreet != null and settlementDetailBO.afterExchangeStreet != ''">
                and t4.exchange_street like concat('%', #{settlementDetailBO.afterExchangeStreet}, '%')
            </if>
            <if test="settlementDetailBO.ownerName != null and settlementDetailBO.ownerName != ''">
                and (SELECT STRING_AGG(owner_name, ',' ORDER BY owner_name) FROM state_household_owner WHERE state_household_id = t1.id) like concat('%', #{settlementDetailBO.ownerName}, '%')
            </if>
            <if test="settlementDetailBO.beforeExchangeLocation != null and settlementDetailBO.beforeExchangeLocation != ''">
                and t1.household_location like concat('%', #{settlementDetailBO.beforeExchangeLocation}, '%')
            </if>
            <if test="settlementDetailBO.afterExchangeLocation != null and settlementDetailBO.afterExchangeLocation != ''">
                and t4.exchange_location like concat('%', #{settlementDetailBO.afterExchangeLocation}, '%')
            </if>
            <if test="settlementDetailBO.taskId != null and settlementDetailBO.taskId != ''">
                and t4.task_id = #{settlementDetailBO.taskId}
            </if>
            <if test="settlementDetailBO.batchName != null and settlementDetailBO.batchName != ''">
                and t4.settle_name = #{settlementDetailBO.batchName}
            </if>
        </where>
    </select>
 
    <select id="listSettleData" parameterType="com.zzg.system.domain.bo.SettlementBO"
            resultType="com.zzg.system.domain.vo.HouseholdVO">
        SELECT t1.project_name,
        t1.status as project_status,
        t1.department as department,
        t2.*
        FROM state_project t1
        LEFT JOIN state_household t2 on t1.id = t2.state_project_id
        LEFT JOIN state_project_info t4 on t1.id = t4.project_id
        <where>
            t2.id is not null
            and t2.del_flag = 0
            <if test="settlementBO != null">
                <if test="settlementBO.isSettled != null and settlementBO.isSettled == 1">
                    and t2.id in (select state_household_id from state_settlement where audit_status is not null)
                </if>
                <if test="settlementBO.isSettled!=null and settlementBO.isSettled == 0">
                    and t2.id not in (select state_household_id from state_settlement where audit_status is not null)
                </if>
                <if test="settlementBO.projectId != null">
                    and t1.id = #{settlementBO.projectId}
                </if>
                <if test="settlementBO.location != null and settlementBO.location != ''">
                    and t2.household_location like concat('%', #{settlementBO.location}, '%')
                </if>
                <if test="settlementBO.usingType != null and settlementBO.usingType != 0">
                    and t2.house_using_type = #{settlementBO.usingType}
                </if>
                <if test="settlementBO.compensationType != null and settlementBO.compensationType != 0">
                    and t2.compensation_type = #{settlementBO.compensationType}
                </if>
                <if test="settlementBO.projectName != null and settlementBO.projectName != ''">
                    and t1.project_name = #{settlementBO.projectName}
                </if>
                <if test="settlementBO.houseHoldNumber != null and settlementBO.houseHoldNumber != ''">
                    and (t2.real_estate_certificate_number like concat('%', #{settlementBO.houseHoldNumber}, '%')
                    or t2.using_area_certificate_number like concat('%', #{settlementBO.houseHoldNumber}, '%'))
                </if>
            </if>
        </where>
    </select>
 
    <delete id="deleteSettlement">
        delete from state_settlement where id = #{id}
    </delete>
 
    <select id="listExecutionData" parameterType="com.zzg.system.domain.bo.StateExecutionBO"
            resultType="com.zzg.system.domain.vo.StateExecutionDetailVO">
        SELECT t1.ID AS houseStateId,
        <!--        t1.street AS houseStreet,-->
        t1.belonging_street_town AS houseStreet,
        t1.household_location    AS houseLocation,
        t3.paid_time             as paidOffTime,
        t3.id                    as stateSettlementId,
        t4.levy_time             as projectTime
        FROM state_project t4
                 left join state_household t1 on t4.id = t1.state_project_id
                 LEFT JOIN state_settlement t3 ON t1.ID = t3.state_household_id
        <where>
            t1.del_flag = 0
            <if test="executionBO != null">
                <if test="executionBO.projectId != null">
                    and t4.id = #{executionBO.projectId}
                </if>
                <if test="executionBO.street != null and executionBO.street != ''">
                    AND t1.belonging_street_town like concat('%', #{executionBO.street}, '%')
                </if>
                <if test="executionBO.houseStateIdList != null">
                    AND t1.id in
                    <foreach item="stateHouseId" collection="executionBO.houseStateIdList" open="(" separator=","
                             close=")">
                        #{stateHouseId}
                    </foreach>
                </if>
                <if test="executionBO.location != null and executionBO.location != ''">
                    AND t1.household_location like concat('%', #{executionBO.location}, '%')
                </if>
            </if>
        </where>
    </select>
</mapper>