瀏覽代碼

拆分统计

魏熙美 5 年之前
父節點
當前提交
4a63baa580

+ 49
- 2
src/main/java/com/huiju/estateagents/controller/StatisticalController.java 查看文件

64
     public ResponseBean selectUserBehavior(@RequestParam(required = false) Integer pageNum,
64
     public ResponseBean selectUserBehavior(@RequestParam(required = false) Integer pageNum,
65
                                            @RequestParam(required = false) Integer pageCode,
65
                                            @RequestParam(required = false) Integer pageCode,
66
                                            @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
66
                                            @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
67
-                                           @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate) {
68
-        return iStatisticalService.selectUserBehavior(pageNum, pageCode, startDate, endDate);
67
+                                           @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
68
+                                           @RequestParam(value = "buildingId", required = false) String buildingId) {
69
+        return iStatisticalService.selectUserBehavior(pageNum, pageCode, startDate, endDate, buildingId);
69
     }
70
     }
70
 
71
 
71
     /**
72
     /**
91
     }
92
     }
92
 
93
 
93
 
94
 
95
+    /**
96
+     * 用户总数
97
+     * @return
98
+     */
99
+    @GetMapping(value = "/admin/selectUserCount")
100
+    public ResponseBean selectUserResource() {
101
+        return iStatisticalService.selectUserCount();
102
+    }
103
+
104
+    /**
105
+     * 用户注册数
106
+     * @return
107
+     */
108
+    @GetMapping(value = "/admin/selectRegisteredCount")
109
+    public ResponseBean selectRegisteredCount() {
110
+        return iStatisticalService.selectRegisteredCount();
111
+    }
112
+
113
+    /**
114
+     * 用户最近七天
115
+     * @return
116
+     */
117
+    @GetMapping(value = "/admin/selectRecentlyCount")
118
+    public ResponseBean selectRecentlyCount(@RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
119
+                                            @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate endDate) {
120
+        return iStatisticalService.selectRecentlyCount(startDate, endDate);
121
+    }
122
+
123
+    /**
124
+     * 性别比例
125
+     * @return
126
+     */
127
+    @GetMapping(value = "/admin/selectSexUser")
128
+    public ResponseBean selectSexUser() {
129
+        return iStatisticalService.selectSexUser();
130
+    }
131
+
132
+    /**
133
+     * 城市比例
134
+     * @return
135
+     */
136
+    @GetMapping(value = "/admin/selectCityUser")
137
+    public ResponseBean selectCityUser() {
138
+        return iStatisticalService.selectCityUser();
139
+    }
140
+
94
 
141
 
95
 }
142
 }

+ 1
- 1
src/main/java/com/huiju/estateagents/mapper/TaPersonMapper.java 查看文件

86
      * @param endDate
86
      * @param endDate
87
      * @return
87
      * @return
88
      */
88
      */
89
-    List<PersonPO> selectUserBehavior(@Param("personType") String personType, @Param("startDate")LocalDate startDate, @Param("endDate")LocalDate endDate);
89
+    List<PersonPO> selectUserBehavior(@Param("personType") String personType, @Param("startDate")LocalDate startDate, @Param("endDate")LocalDate endDate, @Param("buildingId") String buildingId);
90
 
90
 
91
     /**
91
     /**
92
      * 活跃用户数 / 最近新增的用户数
92
      * 活跃用户数 / 最近新增的用户数

+ 1
- 1
src/main/java/com/huiju/estateagents/mapper/TaPersonVisitRecordMapper.java 查看文件

30
      * @param page
30
      * @param page
31
      * @return
31
      * @return
32
      */
32
      */
33
-    IPage<TaPersonVisitRecord> selectAll(IPage<TaPersonVisitRecord> page);
33
+    IPage<TaPersonVisitRecord> selectAll(IPage<TaPersonVisitRecord> page, String buildingId);
34
 
34
 
35
 
35
 
36
     /**
36
     /**

+ 34
- 1
src/main/java/com/huiju/estateagents/service/IStatisticalService.java 查看文件

16
      */
16
      */
17
     ResponseBean indexStatistical();
17
     ResponseBean indexStatistical();
18
 
18
 
19
+    // ----------------   用户统计 start --------------
20
+    /**
21
+     * 用户总数
22
+     * @return
23
+     */
24
+    ResponseBean selectUserCount();
25
+
26
+    /**
27
+     * 注册数
28
+     * @return
29
+     */
30
+    ResponseBean selectRegisteredCount();
31
+
32
+    /**
33
+     * 用户最近七天
34
+     * @return
35
+     */
36
+    ResponseBean selectRecentlyCount(LocalDate startDate, LocalDate endDate);
37
+
38
+    // ----------------   用户统计 end --------------
39
+
40
+    /**
41
+     * 性别比例
42
+     * @return
43
+     */
44
+    ResponseBean selectSexUser();
45
+
46
+    /**
47
+     * 城市比例
48
+     * @return
49
+     */
50
+    ResponseBean selectCityUser();
51
+
19
     /**
52
     /**
20
      * 活跃用户数
53
      * 活跃用户数
21
      * @return
54
      * @return
36
      * @param endDate
69
      * @param endDate
37
      * @return
70
      * @return
38
      */
