|
@@ -1139,7 +1139,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void scoreExport(ArchiveStudentQuery query, OutputStream outputStream) {
|
|
|
+ public void scoreExport(ArchiveStudentQuery query, HttpServletResponse response) {
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
//生成表头
|
|
|
String[] columnName = new String[]{"学生姓名", "学号", "学院", "教学班", "行政班", "课程代码", "课程名称", "状态", "客观分", "主观分", "成绩"};
|
|
@@ -1149,9 +1149,11 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
for (MarkQuestion question : oQuestionList) {
|
|
|
columnNameList.add(question.getMainTitle() + " " + question.getMainNumber() + "-" + question.getSubNumber() + "选项");
|
|
|
columnNameList.add(question.getMainTitle() + " " + question.getMainNumber() + "-" + question.getSubNumber() + "得分");
|
|
|
+ columnNameList.add(question.getMainTitle() + " " + question.getMainNumber() + "-" + question.getSubNumber() + "满分");
|
|
|
}
|
|
|
for (MarkQuestion question : sQuestionList) {
|
|
|
columnNameList.add(question.getMainTitle() + " " + question.getMainNumber() + "-" + question.getSubNumber());
|
|
|
+ columnNameList.add(question.getMainTitle() + " " + question.getMainNumber() + "-" + question.getSubNumber() + "满分");
|
|
|
}
|
|
|
String[] columnNames = columnNameList.toArray(new String[0]);
|
|
|
//生成动态内容
|
|
@@ -1159,6 +1161,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
// 使用成绩管理列表请求的数据权限
|
|
|
DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(sysUser.getSchoolId(), sysUser.getId(), "/api/admin/mark/archive/score/list");
|
|
|
List<ArchiveStudentVo> ret = baseMapper.studentList(sysUser.getSchoolId(), query, dpr);
|
|
|
+
|
|
|
for (ArchiveStudentVo s : ret) {
|
|
|
List<String> valueList = new ArrayList<>();
|
|
|
valueList.add(s.getStudentName());
|
|
@@ -1175,23 +1178,60 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
for (ScoreItem item : s.getScoreList(true, oQuestionList)) {
|
|
|
valueList.add(item.getAnswer());
|
|
|
valueList.add(item.getScore() == null ? "" : item.getScore().toString());
|
|
|
+ valueList.add(item.getTotalScore() == null ? "" : item.getTotalScore().toString());
|
|
|
}
|
|
|
for (ScoreItem item : s.getScoreList(false, sQuestionList)) {
|
|
|
valueList.add(item.getScore().toString());
|
|
|
+ valueList.add(item.getTotalScore() == null ? "" : item.getTotalScore().toString());
|
|
|
}
|
|
|
String[] columnValue = valueList.toArray(new String[0]);
|
|
|
columnValues.add(columnValue);
|
|
|
}
|
|
|
+
|
|
|
+ String rootPath = null;
|
|
|
try {
|
|
|
+ // 本地保存目录
|
|
|
+ File tempFile = SystemConstant.getFileTempParentDirVar(SystemConstant.TEMP_PREFIX);
|
|
|
+ rootPath = tempFile.getPath() + File.separator + SystemConstant.getNanoId();
|
|
|
+
|
|
|
+ // 下载文件保存目录(用uuid命名)
|
|
|
+ String downloadFilePath = rootPath + File.separator + query.getPaperNumber();
|
|
|
+ File downloadPathFile = new File(downloadFilePath);
|
|
|
+ if (!downloadPathFile.exists()) {
|
|
|
+ downloadPathFile.mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
log.debug("导出Excel开始...");
|
|
|
ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
|
|
|
writer.writeDataArrays("成绩导出", null, columnNames, columnValues.listIterator());
|
|
|
- writer.output(outputStream);
|
|
|
- outputStream.flush();
|
|
|
- outputStream.close();
|
|
|
+ FileOutputStream fileOut = new FileOutputStream(downloadFilePath + File.separator + "成绩导出" + SystemConstant.EXCEL_PREFIX);
|
|
|
+ writer.output(fileOut);
|
|
|
+ fileOut.flush();
|
|
|
+ fileOut.close();
|
|
|
+
|
|
|
+ // 通过教学班聚合
|
|
|
+ Map<String, List<String[]>> listMap = columnValues.stream().collect(Collectors.groupingBy(m -> m[3]));
|
|
|
+ Set<Map.Entry<String, List<String[]>>> entrySet = listMap.entrySet();
|
|
|
+ if (entrySet.size() > 1) {
|
|
|
+ for (Map.Entry<String, List<String[]>> entry : entrySet) {
|
|
|
+ writer = ExcelWriter.create(ExcelType.XLSX);
|
|
|
+ writer.writeDataArrays("成绩导出", null, columnNames, entry.getValue().listIterator());
|
|
|
+ FileOutputStream classFileOut = new FileOutputStream(downloadFilePath + File.separator + "成绩导出-" + entry.getKey() + SystemConstant.EXCEL_PREFIX);
|
|
|
+ writer.output(classFileOut);
|
|
|
+ classFileOut.flush();
|
|
|
+ classFileOut.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
log.debug("导出Excel结束");
|
|
|
+
|
|
|
+ String zipFileName = downloadPathFile.getName() + SystemConstant.ZIP_PREFIX;
|
|
|
+ FileUtil.downloadEncryptZip(response, downloadPathFile, zipFileName);
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
|
+ } finally {
|
|
|
+ if (Objects.nonNull(rootPath)) {
|
|
|
+ FileUtil.deleteDirectory(rootPath);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1486,10 +1526,10 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
/**
|
|
|
* 填充大题分析
|
|
|
*
|
|
|
- * @param ret ret
|
|
|
- * @param studentList 涉及的考生集合
|
|
|
- * @param examId 考试id
|
|
|
- * @param paperNumber 试卷编号
|
|
|
+ * @param ret ret
|
|
|
+ * @param studentList 涉及的考生集合
|
|
|
+ * @param examId 考试id
|
|
|
+ * @param paperNumber 试卷编号
|
|
|
*/
|
|
|
private void fillMainQuestionAnalysis(ScoreReportVo ret, List<ArchiveStudentVo> studentList, Long examId, String paperNumber) {
|
|
|
// 试卷结构数据
|
|
@@ -1600,7 +1640,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
ret.setMainQuestionAnalysis(questionVoList);
|
|
|
}
|
|
|
|
|
|
- private String getMainQuestionMapKey(Integer mainNumber, boolean objective){
|
|
|
+ private String getMainQuestionMapKey(Integer mainNumber, boolean objective) {
|
|
|
return mainNumber + "-" + objective;
|
|
|
}
|
|
|
|