Browse Source

印品路径\\问题,禁用卷库不能触发pdf

xiaof 4 năm trước cách đây
mục cha
commit
14583000bc

+ 3 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicAttachmentServiceImpl.java

@@ -295,6 +295,7 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
             pdfStringJoiner.add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.PDF_PREFIX);
 
             String pdfDirName = pdfStringJoiner.toString();
+            String pdfDirNameStr = pdfStringJoiner.toString().replace("\\","/");
             String destUrl = SystemConstant.PDF_TEMP_FILES_DIR + File.separator + pdfDirName;
 
             File pdfFile = new File(destUrl);
@@ -309,7 +310,7 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
             PdfDto pdfDto = null;
             if (oss) {//上传至oss
                 pdfDto = PdfUtil.addPdfPage(pdfFile);
-                ossUtil.ossUpload(pdfDirName, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(pdfFileMd5)));
+                ossUtil.ossUpload(pdfDirNameStr, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(pdfFileMd5)));
 //                htmlFile.delete();
             }
             JSONObject attachmentPath = JSONObject.parseObject(examDetail.getAttachmentPath());
@@ -321,7 +322,7 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
             object.put(SystemConstant.HTML_PATH, filePath);
             object.put("htmlMd5", htmlFileMd5);
             object.put("pdfMd5", pdfFileMd5);
-            object.put(SystemConstant.PDF_PATH, pdfDirName);
+            object.put(SystemConstant.PDF_PATH, pdfDirNameStr);
             object.put(SystemConstant.TYPE, SystemConstant.OSS);
             object.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
                     UploadFileEnum.HTML,

+ 11 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/CommonServiceImpl.java

@@ -80,6 +80,9 @@ public class CommonServiceImpl implements CommonService {
     @Autowired
     private ExamTaskService examTaskService;
 
+    @Autowired
+    private ExamTaskDetailService examTaskDetailService;
+
     @Autowired
     private ExamDetailService examDetailService;
 
@@ -603,7 +606,14 @@ public class CommonServiceImpl implements CommonService {
         // 校验命题任务是否提交
         ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(schoolId, courseCode, paperNumber);
         if (examTask != null && !examTask.getEnable()) {
-            throw ExceptionResultEnum.ERROR.exception("命题任务已禁用");
+            log.info("命题任务已禁用");
+            return;
+//            throw ExceptionResultEnum.ERROR.exception("命题任务已禁用");
+        }
+        ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
+        if (!examTaskDetail.getEnable()) {
+            log.info("卷库已禁用");
+            return;
         }
         // 1.命题任务已完成
         if (examTask != null && examTask.getStatus().name().equals(ExamStatusEnum.FINISH.name())) {

+ 3 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/FreemarkerUtil.java

@@ -115,8 +115,9 @@ public class FreemarkerUtil {
             template.process(dataMap, out);
             out.flush();
             if (oss) {
-                ossUtil.ossUpload(htmlStringJoiner.toString(), htmlFile, DigestUtils.md5Hex(new FileInputStream(htmlFile)));
-                jsonObject.put(SystemConstant.HTML_PATH, htmlStringJoiner.toString());
+                String htmlStringJoinerStr = htmlStringJoiner.toString().replace("\\","/");
+                ossUtil.ossUpload(htmlStringJoinerStr, htmlFile, DigestUtils.md5Hex(new FileInputStream(htmlFile)));
+                jsonObject.put(SystemConstant.HTML_PATH, htmlStringJoinerStr);
                 jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
                         UploadFileEnum.FILE,
                         UploadFileEnum.HTML