From d7a8baeff8b0e68c54a959e5f46f639c54aad1d1 Mon Sep 17 00:00:00 2001
From: 罗元桥 <2376770955@qq.com>
Date: 星期一, 27 九月 2021 17:15:29 +0800
Subject: [PATCH] Merge branch 'test_bak' into 'master'

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java |   93 +++++++++++++++++++++++-----------------------
 1 files changed, 46 insertions(+), 47 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java
index abc5173..7ca614d 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java
@@ -4,6 +4,8 @@
 import java.util.List;
 import java.util.Map;
 
+import com.panzhihua.common.model.dtos.community.CascadeHouseDTO;
+import com.panzhihua.common.model.vos.community.VillageVO;
 import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -156,9 +158,9 @@
     IPage<InputUserInfoVO> specialInputUser(Page page, @Param("pageInputUserDTO") PageInputUserDTO pageInputUserDTO);
 
     @Select("<script> "
-        + "select id,tag_name,community_id,create_at,sys_flag from com_mng_user_tag where community_id = #{comMngUserTagDTO.communityId}"
+        + "select id,tag_name,community_id,create_at,sys_flag from com_mng_user_tag <where> "
         + "<if test='comMngUserTagDTO.tagName != null and comMngUserTagDTO.tagName != &quot;&quot;'>"
-        + " AND tag_name LIKE concat(#{comMngUserTagDTO.tagName},'%') " + " </if> " + " order by create_at desc "
+        + " AND tag_name LIKE concat(#{comMngUserTagDTO.tagName},'%') " + " </if> " + "</where>" + " order by create_at desc "
         + "</script>")
     IPage<ComMngTagVO> specialInputUserTags(Page page, @Param("comMngUserTagDTO") PageInputUserDTO comMngUserTagDTO);
 
@@ -179,10 +181,10 @@
     AreaAddressVO getAreaAddress(@Param("provinceCode") String provinceCode, @Param("cityCode") String cityCode,
         @Param("districtCode") String districtCode);
 
-    @Select("select count(id) as populationTotal "
+    @Select("select count(cmpct.id) as populationTotal "
         + ",(select count(cmpct.id) from com_mng_population_community_tags cmpct left join com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = #{communityId} and cmp.out_or_local = 1) as localTotal "
         + ",(select count(cmpct.id) from com_mng_population_community_tags cmpct left join com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = #{communityId} and cmp.out_or_local = 2) as outTotal "
-        + ",(select count(cmpct.id) from com_mng_population_community_tags cmpct left join com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = #{communityId} and cmpct.label is not null) as specialTotal "
+        + ",(select count(cmpct.id) from com_mng_population_community_tags cmpct left join com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = #{communityId} and IFNULL(cmpct.label,'') != '') as specialTotal "
         + ",(select count(village_id) from com_mng_village where community_id = #{communityId}) as villageTotal "
         + ",(select count(id) from com_mng_population_community_tags where community_id = #{communityId} and label LIKE CONCAT('%','吸毒人员','%')) as drugTotal "
         + ",(select count(id) from com_mng_population_community_tags where community_id = #{communityId} and label LIKE CONCAT('%','社区矫正','%')) as correctTotal "
@@ -193,21 +195,22 @@
         + ",(select count(id) from com_mng_population_community_tags where community_id = #{communityId} and label LIKE CONCAT('%','退役军人','%')) as veteransTotal "
         + ",(select count(id) from com_mng_population_community_tags where community_id = #{communityId} and label LIKE CONCAT('%','残疾人','%')) as disabilityTotal "
         + ",(select count(id) from com_mng_population_community_tags where community_id = #{communityId} and label LIKE CONCAT('%','低保户','%')) as lowSecurityTotal "
-        + " from com_mng_population_community_tags as cmpct where community_id = #{communityId}")
+        + " from com_mng_population_community_tags as cmpct inner join com_mng_population as cmp on cmp.id = cmpct.population_id where community_id = #{communityId}")
     ComMngPopulationTotalVO getPopulationTotalByAdmin(@Param("communityId") Long communityId);
 
