|
@@ -2,28 +2,32 @@ package com.qmth.distributed.print.business.templete.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
-import com.qmth.distributed.print.business.service.DataSyncService;
|
|
|
-import com.qmth.distributed.print.business.service.impl.DataSyncServiceImpl;
|
|
|
+import com.qmth.distributed.print.business.entity.ExamPrintPlan;
|
|
|
+import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
|
|
|
+import com.qmth.distributed.print.business.service.ExamPrintPlanService;
|
|
|
+import com.qmth.distributed.print.business.service.TSyncExamStudentScoreService;
|
|
|
import com.qmth.distributed.print.business.templete.service.PushLogicService;
|
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
import com.qmth.teachcloud.common.bean.params.PushBeforeRoleParam;
|
|
|
import com.qmth.teachcloud.common.bean.params.UserPushParam;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.entity.BasicClazz;
|
|
|
+import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.userPush.BeforeJudgeEnum;
|
|
|
import com.qmth.teachcloud.common.enums.userPush.SyncStatusEnum;
|
|
|
+import com.qmth.teachcloud.common.service.BasicClazzService;
|
|
|
+import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
import com.qmth.teachcloud.common.service.SysUserRoleService;
|
|
|
import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
import com.qmth.teachcloud.common.sync.StmmsUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -44,6 +48,18 @@ public class PushLogicServiceImpl implements PushLogicService {
|
|
|
@Resource
|
|
|
StmmsUtils stmmsUtils;
|
|
|
|
|
|
+ @Resource
|
|
|
+ SysOrgService sysOrgService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ BasicClazzService basicClazzService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ ExamPrintPlanService examPrintPlanService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TSyncExamStudentScoreService tSyncExamStudentScoreService;
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> executeUserPushLogic(Map<String, Object> map) throws IllegalAccessException {
|
|
|
int correct = 0;
|
|
@@ -80,38 +96,71 @@ public class PushLogicServiceImpl implements PushLogicService {
|
|
|
* @throws IllegalAccessException
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Map<String, Object> executeScorePushLogic(Map<String, Object> map) throws Exception {
|
|
|
- SysUser sysUser = (SysUser) map.get(SystemConstant.SYS_USER);
|
|
|
+// SysUser sysUser = (SysUser) map.get(SystemConstant.SYS_USER);
|
|
|
+ Long schoolId = 2L;
|
|
|
Integer examId = (Integer) map.get("examId");
|
|
|
String examCode = (String) map.get("examCode");
|
|
|
+ Long examIdLong = Long.parseLong(String.valueOf(examId));
|
|
|
+ List<TSyncExamStudentScore> tSyncExamStudentScoreList = null;
|
|
|
try {
|
|
|
- int totalCount = stmmsUtils.getStudentCount(sysUser.getSchoolId(), examId, examCode, null, null, null, null, null, null);
|
|
|
+ int totalCount = stmmsUtils.getStudentCount(schoolId, examId, examCode, null, null, null, null, null, null);
|
|
|
log.info("云阅卷:考试成绩考生数量查询接口调用,返回数量:{}", totalCount);
|
|
|
-// List<Map> paramList = new ArrayList<>();
|
|
|
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(sysUser.getSchoolId(), examId, examCode, null, null, null, null, null, null, i, pageSize);
|
|
|
+ Map<String, SysOrg> orgMap = new HashMap<>();
|
|
|
+ Map<String, BasicClazz> clazzMap = new HashMap<>();
|
|
|
+ Long semesterId = examPrintPlanService.getOne(new QueryWrapper<ExamPrintPlan>().lambda().eq(ExamPrintPlan::getThirdRelateId, examIdLong)).getId();
|
|
|
+ tSyncExamStudentScoreList = new ArrayList<>();
|
|
|
+ for (int i = 1; i <= 1; i++) {
|
|
|
+ List<Map> students = stmmsUtils.getStudentScore(schoolId, examId, examCode, null, null, null, null, null, null, i, pageSize);
|
|
|
for (Map student : students) {
|
|
|
- String jxbId = String.valueOf(student.get("className"));
|
|
|
- String xhId = String.valueOf(student.get("studentCode"));
|
|
|
- String xmcj = String.valueOf(student.get("totalScore"));
|
|
|
-// Map<String, String> stringMap = new HashMap<>();
|
|
|
-// stringMap.put("jxb_id", jxbId);
|
|
|
-// stringMap.put("xh_id", xhId);
|
|
|
-// stringMap.put("xmcj", xmcj);
|
|
|
-// paramList.add(stringMap);
|
|
|
+ //查学院id
|
|
|
+ Long orgId = null;
|
|
|
+ if (!orgMap.containsKey(student.get("college"))) {
|
|
|
+ SysOrg sysOrg = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId, schoolId).eq(SysOrg::getName, student.get("college")));
|
|
|
+ if (Objects.nonNull(sysOrg)) {
|
|
|
+ orgId = sysOrg.getId();
|
|
|
+ orgMap.put(sysOrg.getName(), sysOrg);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ orgId = orgMap.get(student.get("college")).getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ //查班级和专业id
|
|
|
+ Long clazzId = null, majorId = null;
|
|
|
+ if (!clazzMap.containsKey(student.get("className"))) {
|
|
|
+ BasicClazz basicClazz = basicClazzService.getOne(new QueryWrapper<BasicClazz>().lambda().eq(BasicClazz::getSchoolId, schoolId).eq(BasicClazz::getClazzName, student.get("className")));
|
|
|
+ if (Objects.nonNull(basicClazz)) {
|
|
|
+ clazzId = basicClazz.getId();
|
|
|
+ majorId = basicClazz.getMajorId();
|
|
|
+ clazzMap.put(basicClazz.getClazzName(), basicClazz);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ clazzId = clazzMap.get(student.get("className")).getId();
|
|
|
+ majorId = clazzMap.get(student.get("className")).getMajorId();
|
|
|
+ }
|
|
|
+ student.put(SystemConstant.SCHOOL_ID, schoolId);
|
|
|
+ student.put("semesterId", semesterId);
|
|
|
+ student.put("orgId", orgId);
|
|
|
+ student.put("clazzId", clazzId);
|
|
|
+ student.put("userId", 2L);
|
|
|
+ tSyncExamStudentScoreList.add(new TSyncExamStudentScore(student));
|
|
|
}
|
|
|
}
|
|
|
+ tSyncExamStudentScoreService.remove(new QueryWrapper<TSyncExamStudentScore>().lambda().eq(TSyncExamStudentScore::getSchoolId, schoolId).eq(TSyncExamStudentScore::getExamId, examIdLong));
|
|
|
+ tSyncExamStudentScoreService.saveOrUpdateBatch(tSyncExamStudentScoreList);
|
|
|
}
|
|
|
map.computeIfAbsent("count", v -> totalCount);
|
|
|
- map.computeIfAbsent("correct", v -> totalCount);
|
|
|
+ List<TSyncExamStudentScore> finalTSyncExamStudentScoreList = tSyncExamStudentScoreList;
|
|
|
+ map.computeIfAbsent("correct", v -> finalTSyncExamStudentScoreList.size());
|
|
|
} catch (Exception e) {
|
|
|
log.info("云阅卷:接口调用失败:{}", e.getMessage());
|
|
|
throw new RuntimeException("云阅卷:接口调用失败:" + e.getMessage());
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
-}
|
|
|
+}
|