deason il y a 5 ans
Parent
commit
e20ca74295

+ 23 - 11
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/PaperController.java

@@ -597,20 +597,26 @@ public class PaperController extends ControllerSupport {
 
         ExportServiceManage manager = exportServiceManageRepo.findByOrgId(paper.getOrgId());
         if (manager == null) {
-            manager = exportServiceManageRepo.findByOrgName("山东大学");
+            throw new StatusException("500", "当前学校尚未配置试卷模板!");
         }
-        ExportPaperAbstractService exportPaperService = SpringContextUtils.getBean(ExportPaperAbstractService.class, manager.getExportServiceName());
 
+        ExportPaperAbstractService exportPaperService = SpringContextUtils.getBean(ExportPaperAbstractService.class, manager.getExportServiceName());
         PaperExp previewPaper = exportPaperService.previewPaperForPDF(paper);
+
         model.addAttribute("htmlList", PreviewPaperHandler.convertPaperHtml(previewPaper));
+        model.addAttribute("orgName", manager.getOrgName());
         model.addAttribute("examName", examName);
         model.addAttribute("courseNo", previewPaper.getCourseNo());
         model.addAttribute("courseName", previewPaper.getCourseName());
         model.addAttribute("courseLevel", previewPaper.getCourseLevel());
-        model.addAttribute("orgName", manager.getOrgName());
 
-        //return manager.getExportServiceName() + "_paper";
-        return "sddxExportPaperService_paper";
+        //目前只“山东大学”和“陕师大”配了试卷模板
+        if ("sddxExportPaperService".equals(manager.getExportServiceName())
+                || "sxsfExportPaperService".equals(manager.getExportServiceName())) {
+            return String.format("%s_paper", manager.getExportServiceName());
+        } else {
+            return "default_paper";
+        }
     }
 
     @Naked
@@ -624,20 +630,26 @@ public class PaperController extends ControllerSupport {
 
         ExportServiceManage manager = exportServiceManageRepo.findByOrgId(paper.getOrgId());
         if (manager == null) {
-            manager = exportServiceManageRepo.findByOrgName("山东大学");
+            throw new StatusException("500", "当前学校尚未配置试卷模板!");
         }
-        ExportPaperAbstractService exportPaperService = SpringContextUtils.getBean(ExportPaperAbstractService.class, manager.getExportServiceName());
 
+        ExportPaperAbstractService exportPaperService = SpringContextUtils.getBean(ExportPaperAbstractService.class, manager.getExportServiceName());
         PaperExp previewPaper = exportPaperService.previewPaperForPDF(paper);
+
         model.addAttribute("htmlList", PreviewPaperHandler.convertPaperAnswerHtml(previewPaper));
+        model.addAttribute("orgName", manager.getOrgName());
         model.addAttribute("examName", examName);
-        model.addAttribute("courseName", previewPaper.getCourseName());
         model.addAttribute("courseNo", previewPaper.getCourseNo());
+        model.addAttribute("courseName", previewPaper.getCourseName());
         model.addAttribute("courseLevel", previewPaper.getCourseLevel());
-        model.addAttribute("orgName", manager.getOrgName());
 
-        //return manager.getExportServiceName() + "_answer";
-        return "sddxExportPaperService_answer";
+        //目前只“山东大学”和“陕师大”配了试卷模板
+        if ("sddxExportPaperService".equals(manager.getExportServiceName())
+                || "sxsfExportPaperService".equals(manager.getExportServiceName())) {
+            return String.format("%s_answer", manager.getExportServiceName());
+        } else {
+            return "default_answer";
+        }
     }
 
     @ApiOperation(value = "传送到印刷平台", notes = "传送到印刷平台")