|
@@ -17,20 +17,19 @@ import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
import com.qmth.boot.core.exception.ParameterException;
|
|
|
import com.qmth.boot.tools.excel.ExcelWriter;
|
|
|
import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
|
+import com.qmth.boot.tools.excel.model.CellValue;
|
|
|
import com.qmth.boot.tools.io.ZipWriter;
|
|
|
import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
|
|
|
import com.qmth.teachcloud.common.bean.vo.FilePathVo;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.entity.BasicExam;
|
|
|
-import com.qmth.teachcloud.common.entity.BasicExamStudent;
|
|
|
-import com.qmth.teachcloud.common.entity.MarkQuestion;
|
|
|
-import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
+import com.qmth.teachcloud.common.entity.*;
|
|
|
import com.qmth.teachcloud.common.enums.BasicExamStudentStatusEnum;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.PageSizeEnum;
|
|
|
import com.qmth.teachcloud.common.enums.ScanStatus;
|
|
|
import com.qmth.teachcloud.common.enums.mark.MarkPaperStatus;
|
|
|
import com.qmth.teachcloud.common.enums.mark.SubjectiveStatus;
|
|
|
+import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
|
import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
|
|
|
import com.qmth.teachcloud.common.service.FileUploadService;
|
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
@@ -166,6 +165,8 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
private ScanStudentPaperService scanStudentPaperService;
|
|
|
@Resource
|
|
|
private ScanBatchPaperService scanBatchPaperService;
|
|
|
+ @Resource
|
|
|
+ private BasicCourseService basicCourseService;
|
|
|
|
|
|
@Override
|
|
|
public List<String> listClassByExamIdAndCourseCode(Long examId, String paperNumber) {
|
|
@@ -417,7 +418,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
|
|
|
- writer.writeDataArrays("成绩导出", null, columnNames, columnValues.listIterator());
|
|
|
+ writer.writeStringArrays("成绩导出", null, columnNames, columnValues.listIterator());
|
|
|
writer.output(outputStream);
|
|
|
outputStream.flush();
|
|
|
outputStream.close();
|
|
@@ -1140,6 +1141,8 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
|
|
|
@Override
|
|
|
public void scoreExport(ArchiveStudentQuery query, HttpServletResponse response) {
|
|
|
+ MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(query.getExamId(), query.getPaperNumber());
|
|
|
+ BasicCourse basicCourse = basicCourseService.getById(markPaper.getCourseId());
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
//生成表头
|
|
|
String[] columnName = new String[]{"学生姓名", "学号", "学院", "教学班", "行政班", "课程代码", "课程名称", "状态", "客观分", "主观分", "成绩"};
|
|
@@ -1156,35 +1159,35 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
columnNameList.add(question.getMainTitle() + " " + question.getMainNumber() + "-" + question.getSubNumber() + "满分");
|
|
|
}
|
|
|
String[] columnNames = columnNameList.toArray(new String[0]);
|
|
|
- //生成动态内容
|
|
|
- List<String[]> columnValues = new ArrayList<>();
|
|
|
// 使用成绩管理列表请求的数据权限
|
|
|
DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(sysUser.getSchoolId(), sysUser.getId(), "/api/admin/mark/archive/score/list");
|
|
|
List<ArchiveStudentVo> ret = baseMapper.studentList(sysUser.getSchoolId(), query, dpr);
|
|
|
|
|
|
+ //生成动态内容
|
|
|
+ List<CellValue[]> columnValues = new ArrayList<>();
|
|
|
for (ArchiveStudentVo s : ret) {
|
|
|
- List<String> valueList = new ArrayList<>();
|
|
|
- valueList.add(s.getStudentName());
|
|
|
- valueList.add(s.getStudentCode());
|
|
|
- valueList.add(s.getCollegeName());
|
|
|
- valueList.add(s.getTeachClassName());
|
|
|
- valueList.add(s.getClassName());
|
|
|
- valueList.add(s.getCourseCode());
|
|
|
- valueList.add(s.getCourseName());
|
|
|
- valueList.add(Objects.nonNull(s.getStatus()) ? s.getStatus().getName() : null);
|
|
|
- valueList.add(s.getObjectiveScore() == null ? "" : s.getObjectiveScore().toString());
|
|
|
- valueList.add(s.getSubjectiveScore() == null ? "" : s.getSubjectiveScore().toString());
|
|
|
- valueList.add(s.getTotalScore() == null ? "" : s.getTotalScore().toString());
|
|
|
+ List<CellValue> valueList = new ArrayList<>();
|
|
|
+ valueList.add(CellValue.of(s.getStudentName()));
|
|
|
+ valueList.add(CellValue.of(s.getStudentCode()));
|
|
|
+ valueList.add(CellValue.of(s.getCollegeName()));
|
|
|
+ valueList.add(CellValue.of(s.getTeachClassName()));
|
|
|
+ valueList.add(CellValue.of(s.getClassName()));
|
|
|
+ valueList.add(CellValue.of(s.getCourseCode()));
|
|
|
+ valueList.add(CellValue.of(s.getCourseName()));
|
|
|
+ valueList.add(CellValue.of(Objects.nonNull(s.getStatus()) ? s.getStatus().getName() : ""));
|
|
|
+ valueList.add(s.getObjectiveScore() == null ? CellValue.of("") : CellValue.of(s.getObjectiveScore()));
|
|
|
+ valueList.add(s.getSubjectiveScore() == null ? CellValue.of("") : CellValue.of(s.getSubjectiveScore()));
|
|
|
+ valueList.add(s.getTotalScore() == null ? CellValue.of("") : CellValue.of(s.getTotalScore()));
|
|
|
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());
|
|
|
+ valueList.add(CellValue.of(item.getAnswer()));
|
|
|
+ valueList.add(item.getScore() == null ? CellValue.of("") : CellValue.of(item.getScore()));
|
|
|
+ valueList.add(item.getTotalScore() == null ? CellValue.of("") : CellValue.of(item.getTotalScore()));
|
|
|
}
|
|
|
for (ScoreItem item : s.getScoreList(false, sQuestionList)) {
|
|
|
- valueList.add(item.getScore().toString());
|
|
|
- valueList.add(item.getTotalScore() == null ? "" : item.getTotalScore().toString());
|
|
|
+ valueList.add(CellValue.of(item.getScore()));
|
|
|
+ valueList.add(item.getTotalScore() == null ? CellValue.of("") : CellValue.of(item.getTotalScore()));
|
|
|
}
|
|
|
- String[] columnValue = valueList.toArray(new String[0]);
|
|
|
+ CellValue[] columnValue = valueList.toArray(new CellValue[0]);
|
|
|
columnValues.add(columnValue);
|
|
|
}
|
|
|
|
|
@@ -1203,20 +1206,21 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
|
|
|
log.debug("导出Excel开始...");
|
|
|
ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
|
|
|
- writer.writeDataArrays("成绩导出", null, columnNames, columnValues.listIterator());
|
|
|
- FileOutputStream fileOut = new FileOutputStream(downloadFilePath + File.separator + "成绩导出" + SystemConstant.EXCEL_PREFIX);
|
|
|
+ writer.writeDataArrays("成绩单", null, columnNames, columnValues.listIterator());
|
|
|
+ FileOutputStream fileOut = new FileOutputStream(downloadFilePath + File.separator + basicCourse.getName() + "-成绩单" + 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();
|
|
|
+ Map<CellValue, List<CellValue[]>> listMap = columnValues.stream().collect(Collectors.groupingBy(m -> m[3]));
|
|
|
+ Set<Map.Entry<CellValue, List<CellValue[]>>> entrySet = listMap.entrySet();
|
|
|
if (entrySet.size() > 1) {
|
|
|
- for (Map.Entry<String, List<String[]>> entry : entrySet) {
|
|
|
+ for (Map.Entry<CellValue, List<CellValue[]>> 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.writeDataArrays("成绩单", null, columnNames, entry.getValue().listIterator());
|
|
|
+ // todo 班级名称未解决
|
|
|
+ FileOutputStream classFileOut = new FileOutputStream(downloadFilePath + File.separator + basicCourse.getName() + "-" + entry.getKey() + "成绩单" + SystemConstant.EXCEL_PREFIX);
|
|
|
writer.output(classFileOut);
|
|
|
classFileOut.flush();
|
|
|
classFileOut.close();
|
|
@@ -2027,7 +2031,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
writer.setCellStyle(sheetName, cellStyle2, 0, new int[]{4, 5, 6});
|
|
|
|
|
|
- writer.writeDataArrays(sheetName, null, columnNames, columnValues.listIterator());
|
|
|
+ writer.writeStringArrays(sheetName, null, columnNames, columnValues.listIterator());
|
|
|
|
|
|
writer.output(outputStream);
|
|
|
outputStream.flush();
|