|
@@ -1844,33 +1844,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
// 文件路径
|
|
|
String filePath = zipLocalRootPath + File.separator + course + File.separator + paperNumber + File.separator;
|
|
|
|
|
|
- Long examCardId = paperCellList.get(0).getExamCardId();
|
|
|
- Long cardRuleId = paperCellList.get(0).getCardRuleId();
|
|
|
- ExamCard examCard = examCardService.getById(examCardId);
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
|
- String htmlContent;
|
|
|
- if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
- htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
- } else {
|
|
|
- BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
|
|
|
- htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- byte[] bytes = htmlContent.getBytes();
|
|
|
- String cardName = "题卡-";
|
|
|
- if (namedByCourseInfo) {
|
|
|
- cardName = cardName + course;
|
|
|
- }
|
|
|
- if (namedByPaperNumber) {
|
|
|
- cardName = cardName + paperNumber;
|
|
|
- }
|
|
|
- if (namedByOriginalFile) {
|
|
|
- cardName = cardName + examCardService.getById(examCardId).getTitle();
|
|
|
- }
|
|
|
- String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
|
|
|
- String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
|
|
|
-
|
|
|
// 试卷文件曝光度筛选
|
|
|
if (Objects.nonNull(paperFileDownloadExposureStatus)) {
|
|
|
switch (paperFileDownloadExposureStatus) {
|
|
@@ -1900,19 +1873,48 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
switch (paperFileDownloadContent) {
|
|
|
case ONLY_CARD: // 只下载题卡
|
|
|
- File localFile = new File(cardLocalHtmlPath);
|
|
|
- if (!localFile.getParentFile().exists()) {
|
|
|
- boolean mkr = localFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
- FileCopyUtils.copy(bytes, localFile);
|
|
|
+ for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
|
+ Long examCardId = examTaskPaperFileDto.getExamCardId();
|
|
|
+ Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
|
|
|
+ ExamCard examCard = examCardService.getById(examCardId);
|
|
|
+ ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
|
+ String htmlContent;
|
|
|
+ if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
+ htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
+ } else {
|
|
|
+ BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
|
|
|
+ htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
+ }
|
|
|
+
|
|
|
+ byte[] bytes = htmlContent.getBytes();
|
|
|
+ String cardName = "题卡-";
|
|
|
+ if (namedByCourseInfo) {
|
|
|
+ cardName = cardName + course;
|
|
|
+ }
|
|
|
+ if (namedByPaperNumber) {
|
|
|
+ cardName = cardName + paperNumber;
|
|
|
+ }
|
|
|
+ if (namedByOriginalFile) {
|
|
|
+ cardName = cardName + examCardService.getById(examCardId).getTitle();
|
|
|
+ }
|
|
|
+ cardName = cardName + "-" + examTaskPaperFileDto.getPaperType();
|
|
|
+ String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
|
|
|
+ String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
|
|
|
+
|
|
|
+ File localFile = new File(cardLocalHtmlPath);
|
|
|
+ if (!localFile.getParentFile().exists()) {
|
|
|
+ boolean mkr = localFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ FileCopyUtils.copy(bytes, localFile);
|
|
|
|
|
|
- File pdfFile = new File(cardLocalPdfPath);
|
|
|
- if (!pdfFile.exists()) {
|
|
|
- boolean cf = pdfFile.createNewFile();
|
|
|
+ File pdfFile = new File(cardLocalPdfPath);
|
|
|
+ if (!pdfFile.exists()) {
|
|
|
+ boolean cf = pdfFile.createNewFile();
|
|
|
+ }
|
|
|
+ HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
+ specialSuccessMessage = "";
|
|
|
+ courseCount = 1;
|
|
|
}
|
|
|
- HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
- specialSuccessMessage = "";
|
|
|
- courseCount = 1;
|
|
|
break;
|
|
|
case ONLY_PAPER: // 只下载试卷
|
|
|
for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
@@ -1938,20 +1940,47 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
break;
|
|
|
case PAPER_AND_CARD: // 全部下载
|
|
|
- // 题卡
|
|
|
- File localCardFile = new File(cardLocalHtmlPath);
|
|
|
- if (!localCardFile.getParentFile().exists()) {
|
|
|
- boolean mkr = localCardFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
- FileCopyUtils.copy(bytes, localCardFile);
|
|
|
-
|
|
|
- File cardPdfFile = new File(cardLocalPdfPath);
|
|
|
- if (!cardPdfFile.exists()) {
|
|
|
- boolean cf = cardPdfFile.createNewFile();
|
|
|
- }
|
|
|
- HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
- // 试卷
|
|
|
for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
|
+ // 题卡
|
|
|
+ Long examCardId = examTaskPaperFileDto.getExamCardId();
|
|
|
+ Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
|
|
|
+ ExamCard examCard = examCardService.getById(examCardId);
|
|
|
+ ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
|
+ String htmlContent;
|
|
|
+ if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
+ htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
+ } else {
|
|
|
+ BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
|
|
|
+ htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
+ }
|
|
|
+
|
|
|
+ byte[] bytes = htmlContent.getBytes();
|
|
|
+ String cardName = "题卡-";
|
|
|
+ if (namedByCourseInfo) {
|
|
|
+ cardName = cardName + course;
|
|
|
+ }
|
|
|
+ if (namedByPaperNumber) {
|
|
|
+ cardName = cardName + paperNumber;
|
|
|
+ }
|
|
|
+ if (namedByOriginalFile) {
|
|
|
+ cardName = cardName + examCardService.getById(examCardId).getTitle();
|
|
|
+ }
|
|
|
+ cardName = cardName + "-" + examTaskPaperFileDto.getPaperType();
|
|
|
+ String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
|
|
|
+ String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
|
|
|
+ File localCardFile = new File(cardLocalHtmlPath);
|
|
|
+ if (!localCardFile.getParentFile().exists()) {
|
|
|
+ boolean mkr = localCardFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ FileCopyUtils.copy(bytes, localCardFile);
|
|
|
+
|
|
|
+ File cardPdfFile = new File(cardLocalPdfPath);
|
|
|
+ if (!cardPdfFile.exists()) {
|
|
|
+ boolean cf = cardPdfFile.createNewFile();
|
|
|
+ }
|
|
|
+ HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
+
|
|
|
+ // 试卷
|
|
|
String paperName = "试卷-";
|
|
|
if (namedByCourseInfo) {
|
|
|
paperName = paperName + course;
|