|
@@ -1,6 +1,7 @@
|
|
|
package com.qmth.teachcloud.mark.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -12,16 +13,18 @@ import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
import com.qmth.boot.core.exception.ParameterException;
|
|
|
import com.qmth.teachcloud.common.bean.vo.FilePathVo;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
|
import com.qmth.teachcloud.common.entity.BasicExam;
|
|
|
import com.qmth.teachcloud.common.entity.MarkQuestion;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
+import com.qmth.teachcloud.common.enums.CardCreateMethodEnum;
|
|
|
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.TeachcloudCommonService;
|
|
|
-import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
|
-import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
+import com.qmth.teachcloud.common.util.*;
|
|
|
import com.qmth.teachcloud.mark.bean.UpdateTimeVo;
|
|
|
import com.qmth.teachcloud.mark.bean.archivescore.*;
|
|
|
import com.qmth.teachcloud.mark.bean.omredit.OmrEditDomain;
|
|
@@ -54,10 +57,13 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.FileCopyUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
+import java.io.File;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -887,10 +893,53 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
return this.count(queryWrapper);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void scoreReportDownload(JSONObject jsonObject, HttpServletResponse response) {
|
|
|
+ String rootPath = null;
|
|
|
+ File htmlFile;
|
|
|
+ File pdfFile;
|
|
|
+ try {
|
|
|
+ // 本地保存目录
|
|
|
+ File tempFile = SystemConstant.getFileTempDirVar(System.currentTimeMillis() + File.separator + SystemConstant.getNanoId(), SystemConstant.TEMP_PREFIX);
|
|
|
+ rootPath = tempFile.getParent();
|
|
|
+
|
|
|
+ // 删除临时目录中创建的临时文件
|
|
|
+ if (Objects.nonNull(tempFile)) {
|
|
|
+ tempFile.delete();
|
|
|
+ }
|
|
|
+ // html文件
|
|
|
+ String cardHtmlPath = rootPath + File.separator + System.currentTimeMillis() + File.separator + "temp" + SystemConstant.HTML_PREFIX;
|
|
|
+ htmlFile = new File(cardHtmlPath);
|
|
|
+ if (!htmlFile.exists()) {
|
|
|
+ htmlFile.getParentFile().mkdirs();
|
|
|
+ htmlFile.createNewFile();
|
|
|
+ }
|
|
|
+ // 生成html文件
|
|
|
+ FileCopyUtils.copy(jsonObject.getString("htmlContent").getBytes(StandardCharsets.UTF_8), htmlFile);
|
|
|
+
|
|
|
+ // pdf文件
|
|
|
+ String cardPdfPath = rootPath + File.separator + System.currentTimeMillis() + File.separator + "temp" + SystemConstant.PDF_PREFIX;
|
|
|
+ pdfFile = new File(cardPdfPath);
|
|
|
+ if (!pdfFile.exists()) {
|
|
|
+ pdfFile.getParentFile().mkdirs();
|
|
|
+ pdfFile.createNewFile();
|
|
|
+ }
|
|
|
+ HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A4);
|
|
|
+ FileUtil.outputFile(response, pdfFile, "报告" + SystemConstant.PDF_PREFIX);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (Objects.nonNull(rootPath)) {
|
|
|
+ ConvertUtil.delFolder(rootPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void fillObjective(ScoreReportVo ret, Long examId, String paperNumber) {
|
|
|
List<MarkQuestion> qs = markQuestionService.listQuestionByExamIdAndPaperNumber(examId, paperNumber);
|
|
|
List<MarkStudent> students = listByExamIdAndPaperNumberAndAbsent(examId, paperNumber, false);
|
|
|
Map<String, QuestionVo> map = new HashMap<>();
|
|
|
+ List<QuestionVo> list = new ArrayList<>();
|
|
|
for (MarkStudent s : students) {
|
|
|
List<ScoreItem> sis = s.getScoreList(true, qs);
|
|
|
if (CollectionUtils.isNotEmpty(sis)) {
|
|
@@ -923,7 +972,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
|
|
|
if (map.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
- List<QuestionVo> list = new ArrayList<>(map.values());
|
|
|
+
|
|
|
Collections.sort(list, (o1, o2) -> {
|
|
|
if (o1.getMainNumber() > o2.getMainNumber()) {
|
|
|
return 1;
|