From 69f019d28997cb231fad5ff4541449f35ce92428 Mon Sep 17 00:00:00 2001
From: tangxiaobao <303826152@qq.com>
Date: 星期五, 20 八月 2021 16:42:10 +0800
Subject: [PATCH] 实有人口和社区关系以及对应标签修改

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java |   59 +++++++++++++++++++++++++++++++----------------------------
 1 files changed, 31 insertions(+), 28 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 814a7b3..222a9ef 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
@@ -172,7 +172,7 @@
             "AND cmpct.label LIKE concat('%',#{comMngPopulationVO.label},'%') " +
             " </if> " +
             "<if test='comMngPopulationVO.actId != null'>" +
-            " and cmp.act_id = #{comMngPopulationVO.actId} " +
+            " and cmpct.community_id = #{comMngPopulationVO.actId} " +
             " </if> " +
             "<if test='comMngPopulationVO.outOrLocal != null'>" +
             " and cmp.out_or_local = #{comMngPopulationVO.outOrLocal} " +
@@ -272,46 +272,48 @@
     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 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 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(village_id) from com_mng_village where community_id = #{communityId}) as villageTotal " +
-            ",(select count(cmp.id) from com_mng_population cmp left join com_mng_population_community_tags cmpct on cmp.id = cmpct.population_id where cmp.act_id = #{communityId} and cmpct.label LIKE CONCAT('%','吸毒人员','%')) as drugTotal " +
-            ",(select count(cmp.id) from com_mng_population cmp left join com_mng_population_community_tags cmpct on cmp.id = cmpct.population_id where cmp.act_id = #{communityId} and cmpct.label LIKE CONCAT('%','社区矫正','%')) as correctTotal " +
-            ",(select count(cmp.id) from com_mng_population cmp left join com_mng_population_community_tags cmpct on cmp.id = cmpct.population_id where cmp.act_id = #{communityId} and cmpct.label LIKE CONCAT('%','精神障碍患者','%')) as majorTotal " +
-            ",(select count(cmp.id) from com_mng_population cmp left join com_mng_population_community_tags cmpct on cmp.id = cmpct.population_id where cmp.act_id = #{communityId} and cmpct.label LIKE CONCAT('%','邪教人员','%')) as cultTotal " +
-            ",(select count(cmp.id) from com_mng_population cmp left join com_mng_population_community_tags cmpct on cmp.id = cmpct.population_id where cmp.act_id = #{communityId} and cmpct.label LIKE CONCAT('%','刑满释放','%')) as rehabilitationTotal " +
-            ",(select count(cmp.id) from com_mng_population cmp left join com_mng_population_community_tags cmpct on cmp.id = cmpct.population_id where cmp.act_id = #{communityId} and cmpct.label LIKE CONCAT('%','重点人员','%')) as keyTotal " +
-            ",(select count(cmp.id) from com_mng_population cmp left join com_mng_population_community_tags cmpct on cmp.id = cmpct.population_id where cmp.act_id = #{communityId} and cmpct.label LIKE CONCAT('%','退役军人','%')) as veteransTotal " +
-            ",(select count(cmp.id) from com_mng_population cmp left join com_mng_population_community_tags cmpct on cmp.id = cmpct.population_id where cmp.act_id = #{communityId} and cmpct.label LIKE CONCAT('%','残疾人','%')) as disabilityTotal " +
-            ",(select count(cmp.id) from com_mng_population cmp left join com_mng_population_community_tags cmpct on cmp.id = cmpct.population_id where cmp.act_id = #{communityId} and cmpct.label LIKE CONCAT('%','低保户','%')) as lowSecurityTotal " +
-            " from com_mng_population as cmp where act_id = #{communityId}")
+            ",(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 " +
+            ",(select count(id) from com_mng_population_community_tags where community_id = #{communityId} and label LIKE CONCAT('%','精神障碍患者','%')) as majorTotal " +
+            ",(select count(id) from com_mng_population_community_tags where community_id = #{communityId} and label LIKE CONCAT('%','邪教人员','%')) as cultTotal " +
+            ",(select count(id) from com_mng_population_community_tags where community_id = #{communityId} and label LIKE CONCAT('%','刑满释放','%')) as rehabilitationTotal " +
+            ",(select count(id) from com_mng_population_community_tags where community_id = #{communityId} and label LIKE CONCAT('%','重点人员','%')) as keyTotal " +
+            ",(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}")
     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 " +
