deason 2 yıl önce
ebeveyn
işleme
98c3d82905

+ 66 - 1
src/main/java/cn/com/qmth/examcloud/tool/service/update_correct_answer_and_re_fix_score/UpdateCorrectAnswerAndReFixScoreTask.java

@@ -4,10 +4,15 @@ 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.service.update_correct_answer_and_re_fix_score.vo.ExamStudentVO;
+import cn.com.qmth.examcloud.tool.utils.HttpHelper;
 import cn.com.qmth.examcloud.tool.utils.JsonMapper;
 import cn.com.qmth.examcloud.tool.utils.StatusException;
+import cn.com.qmth.examcloud.tool.vo.Pager;
 import cn.com.qmth.examcloud.tool.vo.User;
+import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -15,7 +20,9 @@ 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;
 
 @Component
 public class UpdateCorrectAnswerAndReFixScoreTask {
@@ -68,7 +75,65 @@ public class UpdateCorrectAnswerAndReFixScoreTask {
     }
 
     public void process(Long examId, CourseVO course, User user) {
-        // todo
+        List<ExamStudentVO> examStudents = this.getExamStudentList(user.getKey(), user.getToken(), examId, course.getCourseId());
+
+        for (ExamStudentVO examStudent : examStudents) {
+            // 按考生逐个更新正确答案并重新算分
+            this.fix(user.getKey(), user.getToken(), examId, course.getCourseId(), examStudent.getExamStudentId());
+        }
+
+        examStudents.clear();
+    }
+
+    private void fix(String key, String token, Long examId, Long courseId, Long examStudentId) {
+        Map<String, String> params = new HashMap<>();
+        params.put("examId", String.valueOf(examId));
+        params.put("courseId", String.valueOf(courseId));
+        params.put("examStudentId", String.valueOf(examStudentId));
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("key", key);
+        headers.put("token", token);
+
+        String url = sysProperty.getServerUrl() + "/api/ecs_oe_admin/exam/score/updateCorrectAnswerAndReFixScore";
+        HttpHelper.get(url, headers, params);
+    }
+
+    /**
+     * 获取网考考生列表
+     */
+    private List<ExamStudentVO> getExamStudentList(String key, String token, Long examId, Long courseId) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("examId", examId);
+        params.put("courseId", courseId);
+        params.put("pageSize", 500);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("key", key);
+        headers.put("token", token);
+
+        String url = sysProperty.getServerUrl() + "/api/ecs_oe_admin/exam/student/simple/list";
+        List<ExamStudentVO> all = new ArrayList<>();
+        JsonMapper jsonMapper = new JsonMapper();
+
+        int sum = 0, pageNo = 0;
+        while (true) {
+            params.put("pageNo", ++pageNo);
+            String json = HttpHelper.post(url, headers, params);
+
+            Pager<ExamStudentVO> page = jsonMapper.parseJson(json, new TypeReference<Pager<ExamStudentVO>>() {
+            });
+            if (page == null || CollectionUtils.isEmpty(page.getContent())) {
+                break;
+            }
+            all.addAll(page.getContent());
+
+            sum += page.getContent().size();
+            float rate = sum * 100f / page.getTotalElements();
+            log.info("examId={} courseId={} 已获取考生数:{} 进度:{}%", examId, courseId, sum, rate);
+        }
+
+        return all;
     }
 
 }

+ 136 - 0
src/main/java/cn/com/qmth/examcloud/tool/service/update_correct_answer_and_re_fix_score/vo/ExamStudentVO.java

@@ -0,0 +1,136 @@
+package cn.com.qmth.examcloud.tool.service.update_correct_answer_and_re_fix_score.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+@Setter
+@Getter
+public class ExamStudentVO implements Serializable {
+
+    private static final long serialVersionUID = -4647126917276922968L;
+
+    private Long id;
+
+    /**
+     * 考生ID(与考务的考生ID一致) 跟其他表关联使用
+     */
+    private Long examStudentId;
+
+    /**
+     * 考试ID
+     */
+    private Long examId;
+
+    /**
+     * 学生ID
+     */
+    private Long studentId;
+
+    /**
+     * 学号
+     */
+    private String studentCode;
+
+    /**
+     * 学生姓名
+     */
+    private String studentName;
+
+    /**
+     * 身份证号
+     */
+    private String identityNumber;
+
+    /**
+     * 课程ID
+     */
+    private Long courseId;
+
+    /**
+     * 课程Code
+     */
+    private String courseCode;
+
+    /**
+     * 课程层次
+     */
+    private String courseLevel;
+
+    /**
+     * 学习中心ID
+     */
+    private Long orgId;
+
+    /**
+     * 顶级机构ID
+     */
+    private Long rootOrgId;
+
+    /**
+     * 专业code
+     */
+    private String specialtyCode;
+
+    /**
+     * 专业名称
+     */
+    private String specialtyName;
+
+    /**
+     * 试卷类型
+     */
+    private String paperType;
+
+    /**
+     * 采集人
+     */
+    private String infoCollector;
+
+    /**
+     * 是否完成考试
+     */
+    private Boolean finished;
+
+    /**
+     * 已经考试的次数
+     */
+    private Integer usedNum;
+
+    /**
+     * 补加的考试次数
+     */
+    private Integer extraNum;
+
+    /**
+     * 年级
+     */
+    private String grade;
+
+    /**
+     * 是否可用
+     */
+    private Boolean enable;
+
+    /**
+     * 重考理由
+     */
+    private String reexamineType;
+
+    /**
+     * 重考理由详情
+     */
+    private String reexamineDetail;
+
+    /**
+     * 场次id
+     */
+    private Long examStageId;
+
+    /**
+     * 场次号
+     */
+    private Integer examStageOrder;
+
+}