|
@@ -1,336 +0,0 @@
|
|
|
-package cn.com.qmth.examcloud.core.questions.starter;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.QuesRepo;
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.temp.DdExcelService;
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.temp.UpdatePaperStruct;
|
|
|
-import org.junit.Test;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
-import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
-import org.springframework.data.mongodb.core.query.Query;
|
|
|
-import org.springframework.test.context.junit4.SpringRunner;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.regex.Pattern;
|
|
|
-
|
|
|
-
|
|
|
- * @author weiwenhai
|
|
|
- * @date 2018.7.19
|
|
|
- * @company qmth
|
|
|
- * @describle 测试地大题库导入
|
|
|
- */
|
|
|
-@RunWith(SpringRunner.class)
|
|
|
-@SpringBootTest
|
|
|
-public class DdCollegeUtilTest {
|
|
|
- private static final Logger log = LoggerFactory.getLogger(DdCollegeUtilTest.class);
|
|
|
-
|
|
|
-
|
|
|
- private DdCollegeUtilService ddCollegeUtilService;
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testPapers() {
|
|
|
- String codeName = "基础工程学/D06020008";
|
|
|
- List<TestPaper> testPapers = ddCollegeUtilService.queryByCourse(codeName);
|
|
|
- for(TestPaper testPaper:testPapers){
|
|
|
- System.out.println(testPaper.toString());
|
|
|
- }
|
|
|
- try {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ddCollegeUtilService.importPaper("1627", "D09020001",2);
|
|
|
- ddCollegeUtilService.importPaper("1627", "F09020010",2);
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
- }
|
|
|
- List<TestQuestion> list = ddCollegeUtilService.querySubQuestions("24AE438A37B67D7F0430D434A9D0C929");
|
|
|
- System.out.println(list);
|
|
|
- int count = ddCollegeUtilService.testCount();
|
|
|
- System.out.println(count);
|
|
|
-
|
|
|
- }*/
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private MongoTemplate mongoTemplate;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- PaperDetailUnitRepo paperDetailUnitRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- DdExcelService ddExcelService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- QuesRepo quesRepo;
|
|
|
-
|
|
|
-
|
|
|
- public void updatePaperType(){
|
|
|
- System.out.println("开始更新paperType...");
|
|
|
- Query query = new Query();
|
|
|
- long count = this.mongoTemplate.count(query, PaperDetailUnit.class);
|
|
|
- int size = (int) (count/1000);
|
|
|
- for(int i=0;i<=size;i++){
|
|
|
- query.skip(i * 1000);
|
|
|
- query.limit(1000);
|
|
|
- List<PaperDetailUnit> pduList = this.mongoTemplate.find(query, PaperDetailUnit.class);
|
|
|
- for(PaperDetailUnit pdu:pduList){
|
|
|
- pdu.setPaperType(pdu.getPaper().getPaperType());
|
|
|
- }
|
|
|
- paperDetailUnitRepo.save(pduList);
|
|
|
- System.out.println("更新完..."+ (i+1)*1000 + "记录");
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- @Test
|
|
|
- public void excelTest() {
|
|
|
- try {
|
|
|
-
|
|
|
- ddExcelService.exportPaperExcel("1387");
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @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");
|
|
|
-
|
|
|
- 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());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- map2.put("d", "d");
|
|
|
- Query query2 = new Query();
|
|
|
- for(Map.Entry<String, String> entry:map2.entrySet()){
|
|
|
- String key = "properties." + entry.getKey();
|
|
|
- query2.addCriteria(Criteria.where(key).is(entry.getValue()));
|
|
|
- }
|
|
|
- long count2 = this.mongoTemplate.count(query2, Question.class);
|
|
|
- List<Question> questionList2 = this.mongoTemplate.find(query2, Question.class);
|
|
|
- System.out.println("第二次查询:");
|
|
|
- System.out.println("count:"+ count2);
|
|
|
- for(Question question:questionList2){
|
|
|
- System.out.println("question:"+question.getProperties());
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, String> map3 = new HashMap<String, String>();
|
|
|
- map3.put("a", "a");
|
|
|
- map3.put("b", "b");
|
|
|
- Query query3 = new Query();
|
|
|
- for(Map.Entry<String, String> entry:map3.entrySet()){
|
|
|
- String key = "properties." + entry.getKey();
|
|
|
- query3.addCriteria(Criteria.where(key).is(entry.getValue()));
|
|
|
- }
|
|
|
- long count3 = this.mongoTemplate.count(query3, Question.class);
|
|
|
- List<Question> questionList3 = this.mongoTemplate.find(query3, Question.class);
|
|
|
- System.out.println("第三次查询:");
|
|
|
- System.out.println("count:"+ count3);
|
|
|
- for(Question question:questionList3){
|
|
|
- System.out.println("question:"+question.getProperties());
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, String> map4 = new HashMap<String, String>();
|
|
|
- map4.put("a", "a");
|
|
|
- map4.put("b", "b");
|
|
|
- map4.put("c", "c");
|
|
|
- Query query4 = new Query();
|
|
|
- for(Map.Entry<String, String> entry:map4.entrySet()){
|
|
|
- String key = "properties." + entry.getKey();
|
|
|
- query4.addCriteria(Criteria.where(key).is(entry.getValue()));
|
|
|
- }
|
|
|
- long count4 = this.mongoTemplate.count(query4, Question.class);
|
|
|
- List<Question> questionList4 = this.mongoTemplate.find(query4, Question.class);
|
|
|
- System.out.println("第四次查询:");
|
|
|
- System.out.println("count:"+ count4);
|
|
|
- for(Question question:questionList4){
|
|
|
- System.out.println("question:"+question.getProperties());
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, String> map5 = new HashMap<String, String>();
|
|
|
- map5.put("a", "a");
|
|
|
- map5.put("d", "d");
|
|
|
- Query query5 = new Query();
|
|
|
- for(Map.Entry<String, String> entry:map5.entrySet()){
|
|
|
- String key = "properties." + entry.getKey();
|
|
|
- query5.addCriteria(Criteria.where(key).is(entry.getValue()));
|
|
|
- }
|
|
|
- long count5 = this.mongoTemplate.count(query5, Question.class);
|
|
|
- List<Question> questionList5 = this.mongoTemplate.find(query5, Question.class);
|
|
|
- System.out.println("第五次查询:");
|
|
|
- System.out.println("count:"+ count5);
|
|
|
- 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("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");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|