罗元桥
2021-05-25 b24f9c75c79e4de248505295bfea7055e4975ff4
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
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.ComMngPopulationDTO;
import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
import com.panzhihua.common.model.vos.area.AreaAddressVO;
import com.panzhihua.common.model.vos.community.ComActMessageVO;
import com.panzhihua.common.model.vos.community.ComMngPopulationTotalVO;
import com.panzhihua.common.model.vos.community.ComMngPopulationVO;
import com.panzhihua.common.model.vos.community.PageComActMessageVO;
import com.panzhihua.common.model.vos.user.ComHouseMemberVo;
import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO;
import com.panzhihua.common.model.vos.user.InputUserInfoVO;
import com.panzhihua.common.model.vos.user.UserElectronicFileVO;
import com.panzhihua.service_community.model.dos.ComMngPopulationDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
import java.util.List;
 
/**
 * 实有人口Dao
 */
@Mapper
public interface ComMngPopulationDAO extends BaseMapper<ComMngPopulationDO> {
 
    @Select("<script> " +
            "SELECT\n" +
            "cmp.`name`,\n" +
            "cmp.id,\n" +
            "cmp.street_id,\n" +
            "cmp.act_id,\n" +
            "cmp.village_id,\n" +
            "cmp.sex,\n" +
            "cmp.age,\n" +
            "cmp.card_no,\n" +
            "cmp.road,\n" +
            "cmp.door_no,\n" +
            "cmp.floor,\n" +
            "cmp.unit_no,\n" +
            "cmp.house_no,\n" +
            "cmp.political_outlook,\n" +
            "cmp.work_company,\n" +
            "cmp.special_situation,\n" +
            "cmp.phone,\n" +
            "cmp.remark,\n" +
            "cmv.alley,\n" +
            "cmp.native_place,\n" +
            "cmp.nation \n" +
            "FROM \n" +
            "com_mng_population AS cmp " +
            "LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cmp.village_id " +
            "<where>" +
            "<if test='comMngPopulationVO.name != null and comMngPopulationVO.name.trim() != &quot;&quot;'>" +
            "AND cmp.`name` LIKE concat(#{comMngPopulationVO.name},'%') " +
            " </if> " +
            "<if test='comMngPopulationVO.road != null and comMngPopulationVO.road.trim() != &quot;&quot;'>" +
            "AND cmp.road LIKE concat(#{comMngPopulationVO.road},'%') " +
            " </if> " +
            "<if test='comMngPopulationVO.doorNo != null and comMngPopulationVO.doorNo.trim() != &quot;&quot;'>" +
            "AND cmp.door_no = #{comMngPopulationVO.doorNo} " +
            " </if> " +
            "<if test='comMngPopulationVO.alley != null and comMngPopulationVO.alley.trim() != &quot;&quot;'>" +
            "AND cmv.alley LIKE concat(#{comMngPopulationVO.alley},'%') " +
            " </if> " +
            "<if test='comMngPopulationVO.sex != null and comMngPopulationVO.sex.trim() != &quot;&quot;'>" +
            "AND cmp.sex = #{comMngPopulationVO.sex} " +
            " </if> " +
            "<if test='comMngPopulationVO.ageStart != null'>" +
            "AND cmp.age <![CDATA[ >= ]]> #{comMngPopulationVO.ageStart} " +
            " </if> " +
            "<if test='comMngPopulationVO.ageEnd != null'>" +
            "AND cmp.age <![CDATA[ <= ]]> #{comMngPopulationVO.ageEnd} " +
            " </if> " +
            "<if test='comMngPopulationVO.nativePlace != null and comMngPopulationVO.nativePlace.trim() != &quot;&quot;'>" +
            "AND cmp.native_place LIKE concat(#{comMngPopulationVO.nativePlace},'%') " +
            " </if> " +
            "<if test='comMngPopulationVO.nation != null and comMngPopulationVO.nation.trim() != &quot;&quot;'>" +
            "AND cmp.nation = #{comMngPopulationVO.nation} " +
            " </if> " +
            "<if test='comMngPopulationVO.politicalOutlook != null and comMngPopulationVO.politicalOutlook.trim() != &quot;&quot;'>" +
            "AND cmp.political_outlook = #{comMngPopulationVO.politicalOutlook} " +
            " </if> " +
            "<if test='comMngPopulationVO.cardNo != null and comMngPopulationVO.cardNo.trim() != &quot;&quot;'>" +
            "AND cmp.card_no = #{comMngPopulationVO.cardNo} " +
            " </if> " +
            "<if test='comMngPopulationVO.remark != null and comMngPopulationVO.remark.trim() != &quot;&quot;'>" +
            "AND cmp.remark = #{comMngPopulationVO.remark} " +
            " </if> " +
            " </where>" +
            " order by cmp.create_at desc " +
            "</script>")
    List<ComMngPopulationVO> listPopulation(ComMngPopulationDTO populationVO);
 
 
    @Select("select id,user_id,relationship,`name`,id_card,phone,age,health,job,create_at,update_at,card_photo_front,card_photo_back,family_book from com_mng_family_info where user_id=#{userId} order by create_at desc ")
    List<ComMngFamilyInfoVO> listFamilyByUserId(Long userId);
 
