mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?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.name 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>
    <select id="getAlarmBaseData"
            resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenAlarmStatisticsInfo">
        SELECT
        (SELECT COUNT(id) FROM com_property_equipment WHERE community_id = #{communityId} AND `type` = 2) AS abnormalAlarmTotal,
        (SELECT COUNT(id) FROM com_property_equipment WHERE community_id = #{communityId} AND `type` = 1) AS oneKeyAlarmTotal,
        (SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
        WHERE t2.community_id = #{communityId} AND t2.`type` = 2) AS abnormalTotal,
        (SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
        WHERE t2.community_id = #{communityId} AND t2.`type` = 1) AS oneKeyTotal,
        (SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
        WHERE t2.community_id = #{communityId} AND t1.`status` = 0 AND t1.`type` = 2) AS pendingAbnormalTotal,
        (SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
        WHERE t2.community_id = #{communityId} AND t1.`status` = 1 AND t1.`type` = 2) AS completeAbnormalTotal,
        (SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
        WHERE t2.community_id = #{communityId} AND t1.`status` = 0 AND t1.`type` = 1 and t1.serial_no not like '70%') AS pendingServiceTotal,
        (SELECT COUNT(t1.id) FROM com_property_alarm t1 LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
        WHERE t2.community_id = #{communityId} AND t1.`status` = 1 AND t1.`type` = 1 and t1.serial_no not like '70%') AS completeServiceTotal
    </select>
    <select id="retrieveAbnormalAddPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT filed, SUM(num) AS num FROM (
            SELECT DATE_FORMAT( t.create_time, '%Y-%m' ) AS filed, COUNT(1) AS num
            FROM com_property_alarm t
            LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
            WHERE t1.community_id = #{communityId} AND t1.`type` = 2 AND DATE_FORMAT( t.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="retrieveAbnormalTotalPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT COUNT( 1 ) AS num
        FROM com_property_alarm t
        LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
        WHERE t1.community_id = #{communityId} AND t1.`type` = 2 AND DATE_FORMAT( t.create_time, '%Y-%m' ) &lt;= #{date}
    </select>
    <select id="retrieveServiceAddPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT filed, SUM(num) AS num FROM (
            SELECT DATE_FORMAT( t.create_time, '%Y-%m' ) AS filed, COUNT(1) AS num
            FROM com_property_alarm t
            LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
            WHERE t1.community_id = #{communityId} AND t1.`type` = 1 AND DATE_FORMAT( t.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="retrieveServiceTotalPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT COUNT( 1 ) AS num
        FROM com_property_alarm t
        LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
        WHERE t1.community_id = #{communityId} AND t1.`type` = 1 AND DATE_FORMAT( t.create_time, '%Y-%m' ) &lt;= #{date}
    </select>
    <select id="getAbnormalList" resultType="com.panzhihua.common.model.vos.property.ComPropertyAlarmVO">
        SELECT
        t.id,
        t.create_time,
        t1.phone,
        t1.username AS name,
        t1.position
        FROM
        com_property_alarm t
        LEFT JOIN com_property_equipment t1 ON t.serial_no = t1.serial_no
        WHERE t1.community_id = #{communityId} AND t.`type` = #{type} AND t.`status` = #{status} and t.serial_no not like '70%'
        ORDER BY t.create_time DESC
    </select>
    <select id="getAlarmPointMapData"
            resultType="com.panzhihua.common.model.vos.property.ComPropertyEquipmentVO">
        SELECT
            id,
            phone,
            username,
            latitude,
            longitude,
            `type`,
            `position`,
            `type` AS equipmentStatus
        FROM com_property_equipment
        WHERE serial_no IN(
            SELECT DISTINCT(t1.serial_no)
            FROM com_property_alarm t1
            LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
            WHERE t2.community_id = #{communityId} AND t1.`status` = 0 and t1.serial_no not like '70%'
        )
        UNION ALL
        SELECT
            id,
            phone,
            username,
            latitude,
            longitude,
            `type`,
            `position`,
            3 AS equipmentStatus
        FROM com_property_equipment
            WHERE community_id = #{communityId} AND serial_no NOT IN(
            SELECT DISTINCT(t1.serial_no)
            FROM com_property_alarm t1
            LEFT JOIN com_property_equipment t2 ON t1.serial_no = t2.serial_no
            WHERE t2.community_id = #{communityId} AND t1.`status` = 0
        ) and serial_no not like '70%'
    </select>
 
    <select id="noticeList" resultType="com.panzhihua.common.model.vos.community.ComActAnnouncementVO">
        select * from com_act_announcement where property_id=#{propertyId}
    </select>
 
</mapper>