huanghongfa
2021-08-21 2e64c232ab6b51b2cecf1ee96e1e9b709234f326
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
package com.panzhihua.service_community.dao;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.community.ComMngPopulationHouseAdminDTO;
import com.panzhihua.common.model.dtos.grid.PageComMngVillageBuildHouseAppDTO;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.model.vos.grid.ComMngVillageBuildingHouseDetailVO;
import com.panzhihua.common.model.vos.grid.ComMngVillageBuildingHouseVO;
import com.panzhihua.common.model.vos.grid.PopulationListVO;
import com.panzhihua.common.model.vos.grid.admin.ComMngSubordinateVO;
import com.panzhihua.common.model.vos.user.ComMngHouseVo;
import com.panzhihua.service_community.model.dos.ComMngPopulationDO;
import com.panzhihua.service_community.model.dos.ComMngPopulationHouseDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
import java.util.List;
 
/**
 * @auther lyq
 * @create 2021-05-18 09:26:31
 * @describe 社区管理》小区管理》实有房屋mapper类
 */
@Mapper
public interface ComMngPopulationHouseDAO extends BaseMapper<ComMngPopulationHouseDO> {
 
    @Select("select cmphu.house_id,cmph.address,cmph.status,cmphu.popul_id,cmphu.residence,cmphu.relation_id,cmphu.relation from com_mng_population_house_user cmphu " +
            " left join com_mng_population_house as cmph on cmph.id = cmphu.house_id " +
            " where cmphu.popul_id = #{populId}")
    List<ComMngHouseVo> getPopulHouseListByPopulId(@Param("populId")Long populId);
 
    @Select("<script> " +
            "select id as houseId,cmv.alley from com_mng_population_house as cmph left join com_mng_village as cmv on cmv.village_id = cmph.village_id where cmph.community_id = #{communityId}" +
            "<if test='villageId != null and villageId != &quot;&quot;'>" +
            "and cmv.village_id = #{villageId}" +
            " </if> " +
            " </script>")
    List<ComMngCascadeHouseVO> getHouseLevelByAlley(@Param(value = "communityId") Long communityId,@Param(value = "villageId") Long villageId);
 
    @Select("<script> " +
            "select id as houseId,cmv.alley,cmv.house_num from com_mng_population_house as cmph left join com_mng_village as cmv on cmv.village_id = cmph.village_id where cmph.community_id = #{communityId}" +
            "<if test='name != null and name != &quot;&quot;'>" +
            "and cmv.alley = #{name}" +
            " </if> " +
            "<if test='villageId != null'>" +
            "and cmv.village_id = #{villageId}" +
            " </if> " +
            " </script>")
    List<ComMngCascadeHouseVO> getHouseLevelByHouseNum(@Param("name") String name,@Param("communityId") Long communityId,@Param(value = "villageId") Long villageId);
 
    @Select("<script> " +
            "select id as houseId,cmv.alley,cmv.house_num,cmph.floor from com_mng_population_house as cmph left join com_mng_village as cmv on cmv.village_id = cmph.village_id where cmph.community_id = #{communityId} " +
            "<if test='name != null and name != &quot;&quot;'>" +
            "and cmv.alley = #{name}" +
            " </if> " +
            "<if test='houseNum != null and houseNum != &quot;&quot;'>" +
            "and cmv.house_num = #{houseNum}" +
            " </if> " +
            "<if test='villageId != null'>" +
            "and cmv.village_id = #{villageId}" +
            " </if> " +
            " </script>")
    List<ComMngCascadeHouseVO> getHouseLevelByFloor(@Param("name") String name,@Param("houseNum") String houseNum,@Param("communityId") Long communityId,@Param(value = "villageId") Long villageId);
 
    @Select("<script> " +
            "select id as houseId,cmv.alley,cmv.house_num,cmph.floor,cmph.unit_no from com_mng_population_house as cmph left join com_mng_village as cmv on cmv.village_id = cmph.village_id where cmph.community_id = #{communityId} " +
            "<if test='name != null and name != &quot;&quot;'>" +
            "and cmv.alley = #{name}" +
            " </if> " +
            "<if test='houseNum != null and houseNum != &quot;&quot;'>" +
            "and cmv.house_num = #{houseNum}" +
            " </if> " +
            "<if test='floor != null and floor != &quot;&quot;'>" +
            "and cmph.floor = #{floor}" +
            " </if> " +
            "<if test='villageId != null'>" +
            "and cmv.village_id = #{villageId}" +
            " </if> " +
            " </script>")
    List<ComMngCascadeHouseVO> getHouseLevelByUnitNo(@Param("name") String name,@Param("houseNum") String houseNum,@Param("floor") String floor,@Param("communityId") Long communityId,@Param(value = "villageId") Long villageId);
 
