|
@@ -19,6 +19,7 @@ import com.qmth.distributed.print.business.mapper.ExamTaskMapper;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
|
|
|
import com.qmth.distributed.print.business.templete.execute.AsyncPaperReviewPdfExportService;
|
|
|
+import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
|
import com.qmth.teachcloud.common.bean.dto.BlurryUserDto;
|
|
|
import com.qmth.teachcloud.common.bean.dto.MqDto;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
@@ -1092,6 +1093,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
@Override
|
|
|
public void paperDownload(HttpServletResponse response, Long examTaskId) throws Exception {
|
|
|
String schoolId = ServletUtil.getRequestHeaderSchoolId().toString();
|
|
|
+ ExamTask examTask = this.getById(examTaskId);
|
|
|
QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
|
|
|
ExamTaskDetail examTaskDetail = examTaskDetailService.getOne(queryWrapper);
|
|
@@ -1101,7 +1103,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
|
|
|
List<JSONObject> jsonObjectList = JSONObject.parseArray(paperAttachmentIds, JSONObject.class);
|
|
|
// 本地保存目录
|
|
|
- String rootPath = SystemConstant.TEMP_FILES_DIR + File.separator + schoolId + File.separator + examTaskDetail.getId();
|
|
|
+ String rootPath = SystemConstant.TEMP_FILES_DIR + File.separator + System.currentTimeMillis();
|
|
|
List<File> fileList = new ArrayList<>();
|
|
|
// 试卷
|
|
|
for (JSONObject jsonObject : jsonObjectList) {
|
|
@@ -1112,8 +1114,9 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
if (attachment == null) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("附件数据异常");
|
|
|
}
|
|
|
- String fileName = attachment.getName() + "-" + name + attachment.getType();
|
|
|
- File file = teachcloudCommonService.copyFile(rootPath, fileName, attachment);
|
|
|
+ String paperPath = rootPath + File.separator + examTask.getPaperNumber();
|
|
|
+ String fileName = "试卷" + "_" + examTask.getPaperNumber() + "_" + name + attachment.getType();
|
|
|
+ File file = teachcloudCommonService.copyFile(paperPath, fileName, attachment);
|
|
|
fileList.add(file);
|
|
|
}
|
|
|
}
|
|
@@ -1122,6 +1125,8 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
Long cardId = examTaskDetail.getCardId();
|
|
|
if (cardId != null) {
|
|
|
ExamCard examCard = examCardService.getById(cardId);
|
|
|
+
|
|
|
+ String cardPath = rootPath + File.separator + examTask.getPaperNumber();
|
|
|
// 通用模板
|
|
|
if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
|
|
|
if (examCard.getTemplateId() != null) {
|
|
@@ -1130,9 +1135,18 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
throw ExceptionResultEnum.ERROR.exception("题卡文件异常");
|
|
|
}
|
|
|
BasicAttachment attachment = basicAttachmentService.getById(basicTemplate.getAttachmentId());
|
|
|
- String fileName = attachment.getName() + attachment.getType();
|
|
|
- File file = teachcloudCommonService.copyFile(rootPath, fileName, attachment);
|
|
|
+ String fileName = "题卡" + "_" + examTask.getPaperNumber() + attachment.getType();
|
|
|
+ File file = teachcloudCommonService.copyFile(cardPath, fileName, attachment);
|
|
|
fileList.add(file);
|
|
|
+
|
|
|
+ String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
|
|
|
+ // 转pdf文件
|
|
|
+ File file1 = new File(cardPdfPath);
|
|
|
+ if (!file1.exists()) {
|
|
|
+ file1.createNewFile();
|
|
|
+ }
|
|
|
+ HtmlToPdfUtil.convert(file.getPath(), cardPdfPath, PageSizeEnum.A3);
|
|
|
+ fileList.add(file1);
|
|
|
}
|
|
|
}
|
|
|
// 自制题卡或者客服制卡
|
|
@@ -1141,8 +1155,18 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
if (StringUtils.isBlank(examCardDetail.getHtmlContent())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("题卡内容有误");
|
|
|
}
|
|
|
- File file = basicAttachmentService.saveAttachmentHtml(rootPath, examCard.getTitle() + ".html", examCardDetail.getHtmlContent());
|
|
|
+ String fileName = "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
|
|
|
+ File file = basicAttachmentService.saveAttachmentHtml(cardPath, fileName, examCardDetail.getHtmlContent());
|
|
|
fileList.add(file);
|
|
|
+
|
|
|
+ String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
|
|
|
+ // 转pdf文件
|
|
|
+ File file1 = new File(cardPdfPath);
|
|
|
+ if (!file1.exists()) {
|
|
|
+ file1.createNewFile();
|
|
|
+ }
|
|
|
+ HtmlToPdfUtil.convert(file.getPath(), cardPdfPath, PageSizeEnum.A3);
|
|
|
+ fileList.add(file1);
|
|
|
}
|
|
|
}
|
|
|
if (fileList.size() == 0) {
|