xiatian 1 ano atrás
pai
commit
9703f49593

+ 44 - 6
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/debug/DebugService.java

@@ -1,6 +1,7 @@
 package cn.com.qmth.dp.examcloud.oe.modules.debug;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
@@ -12,6 +13,9 @@ import org.jsoup.nodes.Node;
 import org.jsoup.nodes.TextNode;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.aggregation.Aggregation;
+import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
+import org.springframework.data.mongodb.core.aggregation.AggregationResults;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
@@ -19,6 +23,10 @@ import org.springframework.stereotype.Service;
 import cn.com.qmth.dp.examcloud.oe.entity.question.PaperDetailUnit;
 import cn.com.qmth.dp.examcloud.oe.entity.question.QuesOption;
 import cn.com.qmth.dp.examcloud.oe.entity.question.Question;
+import cn.com.qmth.dp.examcloud.oe.modules.export_course_questions_diff_count.QuestionTypeCount;
+import cn.com.qmth.examcloud.commons.util.DateUtil;
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.GenPaperDto;
+import cn.com.qmth.examcloud.core.questions.service.impl.GenPaperService;
 
 @Service
 public class DebugService {
@@ -34,19 +42,49 @@ public class DebugService {
     public static final String ELEMENT_TYPE_IMG = "image";
     
     public static final String ELEMENT_TYPE_DOCTAG = "doctag";
-
-
+    @Autowired
+    GenPaperService genPaperService;
 	@Autowired
 	MongoTemplate mongoTemplate;
 
 	public void start() {
-		Query query = new Query();
-		query.addCriteria(Criteria.where("paper.$id").is(new ObjectId("64ddd05a391d2033f36b0a20")));
-		List<PaperDetailUnit> ps = mongoTemplate.find(query, PaperDetailUnit.class, "paperDetailUnit");
-		ExportPaperUtil.disposePaperDoc(ps);
+		System.out.println("start *********************");
+//		GenPaperDto d=new GenPaperDto();
+//		d.setCourseNo("061001");
+//		d.setGenNumber(1);
+//		List<String> pids=new ArrayList<>();
+//		pids.add("62b965233c66227eeadbdd68");
+//		d.setPaperIds(pids);
+//		d.setPaperName("test1");
+//		d.setPaperStructId("656f2be8267c7c21db09b990");
+//		genPaperService.genPaper(d);
+//		Query query = new Query();
+//		query.addCriteria(Criteria.where("paper.$id").is(new ObjectId("64ddd05a391d2033f36b0a20")));
+//		List<PaperDetailUnit> ps = mongoTemplate.find(query, PaperDetailUnit.class, "paperDetailUnit");
+//		ExportPaperUtil.disposePaperDoc(ps);
 //		for(PaperDetailUnit p:ps) {
 //			disposeQuestion(p.getQuestion());
 //		}
+		List<QuestionTypeCount> ret=countByType("WB7030", "17351");
+		System.out.println();
+	}
+	
+	private List<QuestionTypeCount> countByType(String courseCode, String rootOrgId) {
+        Date day=DateUtil.parse("2023-08-21 00:00:00", "yyyy-MM-dd HH:mm:ss");
+		List<AggregationOperation> operations = new ArrayList<>();
+		operations.add(Aggregation.match(
+				Criteria.where("orgId").is(rootOrgId)
+				.and("course.code").is(courseCode)
+				.and("creationBy").is(646523L)
+				.and("creationDate").gt(day)
+					)
+				);
+		operations.add(Aggregation.group("questionType", "difficulty").count().as("count"));
+		operations.add(Aggregation.project("count").andInclude("questionType").andInclude("difficulty"));
+		Aggregation aggregation = Aggregation.newAggregation(operations);
+		AggregationResults<QuestionTypeCount> outputTypeCount = mongoTemplate.aggregate(aggregation, Question.class,
+				QuestionTypeCount.class);
+		return outputTypeCount.getMappedResults();
 	}
 	
 	private static void disposeQuestion(Question qes) {

+ 16 - 6
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_course_questions_diff_count/ExportCourseQuestionsDiffCountService.java

@@ -8,6 +8,7 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -26,17 +27,17 @@ import cn.com.qmth.examcloud.web.support.SpringContextHolder;
 @Service
 public class ExportCourseQuestionsDiffCountService {
 	private String rootOrgId = "17351";
-	private int threadCount=20;
+	private int threadCount = 20;
 
 	public void start() {
-		Date s=new Date();
+		Date s = new Date();
 		ExportQuesDiffProducer pr = SpringContextHolder.getBean(ExportQuesDiffProducer.class);
 		try {
-			Map<String, Object> param=new HashMap<>();
+			Map<String, Object> param = new HashMap<>();
 			param.put("rootOrgId", rootOrgId);
 			pr.startDispose(ExportQuesDiffConsumer.class, threadCount, param);
 			List<CourseQuestionsCountRetDto> ret = new ArrayList<CourseQuestionsCountRetDto>();
-			for(Consumer c:pr.getConsumers()) {
+			for (Consumer c : pr.getConsumers()) {
 				ret.addAll(c.getRet());
 			}
 			Collections.sort(ret, new Comparator<CourseQuestionsCountRetDto>() {
@@ -48,6 +49,15 @@ public class ExportCourseQuestionsDiffCountService {
 				}
 
 			});
+			Iterator<CourseQuestionsCountRetDto> it = ret.iterator();
+			while (it.hasNext()) {
+				CourseQuestionsCountRetDto t = it.next();
+				if (t.getBoolNan() + t.getBoolYi() + t.getBoolZhong() 
+				+ t.getMultiNan() + t.getMultiYi()+ t.getMultiZhong() 
+				+ t.getSingleNan()+t.getSingleYi()+t.getSingleZhong()==0) {
+					it.remove();
+				}
+			}
 			FileOutputStream fos = null;
 			try {
 				File file = new File("d:/ret.xlsx");
@@ -72,8 +82,8 @@ public class ExportCourseQuestionsDiffCountService {
 			throw new RuntimeException(e);
 
 		}
-		Date e=new Date();
-		System.out.println("time:" + (e.getTime()-s.getTime()));
+		Date e = new Date();
+		System.out.println("time:" + (e.getTime() - s.getTime()));
 	}
 
 }

+ 33 - 39
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_course_questions_diff_count/ExportQuesDiffConsumer.java

@@ -2,26 +2,20 @@ package cn.com.qmth.dp.examcloud.oe.modules.export_course_questions_diff_count;
 
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.collections4.CollectionUtils;
-import org.bson.types.ObjectId;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
-import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.aggregation.Aggregation;
 import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
 import org.springframework.data.mongodb.core.aggregation.AggregationResults;
 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.dp.examcloud.oe.entity.question.Course;
-import cn.com.qmth.dp.examcloud.oe.entity.question.Paper;
-import cn.com.qmth.dp.examcloud.oe.entity.question.PaperDetailUnit;
 import cn.com.qmth.dp.examcloud.oe.entity.question.Question;
 import cn.com.qmth.dp.examcloud.oe.enums.question.QuesStructType;
 import cn.com.qmth.dp.examcloud.oe.multithread.Consumer;
@@ -41,7 +35,7 @@ public class ExportQuesDiffConsumer extends Consumer<Course> {
 		String rootOrgId = (String) param.get("rootOrgId");
 		rd.setCourseCode(c.getCode());
 		rd.setCourseName(c.getName());
-		List<QuestionTypeCount> tc = countByType2(c.getCode(), rootOrgId);
+		List<QuestionTypeCount> tc = countByType(c.getCode(), rootOrgId);
 		if (CollectionUtils.isNotEmpty(tc)) {
 			setCount(rd, tc);
 		}
@@ -79,7 +73,7 @@ public class ExportQuesDiffConsumer extends Consumer<Course> {
 	}
 
 	private List<QuestionTypeCount> countByType(String courseCode, String rootOrgId) {
-        Date day=DateUtil.parse("2023-09-14 00:00:00", "yyyy-MM-dd HH:mm:ss");
+        Date day=DateUtil.parse("2023-08-21 00:00:00", "yyyy-MM-dd HH:mm:ss");
 		List<AggregationOperation> operations = new ArrayList<>();
 		operations.add(Aggregation.match(
 				Criteria.where("orgId").is(rootOrgId)
@@ -96,36 +90,36 @@ public class ExportQuesDiffConsumer extends Consumer<Course> {
 		return outputTypeCount.getMappedResults();
 	}
 	
-	private List<QuestionTypeCount> countByType2(String courseCode, String rootOrgId) {
-		List<QuestionTypeCount> ret=new ArrayList<>();
-		Query query = new Query();
-		query.addCriteria(Criteria.where("orgId").is(rootOrgId));
-		query.addCriteria(Criteria.where("course.code").is(courseCode));
-		query.addCriteria(Criteria.where("paperType").is("IMPORT"));
-		query.with(Sort.by(Sort.Direction.DESC,"creationDate"));
-		List<Paper> ps = mongoTemplate.find(query, Paper.class);
-		if(ps.size()==0) {
-			return ret;
-		}
-		Query q2 = new Query();
-		q2.addCriteria(Criteria.where("paper.$id").is(new ObjectId(ps.get(0).getId())));
-		List<PaperDetailUnit> us = mongoTemplate.find(q2, PaperDetailUnit.class);
-		Map<String,QuestionTypeCount> map=new HashMap<>();
-		for(PaperDetailUnit u:us) {
-			String key=u.getQuestionType().name()+"_"+u.getQuestion().getDifficulty();
-			QuestionTypeCount tem=map.get(key);
-			if(tem==null) {
-				tem=new QuestionTypeCount();
-				tem.setDifficulty(u.getQuestion().getDifficulty());
-				tem.setQuestionType(u.getQuestionType().name());
-				map.put(key, tem);
-			}
-			tem.setCount(tem.getCount()+1);
-		}
-		for(QuestionTypeCount v:map.values()) {
-			ret.add(v);
-		}
-		return ret;
-	}
+//	private List<QuestionTypeCount> countByType2(String courseCode, String rootOrgId) {
+//		List<QuestionTypeCount> ret=new ArrayList<>();
+//		Query query = new Query();
+//		query.addCriteria(Criteria.where("orgId").is(rootOrgId));
+//		query.addCriteria(Criteria.where("course.code").is(courseCode));
+//		query.addCriteria(Criteria.where("paperType").is("IMPORT"));
+//		query.with(Sort.by(Sort.Direction.DESC,"creationDate"));
+//		List<Paper> ps = mongoTemplate.find(query, Paper.class);
+//		if(ps.size()==0) {
+//			return ret;
+//		}
+//		Query q2 = new Query();
+//		q2.addCriteria(Criteria.where("paper.$id").is(new ObjectId(ps.get(0).getId())));
+//		List<PaperDetailUnit> us = mongoTemplate.find(q2, PaperDetailUnit.class);
+//		Map<String,QuestionTypeCount> map=new HashMap<>();
+//		for(PaperDetailUnit u:us) {
+//			String key=u.getQuestionType().name()+"_"+u.getQuestion().getDifficulty();
+//			QuestionTypeCount tem=map.get(key);
+//			if(tem==null) {
+//				tem=new QuestionTypeCount();
+//				tem.setDifficulty(u.getQuestion().getDifficulty());
+//				tem.setQuestionType(u.getQuestionType().name());
+//				map.put(key, tem);
+//			}
+//			tem.setCount(tem.getCount()+1);
+//		}
+//		for(QuestionTypeCount v:map.values()) {
+//			ret.add(v);
+//		}
+//		return ret;
+//	}
 
 }

+ 9 - 3
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_course_questions_diff_count/ExportQuesDiffProducer.java

@@ -2,8 +2,10 @@ package cn.com.qmth.dp.examcloud.oe.modules.export_course_questions_diff_count;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -33,20 +35,24 @@ public class ExportQuesDiffProducer extends Producer {
 	
 	
 	private List<Course> getCourse() {
+		Set<String> set=new HashSet<>();
 		List<Course> list=new ArrayList<>();
 		XSSFWorkbook wb = null;
 		try {
 			wb = new XSSFWorkbook(ResouceUtil.getStream("subject_codes.xlsx"));
 			XSSFSheet sheet = wb.getSheetAt(0);
 			int rows = sheet.getLastRowNum();
-			for (int i = 2; i <= rows; i++) {
+			for (int i = 1; i <= rows; i++) {
 				Course c = new Course();
 				XSSFRow row = sheet.getRow(i);
 				String ecCode = row.getCell(0).getStringCellValue().trim();
-				String name = row.getCell(1).getStringCellValue().trim();
+				String name = row.getCell(2).getStringCellValue().trim();
 				c.setCode(ecCode);
 				c.setName(name);
-				list.add(c);
+				if(!set.contains(ecCode)) {
+					list.add(c);
+					set.add(ecCode);
+				}
 				
 			}
 		} catch (IOException e) {

+ 25 - 4
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_extract_config/ExportExtractConfigService.java

@@ -4,6 +4,8 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import org.apache.commons.collections4.CollectionUtils;
@@ -26,8 +28,13 @@ import cn.com.qmth.examcloud.commons.exception.StatusException;
  */
 @Service
 public class ExportExtractConfigService {
-	private static Long examId=28L;
+	private static List<Long> examIds=new ArrayList<>();
 	
+	static {
+		examIds.add(5591L);
+		examIds.add(5592L);
+		examIds.add(5593L);
+	}
 	@Autowired
 	private MongoTemplate mongoTemplate;
 	
@@ -37,7 +44,7 @@ public class ExportExtractConfigService {
 			file.delete();
 		}
 		Query query = new Query();
-		query.addCriteria(Criteria.where("examId").is(examId));
+		query.addCriteria(Criteria.where("examId").in(examIds));
 		List<ExtractConfig> ps = mongoTemplate.find(query, ExtractConfig.class, "extractConfig");
 		if(CollectionUtils.isEmpty(ps)) {
 			return;
@@ -46,6 +53,7 @@ public class ExportExtractConfigService {
 		for(ExtractConfig ec:ps) {
 			if(CallType.RANDOM_PAPER.equals(ec.getCallType())) {
 				ExtractConfigDto dto=new ExtractConfigDto();
+				dto.setExamId(ec.getExamId());
 				dto.setCourseName(ec.getCourse().getName());
 				dto.setCourseCode(ec.getCourse().getCode());
 				dto.setCallType(ec.getCallType().getName());
@@ -54,6 +62,7 @@ public class ExportExtractConfigService {
 			}else {
 				for(ExamPaper ep:ec.getExamPaperList()) {
 					ExtractConfigDto dto=new ExtractConfigDto();
+					dto.setExamId(ec.getExamId());
 					dto.setCourseName(ec.getCourse().getName());
 					dto.setCourseCode(ec.getCourse().getCode());
 					dto.setCallType(ec.getCallType().getName());
@@ -62,6 +71,20 @@ public class ExportExtractConfigService {
 				}
 			}
 		}
+		Collections.sort(ret, new Comparator<ExtractConfigDto>() {
+
+            @Override
+            public int compare(ExtractConfigDto o1, ExtractConfigDto o2) {
+                if (o1.getExamId() < o2.getExamId()) {
+                    return -1;
+                } else if (o1.getExamId()> o2.getExamId()) {
+                    return 1;
+                } else {
+                    return o1.getCourseCode().compareTo(o2.getCourseCode());
+                }
+            }
+
+        });
 		FileOutputStream fos = null;
 		try {
 			file.createNewFile();
@@ -81,8 +104,6 @@ public class ExportExtractConfigService {
 	}
 	
 	private String getPaperName(String id) {
-		Query query = new Query();
-		query.addCriteria(Criteria.where("examId").is(examId));
 		RandomPaper p = mongoTemplate.findById(id, RandomPaper.class);
 		if(p==null) {
 			throw new StatusException("未找到千卷模版");

+ 12 - 4
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_extract_config/ExtractConfigDto.java

@@ -3,13 +3,15 @@ package cn.com.qmth.dp.examcloud.oe.modules.export_extract_config;
 import cn.com.qmth.dp.examcloud.oe.excel.ExcelProperty;
 
 public class ExtractConfigDto {
-	@ExcelProperty(name = "课程名称", width = 25, index = 1)
-	private String courseName;
+	@ExcelProperty(name = "考试id", width = 25, index = 1)
+	private Long examId;
 	@ExcelProperty(name = "课程代码", width = 25, index = 2)
 	private String courseCode;
-	@ExcelProperty(name = "抽题模式", width = 25, index = 3)
+	@ExcelProperty(name = "课程名称", width = 25, index = 3)
+	private String courseName;
+	@ExcelProperty(name = "抽题模式", width = 25, index = 4)
 	private String callType;
-	@ExcelProperty(name = "试卷名称", width = 25, index = 4)
+	@ExcelProperty(name = "试卷名称", width = 25, index = 5)
 	private String paperName;
 	public String getCourseName() {
 		return courseName;
@@ -35,6 +37,12 @@ public class ExtractConfigDto {
 	public void setCallType(String callType) {
 		this.callType = callType;
 	}
+	public Long getExamId() {
+		return examId;
+	}
+	public void setExamId(Long examId) {
+		this.examId = examId;
+	}
 	
 	
 }