Browse Source

提交到本地,不推送

weiwenhai 6 năm trước cách đây
mục cha
commit
d43d4f6113

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 9 - 9
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/DdCollegeUtilService.java


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

@@ -1,4 +1,4 @@
-package cn.com.qmth.examcloud.core.questions.starter.oracle;
+/*package cn.com.qmth.examcloud.core.questions.starter.oracle;
 
 import javax.sql.DataSource;
 
@@ -10,12 +10,12 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Primary;
 import org.springframework.jdbc.core.JdbcTemplate;
 
-/**
+*//**
  * @author 		weiwenhai
  * @date		2018.7.30
  * @company		qmth
  * @describle	数据库连接池
- */
+ *//*
 @Configuration("nativeOracleConfig")
 public class NativeOracleConfig {
 
@@ -47,3 +47,4 @@ public class NativeOracleConfig {
 	}
 
 }
+*/

+ 6 - 6
examcloud-core-questions-starter/src/main/resources/application-dev.properties

@@ -1,5 +1,5 @@
-spring.data.mongodb.uri=mongodb://root:Qmth87863577@127.0.0.1:6600/comm-ques-bank?authSource=admin&authMechanism=SCRAM-SHA-1
-#spring.data.mongodb.uri=mongodb://192.168.10.30:27017/comm-ques-bank
+#spring.data.mongodb.uri=mongodb://root:Qmth87863577@127.0.0.1:6600/comm-ques-bank?authSource=admin&authMechanism=SCRAM-SHA-1
+spring.data.mongodb.uri=mongodb://192.168.10.30:27017/comm-ques-bank
 spring.data.mongodb.grid-fs-database=comm-ques-bank
 spring.data.mongodb.database=comm-ques-bank
 eureka.client.serviceUrl.defaultZone=http://192.168.10.30:1111/eureka/
@@ -29,10 +29,10 @@ spring.datasource.primary.driver-class-name=com.mysql.jdbc.Driver
 spring.jpa.show-sql=false
 spring.jpa.hibernate.ddl-auto=update
 
-spring.datasource.secondary.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
-spring.datasource.secondary.username=wwh
-spring.datasource.secondary.password=wwh
-spring.datasource.secondary.driver-class-name=oracle.jdbc.OracleDriver
+#spring.datasource.secondary.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
+#spring.datasource.secondary.username=wwh
+#spring.datasource.secondary.password=wwh
+#spring.datasource.secondary.driver-class-name=oracle.jdbc.OracleDriver
 
 spring.rabbitmq.host=192.168.10.30
 spring.rabbitmq.port=5672

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

@@ -6,9 +6,16 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 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 cn.com.qmth.examcloud.core.questions.service.temp.DdCollegeUtilService;
+import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
+import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
 import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestOption;
 import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestPaper;
 import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestQuestion;
@@ -23,16 +30,16 @@ import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestQuestion;
 @SpringBootTest
 public class DdCollegeUtilTest {
 
-	@Autowired
+	/*@Autowired
 	private DdCollegeUtilService ddCollegeUtilService;
 	
 	@Test
 	public void testPapers() {
-		/*String codeName = "基础工程学/D06020008";
+		String codeName = "基础工程学/D06020008";
 		List<TestPaper> testPapers = ddCollegeUtilService.queryByCourse(codeName);
 		for(TestPaper testPaper:testPapers){
 			System.out.println(testPaper.toString());
-		}*/
+		}
 		try {
 			//ddCollegeUtilService.importPaper("1627", "D09020014",2);
 			//ddCollegeUtilService.importPaper("1627", "D01020019",2);
@@ -54,30 +61,36 @@ public class DdCollegeUtilTest {
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
-		/*List<TestQuestion> list = ddCollegeUtilService.querySubQuestions("24AE438A37B67D7F0430D434A9D0C929");
-		System.out.println(list);*/
-		/*int count = ddCollegeUtilService.testCount();
-		System.out.println(count);*/
+		List<TestQuestion> list = ddCollegeUtilService.querySubQuestions("24AE438A37B67D7F0430D434A9D0C929");
+		System.out.println(list);
+		int count = ddCollegeUtilService.testCount();
+		System.out.println(count);
 		//int count = ddCollegeUtilService.testCount();
-	}
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
+	}*/
 	
+	 @Autowired
+	 private MongoTemplate mongoTemplate;
+	 
+	 @Autowired
+	 PaperDetailUnitRepo paperDetailUnitRepo;
+
+	 @Test
+	 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 + "记录");
+		 }
+	 }
 	
 }
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác