|
@@ -6,6 +6,7 @@ import cn.com.qmth.examcloud.tool.service.export_student_answer_and_score_detail
|
|
|
import cn.com.qmth.examcloud.tool.service.query_paper_struct.vo.ExamPaperVO;
|
|
|
import cn.com.qmth.examcloud.tool.service.query_paper_struct.vo.ExtractConfigVO;
|
|
|
import cn.com.qmth.examcloud.tool.service.query_paper_struct.vo.GetPaperStructResp;
|
|
|
+import cn.com.qmth.examcloud.tool.utils.ExcelHelper;
|
|
|
import cn.com.qmth.examcloud.tool.utils.HttpHelper;
|
|
|
import cn.com.qmth.examcloud.tool.utils.JsonMapper;
|
|
|
import cn.com.qmth.examcloud.tool.utils.SignUtils;
|
|
@@ -14,13 +15,16 @@ import cn.com.qmth.examcloud.tool.vo.paper.DefaultQuestionGroup;
|
|
|
import cn.com.qmth.examcloud.tool.vo.paper.DefaultQuestionStructureWrapper;
|
|
|
import cn.com.qmth.examcloud.tool.vo.paper.DefaultQuestionUnitWrapper;
|
|
|
import cn.com.qmth.examcloud.tool.vo.user.User;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -46,13 +50,14 @@ public class QueryPaperStructTask {
|
|
|
headers.put("token", user.getToken());
|
|
|
|
|
|
List<CourseVO> courses = commonService.getExamCourseList(user, examId);
|
|
|
- log.info("examId:{}, 课程数为:{}", examId, courses.size());
|
|
|
+ log.info("考试Id:{}, 课程数为:{}", examId, courses.size());
|
|
|
|
|
|
+ List<List<String>> excelRows = new ArrayList<>();
|
|
|
for (CourseVO course : courses) {
|
|
|
List<ExtractConfigVO> extractConfigs = this.getExtractConfig(user, examId, course.getCourseCode());
|
|
|
if (CollectionUtils.isEmpty(extractConfigs)) {
|
|
|
// 若当前账号未配相关数据权限,则会取不到调卷规则数据,请更换账号!!
|
|
|
- log.info("examId:{}, courseId:{}, courseCode:{}, 未配置调卷规则!", examId, course.getCourseId(),
|
|
|
+ log.info("考试Id:{}, 课程Id:{}, 课程代码:{}, 未配置调卷规则!", examId, course.getCourseId(),
|
|
|
course.getCourseCode());
|
|
|
continue;
|
|
|
}
|
|
@@ -60,33 +65,46 @@ public class QueryPaperStructTask {
|
|
|
for (ExtractConfigVO extractConfig : extractConfigs) {
|
|
|
for (ExamPaperVO examPaper : extractConfig.getExamPaperList()) {
|
|
|
String basePaperId = examPaper.getPaper().getId();
|
|
|
- GetPaperStructResp resp = this.getPaperStruct(examId, course.getCourseCode(),
|
|
|
- examPaper.getGroupCode(), basePaperId);
|
|
|
- System.out.println("\n========== ========== ==========");
|
|
|
- System.out.println(
|
|
|
- String.format("examId:%s courseId:%s courseCode:%s paperType:%s basePaperId:%s 试卷名称:%s",
|
|
|
- examId, course.getCourseId(), course.getCourseCode(), examPaper.getGroupCode(),
|
|
|
- basePaperId, resp.getDefaultPaper().getName()));
|
|
|
- System.out.println("========== ========== ==========");
|
|
|
- List<DefaultQuestionGroup> questionGroupList = resp.getDefaultPaper().getQuestionGroupList();
|
|
|
-
|
|
|
- int index = 0;
|
|
|
- for (int i = 0; i < questionGroupList.size(); i++) {
|
|
|
- DefaultQuestionGroup questionGroup = questionGroupList.get(i);
|
|
|
- List<DefaultQuestionStructureWrapper> questionWrapperList = questionGroup.getQuestionWrapperList();
|
|
|
-
|
|
|
- for (int j = 0; j < questionWrapperList.size(); j++) {
|
|
|
- DefaultQuestionStructureWrapper questionStructure = questionWrapperList.get(j);
|
|
|
- List<DefaultQuestionUnitWrapper> questionUnitWrapperList = questionStructure.getQuestionUnitWrapperList();
|
|
|
-
|
|
|
- for (int k = 0; k < questionUnitWrapperList.size(); k++) {
|
|
|
- DefaultQuestionUnitWrapper questionUnit = questionUnitWrapperList.get(k);
|
|
|
-
|
|
|
- System.out.println(String.format("试题ID:%s %s%s-%s", questionStructure.getQuestionId(),
|
|
|
- questionUnit.getQuestionType().getDesc(), i + 1, ++index));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ String basePaperName = examPaper.getPaper().getName();
|
|
|
+ System.out.printf("%n%n 考试Id:%s 课程代码:%s 课程名称:%s 抽题模式:%s 权重比例:%s 试卷类型:%s 试卷Id:%s 试卷名称:%s",
|
|
|
+ examId, course.getCourseCode(), course.getCourseName(), extractConfig.getCallType(),
|
|
|
+ examPaper.getWeight(), examPaper.getGroupCode(), basePaperId, basePaperName);
|
|
|
+
|
|
|
+ List<String> rowValues = Lists.newArrayList(examId.toString(), course.getCourseCode(),
|
|
|
+ course.getCourseName(), extractConfig.getCallType(), examPaper.getWeight().toString(),
|
|
|
+ examPaper.getGroupCode(), basePaperId, basePaperName);
|
|
|
+ excelRows.add(rowValues);
|
|
|
+
|
|
|
+ // this.printPaperStruct(examId, course, examPaper, basePaperId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ final String filePath = "D:/result_" + examId + ".xlsx";
|
|
|
+ List<String> excelHeaders = Lists.newArrayList("考试Id", "课程代码", "课程名称", "抽题模式", "权重比例", "试卷类型", "试卷Id", "试卷名称");
|
|
|
+ EasyExcel.write(filePath).head(ExcelHelper.buildHeaders(excelHeaders))
|
|
|
+ .registerWriteHandler(ExcelHelper.sheetStrategy()).registerWriteHandler(ExcelHelper.styleStrategy())
|
|
|
+ .sheet().doWrite(excelRows);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void printPaperStruct(Long examId, CourseVO course, ExamPaperVO examPaper, String basePaperId) {
|
|
|
+ GetPaperStructResp resp = this.getPaperStruct(examId, course.getCourseCode(), examPaper.getGroupCode(), basePaperId);
|
|
|
+ List<DefaultQuestionGroup> questionGroupList = resp.getDefaultPaper().getQuestionGroupList();
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
+ for (int i = 0; i < questionGroupList.size(); i++) {
|
|
|
+ DefaultQuestionGroup questionGroup = questionGroupList.get(i);
|
|
|
+ List<DefaultQuestionStructureWrapper> questionWrapperList = questionGroup.getQuestionWrapperList();
|
|
|
+
|
|
|
+ for (int j = 0; j < questionWrapperList.size(); j++) {
|
|
|
+ DefaultQuestionStructureWrapper questionStructure = questionWrapperList.get(j);
|
|
|
+ List<DefaultQuestionUnitWrapper> questionUnitWrapperList = questionStructure.getQuestionUnitWrapperList();
|
|
|
+
|
|
|
+ for (int k = 0; k < questionUnitWrapperList.size(); k++) {
|
|
|
+ DefaultQuestionUnitWrapper questionUnit = questionUnitWrapperList.get(k);
|
|
|
+
|
|
|
+ System.out.printf("%n 试题ID:%s %s%s-%s", questionStructure.getQuestionId(),
|
|
|
+ questionUnit.getQuestionType().getDesc(), i + 1, ++index);
|
|
|
}
|
|
|
}
|
|
|
}
|