zhaozhengjie
2022-09-29 fea9a3dfbb66f9717f9bb981cc045efc68d5fc03
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
package com.panzhihua.service_community.dao;
 
import java.util.List;
 
import com.panzhihua.common.model.vos.community.ComActPasswordVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
 
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.PageComActDTO;
import com.panzhihua.common.model.dtos.community.switchs.SearchCommunityDTO;
import com.panzhihua.common.model.vos.community.ComActVO;
import com.panzhihua.common.model.vos.community.ComPopulationActVO;
import com.panzhihua.common.model.vos.community.switchs.CommunitySwitchAllAppletsVO;
import com.panzhihua.common.model.vos.community.switchs.StreetAllAppletsVO;
import com.panzhihua.common.model.vos.grid.EventGridCommunityAdminVO;
import com.panzhihua.service_community.model.dos.ComActDO;
 
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: 社区
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2020-12-07 14:13
 **/
@Mapper
public interface ComActDAO extends BaseMapper<ComActDO> {
    // @Select("<script> " +
    // " <where>" +
    // "<if test='nameCn != null and nameCn.trim() != &quot;&quot;'>" +
    // " </if> " +
    // "<if test='nameCn != null and nameCn.trim() != &quot;&quot;'>" +
    // " </if> " +
    // "<if test='nameCn != null and nameCn.trim() != &quot;&quot;'>" +
    // " </if> " +
    // " </where>" +
    // "</script>")
 
    @Select("<script> " + "SELECT\n" + "c.community_id,\n" + "c.`name`,\n"
        + "ST_Distance_Sphere ( Point ( #{lng}, #{lat} ), Point ( c.lng, c.lat ) ) AS distance \n" + "FROM\n"
        + "com_act c \n" + " <where>" + "<if test='areaCode != null and areaCode.trim() != &quot;&quot;'>"
        + "c.area_code = #{areaCode} \n" + " </if> " + " </where>" + "ORDER BY\n" + "distance ASC"
        + "<if test='lng != null and lng.trim() != &quot;&quot;'>" + " limit 100 " + " </if> " + "</script>")
    List<ComActVO> listCommunity(ComActVO comActVO);
 
    @Select("select district_name from com_mng_struct_area_district where district_adcode=#{areaCode}")
    String selectAreaName(String areaCode);
 
    @Select("<script> " + "SELECT\n" + "a.* \n" + "FROM\n" + "com_act a \n" + " <where>"
        + "<if test='pageComActDTO.name != null and pageComActDTO.name.trim() != &quot;&quot;'>"
        + "and a.name LIKE concat( #{pageComActDTO.name}, '%' ) \n" + " </if> "
        + "<if test='pageComActDTO.areaCode != null and pageComActDTO.areaCode.trim() != &quot;&quot;'>"
        + "AND a.area_code = #{pageComActDTO.areaCode} \n" + " </if> "
        + "<if test='pageComActDTO.createAtBegin != null '>" + "AND a.create_at BETWEEN "
        + "#{pageComActDTO.createAtBegin} \n" + "AND #{pageComActDTO.createAtEnd}" + " </if> " + " </where>"
        + " order by a.create_at desc" + "</script>")
    IPage<ComActVO> pageCommunity(Page page, @Param("pageComActDTO") PageComActDTO pageComActDTO);
 
    @Update("update sys_user u set u.password=#{password} where u.account=#{account} and u.type=3 and u.community_id = ${communityId}")
    void updateAccountPassword(@Param("password") String password, @Param("account") String account,
        @Param("communityId") Long communityId);
 
    @Select("select community_id,`name`,lng,lat from com_act where state = 0 and app_id =#{appId}")
    List<EventGridCommunityAdminVO> getCommunityLists(@Param("appId") String appId);
 
    @Select("select ca.`name`,cmsap.province_name,cmsac.city_name,cmsad.district_name,ca.street_id,ca.community_id,cs.`name` as streetName from com_act as ca \n"
        + "left join com_mng_struct_area_province as cmsap on cmsap.province_adcode = ca.province_code\n"
        + "left join com_mng_struct_area_city as cmsac on cmsac.city_adcode = ca.city_code\n"
        + "left join com_mng_struct_area_district as cmsad on cmsad.district_adcode = ca.area_code\n"
        + "left join com_street as cs on cs.street_id = ca.street_id\n" + "where ca.community_id = ${communityId}")
    ComPopulationActVO getPopulationActById(@Param("communityId") Long communityId);
 
    @Select("select `name`,street_id from com_street where app_id = #{appId}")
    List<StreetAllAppletsVO> getStreetList(String appId);
 
    @Select("select ca.`name`,ca.street_id,ca.community_id,cs.`name` as streetName from com_act as ca left join com_street as cs on cs.street_id = ca.street_id where ca.state = 0 and ca.street_id = #{streetId}")
    List<CommunitySwitchAllAppletsVO> getCommunityListByStreetId(@Param("streetId") Long streetId);
 
    @Select("<script> select ca.`name`,ca.street_id,ca.community_id,cs.`name` as streetName " +
            "from com_act as ca " +
            "left join com_street as cs on cs.street_id = ca.street_id " +
            "where ca.state = 0 and ca.name like concat('%',#{name},'%') <if test='appId !=null and appId !=&quot;&quot;'> and cs.app_id = #{appId} </if> </script> ")
    List<CommunitySwitchAllAppletsVO> getCommunityListByName(@Param("name") String name,@Param("appId") String appId);
 
    @Select("SELECT   c.community_id,    c.`name`,    c.street_id,    cs.`name` as streetName," +
            "round( ST_Distance_Sphere ( Point ( #{communityDTO.longitude}, #{communityDTO.latitude} ), Point ( c.lng, c.lat ) )/ 1000, 2 ) AS distance  " +
            "FROM    com_act c     left join com_street as cs on cs.street_id = c.street_id  " +
            "where cs.area_code = #{communityDTO.areaCode} " +
            "HAVING distance >= 0 and distance <= #{communityDTO.distance}   ORDER BY    distance ASC")
    List<CommunitySwitchAllAppletsVO> getCommunityListByNearby(@Param("communityDTO") SearchCommunityDTO communityDTO);
 
    @Select("<script> select community_id,name,lng,lat from com_act  where state = 0 <if test='areaCode !=null and areaCode !=&quot;&quot;'> and area_code = #{areaCode} </if> </script>")
    List<EventGridCommunityAdminVO> getWestCommunityLists(@Param("areaCode") String areCode);
 
    @Select("select account,plaintext_password as password from com_act where community_id = ${communityId}")
    ComActPasswordVo getCommunityPassword(@Param("communityId") Long communityId);
 
    @Select("select name from com_pb_check_unit where id=#{id}")
    String getUnitName(@Param("id") Long unitId);
 
    @Select("select count(id) from com_pb_check_unit")
    Integer getUnitCount();
 
    @Select("select count(id) from com_pb_member where audit_result=1")
    Integer selectUnitCount();
 
    @Select("select count(id) from com_pb_check_unit")
    Integer selectMemberCount();
 
    @Select("select name from com_pb_check_unit where id=#{id}")
    String selectUnitName(@Param("id") Long id);
 
}