deason 6 gadi atpakaļ
vecāks
revīzija
443ef51b4a

+ 4 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/QuestionStructureServiceImpl.java

@@ -48,6 +48,10 @@ public class QuestionStructureServiceImpl implements ExamQuestionStructureServic
 
         //从题库端获取试卷的试题结构信息
         ExamQuestionStructureInfo info = statisticService.findStructureByPaperId(examId, paperId);
+        if (info == null) {
+            log.warn("试卷试题结构不存在! paperId is " + paperId);
+            return;
+        }
 
         //先清理旧数据
         objectiveQuestionStructureRepository.deleteByExamIdAndPaperId(examId, paperId);

+ 4 - 0
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/BaseTest.java

@@ -21,6 +21,10 @@ import org.springframework.test.context.junit4.SpringRunner;
 @SpringBootTest(classes = PrintApplication.class)
 public class BaseTest {
     protected JsonMapper jsonMapper = new JsonMapper();
+    protected final Long orgId = 0L;
+    protected final Long examId = 71L;
+    protected final Long courseId = 7L;
+    protected final String paperType = "X";
 
     //@Test
     public void init() throws Exception {

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

@@ -12,7 +12,6 @@ import cn.com.qmth.examcloud.core.print.service.CoursePaperService;
 import cn.com.qmth.examcloud.core.print.service.StatisticService;
 import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.ExportAllReq;
 import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.ExportBatchReq;
-import cn.com.qmth.examcloud.core.print.service.bean.examquestionstructure.ExamQuestionStructureInfo;
 import com.google.common.collect.Lists;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,41 +30,38 @@ public class CoursePaperServiceTest extends BaseTest {
 
     @Test
     public void test() throws Exception {
-        coursePaperService.syncCourseNameByCourseId(18L, "测试课程");
+        coursePaperService.syncCourseNameByCourseId(courseId, "测试课程");
     }
 
     @Test
     public void allotCoursePaperTest() throws Exception {
         Long courseStatisticId = 1L;
         Long coursePaperId = 1L;
-        //coursePaperService.allotCoursePaper(courseStatisticId, coursePaperId);
-
-        Long orgId = 27L;
-        Long examId = 21L;
-        coursePaperService.allotAllCoursePaper(orgId, examId);
+        coursePaperService.allotCoursePaper(courseStatisticId, coursePaperId);
+        //coursePaperService.allotAllCoursePaper(orgId, examId);
     }
 
     @Test
     public void syncCoursePaperTest() throws Exception {
         CoursePaper coursePaper = new CoursePaper();
-        coursePaper.setOrgId(27L);
-        coursePaper.setExamId(21L);
-        coursePaper.setCourseId(18L);
+        coursePaper.setOrgId(orgId);
+        coursePaper.setExamId(examId);
+        coursePaper.setCourseId(courseId);
         coursePaper.setCourseCode("123456");
         coursePaper.setCourseName("测试课程");
-        coursePaper.setPaperId("e965c24e-68a7-4f4d-ac1f-00ca0c904b10");
+        coursePaper.setPaperId("5bbc422def8fce44c27cfecf");
         coursePaper.setPaperName("测试试卷");
         coursePaperService.syncCoursePaper(coursePaper);
 
-        ExamQuestionStructureInfo info = statisticService.findStructureByPaperId(coursePaper.getExamId(), coursePaper.getPaperId());
-        System.out.println(jsonMapper.toJson(info));
+//        ExamQuestionStructureInfo info = statisticService.findStructureByPaperId(coursePaper.getExamId(), coursePaper.getPaperId());
+//        System.out.println(jsonMapper.toJson(info));
     }
 
     @Test
     public void exportAllCoursePaperTest() throws Exception {
         ExportAllReq req = new ExportAllReq();
-        req.setOrgId(27L);
-        req.setExamId(21L);
+        req.setOrgId(orgId);
+        req.setExamId(examId);
         req.setNeedPaper(true);
         req.setNeedAnswer(true);
         req.setNeedStruct(true);
@@ -78,7 +74,7 @@ public class CoursePaperServiceTest extends BaseTest {
     @Test
     public void exportBatchCoursePaperTest() throws Exception {
         ExportBatchReq req = new ExportBatchReq();
-        req.setIds(Lists.newArrayList(27L, 28L, 29L));
+        req.setIds(Lists.newArrayList(1L, 2L, 3L));
         req.setNeedPaper(true);
         req.setNeedAnswer(true);
         req.setNeedStruct(true);

+ 9 - 9
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/CourseStatisticServiceTest.java

@@ -29,9 +29,9 @@ public class CourseStatisticServiceTest extends BaseTest {
     @Test
     public void getCourseStatisticListTest() throws Exception {
         CourseStatisticQuery query = new CourseStatisticQuery();
-        query.setOrgId(27L);
-        query.setExamId(21L);
-        query.setCourseId(18L);
+        query.setOrgId(orgId);
+        query.setExamId(examId);
+        query.setCourseId(courseId);
         query.setPaperStatus(0);
         //query.setPaperName("测试试卷");
         Page<CourseStatisticInfo> page = courseStatisticService.getCourseStatisticList(query);
@@ -41,16 +41,16 @@ public class CourseStatisticServiceTest extends BaseTest {
     @Test
     public void initCourseStatisticTest() throws Exception {
         CourseStatisticRefreshReq req = new CourseStatisticRefreshReq();
-        req.setOrgId(27L);
-        req.setExamId(21L);
+        req.setOrgId(orgId);
+        req.setExamId(examId);
+
         List<CourseStatisticRefreshReq.Course> courses = new ArrayList<>();
-        courses.add(new CourseStatisticRefreshReq.Course(18L, "X"));
-        courses.add(new CourseStatisticRefreshReq.Course(19L, "X"));
+        courses.add(new CourseStatisticRefreshReq.Course(courseId, paperType));
         req.setCourses(courses);
-        courseStatisticService.refreshCourseStatistic(req);
 
+        courseStatisticService.refreshCourseStatistic(req);
         //courseStatisticService.initAllCourseStatistic();
-        //courseStatisticService.syncCourseNameByCourseId(19L, "测试课程");
+        //courseStatisticService.syncCourseNameByCourseId(courseId, "测试课程");
     }
 
 }

+ 9 - 9
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/PrintingProjectServiceTest.java

@@ -38,8 +38,8 @@ public class PrintingProjectServiceTest extends BaseTest {
     @Test
     public void getPrintingProjectListTest() throws Exception {
         PrintingProjectQuery query = new PrintingProjectQuery();
-        query.setOrgId(1L);
-        query.setExamId(1L);
+        query.setOrgId(orgId);
+        query.setExamId(examId);
         query.setPmId(1L);
         query.setSupplierId(1L);
         Page<PrintingProjectInfo> page = printingProjectService.getPrintingProjectList(query);
@@ -49,8 +49,8 @@ public class PrintingProjectServiceTest extends BaseTest {
     @Test
     public void updatePrintingProjectTest() throws Exception {
         PrintingProjectInfo info = new PrintingProjectInfo();
-        info.setId(1L);
-        info.setPmId(1L);
+        info.setId(orgId);
+        info.setPmId(examId);
         info.setPmName("雷布斯");
         info.setSupplierId(1L);
         info.setSupplierName("小米公司");
@@ -76,10 +76,10 @@ public class PrintingProjectServiceTest extends BaseTest {
 
     @Test
     public void syncPrintingProjectTest() throws Exception {
-        ExamInfo examInfo = new ExamInfo(1L, "武汉大学", 1L, "计算机考试");
+        ExamInfo examInfo = new ExamInfo(orgId, "武汉大学", examId, "计算机考试");
         printingProjectService.syncPrintingProject(examInfo);
-        printingProjectService.syncOrgNameByOrgId(1L, "武汉大学1");
-        printingProjectService.syncExamNameByExamId(1L, "计算机考试1");
+        printingProjectService.syncOrgNameByOrgId(orgId, "武汉大学1");
+        printingProjectService.syncExamNameByExamId(examId, "计算机考试1");
         printingProjectService.syncPmNameByPmId(1L, "雷布斯1");
         printingProjectService.syncSupplierNameBySupplierId(1L, "小米公司1");
     }
@@ -91,7 +91,7 @@ public class PrintingProjectServiceTest extends BaseTest {
         Specification<PrintingProject> spec1 = SpecUtils.buildSearchers(PrintingProject.class, searchBuilder1.build());
 
         //查询条件2
-        SearchBuilder searchBuilder2 = new SearchBuilder().eq("orgId", 1L).eq("examId", 1L);
+        SearchBuilder searchBuilder2 = new SearchBuilder().eq("orgId", orgId).eq("examId", examId);
         Specification<PrintingProject> spec2 = SpecUtils.buildSearchers(PrintingProject.class, searchBuilder2.build(), true);
 
         //查询条件3
@@ -101,7 +101,7 @@ public class PrintingProjectServiceTest extends BaseTest {
         //合并查询条件
 //        Specification<PrintingProject> spec = SpecUtils.orMerge(spec1, spec2, spec3);
 //        Specification<PrintingProject> spec = SpecUtils.andMerge(spec1, spec2, spec3);
-        Specification<PrintingProject> spec = SearchBuilder.EQ("orgId", 1L);
+        Specification<PrintingProject> spec = SearchBuilder.EQ("orgId", orgId);
 
         OrderBuilder orderBuilder = new OrderBuilder().desc("id");
         List<PrintingProject> list = printingProjectRepository.findAll(spec, orderBuilder.build());

+ 0 - 4
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/ProjectStatisticServiceTest.java

@@ -22,16 +22,12 @@ public class ProjectStatisticServiceTest extends BaseTest {
 
     @Test
     public void getPrintingProjectStatisticTest() throws Exception {
-        Long orgId = 27L;
-        Long examId = 70L;
         PrintingProjectStatisticInfo info = printingProjectStatisticService.getPrintingProjectStatistic(orgId, examId);
         System.out.println(jsonMapper.toJson(info));
     }
 
     @Test
     public void initPrintingProjectStatisticTest() throws Exception {
-        Long orgId = 27L;
-        Long examId = 70L;
         printingProjectStatisticService.refreshPrintingProjectStatistic(orgId, examId);
         //printingProjectStatisticService.initAllPrintingProjectStatistic();
     }