|
@@ -48,56 +48,74 @@ public class CreateRandomPaperTemplateTask {
|
|
|
throw new StatusException("用户未登录!");
|
|
|
}
|
|
|
|
|
|
- this.execute(user, jsonParams);
|
|
|
+ this.execute(user, jsonParams, task);
|
|
|
}
|
|
|
|
|
|
- private void execute(User user, JsonNode jsonParams) {
|
|
|
+ private void execute(User user, JsonNode jsonParams, TaskEntity task) {
|
|
|
Long examId = jsonParams.get("examId").asLong(0L);
|
|
|
Integer questionPool = jsonParams.get("questionPool").asInt(1);
|
|
|
String structType = jsonParams.get("structType").asInt(1) == 1 ? "EXACT" : "BLUEPRINT";
|
|
|
String structName = jsonParams.get("structName").asText("");
|
|
|
String paperKeywords = jsonParams.get("paperKeywords").asText("");
|
|
|
|
|
|
- log.info("examId = {}, questionPool = {}, structType = {}, structName = {}, paperKeywords = {}", examId,
|
|
|
- questionPool, structType, structName, paperKeywords);
|
|
|
+ log.info("examId:{} questionPool:{} structType:{} structName:{} paperKeywords:{}", examId, questionPool,
|
|
|
+ structType, structName, paperKeywords);
|
|
|
|
|
|
List<CourseVO> courses = commonService.getExamCourseList(user, examId);
|
|
|
- log.info("examId:{}, 待处理的课程数为:{}", examId, courses.size());
|
|
|
+ log.info("待处理课程总数为:{} examId:{}", courses.size(), examId);
|
|
|
|
|
|
if (courses.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
int index = 0;
|
|
|
+ List<String> messages = new ArrayList<>();
|
|
|
+
|
|
|
for (CourseVO course : courses) {
|
|
|
// 按考试课程逐个处理
|
|
|
index++;
|
|
|
|
|
|
if (this.existRandomPaperTemplate(user, course.getCourseId())) {
|
|
|
- log.warn("examId:{} courseId:{} 已处理课程数:{} 已存在随机抽卷模板!", examId, course.getCourseId(),
|
|
|
- index);
|
|
|
+ String msg = String.format("【%s】 课程代码:%s 已存在随机抽卷模板!", index, course.getCourseCode());
|
|
|
+ messages.add(msg);
|
|
|
+ log.warn(msg);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 获取试卷结构
|
|
|
String paperStructId = this.getPaperStructId(user, course.getCourseCode(), structType, structName);
|
|
|
if (paperStructId == null) {
|
|
|
- log.warn("examId:{} courseId:{} 已处理课程数:{} 未找到试卷结构!", examId, course.getCourseId(), index);
|
|
|
+ String msg = String.format("【%s】 课程代码:%s 未找到试卷结构!", index, course.getCourseCode());
|
|
|
+ messages.add(msg);
|
|
|
+ log.warn(msg);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 获取试卷列表
|
|
|
List<String> paperIds = this.getPapers(user, course.getCourseCode(), questionPool, paperKeywords);
|
|
|
if (paperIds.isEmpty()) {
|
|
|
- log.warn("examId:{} courseId:{} 已处理课程数:{} 未找到相关试卷!", examId, course.getCourseId(), index);
|
|
|
+ String msg = String.format("【%s】 课程代码:%s 未找到相关试卷!", index, course.getCourseCode());
|
|
|
+ messages.add(msg);
|
|
|
+ log.warn(msg);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 保存随机抽卷模板
|
|
|
- this.saveRandomPaperTemplate(user, course.getCourseId(), structType, paperStructId, questionPool, paperIds);
|
|
|
+ try {
|
|
|
+ this.saveRandomPaperTemplate(user, course, structType, paperStructId, questionPool, paperIds);
|
|
|
+ } catch (Exception e) {
|
|
|
+ String msg = String.format("【%s】 课程代码:%s 处理失败!%s", index, course.getCourseCode(),
|
|
|
+ e.getMessage());
|
|
|
+ messages.add(msg);
|
|
|
+ log.warn(msg);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- log.info("examId:{} courseId:{} 已处理课程数:{}", examId, course.getCourseId(), index);
|
|
|
+ String msg = String.format("【%s】 课程代码:%s 处理完成!", index, course.getCourseCode());
|
|
|
+ log.info(msg);
|
|
|
}
|
|
|
+
|
|
|
+ task.setDescription(StringUtils.join(messages, "\n"));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -118,6 +136,7 @@ public class CreateRandomPaperTemplateTask {
|
|
|
JsonMapper jsonMapper = new JsonMapper();
|
|
|
List<PaperStructVO> list = jsonMapper.toList(json, PaperStructVO.class);
|
|
|
for (PaperStructVO vo : list) {
|
|
|
+ log.info("courseCode:{} paperStructId:{} structName:{}", courseCode, vo.getId(), vo.getName());
|
|
|
if (vo.getName().equals(structName)) {
|
|
|
return vo.getId();
|
|
|
}
|
|
@@ -172,6 +191,7 @@ public class CreateRandomPaperTemplateTask {
|
|
|
|
|
|
List<String> paperIds = new ArrayList<>();
|
|
|
for (PaperVO vo : page.getContent()) {
|
|
|
+ log.info("courseCode:{} paperId:{} paperName:{}", courseCode, vo.getId(), vo.getName());
|
|
|
for (String keyword : keywords) {
|
|
|
if (vo.getName().contains(keyword)) {
|
|
|
paperIds.add(vo.getId());
|
|
@@ -186,7 +206,7 @@ public class CreateRandomPaperTemplateTask {
|
|
|
/**
|
|
|
* 保存随机抽卷模板
|
|
|
*/
|
|
|
- public void saveRandomPaperTemplate(User user, Long courseId, String paperStructType, String paperStructId,
|
|
|
+ public void saveRandomPaperTemplate(User user, CourseVO course, String paperStructType, String paperStructId,
|
|
|
Integer questionPool, List<String> paperIds) {
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("key", user.getKey());
|
|
@@ -195,8 +215,8 @@ public class CreateRandomPaperTemplateTask {
|
|
|
String paperType = questionPool == 1 ? "IMPORT" : "GENERATE";
|
|
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
- params.put("name", "todo");//todo
|
|
|
- params.put("courseId", courseId.toString());
|
|
|
+ params.put("name", course.getCourseName() + "抽卷模板");//todo
|
|
|
+ params.put("courseId", String.valueOf(course.getCourseId()));
|
|
|
params.put("paperStructType", paperStructType);
|
|
|
params.put("paperStructId", paperStructId);
|
|
|
params.put("paperType", paperType);
|