101captain
2021-12-23 5a8a90c095280fbd2106869ecd2bad10e01a57a6
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.panzhihua.service_community.dao.ComPropertyDao">
 
    <resultMap type="com.panzhihua.service_community.entity.ComProperty" id="ComPropertyBaseResultMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="introduction" column="introduction"/>
        <result property="contactName" column="contact_name"/>
        <result property="phone" column="phone"/>
        <result property="address" column="address"/>
        <result property="userId" column="user_id"/>
        <result property="communityId" column="community_id"/>
        <result property="createTime" column="create_time"/>
        <result property="areaId" column="area_id"/>
    </resultMap>
 
    <select id="pageList" resultType="com.panzhihua.common.model.vos.community.ComPropertyVO">
        select t.*,t1.account,t1.password,t2.address as areaName,t3.role_id as roleId from com_property t
        left join sys_user t1 on t.user_id = t1.user_id
        left join com_mng_village t2 on t.area_id = t2.village_id
        left join sys_user_role t3 on t.user_id = t3.user_id
        <where>
            1=1
            <if test="commonPage.name !=null and commonPage.name !=''">
                and t.name like concat(#{commonPage.name},'%')
            </if>
            <if test="commonPage.username !=null and commonPage.username !=''">
                and t.contact_name like concat(#{commonPage.username},'%')
            </if>
            <if test="commonPage.phone !=null and commonPage.phone !=''">
                and t.phone like concat(#{commonPage.phone},'%')
            </if>
            <if test="commonPage.paramId !=null">
                and t.community_id =#{commonPage.paramId}
            </if>
            <if test="commonPage.areaId !=null">
                and t.area_id =#{commonPage.areaId}
            </if>
        </where>
        order by t.create_time desc
    </select>
    <select id="getRepairPolylineDate" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT DATE_FORMAT( p1.create_time, '%m' ) AS filed, COUNT(1) AS num FROM com_property_repair p1
        LEFT JOIN com_property p2 ON p1.property_id = p2.id
        WHERE p2.community_id = #{communityId} AND DATE_FORMAT( p1.create_time, '%Y' ) = DATE_FORMAT( CURDATE( ) , '%Y' ) GROUP BY filed
    </select>
    <select id="getRepairTotalPolylineDate"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT COUNT(1) AS num FROM com_property_repair p1
        LEFT JOIN com_property p2 ON p1.property_id = p2.id
        WHERE p2.community_id = #{communityId} AND DATE_FORMAT( p1.create_time, '%Y%m' ) &lt;= #{date}
    </select>
    <select id="getEventAddPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT DATE_FORMAT( e.create_at, '%m' ) AS filed, COUNT(e.id) AS num
        FROM `event` AS e
        LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        WHERE e.event_category = 1 AND e.event_type IN ( 1, 2, 3, 5, 6 ) AND e.event_status = 2 AND egd.grid_community_id = #{communityId}
                AND DATE_FORMAT( e.create_at, '%Y' ) = DATE_FORMAT( CURDATE( ) , '%Y' ) GROUP BY filed
        UNION ALL SELECT
                DATE_FORMAT( create_at, '%m' ) AS filed,  COUNT(id) AS num
        FROM com_act_easy_photo WHERE community_id = #{communityId} AND `status` IN (1,2,4) AND del_tag = 0 AND classify_id IN (1,3,4,5,6,7,8) AND DATE_FORMAT( create_at, '%Y' ) = DATE_FORMAT( CURDATE( ) , '%Y' ) GROUP BY filed
    </select>
    <select id="getEventTotalPolylineDate"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT SUM(num) AS num FROM (
        SELECT COUNT(e.id) AS num
        FROM `event` AS e
        LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        WHERE e.event_category = 1 AND e.event_type IN ( 1, 2, 3, 5, 6 ) AND e.event_status = 2 AND egd.grid_community_id = #{communityId}
                AND DATE_FORMAT( e.create_at, '%Y%m' ) &lt;= #{date}
        UNION ALL SELECT
                COUNT(id) AS num
        FROM com_act_easy_photo WHERE community_id = #{communityId} AND `status` IN (1,2,4) AND del_tag = 0 AND classify_id IN (1,3,4,5,6,7,8) AND DATE_FORMAT( create_at, '%Y%m' ) &lt;= #{date}
        ) temp
    </select>
 
</mapper>