huanghongfa
2021-05-28 54ad966d0b142c97fc659263b51d1ea5d7b5c7c6
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationHouseDAO.java
@@ -1,6 +1,10 @@
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.vos.community.*;
import com.panzhihua.common.model.vos.user.ComMngHouseVo;
import com.panzhihua.service_community.model.dos.ComMngPopulationHouseDO;
import org.apache.ibatis.annotations.Mapper;
@@ -22,4 +26,152 @@
            " 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 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.houseNum = #{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> " +
            " </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);
}