    @Select("select cmphu.popul_id,cmp.name,cmp.relation,cmp.age,cmp.phone,cmp.healthy,cmp.card_no,cmp.work_company from com_mng_population_house_user cmphu " +
            " left join com_mng_population cmp on cmp.id = cmphu.popul_id " +
            " where cmphu.house_id = #{houseId} and cmphu.popul_id != #{populId}")
    List<ComHouseMemberVo> listHouseMermberByUserId(@Param("houseId") Long houseId, @Param("populId") Long populId);
 
    @Select("<script> " +
            "SELECT\n" +
            "cmp.`name`,\n" +
            "cmp.id,\n" +
            "cmp.street_id,\n" +
            "cmp.act_id,\n" +
            "cmp.village_id,\n" +
            "cmp.sex,\n" +
            "cmp.age,\n" +
            "cmp.card_no,\n" +
            "cmp.road,\n" +
            "cmp.door_no,\n" +
            "cmp.floor,\n" +
            "cmp.unit_no,\n" +
            "cmp.house_no,\n" +
            "cmp.political_outlook,\n" +
            "cmp.work_company,\n" +
            "cmp.special_situation,\n" +
            "cmp.phone,\n" +
            "cmp.remark,\n" +
            "cmv.alley,\n" +
            "cmp.native_place,\n" +
            "cmp.nation, \n" +
            "cmp.label, \n" +
            "cmp.relation, \n" +
            "cmp.marriage, \n" +
            "cmp.culture_level, \n" +
            "cmp.out_or_local, \n" +
            "cmp.census_register, \n" +
            "cmp.healthy, \n" +
            "cmp.birthday, \n" +
            "cmp.is_rent \n" +
            "FROM \n" +
            "com_mng_population AS cmp " +
            "LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cmp.village_id " +
            "<where>" +
            "<if test='comMngPopulationVO.name != null and comMngPopulationVO.name != &quot;&quot;'>" +
            "AND cmp.`name` LIKE concat(#{comMngPopulationVO.name},'%') " +
            " </if> " +
            "<if test='comMngPopulationVO.actId != null'>" +
            " and cmp.act_id = #{comMngPopulationVO.actId} " +
            " </if> " +
            "<if test='comMngPopulationVO.villageId != null'>" +
            " and cmp.village_id = #{comMngPopulationVO.villageId} " +
            " </if> " +
            "<if test='comMngPopulationVO.road != null and comMngPopulationVO.road != &quot;&quot;'>" +
            "AND cmp.road = #{comMngPopulationVO.road} " +
            " </if> " +
            "<if test='comMngPopulationVO.doorNo != null and comMngPopulationVO.doorNo != &quot;&quot;'>" +
            "AND cmp.door_no = #{comMngPopulationVO.doorNo} " +
            " </if> " +
            "<if test='comMngPopulationVO.floor != null and comMngPopulationVO.floor != &quot;&quot;'>" +
            "AND cmp.floor = #{comMngPopulationVO.floor} " +
            " </if> " +
            "<if test='comMngPopulationVO.unitNo != null and comMngPopulationVO.unitNo != &quot;&quot;'>" +
            "AND cmp.unit_no = #{comMngPopulationVO.unitNo} " +
            " </if> " +
            "<if test='comMngPopulationVO.houseNo != null and comMngPopulationVO.houseNo != &quot;&quot;'>" +
            "AND cmp.house_no = #{comMngPopulationVO.houseNo} " +
            " </if> " +
            "<if test='comMngPopulationVO.alley != null and comMngPopulationVO.alley != &quot;&quot;'>" +
            "AND cmv.alley LIKE concat(#{comMngPopulationVO.alley},'%') " +
            " </if> " +
            "<if test='comMngPopulationVO.sex != null and comMngPopulationVO.sex != &quot;&quot;'>" +
            "AND cmp.sex = #{comMngPopulationVO.sex} " +
            " </if> " +
            "<if test='comMngPopulationVO.ageStart != null and comMngPopulationVO.ageStart != &quot;&quot;'>" +
            "AND cmp.age <![CDATA[ >= ]]> #{comMngPopulationVO.ageStart} " +
            " </if> " +
            "<if test='comMngPopulationVO.ageEnd != null and comMngPopulationVO.ageEnd != &quot;&quot;'>" +
            "AND cmp.age <![CDATA[ <= ]]> #{comMngPopulationVO.ageEnd} " +
            " </if> " +
            "<if test='comMngPopulationVO.nativePlace != null and comMngPopulationVO.nativePlace != &quot;&quot;'>" +
            "AND cmp.native_place LIKE concat(#{comMngPopulationVO.nativePlace},'%') " +
            " </if> " +
            "<if test='comMngPopulationVO.nation != null and comMngPopulationVO.nation != &quot;&quot;'>" +
            "AND cmp.nation = #{comMngPopulationVO.nation} " +
            " </if> " +
            "<if test='comMngPopulationVO.politicalOutlook != null and comMngPopulationVO.politicalOutlook != &quot;&quot;'>" +
            "AND cmp.political_outlook = #{comMngPopulationVO.politicalOutlook} " +
            " </if> " +
            "<if test='comMngPopulationVO.cardNo != null and comMngPopulationVO.cardNo != &quot;&quot;'>" +
            "AND cmp.card_no = #{comMngPopulationVO.cardNo} " +
            " </if> " +
            "<if test='comMngPopulationVO.remark != null and comMngPopulationVO.remark != &quot;&quot;'>" +
            "AND cmp.remark = #{comMngPopulationVO.remark} " +
            " </if> " +
            " </where>" +
            " order by cmp.create_at desc" +
            "</script>")
    IPage<ComMngPopulationVO> pagePopulation(Page page, @Param("comMngPopulationVO") ComMngPopulationDTO comMngPopulationVO);
 
