|
@@ -718,14 +718,36 @@ public class ExportPaperServiceImpl implements ExportPaperService {
|
|
|
List<Question> questionList = this.mongoTemplate.find(query, Question.class);
|
|
|
return questionList;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- System.out.println("a");
|
|
|
- Map<Long, Long> map = new HashMap<Long, Long>();
|
|
|
- map.put(1l, 1l);
|
|
|
- map.put(1l, 2l);
|
|
|
- System.out.println(map.get(1l));
|
|
|
+
|
|
|
+ public List<Question> questionList2(String courseNo, CourseProperty courseProperty, QuesStructType quesStructType, Property parentProperty, Property sonProperty,List<Question> questions) {
|
|
|
+ List<Question> questionList = new ArrayList<Question>();
|
|
|
+ String id = courseNo + quesStructType.name() + courseProperty.getName();
|
|
|
+ //二级属性不为空,那么一级属性也不为空
|
|
|
+ if (sonProperty != null && sonProperty.getId() != null) {
|
|
|
+ id = id + parentProperty.getId() + sonProperty.getId();
|
|
|
+ } else {
|
|
|
+ if (parentProperty != null && parentProperty.getId() != null) {
|
|
|
+ id = id + parentProperty.getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(Question question:questions){
|
|
|
+ List<String> idStrings = new ArrayList<String>();
|
|
|
+ String id_Q = question.getCourseNo() + question.getQuestionType();
|
|
|
+ List<QuesProperty> quesProperties = question.getQuesProperties();
|
|
|
+ if(quesProperties != null && quesProperties.size()>0){
|
|
|
+ for(QuesProperty property:quesProperties){
|
|
|
+ String idP = id_Q + property.getCoursePropertyName() + property.getFirstProperty().getId();
|
|
|
+ if(property.getSecondProperty() != null){
|
|
|
+ idP = id_Q + property.getCoursePropertyName() + property.getFirstProperty().getId() + property.getSecondProperty().getId();
|
|
|
+ }
|
|
|
+ idStrings.add(idP);
|
|
|
+ }
|
|
|
+ if(idStrings.contains(id)){
|
|
|
+ questionList.add(question);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return questionList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -770,5 +792,74 @@ public class ExportPaperServiceImpl implements ExportPaperService {
|
|
|
byte[] pkgByte = quesPkg.getQuesPkg();
|
|
|
return DocxProcessUtil.getPkg(pkgByte);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void downQuestionDistributeByPapers(String paperIds, HttpServletResponse response) throws IOException {
|
|
|
+ List<QuestionDistributeDto> questionDistributeDtos = new ArrayList<QuestionDistributeDto>();
|
|
|
+ //定义课程集合
|
|
|
+ List<String> courseNos = new ArrayList<String>();
|
|
|
+ //定义试题集合
|
|
|
+ List<Question> questions = new ArrayList<Question>();
|
|
|
+ // 查询试卷集合
|
|
|
+ String[] paperIdArray = paperIds.split(",");
|
|
|
+ for (int i = 0; i < paperIdArray.length; i++) {
|
|
|
+ Paper basePaper = paperRepo.findOne(paperIdArray[i]);
|
|
|
+ courseNos.add(basePaper.getCourse().getCode());
|
|
|
+ //将小题全部取出来,只取一次,减少对数据库的查询
|
|
|
+ List<PaperDetailUnit> allPaperDetailUnits = paperDetailUnitRepo.findByPaper(basePaper);
|
|
|
+ for(PaperDetailUnit unit:allPaperDetailUnits){
|
|
|
+ if(unit.getQuestionType().equals(QuesStructType.SINGLE_ANSWER_QUESTION)||unit.getQuestionType().equals(QuesStructType.MULTIPLE_ANSWER_QUESTION)||unit.getQuestionType().equals(QuesStructType.BOOL_ANSWER_QUESTION)){
|
|
|
+ questions.add(unit.getQuestion());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //根据课程code查询课程属性集合
|
|
|
+ for(String courseNo:courseNos){
|
|
|
+ List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCodeAndEnable(courseNo, true);
|
|
|
+ //遍历课程属性集合,根据课程属性查询一级
|
|
|
+ if (courseProperties != null && courseProperties.size() > 0) {
|
|
|
+ for (CourseProperty courseProperty : courseProperties) {
|
|
|
+ List<Property> parentProperties = propertyService.findPropertyParents(courseProperty.getId(), courseProperty.getOrgId());
|
|
|
+ if (parentProperties != null && parentProperties.size() > 0) {
|
|
|
+ for (Property parentProperty : parentProperties) {
|
|
|
+ List<Property> sonProperties = propertyService.findPropertySons(parentProperty.getId());
|
|
|
+ if (sonProperties != null && sonProperties.size() > 0) {
|
|
|
+ for (Property sonProperty : sonProperties) {
|
|
|
+ //单选题集合
|
|
|
+ List<Question> sinList = questionList2(courseNo, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, sonProperty,questions);
|
|
|
+ //多选题集合
|
|
|
+ List<Question> mulList = questionList2(courseNo, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, sonProperty,questions);
|
|
|
+ //判断题集合
|
|
|
+ List<Question> bolList = questionList2(courseNo, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, sonProperty,questions);
|
|
|
+ //计算所有题型数量
|
|
|
+ Map<Long, Long> map = countQuesType(sinList, mulList, bolList);
|
|
|
+ QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), sonProperty.getName(), map);
|
|
|
+ questionDistributeDtos.add(questionDistributeDto);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //一级属性不为空,二级属性为空
|
|
|
+ //单选题集合
|
|
|
+ List<Question> sinList = questionList2(courseNo, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, null,questions);
|
|
|
+ //多选题集合
|
|
|
+ List<Question> mulList = questionList2(courseNo, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, null,questions);
|
|
|
+ //判断题集合
|
|
|
+ List<Question> bolList = questionList2(courseNo, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, null,questions);
|
|
|
+ //计算所有题型数量
|
|
|
+ Map<Long, Long> map = countQuesType(sinList, mulList, bolList);
|
|
|
+ QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), null, map);
|
|
|
+ questionDistributeDtos.add(questionDistributeDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //一级属性为空
|
|
|
+ QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), null, null, null);
|
|
|
+ questionDistributeDtos.add(questionDistributeDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //生成Excel导出
|
|
|
+ writeExcel(questionDistributeDtos, 21, new Date().toString(), response);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|