    @Select("<script> " +
            "select cmph.id as houseId,cmv.alley,cmv.house_num,cmph.floor,cmph.unit_no,cmph.house_no from com_mng_population_house as cmph left join com_mng_village as cmv on cmv.village_id = cmph.village_id where cmph.community_id = #{communityId} " +
            "<if test='name != null and name != &quot;&quot;'>" +
            "and cmv.alley = #{name}" +
            " </if> " +
            "<if test='houseNum != null and houseNum != &quot;&quot;'>" +
            "and cmv.house_num = #{houseNum}" +
            " </if> " +
            "<if test='floor != null and floor != &quot;&quot;'>" +
            "and cmph.floor = #{floor}" +
            " </if> " +
            "<if test='unitNo != null and unitNo != &quot;&quot;'>" +
            "and cmph.unit_no = #{unitNo}" +
            " </if> " +
            "<if test='villageId != null'>" +
            "and cmv.village_id = #{villageId}" +
            " </if> " +
            " </script>")
    List<ComMngCascadeHouseVO> getHouseLevelByHouseNo(@Param("name") String name,@Param("houseNum") String houseNum,@Param("floor") String floor,@Param("unitNo") String unitNo,@Param("communityId") Long communityId,@Param(value = "villageId") Long villageId);
 
    @Select("update com_mng_population_house set is_empty = #{isEmpty} where id = #{houseId}")
    void updateHouseByIsEmpty(@Param("houseId") Long houseId,@Param("isEmpty") Integer isEmpty);
 
    @Select("<script> " +
            "select cmph.id,cmv.alley,cmv.house_num,cmv.group_at,cmph.address,cmph.status,cmph.purpose,cmph.control_status" +
            ",cmph.update_at,cmph.is_empty from com_mng_population_house as cmph" +
            " left join com_mng_village as cmv on cmv.village_id = cmph.village_id" +
            "<where>" +
            "<if test='populationHouseAdminDTO.communityId != null'>" +
            " and cmph.community_id = #{populationHouseAdminDTO.communityId} " +
            " </if> " +
            "<if test='populationHouseAdminDTO.alley != null and populationHouseAdminDTO.alley != &quot;&quot;'>" +
//            "AND cmv.alley like #{populationHouseAdminDTO.alley} " +
            "AND cmv.alley like concat('%',#{populationHouseAdminDTO.alley},'%') " +
            " </if> " +
            "<if test='populationHouseAdminDTO.houseNum != null and populationHouseAdminDTO.houseNum != &quot;&quot;'>" +
            "AND cmv.house_num = #{populationHouseAdminDTO.houseNum} " +
            " </if> " +
            "<if test='populationHouseAdminDTO.groupAt != null and populationHouseAdminDTO.groupAt != &quot;&quot;'>" +
            "AND cmv.group_at = #{populationHouseAdminDTO.groupAt} " +
            " </if> " +
            "<if test='populationHouseAdminDTO.status != null'>" +
            "AND cmph.status = #{populationHouseAdminDTO.status} " +
            " </if> " +
            "<if test='populationHouseAdminDTO.purpose != null'>" +
            "AND cmph.purpose = #{populationHouseAdminDTO.purpose} " +
            " </if> " +
            "<if test='populationHouseAdminDTO.controlStatus != null'>" +
            "AND cmph.control_status = #{populationHouseAdminDTO.controlStatus} " +
            " </if> " +
            "<if test='populationHouseAdminDTO.startTime != null and populationHouseAdminDTO.startTime != &quot;&quot; '>" +
            " AND cmph.update_at <![CDATA[>=]]> #{populationHouseAdminDTO.startTime}  " +
            "</if>" +
            "<if test='populationHouseAdminDTO.endTime != null and populationHouseAdminDTO.startTime != &quot;&quot; '>" +
            " AND cmph.update_at <![CDATA[<=]]> #{populationHouseAdminDTO.endTime}  " +
            " </if> " +
 
            "<if test='populationHouseAdminDTO.road != null and populationHouseAdminDTO.road != &quot;&quot; '>" +
            " AND cmv.alley = #{populationHouseAdminDTO.road}  " +
            " </if> " +
            "<if test='populationHouseAdminDTO.doorNo != null and populationHouseAdminDTO.doorNo != &quot;&quot; '>" +
            " AND cmv.house_num = #{populationHouseAdminDTO.doorNo}  " +
            " </if> " +
            "<if test='populationHouseAdminDTO.floor != null and populationHouseAdminDTO.floor != &quot;&quot; '>" +
            " AND cmph.floor = #{populationHouseAdminDTO.floor}  " +
            " </if> " +
            "<if test='populationHouseAdminDTO.unitNo != null and populationHouseAdminDTO.unitNo != &quot;&quot; '>" +
            " AND cmph.unit_no = #{populationHouseAdminDTO.unitNo}  " +
            " </if> " +
            "<if test='populationHouseAdminDTO.houseNo != null and populationHouseAdminDTO.houseNo != &quot;&quot; '>" +
            " AND cmph.house_no = #{populationHouseAdminDTO.houseNo}  " +
            " </if> " +
            "<if test='populationHouseAdminDTO.villageId != null'>" +
            " and cmph.village_id = #{populationHouseAdminDTO.villageId} " +
            " </if> " +
            "<if test='populationHouseAdminDTO.address != null and populationHouseAdminDTO.address != &quot;&quot; '>" +
            " AND cmph.address = #{populationHouseAdminDTO.address}  " +
            " </if> " +
            " </where>" +
            " order by update_at desc" +
            " </script>")
    IPage<ComMngPopulationHouseAdminVO> getPageHouse(Page page, @Param("populationHouseAdminDTO") ComMngPopulationHouseAdminDTO populationHouseAdminDTO);
 
