|
@@ -1720,18 +1720,35 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
String filePath = zipLocalRootPath + File.separator + course + File.separator + paperNumber + File.separator;
|
|
String filePath = zipLocalRootPath + File.separator + course + File.separator + paperNumber + File.separator;
|
|
|
|
|
|
Long examCardId = paperCellList.get(0).getExamCardId();
|
|
Long examCardId = paperCellList.get(0).getExamCardId();
|
|
|
|
+ Long cardRuleId = paperCellList.get(0).getCardRuleId();
|
|
|
|
+ ExamCard examCard = examCardService.getById(examCardId);
|
|
ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
- String htmlContent = examCardDetail.getHtmlContent();
|
|
|
|
|
|
+ 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();
|
|
byte[] bytes = htmlContent.getBytes();
|
|
- String cardLocalPath = filePath + "题卡-" + examCardService.getById(examCardId).getTitle() + SystemConstant.HTML_PREFIX;
|
|
|
|
|
|
+ String cardLocalHtmlPath = filePath + "题卡-" + examCardService.getById(examCardId).getTitle() + SystemConstant.HTML_PREFIX;
|
|
|
|
+ String cardLocalPdfPath = filePath + "题卡-" + examCardService.getById(examCardId).getTitle() + SystemConstant.PDF_PREFIX;
|
|
|
|
|
|
switch (paperFileDownloadContent) {
|
|
switch (paperFileDownloadContent) {
|
|
case ONLY_CARD: // 只下载题卡
|
|
case ONLY_CARD: // 只下载题卡
|
|
- File localFile = new File(cardLocalPath);
|
|
|
|
|
|
+ File localFile = new File(cardLocalHtmlPath);
|
|
if (!localFile.getParentFile().exists()) {
|
|
if (!localFile.getParentFile().exists()) {
|
|
boolean mkr = localFile.getParentFile().mkdirs();
|
|
boolean mkr = localFile.getParentFile().mkdirs();
|
|
}
|
|
}
|
|
FileCopyUtils.copy(bytes, localFile);
|
|
FileCopyUtils.copy(bytes, localFile);
|
|
|
|
+
|
|
|
|
+ File pdfFile = new File(cardLocalPdfPath);
|
|
|
|
+ if (!pdfFile.exists()) {
|
|
|
|
+ boolean cf = pdfFile.createNewFile();
|
|
|
|
+ }
|
|
|
|
+ HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
break;
|
|
break;
|
|
case ONLY_PAPER: // 只下载试卷
|
|
case ONLY_PAPER: // 只下载试卷
|
|
for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
@@ -1752,11 +1769,17 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
break;
|
|
break;
|
|
case PAPER_AND_CARD: // 全部下载
|
|
case PAPER_AND_CARD: // 全部下载
|
|
// 题卡
|
|
// 题卡
|
|
- File localCardFile = new File(cardLocalPath);
|
|
|
|
|
|
+ File localCardFile = new File(cardLocalHtmlPath);
|
|
if (!localCardFile.getParentFile().exists()) {
|
|
if (!localCardFile.getParentFile().exists()) {
|
|
boolean mkr = localCardFile.getParentFile().mkdirs();
|
|
boolean mkr = localCardFile.getParentFile().mkdirs();
|
|
}
|
|
}
|
|
FileCopyUtils.copy(bytes, localCardFile);
|
|
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) {
|
|
for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
String paperName = "试卷-";
|
|
String paperName = "试卷-";
|
|
@@ -1778,7 +1801,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ZipUtil.zip(zipLocalRootPath, zipFile.getPath(), false);
|
|
ZipUtil.zip(zipLocalRootPath, zipFile.getPath(), false);
|
|
-// ossUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))));
|
|
|
|
fileStoreUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))), fileStoreUtil.getUploadEnumByPath(dirNameTmp).getFssType());
|
|
fileStoreUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))), fileStoreUtil.getUploadEnumByPath(dirNameTmp).getFssType());
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put(SystemConstant.PATH, dirNameTmp);
|
|
jsonObject.put(SystemConstant.PATH, dirNameTmp);
|