101captain
2022-03-09 9c5b811fb700bc66e66dbf38ed8733e57a4edac6
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
<?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 filed, SUM(num) AS num FROM (
        SELECT DATE_FORMAT( p1.create_time, '%Y-%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-%m' ) &gt; DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
                        UNION ALL SELECT * FROM
                        (
                            SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
                            SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
                        ) temT
        ) temp GROUP BY filed ORDER BY filed ASC
    </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 filed, SUM(num) AS num FROM (
        SELECT DATE_FORMAT( e.create_at, '%Y-%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-%m' ) &gt; DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
        UNION ALL SELECT
                DATE_FORMAT( create_at, '%Y-%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-%m' ) &gt; DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
                UNION ALL SELECT * FROM
                (
                    SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
                ) temT
        ) temp GROUP BY filed ORDER BY filed ASC
    </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>