diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java index d07186ca..5cbb82ad 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java @@ -88,7 +88,34 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseServicequeryByConditionQuery(PageQuery query){ PageQuery ret = teacherOpenCourseQuestionLogDao.queryByConditionQuery(query); - queryListAfter(ret.getList()); + List list = ret.getList(); + queryListAfter(list); + + Map> studentMap = new HashMap<>(); + if (ObjectUtil.isNotEmpty(list)) { + String studentIds = list.stream().map(TeacherOpenCourseQuestionLog::getStudentId).map(Object::toString).collect(joining(",")); + List studentList = studentDao.getByIds(studentIds); + dictParser(studentList); + if (ObjectUtil.isNotEmpty(studentList)) { + studentMap.putAll(studentList.stream().collect(groupingBy(Student::getStudentId))); + } + + list.forEach(item -> { + List students = studentMap.get(item.getStudentId()); + if (ObjectUtil.isNotEmpty(students)) { + Student student = students.get(0); + // 学生编号 + item.set("studentSn", student.getStudentSn()); + item.set("studentName", student.getStudentName()); + SchoolClass schoolClass = student.getSchoolClass(); + + // 班级 + if(null != schoolClass) { + item.set("className", schoolClass.getClassName()); + } + } + }); + } return ret; } diff --git a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java index 4af3443f..b291192e 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java @@ -2,6 +2,7 @@ package com.ibeetl.jlw.web; import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.jlw.Interceptor.SCoreUser; import cn.jlw.Interceptor.TStudent; @@ -33,10 +34,8 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import java.math.BigDecimal; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeSet; +import java.util.*; +import java.util.stream.Collectors; import static cn.jlw.util.CacheUserUtil.getStudent; import static com.ibeetl.admin.core.util.ExcelUtil.convertData; @@ -345,6 +344,45 @@ public class TeacherOpenCourseQuestionLogController { write(resp, filename,"Sheet1", header.values(), convertData(header.keySet(), maps)); } + + /** + * 作业详情导出 + * @param condition 日志记录查询条件 + * @return + */ + @SneakyThrows + @GetMapping(API + "/zyDetailExport.do") + public void zyDetailExport(HttpServletResponse resp, TeacherOpenCourseQuestionLogQuery condition) { + + /** 构建表头 */ + Map header = new LinkedHashMap<>(11); + header.put("studentName", "学生姓名"); + header.put("studentSn", "学生学号"); + header.put("className", "班级"); + header.put("questionStem", "题干"); + header.put("questionTypeText", "题型"); + header.put("teacherOpenCourseQuestionLogAnswer", "我的选项"); + header.put("questionAnswer", "答案"); + header.put("studentScore", "得分"); + + List datas = new ArrayList<>(); + PageQuery pageQuery = condition.getPageQuery(); + condition.setTeacherOpenCourseQuestionLogStatus(1); + condition.setQuestionLogAddType(FINALLY_SUBMIT); + pageQuery.setPageSize(Integer.MAX_VALUE); + pageQuery.setPageNumber(1L); + PageQuery teacherOpenCourseQuestionLogPageQuery = teacherOpenCourseQuestionLogService.queryByConditionQuery(pageQuery); + + if (ObjectUtil.isNotEmpty(teacherOpenCourseQuestionLogPageQuery)) { + datas = teacherOpenCourseQuestionLogPageQuery.getList().stream().filter(item -> null != item.get("studentName")).collect(Collectors.toList()); + } + + List> maps = BeanCopyUtil.baseEntity2MapWithParallel(datas); + + String filename = StrUtil.format("题目日志详情-导出 {}.xlsx", DateUtil.now()); + write(resp, filename,"Sheet1", header.values(), convertData(header.keySet(), maps)); + } + /** * 功能描述:
* 题目获取答案,并锁定题目(改变为LOCK状态) diff --git a/web/src/main/resources/sql/jlw/questionLogSummary.md b/web/src/main/resources/sql/jlw/questionLogSummary.md index a1af8a01..4244efd1 100644 --- a/web/src/main/resources/sql/jlw/questionLogSummary.md +++ b/web/src/main/resources/sql/jlw/questionLogSummary.md @@ -4,9 +4,14 @@ queryByCondition select @pageTag(){ - t.* + t.*, + ta.student_name, + ta.student_sn, + tb.class_name @} from question_log_summary t + inner join student ta on ta.student_id = t.person_id and ta.student_status = 1 + inner join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 where 1=1 @//数据权限,该sql语句功能点,如果不考虑数据权限,可以删除此行 and #function("questionLogSummary.query")# @@ -96,9 +101,14 @@ queryByConditionQuery select @pageTag(){ - t.* + t.*, + ta.student_name, + ta.student_sn, + tb.class_name @} from question_log_summary t + inner join student ta on ta.student_id = t.person_id and ta.student_status = 1 + inner join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 where 1=1 @if(!isEmpty(questionLogSummaryId)){ and t.question_log_summary_id =#questionLogSummaryId# @@ -356,8 +366,13 @@ getQuestionLogSummaryValues * 根据不为空的参数进行查询 - select t.* + select t.*, + ta.student_name, + ta.student_sn, + tb.class_name from question_log_summary t + inner join student ta on ta.student_id = t.person_id and ta.student_status = 1 + inner join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 where 1=1 @if(!isEmpty(questionLogSummaryId)){ and t.question_log_summary_id =#questionLogSummaryId# @@ -425,8 +440,13 @@ getValuesByQuery * 根据不为空的参数进行查询 - select t.* + select t.*, + ta.student_name, + ta.student_sn, + tb.class_name from question_log_summary t + inner join student ta on ta.student_id = t.person_id and ta.student_status = 1 + inner join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 where 1=1 and #function("questionLogSummary.query")# @if(!isEmpty(questionLogSummaryId)){ and t.question_log_summary_id =#questionLogSummaryId# @@ -513,8 +533,13 @@ getValuesByQueryNotWithPermission * 根据不为空的参数进行查询(不包含权限) - select t.* + select t.*, + ta.student_name, + ta.student_sn, + tb.class_name from question_log_summary t + inner join student ta on ta.student_id = t.person_id and ta.student_status = 1 + inner join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 where 1=1 @if(!isEmpty(questionLogSummaryId)){ and t.question_log_summary_id =#questionLogSummaryId#