    @Select("select id,address,status,purpose,control_status,update_at,code,construct_purpose,construct_area from com_mng_population_house where id = #{houseId}")
    ComMngPopulationHouseDetailAdminVO getHouseDetail(@Param("houseId") Long houseId);
 
    @Select("select count(id) as houseTotal" +
            ",(select count(id) from com_mng_population_house where is_empty = 1 and community_id = #{communityId}) as emptyTotal" +
            ",(select count(id) from com_mng_population_house where control_status = 2 and community_id = #{communityId}) as followTotal" +
            ",(select count(id) from com_mng_population_house where control_status = 3 and community_id = #{communityId}) as controlTotal" +
            " from com_mng_population_house as cmph where community_id = #{communityId}")
    ComMngPopulationHouseTotalVO getHouseTotalByAdmin(@Param("communityId") Long communityId);
 
    @Select("select (select province_name from com_mng_struct_area_province where province_adcode = ca.province_code) as provinceName," +
            "(select city_name from com_mng_struct_area_city where city_adcode = ca.city_code) as cityName," +
            "(select district_name from com_mng_struct_area_district where district_adcode = ca.area_code) as districtName" +
            ",ca.province_code as provinceAdcode,ca.city_code as cityAdcode,ca.area_code as districtAdcode" +
            " from com_act as ca where ca.community_id = #{communityId}")
    ComMngVillageRegionVO getRegion(@Param("communityId") Long communityId);
 
    @Select("<script> " +
            "SELECT id, floor, unit_no, house_no, `status`,( SELECT count( id ) FROM com_mng_population_house_user WHERE house_id = cmph.id ) AS userNum " +
            " FROM " +
            " com_mng_population_house AS cmph " +
            " <where> " +
            "<if test='buildHouseAppDTO.villageId != null '>" +
            " and cmph.village_id = #{buildHouseAppDTO.villageId}  " +
            " </if> " +
            "<if test='buildHouseAppDTO.floor != null and buildHouseAppDTO.floor !=&quot;&quot; '>" +
            " and cmph.floor = #{buildHouseAppDTO.floor}  " +
            " </if> " +
            "<if test='buildHouseAppDTO.unitNo != null and buildHouseAppDTO.unitNo !=&quot;&quot; '>" +
            " and cmph.unit_no = #{buildHouseAppDTO.unitNo}  " +
            " </if> " +
            "<if test='buildHouseAppDTO.houseNo != null and buildHouseAppDTO.houseNo !=&quot;&quot; '>" +
            " and cmph.house_no like concat(#{buildHouseAppDTO.houseNo},'%')  " +
            " </if> " +
            " </where>" +
            " </script>")
    IPage<ComMngVillageBuildingHouseVO> getGridVillageBuildingHouseList(Page page, @Param("buildHouseAppDTO") PageComMngVillageBuildHouseAppDTO buildHouseAppDTO);
 
