|
@@ -1,21 +1,17 @@
|
|
|
package com.qmth.distributed.print.business.templete.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.qmth.distributed.print.business.entity.TSyncExamLog;
|
|
|
import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
|
|
|
-import com.qmth.distributed.print.business.entity.TeachClazz;
|
|
|
import com.qmth.distributed.print.business.enums.ImageTrajectoryEnum;
|
|
|
import com.qmth.distributed.print.business.service.ExamStudentService;
|
|
|
import com.qmth.distributed.print.business.service.TSyncExamStudentScoreService;
|
|
|
import com.qmth.distributed.print.business.service.TeachClazzService;
|
|
|
import com.qmth.distributed.print.business.templete.service.PushLogicService;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.entity.BasicClazz;
|
|
|
-import com.qmth.teachcloud.common.entity.BasicMajor;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.service.BasicClazzService;
|
|
|
-import com.qmth.teachcloud.common.service.BasicMajorService;
|
|
|
import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -24,10 +20,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.Semaphore;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
@@ -54,85 +48,85 @@ public class PushLogicServiceImpl implements PushLogicService {
|
|
|
@Resource
|
|
|
ExamStudentService examStudentService;
|
|
|
|
|
|
- @Resource
|
|
|
- BasicMajorService basicMajorService;
|
|
|
-
|
|
|
/**
|
|
|
* 成绩查询推送异步任务处理方法
|
|
|
*
|
|
|
- * @param map 任务源
|
|
|
+ * @param tSyncExamLog 任务源
|
|
|
* @return
|
|
|
- * @throws IllegalAccessException
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Map<String, Object> executeScorePushLogic(Map<String, Object> map) throws Exception {
|
|
|
- SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
- Long schoolId = sysUser.getSchoolId();
|
|
|
- LinkedMultiValueMap<Long, Integer> semesterExamIdMap = (LinkedMultiValueMap<Long, Integer>) map.get("semesterExamIdMap");
|
|
|
+ public Map<String, Object> executeScorePushLogic(TSyncExamLog tSyncExamLog) {
|
|
|
+ Long schoolId = tSyncExamLog.getSchoolId();
|
|
|
+ Long semesterId = tSyncExamLog.getSemesterId();
|
|
|
+ Integer examId = Math.toIntExact(tSyncExamLog.getExamId());
|
|
|
List<TSyncExamStudentScore> tSyncExamStudentScoreList = new ArrayList<>();
|
|
|
List<String> errorTSyncExamStudentScoreList = new ArrayList<>();
|
|
|
- AtomicInteger count = new AtomicInteger(0);
|
|
|
+ Set<String> courseList = new HashSet<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
try {
|
|
|
- semesterExamIdMap.forEach((k, v) -> {
|
|
|
- for (Integer examId : v) {
|
|
|
- int totalCount = stmmsUtils.getStudentCount(schoolId, examId, null, null, null, null, null, null, null, true);
|
|
|
- count.set(count.get() + totalCount);
|
|
|
- log.info("云阅卷:考试成绩考生数量查询接口调用,返回数量:{}", totalCount);
|
|
|
- if (totalCount > 0) {
|
|
|
- int pageSize = stmmsUtils.getDefaultPageSize();
|
|
|
- int mod = totalCount % pageSize;
|
|
|
- int pageNos = mod == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
|
|
|
- for (int i = 1; i <= pageNos; i++) {
|
|
|
- List<Map> students = stmmsUtils.getStudentScore(schoolId, examId, null, null, null, null, null, null, null, true, i, pageSize);
|
|
|
- for (Map student : students) {
|
|
|
- try {
|
|
|
- Long orgId = null, clazzId = null;
|
|
|
- String clazzName = "";
|
|
|
- String majorName = "";
|
|
|
- if (Objects.nonNull(student.get("studentCode")) && !Objects.equals("无", student.get("studentCode"))) {
|
|
|
- String studentCode = String.valueOf(student.get("studentCode"));
|
|
|
- String subjectCode = String.valueOf(student.get("subjectCode"));
|
|
|
- String examNumber = String.valueOf(student.get("examNumber"));
|
|
|
-// Long printPlanId = Long.valueOf(student.get("examCode").toString()); // 计划ID
|
|
|
-
|
|
|
- // 分布式印刷系统内部考生信息
|
|
|
- List<Map> studentInfos = examStudentService.listStudentScoreSync(schoolId, studentCode, examNumber, subjectCode);
|
|
|
- if (studentInfos == null || studentInfos.size() == 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到此考生信息");
|
|
|
- }
|
|
|
- Map dpsPrintStuMap = studentInfos.get(0);
|
|
|
-
|
|
|
- // 组装本系统内考生信息
|
|
|
- clazzId = dpsPrintStuMap.get("clazzId") == null || "".equals(dpsPrintStuMap.get("clazzId")) ? null : Long.parseLong(String.valueOf(dpsPrintStuMap.get("clazzId")));
|
|
|
- clazzName = String.valueOf(dpsPrintStuMap.get("clazzName"));
|
|
|
- majorName = String.valueOf(dpsPrintStuMap.get("majorName"));
|
|
|
- student.put("clazzId",clazzId);
|
|
|
- student.put("clazzName",clazzName);
|
|
|
- student.put("majorName",majorName);
|
|
|
- }
|
|
|
-
|
|
|
- student.put(SystemConstant.SCHOOL_ID, schoolId);
|
|
|
- student.put("semesterId", k);
|
|
|
- student.put("orgId", orgId);
|
|
|
- student.put("userId", sysUser.getId());
|
|
|
- tSyncExamStudentScoreList.add(new TSyncExamStudentScore(student));
|
|
|
- } catch (Exception e) {
|
|
|
- log.info("同步学生成绩信息失败:{}", e.getMessage());
|
|
|
- errorTSyncExamStudentScoreList.add(student.get("name") + "," + student.get("examNumber") + "\r\n");
|
|
|
+ int totalCount = stmmsUtils.getStudentCount(schoolId, examId, null, null, null, null, null, null, null, true);
|
|
|
+ log.info("云阅卷:考试成绩考生数量查询接口调用,返回数量:{}", totalCount);
|
|
|
+ if (totalCount > 0) {
|
|
|
+ int pageSize = stmmsUtils.getDefaultPageSize();
|
|
|
+ int mod = totalCount % pageSize;
|
|
|
+ int pageNos = mod == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
|
|
|
+ for (int i = 1; i <= pageNos; i++) {
|
|
|
+ List<Map> students = stmmsUtils.getStudentScore(schoolId, examId, null, null, null, null, null, null, null, true, i, pageSize);
|
|
|
+ for (Map student : students) {
|
|
|
+ try {
|
|
|
+ Long orgId = null, clazzId = null;
|
|
|
+ String clazzName = "";
|
|
|
+ String majorName = "";
|
|
|
+ if (Objects.nonNull(student.get("studentCode")) && !Objects.equals("无", student.get("studentCode"))) {
|
|
|
+ String studentCode = String.valueOf(student.get("studentCode"));
|
|
|
+ String subjectCode = String.valueOf(student.get("subjectCode"));
|
|
|
+ String examNumber = String.valueOf(student.get("examNumber"));
|
|
|
+
|
|
|
+ courseList.add(subjectCode);
|
|
|
+
|
|
|
+ // 分布式印刷系统内部考生信息
|
|
|
+ List<Map> studentInfos = examStudentService.listStudentScoreSync(schoolId, studentCode, examNumber, subjectCode);
|
|
|
+ if (studentInfos == null || studentInfos.size() == 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到此考生信息");
|
|
|
}
|
|
|
+ Map dpsPrintStuMap = studentInfos.get(0);
|
|
|
+
|
|
|
+ // 组装本系统内考生信息
|
|
|
+ clazzId = dpsPrintStuMap.get("clazzId") == null || "".equals(dpsPrintStuMap.get("clazzId")) ? null : Long.parseLong(String.valueOf(dpsPrintStuMap.get("clazzId")));
|
|
|
+ clazzName = String.valueOf(dpsPrintStuMap.get("clazzName"));
|
|
|
+ majorName = String.valueOf(dpsPrintStuMap.get("majorName"));
|
|
|
+ student.put("clazzId", clazzId);
|
|
|
+ student.put("clazzName", clazzName);
|
|
|
+ student.put("majorName", majorName);
|
|
|
}
|
|
|
- }
|
|
|
- if (tSyncExamStudentScoreList.size() > 0) {
|
|
|
- tSyncExamStudentScoreService.remove(new QueryWrapper<TSyncExamStudentScore>().lambda().eq(TSyncExamStudentScore::getSchoolId, schoolId).eq(TSyncExamStudentScore::getExamId, Long.parseLong(String.valueOf(examId))));
|
|
|
- tSyncExamStudentScoreService.saveOrUpdateBatch(tSyncExamStudentScoreList);
|
|
|
+
|
|
|
+ student.put(SystemConstant.SCHOOL_ID, schoolId);
|
|
|
+ student.put("semesterId", semesterId);
|
|
|
+ student.put("orgId", orgId);
|
|
|
+ student.put("userId", tSyncExamLog.getCreateId());
|
|
|
+ // 成功数据
|
|
|
+ tSyncExamStudentScoreList.add(new TSyncExamStudentScore(student));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("同步学生成绩信息失败:{}", e.getMessage());
|
|
|
+ // 失败数据
|
|
|
+ errorTSyncExamStudentScoreList.add(student.get("name") + "," + student.get("examNumber") + "\r\n");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
- map.computeIfAbsent("count", e -> count.get());
|
|
|
+ if (tSyncExamStudentScoreList.size() > 0) {
|
|
|
+ tSyncExamStudentScoreService.remove(new QueryWrapper<TSyncExamStudentScore>().lambda().eq(TSyncExamStudentScore::getSchoolId, schoolId)
|
|
|
+ .eq(TSyncExamStudentScore::getSemesterId, semesterId)
|
|
|
+ .eq(TSyncExamStudentScore::getExamId, Long.parseLong(String.valueOf(examId))));
|
|
|
+ tSyncExamStudentScoreService.saveOrUpdateBatch(tSyncExamStudentScoreList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.putIfAbsent("count", totalCount);
|
|
|
+ map.putIfAbsent("courses", courseList.size());
|
|
|
map.computeIfAbsent("correct", e -> tSyncExamStudentScoreList.size());
|
|
|
if (Objects.nonNull(errorTSyncExamStudentScoreList) && errorTSyncExamStudentScoreList.size() > 0) {
|
|
|
+ map.computeIfAbsent("errorCount", e -> errorTSyncExamStudentScoreList.size());
|
|
|
map.computeIfAbsent("error", e -> "未同步成功数据" + errorTSyncExamStudentScoreList.size() + "条:\r\n" + errorTSyncExamStudentScoreList.toString());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -140,10 +134,10 @@ public class PushLogicServiceImpl implements PushLogicService {
|
|
|
throw new RuntimeException("云阅卷:接口调用失败:" + e.getMessage());
|
|
|
}
|
|
|
|
|
|
- if(!tSyncExamStudentScoreList.isEmpty()){
|
|
|
+ if (!tSyncExamStudentScoreList.isEmpty()) {
|
|
|
try {
|
|
|
for (TSyncExamStudentScore tSyncExamStudentScore : tSyncExamStudentScoreList) {
|
|
|
- tSyncExamStudentScoreService.createImageTrajectory(tSyncExamStudentScore, ImageTrajectoryEnum.PREVIEW, true, sysUser.getId());
|
|
|
+ tSyncExamStudentScoreService.createImageTrajectory(tSyncExamStudentScore, ImageTrajectoryEnum.PREVIEW, true, tSyncExamLog.getCreateId());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
|