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
204
205
206
207
208
209
<?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.StateHouseholdMapper">
    <select id="listByConditions" parameterType="com.zzg.system.domain.bo.HouseholdBO"
            resultType="com.zzg.system.domain.vo.HouseholdVO">
        SELECT t1.project_name,
               t1.project_no,
               t1.is_need_evaluate,
               t1.status as project_status,
        <!--               t1.street     as projectStreet,-->
        <!--        为了前端不改接口这里直接 as成旧字段-->
        t2.belonging_street_town as projectStreet,
        t2.door_number,
        t2.building_number,
        t1.audit_status,
        t5.dept_name            as department,
        t2.*,
        t3.owner_name            as ownerName,
        t3.owner_type            as ownerType
        FROM state_project t1
                 LEFT JOIN state_household t2 on t1.id = t2.state_project_id
                 LEFT JOIN state_household_owner t3 on t2.id = t3.state_household_id
                 LEFT JOIN state_project_info t4 on t1.id = t4.project_id
        left join sys_dept t5 on t2.dept_id = t5.dept_id
        <where>
            T2.id is not null
              and t2.del_flag != 1
            <if test="householdBOBody != null">
                <if test="householdBOBody.location != null and householdBOBody.location != ''">
                    and t2.household_location like concat('%', #{householdBOBody.location}, '%')
                </if>
                <if test="householdBOBody.usingType != null and householdBOBody.usingType != 0">
                    and t2.house_using_type = #{householdBOBody.usingType}
                </if>
                <if test="householdBOBody.projectId != null">
                    and t1.id = #{householdBOBody.projectId}
                </if>
                <if test="householdBOBody.searchStatus != null">
                    and t2.search_status = #{householdBOBody.searchStatus}
                </if>
                <if test="householdBOBody.houseHoldNumber != null and householdBOBody.houseHoldNumber != ''">
                    and (t2.real_estate_certificate_number like concat('%', #{householdBOBody.houseHoldNumber}, '%')
                        or t2.using_area_certificate_number like concat('%', #{householdBOBody.houseHoldNumber}, '%'))
                </if>
                <if test="householdBOBody.ownerName != null and householdBOBody.ownerName != ''">
                    and t3.owner_name like concat('%', #{householdBOBody.ownerName}, '%')
                </if>
                <if test="householdBOBody.constructionCompany != null and householdBOBody.constructionCompany != ''">
                    and t5.dept_name  like
                        concat('%', #{householdBOBody.constructionCompany}, '%')
                </if>
                <if test="householdBOBody.projectName != null and householdBOBody.projectName != ''">
                    and t1.project_name like
                        concat('%', #{householdBOBody.projectName}, '%')
                </if>
                <if test="householdBOBody.appSearchStr != null and householdBOBody.appSearchStr != ''">
                    and (
                                t2.belonging_street_town like concat('%', #{householdBOBody.appSearchStr}, '%')
                            or
                                t2.door_number like concat('%', #{householdBOBody.appSearchStr}, '%')
                            or
                                t2.building_number like concat('%', #{householdBOBody.appSearchStr}, '%')
                        )
                </if>
            </if>
        </where>
        ORDER BY t2.create_time DESC
    </select>
 
 
    <select id="pageByConditionsWithoutOwners" parameterType="com.zzg.system.domain.bo.HouseholdBO"
            resultType="com.zzg.system.domain.vo.HouseholdVO">
        SELECT t1.project_name,
        t1.project_no,
        t1.is_need_evaluate,
        t1.status as project_status,
        <!--               t1.street     as projectStreet,-->
        <!--        为了前端不改接口这里直接 as成旧字段-->
        t2.belonging_street_town     as projectStreet,
        t2.door_number,
        t2.building_number,
        t1.audit_status,
        t5.dept_name 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
        left join sys_dept t5 on t2.dept_id = t5.dept_id
        <where>
            T2.id is not null
            and t2.del_flag != 1
            <if test="householdBOBody != null">
                <if test="householdBOBody.location != null and householdBOBody.location != ''">
                    and t2.household_location like concat('%', #{householdBOBody.location}, '%')
                </if>
                <if test="householdBOBody.usingType != null and householdBOBody.usingType != 0">
                    and t2.house_using_type = #{householdBOBody.usingType}
                </if>
                <if test="householdBOBody.projectId != null">
                    and t1.id = #{householdBOBody.projectId}
                </if>
                <if test="householdBOBody.houseHoldNumber != null and householdBOBody.houseHoldNumber != ''">
                    and (t2.real_estate_certificate_number like concat('%', #{householdBOBody.houseHoldNumber}, '%')
                    or t2.using_area_certificate_number like concat('%', #{householdBOBody.houseHoldNumber}, '%'))
                </if>
                <if test="householdBOBody.constructionCompany != null and householdBOBody.constructionCompany != ''">
                    and t5.dept_name like
                    concat('%', #{householdBOBody.constructionCompany}, '%')
                </if>
                <if test="householdBOBody.projectName != null and householdBOBody.projectName != ''">
                    and t1.project_name like
                    concat('%', #{householdBOBody.projectName}, '%')
                </if>
                <if test="householdBOBody.appSearchStr != null and householdBOBody.appSearchStr != ''">
                    and (
                    t2.belonging_street_town like concat('%', #{householdBOBody.appSearchStr}, '%')
                    or
                    t2.door_number like concat('%', #{householdBOBody.appSearchStr}, '%')
                    or
                    t2.building_number like concat('%', #{householdBOBody.appSearchStr}, '%')
                    )
                </if>
            </if>
        </where>
        ORDER BY t2.create_time DESC
    </select>
 
 
 
    <select id="pageByConditions" parameterType="com.zzg.system.domain.bo.HouseholdBO"
            resultType="com.zzg.system.domain.vo.HouseholdVO">
        SELECT t1.department as department, t2.*, t3.owner_name as ownerName, t3.owner_type as ownerType
        FROM state_project t1
                 LEFT JOIN state_household t2 on t1.id = t2.state_project_id
                 LEFT JOIN state_household_owner t3 on t2.id = t3.state_household_id
                 LEFT JOIN state_project_info t4 on t1.id = t4.project_id
        <where>
            <if test="getProjectPageBO.projectName != null and getProjectPageBO.projectName != ''">
                and t1.project_name = #{getProjectPageBO.projectName}
            </if>
            <if test="getProjectPageBO.collectionEnforcementDepartment != null and getProjectPageBO.collectionEnforcementDepartment != ''">
                and t4.collection_enforcement_department like
                    concat('%', #{getProjectPageBO.collectionEnforcementDepartment}, '%')
            </if>
            <if test="getProjectPageBO.department != null and getProjectPageBO.department != ''">
                and t4.department like
                    concat('%', #{getProjectPageBO.department}, '%')
            </if>
        </where>
    </select>
 
    <select id="pageByProjectId" resultType="com.zzg.system.domain.vo.HouseholdVO">
        SELECT *
        FROM (
        SELECT A.*, t1.sign_at as signAt
        FROM state_household A
                 left join state_agreement t1 on a.id = t1.state_household_id
        WHERE t1.agreement_file_type = 1
          and t1.agreement_number is not null
          and A.agreement_status = 3
          and A.del_flag = 0
          and A.state_project_id IN
        <foreach item="projectId" collection="projectIdList" open="(" separator="," close=")">
            #{projectId}
        </foreach>
 
        <if test="street != null and street != ''">
            and A.belonging_street_town like
            concat('%', #{street}, '%')
        </if>
        ORDER BY t1.sign_at ASC
        LIMIT 100
        ) AS result
    </select>
 
    <select id="listBySearchCondition" parameterType="com.zzg.system.domain.bo.HouseQueryBO"
            resultType="com.zzg.system.domain.vo.HouseQueryVO">
        SELECT t1.ID AS projectId,
        t1.project_name,
        t1.street AS projectStreet,
        t1.audit_status as auditStatus,
        t1.department AS department,
        t1.create_time AS lastCreateTime
        FROM state_project t1
        LEFT JOIN state_household t2 ON t1.ID = t2.state_project_id
        <where>
            -- 入户调查接口只需要 入户调查阶段的项目
            t1.id is not null and t1.status = 2 and t1.del_flag = 0
            <if test="houseQueryBO != null">
                <if test="houseQueryBO.projectId != null">
                    and t1.id = #{houseQueryBO.projectId}
                </if>
                <if test="houseQueryBO.department != null and houseQueryBO.department != ''">
                    and t1.department like concat('%', #{houseQueryBO.department},'%')
                </if>
                <if test="houseQueryBO.street != null and houseQueryBO.street != '' ">
                    and t1.street like concat('%', #{houseQueryBO.street},'%')
                </if>
            </if>
        </where>
        GROUP BY t1.ID,
        t1.project_name,
        t1.street,
        t1.audit_status,
        t1.department,
        lastCreateTime
        ORDER BY lastCreateTime DESC
    </select>
</mapper>