-    @Select("select count(id) as populationTotal,"
-        + "IFNULL((select count(id) from com_mng_population_house where community_id = cmp.act_id),0) as houseTotal, "
-        + "IFNULL((select count(id) from com_mng_real_company where community_id = cmp.act_id),0) as companyTotal, "
-        + "IFNULL((select count(village_id) from com_mng_village where community_id = cmp.act_id),0) as villageTotal "
-        + " com_mng_population_community_tags as cmpct " + " where community_id = = #{communityId}")
+    @Select("select count(id) as populationTotal," +
+            "IFNULL((select count(id) from com_mng_population_house where community_id = cmpct.community_id),0) as houseTotal, " +
+            "IFNULL((select count(id) from com_mng_real_company where community_id = cmpct.community_id),0) as companyTotal, " +
+            "IFNULL((select count(village_id) from com_mng_village where community_id = cmpct.community_id),0) as villageTotal " +
+            " from com_mng_population_community_tags AS cmpct " +
+            " where cmpct.community_id = #{communityId}")
     IndexBasicsStatisticsVO getScreenIndexByBasics(@Param("communityId") Long communityId);
 
     @Select("SELECT " + " IFNULL( NULL, 1 ) AS type, " + " count( cmpct.id ) AS sum  " + "FROM "
         + " com_mng_population_community_tags as cmpct  "
         + " left join com_mng_population  as cmp on cmpct.population_id = cmp.id " + "WHERE " + " cmp.sex = 1  "
         + " AND cmpct.community_id = #{communityId} UNION ALL " + "SELECT " + " IFNULL( NULL, 2 ) AS type, "
-        + " count( id ) AS sum  " + "FROM " + " com_mng_population_community_tags as cmpct  "
+        + " count( cmpct.id ) AS sum  " + "FROM " + " com_mng_population_community_tags as cmpct  "
         + " left join com_mng_population  as cmp on cmpct.population_id = cmp.id " + "WHERE " + " cmp.sex = 2  "
         + " AND cmpct.community_id = #{communityId}")
     List<IndexPopulationSexStatisticsVO> getScreenIndexByPopulationSex(@Param("communityId") Long communityId);
