weiwenhai 6 lat temu
rodzic
commit
fa1b3b9da9

+ 2 - 0
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/PaperRepo.java

@@ -33,5 +33,7 @@ public interface PaperRepo extends MongoRepository<Paper, String>, QueryByExampl
     List<Paper> findBySpecialtyCodeAndOrgId(String specialtyCode,String orgId);
     
     Paper findByNameAndOrgIdAndPaperType(String name, String orgId, PaperType paperType);
+    
+    List<Paper> findByPaperType(PaperType paperType);
 
 }

+ 1 - 3
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/GenPaperService.java

@@ -38,7 +38,6 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
 import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
 import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
 import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
-import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
 import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
 import cn.com.qmth.examcloud.commons.web.security.bean.User;
@@ -565,7 +564,6 @@ public class GenPaperService {
 			newUnit.setId(null);
 			newUnit.setCreator(name);
 			newUnit.setCreateTime(CommonUtils.getCurDateTime());
-			newUnit.setPaperType(PaperType.GENERATE);
 			newDetailUnits.add(newUnit);
 		}
 		return newDetailUnits;
@@ -591,7 +589,6 @@ public class GenPaperService {
 			newUnit.setId(null);
 			newUnit.setCreator(name);
 			newUnit.setCreateTime(CommonUtils.getCurDateTime());
-			newUnit.setPaperType(PaperType.GENERATE);
 			newDetailUnits.add(newUnit);
     	}
     	return newDetailUnits;
@@ -700,6 +697,7 @@ public class GenPaperService {
     			paperDetailUnit.setPaper(paper);
     			paperDetailUnit.setPaperDetail(paperDetail);
     			paperDetailUnit.setNumber(number+1);
+    			paperDetailUnit.setPaperType(PaperType.GENERATE);
     			unitRepo.save(paperDetailUnit);
     			number++ ;
     		}

+ 21 - 16
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/UpdatePaperStruct.java → examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/UpdatePaperStruct.java

@@ -1,19 +1,18 @@
-package cn.com.qmth.examcloud.core.questions.service.temp.vo;
+package cn.com.qmth.examcloud.core.questions.service.temp;
 
 import java.util.List;
 
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 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.stereotype.Service;
 
-import cn.com.qmth.examcloud.core.questions.base.enums.GenPaperType;
 import cn.com.qmth.examcloud.core.questions.dao.PaperStructRepo;
 import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailStruct;
 import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnitStruct;
 import cn.com.qmth.examcloud.core.questions.dao.entity.PaperStruct;
+import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PaperDetailUnitStructDto;
 
 /**
  * @author 		weiwenhai
@@ -35,31 +34,37 @@ public class UpdatePaperStruct {
 		//根据orgId查询所有精确试卷结构
 		Query query = new Query();
         query.addCriteria(Criteria.where("orgId").is(orgId));
-        query.addCriteria(Criteria.where("id").nin("BLUEPRINT"));
+        query.addCriteria(Criteria.where("type").is("EXACT"));
         List<PaperStruct> paperStructList = this.mongoTemplate.find(query, PaperStruct.class);
+        int i = 0;
         if(paperStructList!=null && paperStructList.size()>0){
         	for(PaperStruct paperStruct:paperStructList){
-        		//1.跟新type
-        		if(StringUtils.isBlank(paperStruct.getType())){
-        			paperStruct.setType("EXACT");
-        		}
-        		//2.跟新genPaperType
-        		if(paperStruct.getGenPaperType() == null){
-        			paperStruct.setGenPaperType(GenPaperType.COMMON);
-        		}
+        		//获取大题集合
         		List<PaperDetailStruct> paperDetailStructs = paperStruct.getPaperDetailStructs();
-        		for(PaperDetailStruct paperDetailStruct:paperDetailStructs){
-        			//得到以前的小题
-        			List<PaperDetailUnitStruct> unitStructs = paperDetailStruct.getPaperDetailUnitStructs();
-        			for(PaperDetailUnitStruct unitStruct:unitStructs){
+    			for(PaperDetailStruct paperDetailStruct:paperDetailStructs){
+    				//获取小题类型统计
+    				List<PaperDetailUnitStructDto> unitStructs = paperDetailStruct.getUnitStructs();
+    				for(PaperDetailUnitStructDto dto:unitStructs){
+    					dto.setPublicDifficulty(0);
+    					dto.setPublicMedium(dto.getCount());
+    					dto.setPublicSimple(0);
+    					dto.setNoPublicDifficulty(0);
+    					dto.setNoPublicMedium(0);
+    					dto.setNoPublicSimple(0);
+    				}
+        			List<PaperDetailUnitStruct> units = paperDetailStruct.getPaperDetailUnitStructs();
+        			for(PaperDetailUnitStruct unitStruct:units){
         				unitStruct.setDifficulty("中");
                 		unitStruct.setPublicity(true);
                 		unitStruct.setPropertyGroup(buildGroup(unitStruct));
         			}
         		}
+    			i++;
         	}
         }
+        System.out.println("更新精确试卷结构的数量为:"+ i + "------个");
         paperStructRepo.save(paperStructList);
+        System.out.println("更新成功!----");
 	}
 	
 	/**

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

@@ -19,6 +19,7 @@ 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;
 
 /**
  * @author 		weiwenhai
@@ -244,6 +245,14 @@ public class DdCollegeUtilTest {
 			 System.out.println("question:"+question.getProperties());
 		 }*/
 	 }
+	 
+	 @Autowired
+	 private UpdatePaperStruct updatePaperStruct;
+	 
+	 @Test
+	 public void updatePaperStruct(){
+		 updatePaperStruct.updatePaperStruct("43");
+	 }
 }
 
 

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

@@ -1,5 +1,7 @@
 package cn.com.qmth.examcloud.core.questions.starter;
 
+import java.util.List;
+
 import org.apache.commons.lang.StringUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -7,8 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
 import cn.com.qmth.examcloud.core.questions.dao.ExportServiceManageRepo;
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
+import cn.com.qmth.examcloud.core.questions.dao.PaperRepo;
 import cn.com.qmth.examcloud.core.questions.dao.entity.ExportServiceManage;
+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.PaperService;
 
 /**
@@ -24,6 +31,10 @@ public class PaperServiceTest {
 	PaperService paperService;
 	@Autowired
 	ExportServiceManageRepo esmRepo;
+	@Autowired
+	PaperRepo paperRepo;
+	@Autowired
+	PaperDetailUnitRepo unitRepo;
 	
 	@Test
 	public void testUseBasePaper(){
@@ -45,5 +56,20 @@ public class PaperServiceTest {
 		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.save(units);
+			System.out.println("已经处理完第" + i + "试卷");
+		}
+	}
 }