huanghongfa
2021-07-05 2dcf4b9d75cc1b6613aea59cec4a0f9cc97f1c0e
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java
@@ -4,7 +4,11 @@
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.grid.PageComMngPopulationDTO;
import com.panzhihua.common.model.dtos.grid.PagePopulationListDTO;
import com.panzhihua.common.model.dtos.grid.admin.ComMngPopulationExportDTO;
import com.panzhihua.common.model.dtos.grid.admin.ComMngPopulationListDTO;
import com.panzhihua.common.model.dtos.grid.admin.PageComMngVillagePopulationDTO;
import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
import com.panzhihua.common.model.vos.area.AreaAddressVO;
import com.panzhihua.common.model.vos.community.ComActMessageVO;
@@ -15,8 +19,12 @@
import com.panzhihua.common.model.vos.community.screen.event.*;
import com.panzhihua.common.model.vos.community.screen.index.*;
import com.panzhihua.common.model.vos.grid.EventGridDataVO;
import com.panzhihua.common.model.vos.grid.EventSpecialPopulationVO;
import com.panzhihua.common.model.vos.grid.PopulationDetailVO;
import com.panzhihua.common.model.vos.grid.PopulationListVO;
import com.panzhihua.common.model.vos.grid.admin.ComMngPopulationListVO;
import com.panzhihua.common.model.vos.grid.admin.ComMngVillagePopulationListVO;
import com.panzhihua.common.model.vos.grid.admin.PopulationStatisticsVO;
import com.panzhihua.common.model.vos.user.*;
import com.panzhihua.common.model.vos.community.PageComActMessageVO;
import com.panzhihua.common.model.vos.user.ComHouseMemberVo;
@@ -702,8 +710,7 @@
            " AND e.event_type IN ( 1, 2, 3, 4, 5, 6 )  " +
            " AND e.event_status = 2  " +
            " AND egd.grid_community_id = #{communityId}  " +
            " AND e.happen_time BETWEEN date_add( curdate(), INTERVAL - DAY ( curdate())+ 1 DAY )  " +
            " AND date_add( curdate()- DAY ( curdate())+ 1, INTERVAL 1 MONTH ) UNION ALL " +
            " AND e.create_at >= DATE_SUB(CURDATE(),INTERVAL 30 DAY) UNION ALL " +
            "SELECT " +
            " IFNULL( NULL, 7 ) AS type, " +
            " id AS eventId, " +
@@ -714,8 +721,7 @@
            " community_id = #{communityId}  " +
            " AND del_tag = 0  " +
            " AND lng_lat IS NOT NULL  " +
            " AND create_at BETWEEN date_add( curdate(), INTERVAL - DAY ( curdate())+ 1 DAY )  " +
            " AND date_add( curdate()- DAY ( curdate())+ 1, INTERVAL 1 MONTH )")
            " AND create_at >= DATE_SUB(CURDATE(),INTERVAL 30 DAY)")
    List<EventGridIncidentStatisticsVO> getEventScreenEventList(@Param("communityId") Long communityId);
    @Select("SELECT " +
@@ -910,4 +916,176 @@
            " id = #{populationId}")
    PopulationDetailVO getPopulationDetailApp(@Param("populationId") Long populationId);
    @Select("<script> " +
            "SELECT " +
            " *  " +
            "FROM " +
            " ( " +
            " SELECT " +
            " cmp.id, " +
            "  cmp.`name` AS userName, " +
            "  cmp.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, " +
            "  ( SELECT event_status FROM event_visiting_tasks WHERE event_status in (1,2,3,5) AND visiter_id = cmp.id ORDER BY create_at DESC LIMIT 1 ) AS eventStatus, " +
            "  ( SELECT create_at FROM event_visiting_tasks WHERE event_status in (1,2,3,5) AND visiter_id = cmp.id ORDER BY create_at DESC LIMIT 1 ) AS createAt " +
            " FROM " +
            " com_mng_population AS cmp where 1=1 " +
            "<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},'%') or cmp.address like concat (#{populationListDTO.keyWord},'%')) " +
            " </if> " +
            "<if test='populationListDTO.label != null and populationListDTO.label != &quot;&quot;'>" +
            "AND cmp.label like concat ('%',#{populationListDTO.label},'%') " +
            " </if> " +
            "<if test='populationListDTO.sex != null'>" +
            "AND cmp.sex = #{populationListDTO.sex} " +
            " </if> " +
            "<if test='populationListDTO.isHouse != null and populationListDTO.isHouse == 1'>" +
            "AND cmp.house_id is not null " +
            " </if> " +
            "<if test='populationListDTO.isHouse != null and populationListDTO.isHouse == 2'>" +
            "AND cmp.house_id is null " +
            " </if> " +
            "<if test='populationListDTO.communityId != null'>" +
            "AND cmp.act_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>")
    IPage<ComMngPopulationListVO> getGridPopulationAdminList(Page page,@Param("populationListDTO") ComMngPopulationListDTO populationListDTO);
    @Select("select relation from com_mng_population_house_user where house_id = #{houseId} and popul_id = #{populationId}")
    Integer getPopulationRelationByHouseId(@Param("houseId") Long houseId, @Param("populationId") Long populationId);
    @Select("<script>" +
            " select count(id) from event_visiting_tasks as evt where visiter_id in " +
            "<foreach collection='ids' item='id' index='index' open='(' close=')' separator=',' >" +
            "#{id}" +
            "</foreach>" +
            " </script>")
    Integer getPopulationVisitingCount(@Param("ids") List<Long> ids);
    @Select("<script> " +
            "SELECT " +
            "   cmp.id, " +
            "   cmp.`name`, " +
            "   cmp.card_no as idCard, " +
            "   cmp.label, " +
            "   cmp.sex, " +
            "   IFNULL( cmp.phone, '暂无' ) as phone, " +
            "   cmp.address, " +
            "   cmp.political_outlook " +
            "  FROM " +
            "   com_mng_population AS cmp where 1=1 " +
            "<if test='populationDTO.keyWord != null'>" +
            " AND (cmp.name like concat(#{populationDTO.keyWord},'%') or cmp.card_no_str like concat(#{populationDTO.keyWord},'%')) " +
            " </if> " +
            " </script>")
    IPage<EventSpecialPopulationVO> getBuildingHousePopulationList(Page page,@Param("populationDTO") PageComMngPopulationDTO populationDTO);
    @Select("<script> " +
            "SELECT " +
            " count( id ) AS localNum, " +
            " ( SELECT count( id ) FROM com_mng_population WHERE out_or_local = 2 " +
            "<if test='communityId != null and communityId != 0'>" +
            " AND act_id = #{communityId} " +
            " </if> " +
            " ) AS flowNum, " +
            " ( SELECT count( id ) FROM com_mng_population WHERE label IS NOT NULL " +
            "<if test='communityId != null and communityId != 0'>" +
            " AND act_id = #{communityId} " +
            " </if> " +
            " ) AS specialNum  " +
            "FROM " +
            " com_mng_population  " +
            "WHERE " +
            " out_or_local = 1 " +
            "<if test='communityId != null and communityId != 0'>" +
            " AND act_id = #{communityId} " +
            " </if> " +
            " </script>")
    PopulationStatisticsVO getGridPopulationStatistics(@Param("communityId") Long communityId);
    @Select("<script> " +
            "SELECT " +
            " *  " +
            "FROM " +
            " ( " +
            " SELECT " +
            " cmp.id, " +
            "  cmp.`name` AS userName, " +
            "  cmp.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, " +
            "  ( SELECT event_status FROM event_visiting_tasks WHERE event_status in (1,2,3,5) AND visiter_id = cmp.id ORDER BY create_at DESC LIMIT 1 ) AS eventStatus, " +
            "  ( SELECT create_at FROM event_visiting_tasks WHERE event_status in (1,2,3,5) AND visiter_id = cmp.id ORDER BY create_at DESC LIMIT 1 ) AS createAt " +
            " FROM " +
            " com_mng_population AS cmp where 1=1 " +
            "<if test='populationExportDTO.keyWord != null and populationExportDTO.keyWord != &quot;&quot;'>" +
            "AND (cmp.name like concat (#{populationExportDTO.keyWord},'%') or cmp.card_no_str like concat (#{populationExportDTO.keyWord},'%') or cmp.address like concat (#{populationExportDTO.keyWord},'%')) " +
            " </if> " +
            "<if test='populationExportDTO.label != null and populationExportDTO.label != &quot;&quot;'>" +
            "AND cmp.label like concat ('%',#{populationExportDTO.label},'%') " +
            " </if> " +
            "<if test='populationExportDTO.sex != null'>" +
            "AND cmp.sex = #{populationExportDTO.sex} " +
            " </if> " +
            "<if test='populationExportDTO.isHouse != null and populationExportDTO.isHouse == 1'>" +
            "AND cmp.house_id is not null " +
            " </if> " +
            "<if test='populationExportDTO.populationIds != null and populationExportDTO.populationIds.size > 0'>" +
            "AND cmp.id in  " +
            "<foreach item='item' collection='populationExportDTO.populationIds' separator=',' open='(' close=')' index=''>" +
            "#{item}" +
            "</foreach>" +
            " </if> " +
            "<if test='populationExportDTO.isHouse != null and populationExportDTO.isHouse == 2'>" +
            "AND cmp.house_id is null " +
            " </if> " +
            "<if test='populationExportDTO.communityId != null'>" +
            "AND cmp.act_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>")
    List<ComMngPopulationListVO> getGridPopulationAdminLists(@Param("populationExportDTO") ComMngPopulationExportDTO populationExportDTO);
    @Select("<script> " +
            " select id,`name`,card_no,label from com_mng_population where 1=1 " +
            "<if test='villagePopulationDTO.villageId != null'>" +
            " and village_id = #{villagePopulationDTO.villageId} " +
            " </if> " +
            "<if test='villagePopulationDTO.keyWord != null'>" +
            " AND (name like concat (#{villagePopulationDTO.keyWord},'%') or card_no_str like concat (#{villagePopulationDTO.keyWord},'%'))  " +
            " </if> " +
            "<if test='villagePopulationDTO.label != null and villagePopulationDTO.label != &quot;&quot;'>" +
            " AND label like concat ('%',#{villagePopulationDTO.label},'%')  " +
            " </if> " +
            " </script>")
    IPage<ComMngVillagePopulationListVO> getVillagePopulationAdmin(Page page,@Param("villagePopulationDTO") PageComMngVillagePopulationDTO villagePopulationDTO);
}