@@ -270,8 +273,8 @@
     List<ComMngUserTagVO> getUserTagListByCommunityId(@Param("communityId") Long communityId);
 
     @Select("SELECT " + " count( id )  " + "FROM " + " com_mng_population_community_tags  " + "WHERE "
-        + " label like concat('%',#{label},'%')")
-    Integer getSpecialStatisticsByLabel(@Param("label") String label);
+        + " community_id = #{communityId} and label like concat('%',#{label},'%')")
+    Integer getSpecialStatisticsByLabel(@Param("label") String label,@Param("communityId") Long communityId);
 
     @Select("<script> " + "SELECT " + " count( egd.id ) AS gridTotal, "
         + " ( SELECT count( user_id ) FROM sys_user WHERE community_id = egd.grid_community_id AND type = 6 ) AS gridMemberTotal, "
@@ -403,7 +406,7 @@
         + " AND create_at <![CDATA[>=]]> #{screenEventDTO.startTime} " + " </if> "
         + "<if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>"
         + " AND create_at <![CDATA[<=]]> #{screenEventDTO.endTime} " + " </if> " + "), 0 ) AS eventSSPTotal, "
-        + " IFNULL(( SELECT count( id ) FROM com_act_easy_photo WHERE del_tag = 0 AND handle_status = 2 AND community_id = #{screenEventDTO.communityId} "
+        + " IFNULL(( SELECT count( id ) FROM com_act_easy_photo WHERE del_tag = 0 AND status = 4 AND community_id = #{screenEventDTO.communityId} "
         + "<if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>"
         + " AND create_at <![CDATA[>=]]> #{screenEventDTO.startTime} " + " </if> "
         + "<if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>"
@@ -506,15 +509,15 @@
     @Select("SELECT " + "(SELECT COUNT(aa.age) FROM "
         + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population as cmp left join com_mng_population_community_tags as cmpct on cmp.id = cmpct.population_id WHERE cmpct.community_id = #{communityId}) as aa where aa.age<= 16) as age16,"
         + "(SELECT COUNT(aa.age) FROM "
-        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population as cmp left join com_mng_population_community_tags as cmpct on cmp.id = cmpct.population_id WHERE cmpct.community_id = #{communityId}) AS aa WHERE aa.age > 16 and aa.age<= 27) AS age27,"
+        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population_community_tags as capct left join com_mng_population as cmp on cmp.id = capct.population_id and capct.community_id =  #{communityId}) AS aa WHERE aa.age > 16 and aa.age<= 27) AS age27,"
         + "(SELECT COUNT(aa.age) FROM "
-        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population as cmp left join com_mng_population_community_tags as cmpct on cmp.id = cmpct.population_id  WHERE cmpct.community_id = #{communityId}) AS aa WHERE aa.age > 27 and aa.age<= 35) AS age35,"
+        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population_community_tags as capct left join com_mng_population as cmp on cmp.id = capct.population_id and capct.community_id = #{communityId}) AS aa WHERE aa.age > 27 and aa.age<= 35) AS age35,"
         + "(SELECT COUNT(aa.age) FROM "
-        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population as cmp left join com_mng_population_community_tags as cmpct on cmp.id = cmpct.population_id  WHERE cmpct.community_id = #{communityId}) AS aa WHERE aa.age > 35 and aa.age<= 45) AS age45,"
+        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population_community_tags as capct left join com_mng_population as cmp on cmp.id = capct.population_id and capct.community_id = #{communityId}) AS aa WHERE aa.age > 35 and aa.age<= 45) AS age45,"
         + "(SELECT COUNT(aa.age) FROM "
-        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population as cmp left join com_mng_population_community_tags as cmpct on cmp.id = cmpct.population_id  WHERE cmpct.community_id = #{communityId}) AS aa WHERE aa.age > 45 and aa.age<= 55) AS age55,"
+        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population_community_tags as capct left join com_mng_population as cmp on cmp.id = capct.population_id and capct.community_id = #{communityId}) AS aa WHERE aa.age > 45 and aa.age<= 55) AS age55,"
         + "(SELECT COUNT(aa.age) FROM "
-        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population as cmp left join com_mng_population_community_tags as cmpct on cmp.id = cmpct.population_id  WHERE cmpct.community_id = #{communityId}) AS aa WHERE aa.age > 55) AS age55over")
+        + "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, cmp.birthday, CURDATE()) ) AS age FROM com_mng_population_community_tags as capct left join com_mng_population as cmp on cmp.id = capct.population_id and capct.community_id = #{communityId}) AS aa WHERE aa.age > 55) AS age55over")
     Map<String, Long> indexCountByAge(@Param("communityId") Long communityId);
 
     @Select("SELECT " + " id, " + " su.nick_name AS userName, " + " su.image_url, " + " caep.create_at, "
@@ -547,15 +550,6 @@
     @Select("select count(id) from com_elders_auth_elderly WHERE community_id = #{communityId}")
     Integer getStatisticsCount(@Param("communityId") Long communityId);
 
-    @Select("<script> "
-        + "select cmp.id,cmp.`name`,cmp.phone,cmp.card_no,cmpct.label,cmp.address,cmp.nation,cmp.political_outlook,cmv.lng,cmv.lat"
-        + ",cmp.sex from com_mng_population as cmp left join com_mng_village as cmv on cmv.village_id = cmp.village_id "
-        + " left join com_mng_population_community_tags as cmpct on cmp.id = cmpct.population_id  "
-        + " where cmpct.community_id = #{populationListDTO.communityId}"
-        + "<if test='populationListDTO.keyWord != null and populationListDTO.keyWord != &quot;&quot;'>"
-        + "AND (cmp.`name` like concat (#{populationListDTO.keyWord},'%') or cmp.card_no_str like concat (#{populationListDTO.keyWord},'%'))  "
-        + " </if> " + "<if test='populationListDTO.label != null and populationListDTO.label != &quot;&quot;'>"
-        + "AND cmpct.label like concat ('%',#{populationListDTO.label},'%') " + " </if> " + " </script>")
     IPage<PopulationListVO> pagePopulationListApp(Page page,
         @Param("populationListDTO") PagePopulationListDTO populationListDTO);
 
@@ -566,10 +560,10 @@
         + " cmp.census_register, " + " cmp.out_or_local, " + " cmp.remark, " + " cmp.marriage " + "FROM "
         + " com_mng_population AS cmp " + " LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cmp.village_id  "
         + " left join com_mng_population_community_tags as cmpct on cmp.id = cmpct.population_id  " + "WHERE "
-        + " id = #{populationId}")
+        + " cmp.id = #{populationId}")
     PopulationDetailVO getPopulationDetailApp(@Param("populationId") Long populationId);
 
