From 588f18d1a9ebcdb8bd68d03b1c1057617542bf22 Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Mon, 13 Feb 2023 22:28:51 +0800 Subject: [PATCH] 1 --- web/src/main/resources/sql/jlw/student.md | 73 +++++++++++++---------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/web/src/main/resources/sql/jlw/student.md b/web/src/main/resources/sql/jlw/student.md index c0e08e4f..887926d1 100644 --- a/web/src/main/resources/sql/jlw/student.md +++ b/web/src/main/resources/sql/jlw/student.md @@ -1570,6 +1570,7 @@ queryStudentLoginLogByCondition td.universities_colleges_province, td.class_name ) z + order by z.login_time desc queryStudentUseLogByCondition === @@ -1672,6 +1673,7 @@ queryStudentUseLogByCondition tb.application_name, td.class_name ) z + order by z.login_time desc queryStudentLogAnalysisByCondition === @@ -1682,34 +1684,45 @@ queryStudentLogAnalysisByCondition Z.* @} FROM ( - SELECT - @// 日期 - DATE_FORMAT(ta.create_time, '%Y-%m-%d') as time, + SELECT + zz.time, + zz.universities_colleges_name, + zz.universities_colleges_province, + zz.login_count, + @// 当前时间和日志的创建是同一天的话,在线人数就根据人头数来算。否则就是0 + ( CASE WHEN TO_DAYS( now()) = TO_DAYS( zz.time ) THEN zz.on_line_count ELSE 0 END ) AS on_line_count + FROM + ( + SELECT + @// 日期 + DATE_FORMAT(ta.create_time, '%Y-%m-%d') as time, + te.universities_colleges_name, + te.universities_colleges_province, + count( 1 ) AS login_count, + count( ta.user_id ) AS on_line_count + FROM + sys_log ta + LEFT JOIN student t ON ta.user_id = t.user_id + LEFT JOIN school_class td ON td.class_id = t.class_id + LEFT JOIN universities_colleges te ON te.universities_colleges_id = td.universities_colleges_id + WHERE + 1 + AND te.universities_colleges_id IS NOT NULL + @// 用来过滤院校管理员所能查看的数据 + @if(!isEmpty(universitiesCollegesId)) { + and te.universities_colleges_id = #universitiesCollegesId# + and t.student_id is not null + @} + @if(!isEmpty(loginStartTime)) { + and ta.create_time >= #loginStartTime# + @} + @if(!isEmpty(loginEndTime)) { + and ta.create_time <= #loginEndTime# + @} + GROUP BY + `time`, te.universities_colleges_name, - te.universities_colleges_province, - count( 1 ) AS login_count, - count( DISTINCT ta.user_id ) AS on_line_count - FROM - sys_log ta - LEFT JOIN student t ON ta.user_id = t.user_id - LEFT JOIN school_class td ON td.class_id = t.class_id - LEFT JOIN universities_colleges te ON te.universities_colleges_id = td.universities_colleges_id - WHERE - 1 - AND te.universities_colleges_id IS NOT NULL - @// 用来过滤院校管理员所能查看的数据 - @if(!isEmpty(universitiesCollegesId)) { - and te.universities_colleges_id = #universitiesCollegesId# - and t.student_id is not null - @} - @if(!isEmpty(loginStartTime)) { - and ta.create_time >= #loginStartTime# - @} - @if(!isEmpty(loginEndTime)) { - and ta.create_time <= #loginEndTime# - @} - GROUP BY - DATE_FORMAT(ta.create_time, '%Y-%m-%d'), - te.universities_colleges_name, - te.universities_colleges_province - ) Z \ No newline at end of file + te.universities_colleges_province + ) zz + ) Z + order by z.time desc \ No newline at end of file