张延森 před 5 roky
rodič
revize
596e7351b9

+ 22
- 22
src/main/resources/mapper/TaPersonMapper.xml Zobrazit soubor

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

+ 9
- 3
src/main/resources/mapper/TaPersonVisitRecordMapper.xml Zobrazit soubor

@@ -8,8 +8,14 @@
8 8
 
9 9
     <select id="selectAll" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
10 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 19
             tbe.event_name as eventName,
14 20
             COUNT(1) as accessCount
15 21
         FROM
@@ -32,7 +38,7 @@
32 38
             </trim>
33 39
 
34 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 42
     </select>
37 43
 
38 44
 </mapper>