|
@@ -2,6 +2,7 @@ package cn.com.qmth.dp.examcloud.oe.modules.findreduplicatequestion;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -22,7 +23,6 @@ import cn.com.qmth.dp.examcloud.oe.enums.question.PaperType;
|
|
|
import cn.com.qmth.dp.examcloud.oe.enums.question.QuesStructType;
|
|
|
import cn.com.qmth.dp.examcloud.oe.multithread.Consumer;
|
|
|
import cn.com.qmth.dp.examcloud.oe.util.PaperUtil;
|
|
|
-import cn.com.qmth.dp.examcloud.oe.util.StringSimilarityUtils;
|
|
|
import cn.com.qmth.examcloud.commons.util.DateUtil;
|
|
|
|
|
|
@Service
|
|
@@ -62,17 +62,9 @@ public class ExportQuesReduplicateConsumer extends Consumer<Course> {
|
|
|
if (CollectionUtils.isEmpty(quess)) {
|
|
|
return;
|
|
|
}
|
|
|
- List<QuestionDto> sin = findQuestionByType(quess, QuesStructType.SINGLE_ANSWER_QUESTION);
|
|
|
- if (CollectionUtils.isNotEmpty(sin)) {
|
|
|
- checkQuestion(sin, c.getName(), c.getCode());
|
|
|
- }
|
|
|
- List<QuestionDto> mut = findQuestionByType(quess, QuesStructType.MULTIPLE_ANSWER_QUESTION);
|
|
|
- if (CollectionUtils.isNotEmpty(mut)) {
|
|
|
- checkQuestion(mut, c.getName(), c.getCode());
|
|
|
- }
|
|
|
- List<QuestionDto> bool = findQuestionByType(quess, QuesStructType.BOOL_ANSWER_QUESTION);
|
|
|
- if (CollectionUtils.isNotEmpty(bool)) {
|
|
|
- checkQuestion(bool, c.getName(), c.getCode());
|
|
|
+ Map<QuesStructType,List<QuestionDto>> map=toMap(quess);
|
|
|
+ for(QuesStructType k:map.keySet()) {
|
|
|
+ checkQuestion(map.get(k), c.getName(), c.getCode());
|
|
|
}
|
|
|
System.out.println("处理完科目:" + c.getCode());
|
|
|
}
|
|
@@ -87,12 +79,15 @@ public class ExportQuesReduplicateConsumer extends Consumer<Course> {
|
|
|
// return ret;
|
|
|
// }
|
|
|
|
|
|
- private List<QuestionDto> findQuestionByType(List<QuestionDto> dtos, QuesStructType type) {
|
|
|
- List<QuestionDto> ret = new ArrayList<>();
|
|
|
+ private Map<QuesStructType,List<QuestionDto>> toMap(List<QuestionDto> dtos) {
|
|
|
+ Map<QuesStructType,List<QuestionDto>> ret=new HashMap<>();
|
|
|
for (QuestionDto dto : dtos) {
|
|
|
- if (type.equals(dto.getQuestionType())) {
|
|
|
- ret.add(dto);
|
|
|
+ List<QuestionDto> tem=ret.get(dto.getQuestionType());
|
|
|
+ if(tem==null) {
|
|
|
+ tem=new ArrayList<>();
|
|
|
+ ret.put(dto.getQuestionType(), tem);
|
|
|
}
|
|
|
+ tem.add(dto);
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
@@ -108,11 +103,11 @@ public class ExportQuesReduplicateConsumer extends Consumer<Course> {
|
|
|
// }
|
|
|
|
|
|
private List<QuestionDto> findQuestion(String rootOrgId, String courseCode) {
|
|
|
- Date day=DateUtil.parse("2024-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date day=DateUtil.parse("2024-06-13 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
|
|
Query query = new Query();
|
|
|
query.addCriteria(Criteria.where("orgId").is(rootOrgId));
|
|
|
query.addCriteria(Criteria.where("course.code").is(courseCode));
|
|
|
-// query.addCriteria(Criteria.where("creationBy").is(646523L));
|
|
|
+ query.addCriteria(Criteria.where("creationBy").is(646523L));
|
|
|
query.addCriteria(Criteria.where("creationDate").gt(day));
|
|
|
List<QuestionDto> ret = this.mongoTemplate.find(query, QuestionDto.class, "question");
|
|
|
return ret;
|
|
@@ -172,7 +167,7 @@ public class ExportQuesReduplicateConsumer extends Consumer<Course> {
|
|
|
Set<String> checkIds = new HashSet<>();
|
|
|
for (QuestionDto dto : dtos) {
|
|
|
dto.setExtractText(PaperUtil.getExtractText(dto));
|
|
|
- if (StringUtils.isEmpty(dto.getExtractText())||PaperUtil.hasImg(dto)) {
|
|
|
+ if (PaperUtil.hasImg(dto)||StringUtils.isEmpty(dto.getExtractText())) {
|
|
|
checkIds.add(dto.getId());
|
|
|
}
|
|
|
}
|
|
@@ -191,9 +186,9 @@ public class ExportQuesReduplicateConsumer extends Consumer<Course> {
|
|
|
continue;
|
|
|
}
|
|
|
String quesText2 = subdto.getExtractText();
|
|
|
- double similarity = StringSimilarityUtils.getSimilarityWithCosinesBySeg(quesText1, quesText2);
|
|
|
- if (similarity > 0.94) {
|
|
|
-// if (StringUtils.equals(quesText1, quesText2)) {
|
|
|
+// double similarity = StringSimilarityUtils.getSimilarityWithCosinesBySeg(quesText1, quesText2);
|
|
|
+// if (similarity > 0.94) {
|
|
|
+ if (StringUtils.equals(quesText1, quesText2)) {
|
|
|
checkIds.add(dto.getId());
|
|
|
checkIds.add(subdto.getId());
|
|
|
if (!hasGroup) {
|