deason 1 жил өмнө
parent
commit
656096c863

+ 3 - 3
src/main/java/cn/com/qmth/examcloud/tool/service/batch_import_exam_student/BatchImportExamStudentTask.java

@@ -43,12 +43,12 @@ public class BatchImportExamStudentTask implements TaskService {
 
 
     @Override
     @Override
     public void start(TaskEntity task) {
     public void start(TaskEntity task) {
-        User user = LoginSessionManager.getLoginSession(task.getUserToken());
-        if (user == null) {
+        User loginUser = LoginSessionManager.getLoginSession(task.getUserToken());
+        if (loginUser == null) {
             throw new StatusException("用户未登录!");
             throw new StatusException("用户未登录!");
         }
         }
 
 
-        this.execute(user, task);
+        this.execute(loginUser, task);
     }
     }
 
 
     private void execute(User loginUser, TaskEntity task) {
     private void execute(User loginUser, TaskEntity task) {

+ 15 - 15
src/main/java/cn/com/qmth/examcloud/tool/service/config_exam_paper/ConfigExamPaperTask.java

@@ -35,27 +35,27 @@ public class ConfigExamPaperTask implements TaskService {
 
 
     @Override
     @Override
     public void start(TaskEntity task) {
     public void start(TaskEntity task) {
-        JsonNode jsonParams = new JsonMapper().getNode(task.getParams());
-        if (jsonParams == null) {
-            throw new StatusException("任务参数解析错误!");
-        }
-
-        User user = LoginSessionManager.getLoginSession(task.getUserToken());
-        if (user == null) {
+        User loginUser = LoginSessionManager.getLoginSession(task.getUserToken());
+        if (loginUser == null) {
             throw new StatusException("用户未登录!");
             throw new StatusException("用户未登录!");
         }
         }
 
 
-        this.execute(user, jsonParams);
+        this.execute(loginUser, task);
     }
     }
 
 
-    private void execute(User user, JsonNode jsonParams) {
+    private void execute(User loginUser, TaskEntity task) {
+        JsonNode jsonParams = new JsonMapper().getNode(task.getParams());
+        if (jsonParams == null) {
+            throw new StatusException("任务参数解析错误!");
+        }
+
         Long examId = jsonParams.get("examId").asLong(0L);
         Long examId = jsonParams.get("examId").asLong(0L);
         String courseCodes = jsonParams.get("courseCodes").asText("");
         String courseCodes = jsonParams.get("courseCodes").asText("");
         log.info("examId = {}, courseCodes = {}", examId, courseCodes);
         log.info("examId = {}, courseCodes = {}", examId, courseCodes);
 
 
         // 待处理的课程列表(未指定课程则按考试的全部课程)
         // 待处理的课程列表(未指定课程则按考试的全部课程)
         List<CourseVO> todoCourses;
         List<CourseVO> todoCourses;
-        List<CourseVO> courses = commonService.getExamCourseList(user, examId);
+        List<CourseVO> courses = commonService.getExamCourseList(loginUser, examId);
         if (StringUtils.isNotBlank(courseCodes)) {
         if (StringUtils.isNotBlank(courseCodes)) {
             todoCourses = new ArrayList<>();
             todoCourses = new ArrayList<>();
             String[] courseCodeList = StringUtils.split(courseCodes, ",");
             String[] courseCodeList = StringUtils.split(courseCodes, ",");
@@ -75,7 +75,7 @@ public class ConfigExamPaperTask implements TaskService {
         for (CourseVO course : todoCourses) {
         for (CourseVO course : todoCourses) {
             // 按考试课程逐个处理
             // 按考试课程逐个处理
             try {
             try {
-                this.process(user, examId, course);
+                this.process(loginUser, examId, course);
             } catch (Exception e) {
             } catch (Exception e) {
                 errors.add(String.format("课程代码:%s  处理失败:%s", course.getCourseCode(), e.getMessage()));
                 errors.add(String.format("课程代码:%s  处理失败:%s", course.getCourseCode(), e.getMessage()));
             }
             }
@@ -88,17 +88,17 @@ public class ConfigExamPaperTask implements TaskService {
         }
         }
     }
     }
 
 
-    public void process(User user, Long examId, CourseVO course) {
+    public void process(User loginUser, Long examId, CourseVO course) {
         // 按课程逐个配置考试调卷规则
         // 按课程逐个配置考试调卷规则
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
         Map<String, Object> params = new HashMap<>();
         Map<String, Object> params = new HashMap<>();
         params.put("examId", examId);
         params.put("examId", examId);
         params.put("courseCode", course.getCourseCode());
         params.put("courseCode", course.getCourseCode());
 
 
-        final String url = user.getServerUrl() + "/api/ecs_ques/extract_config/randompaper/save";
+        final String url = loginUser.getServerUrl() + "/api/ecs_ques/extract_config/randompaper/save";
         HttpHelper.post(url, headers, params);
         HttpHelper.post(url, headers, params);
         log.info("examId:{} courseId:{} courseCode:{} 已处理!", examId, course.getCourseId(), course.getCourseCode());
         log.info("examId:{} courseId:{} courseCode:{} 已处理!", examId, course.getCourseId(), course.getCourseCode());
     }
     }

+ 33 - 33
src/main/java/cn/com/qmth/examcloud/tool/service/create_random_paper_template/CreateRandomPaperTemplateTask.java

@@ -41,20 +41,20 @@ public class CreateRandomPaperTemplateTask implements TaskService {
 
 
     @Override
     @Override
     public void start(TaskEntity task) {
     public void start(TaskEntity task) {
-        JsonNode jsonParams = new JsonMapper().getNode(task.getParams());
-        if (jsonParams == null) {
-            throw new StatusException("任务参数解析错误!");
-        }
-
-        User user = LoginSessionManager.getLoginSession(task.getUserToken());
-        if (user == null) {
+        User loginUser = LoginSessionManager.getLoginSession(task.getUserToken());
+        if (loginUser == null) {
             throw new StatusException("用户未登录!");
             throw new StatusException("用户未登录!");
         }
         }
 
 
-        this.execute(user, jsonParams, task);
+        this.execute(loginUser, task);
     }
     }
 
 
-    private void execute(User user, JsonNode jsonParams, TaskEntity task) {
+    private void execute(User loginUser, TaskEntity task) {
+        JsonNode jsonParams = new JsonMapper().getNode(task.getParams());
+        if (jsonParams == null) {
+            throw new StatusException("任务参数解析错误!");
+        }
+
         Long examId = jsonParams.get("examId").asLong(0L);
         Long examId = jsonParams.get("examId").asLong(0L);
         String questionPool = jsonParams.get("questionPool").asInt(1) == 1 ? "IMPORT" : "GENERATE";
         String questionPool = jsonParams.get("questionPool").asInt(1) == 1 ? "IMPORT" : "GENERATE";
         String structType = jsonParams.get("structType").asInt(1) == 1 ? "EXACT" : "BLUEPRINT";
         String structType = jsonParams.get("structType").asInt(1) == 1 ? "EXACT" : "BLUEPRINT";
@@ -73,7 +73,7 @@ public class CreateRandomPaperTemplateTask implements TaskService {
         log.info("examId:{} questionPool:{} structType:{} structName:{} paperKeywords:{} paperStartTime:{}", examId,
         log.info("examId:{} questionPool:{} structType:{} structName:{} paperKeywords:{} paperStartTime:{}", examId,
                 questionPool, structType, structName, paperKeywords, paperStartTime);
                 questionPool, structType, structName, paperKeywords, paperStartTime);
 
 
-        List<CourseVO> courses = commonService.getExamCourseList(user, examId);
+        List<CourseVO> courses = commonService.getExamCourseList(loginUser, examId);
         log.info("待处理课程总数为:{} examId:{}", courses.size(), examId);
         log.info("待处理课程总数为:{} examId:{}", courses.size(), examId);
 
 
         if (courses.isEmpty()) {
         if (courses.isEmpty()) {
@@ -87,7 +87,7 @@ public class CreateRandomPaperTemplateTask implements TaskService {
             // 按考试课程逐个处理
             // 按考试课程逐个处理
             index++;
             index++;
 
 
-            if (this.existRandomPaperTemplate(user, course.getCourseId())) {
+            if (this.existRandomPaperTemplate(loginUser, course.getCourseId())) {
                 String msg = String.format("【%s】 课程代码:%s 已存在随机抽卷模板!", index, course.getCourseCode());
                 String msg = String.format("【%s】 课程代码:%s 已存在随机抽卷模板!", index, course.getCourseCode());
                 messages.add(msg);
                 messages.add(msg);
                 log.warn(msg);
                 log.warn(msg);
@@ -95,7 +95,7 @@ public class CreateRandomPaperTemplateTask implements TaskService {
             }
             }
 
 
             // 获取试卷结构
             // 获取试卷结构
-            String paperStructId = this.getPaperStructId(user, course.getCourseCode(), structType, structName);
+            String paperStructId = this.getPaperStructId(loginUser, course.getCourseCode(), structType, structName);
             if (paperStructId == null) {
             if (paperStructId == null) {
                 String msg = String.format("【%s】 课程代码:%s 未找到匹配的试卷结构!", index, course.getCourseCode());
                 String msg = String.format("【%s】 课程代码:%s 未找到匹配的试卷结构!", index, course.getCourseCode());
                 messages.add(msg);
                 messages.add(msg);
@@ -104,7 +104,7 @@ public class CreateRandomPaperTemplateTask implements TaskService {
             }
             }
 
 
             // 获取试卷列表
             // 获取试卷列表
-            List<String> paperIds = this.getPapers(user, course.getCourseCode(), questionPool, paperKeywords,
+            List<String> paperIds = this.getPapers(loginUser, course.getCourseCode(), questionPool, paperKeywords,
                     startTime);
                     startTime);
             if (paperIds.isEmpty()) {
             if (paperIds.isEmpty()) {
                 String msg = String.format("【%s】 课程代码:%s 未找到相关试卷!", index, course.getCourseCode());
                 String msg = String.format("【%s】 课程代码:%s 未找到相关试卷!", index, course.getCourseCode());
@@ -115,7 +115,7 @@ public class CreateRandomPaperTemplateTask implements TaskService {
 
 
             // 保存随机抽卷模板
             // 保存随机抽卷模板
             try {
             try {
-                this.saveRandomPaperTemplate(user, course, structType, paperStructId, questionPool, paperIds);
+                this.saveRandomPaperTemplate(loginUser, course, structType, paperStructId, questionPool, paperIds);
             } catch (Exception e) {
             } catch (Exception e) {
                 String msg = String.format("【%s】 课程代码:%s 处理失败!%s", index, course.getCourseCode(),
                 String msg = String.format("【%s】 课程代码:%s 处理失败!%s", index, course.getCourseCode(),
                         e.getMessage());
                         e.getMessage());
@@ -134,16 +134,16 @@ public class CreateRandomPaperTemplateTask implements TaskService {
     /**
     /**
      * 获取试卷结构信息
      * 获取试卷结构信息
      */
      */
-    private String getPaperStructId(User user, String courseCode, String structType, String structName) {
+    private String getPaperStructId(User loginUser, String courseCode, String structType, String structName) {
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
         Map<String, String> params = new HashMap<>();
         Map<String, String> params = new HashMap<>();
         params.put("courseNo", courseCode);
         params.put("courseNo", courseCode);
         params.put("type", structType);
         params.put("type", structType);
 
 
-        String url = user.getServerUrl() + "/api/ecs_ques/paperStruct";
+        String url = loginUser.getServerUrl() + "/api/ecs_ques/paperStruct";
         String json = HttpHelper.get(url, headers, params);
         String json = HttpHelper.get(url, headers, params);
 
 
         JsonMapper jsonMapper = new JsonMapper();
         JsonMapper jsonMapper = new JsonMapper();
@@ -161,12 +161,12 @@ public class CreateRandomPaperTemplateTask implements TaskService {
     /**
     /**
      * 判断课程是否已存在随机抽卷模板
      * 判断课程是否已存在随机抽卷模板
      */
      */
-    private boolean existRandomPaperTemplate(User user, Long courseId) {
+    private boolean existRandomPaperTemplate(User loginUser, Long courseId) {
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
-        String url = user.getServerUrl() + "/api/ecs_ques/randompaper/page?pageSize=1&courseId=" + courseId;
+        String url = loginUser.getServerUrl() + "/api/ecs_ques/randompaper/page?pageSize=1&courseId=" + courseId;
         String json = HttpHelper.post(url, headers, null);
         String json = HttpHelper.post(url, headers, null);
 
 
         JsonMapper jsonMapper = new JsonMapper();
         JsonMapper jsonMapper = new JsonMapper();
@@ -181,11 +181,11 @@ public class CreateRandomPaperTemplateTask implements TaskService {
     /**
     /**
      * 获取试卷列表
      * 获取试卷列表
      */
      */
-    private List<String> getPapers(User user, String courseCode, String questionPool, String paperKeywords,
-            Date paperStartTime) {
+    private List<String> getPapers(User loginUser, String courseCode, String questionPool, String paperKeywords,
+                                   Date paperStartTime) {
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
         Map<String, String> params = new HashMap<>();
         Map<String, String> params = new HashMap<>();
         params.put("courseNo", courseCode);
         params.put("courseNo", courseCode);
@@ -195,9 +195,9 @@ public class CreateRandomPaperTemplateTask implements TaskService {
 
 
         final String url;
         final String url;
         if ("IMPORT".equals(questionPool)) {
         if ("IMPORT".equals(questionPool)) {
-            url = user.getServerUrl() + "/api/ecs_ques/importPaper/huoge/%s/" + pageSize;
+            url = loginUser.getServerUrl() + "/api/ecs_ques/importPaper/huoge/%s/" + pageSize;
         } else {
         } else {
-            url = user.getServerUrl() + "/api/ecs_ques/genPaper/huoge/%s/" + pageSize;
+            url = loginUser.getServerUrl() + "/api/ecs_ques/genPaper/huoge/%s/" + pageSize;
         }
         }
 
 
         List<String> paperIds = new ArrayList<>();
         List<String> paperIds = new ArrayList<>();
@@ -247,11 +247,11 @@ public class CreateRandomPaperTemplateTask implements TaskService {
     /**
     /**
      * 保存随机抽卷模板
      * 保存随机抽卷模板
      */
      */
-    public void saveRandomPaperTemplate(User user, CourseVO course, String paperStructType, String paperStructId,
-            String paperType, List<String> paperIds) {
+    public void saveRandomPaperTemplate(User loginUser, CourseVO course, String paperStructType, String paperStructId,
+                                        String paperType, List<String> paperIds) {
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
         Map<String, String> params = new HashMap<>();
         Map<String, String> params = new HashMap<>();
         params.put("name", course.getCourseName() + "-抽题模板");//todo
         params.put("name", course.getCourseName() + "-抽题模板");//todo
@@ -261,7 +261,7 @@ public class CreateRandomPaperTemplateTask implements TaskService {
         params.put("paperType", paperType);
         params.put("paperType", paperType);
         params.put("paperIds", StringUtils.join(paperIds, ","));
         params.put("paperIds", StringUtils.join(paperIds, ","));
 
 
-        final String url = user.getServerUrl() + "/api/ecs_ques/randompaper/save?" + HttpHelper.toUrlParams(params);
+        final String url = loginUser.getServerUrl() + "/api/ecs_ques/randompaper/save?" + HttpHelper.toUrlParams(params);
         String json = HttpHelper.post(url, headers, null);
         String json = HttpHelper.post(url, headers, null);
         TemplateStructInfo info = new JsonMapper().parseJson(json, TemplateStructInfo.class);
         TemplateStructInfo info = new JsonMapper().parseJson(json, TemplateStructInfo.class);
         if (info != null && info.getValid()) {
         if (info != null && info.getValid()) {

+ 28 - 28
src/main/java/cn/com/qmth/examcloud/tool/service/export_student_answer_and_score_detail/ExportStudentAnswerAndScoreDetailTask.java

@@ -39,20 +39,15 @@ public class ExportStudentAnswerAndScoreDetailTask implements TaskService {
 
 
     @Override
     @Override
     public void start(TaskEntity task) {
     public void start(TaskEntity task) {
-        JsonNode jsonParams = new JsonMapper().getNode(task.getParams());
-        if (jsonParams == null) {
-            throw new StatusException("任务参数解析错误!");
-        }
-
-        User user = LoginSessionManager.getLoginSession(task.getUserToken());
-        if (user == null) {
+        User loginUser = LoginSessionManager.getLoginSession(task.getUserToken());
+        if (loginUser == null) {
             throw new StatusException("用户未登录!");
             throw new StatusException("用户未登录!");
         }
         }
 
 
         final String tempDir = "export_" + DateHelper.currentTimeMillis() + "_" + task.getId();
         final String tempDir = "export_" + DateHelper.currentTimeMillis() + "_" + task.getId();
         FileHelper.makeDirs(sysProperty.getDataDir() + "/" + tempDir);
         FileHelper.makeDirs(sysProperty.getDataDir() + "/" + tempDir);
 
 
-        this.execute(user, jsonParams, tempDir);
+        this.execute(loginUser, task, tempDir);
 
 
         // 压缩文件
         // 压缩文件
         FileHelper.zip(new File(sysProperty.getDataDir() + "/" + tempDir),
         FileHelper.zip(new File(sysProperty.getDataDir() + "/" + tempDir),
@@ -60,7 +55,12 @@ public class ExportStudentAnswerAndScoreDetailTask implements TaskService {
         task.setFilePath(tempDir + ".zip");
         task.setFilePath(tempDir + ".zip");
     }
     }
 
 
-    private void execute(User user, JsonNode jsonParams, String tempDir) {
+    private void execute(User loginUser, TaskEntity task, String tempDir) {
+        JsonNode jsonParams = new JsonMapper().getNode(task.getParams());
+        if (jsonParams == null) {
+            throw new StatusException("任务参数解析错误!");
+        }
+
         Long examId = jsonParams.get("examId").asLong(0L);
         Long examId = jsonParams.get("examId").asLong(0L);
         String courseCodes = jsonParams.get("courseCodes").asText("");
         String courseCodes = jsonParams.get("courseCodes").asText("");
         Boolean needSubjective = jsonParams.get("needSubjective").asBoolean(false);
         Boolean needSubjective = jsonParams.get("needSubjective").asBoolean(false);
@@ -70,7 +70,7 @@ public class ExportStudentAnswerAndScoreDetailTask implements TaskService {
 
 
         // 待处理的课程列表(未指定课程则按考试的全部课程)
         // 待处理的课程列表(未指定课程则按考试的全部课程)
         List<CourseVO> todoCourses;
         List<CourseVO> todoCourses;
-        List<CourseVO> courses = commonService.getExamCourseList(user, examId);
+        List<CourseVO> courses = commonService.getExamCourseList(loginUser, examId);
         if (StringUtils.isNotBlank(courseCodes)) {
         if (StringUtils.isNotBlank(courseCodes)) {
             todoCourses = new ArrayList<>();
             todoCourses = new ArrayList<>();
             String[] courseCodeList = StringUtils.split(courseCodes, ",");
             String[] courseCodeList = StringUtils.split(courseCodes, ",");
@@ -89,15 +89,15 @@ public class ExportStudentAnswerAndScoreDetailTask implements TaskService {
         int index = 0;
         int index = 0;
         for (CourseVO course : todoCourses) {
         for (CourseVO course : todoCourses) {
             // 按考试课程逐个处理
             // 按考试课程逐个处理
-            this.export(user, examId, course, needSubjective, needQuestionId, tempDir);
+            this.export(loginUser, examId, course, needSubjective, needQuestionId, tempDir);
 
 
             log.info("examId:{} courseId:{} 已处理课程数:{}", examId, course.getCourseId(), ++index);
             log.info("examId:{} courseId:{} 已处理课程数:{}", examId, course.getCourseId(), ++index);
         }
         }
     }
     }
 
 
-    private void export(User user, Long examId, CourseVO course, Boolean needSubjective, Boolean needQuestionId,
-            String tempDir) {
-        List<ExamStudentScoreVO> examStudentScoreList = this.getExamStudentScoreList(user, examId,
+    private void export(User loginUser, Long examId, CourseVO course, Boolean needSubjective, Boolean needQuestionId,
+                        String tempDir) {
+        List<ExamStudentScoreVO> examStudentScoreList = this.getExamStudentScoreList(loginUser, examId,
                 course.getCourseId());
                 course.getCourseId());
 
 
         // Excel动态列
         // Excel动态列
@@ -128,7 +128,7 @@ public class ExportStudentAnswerAndScoreDetailTask implements TaskService {
             }
             }
 
 
             // 获取考试试题作答记录
             // 获取考试试题作答记录
-            List<ExamQuestionVO> examQuestions = this.getExamRecordQuestions(user, vo.getExamRecordDataId());
+            List<ExamQuestionVO> examQuestions = this.getExamRecordQuestions(loginUser, vo.getExamRecordDataId());
 
 
             if (dynamicExcelHeaders.isEmpty()) {
             if (dynamicExcelHeaders.isEmpty()) {
                 for (ExamQuestionVO question : examQuestions) {
                 for (ExamQuestionVO question : examQuestions) {
@@ -164,7 +164,7 @@ public class ExportStudentAnswerAndScoreDetailTask implements TaskService {
             Map<String, Double> subjectiveQuestionScores = null;
             Map<String, Double> subjectiveQuestionScores = null;
             if (existSubjectiveQuestion && needSubjective) {
             if (existSubjectiveQuestion && needSubjective) {
                 // 获取阅卷端考生考试记录中主观题的得分明细
                 // 获取阅卷端考生考试记录中主观题的得分明细
-                subjectiveQuestionScores = this.getSubjectiveQuestionScores(user, vo.getExamRecordDataId());
+                subjectiveQuestionScores = this.getSubjectiveQuestionScores(loginUser, vo.getExamRecordDataId());
             }
             }
 
 
             // Excel动态列值
             // Excel动态列值
@@ -240,13 +240,13 @@ public class ExportStudentAnswerAndScoreDetailTask implements TaskService {
     /**
     /**
      * 获取阅卷端考生考试记录中主观题的得分明细
      * 获取阅卷端考生考试记录中主观题的得分明细
      */
      */
-    private Map<String, Double> getSubjectiveQuestionScores(User user, Long examRecordDataId) {
+    private Map<String, Double> getSubjectiveQuestionScores(User loginUser, Long examRecordDataId) {
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
         String url =
         String url =
-                user.getServerUrl() + "/api/ecs_marking/student/paper/getSubjectiveQuestionScores/" + examRecordDataId;
+                loginUser.getServerUrl() + "/api/ecs_marking/student/paper/getSubjectiveQuestionScores/" + examRecordDataId;
         String json = HttpHelper.post(url, headers, null);
         String json = HttpHelper.post(url, headers, null);
 
 
         JsonMapper jsonMapper = new JsonMapper();
         JsonMapper jsonMapper = new JsonMapper();
@@ -264,15 +264,15 @@ public class ExportStudentAnswerAndScoreDetailTask implements TaskService {
     /**
     /**
      * 获取考试试题作答记录
      * 获取考试试题作答记录
      */
      */
-    private List<ExamQuestionVO> getExamRecordQuestions(User user, Long examRecordDataId) {
+    private List<ExamQuestionVO> getExamRecordQuestions(User loginUser, Long examRecordDataId) {
         Map<String, String> params = new HashMap<>();
         Map<String, String> params = new HashMap<>();
         params.put("examRecordDataId", String.valueOf(examRecordDataId));
         params.put("examRecordDataId", String.valueOf(examRecordDataId));
 
 
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
-        String url = user.getServerUrl() + "/api/ecs_oe_admin/examRecordQuestions/getExamRecordQuestions";
+        String url = loginUser.getServerUrl() + "/api/ecs_oe_admin/examRecordQuestions/getExamRecordQuestions";
         String json = HttpHelper.get(url, headers, params);
         String json = HttpHelper.get(url, headers, params);
 
 
         JsonMapper jsonMapper = new JsonMapper();
         JsonMapper jsonMapper = new JsonMapper();
@@ -287,17 +287,17 @@ public class ExportStudentAnswerAndScoreDetailTask implements TaskService {
     /**
     /**
      * 获取考生成绩明细列表
      * 获取考生成绩明细列表
      */
      */
-    private List<ExamStudentScoreVO> getExamStudentScoreList(User user, Long examId, Long courseId) {
+    private List<ExamStudentScoreVO> getExamStudentScoreList(User loginUser, Long examId, Long courseId) {
         Map<String, Object> params = new HashMap<>();
         Map<String, Object> params = new HashMap<>();
         params.put("examId", examId);
         params.put("examId", examId);
         params.put("courseId", courseId);
         params.put("courseId", courseId);
         params.put("pageSize", 500);
         params.put("pageSize", 500);
 
 
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
-        String url = user.getServerUrl() + "/api/ecs_oe_admin/exam/score/statistic/list/for/tool";
+        String url = loginUser.getServerUrl() + "/api/ecs_oe_admin/exam/score/statistic/list/for/tool";
         List<ExamStudentScoreVO> all = new ArrayList<>();
         List<ExamStudentScoreVO> all = new ArrayList<>();
         JsonMapper jsonMapper = new JsonMapper();
         JsonMapper jsonMapper = new JsonMapper();
 
 

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

@@ -39,20 +39,20 @@ public class UpdateCorrectAnswerAndReFixScoreTask implements TaskService {
 
 
     @Override
     @Override
     public void start(TaskEntity task) {
     public void start(TaskEntity task) {
-        JsonNode jsonParams = new JsonMapper().getNode(task.getParams());
-        if (jsonParams == null) {
-            throw new StatusException("任务参数解析错误!");
-        }
-
-        User user = LoginSessionManager.getLoginSession(task.getUserToken());
-        if (user == null) {
+        User loginUser = LoginSessionManager.getLoginSession(task.getUserToken());
+        if (loginUser == null) {
             throw new StatusException("用户未登录!");
             throw new StatusException("用户未登录!");
         }
         }
 
 
-        this.execute(user, jsonParams);
+        this.execute(loginUser, task);
     }
     }
 
 
-    private void execute(User user, JsonNode jsonParams) {
+    private void execute(User loginUser, TaskEntity task) {
+        JsonNode jsonParams = new JsonMapper().getNode(task.getParams());
+        if (jsonParams == null) {
+            throw new StatusException("任务参数解析错误!");
+        }
+
         Long examId = jsonParams.get("examId").asLong(0L);
         Long examId = jsonParams.get("examId").asLong(0L);
         String courseCodes = jsonParams.get("courseCodes").asText("");
         String courseCodes = jsonParams.get("courseCodes").asText("");
 
 
@@ -68,7 +68,7 @@ public class UpdateCorrectAnswerAndReFixScoreTask implements TaskService {
 
 
         // 待处理的课程列表(未指定课程则按考试的全部课程)
         // 待处理的课程列表(未指定课程则按考试的全部课程)
         List<CourseVO> todoCourses;
         List<CourseVO> todoCourses;
-        List<CourseVO> courses = commonService.getExamCourseList(user, examId);
+        List<CourseVO> courses = commonService.getExamCourseList(loginUser, examId);
         if (StringUtils.isNotBlank(courseCodes)) {
         if (StringUtils.isNotBlank(courseCodes)) {
             todoCourses = new ArrayList<>();
             todoCourses = new ArrayList<>();
             String[] courseCodeList = StringUtils.split(courseCodes, ",");
             String[] courseCodeList = StringUtils.split(courseCodes, ",");
@@ -88,19 +88,19 @@ public class UpdateCorrectAnswerAndReFixScoreTask implements TaskService {
         for (CourseVO course : todoCourses) {
         for (CourseVO course : todoCourses) {
             // 按考试课程逐个处理
             // 按考试课程逐个处理
             log.info("examId:{} todoCourseCount:{} curIndex:{}", examId, todoCourses.size(), index);
             log.info("examId:{} todoCourseCount:{} curIndex:{}", examId, todoCourses.size(), index);
-            this.process(user, examId, course, updateObjectiveAnswer, updateObjectiveScore, updateSubjectiveScore);
+            this.process(loginUser, examId, course, updateObjectiveAnswer, updateObjectiveScore, updateSubjectiveScore);
             index++;
             index++;
         }
         }
     }
     }
 
 
-    public void process(User user, Long examId, CourseVO course, Boolean updateObjectiveAnswer,
-            Boolean updateObjectiveScore, Boolean updateSubjectiveScore) {
-        List<ExamStudentVO> examStudents = this.getExamStudentList(user, examId, course.getCourseId());
+    public void process(User loginUser, Long examId, CourseVO course, Boolean updateObjectiveAnswer,
+                        Boolean updateObjectiveScore, Boolean updateSubjectiveScore) {
+        List<ExamStudentVO> examStudents = this.getExamStudentList(loginUser, examId, course.getCourseId());
 
 
         int index = 0, total = examStudents.size();
         int index = 0, total = examStudents.size();
         for (ExamStudentVO examStudent : examStudents) {
         for (ExamStudentVO examStudent : examStudents) {
             // 按考生逐个重新算分
             // 按考生逐个重新算分
-            this.fix(user, examId, course.getCourseId(), examStudent.getExamStudentId(), updateObjectiveAnswer,
+            this.fix(loginUser, examId, course.getCourseId(), examStudent.getExamStudentId(), updateObjectiveAnswer,
                     updateObjectiveScore, updateSubjectiveScore);
                     updateObjectiveScore, updateSubjectiveScore);
 
 
             index++;
             index++;
@@ -117,8 +117,8 @@ public class UpdateCorrectAnswerAndReFixScoreTask implements TaskService {
         examStudents.clear();
         examStudents.clear();
     }
     }
 
 
-    private void fix(User user, Long examId, Long courseId, Long examStudentId, Boolean updateObjectiveAnswer,
-            Boolean updateObjectiveScore, Boolean updateSubjectiveScore) {
+    private void fix(User loginUser, Long examId, Long courseId, Long examStudentId, Boolean updateObjectiveAnswer,
+                     Boolean updateObjectiveScore, Boolean updateSubjectiveScore) {
         Map<String, Object> params = new HashMap<>();
         Map<String, Object> params = new HashMap<>();
         params.put("examId", examId);
         params.put("examId", examId);
         params.put("courseId", courseId);
         params.put("courseId", courseId);
@@ -128,27 +128,27 @@ public class UpdateCorrectAnswerAndReFixScoreTask implements TaskService {
         params.put("updateSubjectiveScore", updateSubjectiveScore);
         params.put("updateSubjectiveScore", updateSubjectiveScore);
 
 
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
-        String url = user.getServerUrl() + "/api/ecs_oe_admin/exam/score/reFixScore";
+        String url = loginUser.getServerUrl() + "/api/ecs_oe_admin/exam/score/reFixScore";
         HttpHelper.post(url, headers, params);
         HttpHelper.post(url, headers, params);
     }
     }
 
 
     /**
     /**
      * 获取网考考生列表
      * 获取网考考生列表
      */
      */
-    private List<ExamStudentVO> getExamStudentList(User user, Long examId, Long courseId) {
+    private List<ExamStudentVO> getExamStudentList(User loginUser, Long examId, Long courseId) {
         Map<String, Object> params = new HashMap<>();
         Map<String, Object> params = new HashMap<>();
         params.put("examId", examId);
         params.put("examId", examId);
         params.put("courseId", courseId);
         params.put("courseId", courseId);
         params.put("pageSize", 500);
         params.put("pageSize", 500);
 
 
         Map<String, String> headers = new HashMap<>();
         Map<String, String> headers = new HashMap<>();
-        headers.put("key", user.getKey());
-        headers.put("token", user.getToken());
+        headers.put("key", loginUser.getKey());
+        headers.put("token", loginUser.getToken());
 
 
-        String url = user.getServerUrl() + "/api/ecs_oe_admin/exam/student/simple/list";
+        String url = loginUser.getServerUrl() + "/api/ecs_oe_admin/exam/student/simple/list";
         List<ExamStudentVO> all = new ArrayList<>();
         List<ExamStudentVO> all = new ArrayList<>();
         JsonMapper jsonMapper = new JsonMapper();
         JsonMapper jsonMapper = new JsonMapper();