-    @Select("<script> " + "SELECT " + " *  " + "FROM " + " ( " + " SELECT " + " cmp.id, " + "  cmp.`name` AS userName, "
+    @Select("<script> " + " SELECT " + " cmp.id, " + "  cmp.`name` AS userName, "
         + "  cmpct.label, " + "  cmp.card_no, " + "  cmp.card_no_str, " + "  cmp.sex, " + "  cmp.address, "
         + "  cmp.political_outlook, " + "  cmp.census_register, " + "  cmp.house_id, " + "  cmp.phone, "
         + "  IFNULL(cmp.house_id,0) as isHouse, "
@@ -588,9 +582,7 @@
         + "AND cmp.house_id is null " + " </if> " + "<if test='populationListDTO.communityId != null'>"
         + "AND cmpct.community_id = #{populationListDTO.communityId} " + " </if> "
         + "<if test='populationListDTO.politicalOutlook != null'>"
-        + "AND cmp.political_outlook = #{populationListDTO.politicalOutlook} " + " </if> "
-        + " ) as population where 1=1 " + "<if test='populationListDTO.eventStatus != null'>"
-        + "AND population.eventStatus = #{populationListDTO.eventStatus} " + " </if> " + " </script>")
+        + "AND cmp.political_outlook = #{populationListDTO.politicalOutlook} " + " </if> " + " </script>")
     IPage<ComMngPopulationListVO> getGridPopulationAdminList(Page page,
         @Param("populationListDTO") ComMngPopulationListDTO populationListDTO);
 
@@ -601,6 +593,12 @@
         + "<foreach collection='ids' item='id' index='index' open='(' close=')' separator=',' >" + "#{id}"
         + "</foreach>" + " </script>")
     Integer getPopulationVisitingCount(@Param("ids") List<Long> ids);
