72 KiB
queryByCondition
-
根据不为空的参数进行分页查询
select @pageTag(){ t.student_id, t.class_id, t.student_name, t.student_sn, t.student_mobile, t.student_email, t.student_weixin_info, t.student_qq, t.student_gender, t.student_status, t.add_time, t.org_id, t.user_id, t.code_from, a.class_name, b.universities_colleges_name, bb.university_faculty_name, aa.university_system_name, @if(!isEmpty(log)){ d.resources_application_id, TRIM(REPLACE(d.application_name,'子应用','')) platform, @} @if(!isEmpty(competitionId)){ c.team_name, c.team_students_ids, (SELECT GROUP_CONCAT(student_name ORDER BY FIND_IN_SET(student_id,c.team_students_ids)) FROM student WHERE FIND_IN_SET(student_id,c.team_students_ids) ) team_student_names, @} cu.
code
@} from student t LEFT JOIN school_class a ON a.class_id = t.class_id LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id LEFT join university_system aa on a.university_system_id = aa.university_system_id LEFT join university_faculty bb on aa.university_faculty_id = bb.university_faculty_id @if(!isEmpty(competitionId)){ LEFT JOIN ( @if(!isEmpty(studentTempList)){ SELECT
DISTINCT students_id, team_name, team_students_ids from( @for(item in studentTempList){ ( SELECT #item.studentsId# students_id, #item.teamName# team_name, #item.studentsIds# team_students_ids ) #text(itemLP.last?"":"UNION ALL" )# @} )c @}else{ SELECT cs.students_id,
cs.team_name, (SELECT GROUP_CONCAT(students_id ORDER BY students_id) FROM competition_students WHERE team_flag = cs.team_flag AND is_captain = 2 ) team_students_ids -- 队员IDs FROM competition_students cs LEFT JOIN competition c ON c.competition_id = cs.competition_id WHERE c.competition_id = #competitionId# AND cs.is_captain = 1 GROUP BY cs.competition_students_id @} )c ON c.students_id = t.student_id
@} @if(!isEmpty(log)){ LEFT JOIN universities_colleges_jurisdiction_experimental_system c ON c.universities_colleges_id = b.universities_colleges_id AND c.type = 1 AND c.use_type != 0 LEFT JOIN resources_application d ON d.resources_application_id = c.type_id @} LEFT JOIN core_user cu ON cu.id = t.user_id where 1=1
and aa.university_system_status = 1 and bb.university_faculty_status = 1 @//数据权限,该sql语句功能点,如果不考虑数据权限,可以删除此行
and #function("student.query")# @if(!isEmpty(resourcesApplicationId)){ and d.resources_application_id =#resourcesApplicationId# @} @if(!isEmpty(studentId)){ and t.student_id =#studentId# @} @if(!isEmpty(universitiesCollegesId)){ and b.universities_colleges_id =#universitiesCollegesId# @} @if(!isEmpty(classId)){ and t.class_id =#classId# @} @if(!isEmpty(classIds)){ and find_in_set(t.class_id,#classIds#) @} @if(!isEmpty(className)){ and a.class_name like #'%'+className+'%'# @} @if(!isEmpty(universitiesCollegesName)){ and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'# @} @if(!isEmpty(studentName)){ and t.student_name like #'%'+studentName+'%'# @} @if(!isEmpty(studentSn)){ and t.student_sn like #'%'+studentSn+'%'# @} @if(!isEmpty(studentMobile)){ and t.student_mobile =#studentMobile# @} @if(!isEmpty(studentEmail)){ and t.student_email =#studentEmail# @} @if(!isEmpty(studentStatus)){ and t.student_status =#studentStatus# @} @if(!isEmpty(studentStatuses)){ and find_in_set(t.student_status,#studentStatuses#) @} @if(!isEmpty(studentPassword)){ and t.student_password =#studentPassword# @} @if(!isEmpty(addTime)){ and t.add_time =#addTime# @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @if(!isEmpty(userId)){ and t.user_id =#userId# @} @if(!isEmpty(competitionId)){ -- 1只包含参赛学员 2不包含参赛学员 @if(beCompetitionStudent == 1){ @if(!isEmpty(tempStudentIds)){ AND find_in_set(t.student_id,#tempStudentIds#) @}else{ AND find_in_set(t.student_id,IFNULL((SELECT GROUP_CONCAT(students_id) FROM competition_students WHERE competition_id = #competitionId# and case when (select competition_type from competition where competition_id = #competitionId#) = 2 then is_captain = 1 else 1=1 end),"-1")) @} @}else if(beCompetitionStudent == 2){ @if(!isEmpty(tempStudentIds)){ AND NOT find_in_set(t.student_id,#tempStudentIds#) @}else{ AND t.student_id NOT IN (SELECT students_id FROM competition_students WHERE competition_id = #competitionId#) @} @} @} @if(!isEmpty(examId)){ -- 1只包含参赛学员 2不包含参赛学员 @if(beExamStudent == 1){ @if(!isEmpty(tempStudentIds)){ and find_in_set(t.student_id,#tempStudentIds#) @}else{ and t.student_id IN (SELECT students_id FROM exam_students WHERE exam_id = #examId#) @} @}else if(beExamStudent == 2){ @if(!isEmpty(tempStudentIds)){ AND NOT find_in_set(t.student_id,#tempStudentIds#) @}else{ AND t.student_id NOT IN (SELECT students_id FROM exam_students WHERE exam_id = #examId#) @}
@} @} ORDER BY t.add_time DESC
queryByConditionQuery
- 没有权限的查询
select @pageTag(){ t.* @} from student t LEFT JOIN school_class a ON a.class_id = t.class_id LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id where 1=1 @if(!isEmpty(studentId)){ and t.student_id =#studentId# @} @if(!isEmpty(universitiesCollegesId)){ and b.universities_colleges_id =#universitiesCollegesId# @} @if(!isEmpty(universitySystemId)){ and a.university_system_id =#universitySystemId# @} @if(!isEmpty(classId)){ and t.class_id =#classId# @} @if(!isEmpty(classIds)){ and find_in_set(t.class_id ,#classIds#) @} @if(!isEmpty(className)){ and a.class_name like #'%'+className+'%'# @} @if(!isEmpty(universitiesCollegesName)){ and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'# @} @if(!isEmpty(studentName)){ and t.student_name like #'%'+studentName+'%'# @} @if(!isEmpty(studentSn)){ and t.student_sn =#studentSn# @} @if(!isEmpty(studentMobile)){ and t.student_mobile =#studentMobile# @} @if(!isEmpty(studentEmail)){ and t.student_email =#studentEmail# @} @if(!isEmpty(studentStatus)){ and t.student_status =#studentStatus# @} @if(!isEmpty(studentGender)){ and t.student_gender =#studentGender# @} @if(!isEmpty(studentStatuses)){ and find_in_set(t.student_status,#studentStatuses#) @} @if(!isEmpty(studentPassword)){ and t.student_password =#studentPassword# @} @if(!isEmpty(addTime)){ and t.add_time =#addTime# @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @if(!isEmpty(userId)){ and t.user_id =#userId# @} @if(!isEmpty(studentSnOrName)){ and (t.student_sn like #'%'+studentSnOrName+'%'# or t.student_name like #'%'+studentSnOrName+'%'#) @} @if(!isEmpty(orderByRand)){ ORDER BY RAND() @}
queryByCondition2Student
-
根据不为空的参数进行分页查询
select @pageTag(){ t.student_id, t.class_id, t.student_name, t.student_sn, t.student_mobile, t.student_email, t.student_qq, t.student_gender, t.student_status, t.add_time, t.org_id, t.user_id, a.class_name,b.universities_colleges_name, @if(!isEmpty(competitionId)){ c.team_students_ids, (SELECT GROUP_CONCAT(student_name ORDER BY FIND_IN_SET(student_id,c.team_students_ids)) FROM student WHERE FIND_IN_SET(student_id,c.team_students_ids) ) team_student_names, @} cu.code @} from student t LEFT JOIN school_class a ON a.class_id = t.class_id LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id @if(!isEmpty(competitionId)){ LEFT JOIN ( @if(!isEmpty(studentTempList)){ SELECT
DISTINCT students_id, team_name, team_students_ids from( @for(item in studentTempList){ ( SELECT #item.studentsId# students_id, #item.teamName# team_name, #item.studentsIds# team_students_ids ) #text(itemLP.last?"":"UNION ALL" )# @} )c @}else{ SELECT cs.students_id,
cs.team_name, (SELECT GROUP_CONCAT(students_id ORDER BY students_id) FROM competition_students WHERE team_flag = cs.team_flag AND is_captain = 2 ) team_students_ids -- 队员IDs FROM competition_students cs LEFT JOIN competition c ON c.competition_id = cs.competition_id WHERE c.competition_id = #competitionId# AND cs.is_captain = 1 GROUP BY cs.competition_students_id @} )c ON c.students_id = t.student_id
@} left join core_user cu ON cu.id = t.user_id where 1=1
@if(!isEmpty(studentId)){ and t.student_id =#studentId# @} @if(!isEmpty(notStudentId)){ and t.student_id != #notStudentId# @} @if(!isEmpty(universitiesCollegesId)){ and b.universities_colleges_id =#universitiesCollegesId# @} @if(!isEmpty(classId)){ and t.class_id =#classId# @} @if(!isEmpty(className)){ and a.class_name like #'%'+className+'%'# @} @if(!isEmpty(universitiesCollegesName)){ and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'# @} @if(!isEmpty(studentName)){ and t.student_name like #'%'+studentName+'%'# @} @if(!isEmpty(studentSn)){ and t.student_sn =#studentSn# @} @if(!isEmpty(studentMobile)){ and t.student_mobile =#studentMobile# @} @if(!isEmpty(studentEmail)){ and t.student_email =#studentEmail# @} @if(!isEmpty(studentStatus)){ and t.student_status =#studentStatus# @} @if(!isEmpty(studentGender)){ and t.student_gender =#studentGender# @} @if(!isEmpty(studentStatuses)){ and find_in_set(t.student_status,#studentStatuses#) @} @if(!isEmpty(studentPassword)){ and t.student_password =#studentPassword# @} @if(!isEmpty(addTime)){ and t.add_time =#addTime# @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @if(!isEmpty(userId)){ and t.user_id =#userId# @} @if(!isEmpty(competitionId)){ -- 1只包含参赛学员 2不包含参赛学员 @if(beCompetitionStudent == 1){ @if(!isEmpty(tempStudentIds)){ AND find_in_set(t.student_id,#tempStudentIds#) @}else{ AND find_in_set(t.student_id,IFNULL((SELECT GROUP_CONCAT(students_id) FROM competition_students WHERE competition_id = #competitionId# and case when (select competition_type from competition where competition_id = #competitionId#) = 2 then is_captain = 1 else 1=1 end),"-1")) @} @}else if(beCompetitionStudent == 2){ @if(!isEmpty(tempStudentIds)){ AND NOT find_in_set(t.student_id,#tempStudentIds#) @}else{ AND t.student_id NOT IN (SELECT students_id FROM competition_students WHERE competition_id = #competitionId#) @} @} @} @if(!isEmpty(examId)){ -- 1只包含参赛学员 2不包含参赛学员 @if(beExamStudent == 1){ @if(!isEmpty(tempStudentIds)){ and find_in_set(t.student_id,#tempStudentIds#) @}else{ and t.student_id IN (SELECT students_id FROM exam_students WHERE exam_id = #examId#) @} @}else if(beExamStudent == 2){ @if(!isEmpty(tempStudentIds)){ AND NOT find_in_set(t.student_id,#tempStudentIds#) @}else{ AND t.student_id NOT IN (SELECT students_id FROM exam_students WHERE exam_id = #examId#) @}
@} @} ORDER BY t.add_time DESC
deleteStudentByIds
-
批量删除(假删除)
UPDATE
student
SETstudent_status
= 2 WHERE FIND_IN_SET(student_id,#ids#)
deleteByIds
-
批量删除(真删除)
DELETE FROM
student
WHERE FIND_IN_SET(student_id,#ids#)
getByUserId
select t.* from `student` t where t.user_id = #userId#
getByAccount
select t.* from student
t where t.user_id = (select id from core_user where code = #account#)
getByIds
select t.* from student
t where find_in_set(t.student_id,#studentIds#)
getExcelValues
-
根据不为空的参数进行查询Excel所需数据
SELECT * FROM ( ( SELECT MAX(LENGTH(a.class_name)) class_name, MAX(LENGTH(t.student_name)) student_name, MAX(LENGTH(t.student_sn)) student_sn, MAX(LENGTH(t.student_mobile)) student_mobile, MAX(LENGTH(t.student_email)) student_email FROM student AS t LEFT JOIN school_class a ON a.class_id = t.class_id LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id where t.student_status = 1 @if(!isEmpty(universitiesCollegesId)){ and b.universities_colleges_id =#universitiesCollegesId# @} @if(!isEmpty(classId)){ and t.class_id =#classId# @} @if(!isEmpty(className)){ and a.class_name like #'%'+className+'%'# @} @if(!isEmpty(universitiesCollegesName)){ and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'# @} @if(!isEmpty(studentName)){ and t.student_name like #'%'+studentName+'%'# @} @if(!isEmpty(studentSn)){ and t.student_sn like #'%'+studentSn+'%'# @} )
UNION ALL ( SELECT a.class_name, t.student_name, t.student_sn, t.student_mobile, t.student_email FROM student AS t LEFT JOIN school_class a ON a.class_id = t.class_id LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id where t.student_status = 1 @if(!isEmpty(universitiesCollegesId)){ and b.universities_colleges_id =#universitiesCollegesId# @} @if(!isEmpty(classId)){ and t.class_id =#classId# @} @if(!isEmpty(className)){ and a.class_name like #'%'+className+'%'# @} @if(!isEmpty(universitiesCollegesName)){ and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'# @} @if(!isEmpty(studentName)){ and t.student_name like #'%'+studentName+'%'# @} @if(!isEmpty(studentSn)){ and t.student_sn like #'%'+studentSn+'%'# @} )
)t
getExcelValues2Competition
SELECT * FROM (
(
select
MAX(LENGTH(t.student_name)) student_name,
MAX(LENGTH(t.student_sn)) student_sn,
MAX(LENGTH(a.class_name)) class_name,
MAX(LENGTH(b.universities_colleges_name)) universities_colleges_name,
@if(!isEmpty(competitionId)){
MAX(LENGTH(c.team_name)) team_name,
MAX(LENGTH(c.team_students_ids)) team_students_ids,
MAX(LENGTH((SELECT GROUP_CONCAT(student_name ORDER BY FIND_IN_SET(student_id,c.team_students_ids) SEPARATOR ' / ') FROM student WHERE FIND_IN_SET(student_id,c.team_students_ids)))) team_student_names,
@}
MAX(LENGTH(cu.code
)) code
from student t
LEFT JOIN school_class a ON a.class_id = t.class_id
LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id
@if(!isEmpty(competitionId)){
LEFT JOIN (
@if(!isEmpty(studentTempList)){
SELECT
DISTINCT students_id,
team_name,
team_students_ids
from(
@for(item in studentTempList){
(
SELECT
#item.studentsId# students_id,
#item.teamName# team_name,
#item.studentsIds# team_students_ids
)
#text(itemLP.last?"":"UNION ALL" )#
@}
)c
@}else{
SELECT
cs.students_id,
cs.team_name,
(SELECT GROUP_CONCAT(students_id ORDER BY students_id) FROM competition_students WHERE team_flag = cs.team_flag AND is_captain = 2 ) team_students_ids -- 队员IDs
FROM competition_students cs
LEFT JOIN competition c ON c.competition_id = cs.competition_id
WHERE c.competition_id = #competitionId# AND cs.is_captain = 1
GROUP BY cs.competition_students_id
@}
)c ON c.students_id = t.student_id
@}
LEFT JOIN core_user cu ON cu.id = t.user_id
where 1=1
@if(!isEmpty(resourcesApplicationId)){
and d.resources_application_id =#resourcesApplicationId#
@}
@if(!isEmpty(studentId)){
and t.student_id =#studentId#
@}
@if(!isEmpty(universitiesCollegesId)){
and b.universities_colleges_id =#universitiesCollegesId#
@}
@if(!isEmpty(classId)){
and t.class_id =#classId#
@}
@if(!isEmpty(className)){
and a.class_name like #'%'+className+'%'#
@}
@if(!isEmpty(universitiesCollegesName)){
and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'#
@}
@if(!isEmpty(studentName)){
and t.student_name like #'%'+studentName+'%'#
@}
@if(!isEmpty(studentSn)){
and t.student_sn like #'%'+studentSn+'%'#
@}
@if(!isEmpty(studentMobile)){
and t.student_mobile =#studentMobile#
@}
@if(!isEmpty(studentEmail)){
and t.student_email =#studentEmail#
@}
@if(!isEmpty(studentStatus)){
and t.student_status =#studentStatus#
@}
@if(!isEmpty(studentGender)){
and t.student_gender =#studentGender#
@}
@if(!isEmpty(studentPassword)){
and t.student_password =#studentPassword#
@}
@if(!isEmpty(addTime)){
and t.add_time =#addTime#
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@if(!isEmpty(userId)){
and t.user_id =#userId#
@}
@if(!isEmpty(competitionId)){
-- 1只包含参赛学员 2不包含参赛学员
@if(beCompetitionStudent == 1){
@if(!isEmpty(tempStudentIds)){
AND find_in_set(t.student_id,#tempStudentIds#)
@}else{
AND find_in_set(t.student_id,IFNULL((SELECT GROUP_CONCAT(students_id) FROM competition_students WHERE competition_id = #competitionId# and case when (select competition_type from competition where competition_id = #competitionId#) = 2 then is_captain = 1 else 1=1 end),"-1"))
@}
@}else if(beCompetitionStudent == 2){
@if(!isEmpty(tempStudentIds)){
AND NOT find_in_set(t.student_id,#tempStudentIds#)
@}else{
AND t.student_id NOT IN (SELECT students_id FROM competition_students WHERE competition_id = #competitionId#)
@}
@}
@}
@if(!isEmpty(examId)){
-- 1只包含参赛学员 2不包含参赛学员
@if(beExamStudent == 1){
@if(!isEmpty(tempStudentIds)){
and find_in_set(t.student_id,#tempStudentIds#)
@}else{
and t.student_id IN (SELECT students_id FROM exam_students WHERE exam_id = #examId#)
@}
@}else if(beExamStudent == 2){
@if(!isEmpty(tempStudentIds)){
AND NOT find_in_set(t.student_id,#tempStudentIds#)
@}else{
AND t.student_id NOT IN (SELECT students_id FROM exam_students WHERE exam_id = #examId#)
@}
@}
@}
)
UNION ALL
(
select
t.student_name,
t.student_sn,
a.class_name,
b.universities_colleges_name,
@if(!isEmpty(competitionId)){
c.team_name,
c.team_students_ids,
(SELECT GROUP_CONCAT(student_name ORDER BY FIND_IN_SET(student_id,c.team_students_ids) SEPARATOR ' / ') FROM student WHERE FIND_IN_SET(student_id,c.team_students_ids) ) team_student_names,
@}
cu.`code`
from student t
LEFT JOIN school_class a ON a.class_id = t.class_id
LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id
@if(!isEmpty(competitionId)){
LEFT JOIN (
@if(!isEmpty(studentTempList)){
SELECT
DISTINCT students_id,
team_name,
team_students_ids
from(
@for(item in studentTempList){
(
SELECT
#item.studentsId# students_id,
#item.teamName# team_name,
#item.studentsIds# team_students_ids
)
#text(itemLP.last?"":"UNION ALL" )#
@}
)c
@}else{
SELECT
cs.students_id,
cs.team_name,
(SELECT GROUP_CONCAT(students_id ORDER BY students_id) FROM competition_students WHERE team_flag = cs.team_flag AND is_captain = 2 ) team_students_ids -- 队员IDs
FROM competition_students cs
LEFT JOIN competition c ON c.competition_id = cs.competition_id
WHERE c.competition_id = #competitionId# AND cs.is_captain = 1
GROUP BY cs.competition_students_id
@}
)c ON c.students_id = t.student_id
@}
LEFT JOIN core_user cu ON cu.id = t.user_id
where 1=1
@if(!isEmpty(resourcesApplicationId)){
and d.resources_application_id =#resourcesApplicationId#
@}
@if(!isEmpty(studentId)){
and t.student_id =#studentId#
@}
@if(!isEmpty(universitiesCollegesId)){
and b.universities_colleges_id =#universitiesCollegesId#
@}
@if(!isEmpty(classId)){
and t.class_id =#classId#
@}
@if(!isEmpty(className)){
and a.class_name like #'%'+className+'%'#
@}
@if(!isEmpty(universitiesCollegesName)){
and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'#
@}
@if(!isEmpty(studentName)){
and t.student_name like #'%'+studentName+'%'#
@}
@if(!isEmpty(studentSn)){
and t.student_sn like #'%'+studentSn+'%'#
@}
@if(!isEmpty(studentMobile)){
and t.student_mobile =#studentMobile#
@}
@if(!isEmpty(studentEmail)){
and t.student_email =#studentEmail#
@}
@if(!isEmpty(studentStatus)){
and t.student_status =#studentStatus#
@}
@if(!isEmpty(studentGender)){
and t.student_gender =#studentGender#
@}
@if(!isEmpty(studentPassword)){
and t.student_password =#studentPassword#
@}
@if(!isEmpty(addTime)){
and t.add_time =#addTime#
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@if(!isEmpty(userId)){
and t.user_id =#userId#
@}
@if(!isEmpty(competitionId)){
-- 1只包含参赛学员 2不包含参赛学员
@if(beCompetitionStudent == 1){
@if(!isEmpty(tempStudentIds)){
AND find_in_set(t.student_id,#tempStudentIds#)
@}else{
AND find_in_set(t.student_id,IFNULL((SELECT GROUP_CONCAT(students_id) FROM competition_students WHERE competition_id = #competitionId# and case when (select competition_type from competition where competition_id = #competitionId#) = 2 then is_captain = 1 else 1=1 end),"-1"))
@}
@}else if(beCompetitionStudent == 2){
@if(!isEmpty(tempStudentIds)){
AND NOT find_in_set(t.student_id,#tempStudentIds#)
@}else{
AND t.student_id NOT IN (SELECT students_id FROM competition_students WHERE competition_id = #competitionId#)
@}
@}
@}
@if(!isEmpty(examId)){
-- 1只包含参赛学员 2不包含参赛学员
@if(beExamStudent == 1){
@if(!isEmpty(tempStudentIds)){
and find_in_set(t.student_id,#tempStudentIds#)
@}else{
and t.student_id IN (SELECT students_id FROM exam_students WHERE exam_id = #examId#)
@}
@}else if(beExamStudent == 2){
@if(!isEmpty(tempStudentIds)){
AND NOT find_in_set(t.student_id,#tempStudentIds#)
@}else{
AND t.student_id NOT IN (SELECT students_id FROM exam_students WHERE exam_id = #examId#)
@}
@}
@}
)
)t
getStudentValues
-
根据不为空的参数进行查询
select t.*,a.class_name,b.universities_colleges_id,b.universities_colleges_name from student t LEFT JOIN school_class a ON a.class_id = t.class_id LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id where 1=1
@if(!isEmpty(studentId)){ and t.student_id =#studentId# @} @if(!isEmpty(universitiesCollegesId)){ and b.universities_colleges_id =#universitiesCollegesId# @} @if(!isEmpty(classId)){ and t.class_id =#classId# @} @if(!isEmpty(className)){ and a.class_name like #'%'+className+'%'# @} @if(!isEmpty(universitiesCollegesName)){ and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'# @} @if(!isEmpty(studentName)){ and t.student_name like #'%'+studentName+'%'# @} @if(!isEmpty(studentSn)){ and t.student_sn =#studentSn# @} @if(!isEmpty(studentMobile)){ and t.student_mobile =#studentMobile# @} @if(!isEmpty(studentEmail)){ and t.student_email =#studentEmail# @} @if(!isEmpty(studentStatus)){ and t.student_status =#studentStatus# @} @if(!isEmpty(studentGender)){ and t.student_gender =#studentGender# @} @if(!isEmpty(studentPassword)){ and t.student_password =#studentPassword# @} @if(!isEmpty(addTime)){ and t.add_time =#addTime# @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @if(!isEmpty(userId)){ and t.user_id =#userId# @}
getValuesByQuery
-
根据不为空的参数进行查询
select t.*,a.class_name,b.universities_colleges_id,b.universities_colleges_name,t.student_id value,t.student_name name from student t LEFT JOIN school_class a ON a.class_id = t.class_id LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id where 1=1
@if(!isEmpty(studentId)){ and t.student_id =#studentId# @} @if(!isEmpty(universitiesCollegesId)){ and b.universities_colleges_id =#universitiesCollegesId# @} @if(!isEmpty(universitySystemId)){ and a.university_system_id =#universitySystemId# @} @if(!isEmpty(classId)){ and t.class_id =#classId# @} @if(!isEmpty(classIds)){ and find_in_set(t.class_id ,#classIds#) @} @if(!isEmpty(className)){ and a.class_name like #'%'+className+'%'# @} @if(!isEmpty(universitiesCollegesName)){ and b.universities_colleges_name like #'%'+universitiesCollegesName+'%'# @} @if(!isEmpty(studentName)){ and t.student_name like #'%'+studentName+'%'# @} @if(!isEmpty(studentSn)){ and t.student_sn =#studentSn# @} @if(!isEmpty(studentMobile)){ and t.student_mobile =#studentMobile# @} @if(!isEmpty(studentEmail)){ and t.student_email =#studentEmail# @} @if(!isEmpty(studentStatus)){ and t.student_status =#studentStatus# @} @if(!isEmpty(studentGender)){ and t.student_gender =#studentGender# @} @if(!isEmpty(studentStatuses)){ and find_in_set(t.student_status,#studentStatuses#) @} @if(!isEmpty(studentPassword)){ and t.student_password =#studentPassword# @} @if(!isEmpty(addTime)){ and t.add_time =#addTime# @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @if(!isEmpty(userId)){ and t.user_id =#userId# @} @if(!isEmpty(orderByRand)){ ORDER BY RAND() @}
getStudentLog
SELECT t.student_id, t.platform, LEFT(SUBSTRING_INDEX(GROUP_CONCAT(t.last_login_time ORDER BY t.last_login_time DESC),',',1),19) last_login_time, LEFT(SUBSTRING_INDEX(GROUP_CONCAT(t.last_operate_time ORDER BY t.last_operate_time DESC),',',1),19) last_operate_time, SUBSTRING_INDEX(GROUP_CONCAT(t.IP ORDER BY t.last_login_time DESC),',',1) IP FROM ( SELECT t.student_id, a.create_time last_login_time, a1.create_time last_operate_time, a.IP, CASE WHEN a.params LIKE '%\_ch%' THEN (SELECT TRIM(REPLACE(application_name,'子应用','')) FROM resources_application WHERE resources_application_id = 3) ELSE CASE WHEN a.params LIKE '%\_dsj%' THEN (SELECT TRIM(REPLACE(application_name,'子应用','')) FROM resources_application WHERE resources_application_id = 1) ELSE CASE WHEN a.params LIKE '%\_jr%' THEN (SELECT TRIM(REPLACE(application_name,'子应用','')) FROM resources_application WHERE resources_application_id = 2) ELSE CASE WHEN a.params LIKE '%\_sy%' THEN (SELECT TRIM(REPLACE(application_name,'子应用','')) FROM resources_application WHERE resources_application_id = 4) ELSE CASE WHEN a.params LIKE '%\yx%' THEN (SELECT TRIM(REPLACE(application_name,'子应用','')) FROM resources_application WHERE resources_application_id = 5) END END END END END platform FROM student t LEFT JOIN (SELECT student_id,SUBSTRING_INDEX(GROUP_CONCAT(create_time ORDER BY create_time DESC),',',1) create_time,SUBSTRING_INDEX(GROUP_CONCAT(params ORDER BY create_time DESC),',',1) params,SUBSTRING_INDEX(GROUP_CONCAT(ip ORDER BY create_time DESC),',',1) ip FROM sys_log WHERE student_id > 0 AND request_url LIKE '%/api/student/indexInfo.do%' GROUP BY student_id) a ON a.student_id = t.student_id LEFT JOIN (SELECT student_id,SUBSTRING_INDEX(GROUP_CONCAT(create_time ORDER BY create_time DESC),',',1) create_time FROM sys_log WHERE student_id > 0 GROUP BY student_id) a1 ON a1.student_id = t.student_id WHERE a.params LIKE '%studentEnd\%' @if(!isEmpty(studentIds)){ and find_in_set(t.student_id ,#studentIds#) @} )t GROUP BY t.student_id,platform
getPracticePerformanceStatistic
-
练习成绩统计
SELECT @pageTag(){ t.*, t1.class_id, t1.student_name, t1.student_sn, t1.student_mobile, t1.student_email, t1.student_status, t1.add_time, t1.org_id, t1.user_id, a.class_name, b.universities_colleges_name @} FROM ( SELECT t.student_id, t.resources_question_num, t.resources_competition_num, t.resources_training_num, CONCAT(FLOOR(ROUND(t.resources_question_right_num / t.resources_question_all_num,2)*100),'%') resources_question_proportion, CONCAT(FLOOR(ROUND(t.resources_competition_step_right_num / t.resources_competition_step_all_num,2)*100),'%') resources_competition_proportion, CONCAT(FLOOR(ROUND(t.resources_training_step_right_num / t.resources_training_step_all_num,2)*100),'%')resources_training_proportion
FROM ( SELECT a.student_id, COUNT(DISTINCT a.resources_question_id) resources_question_num, COUNT(DISTINCT c.resources_competition_id) resources_competition_num, COUNT(DISTINCT d.resources_training_id) resources_training_num, SUM(CASE WHEN a.resources_question_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_question_right_num, COUNT(CASE WHEN a.resources_question_id > 0 THEN b.student_question_log_id ELSE NULL END) resources_question_all_num, SUM(CASE WHEN a.resources_competition_step_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_competition_step_right_num, COUNT(CASE WHEN a.resources_competition_step_id > 0 THEN b.student_question_log_id ELSE NULL END)resources_competition_step_all_num, SUM(CASE WHEN a.resources_training_step_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_training_step_right_num, COUNT(CASE WHEN a.resources_training_step_id > 0 THEN b.student_question_log_id ELSE NULL END)resources_training_step_all_num FROM student_question_log a LEFT JOIN student_question_log_info b ON b.student_question_log_id = a.student_question_log_id LEFT JOIN resources_competition_step c ON c.resources_competition_step_id = a.resources_competition_step_id LEFT JOIN resources_training_step d ON d.resources_training_step_id = a.resources_training_step_id LEFT JOIN student s ON s.student_id = a.student_id WHERE 1=1 @if(!isEmpty(orgId)){ and s.org_id =#orgId# @} @if(!isEmpty(studentIds)){ and find_in_set(t.student_id ,#studentIds#) @} @if(!isEmpty(studentId)){ and t.student_id = #studentId# @} @if(!isEmpty(classId)){ and s.class_id = #classId# @} GROUP BY a.student_id ) t
) t LEFT JOIN student t1 ON t1.student_id = t.student_id LEFT JOIN school_class a ON a.class_id = t1.class_id LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id @if(!isEmpty(orderByResourcesQuestionNum)){ @if(orderByResourcesQuestionNum == 1){ ORDER BY t.resources_question_num @}else if(orderByResourcesQuestionNum == 2){ ORDER BY t.resources_question_num DESC @} @} @if(!isEmpty(orderByResourcesCompetitionNum)){ @if(orderByResourcesCompetitionNum == 1){ ORDER BY t.resources_competition_num @}else if(orderByResourcesCompetitionNum == 2){ ORDER BY t.resources_competition_num DESC @} @} @if(!isEmpty(orderByResourcesTrainingNum)){ @if(orderByResourcesTrainingNum == 1){ ORDER BY t.resources_training_num @}else if(orderByResourcesTrainingNum == 2){ ORDER BY t.resources_training_num DESC @} @} @if(!isEmpty(orderByResourcesQuestionProportion)){ @if(orderByResourcesQuestionProportion == 1){ ORDER BY REPLACE(t.resources_question_proportion,'%','')+0 @}else if(orderByResourcesQuestionProportion == 2){ ORDER BY REPLACE(t.resources_question_proportion,'%','')+0 DESC @} @} @if(!isEmpty(orderByResourcesCompetitionProportion)){ @if(orderByResourcesCompetitionProportion == 1){ ORDER BY REPLACE(t.resources_competition_proportion,'%','')+0 @}else if(orderByResourcesCompetitionProportion == 2){ ORDER BY REPLACE(t.resources_competition_proportion,'%','')+0 DESC @} @} @if(!isEmpty(orderByResourcesTrainingProportion)){ @if(orderByResourcesTrainingProportion == 1){ ORDER BY REPLACE(t.resources_training_proportion,'%','')+0 @}else if(orderByResourcesTrainingProportion == 2){ ORDER BY REPLACE(t.resources_training_proportion,'%','')+0 DESC @} @}
getPracticePerformanceStatisticInfo
-
练习成绩统计详情
SELECT t.course_info_id, t.resources_question_num, t.resources_competition_num, t.resources_training_num, CONCAT(t.resources_question_right_num ,'/', t.resources_question_all_num) resources_question_proportion, CONCAT(t.resources_competition_step_right_num ,'/', t.resources_competition_step_all_num) resources_competition_proportion, CONCAT(t.resources_training_step_right_num ,'/', t.resources_training_step_all_num)resources_training_proportion
FROM ( SELECT a.course_info_id, COUNT(DISTINCT a.resources_question_id) resources_question_num, COUNT(DISTINCT c.resources_competition_id) resources_competition_num, COUNT(DISTINCT d.resources_training_id) resources_training_num, SUM(CASE WHEN a.resources_question_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_question_right_num, COUNT(CASE WHEN a.resources_question_id > 0 THEN b.student_question_log_id ELSE NULL END) resources_question_all_num, SUM(CASE WHEN a.resources_competition_step_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_competition_step_right_num, COUNT(CASE WHEN a.resources_competition_step_id > 0 THEN b.student_question_log_id ELSE NULL END)resources_competition_step_all_num, SUM(CASE WHEN a.resources_training_step_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_training_step_right_num, COUNT(CASE WHEN a.resources_training_step_id > 0 THEN b.student_question_log_id ELSE NULL END)resources_training_step_all_num
FROM ( SELECT t.*, CASE WHEN t.resources_question_id > 0 THEN ( SELECT a.course_info_id FROM resources_question a WHERE a.resources_question_id = t.resources_question_id ) ELSE CASE WHEN t.resources_competition_step_id > 0 THEN ( SELECT DISTINCT b.course_info_id FROM resources_competition_step a LEFT JOIN resources_competition b ON b.resources_competition_id = a.resources_competition_id WHERE a.resources_competition_step_id = t.resources_competition_step_id ) ELSE CASE WHEN t.resources_training_step_id > 0 THEN ( SELECT DISTINCT b.course_info_id FROM resources_training_step a LEFT JOIN resources_training b ON b.resources_training_id = a.resources_training_id WHERE a.resources_training_step_id = t.resources_training_step_id ) ELSE NULL END END END course_info_id from student_question_log t WHERE student_id = #studentId# )a LEFT JOIN student_question_log_info b ON b.student_question_log_id = a.student_question_log_id LEFT JOIN resources_competition_step c ON c.resources_competition_step_id = a.resources_competition_step_id LEFT JOIN resources_training_step d ON d.resources_training_step_id = a.resources_training_step_id WHERE 1=1 @if(!isEmpty(courseInfoIds)){ and find_in_set(a.course_info_id ,#courseInfoIds#) @} GROUP BY a.course_info_id
) t
getPracticeProgress
-
练习进度
SELECT t.course_info_id, t.resources_question_num, t.resources_competition_num, t.resources_training_num, CONCAT(t.resources_question_num ,'/', t.resources_question_all_num) resources_question_proportion, CONCAT(t.resources_competition_num ,'/', t.resources_competition_all_num) resources_competition_proportion, CONCAT(t.resources_training_num ,'/', t.resources_training_all_num)resources_training_proportion
FROM ( SELECT a.course_info_id, COUNT(DISTINCT a.resources_question_id) resources_question_num, COUNT(DISTINCT c.resources_competition_id) resources_competition_num, COUNT(DISTINCT d.resources_training_id) resources_training_num, (SELECT COUNT(resources_question_id) FROM resources_question WHERE course_info_id = a.course_info_id) resources_question_all_num, (SELECT COUNT(resources_competition_id) FROM resources_competition WHERE course_info_id = a.course_info_id) resources_competition_all_num, (SELECT COUNT(resources_training_id) FROM resources_training WHERE course_info_id = a.course_info_id) resources_training_all_num
FROM ( SELECT t.*, CASE WHEN t.resources_question_id > 0 THEN ( SELECT a.course_info_id FROM resources_question a WHERE a.resources_question_id = t.resources_question_id ) ELSE CASE WHEN t.resources_competition_step_id > 0 THEN ( SELECT DISTINCT b.course_info_id FROM resources_competition_step a LEFT JOIN resources_competition b ON b.resources_competition_id = a.resources_competition_id WHERE a.resources_competition_step_id = t.resources_competition_step_id ) ELSE CASE WHEN t.resources_training_step_id > 0 THEN ( SELECT DISTINCT b.course_info_id FROM resources_training_step a LEFT JOIN resources_training b ON b.resources_training_id = a.resources_training_id WHERE a.resources_training_step_id = t.resources_training_step_id ) ELSE NULL END END END course_info_id FROM student_question_log t LEFT JOIN student s ON s.student_id = t.student_id WHERE 1=1 @if(!isEmpty(orgId)){ and s.org_id =#orgId# @} @if(!isEmpty(studentIds)){ and find_in_set(t.student_id ,#studentIds#) @} @if(!isEmpty(studentId)){ and t.student_id = #studentId# @} @if(!isEmpty(classId)){ and s.class_id = #classId# @} )a LEFT JOIN student_question_log_info b ON b.student_question_log_id = a.student_question_log_id LEFT JOIN resources_competition_step c ON c.resources_competition_step_id = a.resources_competition_step_id LEFT JOIN resources_training_step d ON d.resources_training_step_id = a.resources_training_step_id WHERE 1=1 @if(!isEmpty(courseInfoIds)){ and find_in_set(a.course_info_id ,#courseInfoIds#) @} GROUP BY a.course_info_id
) t
getErrorStatistics
-
错题统计
SELECT @pageTag(){ @if(questionType == 1){ t.resources_question_id, d.question_type, d.question_stem, @}else if(questionType == 2){ t.resources_competition_id, e.resources_competition_name question_stem, @}else if(questionType == 3){ t.resources_training_id, e.resources_training_name question_stem, @} t.wrong_proportion, t.course_info_id, b.course_info_name, c.course_info_name course_info_parent_name, FIND_IN_SET(wrong_proportion,wrong_proportions) ranking @} FROM ( SELECT t.course_info_id @if(questionType == 1){ ,t.resources_question_id, CONCAT(FLOOR(ROUND((t.resources_question_all_num - t.resources_question_right_num) / t.resources_question_all_num,2)*100),'%') wrong_proportion @}else if(questionType == 2){ ,t.resources_competition_id, CONCAT(FLOOR(ROUND((t.resources_competition_step_all_num - t.resources_competition_step_right_num) / t.resources_competition_step_all_num,2)*100),'%') wrong_proportion @}else if(questionType == 3){ ,t.resources_training_id, CONCAT(FLOOR(ROUND((t.resources_training_step_all_num - t.resources_training_step_right_num) / t.resources_training_step_all_num,2)100),'%')wrong_proportion
@} FROM ( SELECT GROUP_CONCAT(DISTINCT a.course_info_id) course_info_id, resources_question_id, resources_competition_id, resources_training_id, SUM(CASE WHEN a.resources_question_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_question_right_num, COUNT(CASE WHEN a.resources_question_id > 0 THEN b.student_question_log_id ELSE NULL END) resources_question_all_num, SUM(CASE WHEN a.resources_competition_step_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_competition_step_right_num, COUNT(CASE WHEN a.resources_competition_step_id > 0 THEN b.student_question_log_id ELSE NULL END)resources_competition_step_all_num, SUM(CASE WHEN a.resources_training_step_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_training_step_right_num, COUNT(CASE WHEN a.resources_training_step_id > 0 THEN b.student_question_log_id ELSE NULL END)resources_training_step_all_num FROM ( SELECT t., CASE WHEN t.resources_question_id > 0 THEN ( SELECT a.course_info_id FROM resources_question a WHERE a.resources_question_id = t.resources_question_id ) ELSE CASE WHEN t.resources_competition_step_id > 0 THEN ( SELECT DISTINCT b.course_info_id FROM resources_competition_step a LEFT JOIN resources_competition b ON b.resources_competition_id = a.resources_competition_id WHERE a.resources_competition_step_id = t.resources_competition_step_id ) ELSE CASE WHEN t.resources_training_step_id > 0 THEN ( SELECT DISTINCT b.course_info_id FROM resources_training_step a LEFT JOIN resources_training b ON b.resources_training_id = a.resources_training_id WHERE a.resources_training_step_id = t.resources_training_step_id ) ELSE NULL END END END course_info_id FROM student_question_log t LEFT JOIN student s ON s.student_id = t.student_id WHERE 1=1 )a LEFT JOIN student_question_log_info b ON b.student_question_log_id = a.student_question_log_id LEFT JOIN resources_competition_step c ON c.resources_competition_step_id = a.resources_competition_step_id LEFT JOIN resources_training_step d ON d.resources_training_step_id = a.resources_training_step_id LEFT JOIN student s ON s.student_id = a.student_id
WHERE 1=1 @if(!isEmpty(orgId)){ and s.org_id =#orgId# @} @if(questionType == 1){ and resources_question_id > 0 @}else if(questionType == 2){ and resources_competition_id > 0 @}else if(questionType == 3){ and resources_training_id > 0 @} @if(!isEmpty(classId)){ and s.class_id = #classId# @} GROUP BY resources_question_id,resources_competition_id,resources_training_id )t )t LEFT JOIN ( SELECT @if(questionType == 1){ GROUP_CONCAT(DISTINCT CONCAT(FLOOR(ROUND((t.resources_question_all_num - t.resources_question_right_num) / t.resources_question_all_num,2)*100),'%') ORDER BY FLOOR(ROUND((t.resources_question_all_num - t.resources_question_right_num) / t.resources_question_all_num,2)*100)) wrong_proportions @}else if(questionType == 2){ GROUP_CONCAT(DISTINCT CONCAT(FLOOR(ROUND((t.resources_competition_step_all_num - t.resources_competition_step_right_num) / t.resources_competition_step_all_num,2)*100),'%') ORDER BY FLOOR(ROUND((t.resources_competition_step_all_num - t.resources_competition_step_right_num) / t.resources_competition_step_all_num,2)*100)) wrong_proportions @}else if(questionType == 3){ GROUP_CONCAT(DISTINCT CONCAT(FLOOR(ROUND((t.resources_training_step_all_num - t.resources_training_step_right_num) / t.resources_training_step_all_num,2)*100),'%') ORDER BY FLOOR(ROUND((t.resources_training_step_all_num - t.resources_training_step_right_num) / t.resources_training_step_all_num,2)100)) wrong_proportions @} FROM ( SELECT GROUP_CONCAT(DISTINCT a.course_info_id) course_info_id, resources_question_id, resources_competition_id, resources_training_id, SUM(CASE WHEN a.resources_question_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_question_right_num, COUNT(CASE WHEN a.resources_question_id > 0 THEN b.student_question_log_id ELSE NULL END) resources_question_all_num, SUM(CASE WHEN a.resources_competition_step_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_competition_step_right_num, COUNT(CASE WHEN a.resources_competition_step_id > 0 THEN b.student_question_log_id ELSE NULL END)resources_competition_step_all_num, SUM(CASE WHEN a.resources_training_step_id > 0 THEN CASE WHEN b.question_fraction = b.student_fraction THEN 1 ELSE 0 END ELSE 0 END) resources_training_step_right_num, COUNT(CASE WHEN a.resources_training_step_id > 0 THEN b.student_question_log_id ELSE NULL END)resources_training_step_all_num FROM ( SELECT t., CASE WHEN t.resources_question_id > 0 THEN ( SELECT a.course_info_id FROM resources_question a WHERE a.resources_question_id = t.resources_question_id ) ELSE CASE WHEN t.resources_competition_step_id > 0 THEN ( SELECT DISTINCT b.course_info_id FROM resources_competition_step a LEFT JOIN resources_competition b ON b.resources_competition_id = a.resources_competition_id WHERE a.resources_competition_step_id = t.resources_competition_step_id ) ELSE CASE WHEN t.resources_training_step_id > 0 THEN ( SELECT DISTINCT b.course_info_id FROM resources_training_step a LEFT JOIN resources_training b ON b.resources_training_id = a.resources_training_id WHERE a.resources_training_step_id = t.resources_training_step_id ) ELSE NULL END END END course_info_id FROM student_question_log t LEFT JOIN student s ON s.student_id = t.student_id WHERE 1=1 )a LEFT JOIN student_question_log_info b ON b.student_question_log_id = a.student_question_log_id LEFT JOIN resources_competition_step c ON c.resources_competition_step_id = a.resources_competition_step_id LEFT JOIN resources_training_step d ON d.resources_training_step_id = a.resources_training_step_id LEFT JOIN student s ON s.student_id = a.student_id WHERE 1=1 @if(!isEmpty(orgId)){ and s.org_id =#orgId# @} @if(questionType == 1){ and resources_question_id > 0 @}else if(questionType == 2){ and resources_competition_id > 0 @}else if(questionType == 3){ and resources_training_id > 0 @} @if(!isEmpty(classId)){ and s.class_id = #classId# @} GROUP BY resources_question_id,resources_competition_id,resources_training_id )t )a ON 1=1 LEFT JOIN course_info b ON b.course_info_id = t.course_info_id LEFT JOIN course_info c ON c.course_info_id = b.course_info_parent_id @if(questionType == 1){ LEFT JOIN resources_question d ON d.resources_question_id = t.resources_question_id @}else if(questionType == 2){ LEFT JOIN resources_competition e ON e.resources_competition_id = t.resources_competition_id @}else if(questionType == 3){ LEFT JOIN resources_training e ON e.resources_training_id = t.resources_training_id
@} WHERE 1=1 @if(!isEmpty(courseInfoId)){ and c.course_info_id = #courseInfoId# @} ORDER BY IFNULL(FIND_IN_SET(wrong_proportion,wrong_proportions),LENGTH(wrong_proportions))
getStudentExtendSchoolInfo
-
获取学生的学校信息 班级-专业-院系-院校
SELECT t.*, ta.class_id, ta.class_name, tb.university_system_id, tb.university_system_name, tc.university_faculty_id, tc.university_faculty_name, td.universities_colleges_id, td.universities_colleges_name, td.universities_colleges_city, td.universities_colleges_province FROM student t LEFT JOIN school_class ta ON ta.class_id = t.class_id AND ta.class_status = 1 LEFT JOIN university_system tb ON tb.university_system_id = ta.university_system_id AND tb.university_system_status = 1 LEFT JOIN university_faculty tc ON tc.university_faculty_id = tb.university_faculty_id AND tc.university_faculty_status = 1 LEFT JOIN universities_colleges td ON td.universities_colleges_id = tc.universities_colleges_id AND td.universities_colleges_status = 1 WHERE 1 = 1 AND FIND_IN_SET(t.student_id,#studentIds#)
getStudentExtendSchoolInfoListByUserIds
-
通过用户ID 获取学生的学校信息 班级-专业-院系-院校
SELECT t.*, ta.class_id, ta.class_name, tb.university_system_id, tb.university_system_name, tc.university_faculty_id, tc.university_faculty_name, td.universities_colleges_id, td.universities_colleges_name, td.universities_colleges_city, td.universities_colleges_province FROM student t LEFT JOIN school_class ta ON ta.class_id = t.class_id AND ta.class_status = 1 LEFT JOIN university_system tb ON tb.university_system_id = ta.university_system_id AND tb.university_system_status = 1 LEFT JOIN university_faculty tc ON tc.university_faculty_id = tb.university_faculty_id AND tc.university_faculty_status = 1 LEFT JOIN universities_colleges td ON td.universities_colleges_id = tc.universities_colleges_id AND td.universities_colleges_status = 1 WHERE 1 = 1 AND FIND_IN_SET(t.user_id,#userIds#)
getStudentByStudentEditPasswordDTO
-
学生端-修改密码 验证信息
SELECT t.* FROM student t LEFT JOIN core_user ta ON ta.ID = t.user_id WHERE 1 = 1 AND t.student_status = 1 AND ta.STATE = 'S1' AND ta.DEL_FLAG = 0 AND t.student_name = #studentName# AND t.student_sn = #studentSn# AND ta.PASSWORD = #oldPwd#
studentActiveInfo
-
学生端-活跃度信息
SELECT zxc.student_id, zxc.student_name, zxc.student_sn, (select sum(sl.result) from sys_log sl where request_url = #@com.ibeetl.jlw.conf.KeyExpiredListener.TOKEN_EXPIRED_MESSAGE# and sl.student_id = zxc.student_id and sl.user_id = zxc.user_id) AS study_duration, ( SELECT zz.rk FROM ( SELECT z., @platformRank := @platformRank + 1 AS rk FROM ( SELECT t.id, t.
name
, ta.class_id, ta.class_name, t.login_count, t.last_login_time, t.org_id FROM core_user t, student tb, school_class ta WHERE t.id != 1 AND ta.class_id = tb.class_id AND tb.user_id = t.id AND t.job_type1 = 'JT_S_03' AND t.state
= 'S1' AND DEL_FLAG = 0 ORDER BY login_count DESC, last_login_time DESC ) z, ( SELECT @platformRank := 0 ) AS rk WHERE 1 @// 平台排序,不需要给班级ID的条件 AND z.class_id = zxc.class_id AND z.org_id = zxc.org_id ) zz WHERE 1 AND zz.id = zxc.user_id ) AS platform_rank_no, ( SELECT zz.rk FROM ( SELECT z., @classRank := @classRank + 1 AS rk FROM ( SELECT t.id, t.name
, ta.class_id, ta.class_name, t.login_count, t.last_login_time, t.org_id FROM core_user t, student tb, school_class ta WHERE t.id != 1 AND ta.class_id = tb.class_id AND tb.user_id = t.id AND t.job_type1 = 'JT_S_03' AND t.state
= 'S1' AND DEL_FLAG = 0 ORDER BY login_count DESC, last_login_time DESC ) z, ( SELECT @classRank := 0 ) AS rk WHERE 1 AND z.class_id = zxc.class_id AND z.org_id = zxc.org_id ) zz WHERE 1 AND zz.id = zxc.user_id ) AS class_rank_no, (select count(1) from sys_log sl where request_url = #@com.ibeetl.jlw.conf.KeyExpiredListener.TOKEN_EXPIRED_MESSAGE# and sl.student_id = zxc.student_id and sl.user_id = zxc.user_id group by date(create_time) LIMIT 1) AS login_days FROM ( SELECT user_id, org_id, class_id, student_name, student_sn, student_id FROM student WHERE 1 @if(!isEmpty(userId)) { and user_id = #userId# @} @if(!isEmpty(studentId)) { and student_id = #studentId# @} @if(isEmpty(userId) && isEmpty(studentId)) { and 1 != 1 @} LIMIT 1 ) zxc
queryStudentLoginLogByCondition
-
登录日志:
-
院校管理员 查看学生身份的登录日志
-
超管 查看所有人的登录日志
select @pageTag() { z.* @} from ( SELECT tc.
code
, tc.name
, td.universities_colleges_name, @// 所属省份 td.universities_colleges_province, td.class_name, @//指定时间内的,系统登入时间 min( ta.create_time ) AS login_time, @//系统登出时间 ( CASE WHEN count( 1 ) <= 1 THEN '-' ELSE max( ta.create_time ) END ) AS logout_time, @//指定时间内的,在线时长 ( CASE WHEN count( 1 ) <= 1 THEN TIMEDIFF( now(), min( ta.create_time )) ELSE TIMEDIFF( max( ta.create_time ), min( ta.create_time )) END ) AS online_duration, @// 是否在线规则: 登录次数 取余和1做对比 count( 1 ) % 2 = 1 AS is_on_line, @// 会从多个地方登录,这里只是随机取一个IP,确保单条唯一 any_value(ta.ip) as ip, @// 登录次数 count( 1 ) AS login_count FROM sys_log ta left join @// 查询userId对应的院校信息 ( SELECT c.universities_colleges_name, b.universities_colleges_id, c.universities_colleges_province, a.class_id, b.class_name, a.user_id FROM student a LEFT JOIN school_class b ON b.class_id = a.class_id LEFT JOIN universities_colleges c ON b.universities_colleges_id = c.universities_colleges_id UNION ALL SELECT b.universities_colleges_name, b.universities_colleges_id, b.universities_colleges_province, NULL AS class_id, null as class_name, a.user_id FROM teacher a LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id ) td on td.user_id = ta.user_id LEFT JOIN core_user tc ON ta.user_id = tc.id WHERE 1 and ta.user_id is not null @if(!isEmpty(codeOrName)) { and concat(tc.name
, tc.code
) like #'%'+codeOrName+'%'# @} @if(!isEmpty(classId)) { and td.class_id = #classId# @} @if(!isEmpty(loginStartTime)) { and ta.create_time >= #loginStartTime# @} @if(!isEmpty(loginEndTime)) { and ta.create_time <= #loginEndTime# @} @// 用来过滤院校管理员所能查看的数据 @if(!isEmpty(universitiesCollegesId)) { and td.universities_colleges_id = #universitiesCollegesId# @} @if(!isEmpty(isOnLine)) { and (count( 1 ) % 2 = 1) = #isOnLine# @} GROUP BY tc.code
, tc.name
, td.universities_colleges_name, td.universities_colleges_province, td.class_name ) z order by z.login_time desc
queryStudentUseLogByConditionGroupByUniversitiesCollegesId
-
使用日志:(院校分组)
-
院校管理员 只能查看他院校下面的学生、教师、院校管理跳转子应用的日志
-
超管 查看所有跳转子应用的日志
select @pageTag() { @// 子系统名称 platform, @// 子系统应用ID application_id, @// 归属模块
@// 使用人数 count(1) as use_count, universities_colleges_id, universities_colleges_name, @// 所属省份 universities_colleges_province,
@//指定时间内的,在线时长 sum(online_duration) as online_duration, DATE_FORMAT(,'%Y-%m-%d') as create_time
@} from ( SELECT tc.
code
, tc.name
, td.universities_colleges_id, td.universities_colleges_name, @// 所属省份 td.universities_colleges_province, td.class_name, @// 子系统名称 TRIM( REPLACE ( tb.application_name, ' 子应用', '' )) AS platform, tb.application_id, @//指定时间内的,系统登入时间 min( ta.create_time ) AS login_time, @//系统登出时间 ( CASE WHEN count( 1 ) <= 1 THEN '-' ELSE adddate(min( ta.create_time ), interval (TIME_TO_SEC(max( ta.create_time )) - TIME_TO_SEC(min( ta.create_time ))) second) END ) AS logout_time, @//指定时间内的,在线时长 ( CASE WHEN count( 1 ) <= 1 THEN TIMEDIFF( now(), min( ta.create_time )) ELSE TIMEDIFF( max( ta.create_time ), min( ta.create_time )) END ) AS online_duration, @// 是否在线规则: 登录次数 取余和1做对比 count( 1 ) % 2 = 1 AS is_on_line, @// 登录次数 count( 1 ) AS login_count FROM sys_log ta left join @// 查询userId对应的院校信息 ( SELECT c.universities_colleges_name, b.universities_colleges_id, c.universities_colleges_province, a.class_id, b.class_name, a.user_id FROM student a LEFT JOIN school_class b ON b.class_id = a.class_id LEFT JOIN universities_colleges c ON b.universities_colleges_id = c.universities_colleges_id UNION ALL SELECT b.universities_colleges_name, b.universities_colleges_id, b.universities_colleges_province, NULL AS class_id, null as class_name, a.user_id FROM teacher a LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id ) td on td.user_id = ta.user_id LEFT JOIN resources_application tb ON ta.request_url LIKE CONCAT( tb.application_link, '%' ) LEFT JOIN core_user tc ON ta.user_id = tc.id WHERE 1 and ta.user_id is not null AND tb.application_name IS NOT NULL @if(!isEmpty(codeOrName)) { and concat(tc.name
, tc.code
) like #'%'+codeOrName+'%'# @} @if(!isEmpty(classId)) { and td.class_id = #classId# @} @if(!isEmpty(loginStartTime)) { and ta.create_time >= #loginStartTime# @} @if(!isEmpty(loginEndTime)) { and ta.create_time <= #loginEndTime# @} @// 用来过滤院校管理员所能查看的数据 @if(!isEmpty(universitiesCollegesId)) { and td.universities_colleges_id = #universitiesCollegesId# and tb.application_name is not null @} @if(!isEmpty(isOnLine)) { and (count( 1 ) % 2 = 1) = #isOnLine# @} GROUP BY tc.code
, tc.name
, td.universities_colleges_name, td.universities_colleges_province, tb.application_name, td.class_name ) z group by universities_colleges_id order by z.login_time desc
queryStudentUseLogByCondition
-
使用日志:
-
院校管理员 只能查看他院校下面的学生、教师、院校管理跳转子应用的日志
-
超管 查看所有跳转子应用的日志
select @pageTag() { z.* @} from ( SELECT tc.
code
, tc.name
, td.universities_colleges_id, td.universities_colleges_name, @// 所属省份 td.universities_colleges_province, td.class_name, @// 子系统名称 TRIM( REPLACE ( tb.application_name, ' 子应用', '' )) AS platform, @//指定时间内的,系统登入时间 min( ta.create_time ) AS login_time, @//系统登出时间 ( CASE WHEN count( 1 ) <= 1 THEN '-' ELSE adddate(min( ta.create_time ), interval (TIME_TO_SEC(max( ta.create_time )) - TIME_TO_SEC(min( ta.create_time ))) second) END ) AS logout_time, @//指定时间内的,在线时长 ( CASE WHEN count( 1 ) <= 1 THEN TIMEDIFF( now(), min( ta.create_time )) ELSE TIMEDIFF( max( ta.create_time ), min( ta.create_time )) END ) AS online_duration, @// 是否在线规则: 登录次数 取余和1做对比 count( 1 ) % 2 = 1 AS is_on_line, @// 登录次数 count( 1 ) AS login_count FROM sys_log ta left join @// 查询userId对应的院校信息 ( SELECT c.universities_colleges_name, b.universities_colleges_id, c.universities_colleges_province, a.class_id, b.class_name, a.user_id FROM student a LEFT JOIN school_class b ON b.class_id = a.class_id LEFT JOIN universities_colleges c ON b.universities_colleges_id = c.universities_colleges_id UNION ALL SELECT b.universities_colleges_name, b.universities_colleges_id, b.universities_colleges_province, NULL AS class_id, null as class_name, a.user_id FROM teacher a LEFT JOIN universities_colleges b ON b.universities_colleges_id = a.universities_colleges_id ) td on td.user_id = ta.user_id LEFT JOIN resources_application tb ON ta.request_url LIKE CONCAT( tb.application_link, '%' ) LEFT JOIN core_user tc ON ta.user_id = tc.id WHERE 1 and ta.user_id is not null AND tb.application_name IS NOT NULL @if(!isEmpty(codeOrName)) { and concat(tc.name
, tc.code
) like #'%'+codeOrName+'%'# @} @if(!isEmpty(classId)) { and td.class_id = #classId# @} @if(!isEmpty(loginStartTime)) { and ta.create_time >= #loginStartTime# @} @if(!isEmpty(loginEndTime)) { and ta.create_time <= #loginEndTime# @} @// 用来过滤院校管理员所能查看的数据 @if(!isEmpty(universitiesCollegesId)) { and td.universities_colleges_id = #universitiesCollegesId# and tb.application_name is not null @} @if(!isEmpty(isOnLine)) { and (count( 1 ) % 2 = 1) = #isOnLine# @} GROUP BY tc.code
, tc.name
, td.universities_colleges_name, td.universities_colleges_province, tb.application_name, td.class_name ) z order by z.login_time desc
queryStudentLogAnalysisByCondition
-
日志分析,统计报表
SELECT @pageTag() { Z.* @} FROM ( 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 ) zz ) Z order by z.time desc