Răsfoiți Sursa

下载修改

wangliang 2 ani în urmă
părinte
comite
8a2c1ae6de

+ 4 - 13
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -949,7 +949,6 @@ 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);
@@ -976,23 +975,15 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 File file = teachcloudCommonService.copyFile(paperPath, fileName, attachment);
                 fileList.add(file);
             }
-        }
 
-        // 题卡
-//        Long cardId = examTaskDetail.getCardId();
-        if (Objects.nonNull(examTaskDetail.getPaperAttachmentIds())) {
-            JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
-            String cardId = null;
-            for (int i = 0; i < jsonArrayPaper.size(); i++) {
-                JSONObject object = jsonArrayPaper.getJSONObject(i);
-                cardId = (String) object.get("cardId");
-            }
+            // 题卡
+            Long cardId = Long.parseLong(jsonObject.getString("cardId"));
             if (cardId != null) {
                 ExamCard examCard = examCardService.getById(cardId);
 
                 String cardPath = rootPath + File.separator + examTask.getPaperNumber();
-                String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
-                String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
+                String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + "_" + name + SystemConstant.HTML_PREFIX;
+                String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + "_" + name + SystemConstant.PDF_PREFIX;
 
                 ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
                 String htmlContent;

+ 13 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/Zip4jUtil.java

@@ -130,10 +130,18 @@ public class Zip4jUtil {
      */
     private static void commonUnZipFile(String scrPath, String destPath, String password) {
         try {
+            File file = new File(scrPath);
+            if (!file.exists()) {
+                file.getParentFile().mkdirs();
+            }
             ZipFile zipFile = new ZipFile(scrPath);
             if (Objects.nonNull(password) && zipFile.isEncrypted()) {
                 zipFile.setPassword(password);
             }
+            File currentFile = new File(destPath);
+            if (!currentFile.exists()) {
+                throw ExceptionResultEnum.ERROR.exception("待解压的路径不存在");
+            }
             zipFile.extractAll(destPath);
         } catch (ZipException e) {
             log.error(SystemConstant.LOG_ERROR, e);
@@ -151,6 +159,10 @@ public class Zip4jUtil {
      */
     private static void commonZipFile(String scrPath, String destPath, List<File> files, String password) {
         try {
+            File file = new File(scrPath);
+            if (!file.exists()) {
+                file.getParentFile().mkdirs();
+            }
             // 生成的压缩文件
             ZipFile zipFile = new ZipFile(scrPath);
             ZipParameters parameters = new ZipParameters();
@@ -168,7 +180,7 @@ public class Zip4jUtil {
             File[] fs = null;
             if (!CollectionUtil.isEmpty(files)) {
                 // 要打包的文件夹
-                fs = files.toArray(new File[0]);
+                fs = files.toArray(new File[files.size()]);
             } else if (Objects.nonNull(destPath)) {
                 File currentFile = new File(destPath);
                 if (!currentFile.exists()) {