71
      */
39
-    ResponseBean selectUserBehavior(Integer pageNum, Integer pageSize, LocalDate startDate,LocalDate endDate);
72
+    ResponseBean selectUserBehavior(Integer pageNum, Integer pageSize, LocalDate startDate,LocalDate endDate, String buildingId);
40
 
73
 
41
     /**
74
     /**
42
      * 行为分析的 具体数据列表
75
      * 行为分析的 具体数据列表

+ 75
- 4
src/main/java/com/huiju/estateagents/service/impl/StatisticalServiceImpl.java 查看文件

10
 import com.huiju.estateagents.po.PersonPO;
10
 import com.huiju.estateagents.po.PersonPO;
11
 import com.huiju.estateagents.service.IStatisticalService;
11
 import com.huiju.estateagents.service.IStatisticalService;
12
 import lombok.extern.slf4j.Slf4j;
12
 import lombok.extern.slf4j.Slf4j;
13
+import org.omg.CORBA.OBJECT_NOT_EXIST;
13
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.stereotype.Service;
15
 import org.springframework.stereotype.Service;
15
 
16
 
58
         Integer selectRecentlyCount = taPersonMapper.selectRecentlyCount(CommConstant.PERSON_REALTY_CONSULTANT, null, null);
59
         Integer selectRecentlyCount = taPersonMapper.selectRecentlyCount(CommConstant.PERSON_REALTY_CONSULTANT, null, null);
59
 
60
 
60
         // 用户行为
61
         // 用户行为
61
-        List<PersonPO> selectUserBehavior = taPersonMapper.selectUserBehavior(CommConstant.PERSON_REALTY_CONSULTANT, null, null);
62
+        List<PersonPO> selectUserBehavior = taPersonMapper.selectUserBehavior(CommConstant.PERSON_REALTY_CONSULTANT, null, null, null);
62
 
63
 
63
         // 用户活跃数
64
         // 用户活跃数
64
         List<Map<String, Object>> selectActiveUserCount = taPersonMapper.selectActiveUserCount(CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.DAY, null, null);
65
         List<Map<String, Object>> selectActiveUserCount = taPersonMapper.selectActiveUserCount(CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.DAY, null, null);
160
     }
161
     }
161
 
162
 
162
     @Override
163
     @Override
163
-    public ResponseBean selectUserBehavior(Integer pageNum, Integer pageSize, LocalDate startDate, LocalDate endDate) {
164
+    public ResponseBean selectUserBehavior(Integer pageNum, Integer pageSize, LocalDate startDate, LocalDate endDate, String buildingId) {
164
         ResponseBean responseBean = new ResponseBean();
165
         ResponseBean responseBean = new ResponseBean();
165
 
166
 
166
         // 用户行为
167
         // 用户行为
167
-        List<PersonPO> selectUserBehavior = taPersonMapper.selectUserBehavior(CommConstant.PERSON_REALTY_CONSULTANT, startDate, endDate);
168
+        List<PersonPO> selectUserBehavior = taPersonMapper.selectUserBehavior(CommConstant.PERSON_REALTY_CONSULTANT, startDate, endDate, buildingId);
168
 
169
 
169
         IPage<TaPersonVisitRecord> page = new Page<>(pageNum, pageSize);
170
         IPage<TaPersonVisitRecord> page = new Page<>(pageNum, pageSize);
170
-        IPage<TaPersonVisitRecord> visitRecordIPage = taPersonVisitRecordMapper.selectAll(page);
171
+        IPage<TaPersonVisitRecord> visitRecordIPage = taPersonVisitRecordMapper.selectAll(page, buildingId);
171
 
172
 
172
         Map<String, Object> map = new HashMap<>();
173
         Map<String, Object> map = new HashMap<>();
173
         map.put("selectUserBehavior", selectUserBehavior);
174
         map.put("selectUserBehavior", selectUserBehavior);
267
         responseBean.addSuccess(result);
268
         responseBean.addSuccess(result);
268
         return responseBean;
269
         return responseBean;
269
     }
270
     }
271
+
272
+
273
+    @Override
274
+    public ResponseBean selectUserCount() {
275
+        ResponseBean responseBean = new ResponseBean();
276
+        // 总用户数
277
+        Integer selectUserCount = taPersonMapper.selectUserCount(CommConstant.PERSON_REALTY_CONSULTANT);
278
+        Map<String, Object> map = new HashMap<>();
279
+        map.put("selectUserCount", selectUserCount);
280
+        responseBean.addSuccess(map);
281
+        return responseBean;
282
+    }
283
+
284
+    @Override
285
+    public ResponseBean selectRegisteredCount() {
286
+        ResponseBean responseBean = new ResponseBean();
287
+        // 注册数
288
+        Integer selectRegisteredCount = taPersonMapper.selectRegisteredCount(CommConstant.PERSON_REALTY_CONSULTANT);
289
+        Map<String, Object> map = new HashMap<>();
290
+        map.put("selectRegisteredCount", selectRegisteredCount);
291
+        responseBean.addSuccess(map);
292
+        return responseBean;
293
+    }
294
+
295
+    @Override
296
+    public ResponseBean selectRecentlyCount(LocalDate startDate, LocalDate endDate) {
297
+        ResponseBean responseBean = new ResponseBean();
298
+        // 最近七天
299
+        Integer selectRecentlyCount = taPersonMapper.selectRecentlyCount(CommConstant.PERSON_REALTY_CONSULTANT, startDate, endDate);
300
+        Map<String, Object> map = new HashMap<>();
301
+        map.put("selectRecentlyCount", selectRecentlyCount);
302
+        responseBean.addSuccess(map);
303
+        return responseBean;
304
+    }
305
+
306
+    @Override
307
+    public ResponseBean selectSexUser() {
308
+        ResponseBean responseBean = new ResponseBean();
309
+
310
+        // 性别比例
311
+        // 1 男 2 女
312
+        Integer selectSexMale = taPersonMapper.selectSexUser(CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.SEX_MALE);
313
+        Integer selectSexFemale = taPersonMapper.selectSexUser(CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.SEX_FEMALE);
314
+        Map<String, Object> selectSexMaleMap = new HashMap<>();
315
+        selectSexMaleMap.put("name", "男");
316
+        selectSexMaleMap.put("value", selectSexMale);
317
+        Map<String, Object> selectSexFemaleMap = new HashMap<>();
318
+        selectSexFemaleMap.put("name", "女");
319
+        selectSexFemaleMap.put("value", selectSexFemale);
320
+        List<Map<String, Object>> selectSexUser = new ArrayList<>();
321
+        selectSexUser.add(selectSexMaleMap);
322
+        selectSexUser.add(selectSexFemaleMap);
323
+
324
+        Map<String, Object> map = new HashMap<>();
325
+        map.put("selectSexUser", selectSexUser);
326
+        responseBean.addSuccess(map);
327
+        return responseBean;
328
+    }
329
+
330
+    @Override
331
+    public ResponseBean selectCityUser() {
332
+        ResponseBean responseBean = new ResponseBean();
333
+
334
+        // 城市比例
335
+        List<Map<String, Object>> selectCityUser = taPersonMapper.selectCityUser(CommConstant.PERSON_REALTY_CONSULTANT);
336
+        Map<String, Object> map = new HashMap<>();
337
+        map.put("selectCityUser", selectCityUser);
338
+        responseBean.addSuccess(map);
339
+        return responseBean;
340
+    }
270
 }
341
 }

+ 3
- 0
src/main/resources/mapper/TaPersonMapper.xml 查看文件

199
         ta_person tp
199
         ta_person tp
200
         INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
200
         INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
201
         where ifnull(tp.person_type, '') != #{personType}
201
         where ifnull(tp.person_type, '') != #{personType}
202
+        <if test="buildingId != null and buildingId != ''">
203
+            and tpvr.building_id = #{buildingId}
204
+        </if>
202
         GROUP BY  tpvr.event_type, DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' )
205
         GROUP BY  tpvr.event_type, DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' )
203
         ) AS temp ON temp_date.date = temp.date and temp_date.type_id = temp.event_type
206
         ) AS temp ON temp_date.date = temp.date and temp_date.type_id = temp.event_type
204
     </select>
207
     </select>

+ 5
- 0
src/main/resources/mapper/TaPersonVisitRecordMapper.xml 查看文件

14
         FROM
14
         FROM
15
             ta_person_visit_record tpvr
15
             ta_person_visit_record tpvr
16
             LEFT JOIN ta_person tp ON tpvr.person_id = tp.person_id
16
             LEFT JOIN ta_person tp ON tpvr.person_id = tp.person_id
17
+            <where>
18
+                <if test="buildingId != null and buildingId != ''">
19
+                    tpvr.building_id = #{buildingId}
20
+                </if>
21
+            </where>
17
         GROUP BY tpvr.person_id, tpvr.event
22
         GROUP BY tpvr.person_id, tpvr.event
18
     </select>
23
     </select>
19
 
24