Browse Source

用户行为 SQL

魏熙美 5 years ago
parent
commit
5a7cefe887

+ 1
- 1
src/main/java/com/huiju/estateagents/controller/StatisticalController.java View File

78
      */
78
      */
79
     @GetMapping(value = "/admin/selectEventAll")
79
     @GetMapping(value = "/admin/selectEventAll")
80
     public ResponseBean selectEventAll(@RequestParam(required = false) String event,
80
     public ResponseBean selectEventAll(@RequestParam(required = false) String event,
81
-                                              @RequestParam(required = false) Integer personId) {
81
+                                              @RequestParam(required = false) String personId) {
82
         return iStatisticalService.selectEventAll(event, personId);
82
         return iStatisticalService.selectEventAll(event, personId);
83
     }
83
     }
84
 
84
 

+ 1
- 1
src/main/java/com/huiju/estateagents/mapper/TaPersonVisitRecordMapper.java View File

44
      */
44
      */
45
     @ResultType(TaPersonVisitRecord.class)
45
     @ResultType(TaPersonVisitRecord.class)
46
     @Select("select * from ta_person_visit_record where event = #{event} and person_id = #{personId}")
46
     @Select("select * from ta_person_visit_record where event = #{event} and person_id = #{personId}")
47
-    List<TaPersonVisitRecord> selectEventAll(@Param("event") String event, @Param("personId") Integer personId);
47
+    List<TaPersonVisitRecord> selectEventAll(@Param("event") String event, @Param("personId") String personId);
48
 
48
 
49
 }
49
 }

+ 1
- 1
src/main/java/com/huiju/estateagents/service/IStatisticalService.java View File

84
      * @param personId
84
      * @param personId
85
      * @return
85
      * @return
86
      */
86
      */
87
-    ResponseBean selectEventAll(String event, Integer personId);
87
+    ResponseBean selectEventAll(String event, String personId);
88
 
88
 
89
     /**
89
     /**
90
      * 转换率 统计
90
      * 转换率 统计

+ 1
- 1
src/main/java/com/huiju/estateagents/service/impl/StatisticalServiceImpl.java View File

187
     }
187
     }
188
 
188
 
189
     @Override
189
     @Override
190
-    public ResponseBean selectEventAll(String event, Integer personId) {
190
+    public ResponseBean selectEventAll(String event, String personId) {
191
         ResponseBean responseBean = new ResponseBean();
191
         ResponseBean responseBean = new ResponseBean();
192
 
192
 
193
         List<TaPersonVisitRecord> taPersonVisitRecords = taPersonVisitRecordMapper.selectEventAll(event, personId);
193
         List<TaPersonVisitRecord> taPersonVisitRecords = taPersonVisitRecordMapper.selectEventAll(event, personId);

+ 22
- 21
src/main/resources/mapper/TaPersonMapper.xml View File

191
         ) AS temp_date
191
         ) AS temp_date
192
 
192
 
193
         LEFT JOIN (
193
         LEFT JOIN (
194
-        SELECT
195
-        COUNT(1) as activityCount,
196
-        tpvr.event_type,
197
-        DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' ) as date
198
-        FROM
199
-        ta_person tp
200
-        INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
201
-        where ifnull(tp.person_type, '') != #{personType}
202
-        <if test="buildingId != null and buildingId != ''">
203
-            and tpvr.building_id = #{buildingId}
204
-        </if>
205
-        <if test="eventType != null and eventType != ''">
206
-            and tpvr.event_type = #{eventType}
207
-        </if>
208
-        <if test="event != null and event != ''">
209
-            and tpvr.event = #{event}
210
-        </if>
211
-        <if test="activity != null and activity != ''">
212
-            and tpvr.activity = #{activity}
213
-        </if>
194
+            SELECT
195
+                COUNT(1) as activityCount,
196
+                tpvr.event_type,
197
+                DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' ) as date
198
+            FROM
199
+              ta_person tp
200
+            INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
201
+            where ifnull(tp.person_type, '') != #{personType}
202
+            <if test="buildingId != null and buildingId != ''">
203
+                and tpvr.building_id = #{buildingId}
204
+            </if>
205
+            <if test="eventType != null and eventType != ''">
206
+                and tpvr.event_type = #{eventType}
207
+            </if>
208
+            <if test="event != null and event != ''">
209
+                and tpvr.event = #{event}
210
+            </if>
211
+            <if test="activity != null and activity != ''">
212
+                and tpvr.activity = #{activity}
213
+            </if>
214
 
214
 
215
-        GROUP BY  tpvr.event_type, DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' )
215
+            GROUP BY  tpvr.event_type, DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' )
216
         ) AS temp ON temp_date.date = temp.date and temp_date.type_id = temp.event_type
216
         ) AS temp ON temp_date.date = temp.date and temp_date.type_id = temp.event_type
217
+        order by temp.date asc
217
     </select>
218
     </select>
218
 
219
 
219
     <select id="selectActiveUserCount" resultType="map">
220
     <select id="selectActiveUserCount" resultType="map">

+ 9
- 3
src/main/resources/mapper/TaPersonVisitRecordMapper.xml View File

8
 
8
 
9
     <select id="selectAll" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
9
     <select id="selectAll" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
10
         SELECT
10
         SELECT
11
-            tpvr.*,
12
-            tp.name as userName,
11
+            tpvr.record_id as recordId,
12
+            tpvr.person_id as personId,
13
+            tpvr.person_type as personType,
14
+            tpvr.building_id as buildingId,
15
+            tpvr.activity as activity,
16
+            (SELECT MIN(t.visit_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event ) as visitTime,
17
+            (SELECT MAX(t.leave_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event ) as leaveTime,
18
+            ifnull(tp.name, tp.nickname) as userName,
13
             tbe.event_name as eventName,
19
             tbe.event_name as eventName,
14
             COUNT(1) as accessCount
20
             COUNT(1) as accessCount
15
         FROM
21
         FROM
32
             </trim>
38
             </trim>
33
 
39
 
34
         GROUP BY tpvr.person_id, tpvr.event
40
         GROUP BY tpvr.person_id, tpvr.event
35
-        ORDER BY 	tpvr.visit_time ASC
41
+        ORDER BY 	accessCount DESC,tpvr.visit_time DESC
36
     </select>
42
     </select>
37
 
43
 
38
 </mapper>
44
 </mapper>