|
@@ -2,32 +2,31 @@ package com.qmth.eds.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.eds.bean.dto.ExamAssignDto;
|
|
|
import com.qmth.eds.bean.result.AssignResultPreviewResult;
|
|
|
import com.qmth.eds.common.contant.SystemConstant;
|
|
|
-import com.qmth.eds.common.entity.ExamAssign;
|
|
|
-import com.qmth.eds.common.entity.ExamSyncStudent;
|
|
|
-import com.qmth.eds.common.entity.ExamSyncTotal;
|
|
|
-import com.qmth.eds.common.entity.SysUser;
|
|
|
+import com.qmth.eds.common.entity.*;
|
|
|
import com.qmth.eds.common.enums.ExamAssignStatusEnum;
|
|
|
import com.qmth.eds.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.eds.common.util.ServletUtil;
|
|
|
import com.qmth.eds.mapper.ExamAssignMapper;
|
|
|
-import com.qmth.eds.service.AsyncTaskService;
|
|
|
-import com.qmth.eds.service.ExamAssignService;
|
|
|
-import com.qmth.eds.service.ExamSyncStudentService;
|
|
|
-import com.qmth.eds.service.ExamSyncTotalService;
|
|
|
+import com.qmth.eds.service.*;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.checkerframework.checker.units.qual.C;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -47,6 +46,12 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
|
|
|
@Resource
|
|
|
AsyncTaskService asyncTaskService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ CloudMarkingScoreService cloudMarkingScoreService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CloudMarkingScoreForeignService cloudMarkingScoreForeignService;
|
|
|
+
|
|
|
@Resource
|
|
|
ExamAssignMapper examAssignMapper;
|
|
|
|
|
@@ -173,4 +178,78 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
|
|
|
examAssignDto.setInspectCollege(kcxyList);
|
|
|
return examAssignDto;
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public boolean publish(Long id) {
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ ExamAssign examAssign = this.getById(id);
|
|
|
+ Long semesterId = examAssign.getSemesterId();
|
|
|
+ Long examTypeId = examAssign.getExamTypeId();
|
|
|
+ Long collegeId = examAssign.getSchoolId();
|
|
|
+ String courseCode = examAssign.getCourseCode();
|
|
|
+
|
|
|
+ // 查询对外数据
|
|
|
+ ExamSyncTotal examSyncTotal = examSyncTotalService.getBySemesterIdAndExamTypeIdAndUseFile(schoolId, semesterId, examTypeId, true);
|
|
|
+ if (examSyncTotal == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未设置使用数据文件,请联系管理员处理");
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<CloudMarkingScore> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(CloudMarkingScore::getSchoolId, collegeId)
|
|
|
+ .eq(CloudMarkingScore::getSemesterId, semesterId)
|
|
|
+ .eq(CloudMarkingScore::getExamTypeId, examTypeId)
|
|
|
+ .eq(CloudMarkingScore::getSubjectCode, courseCode);
|
|
|
+ List<CloudMarkingScore> cloudMarkingScoreList = cloudMarkingScoreService.list(queryWrapper);
|
|
|
+
|
|
|
+ List<CloudMarkingScoreForeign> cloudMarkingScoreForeigns = new ArrayList<>();
|
|
|
+ List<ExamSyncStudent> examSyncStudents = examSyncStudentService.listByExamSyncTotalId(examSyncTotal);
|
|
|
+ for (CloudMarkingScore cloudMarkingScore : cloudMarkingScoreList) {
|
|
|
+ if (cloudMarkingScore.getExamSyncStudentId() != null) {
|
|
|
+ ExamSyncStudent examSyncStudent = examSyncStudents.stream().filter(m -> cloudMarkingScore.getExamSyncStudentId().equals(m.getId())).findFirst().get();
|
|
|
+ cloudMarkingScoreForeigns.add(new CloudMarkingScoreForeign(collegeId, semesterId, examTypeId, cloudMarkingScore.getExamId(), examSyncStudent.getXnm(), examSyncStudent.getXqm(), examSyncStudent.getJxbId(), examSyncStudent.getKch(), examSyncStudent.getKcmc(), examSyncStudent.getXh(), cloudMarkingScore.getAssignScore()));
|
|
|
+ } else {
|
|
|
+ Optional<ExamSyncStudent> optional = examSyncStudents.stream()
|
|
|
+ .filter(s -> s.getJxbmc().equals(cloudMarkingScore.getClassName())
|
|
|
+ && ((StringUtils.isBlank(s.getCloudMarkingCourseCode()) && s.getKch().equals(cloudMarkingScore.getSubjectCode())) || (StringUtils.isNotBlank(s.getCloudMarkingCourseCode()) && s.getCloudMarkingCourseCode().equals(cloudMarkingScore.getSubjectCode())))
|
|
|
+ && s.getXh().equals(cloudMarkingScore.getStudentCode())).findFirst();
|
|
|
+ if (!optional.isPresent()) {
|
|
|
+ cloudMarkingScoreForeigns.add(new CloudMarkingScoreForeign(collegeId, semesterId, examTypeId, cloudMarkingScore.getExamId(), null, null, null, cloudMarkingScore.getSubjectCode(), cloudMarkingScore.getSubjectName(), cloudMarkingScore.getStudentCode(), cloudMarkingScore.getAssignScore()));
|
|
|
+ } else {
|
|
|
+ ExamSyncStudent examSyncStudent = optional.get();
|
|
|
+ // 匹配上,保存考务数据表ID
|
|
|
+ cloudMarkingScoreForeigns.add(new CloudMarkingScoreForeign(collegeId, semesterId, examTypeId, cloudMarkingScore.getExamId(), examSyncStudent.getXnm(), examSyncStudent.getXqm(), examSyncStudent.getJxbId(), examSyncStudent.getKch(), examSyncStudent.getKcmc(), examSyncStudent.getXh(), cloudMarkingScore.getAssignScore()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> examIds = cloudMarkingScoreList.stream().map(CloudMarkingScore::getExamId).distinct().collect(Collectors.toList());
|
|
|
+ // 删除全量数据
|
|
|
+ UpdateWrapper<CloudMarkingScoreForeign> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.lambda().eq(CloudMarkingScoreForeign::getSchoolId, collegeId)
|
|
|
+ .eq(CloudMarkingScoreForeign::getSemesterId, semesterId)
|
|
|
+ .eq(CloudMarkingScoreForeign::getExamTypeId, examTypeId)
|
|
|
+ .in(CloudMarkingScoreForeign::getExamId, examIds);
|
|
|
+ cloudMarkingScoreForeignService.remove(updateWrapper);
|
|
|
+
|
|
|
+ List<CloudMarkingScoreForeign> foreignData = new ArrayList<>();
|
|
|
+ //1000条提交一次
|
|
|
+ for (CloudMarkingScoreForeign scoreForeign : cloudMarkingScoreForeigns) {
|
|
|
+ if (foreignData.size() == 1000) {
|
|
|
+ cloudMarkingScoreForeignService.saveBatch(foreignData);
|
|
|
+ foreignData.clear();
|
|
|
+ }
|
|
|
+ foreignData.add(scoreForeign);
|
|
|
+ }
|
|
|
+ //将剩下的数据也导入
|
|
|
+ if (!foreignData.isEmpty()) {
|
|
|
+ cloudMarkingScoreForeignService.saveBatch(foreignData);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新发布状态为已发布
|
|
|
+ UpdateWrapper<ExamAssign> examAssignUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ examAssignUpdateWrapper.lambda().set(ExamAssign::getPublish, true)
|
|
|
+ .eq(ExamAssign::getId, id);
|
|
|
+ return this.update(examAssignUpdateWrapper);
|
|
|
+ }
|
|
|
}
|