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
<?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_jinhui_community.dao.JinhuiLargeScreenDao">
 
    <!-- 获取金汇风采数量 -->
    <select id="getMienNum" resultType="String">
        select
            count(id) as number
        from com_act_activity
        where community_id=#{communityId}
    </select>
 
    <!--  获取志愿者服务  -->
    <select id="getVolunteerServeNum" resultType="String">
        select
            count(id) as number
        from com_act_activity
        where community_id=#{communityId}
          and aattend_people in ('志愿者')
    </select>
 
<!--  获取微心愿数量  -->
    <select id="getMicroVolunteeringNum" resultType="String">
        select
            count(id) as number
        from jinhui_micro_volunteering
        where state=#{state}
    </select>
 
    <!--  便民服务商家  -->
    <select id="getConvenientMerchantsNum" resultType="String">
        select
            count(id) as number
        from jinhui_com_convenient_merchants
        <where>
            <if test=" auditType != null and auditType != '' ">
                audit_type=#{auditType}
            </if>
        </where>
    </select>
 
 
    <!--  商家类型  -->
    <select id="getMerchantTypeNum" resultType="com.panzhihua.common.model.vos.jinhui.JinhuiMerchantTypeVO">
        select
            jccsc.name,
            count(jccm.id) as number
        from jinhui_com_convenient_service_categories as jccsc
        left join jinhui_com_convenient_merchants as jccm on jccm.convenient_type=jccsc.id
        GROUP BY jccsc.name
    </select>
 
 
    <!--  商家类型  -->
    <select id="getWorkGuideNum" resultType="String">
        select
            count(id) as number
        from jinhui_com_act_work_guide
    </select>
 
 
    <!--  商家类型  -->
    <select id="getInterspaceApplyNum" resultType="String">
        select
            count(id) as number
        from jinhui_interspace_apply_for
        <where>
            <if test="state!=null and state != ''">
                state=#{state}
            </if>
        </where>
    </select>
 
    <!--  商家类型  -->
    <select id="getShoppingOrderNum" resultType="String">
        select
            count(id) as number
        from jinhui_shopping_order
        <where>
            <if test="cancelType!=null and cancelType != ''">
                cancel_type=#{cancelType}
            </if>
        </where>
    </select>
 
    <!--  党员  志愿者数量  -->
    <select id="baseInfo" resultType="com.panzhihua.common.model.vos.jinhui.JinhuiCommunityServicesVO">
        select
            count(id) as population,
            IFNULL((select count(id) from com_act_announcement where community_id = ${communityId}) ,0) as announcement,
            IFNULL((select count(id) from com_pb_member where community_id = ${communityId} and audit_result =1 ),0) as partyMember,
            IFNULL((select count(id) from com_mng_volunteer_mng where community_id = ${communityId} and state=2 ),0) as volunteer
        from com_mng_population_community_tags AS cmpct
        where cmpct.community_id = ${communityId}
    </select>
 
    <!--  获取社区工作者  -->
    <select id="getServiceTeam" resultType="String">
        SELECT
            count(id) as number
        from com_pb_service_team
        <where>
            1=1
            <if test="communityId != null and communityId !=''">
               and community_id=#{communityId}
            </if>
            <if test="type != null and type !=''">
                and `type`=#{type}
            </if>
        </where>
    </select>
 
 
    <!--  老人手环异常列表数量统计  -->
    <select id="getEarlyWarningNum" resultType="String">
        SELECT
        count(id) as number
        from bracelet_early_warning
        <where>
            1=1
            <if test="disposeType != null and disposeType !=''">
                and dispose_type=#{disposeType}
            </if>
            <if test="communityId != null and communityId !=''">
                and community_id=#{communityId}
            </if>
        </where>
    </select>
 
    <!--  老人手环异常列表  -->
    <select id="getEarlyWarningList" resultType="com.panzhihua.common.model.vos.jinhui.JinhuiOldManVO">
        SELECT
            bew.dispose_time,
            bew.creation_time,
            bew.dispose_type,
            bud.address,
            bud.detail_address,
            bud.mobile,
            bud.bin_phone,
            bud.emergency_contact,
            bud.user_name
        from bracelet_early_warning as bew
        left join bracelet_user_data as bud on bew.equipment_number=bud.device_id
        <where>
            1=1
            <if test="disposeType != null and disposeType !=''">
                and bew.dispose_type=#{disposeType}
            </if>
            <if test="communityId != null and communityId !=''">
                and bew.community_id=#{communityId}
            </if>
        </where>
    </select>
 
 
    <!--  老人手环用户数据  -->
    <select id="getBraceletUser" resultType="String">
        SELECT
            count(bew.id) as number
        from bracelet_user_data as bew
        <where>
            1=1
            <if test="sex != null and sex !=''">
                and bew.sex=#{sex}
            </if>
            <if test="communityId != null and communityId !=''">
                and bew.community_id=#{communityId}
            </if>
        </where>
    </select>
 
 
    <!-- 新增折线数据 -->
    <select id="getEventAddPolylineData"
            resultType="com.panzhihua.common.model.vos.jinhui.JinhuiOldManBrokenLineVO">
        SELECT filed, SUM(num) AS num FROM (
           SELECT DATE_FORMAT( e.creation_time, '%Y-%m' ) AS filed, COUNT(e.id) AS num
           FROM `bracelet_user_data` AS e
           WHERE  e.community_id = #{communityId}
             AND DATE_FORMAT( e.creation_time, '%Y-%m' ) > 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="String">
        SELECT SUM(num) AS num
        FROM (
            SELECT COUNT(e.id) AS num
            FROM `bracelet_user_data` AS e
            WHERE e.community_id = #{communityId}
            AND DATE_FORMAT( e.creation_time, '%Y-%m' ) &lt;=#{date}
        ) temp
    </select>
 
 
 
 
    <select id="getOldManUserDate" resultType="com.panzhihua.common.model.vos.jinhui.JinhuiOldManUserDateVO">
        SELECT
            user_name,
            device_id,
            IFNULL(lng ,add_lng) AS lng,
            IFNULL(lat ,add_lat) as lat,
            is_abnormal
        FROM bracelet_user_data
        WHERE community_id = #{communityId}
    </select>
 
 
    <select id="getEarlyNewDate" resultType="String">
        SELECT
            dispose_type
        FROM bracelet_early_warning
        WHERE community_id = #{communityId} AND equipment_number=#{equipmentNumber}
        order by creation_time desc
        LIMIT 1
    </select>
 
 
 
 
 
</mapper>