    @Select("SELECT " +
            " cmph.id, " +
            " cmv.`name` AS villageName, " +
            " cmph.floor, " +
            " cmph.unit_no, " +
            " cmph.house_no, " +
            " cmph.address, " +
            " cmph.`status`, " +
            " cmv.lat, " +
            " cmv.lng  " +
            "FROM " +
            " com_mng_population_house AS cmph " +
            " LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cmph.village_id  " +
            "WHERE " +
            " cmph.id = #{houseId}")
    ComMngVillageBuildingHouseDetailVO getGridVillageBuildingHouseDetail(@Param("houseId") Long houseId);
 
    @Select("<script> " +
            "SELECT " +
            " cmp.id, " +
            " cmphu.id as housePopulationId, " +
            " cmp.sex, " +
            " cmp.`name`, " +
            " IFNULL( cmp.phone, '暂无' ) as phone, " +
            " cmp.card_no, " +
            " cmp.label, " +
            " cmp.address, " +
            " cmp.nation, " +
            " cmphu.create_at, " +
            " cmp.political_outlook  " +
            "FROM " +
            " com_mng_population_house_user AS cmphu " +
            " LEFT JOIN com_mng_population AS cmp ON cmp.id = cmphu.popul_id  " +
            "WHERE " +
            " cmphu.house_id = #{houseId} " +
            "<if test='relation != null '>" +
            " AND cmphu.relation = #{relation}  " +
            " </if> " +
            "<if test='relationId != null '>" +
            " AND cmphu.relation_id = #{relationId}  " +
            " </if> " +
            " </script>")
    List<PopulationListVO> getGridVillageBuildingPopulationList(@Param("houseId") Long houseId,@Param("relation") Integer relation,@Param("relationId") Integer relationId);
 
    @Select("select id as houseId,floor from com_mng_population_house where village_id = #{villageId} order by create_at asc")
    List<ComMngSubordinateVO> getHouseLevelByFloors(@Param("villageId") Long villageId);
 
    @Select("select id as houseId,unit_no from com_mng_population_house where village_id = #{villageId} and floor = #{floor} order by create_at asc")
    List<ComMngSubordinateVO> getHouseLevelByUnitNos(@Param("villageId") Long villageId,@Param("floor") String floor);
 
    @Select("select id as houseId,house_no from com_mng_population_house where village_id = #{villageId} and floor = #{floor} and unit_no = #{unitNo} order by create_at asc")
    List<ComMngSubordinateVO> getHouseLevelByHouseNos(@Param("villageId") Long villageId,@Param("floor") String floor,@Param("unitNo") String unitNo);
 
    @Insert("<script> " +
            "insert into com_mng_population_house(`id`,`street_id`,`community_id`,`village_id`" +
            ",`alley`,`house_num`,`unit_no`,`floor`,`house_no`,`code`,`address`,`status`" +
            ",`purpose`,`control_status`,`is_empty`,`construct_purpose`,`construct_area`" +
            ",`path`,`create_at`) values " +
            "<foreach collection=\"houseList\" item=\"item\" index=\"index\" separator=\",\">\n" +
            "        (#{item.id},#{item.streetId},#{item.communityId},#{item.villageId}" +
            ",#{item.alley},#{item.houseNum},#{item.unitNo},#{item.floor}" +
            ",#{item.houseNo},#{item.code},#{item.address},#{item.status}" +
            ",#{item.purpose},#{item.controlStatus},#{item.isEmpty},#{item.constructPurpose}" +
            ",#{item.constructArea},#{item.path},now())" +
            "    </foreach>" +
            " </script>")
    void insertAll(@Param("houseList") List<ComMngPopulationHouseDO> houseList);
}