deason 6 жил өмнө
parent
commit
d0cab9c9eb

+ 1 - 5
examcloud-core-print-common/src/main/java/cn/com/qmth/examcloud/core/print/common/Constants.java

@@ -36,8 +36,6 @@ public interface Constants {
     String PRT_CODE_403 = "PRT-000403";
 
     /* 导出文件默认名称 */
-    String PAPER_DOC_NAME = "试卷.docx";
-    String ANSWER_DOC_NAME = "答案.docx";
     String PAPER_PDF_NAME = "试卷.pdf";
     String ANSWER_PDF_NAME = "答案.pdf";
     String STRUCT_ZIP_NAME = "试卷结构.zip";
@@ -45,11 +43,9 @@ public interface Constants {
     String SUBJECTIVE_EXCEL_NAME = "主观题.xlsx";
     String OBJECTIVE_TITLE = "客观题数据";
     String SUBJECTIVE_TITLE = "主观题数据";
-    String PAPER_DIR = "paper";
-    String ANSWER_DIR = "answer";
 
     String SUFFIX_ZIP = ".zip";
-    String SUFFIX_WORD = ".docx";
+    String SUFFIX_PDF = ".pdf";
     String SUFFIX_EXCEL = ".xlsx";
 
     static String rootFileDir() {

+ 12 - 24
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/coursepaper/ExportFileInfo.java

@@ -16,34 +16,14 @@ import javafx.util.Pair;
  */
 public class ExportFileInfo implements JsonSerializable {
     private static final long serialVersionUID = 1L;
-    /**
-     * 试卷Word文件 <名称,地址>
-     */
-    private Pair<String, String> paperWord;
-    /**
-     * 答案Word文件 <名称,地址>
-     */
-    private Pair<String, String> answerWord;
     /**
      * 试卷PDF文件 <名称,地址>
      */
     private Pair<String, String> paperPdf;
-
-    public Pair<String, String> getPaperWord() {
-        return paperWord;
-    }
-
-    public void setPaperWord(Pair<String, String> paperWord) {
-        this.paperWord = paperWord;
-    }
-
-    public Pair<String, String> getAnswerWord() {
-        return answerWord;
-    }
-
-    public void setAnswerWord(Pair<String, String> answerWord) {
-        this.answerWord = answerWord;
-    }
+    /**
+     * 答案PDF文件 <名称,地址>
+     */
+    private Pair<String, String> answerPdf;
 
     public Pair<String, String> getPaperPdf() {
         return paperPdf;
@@ -53,4 +33,12 @@ public class ExportFileInfo implements JsonSerializable {
         this.paperPdf = paperPdf;
     }
 
+    public Pair<String, String> getAnswerPdf() {
+        return answerPdf;
+    }
+
+    public void setAnswerPdf(Pair<String, String> answerPdf) {
+        this.answerPdf = answerPdf;
+    }
+
 }

+ 20 - 18
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/CoursePaperServiceImpl.java

@@ -53,8 +53,8 @@ public class CoursePaperServiceImpl implements CoursePaperService {
     private CourseStatisticRepository courseStatisticRepository;
     @Autowired
     private QuestionStructureService questionStructureService;
-    @Value("${paper.html.url.prefix}")
-    private String PAPER_HTML_URL_PREFIX;//试卷预览地址前缀
+    @Value("${question.url.prefix}")
+    private String QUESTION_URL_PREFIX;//题库访问地址前缀
 
     @Override
     public List<CoursePaperInfo> getCoursePaperList(CoursePaperQuery query) {
@@ -92,22 +92,22 @@ public class CoursePaperServiceImpl implements CoursePaperService {
         Check.isEmpty(coursePaper.getCourseName(), "课程名称不能为空!");
         Check.isEmpty(coursePaper.getPaperId(), "试卷ID不能为空!");
         Check.isEmpty(coursePaper.getPaperName(), "试卷名称不能为空!");
-        Check.isBlank(coursePaper.getPaperWordUrl(), "试卷Word文件地址不能为空!");
-        Check.isBlank(coursePaper.getAnswerWordUrl(), "答案Word文件地址不能为空!");
-        //Check.isBlank(coursePaper.getPaperHtmlUrl(), "试卷页面地址不能为空!");
-        //Check.isBlank(coursePaper.getPaperPdfUrl(), "试卷PDF文件地址不能为空!");
-        //Check.isNull(coursePaper.getPaperP(), "试卷页数不能为空!");
+//        Check.isBlank(coursePaper.getPaperHtmlUrl(), "试卷页面地址不能为空!");
+//        Check.isBlank(coursePaper.getAnswerHtmlUrl(), "答案页面地址不能为空!");
+//        Check.isNull(coursePaper.getPaperP(), "试卷页数不能为空!");
 
-        String paperHtmlUrl = PAPER_HTML_URL_PREFIX.concat(coursePaper.getPaperId());
+        //试卷预览和答案预览地址
+        String paperHtmlUrl = QUESTION_URL_PREFIX.concat("/api/ecs_ques/paper/pdf/").concat(coursePaper.getPaperId());
+        String answerHtmlUrl = QUESTION_URL_PREFIX.concat("/api/ecs_ques/paper/pdf/").concat(coursePaper.getPaperId());
 
         CoursePaper oldCoursePaper = coursePaperRepository.findByExamIdAndPaperId(coursePaper.getExamId(), coursePaper.getPaperId());
         if (oldCoursePaper != null) {
             //存在则修改
             oldCoursePaper.setPaperName(coursePaper.getPaperName());
-            oldCoursePaper.setPaperWordUrl(coursePaper.getPaperWordUrl());
-            oldCoursePaper.setAnswerWordUrl(coursePaper.getAnswerWordUrl());
             oldCoursePaper.setPaperHtmlUrl(paperHtmlUrl);
+            oldCoursePaper.setAnswerHtmlUrl(answerHtmlUrl);
             oldCoursePaper.setPaperPdfUrl(coursePaper.getPaperPdfUrl());//todo
+            oldCoursePaper.setAnswerPdfUrl(coursePaper.getAnswerPdfUrl());//todo
             oldCoursePaper.setPaperP(coursePaper.getPaperP());//todo
             coursePaperRepository.save(oldCoursePaper);
 
@@ -315,11 +315,11 @@ public class CoursePaperServiceImpl implements CoursePaperService {
             ExportFileInfo info = new ExportFileInfo();
 
             if (needPaper) {
-                info.setPaperWord(new Pair<>(title + PAPER_DOC_NAME, paper.getPaperWordUrl()));
+                info.setPaperPdf(new Pair<>(title + PAPER_PDF_NAME, paper.getPaperPdfUrl()));
             }
 
             if (needAnswer) {
-                info.setAnswerWord(new Pair<>(title + ANSWER_DOC_NAME, paper.getAnswerWordUrl()));
+                info.setAnswerPdf(new Pair<>(title + ANSWER_PDF_NAME, paper.getAnswerPdfUrl()));
             }
 
             if (needStruct) {
@@ -356,16 +356,18 @@ public class CoursePaperServiceImpl implements CoursePaperService {
     }
 
     private void doPaperAndAnswerFiles(List<ExportFileInfo> exportFiles, final String targetDir) {
+        if (exportFiles.isEmpty()) {
+            return;
+        }
+
         //试卷或答案存放目录
-        final String paperDir = targetDir + "/" + PAPER_DIR;
-        final String answerDir = targetDir + "/" + ANSWER_DIR;
-        FileUtils.makeDirs(paperDir);
-        FileUtils.makeDirs(answerDir);
+        final String tempDir = targetDir + "/paper";
+        FileUtils.makeDirs(tempDir);
 
         //下载试卷或答案文件
         for (ExportFileInfo info : exportFiles) {
-            this.loadFile(paperDir, info.getPaperWord());
-            this.loadFile(answerDir, info.getAnswerWord());
+            this.loadFile(tempDir, info.getPaperPdf());
+            this.loadFile(tempDir, info.getAnswerPdf());
         }
     }
 

+ 2 - 2
examcloud-core-print-starter/src/main/resources/application-dev.properties

@@ -21,5 +21,5 @@ upyun.bucket=exam-cloud-test
 upyun.bucketUrl=https://v0.api.upyun.com/exam-cloud-test
 upyun.fileUrl=https://ecs-test-static.qmth.com.cn
 upyun.uploadUrl=/ecs-print/test/
-# question prefix config
-paper.html.url.prefix=http://192.168.10.39:8008/api/ecs_ques/paper/pdf/
+# question url prefix config
+question.url.prefix=http://192.168.10.39:8008

+ 2 - 2
examcloud-core-print-starter/src/main/resources/application-prod.properties

@@ -21,5 +21,5 @@ upyun.bucket=exam-cloud
 upyun.bucketUrl=https://v0.api.upyun.com/exam-cloud
 upyun.fileUrl=https://ecs-static.qmth.com.cn
 upyun.uploadUrl=/ecs-print/prod/
-# question prefix config
-paper.html.url.prefix=http://ecs.qmth.com.cn:8008/api/ecs_ques/paper/pdf/
+# question url prefix config
+question.url.prefix=http://ecs.qmth.com.cn:8008

+ 2 - 2
examcloud-core-print-starter/src/main/resources/application-test.properties

@@ -21,5 +21,5 @@ upyun.bucket=exam-cloud-test
 upyun.bucketUrl=https://v0.api.upyun.com/exam-cloud-test
 upyun.fileUrl=https://ecs-test-static.qmth.com.cn
 upyun.uploadUrl=/ecs-print/test/
-# question prefix config
-paper.html.url.prefix=http://ecs-dev.qmth.com.cn:8008/api/ecs_ques/paper/pdf/
+# question url prefix config
+question.url.prefix=http://ecs-dev.qmth.com.cn:8008

+ 2 - 2
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/CoursePaperServiceTest.java

@@ -52,10 +52,10 @@ public class CoursePaperServiceTest extends BaseTest {
         coursePaper.setPaperId("xyz");
         coursePaper.setPaperName("测试试卷");
         coursePaper.setPaperP(5);
-        coursePaper.setPaperWordUrl("https://ecs-test-static.qmth.com.cn/ecs-print/test/demo.docx");
-        coursePaper.setAnswerWordUrl("https://ecs-test-static.qmth.com.cn/ecs-print/test/demo.docx");
         coursePaper.setPaperHtmlUrl("https://ecs-test-static.qmth.com.cn/ecs-print/test/demo.pdf");
         coursePaper.setPaperPdfUrl("https://ecs-test-static.qmth.com.cn/ecs-print/test/demo.pdf");
+        coursePaper.setAnswerHtmlUrl("https://ecs-test-static.qmth.com.cn/ecs-print/test/demo.pdf");
+        coursePaper.setAnswerPdfUrl("https://ecs-test-static.qmth.com.cn/ecs-print/test/demo.pdf");
         coursePaperService.syncCoursePaper(coursePaper);
     }