|
@@ -1,20 +1,29 @@
|
|
|
package com.qmth.eds.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
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.AssignListDto;
|
|
|
import com.qmth.eds.bean.dto.ExamAssignDto;
|
|
|
+import com.qmth.eds.common.contant.SystemConstant;
|
|
|
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.ExamAssignService;
|
|
|
import com.qmth.eds.service.ExamSyncStudentService;
|
|
|
import com.qmth.eds.service.ExamSyncTotalService;
|
|
|
+import com.qmth.eds.service.WhuDataSyncService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -30,26 +39,56 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
|
|
|
@Resource
|
|
|
ExamSyncStudentService examSyncStudentService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ WhuDataSyncService whuDataSyncService;
|
|
|
+
|
|
|
@Override
|
|
|
- public IPage<AssignListDto> pageData(Long semesterId, Long examTypeId, String courseCode, Integer pageNumber, Integer pageSize) {
|
|
|
+ public IPage<ExamAssignDto> pageData(Long semesterId, Long examTypeId, String courseCode, Integer pageNumber, Integer pageSize) {
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- Page<AssignListDto> page = new Page<>(pageNumber, pageSize);
|
|
|
- IPage<AssignListDto> assignListDtoIPage = this.baseMapper.pageData(page, sysUser.getOrgId(), semesterId, examTypeId, courseCode);
|
|
|
-
|
|
|
- ExamSyncTotal examSyncTotal = examSyncTotalService.getBySemesterIdAndExamTypeIdAndDownloadStatus(semesterId, examTypeId, true);
|
|
|
-
|
|
|
- for (AssignListDto record : assignListDtoIPage.getRecords()) {
|
|
|
+ Page<ExamAssignDto> page = new Page<>(pageNumber, pageSize);
|
|
|
+ IPage<ExamAssignDto> assignListDtoIPage = this.baseMapper.pageData(page, sysUser.getOrgId(), semesterId, examTypeId, courseCode);
|
|
|
|
|
|
+ ExamSyncTotal examSyncTotal = examSyncTotalService.getBySemesterIdAndExamTypeIdAndDownloadStatus(schoolId, semesterId, examTypeId, true);
|
|
|
+ for (ExamAssignDto record : assignListDtoIPage.getRecords()) {
|
|
|
+ int actualCount = 0;
|
|
|
+ String kkxy = "";
|
|
|
+ if (examSyncTotal != null) {
|
|
|
+ List<ExamSyncStudent> examSyncStudents = examSyncStudentService.listByExamSyncTotalId(examSyncTotal);
|
|
|
+ if (!CollectionUtils.isEmpty(examSyncStudents)) {
|
|
|
+ List<ExamSyncStudent> syncStudents = examSyncStudents.stream().filter(m -> m.getCloudMarkingCourseCode().equals(courseCode)).collect(Collectors.toList());
|
|
|
+ actualCount = syncStudents.size();
|
|
|
+ List<String> kkxyList = syncStudents.stream().map(ExamSyncStudent::getKkbm).distinct().collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(kkxyList) && kkxyList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s]查询出%d个开课学院,请联系管理员检查数据", courseCode, kkxyList.size()));
|
|
|
+ }
|
|
|
+ kkxy = kkxyList.get(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setActualCount(actualCount);
|
|
|
+ record.setOpenCollege(kkxy);
|
|
|
}
|
|
|
|
|
|
return assignListDtoIPage;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean calcData(Long semesterId, Long examTypeId, String courseCode, String courseName, String formula, Double fullScore, Double passScore, String coefficient) {
|
|
|
+ public boolean calcData(ExamAssign examAssign) {
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
// 保存赋分参数
|
|
|
+ if (examAssign.getId() == null) {
|
|
|
+ examAssign.setId(SystemConstant.getDbUuid());
|
|
|
+ examAssign.setStatus(ExamAssignStatusEnum.INIT);
|
|
|
+ examAssign.setCreateId(sysUser.getId());
|
|
|
+ examAssign.setCreateTime(System.currentTimeMillis());
|
|
|
+ } else {
|
|
|
+ examAssign.setUpdateId(sysUser.getId());
|
|
|
+ examAssign.setUpdateTime(System.currentTimeMillis());
|
|
|
+ }
|
|
|
+ this.saveOrUpdate(examAssign);
|
|
|
|
|
|
// 计算赋分
|
|
|
+ whuDataSyncService.calcAssignScore(examAssign);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -64,7 +103,43 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ExamAssignDto toCalc(Long semesterId, Long examTypeId, String courseCode) {
|
|
|
- return null;
|
|
|
+ public ExamAssignDto toCalc(Long semesterId, Long examTypeId, String courseCode, String courseName, String openCollege) {
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+
|
|
|
+ QueryWrapper<ExamAssign> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ExamAssign::getSchoolId, sysUser.getOrgId())
|
|
|
+ .eq(ExamAssign::getSemesterId, semesterId)
|
|
|
+ .eq(ExamAssign::getExamTypeId, examTypeId)
|
|
|
+ .eq(ExamAssign::getCourseCode, courseCode)
|
|
|
+ .eq(ExamAssign::getOpenCollege, openCollege);
|
|
|
+ ExamAssign examAssign = this.getOne(queryWrapper);
|
|
|
+ ExamAssignDto examAssignDto = new ExamAssignDto();
|
|
|
+ if (examAssign == null) {
|
|
|
+ examAssignDto.setSchoolId(sysUser.getSchoolId());
|
|
|
+ examAssignDto.setSemesterId(semesterId);
|
|
|
+ examAssignDto.setExamTypeId(examTypeId);
|
|
|
+ examAssignDto.setCourseCode(courseCode);
|
|
|
+ examAssignDto.setCourseName(courseName);
|
|
|
+ examAssignDto.setOpenCollege(openCollege);
|
|
|
+ examAssignDto.setStatus(ExamAssignStatusEnum.INIT);
|
|
|
+ } else {
|
|
|
+ BeanUtils.copyProperties(examAssign, examAssignDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ ExamSyncTotal examSyncTotal = examSyncTotalService.getBySemesterIdAndExamTypeIdAndDownloadStatus(schoolId, semesterId, examTypeId, true);
|
|
|
+ int actualCount = 0;
|
|
|
+ List<String> kcxyList = new ArrayList<>();
|
|
|
+ if (examSyncTotal != null) {
|
|
|
+ List<ExamSyncStudent> examSyncStudents = examSyncStudentService.listByExamSyncTotalId(examSyncTotal);
|
|
|
+ if (!CollectionUtils.isEmpty(examSyncStudents)) {
|
|
|
+ List<ExamSyncStudent> syncStudents = examSyncStudents.stream().filter(m -> m.getCloudMarkingCourseCode().equals(courseCode) && m.getKkbm().equals(openCollege)).collect(Collectors.toList());
|
|
|
+ actualCount = syncStudents.size();
|
|
|
+ kcxyList = syncStudents.stream().map(ExamSyncStudent::getJgmc).distinct().collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ examAssignDto.setActualCount(actualCount);
|
|
|
+ examAssignDto.setInspectCollege(kcxyList);
|
|
|
+ return examAssignDto;
|
|
|
}
|
|
|
}
|