|
@@ -1,18 +1,74 @@
|
|
|
package cn.com.qmth.examcloud.tool.service.update_correct_answer_and_re_fix_score;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.tool.config.SysProperty;
|
|
|
import cn.com.qmth.examcloud.tool.entity.TaskEntity;
|
|
|
+import cn.com.qmth.examcloud.tool.service.CommonService;
|
|
|
+import cn.com.qmth.examcloud.tool.service.export_student_answer_and_score_detail.vo.CourseVO;
|
|
|
+import cn.com.qmth.examcloud.tool.utils.JsonMapper;
|
|
|
import cn.com.qmth.examcloud.tool.utils.StatusException;
|
|
|
+import cn.com.qmth.examcloud.tool.vo.User;
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
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.List;
|
|
|
+
|
|
|
@Component
|
|
|
public class UpdateCorrectAnswerAndReFixScoreTask {
|
|
|
|
|
|
private final static Logger log = LoggerFactory.getLogger(UpdateCorrectAnswerAndReFixScoreTask.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CommonService commonService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysProperty sysProperty;
|
|
|
+
|
|
|
public void start(TaskEntity task) {
|
|
|
- throw new StatusException("。。。");
|
|
|
+ JsonNode jsonParams = new JsonMapper().getNode(task.getParams());
|
|
|
+ if (jsonParams == null) {
|
|
|
+ throw new StatusException("任务参数解析错误!");
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = commonService.login(sysProperty.getServerDomain(), sysProperty.getServerLoginName(), sysProperty.getServerPassword());
|
|
|
+ this.execute(jsonParams, user);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void execute(JsonNode jsonParams, User user) {
|
|
|
+ Long examId = jsonParams.get("examId").asLong(0L);
|
|
|
+ String courseCodes = jsonParams.get("courseCodes").asText("");
|
|
|
+ log.info("examId = {}, courseCodes = {}", examId, courseCodes);
|
|
|
+
|
|
|
+ // 待处理的课程列表(未指定课程则按考试的全部课程)
|
|
|
+ List<CourseVO> todoCourses;
|
|
|
+ List<CourseVO> courses = commonService.getExamCourseList(user.getKey(), user.getToken(), examId);
|
|
|
+ if (StringUtils.isNotBlank(courseCodes)) {
|
|
|
+ todoCourses = new ArrayList<>();
|
|
|
+ String[] courseCodeList = StringUtils.split(courseCodes, ",");
|
|
|
+ for (String courseCode : courseCodeList) {
|
|
|
+ for (CourseVO vo : courses) {
|
|
|
+ if (vo.getCourseCode().equals(courseCode)) {
|
|
|
+ todoCourses.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ todoCourses = courses;
|
|
|
+ }
|
|
|
+ log.info("待处理的课程数为:{}", todoCourses.size());
|
|
|
+
|
|
|
+ for (CourseVO course : todoCourses) {
|
|
|
+ // 按考试课程逐个处理
|
|
|
+ this.process(examId, course, user);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void process(Long examId, CourseVO course, User user) {
|
|
|
+ // todo
|
|
|
}
|
|
|
|
|
|
}
|