|
@@ -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;
|
|
|
+// }
|
|
|
|
|
|
}
|