    @Select("<script> " +
            "select cmp.id,cmv.`alley` as areaName,cmp.`name`,cmp.phone,cmp.label as tags,cmp.create_at from com_mng_population as cmp " +
            "left join com_mng_village as cmv on cmv.village_id = cmp.village_id where cmp.act_id = #{pageInputUserDTO.communityId} and cmp.label is not null " +
            "<if test='pageInputUserDTO.name != null and pageInputUserDTO.name != &quot;&quot;'>" +
            " AND cmp.`name` LIKE concat(#{pageInputUserDTO.name},'%') " +
            " </if> " +
            "<if test='pageInputUserDTO.areaName != null and pageInputUserDTO.areaName != &quot;&quot;'>" +
            " AND cmv.`alley` LIKE concat(#{pageInputUserDTO.areaName},'%') " +
            " </if> " +
            "<if test='pageInputUserDTO.tags != null and pageInputUserDTO.tags != &quot;&quot;'>" +
            " AND cmp.label like concat('%',#{pageInputUserDTO.tags},'%') " +
            " </if> " +
            " order by cmp.create_at desc " +
            "</script>")
    IPage<InputUserInfoVO> specialInputUser(Page page, @Param("pageInputUserDTO") PageInputUserDTO pageInputUserDTO);
 
    @Select("select user_id,card_photo_front,card_photo_back,family_book from sys_user where id_card=#{idCard}")
    UserElectronicFileVO getSysUserElectronicFile(@Param("idCard") String idCard);
 
    @Select("select user_id,card_photo_front,card_photo_back,family_book from sys_user where user_id=#{userId}")
    UserElectronicFileVO getSysUserById(@Param("userId") Long userId);
 
    @Select("update sys_user set card_photo_front=#{vo.cardPhotoFront},card_photo_back=#{vo.cardPhotoBack},family_book=#{vo.familyBook} where user_id=#{vo.userId}")
    void updateSysUserElectronicFile(@Param("vo") UserElectronicFileVO vo);
 
    @Select("<script> " +
            "select (select province_name from com_mng_struct_area_province where province_adcode = #{provinceCode}) as province," +
            "(select city_name from com_mng_struct_area_city where city_adcode = #{cityCode}) as city," +
            "(select district_name from com_mng_struct_area_district where district_adcode = #{districtCode}) as district" +
            "</script>")
    AreaAddressVO getAreaAddress(@Param("provinceCode") String provinceCode,@Param("cityCode") String cityCode,@Param("districtCode") String districtCode);
 
    @Select("select count(id) as populationTotal " +
            ",(select count(id) from com_mng_population where act_id = #{communityId} and out_or_local = 1) as localTotal " +
            ",(select count(id) from com_mng_population where act_id = #{communityId} and out_or_local = 2) as outTotal " +
            ",(select count(id) from com_mng_population where act_id = #{communityId} and label is null) as specialTotal " +
            " from com_mng_population as cmp where act_id = #{communityId}")
    ComMngPopulationTotalVO getPopulationTotalByAdmin(@Param("communityId") Long communityId);
}