+
+    /**
+     * 综治后台删除居民,并清理人口与社区绑定关系
+     * @param ids   需要删除的人口id集合
+     */
+    void deletePopulaitonRelation(@Param("ids") List<Long> ids);
 
     @Select("<script> " + "SELECT " + "   cmp.id, " + "   cmp.`name`, " + "   cmp.card_no as idCard, "
         + "   cmpct.label, " + "   cmp.sex, " + "   IFNULL( cmp.phone, '暂无' ) as phone, " + "   cmp.address, "
@@ -616,18 +614,15 @@
         @Param("populationDTO") PageComMngPopulationDTO populationDTO);
 
     @Select("<script> " + "SELECT " + " count( id ) AS localNum, "
-        + " ( SELECT count( cmpct.id ) FROM com_mng_population_community_tags as cmpct left join com_mng_population as cmp on cmp.id = cmpct.population_id WHERE cmp.out_or_local = 2 "
-        + "<if test='communityId != null and communityId != 0'>" + " AND cmpct.community_id = #{communityId} "
-        + " </if> " + " ) AS flowNum, "
-        + " ( SELECT count( cmpct.id ) FROM com_mng_population_community_tags as cmpct left join com_mng_population as cmp on cmp.id = cmpct.population_id WHERE cmpct.label IS NOT NULL "
-        + "<if test='communityId != null and communityId != 0'>" + " AND cmpct.community_id = #{communityId} "
-        + " </if> " + " ) AS specialNum  " + "FROM "
-        + " com_mng_population_community_tags as cmpct left join com_mng_population as cmp on cmp.id = cmpct.population_id  "
-        + "WHERE " + " cmp.out_or_local = 1 " + "<if test='communityId != null and communityId != 0'>"
-        + " AND cmpct.community_id = #{communityId} " + " </if> " + " </script>")
+        + " ( SELECT count( cmp.id ) FROM com_mng_population as cmp WHERE cmp.out_or_local = 2 "
+        +  " ) AS flowNum, "
+        + " ( SELECT count( cmpct.id ) FROM com_mng_population as cmp left join com_mng_population_community_tags AS cmpct on cmp.id = cmpct.population_id WHERE cmpct.label IS NOT NULL "
+        + " ) AS specialNum  " + "FROM "
+        + " com_mng_population as cmp  "
+        + "WHERE " + " cmp.out_or_local = 1 " + " </script>")
     PopulationStatisticsVO getGridPopulationStatistics(@Param("communityId") Long communityId);
 
-    @Select("<script> " + "SELECT " + " *  " + "FROM " + " ( " + " SELECT " + " cmp.id, " + "  cmp.`name` AS userName, "
+    @Select("<script> " + " SELECT " + " cmp.id, " + "  cmp.`name` AS userName, "
         + "  cmpct.label, " + "  cmp.card_no, " + "  cmp.card_no_str, " + "  cmp.sex, " + "  cmp.address, "
         + "  cmp.political_outlook, " + "  cmp.census_register, " + "  cmp.house_id, " + "  cmp.phone, "
         + "  IFNULL(cmp.house_id,0) as isHouse, "
@@ -650,14 +645,12 @@
         + "AND cmp.house_id is null " + " </if> " + "<if test='populationExportDTO.communityId != null'>"
         + "AND cmpct.community_id = #{populationExportDTO.communityId} " + " </if> "
         + "<if test='populationExportDTO.politicalOutlook != null'>"
-        + "AND cmp.political_outlook = #{populationExportDTO.politicalOutlook} " + " </if> "
-        + " ) as population where 1=1 " + "<if test='populationExportDTO.eventStatus != null'>"
-        + "AND population.eventStatus = #{populationExportDTO.eventStatus} " + " </if> " + " </script>")
+        + "AND cmp.political_outlook = #{populationExportDTO.politicalOutlook} " + " </if> " + " </script>")
     List<ComMngPopulationListVO>
         getGridPopulationAdminLists(@Param("populationExportDTO") ComMngPopulationExportDTO populationExportDTO);
 
     @Select("<script> "
-        + " select cmp.id,cmp.`name`,cmp.card_no,cmtct.label from com_mng_population as cmp left join com_mng_population_community_tags AS cmpct on cmp.id = cmpct.population_id where 1=1 "
+        + " select cmp.id,cmp.`name`,cmp.card_no,cmpct.label from com_mng_population as cmp left join com_mng_population_community_tags AS cmpct on cmp.id = cmpct.population_id where 1=1 "
         + "<if test='villagePopulationDTO.villageId != null'>"
         + " and cmp.village_id = #{villagePopulationDTO.villageId} " + " </if> "
         + "<if test='villagePopulationDTO.keyWord != null'>"
@@ -692,4 +685,10 @@
 
     void updateAll(@Param("populationList") List<ComMngPopulationDO> populationList);
 
+    /**
+     * 房屋二级联动
+     * @param communityId
+     * @return
+     */
+    List<VillageVO> getSecondHouseAddress(Long communityId);
 }

--
Gitblit v1.7.1