|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.distributed.print.business.templete.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -26,6 +27,7 @@ import com.qmth.distributed.print.common.util.HexUtils;
|
|
|
import com.qmth.distributed.print.common.util.ResultUtil;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.commons.lang3.time.DateUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
@@ -946,6 +948,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
@Override
|
|
|
public Map<String, Object> executeExportPaperAndCardLogic(Map<String, Object> map) throws IOException {
|
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
+ String yyyyMMddHH24mmss = DateUtil.format(new Date(), "yyyyMMddHHmmss");
|
|
|
+ BasicSchool basicSchool = cacheService.schoolCache(tbTask.getSchoolId());
|
|
|
LocalDateTime nowTime = LocalDateTime.now();
|
|
|
StringJoiner zipJoiner = new StringJoiner("")
|
|
|
.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
|
|
@@ -954,7 +958,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
.add(String.valueOf(nowTime.getYear())).add(File.separator)
|
|
|
.add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
|
|
|
.add(String.format("%02d", nowTime.getDayOfMonth()))
|
|
|
- .add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.ZIP_PREFIX);
|
|
|
+ .add(File.separator)
|
|
|
+ .add(yyyyMMddHH24mmss).add("_").add(basicSchool.getName()).add("_").add("试卷导出文件").add(SystemConstant.ZIP_PREFIX);
|
|
|
String dirNameTmp = dirName.toString().replaceAll("\\\\", "/");
|
|
|
|
|
|
// 根文件路径
|
|
@@ -962,11 +967,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
List<ExamTaskDetailDto> examTasks = (List<ExamTaskDetailDto>) map.get("examTasks");
|
|
|
for (ExamTaskDetailDto examTask : examTasks) {
|
|
|
- String courseCodeName = examTask.getCourseCode() + "(" + examTask.getCourseName() + ")";
|
|
|
ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(Long.valueOf(examTask.getId()));
|
|
|
|
|
|
// 试卷
|
|
|
- String paperSavePath = zipLocalRootPath + File.separator + "试卷";
|
|
|
String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
|
|
|
if (StringUtils.isNotBlank(paperAttachmentIds)) {
|
|
|
List<Map> paperInfo = JSONObject.parseArray(paperAttachmentIds, Map.class);
|
|
@@ -980,7 +983,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
|
|
|
if (Objects.nonNull(attachment)) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(attachment.getPath());
|
|
|
- String paperPath = paperSavePath + File.separator + courseCodeName + File.separator + examTask.getPaperNumber() + File.separator + attachment.getName() + attachment.getType();
|
|
|
+ String paperPath = zipLocalRootPath + File.separator + examTask.getPaperNumber() + File.separator + "试卷" + "_" + examTask.getPaperNumber() + "_" + name + attachment.getType();
|
|
|
ossUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), paperPath);
|
|
|
}
|
|
|
}
|
|
@@ -988,7 +991,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
|
|
|
// 题卡
|
|
|
- String cardSavePath = zipLocalRootPath + File.separator + "题卡";
|
|
|
// 处理题卡
|
|
|
ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
|
|
|
if (Objects.isNull(examCard)) {
|
|
@@ -996,9 +998,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
|
|
|
|
|
|
- String cardPath = cardSavePath + File.separator + courseCodeName + File.separator + examTask.getPaperNumber();
|
|
|
- String cardHtmlPath = cardPath + File.separator + examCard.getTitle() + SystemConstant.HTML_PREFIX;
|
|
|
- String cardPdfPath = cardPath + File.separator + examCard.getTitle() + SystemConstant.PDF_PREFIX;
|
|
|
+ String cardPath = zipLocalRootPath + File.separator + examTask.getPaperNumber();
|
|
|
+ String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
|
|
|
+ String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
|
|
|
// 通用题卡
|
|
|
ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
|
|
|
String htmlContent;
|
|
@@ -1017,7 +1019,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
FileCopyUtils.copy(htmlContent.getBytes(), localFile);
|
|
|
// 转pdf文件
|
|
|
File file = new File(cardPdfPath);
|
|
|
- if(!file.exists()){
|
|
|
+ if (!file.exists()) {
|
|
|
file.createNewFile();
|
|
|
}
|
|
|
HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
|
|
@@ -1027,7 +1029,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
if (!zipFile.getParentFile().exists()) {
|
|
|
zipFile.getParentFile().mkdirs();
|
|
|
}
|
|
|
- if(!zipFile.exists()){
|
|
|
+ if (!zipFile.exists()) {
|
|
|
zipFile.createNewFile();
|
|
|
}
|
|
|
|