-            " from com_mng_population as cmp " +
-            " where act_id = #{communityId}")
+            " com_mng_population_community_tags as cmpct " +
+            " where community_id = = #{communityId}")
     IndexBasicsStatisticsVO getScreenIndexByBasics(@Param("communityId") Long communityId);
 
     @Select("SELECT " +
             " IFNULL( NULL, 1 ) AS type, " +
-            " count( id ) AS sum  " +
+            " count( cmpct.id ) AS sum  " +
             "FROM " +
-            " com_mng_population  " +
+            " com_mng_population_community_tags as cmpct  " +
+            " left join com_mng_population  as cmp on cmpct.population_id = cmp.id " +
             "WHERE " +
-            " sex = 1  " +
-            " AND act_id = #{communityId} UNION ALL " +
+            " cmp.sex = 1  " +
+            " AND cmpct.community_id = #{communityId} UNION ALL " +
             "SELECT " +
             " IFNULL( NULL, 2 ) AS type, " +
             " count( id ) AS sum  " +
             "FROM " +
-            " com_mng_population  " +
+            " com_mng_population_community_tags as cmpct  " +
+            " left join com_mng_population  as cmp on cmpct.population_id = cmp.id " +
             "WHERE " +
-            " sex = 2  " +
-            " AND act_id = #{communityId}")
+            " cmp.sex = 2  " +
+            " AND cmpct.community_id = #{communityId}")
     List<IndexPopulationSexStatisticsVO> getScreenIndexByPopulationSex(@Param("communityId") Long communityId);
 
     @Select("SELECT " +
@@ -458,7 +460,7 @@
     @Select("SELECT " +
             " count( id )  " +
             "FROM " +
-            " com_mng_population  " +
+            " com_mng_population_community_tags  " +
             "WHERE " +
             " label like concat('%',#{label},'%')")
     Integer getSpecialStatisticsByLabel(@Param("label") String label);
@@ -886,12 +888,12 @@
 
     @Select("SELECT " +
             " count( id ) AS specialTotal, " +
-            " ( SELECT count( id ) FROM com_mng_population WHERE label IS NOT NULL AND act_id = #{communityId} AND create_at < #{lastMonth} ) AS toMonthSpecialTotal  " +
+            " ( SELECT count( id ) FROM com_mng_population_community_tags WHERE label IS NOT NULL AND community_id = #{communityId} AND create_at < #{lastMonth} ) AS toMonthSpecialTotal  " +
             "FROM " +
-            " com_mng_population AS cmp  " +
+            " com_mng_population_community_tags AS cmpct  " +
             "WHERE " +
             " label IS NOT NULL  " +
-            " AND act_id = #{communityId}")
+            " AND community_id = #{communityId}")
     CivilPopulationStatisticsVO getCivilScreenPopulation(@Param("communityId") Long communityId, @Param("lastMonth") Date lastMonth);
 
     @Select("SELECT `NAME`, " +
@@ -918,7 +920,8 @@
     CivilVillageStatisticsVO getCivilScreenVillageStatistics(@Param("villageId") Long villageId);
 
 
-    @Select("SELECT COUNT(id) AS man,(SELECT COUNT(id) FROM com_mng_population WHERE sex = 2 AND act_id = #{communityId}) AS woman FROM com_mng_population WHERE sex = 1 AND act_id = #{communityId}")
+    @Select("SELECT COUNT(cmpct.id) AS man,(SELECT COUNT(cmpct.id) 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}) AS woman " +
+            "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}")
     Map<String, Long> countBySex(@Param("communityId") Long communityId);
 
     @Select(

--
Gitblit v1.7.1