deason 6 жил өмнө
parent
commit
985ffee558

+ 2 - 2
examcloud-core-questions-starter/src/main/java/cn/com/qmth/examcloud/core/questions/starter/mongo/NativeMongoConfig.java

@@ -25,13 +25,13 @@ public class NativeMongoConfig {
 
     @Bean
     @Qualifier("mongoDatabase")
-    MongoDatabase getMongoDatabase(){
+    MongoDatabase getMongoDatabase() {
         return mongoClient.getDatabase(DB_NAME);
     }
 
     @Bean
     @Qualifier("pduCollection")
-    MongoCollection<Document> getMongoPduCollection(){
+    MongoCollection<Document> getMongoPduCollection() {
         MongoDatabase database = getMongoDatabase();
         return database.getCollection(PDU_COLLECTION_NAME);
     }

+ 4 - 4
examcloud-core-questions-starter/src/main/java/cn/com/qmth/examcloud/core/questions/starter/oracle/NativeOracleConfig.java

@@ -11,10 +11,10 @@ import org.springframework.context.annotation.Primary;
 import org.springframework.jdbc.core.JdbcTemplate;
 
 *//**
- * @author 		weiwenhai
- * @date		2018.7.30
- * @company		qmth
- * @describle	数据库连接池
+ * @author weiwenhai
+ * @date 2018.7.30
+ * @company qmth
+ * @describle 数据库连接池
  *//*
 @Configuration("nativeOracleConfig")
 public class NativeOracleConfig {

+ 56 - 56
examcloud-core-questions-starter/src/test/java/cn/com/qmth/examcloud/core/questions/starter/ApplicationTest.java

@@ -83,14 +83,14 @@ public class ApplicationTest {
     @Test
     public void testGridFs() throws FileNotFoundException {
         String fileName = "testXml";
-        String filePath = "/Users/songyue/Desktop/"+fileName+".xml";
+        String filePath = "/Users/songyue/Desktop/" + fileName + ".xml";
         FileInputStream fileInputStream = new FileInputStream(new File(filePath));
 //        gridFSUtil.save(fileInputStream,fileName);
 //        gridFSUtil.getByFileName(fileName);
     }
 
     @Test
-    public void testQuestion(){
+    public void testQuestion() {
         Question question = new Question();
         question.setQuesBody("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /><style>.wordTd_disabled{border:solid windowtext 1pt;padding:0cm 5.4pt 0cm 5.4pt;} p{white-space:sWrap;word-wrap:break-word;} span{white-space:sWrap;word-wrap:break-word;}</style></head><body><p style=\"text-align:both;\"><span style=\"color:#000000;font-size:10pt;font-family:Times New Roman;\"><span style=\"font-style:normal;\"><span style=\"font-weight:normal;\">\n" +
                 "材料在外力作用下发生形变(套题题干)。\n" +
@@ -100,11 +100,11 @@ public class ApplicationTest {
         questionType.setQuesType(QuesStructType.NESTED_ANSWER_QUESTION);
         question.setQuestionType(QuesStructType.NESTED_ANSWER_QUESTION);
         List<Question> subquestionList = new ArrayList<Question>();
-        
-        for(int i=0;i < 10;i++){
+
+        for (int i = 0; i < 10; i++) {
             Question subquestion = new Question();
             subquestion.setQuesBody("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /><style>.wordTd_disabled{border:solid windowtext 1pt;padding:0cm 5.4pt 0cm 5.4pt;} p{white-space:sWrap;word-wrap:break-word;} span{white-space:sWrap;word-wrap:break-word;}</style></head><body><p style=\"text-align:both;\"><span style=\"color:#000000;font-size:10pt;font-family:Times New Roman;\"><span style=\"font-style:normal;\"><span style=\"font-weight:normal;\">\n" +
-                    "材料在外力作用下发生形变,当外力撤消后能恢复原来大小和形状的性质称为(小题题干"+i+")。\n" +
+                    "材料在外力作用下发生形变,当外力撤消后能恢复原来大小和形状的性质称为(小题题干" + i + ")。\n" +
                     "</span></span></span></p></body></html>");
             subquestion.setQuesAnswer("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /><style>.wordTd_disabled{border:solid windowtext 1pt;padding:0cm 5.4pt 0cm 5.4pt;} p{white-space:sWrap;word-wrap:break-word;} span{white-space:sWrap;word-wrap:break-word;}</style></head><body><p style=\"text-align:both;\"><span style=\"color:#000000;font-size:10pt;font-family:Times New Roman;\"><span style=\"font-style:normal;\"><span style=\"font-weight:normal;\">\n" +
                     "B\n" +
@@ -127,18 +127,18 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testPaper(){
+    public void testPaper() {
         paperRepo.deleteAll();
         paperDetailRepo.deleteAll();
         paperDetailUnitRepo.deleteAll();
 
-        Paper paper =  new Paper();
+        Paper paper = new Paper();
         paper.setName("测试试卷");
         paper.setPaperDetailCount(1);
         paper.setTitle("测试试卷");
         PaperDetail paperDetail = new PaperDetail();
         paperDetail.setName("选择题");
-        paperDetail.setScore((double)20);
+        paperDetail.setScore((double) 20);
         paperDetail.setNumber(1);
         paperDetail.setPaper(paper);
         QuestionType questionType1 = new QuestionType();
@@ -152,13 +152,13 @@ public class ApplicationTest {
 
         List<Question> questionList = quesRepo.findAll();
         int i = 0;
-        for(Question ques:questionList){
+        for (Question ques : questionList) {
             PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
             paperDetailUnit.setQuestionType(ques.getQuestionType());
             paperDetailUnit.setNumber(i);
             paperDetailUnit.setPaper(paper);
             paperDetailUnit.setPaperDetail(paperDetail);
-            paperDetailUnit.setScore((double)10);
+            paperDetailUnit.setScore((double) 10);
             paperDetailUnit.setQuestion(ques);
             i++;
             paperDetailUnitRepo.save(paperDetailUnit);
@@ -166,11 +166,11 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testExtract(){
+    public void testExtract() {
         extractConfigRepo.deleteAll();
         examPaperRepo.deleteAll();
         ExamPaper examPaper = new ExamPaper();
-        examPaper.setExamId((long)1);
+        examPaper.setExamId((long) 1);
         examPaper.setCourseCode("1");
         examPaper.setExtractCount(1);
         examPaper.setGroupCode("1");
@@ -178,14 +178,14 @@ public class ApplicationTest {
         examPaperRepo.save(examPaper);
 
         ExtractConfig extractConfig = new ExtractConfig();
-        extractConfig.setExamId((long)1);
+        extractConfig.setExamId((long) 1);
         extractConfig.setCourseCode("1");
         extractConfig.setPolicy(ExtractPolicy.RANDOM_POLICY);
         extractConfigRepo.save(extractConfig);
     }
 
     @Test
-    public void testImport(){
+    public void testImport() {
         paperRepo.deleteAll();
         paperDetailRepo.deleteAll();
         quesRepo.deleteAll();
@@ -221,9 +221,9 @@ public class ApplicationTest {
 //        System.out.println("程序运行时间:" + (endTime - startTime)/1000 + "s");    //输出程序运行时间
 //    }
 
-    @SuppressWarnings({ "unused", "resource" })
-	@Test
-    public void testImport1(){
+    @SuppressWarnings({"unused", "resource"})
+    @Test
+    public void testImport1() {
         String inputFilePath = "/Users/songyue/docxImport/ceshi2.docx";
         String outFilePath = "/Users/songyue/docxImport/ceshi11111.docx";
         try {
@@ -232,33 +232,33 @@ public class ApplicationTest {
             System.out.println(inputFilePath);
             WordprocessingMLPackage wordMLPackage = Docx4J.load(inputFile);
             DocxProcessUtil.initPkgImage(wordMLPackage);
-            Docx4J.save(wordMLPackage,new FileOutputStream(outFilePath));
+            Docx4J.save(wordMLPackage, new FileOutputStream(outFilePath));
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
     @Test
-    public void testCourse(){
-        Map<String,String> params = new HashMap<String,String>();
-        params.put("courseNo","03013750");
-        params.put("courseName","专升本《合同法》");
+    public void testCourse() {
+        Map<String, String> params = new HashMap<String, String>();
+        params.put("courseNo", "03013750");
+        params.put("courseName", "专升本《合同法》");
 //        List<Paper> papers = paperRepo.findByParams(params);
-        Page<Paper> papers = paperRepo.findByPaperType(PaperType.IMPORT,new PageRequest(0,10));
+        Page<Paper> papers = paperRepo.findByPaperType(PaperType.IMPORT, new PageRequest(0, 10));
         System.out.println(papers.getTotalElements());
 //        System.out.println(gson.toJson(papers));
     }
 
     @Test
-    public void testCourse1(){
+    public void testCourse1() {
         List<Question> questions = quesRepo.findAll();
         List<Question> saveQues = new ArrayList<>();
-        for(Question question:questions){
+        for (Question question : questions) {
             //Course course = courseRepo.findFirstByCodeAndOrgId(question.getCourseNo(),question.getOrgId());
-        	Course course = courseService.getCourse(Long.valueOf(question.getOrgId()),question.getCourseNo());
-        	if(course != null){
+            Course course = courseService.getCourse(Long.valueOf(question.getOrgId()), question.getCourseNo());
+            if (course != null) {
                 question.setCourseLevel(course.getLevel());
-            }else{
+            } else {
                 question.setCourseLevel(CourseLevel.ALL.name());
             }
             saveQues.add(question);
@@ -267,40 +267,40 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testCourse2(){
+    public void testCourse2() {
         List<Question> questions = quesRepo.findAll();
         List<Question> saveQues = new ArrayList<>();
-        for(Question question:questions){
+        for (Question question : questions) {
             //Course course = courseRepo.findFirstByCodeAndOrgId(question.getCourseNo(),question.getOrgId());
-        	Course course = courseService.getCourse(Long.valueOf(question.getOrgId()),question.getCourseNo());
-        	question.setCourse(course);
+            Course course = courseService.getCourse(Long.valueOf(question.getOrgId()), question.getCourseNo());
+            question.setCourse(course);
             saveQues.add(question);
         }
         quesRepo.saveAll(saveQues);
     }
 
     @Test
-    public void testCourse3(){
+    public void testCourse3() {
         List<Paper> papers = paperRepo.findAll();
         List<Paper> savePaper = new ArrayList<>();
-        for(Paper paper:papers){
+        for (Paper paper : papers) {
             //Course course = courseRepo.findFirstByCodeAndOrgId(paper.getCourseNo(),paper.getOrgId());
-        	Course course = courseService.getCourse(Long.valueOf(paper.getOrgId()),paper.getCourseNo());
-        	paper.setCourse(course);
+            Course course = courseService.getCourse(Long.valueOf(paper.getOrgId()), paper.getCourseNo());
+            paper.setCourse(course);
             savePaper.add(paper);
         }
         paperRepo.saveAll(savePaper);
     }
 
     @Test
-    public void testCourse7(){
+    public void testCourse7() {
         List<Course> courses = new ArrayList<Course>();
-        for(Course course:courses){
-            if(course != null){
-                if(course.getEnable().equals("1")){
+        for (Course course : courses) {
+            if (course != null) {
+                if (course.getEnable().equals("1")) {
                     course.setEnable("true");
                 }
-                if(course.getEnable().equals("0")){
+                if (course.getEnable().equals("0")) {
                     course.setEnable("false");
                 }
             }
@@ -309,38 +309,38 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testCourse6(){
+    public void testCourse6() {
         List<ExtractConfig> configs = extractConfigRepo.findAll();
-        for(ExtractConfig config:configs){
+        for (ExtractConfig config : configs) {
             //Course course = courseRepo.findFirstByCodeAndOrgId(config.getCourseCode(),config.getOrgId());
-            Course course = courseService.getCourse(Long.valueOf(config.getOrgId()),config.getCourseCode());
+            Course course = courseService.getCourse(Long.valueOf(config.getOrgId()), config.getCourseCode());
             config.setCourse(course);
         }
         extractConfigRepo.saveAll(configs);
     }
 
     @Test
-    public void testCourse5(){
+    public void testCourse5() {
         List<Question> questions = quesRepo.findAll();
         List<Paper> papers = paperRepo.findAll();
-        for(Question question:questions){
+        for (Question question : questions) {
             Course course = question.getCourse();
-            if(course != null){
-                if(course.getEnable().equals("1")){
+            if (course != null) {
+                if (course.getEnable().equals("1")) {
                     course.setEnable("true");
                 }
-                if(course.getEnable().equals("0")){
+                if (course.getEnable().equals("0")) {
                     course.setEnable("false");
                 }
             }
         }
-        for(Paper paper:papers){
+        for (Paper paper : papers) {
             Course course = paper.getCourse();
-            if(course != null){
-                if(course.getEnable().equals("1")){
+            if (course != null) {
+                if (course.getEnable().equals("1")) {
                     course.setEnable("true");
                 }
-                if(course.getEnable().equals("0")){
+                if (course.getEnable().equals("0")) {
                     course.setEnable("false");
                 }
             }
@@ -350,10 +350,10 @@ public class ApplicationTest {
     }
 
     @SuppressWarnings("unused")
-	@Test
-    public void testCourse4(){
+    @Test
+    public void testCourse4() {
         //Course course = courseRepo.findFirstByCodeAndOrgId("010048","1");
-        Course course = courseService.getCourse(Long.valueOf("010048"),"1");
+        Course course = courseService.getCourse(Long.valueOf("010048"), "1");
     }
 
 }

+ 182 - 182
examcloud-core-questions-starter/src/test/java/cn/com/qmth/examcloud/core/questions/starter/DdCollegeUtilTest.java

@@ -22,10 +22,10 @@ import cn.com.qmth.examcloud.core.questions.service.temp.DdExcelService;
 import cn.com.qmth.examcloud.core.questions.service.temp.UpdatePaperStruct;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.7.19
- * @company		qmth
- * @describle	测试地大题库导入
+ * @author weiwenhai
+ * @date 2018.7.19
+ * @company qmth
+ * @describle 测试地大题库导入
  */
 @RunWith(SpringRunner.class)
 @SpringBootTest
@@ -68,18 +68,18 @@ public class DdCollegeUtilTest {
 		System.out.println(count);
 		//int count = ddCollegeUtilService.testCount();
 	}*/
-	
-	 @Autowired
-	 private MongoTemplate mongoTemplate;
-	 
-	 @Autowired
-	 PaperDetailUnitRepo paperDetailUnitRepo;
-	 
-	 @Autowired
-	 DdExcelService ddExcelService;
-	 
-	 @Autowired
-	 QuesRepo quesRepo;
+
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+    @Autowired
+    PaperDetailUnitRepo paperDetailUnitRepo;
+
+    @Autowired
+    DdExcelService ddExcelService;
+
+    @Autowired
+    QuesRepo quesRepo;
 
 	/* @Test
 	 public void updatePaperType(){
@@ -98,88 +98,88 @@ public class DdCollegeUtilTest {
 			 System.out.println("更新完..."+ (i+1)*1000 + "记录");
 		 }
 	 }*/
-	 
-	 @Test
-	 public void excelTest(){
-		 try {
-			//ddExcelService.exporExcel("1627");
-			 ddExcelService.exportPaperExcel("1387");
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	 }
-	 
-	 @Test
-	 public void saveQuestionTest(){
-		 Map<String, String> map = new HashMap<String, String>();
-		 map.put("a", "a");
-		 Question question = new Question();
-		 question.setOrgId("wwh");
-		 question.setQuesBody("wwh");
-		 question.setQuesAnswer("wwh");
-		 question.setIsolated(true);
-		 question.setProperties(map);
-		 
-		 Map<String, String> map2 = new HashMap<String, String>();
-		 map2.put("a", "a");
-		 map2.put("b", "b");
-		 Question question2 = new Question();
-		 question2.setOrgId("wwh");
-		 question2.setQuesBody("wwh");
-		 question2.setQuesAnswer("wwh");
-		 question2.setIsolated(true);
-		 question2.setProperties(map2);
-		 
-		 Map<String, String> map3 = new HashMap<String, String>();
-		 map3.put("a", "a");
-		 map3.put("b", "b");
-		 map3.put("c", "c");
-		 Question question3 = new Question();
-		 question3.setOrgId("wwh");
-		 question3.setQuesBody("wwh");
-		 question3.setQuesAnswer("wwh");
-		 question3.setIsolated(true);
-		 question3.setProperties(map3);
-		 
-		 Map<String, String> map4 = new HashMap<String, String>();
-		 map4.put("d", "d");
-		 Question question4 = new Question();
-		 question4.setOrgId("wwh");
-		 question4.setQuesBody("wwh");
-		 question4.setQuesAnswer("wwh");
-		 question4.setIsolated(true);
-		 question4.setProperties(map4);
-		 
-		 List<Question> list = new ArrayList<Question>();
-		 list.add(question);
-		 list.add(question2);
-		 list.add(question3);
-		 list.add(question4);
-		 
-		 quesRepo.saveAll(list);
-		 System.out.println("插入完毕...");
-	 }
-
-	 @Test
-	 public void queryQuestionTest(){
-		 Map<String, String> map = new HashMap<String, String>();
-		 map.put("a", "x,j");
-		 //map.put("b", "b");
-		 Query query = new Query();
-		 for(Map.Entry<String, String> entry:map.entrySet()){
-			 String la = entry.getValue();
-			 la = la.replaceAll(",", "*");
-			 Pattern pattern=Pattern.compile(la, Pattern.CASE_INSENSITIVE);
-			 String key = "properties." + entry.getKey();
-			 query.addCriteria(Criteria.where(key).regex(pattern));
-		 }
-		 long count = this.mongoTemplate.count(query, Question.class);
-		 List<Question> questionList = this.mongoTemplate.find(query, Question.class);
-		 System.out.println("第一次查询:");
-		 System.out.println("count:"+ count);
-		 for(Question question:questionList){
-			 System.out.println("question:"+question.getProperties());
-		 }
+
+    @Test
+    public void excelTest() {
+        try {
+            //ddExcelService.exporExcel("1627");
+            ddExcelService.exportPaperExcel("1387");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Test
+    public void saveQuestionTest() {
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("a", "a");
+        Question question = new Question();
+        question.setOrgId("wwh");
+        question.setQuesBody("wwh");
+        question.setQuesAnswer("wwh");
+        question.setIsolated(true);
+        question.setProperties(map);
+
+        Map<String, String> map2 = new HashMap<String, String>();
+        map2.put("a", "a");
+        map2.put("b", "b");
+        Question question2 = new Question();
+        question2.setOrgId("wwh");
+        question2.setQuesBody("wwh");
+        question2.setQuesAnswer("wwh");
+        question2.setIsolated(true);
+        question2.setProperties(map2);
+
+        Map<String, String> map3 = new HashMap<String, String>();
+        map3.put("a", "a");
+        map3.put("b", "b");
+        map3.put("c", "c");
+        Question question3 = new Question();
+        question3.setOrgId("wwh");
+        question3.setQuesBody("wwh");
+        question3.setQuesAnswer("wwh");
+        question3.setIsolated(true);
+        question3.setProperties(map3);
+
+        Map<String, String> map4 = new HashMap<String, String>();
+        map4.put("d", "d");
+        Question question4 = new Question();
+        question4.setOrgId("wwh");
+        question4.setQuesBody("wwh");
+        question4.setQuesAnswer("wwh");
+        question4.setIsolated(true);
+        question4.setProperties(map4);
+
+        List<Question> list = new ArrayList<Question>();
+        list.add(question);
+        list.add(question2);
+        list.add(question3);
+        list.add(question4);
+
+        quesRepo.saveAll(list);
+        System.out.println("插入完毕...");
+    }
+
+    @Test
+    public void queryQuestionTest() {
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("a", "x,j");
+        //map.put("b", "b");
+        Query query = new Query();
+        for (Map.Entry<String, String> entry : map.entrySet()) {
+            String la = entry.getValue();
+            la = la.replaceAll(",", "*");
+            Pattern pattern = Pattern.compile(la, Pattern.CASE_INSENSITIVE);
+            String key = "properties." + entry.getKey();
+            query.addCriteria(Criteria.where(key).regex(pattern));
+        }
+        long count = this.mongoTemplate.count(query, Question.class);
+        List<Question> questionList = this.mongoTemplate.find(query, Question.class);
+        System.out.println("第一次查询:");
+        System.out.println("count:" + count);
+        for (Question question : questionList) {
+            System.out.println("question:" + question.getProperties());
+        }
 		 
 		 /*Map<String, String> map2 = new HashMap<String, String>();
 		 map2.put("d", "d");
@@ -244,90 +244,90 @@ public class DdCollegeUtilTest {
 		 for(Question question:questionList5){
 			 System.out.println("question:"+question.getProperties());
 		 }*/
-	 }
-	 
-	 @Autowired
-	 private UpdatePaperStruct updatePaperStruct;
-	 
-	 @Test
-	 public void updateP(){
-		 updatePaperStruct.updatePaperStruct("303"); //测试大学
-	 }
-	 
-	 @Test
-	 public void updatePaperStruct(){
-		 //updatePaperStruct.updatePaperStruct("0"); //启明泰和
-		 
-		 updatePaperStruct.updatePaperStruct("1"); //石油大学
-		 
-		 updatePaperStruct.updatePaperStruct("115"); //测试
-		 
-		 updatePaperStruct.updatePaperStruct("135"); //山东大学
-		 
-		 updatePaperStruct.updatePaperStruct("136"); //电子科技大学
-		 
-		 updatePaperStruct.updatePaperStruct("137"); //陕西师范大学
-		 
-		 updatePaperStruct.updatePaperStruct("302"); //天津大学
-		 
-		 updatePaperStruct.updatePaperStruct("371"); //西安交通大学
-		 
-		 updatePaperStruct.updatePaperStruct("372"); //武汉理工大学
-		 
-		 updatePaperStruct.updatePaperStruct("718"); //西南交通大学
-		 
-		 updatePaperStruct.updatePaperStruct("1065"); //华中科技大学
-		 
-		 updatePaperStruct.updatePaperStruct("1226"); //河南优特
-		 
-		 updatePaperStruct.updatePaperStruct("1251"); //湖北职业技术学院
-		 
-		 updatePaperStruct.updatePaperStruct("1252"); //武汉软件工程职业学院
-		 
-		 updatePaperStruct.updatePaperStruct("1256"); //华南师范大学
-		 
-		 updatePaperStruct.updatePaperStruct("1347"); //华中师范大学
-		 
-		 updatePaperStruct.updatePaperStruct("1348"); //福建师范大学
-		 
-		 updatePaperStruct.updatePaperStruct("1350"); //优特教育
-		 
-		 updatePaperStruct.updatePaperStruct("1353"); //奥鹏教育
-		 
-		 updatePaperStruct.updatePaperStruct("1384"); //西南财经大学
-		 
-		 updatePaperStruct.updatePaperStruct("1385"); //北京师范大学
-		 
-		 updatePaperStruct.updatePaperStruct("1387"); //中国地质大学(北京)
-		 
-		 updatePaperStruct.updatePaperStruct("1388"); //北京开放大学
-		 
-		 updatePaperStruct.updatePaperStruct("1394"); //西安电子科技大学
-		 
-		 updatePaperStruct.updatePaperStruct("1407"); //重庆大学
-		 
-		 updatePaperStruct.updatePaperStruct("1408"); //中国医科大学(奥鹏)
-		 
-		 updatePaperStruct.updatePaperStruct("1562"); //北京交通大学(奥鹏)
-		 
-		 updatePaperStruct.updatePaperStruct("1627"); //中国地质大学(武汉)
-		 
-		 updatePaperStruct.updatePaperStruct("1680"); //南开大学(奥鹏)
-		 
-		 updatePaperStruct.updatePaperStruct("1681"); //东北师范大学(奥鹏)
-		 
-		 updatePaperStruct.updatePaperStruct("1734"); //北京航空航天大学(奥鹏)
-		 
-		 updatePaperStruct.updatePaperStruct("1745"); //中国石油大学(华东)
-		 
-		 updatePaperStruct.updatePaperStruct("1759"); //教务平台(全日制)
-		 
-		 updatePaperStruct.updatePaperStruct("1769"); //地质大学(武汉)入学
-		 
-		 updatePaperStruct.updatePaperStruct("1775"); //演示-ACC
-		 
-	 }
-	 
+    }
+
+    @Autowired
+    private UpdatePaperStruct updatePaperStruct;
+
+    @Test
+    public void updateP() {
+        updatePaperStruct.updatePaperStruct("303"); //测试大学
+    }
+
+    @Test
+    public void updatePaperStruct() {
+        //updatePaperStruct.updatePaperStruct("0"); //启明泰和
+
+        updatePaperStruct.updatePaperStruct("1"); //石油大学
+
+        updatePaperStruct.updatePaperStruct("115"); //测试
+
+        updatePaperStruct.updatePaperStruct("135"); //山东大学
+
+        updatePaperStruct.updatePaperStruct("136"); //电子科技大学
+
+        updatePaperStruct.updatePaperStruct("137"); //陕西师范大学
+
+        updatePaperStruct.updatePaperStruct("302"); //天津大学
+
+        updatePaperStruct.updatePaperStruct("371"); //西安交通大学
+
+        updatePaperStruct.updatePaperStruct("372"); //武汉理工大学
+
+        updatePaperStruct.updatePaperStruct("718"); //西南交通大学
+
+        updatePaperStruct.updatePaperStruct("1065"); //华中科技大学
+
+        updatePaperStruct.updatePaperStruct("1226"); //河南优特
+
+        updatePaperStruct.updatePaperStruct("1251"); //湖北职业技术学院
+
+        updatePaperStruct.updatePaperStruct("1252"); //武汉软件工程职业学院
+
+        updatePaperStruct.updatePaperStruct("1256"); //华南师范大学
+
+        updatePaperStruct.updatePaperStruct("1347"); //华中师范大学
+
+        updatePaperStruct.updatePaperStruct("1348"); //福建师范大学
+
+        updatePaperStruct.updatePaperStruct("1350"); //优特教育
+
+        updatePaperStruct.updatePaperStruct("1353"); //奥鹏教育
+
+        updatePaperStruct.updatePaperStruct("1384"); //西南财经大学
+
+        updatePaperStruct.updatePaperStruct("1385"); //北京师范大学
+
+        updatePaperStruct.updatePaperStruct("1387"); //中国地质大学(北京)
+
+        updatePaperStruct.updatePaperStruct("1388"); //北京开放大学
+
+        updatePaperStruct.updatePaperStruct("1394"); //西安电子科技大学
+
+        updatePaperStruct.updatePaperStruct("1407"); //重庆大学
+
+        updatePaperStruct.updatePaperStruct("1408"); //中国医科大学(奥鹏)
+
+        updatePaperStruct.updatePaperStruct("1562"); //北京交通大学(奥鹏)
+
+        updatePaperStruct.updatePaperStruct("1627"); //中国地质大学(武汉)
+
+        updatePaperStruct.updatePaperStruct("1680"); //南开大学(奥鹏)
+
+        updatePaperStruct.updatePaperStruct("1681"); //东北师范大学(奥鹏)
+
+        updatePaperStruct.updatePaperStruct("1734"); //北京航空航天大学(奥鹏)
+
+        updatePaperStruct.updatePaperStruct("1745"); //中国石油大学(华东)
+
+        updatePaperStruct.updatePaperStruct("1759"); //教务平台(全日制)
+
+        updatePaperStruct.updatePaperStruct("1769"); //地质大学(武汉)入学
+
+        updatePaperStruct.updatePaperStruct("1775"); //演示-ACC
+
+    }
+
 }
 
 

+ 203 - 200
examcloud-core-questions-starter/src/test/java/cn/com/qmth/examcloud/core/questions/starter/ExtractConfigServiceTest.java

@@ -36,115 +36,116 @@ import cn.com.qmth.examcloud.core.questions.base.enums.ExamFileType;
 import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
 
 /**
- * @author  	chenken
- * @date    	2017年4月18日 下午3:32:25
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年4月18日 下午3:32:25
+ * @company QMTH
  * @description PaperServiceTest.java
  */
 @RunWith(SpringRunner.class)
 @SpringBootTest
 public class ExtractConfigServiceTest {
-	
-	@Autowired
-	private PaperRepo paperRepo;
-	@Autowired
-	private ExtractConfigService extractConfigService;
-	@Autowired
-	private SxsfExportPaperService sxsfExportPaperService;
-	
-	@Autowired
-	private ExamFileService examFileService;
-	@Autowired
-	private ExportServiceManageRepo exportServiceManageRepo;
-	@Autowired
-	private SddxExportPaperService sddxExportPaperService;
-	@Autowired
+
+    @Autowired
+    private PaperRepo paperRepo;
+    @Autowired
+    private ExtractConfigService extractConfigService;
+    @Autowired
+    private SxsfExportPaperService sxsfExportPaperService;
+
+    @Autowired
+    private ExamFileService examFileService;
+    @Autowired
+    private ExportServiceManageRepo exportServiceManageRepo;
+    @Autowired
+    private SddxExportPaperService sddxExportPaperService;
+    @Autowired
     private MongoTemplate mongoTemplate;
-	
-	@SuppressWarnings("unused")
-	private MockHttpServletRequest request;
-	
+
+    @SuppressWarnings("unused")
+    private MockHttpServletRequest request;
+
     @SuppressWarnings("unused")
-	private MockHttpServletResponse response; 
-    
+    private MockHttpServletResponse response;
+
     @Test
-    public void downloadPaper() throws Exception{
-    	Query query = new Query();
-    	query.addCriteria(Criteria.where("orgId").is(135+""));
-    	query.addCriteria(Criteria.where("paperType").is(PaperType.GENERATE.name()));
-    	List<Paper> paperList = this.mongoTemplate.find(query, Paper.class);
-    	for(Paper paper:paperList){
-    		try {
-    			StringBuffer sb = new StringBuffer();
-    			List<String> paperIds = readFromFile();
-    			for(String paperId:paperIds){
-    				sb.append(paperId);
-    	        	sb.append("\r\n");
-    			}
-    			if(!paperIds.contains(paper.getId())){
-    				System.out.println("当前正在导出ID:"+paper.getId());
-    				sddxExportPaperService.downloadPaper(paper.getId(), "shandong","onLine");
-    				writeToFile(sb.toString()+"\r\n"+paper.getId());
-    			}
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-    	}
+    public void downloadPaper() throws Exception {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(135 + ""));
+        query.addCriteria(Criteria.where("paperType").is(PaperType.GENERATE.name()));
+        List<Paper> paperList = this.mongoTemplate.find(query, Paper.class);
+        for (Paper paper : paperList) {
+            try {
+                StringBuffer sb = new StringBuffer();
+                List<String> paperIds = readFromFile();
+                for (String paperId : paperIds) {
+                    sb.append(paperId);
+                    sb.append("\r\n");
+                }
+                if (!paperIds.contains(paper.getId())) {
+                    System.out.println("当前正在导出ID:" + paper.getId());
+                    sddxExportPaperService.downloadPaper(paper.getId(), "shandong", "onLine");
+                    writeToFile(sb.toString() + "\r\n" + paper.getId());
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
     }
-    
-    /** 
-     * DOC 从文件里读内容. 
-     *  
-     * @throws IOException 
-     */  
-    private static List<String> readFromFile() throws IOException {  
-    	BufferedReader bReader = new BufferedReader(new FileReader("E:\\paperIds.txt"));
-    	List<String> paperIds = new ArrayList<String>();
-    	String temp = "";
-        while((temp=bReader.readLine())!=null) {
-        	if(StringUtils.isNotBlank(temp)){
-        		paperIds.add(temp);
-        	}
+
+    /**
+     * DOC 从文件里读内容.
+     *
+     * @throws IOException
+     */
+    private static List<String> readFromFile() throws IOException {
+        BufferedReader bReader = new BufferedReader(new FileReader("E:\\paperIds.txt"));
+        List<String> paperIds = new ArrayList<String>();
+        String temp = "";
+        while ((temp = bReader.readLine()) != null) {
+            if (StringUtils.isNotBlank(temp)) {
+                paperIds.add(temp);
+            }
         }
         bReader.close();
         return paperIds;
     }
-    
-    /** 
-     * DOC 往文件里写入数据. 
-     *  
-     * @throws IOException 
-     */  
-    private static void writeToFile(String writerContent) throws IOException {  
+
+    /**
+     * DOC 往文件里写入数据.
+     *
+     * @throws IOException
+     */
+    private static void writeToFile(String writerContent) throws IOException {
         File file = new File("E:\\paperIds.txt");// 要写入的文本文件  
         if (!file.exists()) {// 如果文件不存在,则创建该文件  
-            file.createNewFile();  
-        }  
+            file.createNewFile();
+        }
         FileWriter writer = new FileWriter(file);// 获取该文件的输出流  
         writer.write(writerContent);// 写内容  
         writer.flush();// 清空缓冲区,立即将输出流里的内容写到文件里  
         writer.close();// 关闭输出流,施放资源  
     }
-    
+
     @Test
-	public void test1() throws Exception{
-    	ExamFile examFile = new ExamFile();
-    	examFile.setExamId(70+"");
-    	examFile.setOrgId(137+"");
-    	examFile.setExamFileType(ExamFileType.PAPER_STRUCTURE_SUBJECTIVE);
-    	List<ExamFile> examFiles = examFileService.findExamFileListByExamFile(examFile);
-    	for(ExamFile examFile2:examFiles){
-    		System.out.println(examFile2.getFilePath());
-    	}
+    public void test1() throws Exception {
+        ExamFile examFile = new ExamFile();
+        examFile.setExamId(70 + "");
+        examFile.setOrgId(137 + "");
+        examFile.setExamFileType(ExamFileType.PAPER_STRUCTURE_SUBJECTIVE);
+        List<ExamFile> examFiles = examFileService.findExamFileListByExamFile(examFile);
+        for (ExamFile examFile2 : examFiles) {
+            System.out.println(examFile2.getFilePath());
+        }
     }
-    
-    
-	/**
-	 * 测试保存调卷规则
-	 * @throws Exception 
-	 */
-	@Test
-	public void testSaveExtractConfig() throws Exception{
+
+
+    /**
+     * 测试保存调卷规则
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testSaveExtractConfig() throws Exception {
 		/*ExtractConfig extractConfig = new ExtractConfig();
 		extractConfig.setExamId(2L);
 		extractConfig.setExamName("测试考试0419");
@@ -158,118 +159,120 @@ public class ExtractConfigServiceTest {
 		List<ExamPaper> examPaperList = buildTraditionExamPaper();
 		extractConfig.setExamPaperList(examPaperList);
 		extractConfigService.saveExtractConfig(extractConfig,"机构名称");*/
-	}
-	
-	@SuppressWarnings("unused")
-	private List<ExamPaper> buildOnlineExamPaper(){
-		List<ExamPaper> examPaperList = new ArrayList<ExamPaper>();
-		/*******************A类型********************/
-		ExamPaper examPaper1 = new ExamPaper();
-		examPaper1.setExamId(1L);
-		examPaper1.setCourseCode("03013750");
-		examPaper1.setGroupCode("A");
-		examPaper1.setWeight(80);
-		Paper paper1 = new Paper();
-		paper1.setId("58f0a15258e31a0d7448d58c");
-		examPaper1.setPaper(paper1);
-		examPaperList.add(examPaper1);
-		ExamPaper examPaper2 = new ExamPaper();
-		examPaper2.setExamId(1L);
-		examPaper2.setCourseCode("03013750");
-		examPaper2.setGroupCode("A");
-		examPaper2.setWeight(20);
-		Paper paper2 = new Paper();
-		paper2.setId("58f42fcd58e31a025844bfff");
-		examPaper2.setPaper(paper2);
-		examPaperList.add(examPaper2);
-		/*******************B类型********************/
-		ExamPaper examPaper3 = new ExamPaper();
-		examPaper3.setExamId(1L);
-		examPaper3.setCourseCode("03013750");
-		examPaper3.setGroupCode("B");
-		examPaper3.setWeight(60);
-		Paper paper3 = new Paper();
-		paper3.setId("58f4300c58e31a025844c02f");
-		examPaper3.setPaper(paper3);
-		examPaperList.add(examPaper3);
-		ExamPaper examPaper4 = new ExamPaper();
-		examPaper4.setExamId(1L);
-		examPaper4.setCourseCode("03013750");
-		examPaper4.setGroupCode("B");
-		examPaper4.setWeight(40);
-		Paper paper4 = new Paper();
-		paper4.setId("e483c730-921e-4212-a67e-42235a0aec00");
-		examPaper4.setPaper(paper4);
-		examPaperList.add(examPaper4);
-		return examPaperList;
-	}
-	
-	@SuppressWarnings("unused")
-	private List<ExamPaper> buildTraditionExamPaper(){
-		List<ExamPaper> examPaperList = new ArrayList<ExamPaper>();
-		/*******************A类型********************/
-		ExamPaper examPaper1 = new ExamPaper();
-		examPaper1.setExamId(1L);
-		examPaper1.setCourseCode("03013750");
-		examPaper1.setGroupCode("A");
-		examPaper1.setWeight(100);
-		Paper paper1 = new Paper();
-		paper1.setId("58f0a15258e31a0d7448d58c");
-		examPaper1.setPaper(paper1);
-		examPaperList.add(examPaper1);
-		/*******************B类型********************/
-		ExamPaper examPaper2 = new ExamPaper();
-		examPaper2.setExamId(1L);
-		examPaper2.setCourseCode("03013750");
-		examPaper2.setGroupCode("B");
-		examPaper2.setWeight(100);
-		Paper paper2 = new Paper();
-		paper1.setId("58f0a15258e31a0d7448d58c");
-		examPaper1.setPaper(paper2);
-		examPaperList.add(examPaper2);
-		return examPaperList;
-	}
-	
-	@Test
-	public void testGetExamPaperId(){
-		String courseCode = "0003";
-		String orgId = "1";
-		List<String> paperIds = extractConfigService.getExamPaperId(courseCode, orgId);
-		System.out.println(paperIds);
-	}
-	
-	@Test
-	public void testExtract(){
-		Long exam_id = 59L;
-		String course_code = "012027";
-		String group_code = "A";
-		Map<String, Object> returnMap = extractConfigService.extractExamPaper(exam_id, course_code, group_code);
-		System.out.println(returnMap);
-	}
-	@Test
-	public void testcheckIsAllQbjectiveQuestion(){
-		System.out.println(extractConfigService.checkIsAllQbjectiveQuestion("5935658e90994d16dacf9fba"));
-	}
-	@Test
-	public void testGetQuestionById(){
-		String examId = "189";
-		String paperDetailUnitId = "59b8d7200fe2d22f92f48bdc";
-		String courseCode = "000001";
-		String groupCode = "A";
-		QuestionDto dto = extractConfigService.extractExamQuestion(examId,courseCode,groupCode,paperDetailUnitId);
-		System.out.println(dto.getQuesAnswer());
-	}
-	
-	
-	public static void main(String[] args) {
-		List<String> newList = new ArrayList<String>();
-		newList.add("a");
-		newList.add("b");
-		newList.add("c");
-		newList.add("d");
-		newList.add("e");
-		Collections.shuffle(newList);
-		System.out.println(newList);
-	}
+    }
+
+    @SuppressWarnings("unused")
+    private List<ExamPaper> buildOnlineExamPaper() {
+        List<ExamPaper> examPaperList = new ArrayList<ExamPaper>();
+        /*******************A类型********************/
+        ExamPaper examPaper1 = new ExamPaper();
+        examPaper1.setExamId(1L);
+        examPaper1.setCourseCode("03013750");
+        examPaper1.setGroupCode("A");
+        examPaper1.setWeight(80);
+        Paper paper1 = new Paper();
+        paper1.setId("58f0a15258e31a0d7448d58c");
+        examPaper1.setPaper(paper1);
+        examPaperList.add(examPaper1);
+        ExamPaper examPaper2 = new ExamPaper();
+        examPaper2.setExamId(1L);
+        examPaper2.setCourseCode("03013750");
+        examPaper2.setGroupCode("A");
+        examPaper2.setWeight(20);
+        Paper paper2 = new Paper();
+        paper2.setId("58f42fcd58e31a025844bfff");
+        examPaper2.setPaper(paper2);
+        examPaperList.add(examPaper2);
+        /*******************B类型********************/
+        ExamPaper examPaper3 = new ExamPaper();
+        examPaper3.setExamId(1L);
+        examPaper3.setCourseCode("03013750");
+        examPaper3.setGroupCode("B");
+        examPaper3.setWeight(60);
+        Paper paper3 = new Paper();
+        paper3.setId("58f4300c58e31a025844c02f");
+        examPaper3.setPaper(paper3);
+        examPaperList.add(examPaper3);
+        ExamPaper examPaper4 = new ExamPaper();
+        examPaper4.setExamId(1L);
+        examPaper4.setCourseCode("03013750");
+        examPaper4.setGroupCode("B");
+        examPaper4.setWeight(40);
+        Paper paper4 = new Paper();
+        paper4.setId("e483c730-921e-4212-a67e-42235a0aec00");
+        examPaper4.setPaper(paper4);
+        examPaperList.add(examPaper4);
+        return examPaperList;
+    }
+
+    @SuppressWarnings("unused")
+    private List<ExamPaper> buildTraditionExamPaper() {
+        List<ExamPaper> examPaperList = new ArrayList<ExamPaper>();
+        /*******************A类型********************/
+        ExamPaper examPaper1 = new ExamPaper();
+        examPaper1.setExamId(1L);
+        examPaper1.setCourseCode("03013750");
+        examPaper1.setGroupCode("A");
+        examPaper1.setWeight(100);
+        Paper paper1 = new Paper();
+        paper1.setId("58f0a15258e31a0d7448d58c");
+        examPaper1.setPaper(paper1);
+        examPaperList.add(examPaper1);
+        /*******************B类型********************/
+        ExamPaper examPaper2 = new ExamPaper();
+        examPaper2.setExamId(1L);
+        examPaper2.setCourseCode("03013750");
+        examPaper2.setGroupCode("B");
+        examPaper2.setWeight(100);
+        Paper paper2 = new Paper();
+        paper1.setId("58f0a15258e31a0d7448d58c");
+        examPaper1.setPaper(paper2);
+        examPaperList.add(examPaper2);
+        return examPaperList;
+    }
+
+    @Test
+    public void testGetExamPaperId() {
+        String courseCode = "0003";
+        String orgId = "1";
+        List<String> paperIds = extractConfigService.getExamPaperId(courseCode, orgId);
+        System.out.println(paperIds);
+    }
+
+    @Test
+    public void testExtract() {
+        Long exam_id = 59L;
+        String course_code = "012027";
+        String group_code = "A";
+        Map<String, Object> returnMap = extractConfigService.extractExamPaper(exam_id, course_code, group_code);
+        System.out.println(returnMap);
+    }
+
+    @Test
+    public void testcheckIsAllQbjectiveQuestion() {
+        System.out.println(extractConfigService.checkIsAllQbjectiveQuestion("5935658e90994d16dacf9fba"));
+    }
+
+    @Test
+    public void testGetQuestionById() {
+        String examId = "189";
+        String paperDetailUnitId = "59b8d7200fe2d22f92f48bdc";
+        String courseCode = "000001";
+        String groupCode = "A";
+        QuestionDto dto = extractConfigService.extractExamQuestion(examId, courseCode, groupCode, paperDetailUnitId);
+        System.out.println(dto.getQuesAnswer());
+    }
+
+
+    public static void main(String[] args) {
+        List<String> newList = new ArrayList<String>();
+        newList.add("a");
+        newList.add("b");
+        newList.add("c");
+        newList.add("d");
+        newList.add("e");
+        Collections.shuffle(newList);
+        System.out.println(newList);
+    }
 }
 

+ 107 - 107
examcloud-core-questions-starter/src/test/java/cn/com/qmth/examcloud/core/questions/starter/PaperServiceTest.java

@@ -27,122 +27,122 @@ import cn.com.qmth.examcloud.core.questions.service.PaperService;
 import cn.com.qmth.examcloud.core.questions.service.temp.DdExcelService;
 
 /**
- * @author  	chenken
- * @date    	2017年5月12日 下午1:35:39
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年5月12日 下午1:35:39
+ * @company QMTH
  * @description PaperServiceTest.java
  */
 @RunWith(SpringRunner.class)
 @SpringBootTest
 public class PaperServiceTest {
-	@Autowired
-	PaperService paperService;
-	@Autowired
-	ExportServiceManageRepo esmRepo;
-	@Autowired
-	PaperRepo paperRepo;
-	@Autowired
-	PaperDetailUnitRepo unitRepo;
-	@Autowired
-	QuesRepo quesRepo;
-	@Autowired
+    @Autowired
+    PaperService paperService;
+    @Autowired
+    ExportServiceManageRepo esmRepo;
+    @Autowired
+    PaperRepo paperRepo;
+    @Autowired
+    PaperDetailUnitRepo unitRepo;
+    @Autowired
+    QuesRepo quesRepo;
+    @Autowired
     private MongoTemplate mongoTemplate;
-	@Autowired
-	private DdExcelService dService;
-	
-	@Test
-	public void testUseBasePaper(){
-		String selectedPaperIds = "58f7294f6bf08e3453d9836c";
-		String userId = "chenken";
-		paperService.useBasePaper(selectedPaperIds, userId);
-	}
-	
-	public static void main(String[] args){
-		String answers = "正确";
-		System.out.println(!answers.contains("正确"));
-	}
-	
-	
-	@Test
-	public void testExportServiceManage(){
-		ExportServiceManage esm = new ExportServiceManage();
-		esm.setOrgName("石油大学");
-		esm.setExportServiceName("sydxExportPaperService");
-		esmRepo.save(esm);
-	}
-	
-	@Test
-	public void updatePaperDetailUnit(){
-		List<Paper> papers = paperRepo.findByPaperType(PaperType.GENERATE);
-		int i = 0;
-		for(Paper paper:papers){
-			List<PaperDetailUnit> units = unitRepo.findByPaper(paper);
-			for(PaperDetailUnit unit:units){
-				unit.setPaperType(PaperType.GENERATE);
-			}
-			i++;
-			unitRepo.saveAll(units);
-			System.out.println("已经处理完第" + i + "试卷");
-		}
-	}
-	
-	@Test
-	public void updateQuestions(){
-		List<Question> questions = new ArrayList<Question>();
-		List<Question> updateQues = new ArrayList<Question>();
-		String orgId = "1";
-		QuesStructType questionType = QuesStructType.BOOL_ANSWER_QUESTION;
-		Query query = new Query();
+    @Autowired
+    private DdExcelService dService;
+
+    @Test
+    public void testUseBasePaper() {
+        String selectedPaperIds = "58f7294f6bf08e3453d9836c";
+        String userId = "chenken";
+        paperService.useBasePaper(selectedPaperIds, userId);
+    }
+
+    public static void main(String[] args) {
+        String answers = "正确";
+        System.out.println(!answers.contains("正确"));
+    }
+
+
+    @Test
+    public void testExportServiceManage() {
+        ExportServiceManage esm = new ExportServiceManage();
+        esm.setOrgName("石油大学");
+        esm.setExportServiceName("sydxExportPaperService");
+        esmRepo.save(esm);
+    }
+
+    @Test
+    public void updatePaperDetailUnit() {
+        List<Paper> papers = paperRepo.findByPaperType(PaperType.GENERATE);
+        int i = 0;
+        for (Paper paper : papers) {
+            List<PaperDetailUnit> units = unitRepo.findByPaper(paper);
+            for (PaperDetailUnit unit : units) {
+                unit.setPaperType(PaperType.GENERATE);
+            }
+            i++;
+            unitRepo.saveAll(units);
+            System.out.println("已经处理完第" + i + "试卷");
+        }
+    }
+
+    @Test
+    public void updateQuestions() {
+        List<Question> questions = new ArrayList<Question>();
+        List<Question> updateQues = new ArrayList<Question>();
+        String orgId = "1";
+        QuesStructType questionType = QuesStructType.BOOL_ANSWER_QUESTION;
+        Query query = new Query();
         query.addCriteria(Criteria.where("orgId").is(orgId));
         query.addCriteria(Criteria.where("questionType").is(questionType));
         long count = this.mongoTemplate.count(query, Question.class);
-        System.out.println("总体量:"+count);//18761
-        for(int i=0;i<190;i++){
-        	query.limit(100);
-        	query.skip(i * 100);
-        	List<Question> questionList = this.mongoTemplate.find(query, Question.class);
-        	questions.addAll(questionList);
-        	System.out.println("第"+i+"次查询");
+        System.out.println("总体量:" + count);//18761
+        for (int i = 0; i < 190; i++) {
+            query.limit(100);
+            query.skip(i * 100);
+            List<Question> questionList = this.mongoTemplate.find(query, Question.class);
+            questions.addAll(questionList);
+            System.out.println("第" + i + "次查询");
+        }
+        System.out.println("试题集合总体量:" + questions.size());//18761
+        for (Question question : questions) {
+            String answer = question.getQuesAnswer();
+            if (!answer.contains("正确") && !answer.contains("错误")) {
+                if (!StringUtils.isBlank(answer)) {
+                    updateQues.add(question);
+                }
+            }
+        }
+        System.out.println("需要更新的试题量" + updateQues.size());
+        for (Question question : updateQues) {
+            String answer = question.getQuesAnswer();
+            if (answer.contains("对")) {
+                question.setQuesAnswer("正确");
+            }
+            if (answer.contains("错")) {
+                question.setQuesAnswer("错误");
+            }
+        }
+        System.out.println("实际更新的试题量" + updateQues.size());
+        quesRepo.saveAll(updateQues);
+    }
+
+    @Test
+    public void exportPaper() {
+        List<String> codes = new ArrayList<String>();
+        codes.add("Q001002");
+        codes.add("Q001008");
+        codes.add("Q010072");
+        codes.add("Q011028");
+        codes.add("Q011089");
+
+        codes.add("Q011101");
+        codes.add("Z012040");
+        try {
+            dService.exportSubQues("1", 105l, codes);
+        } catch (Exception e) {
+            e.printStackTrace();
         }
-        System.out.println("试题集合总体量:"+questions.size());//18761
-		for(Question question:questions){
-			String answer = question.getQuesAnswer();
-			if(!answer.contains("正确") && !answer.contains("错误")){
-				if(!StringUtils.isBlank(answer)){
-					updateQues.add(question);
-				}
-			}
-		}
-		System.out.println("需要更新的试题量"+updateQues.size());
-		for(Question question:updateQues){
-			String answer = question.getQuesAnswer();
-			if(answer.contains("对")){
-				question.setQuesAnswer("正确");
-			}
-			if(answer.contains("错")){
-				question.setQuesAnswer("错误");
-			}
-		}
-		System.out.println("实际更新的试题量"+updateQues.size());
-		quesRepo.saveAll(updateQues);
-	}
-	
-	@Test
-	public void exportPaper(){
-		List<String> codes = new ArrayList<String>();
-		codes.add("Q001002");
-		codes.add("Q001008");
-		codes.add("Q010072");
-		codes.add("Q011028");
-		codes.add("Q011089");
-		
-		codes.add("Q011101");
-		codes.add("Z012040");
-		try {
-			dService.exportSubQues("1", 105l, codes);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
+    }
 }
 

+ 4 - 4
examcloud-core-questions-starter/src/test/java/cn/com/qmth/examcloud/core/questions/starter/PduNativeTest.java

@@ -29,18 +29,18 @@ public class PduNativeTest {
     private PaperDetailUnitRepo paperDetailUnitRepo;
 
     @Test
-    public void testFind(){
+    public void testFind() {
         long beginTime = System.currentTimeMillis();
         List<PaperDetailUnit> pduList = paperDetailUnitNativeRepo.findByPaperId("591cf69b90994d7427e67008");
-        log.info("原生driver共耗时:"+(System.currentTimeMillis() - beginTime) +"ms");
+        log.info("原生driver共耗时:" + (System.currentTimeMillis() - beginTime) + "ms");
         System.out.printf(pduList.toString());
     }
 
     @Test
-    public void testFind1(){
+    public void testFind1() {
         long beginTime = System.currentTimeMillis();
         List<PaperDetailUnit> pduList = paperDetailUnitRepo.findByPaperId("591cf69b90994d7427e67008");
-        log.info("spring data共耗时:"+(System.currentTimeMillis() - beginTime) +"ms");
+        log.info("spring data共耗时:" + (System.currentTimeMillis() - beginTime) + "ms");
         System.out.printf(pduList.toString());
     }
 }

+ 48 - 46
examcloud-core-questions-starter/src/test/java/cn/com/qmth/examcloud/core/questions/starter/ProbabilityTest.java

@@ -1,57 +1,59 @@
 package cn.com.qmth.examcloud.core.questions.starter;
+
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
 
 /**
  * Java 从一组数据随机选择并可设置出现概率
- * @author pc
  *
+ * @author pc
  */
 public class ProbabilityTest {
-  
-     //String 可以为任意类型 也可以自定义类型
-     static Map<Object, Integer> keyChanceMap = new HashMap<Object,Integer>();
-     static{
-    	 keyChanceMap.put("试卷A", 100);
-     }
-     
-     public static void main(String[] args) {
-         Map<String, Integer> count = new HashMap<String,Integer>();
-         for (int i = 0; i < 100; i++) {
-             String item = chanceSelect(keyChanceMap);
-             if (count.containsKey(item)) {
-                 count.put(item, count.get(item) + 1);
-             } else {
-                 count.put(item, 1);
-             }
-         }
-         for(String id : count.keySet()){
-             System.out.println(id+"\t被选中了 "+count.get(id)+" 次");
-         }
-     }
- 
-     
-     public static String chanceSelect(Map<Object, Integer> keyChanceMap) { 
-         if(keyChanceMap == null || keyChanceMap.size() == 0) {
-        	 return null;  
-         }
-         Integer sum = 0;  
-         for (Integer value : keyChanceMap.values()) {  
-              sum += value;  
-         }  
-         // 从1开始  
-         Integer rand = new Random().nextInt(sum) + 1;  
-           
-         for (Map.Entry<Object, Integer> entry : keyChanceMap.entrySet()) {
-             rand -= entry.getValue();
-             // 选中
-             if (rand <= 0) {
-                 String item = entry.getKey()+"";
-                 return item;
-             }
-         } 
-           
-         return null;  
+
+    //String 可以为任意类型 也可以自定义类型
+    static Map<Object, Integer> keyChanceMap = new HashMap<Object, Integer>();
+
+    static {
+        keyChanceMap.put("试卷A", 100);
+    }
+
+    public static void main(String[] args) {
+        Map<String, Integer> count = new HashMap<String, Integer>();
+        for (int i = 0; i < 100; i++) {
+            String item = chanceSelect(keyChanceMap);
+            if (count.containsKey(item)) {
+                count.put(item, count.get(item) + 1);
+            } else {
+                count.put(item, 1);
+            }
+        }
+        for (String id : count.keySet()) {
+            System.out.println(id + "\t被选中了 " + count.get(id) + " 次");
+        }
+    }
+
+
+    public static String chanceSelect(Map<Object, Integer> keyChanceMap) {
+        if (keyChanceMap == null || keyChanceMap.size() == 0) {
+            return null;
+        }
+        Integer sum = 0;
+        for (Integer value : keyChanceMap.values()) {
+            sum += value;
+        }
+        // 从1开始
+        Integer rand = new Random().nextInt(sum) + 1;
+
+        for (Map.Entry<Object, Integer> entry : keyChanceMap.entrySet()) {
+            rand -= entry.getValue();
+            // 选中
+            if (rand <= 0) {
+                String item = entry.getKey() + "";
+                return item;
+            }
+        }
+
+        return null;
     }
- }
+}