|
@@ -1,12 +1,24 @@
|
|
package com.qmth.teachcloud.report.business.service.impl;
|
|
package com.qmth.teachcloud.report.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.qmth.teachcloud.common.bean.params.UserSaveParams;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysRole;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.enums.DimensionEnum;
|
|
import com.qmth.teachcloud.common.enums.DimensionEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
|
+import com.qmth.teachcloud.common.enums.RoleTypeEnum;
|
|
import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
|
|
+import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
|
+import com.qmth.teachcloud.common.service.SysRoleService;
|
|
|
|
+import com.qmth.teachcloud.common.service.SysUserService;
|
|
import com.qmth.teachcloud.report.business.bean.dto.printOpen.*;
|
|
import com.qmth.teachcloud.report.business.bean.dto.printOpen.*;
|
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.query.TBSchoolClazzDto;
|
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.query.TBSchoolCollegeDto;
|
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.query.TBSchoolTeacherDto;
|
|
import com.qmth.teachcloud.report.business.entity.*;
|
|
import com.qmth.teachcloud.report.business.entity.*;
|
|
|
|
+import com.qmth.teachcloud.report.business.enums.NumberTypeEnum;
|
|
import com.qmth.teachcloud.report.business.service.*;
|
|
import com.qmth.teachcloud.report.business.service.*;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -42,6 +54,24 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
private TBModuleProficiencyService tbModuleProficiencyService;
|
|
private TBModuleProficiencyService tbModuleProficiencyService;
|
|
@Resource
|
|
@Resource
|
|
private TBModuleConfigService tbModuleConfigService;
|
|
private TBModuleConfigService tbModuleConfigService;
|
|
|
|
+ @Resource
|
|
|
|
+ private TBSchoolClazzService tbSchoolClazzService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysOrgService sysOrgService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysRoleService sysRoleService;
|
|
|
|
+ @Resource
|
|
|
|
+ private TBStudentService tbStudentService;
|
|
|
|
+ @Resource
|
|
|
|
+ private TBExamService tbExamService;
|
|
|
|
+ @Resource
|
|
|
|
+ private TBExamStudentService tbExamStudentService;
|
|
|
|
+ @Resource
|
|
|
|
+ private TBExamRecordService tbExamRecordService;
|
|
|
|
+ @Resource
|
|
|
|
+ private TBAnswerService tbAnswerService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private AnalyzeDataCheckService analyzeDataCheckService;
|
|
private AnalyzeDataCheckService analyzeDataCheckService;
|
|
@@ -50,11 +80,11 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
public void tbPaperDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
public void tbPaperDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
- if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,null)){
|
|
|
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
}
|
|
}
|
|
String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
- PaperConfig paperConfig = callPrintOpenApiService.callPaperConfig(examId,courseCode);
|
|
|
|
|
|
+ PaperConfig paperConfig = callPrintOpenApiService.callPaperConfig(examId, courseCode);
|
|
|
|
|
|
BigDecimal coefficient = BigDecimal.ZERO;
|
|
BigDecimal coefficient = BigDecimal.ZERO;
|
|
if (Objects.nonNull(paperConfig.getCoefficient())) {
|
|
if (Objects.nonNull(paperConfig.getCoefficient())) {
|
|
@@ -78,7 +108,7 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
tbPaper.setPaperType(paperConfig.getPaperType());
|
|
tbPaper.setPaperType(paperConfig.getPaperType());
|
|
Long startTime = tbPaper.getStartTime();
|
|
Long startTime = tbPaper.getStartTime();
|
|
Long endTime = tbPaper.getEndTime();
|
|
Long endTime = tbPaper.getEndTime();
|
|
- if (!SystemConstant.isOneNull(startTime,endTime)){
|
|
|
|
|
|
+ if (!SystemConstant.isOneNull(startTime, endTime)) {
|
|
tbPaper.setStartTime(startTime);
|
|
tbPaper.setStartTime(startTime);
|
|
tbPaper.setEndTime(endTime);
|
|
tbPaper.setEndTime(endTime);
|
|
}
|
|
}
|
|
@@ -93,10 +123,10 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
public void tbPaperDimensionDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
public void tbPaperDimensionDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
- if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,null)){
|
|
|
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
}
|
|
}
|
|
- List<PaperDimension> paperDimensionList = callPrintOpenApiService.callPaperDimension(examId,courseCode);
|
|
|
|
|
|
+ List<PaperDimension> paperDimensionList = callPrintOpenApiService.callPaperDimension(examId, courseCode);
|
|
String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
|
|
|
|
List<TBDimension> tbDimensionList = paperDimensionList.stream().flatMap(e -> {
|
|
List<TBDimension> tbDimensionList = paperDimensionList.stream().flatMap(e -> {
|
|
@@ -114,7 +144,7 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
return Stream.of(tbDimension);
|
|
return Stream.of(tbDimension);
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
// 根据课程编号删除已有
|
|
// 根据课程编号删除已有
|
|
- tbDimensionService.remove(new QueryWrapper<TBDimension>().lambda().eq(TBDimension::getExamId,examId).eq(TBDimension::getCourseCode,courseCode));
|
|
|
|
|
|
+ tbDimensionService.remove(new QueryWrapper<TBDimension>().lambda().eq(TBDimension::getExamId, examId).eq(TBDimension::getCourseCode, courseCode));
|
|
// 批量新增
|
|
// 批量新增
|
|
tbDimensionService.saveBatch(tbDimensionList);
|
|
tbDimensionService.saveBatch(tbDimensionList);
|
|
}
|
|
}
|
|
@@ -122,17 +152,17 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
public void tbPaperStructDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
public void tbPaperStructDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
- if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,null)){
|
|
|
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
}
|
|
}
|
|
- List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda().eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,courseCode));
|
|
|
|
- if (tbPaperList.size() != 1){
|
|
|
|
|
|
+ List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda().eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, courseCode));
|
|
|
|
+ if (tbPaperList.size() != 1) {
|
|
throw ExceptionResultEnum.ERROR.exception("未找到考试id为【" + examId + "】,课程编号为【" + courseCode + "】的唯一试卷");
|
|
throw ExceptionResultEnum.ERROR.exception("未找到考试id为【" + examId + "】,课程编号为【" + courseCode + "】的唯一试卷");
|
|
}
|
|
}
|
|
TBPaper tbPaper = tbPaperList.get(0);
|
|
TBPaper tbPaper = tbPaperList.get(0);
|
|
Long paperId = tbPaper.getId();
|
|
Long paperId = tbPaper.getId();
|
|
|
|
|
|
- List<PaperStructure> paperStructureList = callPrintOpenApiService.callPaperStruct(examId,courseCode);
|
|
|
|
|
|
+ List<PaperStructure> paperStructureList = callPrintOpenApiService.callPaperStruct(examId, courseCode);
|
|
|
|
|
|
List<TBPaperStruct> tbPaperStructList = paperStructureList.stream().flatMap(e -> {
|
|
List<TBPaperStruct> tbPaperStructList = paperStructureList.stream().flatMap(e -> {
|
|
TBPaperStruct tbPaperStruct = new TBPaperStruct();
|
|
TBPaperStruct tbPaperStruct = new TBPaperStruct();
|
|
@@ -148,14 +178,14 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
String knowledgeDimension = e.getKnowledgeDimension();
|
|
String knowledgeDimension = e.getKnowledgeDimension();
|
|
String abilityDimension = e.getAbilityDimension();
|
|
String abilityDimension = e.getAbilityDimension();
|
|
// TODO: 2022/6/9 校验的实现
|
|
// TODO: 2022/6/9 校验的实现
|
|
- analyzeDataCheckService.checkPaperStructInDimensionDatasource(knowledgeDimension,abilityDimension,examId,courseCode);
|
|
|
|
|
|
+ analyzeDataCheckService.checkPaperStructInDimensionDatasource(knowledgeDimension, abilityDimension, examId, courseCode);
|
|
tbPaperStruct.setKnowledgeDimension(knowledgeDimension);
|
|
tbPaperStruct.setKnowledgeDimension(knowledgeDimension);
|
|
tbPaperStruct.setAbilityDimension(abilityDimension);
|
|
tbPaperStruct.setAbilityDimension(abilityDimension);
|
|
return Stream.of(tbPaperStruct);
|
|
return Stream.of(tbPaperStruct);
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
// 删除试卷id下所有试卷结构
|
|
// 删除试卷id下所有试卷结构
|
|
- tbPaperStructService.remove(new QueryWrapper<TBPaperStruct>().lambda().eq(TBPaperStruct::getPaperId,paperId));
|
|
|
|
|
|
+ tbPaperStructService.remove(new QueryWrapper<TBPaperStruct>().lambda().eq(TBPaperStruct::getPaperId, paperId));
|
|
// 新增试卷id下的试卷结构
|
|
// 新增试卷id下的试卷结构
|
|
tbPaperStructService.saveBatch(tbPaperStructList);
|
|
tbPaperStructService.saveBatch(tbPaperStructList);
|
|
}
|
|
}
|
|
@@ -163,26 +193,26 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
public void tbPaperModuleDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
public void tbPaperModuleDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
- if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,null)){
|
|
|
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
}
|
|
}
|
|
String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
- List<PaperEvaluation> paperEvaluationList = callPrintOpenApiService.callPaperModule(examId,courseCode);
|
|
|
|
|
|
+ List<PaperEvaluation> paperEvaluationList = callPrintOpenApiService.callPaperModule(examId, courseCode);
|
|
|
|
|
|
List<TBModuleProficiency> tbModuleProficiencyList = new ArrayList<>();
|
|
List<TBModuleProficiency> tbModuleProficiencyList = new ArrayList<>();
|
|
List<TBModuleConfig> tbModuleConfigList = new ArrayList<>();
|
|
List<TBModuleConfig> tbModuleConfigList = new ArrayList<>();
|
|
- Map<DimensionEnum,PaperEvaluation> checkDimensionType = new HashMap<>();
|
|
|
|
|
|
+ Map<DimensionEnum, PaperEvaluation> checkDimensionType = new HashMap<>();
|
|
for (PaperEvaluation paperEvaluation : paperEvaluationList) {
|
|
for (PaperEvaluation paperEvaluation : paperEvaluationList) {
|
|
// 校验大的数据结构
|
|
// 校验大的数据结构
|
|
DimensionEnum moduleType = paperEvaluation.getModuleType();
|
|
DimensionEnum moduleType = paperEvaluation.getModuleType();
|
|
- if (checkDimensionType.containsKey(moduleType)){
|
|
|
|
|
|
+ if (checkDimensionType.containsKey(moduleType)) {
|
|
throw ExceptionResultEnum.ERROR.exception("模块数据存在相同模块类型【" + moduleType + "】异常");
|
|
throw ExceptionResultEnum.ERROR.exception("模块数据存在相同模块类型【" + moduleType + "】异常");
|
|
}
|
|
}
|
|
- checkDimensionType.put(moduleType,paperEvaluation);
|
|
|
|
|
|
+ checkDimensionType.put(moduleType, paperEvaluation);
|
|
|
|
|
|
String interpret = paperEvaluation.getInterpret();
|
|
String interpret = paperEvaluation.getInterpret();
|
|
String remark = paperEvaluation.getRemark();
|
|
String remark = paperEvaluation.getRemark();
|
|
- String formula = paperEvaluation.getFormula();
|
|
|
|
|
|
+ String formula = paperEvaluation.getFormula().getDesc();
|
|
|
|
|
|
// 解析并生成't_b_module_proficiency' 二级维度精熟度
|
|
// 解析并生成't_b_module_proficiency' 二级维度精熟度
|
|
List<SecondaryDimensionLevelDefine> secondaryDimensionLevelDefineList = paperEvaluation.getSecondaryDimensionLevelDefineList();
|
|
List<SecondaryDimensionLevelDefine> secondaryDimensionLevelDefineList = paperEvaluation.getSecondaryDimensionLevelDefineList();
|
|
@@ -230,19 +260,368 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
}
|
|
}
|
|
// 删除后新增
|
|
// 删除后新增
|
|
tbModuleProficiencyService.remove(new QueryWrapper<TBModuleProficiency>().lambda()
|
|
tbModuleProficiencyService.remove(new QueryWrapper<TBModuleProficiency>().lambda()
|
|
- .eq(TBModuleProficiency::getExamId,examId)
|
|
|
|
- .eq(TBModuleProficiency::getCourseCode,courseCode));
|
|
|
|
|
|
+ .eq(TBModuleProficiency::getExamId, examId)
|
|
|
|
+ .eq(TBModuleProficiency::getCourseCode, courseCode));
|
|
tbModuleProficiencyService.saveBatch(tbModuleProficiencyList);
|
|
tbModuleProficiencyService.saveBatch(tbModuleProficiencyList);
|
|
|
|
|
|
tbModuleConfigService.remove(new QueryWrapper<TBModuleConfig>().lambda()
|
|
tbModuleConfigService.remove(new QueryWrapper<TBModuleConfig>().lambda()
|
|
- .eq(TBModuleConfig::getExamId,examId)
|
|
|
|
- .eq(TBModuleConfig::getCourseCode,courseCode));
|
|
|
|
|
|
+ .eq(TBModuleConfig::getExamId, examId)
|
|
|
|
+ .eq(TBModuleConfig::getCourseCode, courseCode));
|
|
tbModuleConfigService.saveBatch(tbModuleConfigList);
|
|
tbModuleConfigService.saveBatch(tbModuleConfigList);
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
- public void tbExamStudentScoreDatasourceDispose(Long examId, String courseCode, Long schoolId) {
|
|
|
|
|
|
+ public void tbExamStudentScoreDatasourceDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
|
|
+ }
|
|
|
|
+ String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
|
|
+ List<ExamStudentScore> examStudentScoreList = callPrintOpenApiService.callExamStudentScore(examId, courseCode);
|
|
|
|
+
|
|
|
|
+ // 1.创建班级数据
|
|
|
|
+ this.createTBSchoolClazz(examStudentScoreList, schoolId);
|
|
|
|
+ // 2.筛选并创建学校学院表
|
|
|
|
+ this.createCollegeInfo(examStudentScoreList, schoolId);
|
|
|
|
+ // 3.筛选并创建教师
|
|
|
|
+ this.saveTeacherInfo(examStudentScoreList, examId, courseCode, schoolId);
|
|
|
|
+ // 4.创建学生及作答
|
|
|
|
+ this.saveExamStudentScore(examStudentScoreList, examId, courseCode, courseName, schoolId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 创建基础班级数据
|
|
|
|
+ *
|
|
|
|
+ * @param examStudentScoreList 考生成绩数据源
|
|
|
|
+ * @param schoolId 学校id
|
|
|
|
+ */
|
|
|
|
+ private void createTBSchoolClazz(List<ExamStudentScore> examStudentScoreList, Long schoolId) {
|
|
|
|
+ List<TBSchoolClazzDto> tbSchoolClazzDtoList = new ArrayList<>();
|
|
|
|
+ List<String> clazzList = examStudentScoreList.stream()
|
|
|
|
+ .map(ExamStudentScore::getClassName)
|
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
|
+ for (String clazzInfo : clazzList) {
|
|
|
|
+ TBSchoolClazzDto tbSchoolClazzDto = new TBSchoolClazzDto();
|
|
|
|
+ tbSchoolClazzDto.setSchoolId(schoolId);
|
|
|
|
+ tbSchoolClazzDto.setClazzCode(clazzInfo);
|
|
|
|
+ tbSchoolClazzDto.setClazzName(clazzInfo);
|
|
|
|
+ tbSchoolClazzDtoList.add(tbSchoolClazzDto);
|
|
|
|
+ }
|
|
|
|
+ tbSchoolClazzService.saveClazzInfo(tbSchoolClazzDtoList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 筛选并创建学校学院表
|
|
|
|
+ *
|
|
|
|
+ * @param examStudentScoreList 考生集合
|
|
|
|
+ * @param schoolId 学校id
|
|
|
|
+ */
|
|
|
|
+ private void createCollegeInfo(List<ExamStudentScore> examStudentScoreList, Long schoolId) {
|
|
|
|
+ List<TBSchoolCollegeDto> tbSchoolCollegeDtoList = new ArrayList<>();
|
|
|
|
+ List<String> collegeList = examStudentScoreList.stream()
|
|
|
|
+ .map(ExamStudentScore::getCollege)
|
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
|
+ for (String collegeInfo : collegeList) {
|
|
|
|
+ TBSchoolCollegeDto tbSchoolCollegeDto = new TBSchoolCollegeDto();
|
|
|
|
+ tbSchoolCollegeDto.setSchoolId(schoolId);
|
|
|
|
+ tbSchoolCollegeDto.setCollegeCode(collegeInfo);
|
|
|
|
+ tbSchoolCollegeDto.setCollegeName(collegeInfo);
|
|
|
|
+ tbSchoolCollegeDtoList.add(tbSchoolCollegeDto);
|
|
|
|
+ }
|
|
|
|
+ for (TBSchoolCollegeDto tbSchoolCollegeDto : tbSchoolCollegeDtoList) {
|
|
|
|
+ sysOrgService.searchOrInsert(tbSchoolCollegeDto.getSchoolId(), tbSchoolCollegeDto.getCollegeName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更新或新增教师信息
|
|
|
|
+ *
|
|
|
|
+ * @param examStudentScoreList 考生集合
|
|
|
|
+ * @param examId 考试id
|
|
|
|
+ * @param courseCode 课程编号
|
|
|
|
+ * @param schoolId 学校id
|
|
|
|
+ */
|
|
|
|
+ private void saveTeacherInfo(List<ExamStudentScore> examStudentScoreList, Long examId, String courseCode, Long schoolId) {
|
|
|
|
+ TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
|
|
|
|
+ .eq(TBExamCourse::getExamId, examId)
|
|
|
|
+ .eq(TBExamCourse::getCourseCode, courseCode)
|
|
|
|
+ .eq(TBExamCourse::getSchoolId, schoolId));
|
|
|
|
+ if (Objects.isNull(tbExamCourse)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("缺少课程数据");
|
|
|
|
+ }
|
|
|
|
+ Long teachCollegeId = tbExamCourse.getTeachCollegeId();
|
|
|
|
+ if (SystemConstant.longNotNull(teachCollegeId)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程数据缺少开课学院异常");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, String> teacherMap = new HashMap<>();
|
|
|
|
+ for (ExamStudentScore examStudentScore : examStudentScoreList) {
|
|
|
|
+ String teacherCode = examStudentScore.getTeacherCode();
|
|
|
|
+ String teacherName = examStudentScore.getTeacherName();
|
|
|
|
+ if (SystemConstant.isOneNull(teacherCode, teacherName)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("缺少教师数据");
|
|
|
|
+ }
|
|
|
|
+ if (teacherMap.containsKey(teacherCode)) {
|
|
|
|
+ String value = teacherMap.get(teacherCode);
|
|
|
|
+ if (!teacherName.equals(value)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("教师工号【" + teacherCode + "】对应多个教师名称");
|
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ teacherMap.put(teacherCode, teacherName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<TBSchoolTeacherDto> tbSchoolTeacherDtoList = teacherMap.keySet().stream().flatMap(e -> {
|
|
|
|
+ TBSchoolTeacherDto tbSchoolTeacherDto = new TBSchoolTeacherDto();
|
|
|
|
+ tbSchoolTeacherDto.setSchoolId(schoolId);
|
|
|
|
+ tbSchoolTeacherDto.setTeacherCode(e);
|
|
|
|
+ tbSchoolTeacherDto.setTeacherName(teacherMap.get(e));
|
|
|
|
+ tbSchoolTeacherDto.setOrgId(teachCollegeId);
|
|
|
|
+ return Stream.of(tbSchoolTeacherDto);
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Map<String, String> checkMap = new HashMap<>();
|
|
|
|
+ for (TBSchoolTeacherDto tbSchoolTeacherDto : tbSchoolTeacherDtoList) {
|
|
|
|
+ if (checkMap.containsKey(tbSchoolTeacherDto.getTeacherCode())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ SysUser old = sysUserService.getOne(new QueryWrapper<SysUser>().lambda()
|
|
|
|
+ .eq(SysUser::getSchoolId, tbSchoolTeacherDto.getSchoolId())
|
|
|
|
+ .eq(SysUser::getLoginName, tbSchoolTeacherDto.getTeacherCode())
|
|
|
|
+ .eq(SysUser::getRealName, tbSchoolTeacherDto.getTeacherName()));
|
|
|
|
+ checkMap.put(tbSchoolTeacherDto.getTeacherCode(), tbSchoolTeacherDto.getTeacherName());
|
|
|
|
+ Long id = 0L;
|
|
|
|
+ if (Objects.nonNull(old)) {
|
|
|
|
+ id = old.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysRole teacherRole = sysRoleService.list(new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.TEACHER)).get(0);
|
|
|
|
+ List<Long> roleIds = new ArrayList<>();
|
|
|
|
+ roleIds.add(teacherRole.getId());
|
|
|
|
+
|
|
|
|
+ UserSaveParams userSaveParams = new UserSaveParams();
|
|
|
|
+ if (id > 0) {
|
|
|
|
+ userSaveParams.setId(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ userSaveParams.setSchoolId(tbSchoolTeacherDto.getSchoolId());
|
|
|
|
+ userSaveParams.setLoginName(tbSchoolTeacherDto.getTeacherCode());
|
|
|
|
+ userSaveParams.setRealName(tbSchoolTeacherDto.getTeacherName());
|
|
|
|
+ userSaveParams.setPassword(SystemConstant.DEFAULT_PASSWORD);
|
|
|
|
+ userSaveParams.setOrgId(tbSchoolTeacherDto.getOrgId());
|
|
|
|
+ userSaveParams.setEnable(true);
|
|
|
|
+ userSaveParams.setRoleIds(roleIds.toArray(new Long[0]));
|
|
|
|
+ sysUserService.saveUserNoAuth(userSaveParams);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增处理考生成绩相关数据
|
|
|
|
+ * <p>
|
|
|
|
+ * 1.t_b_student
|
|
|
|
+ * 2.t_b_exam_student
|
|
|
|
+ * 3.t_b_exam_record
|
|
|
|
+ * 4.t_b_answer
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @param examStudentScoreList 考生成绩相关信息
|
|
|
|
+ * @param examId 考试id
|
|
|
|
+ * @param courseCode 课程编号
|
|
|
|
+ * @param courseName 课程名称
|
|
|
|
+ * @param schoolId 学校id
|
|
|
|
+ */
|
|
|
|
+ private void saveExamStudentScore(List<ExamStudentScore> examStudentScoreList, Long examId, String courseCode, String courseName, Long schoolId) {
|
|
|
|
+ List<TBStudent> tbStudentList = new ArrayList<>();
|
|
|
|
+ List<TBExamStudent> tbExamStudentList = new ArrayList<>();
|
|
|
|
+ List<TBExamRecord> tbExamRecordList = new ArrayList<>();
|
|
|
|
+ List<TBAnswer> tbAnswerList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<String> paperTypeList = examStudentScoreList.stream().map(ExamStudentScore::getPaperType).distinct().collect(Collectors.toList());
|
|
|
|
+ final String specialPaperType = "#";
|
|
|
|
+ paperTypeList.remove(specialPaperType);
|
|
|
|
+ int count = paperTypeList.size();
|
|
|
|
+ int i = 0;
|
|
|
|
+
|
|
|
|
+ Map<String, TBStudent> checkMap = new HashMap<>();
|
|
|
|
+ for (ExamStudentScore examStudentScore : examStudentScoreList) {
|
|
|
|
+ String studentCode = examStudentScore.getStudentCode(); //学号
|
|
|
|
+ String name = examStudentScore.getName(); //名称
|
|
|
|
+ String paperType = examStudentScore.getPaperType(); //试卷类型
|
|
|
|
+ // 循环依次为#生成(分配)试卷编号为A、B、C......A、B、C......
|
|
|
|
+ if (count > 0 && paperType.equals(specialPaperType)) {
|
|
|
|
+ paperType = paperTypeList.get(i);
|
|
|
|
+ i++;
|
|
|
|
+ if (i == count) {
|
|
|
|
+ i = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String college = examStudentScore.getCollege(); //学院
|
|
|
|
+ String className = examStudentScore.getClassName(); //班级名称
|
|
|
|
+ String teacherCode = examStudentScore.getTeacherCode(); //教师
|
|
|
|
+ String teacherName = examStudentScore.getTeacherName();
|
|
|
|
+ // 缺考状态 2 -> 缺考 ; 3 -> 违纪
|
|
|
|
+ int status = examStudentScore.getStatus(); //学生考试状态
|
|
|
|
+ BigDecimal totalScore = examStudentScore.getTotalScore(); //考生总分
|
|
|
|
+ BigDecimal objectiveScore = examStudentScore.getObjectiveScore(); //客观题总分
|
|
|
|
+ BigDecimal subjectiveScore = examStudentScore.getSubjectiveScore(); //主观题总分
|
|
|
|
+ List<AnswerInfo> objectiveScoreDetailList = examStudentScore.getObjectiveScoreDetail(); //客观题明细
|
|
|
|
+ List<AnswerInfo> subjectiveScoreDetailList = examStudentScore.getSubjectiveScoreDetail(); //主观题答题明细
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ 组建学生基础信息 student
|
|
|
|
+ */
|
|
|
|
+ if (checkMap.containsKey(studentCode)) {
|
|
|
|
+ if (!checkMap.get(studentCode).getName().equals(name)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("有学号【" + studentCode + "】的学生名称不统一");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ TBStudent studentTemp = tbStudentService.getOne(new QueryWrapper<TBStudent>().lambda()
|
|
|
|
+ .eq(TBStudent::getSchoolId, schoolId)
|
|
|
|
+ .eq(TBStudent::getStudentCode, studentCode));
|
|
|
|
+ Long studentId;
|
|
|
|
+ if (Objects.nonNull(studentTemp)) {
|
|
|
|
+ studentId = studentTemp.getId();
|
|
|
|
+ } else {
|
|
|
|
+ studentId = SystemConstant.getDbUuid();
|
|
|
|
+ }
|
|
|
|
+ TBStudent tbStudent = new TBStudent();
|
|
|
|
+ tbStudent.setId(studentId);
|
|
|
|
+ tbStudent.setSchoolId(schoolId);
|
|
|
|
+ tbStudent.setName(name);
|
|
|
|
+ tbStudent.setStudentCode(studentCode);
|
|
|
|
+ checkMap.put(studentCode, tbStudent);
|
|
|
|
+ tbStudentList.add(tbStudent);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ 组建考生考试信息 exm_pap_tik
|
|
|
|
+ */
|
|
|
|
+ // 开课学院id
|
|
|
|
+ TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
|
|
|
|
+ .eq(TBExamCourse::getExamId, examId)
|
|
|
|
+ .eq(TBExamCourse::getCourseCode, courseCode)
|
|
|
|
+ .eq(TBExamCourse::getSchoolId, schoolId));
|
|
|
|
+ if (Objects.isNull(tbExamCourse)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("缺少课程数据");
|
|
|
|
+ }
|
|
|
|
+ Long teachCollegeId = tbExamCourse.getTeachCollegeId();
|
|
|
|
+ if (SystemConstant.longNotNull(teachCollegeId)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程数据缺少开课学院异常");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取关联的基础表主键
|
|
|
|
+ SysOrg tbSchoolCollege = sysOrgService.findByForeignKey(schoolId, college, college);
|
|
|
|
+ TBSchoolClazz tbSchoolClazz = tbSchoolClazzService.findByForeignKey(schoolId, className, className);
|
|
|
|
+ SysUser tbSchoolTeacher = sysUserService.findByForeignKey(schoolId, teacherCode);
|
|
|
|
+
|
|
|
|
+ TBExamStudent tbExamStudent = new TBExamStudent();
|
|
|
|
+ Long examStudentId = SystemConstant.getDbUuid();
|
|
|
|
+ tbExamStudent.setId(examStudentId);
|
|
|
|
+ tbExamStudent.setSchoolId(tbExamService.getById(examId).getSchoolId());
|
|
|
|
+ tbExamStudent.setExamId(examId);
|
|
|
|
+ tbExamStudent.setName(name);
|
|
|
|
+ tbExamStudent.setStudentId(checkMap.get(studentCode).getId());
|
|
|
|
+ tbExamStudent.setStudentCode(studentCode);
|
|
|
|
+ tbExamStudent.setCourseCode(courseCode);
|
|
|
|
+ tbExamStudent.setCourseName(courseName);
|
|
|
|
+ tbExamStudent.setTeachCollegeId(teachCollegeId);
|
|
|
|
+ tbExamStudent.setInspectCollegeId(tbSchoolCollege.getId());
|
|
|
|
+ tbExamStudent.setClazzId(tbSchoolClazz.getId());
|
|
|
|
+ tbExamStudent.setMajorId(0L);
|
|
|
|
+ if (Objects.nonNull(tbSchoolTeacher)) {
|
|
|
|
+ tbExamStudent.setTeacherId(tbSchoolTeacher.getId());
|
|
|
|
+ } else {
|
|
|
|
+ tbExamStudent.setTeacherId(0L);
|
|
|
|
+ }
|
|
|
|
+ tbExamStudent.setTicketNumber(studentCode);
|
|
|
|
+ tbExamStudent.setAbsent(status == 2 || status == 3);
|
|
|
|
+ // 全部设置为本届
|
|
|
|
+ tbExamStudent.setStudentCurrent(true);
|
|
|
|
+ tbExamStudentList.add(tbExamStudent);
|
|
|
|
+
|
|
|
|
+ // 构建考生作答记录表(t_b_exam_record)
|
|
|
|
+ Long examRecordId = SystemConstant.getDbUuid();
|
|
|
|
+ TBExamRecord tbExamRecord = new TBExamRecord();
|
|
|
|
+ tbExamRecord.setId(examRecordId);
|
|
|
|
+ tbExamRecord.setExamId(examId);
|
|
|
|
+ tbExamRecord.setPaperId(tbPaperService.findByForeignKey(examId, courseCode, courseName, paperType).getId());
|
|
|
|
+ tbExamRecord.setPaperType(paperType);
|
|
|
|
+ tbExamRecord.setExamStudentId(examStudentId);
|
|
|
|
+ tbExamRecord.setSubjectiveScore(subjectiveScore);
|
|
|
|
+ tbExamRecord.setObjectiveScore(objectiveScore);
|
|
|
|
+ tbExamRecord.setTotalScore(totalScore);
|
|
|
|
+ tbExamRecordList.add(tbExamRecord);
|
|
|
|
+
|
|
|
|
+ // 构建考生作答明细表(t_b_answer)正常考生才记录
|
|
|
|
+ // 客观题(选择)
|
|
|
|
+ if (status == 1) {
|
|
|
|
+ for (AnswerInfo objective : objectiveScoreDetailList) {
|
|
|
|
+ Long answerId = SystemConstant.getDbUuid();
|
|
|
|
+ TBAnswer tbAnswer = new TBAnswer();
|
|
|
|
+ tbAnswer.setId(answerId);
|
|
|
|
+ tbAnswer.setExamRecordId(examRecordId);
|
|
|
|
+ tbAnswer.setNumberType(NumberTypeEnum.OBJECTIVE.getValue());
|
|
|
|
+ String cloudMainNumber = String.valueOf(objective.getMainNumber());
|
|
|
|
+ String cloudSubNumber = objective.getSubNumber();
|
|
|
|
+ tbAnswer.setMainNumber(cloudMainNumber);
|
|
|
|
+ tbAnswer.setSubNumber(cloudSubNumber);
|
|
|
|
+ tbAnswer.setScore(objective.getScore());
|
|
|
|
+ tbAnswer.setAnswer(objective.getAnswer());
|
|
|
|
+ tbAnswerList.add(tbAnswer);
|
|
|
|
+ }
|
|
|
|
+ // 主观题
|
|
|
|
+ for (AnswerInfo subjective : subjectiveScoreDetailList) {
|
|
|
|
+ Long answerId = SystemConstant.getDbUuid();
|
|
|
|
+ TBAnswer tbAnswer = new TBAnswer();
|
|
|
|
+ tbAnswer.setId(answerId);
|
|
|
|
+ tbAnswer.setExamRecordId(examRecordId);
|
|
|
|
+ tbAnswer.setNumberType(NumberTypeEnum.SUBJECTIVE.getValue());
|
|
|
|
+ String cloudMainNumber = String.valueOf(subjective.getMainNumber());
|
|
|
|
+ String cloudSubNumber = subjective.getSubNumber();
|
|
|
|
+ tbAnswer.setMainNumber(cloudMainNumber);
|
|
|
|
+ tbAnswer.setSubNumber(cloudSubNumber);
|
|
|
|
+ tbAnswer.setScore(subjective.getScore());
|
|
|
|
+ tbAnswer.setAnswer(subjective.getAnswer());
|
|
|
|
+ tbAnswerList.add(tbAnswer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 处理并向数据库插入学生信息
|
|
|
|
+ tbStudentService.saveOrUpdateBatch(tbStudentList);
|
|
|
|
+
|
|
|
|
+ // 删除原t_b_answer、t_b_exam_record、t_b_exam_student表数据
|
|
|
|
+ List<String> courseInfoList = tbExamStudentList.stream().map(TBExamStudent::getCourseCode).collect(Collectors.toList());
|
|
|
|
+ Set<Long> examStudentRemoveIdSet = new HashSet<>();
|
|
|
|
+ for (String s : courseInfoList) {
|
|
|
|
+ Set<Long> ids = tbExamStudentService.list(new QueryWrapper<TBExamStudent>().lambda()
|
|
|
|
+ .eq(TBExamStudent::getCourseCode, s))
|
|
|
|
+ .stream().map(TBExamStudent::getId).collect(Collectors.toSet());
|
|
|
|
+ examStudentRemoveIdSet.addAll(ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (examStudentRemoveIdSet.size() > 0) {
|
|
|
|
+ // 删除考生表
|
|
|
|
+ tbExamStudentService.removeByIds(examStudentRemoveIdSet);
|
|
|
|
+ List<TBExamRecord> willRemoveRecord = tbExamRecordService.list(new QueryWrapper<TBExamRecord>()
|
|
|
|
+ .lambda().in(TBExamRecord::getExamStudentId, examStudentRemoveIdSet));
|
|
|
|
+ if (willRemoveRecord.size() > 0) {
|
|
|
|
+ List<Long> willRemoveRecordIdList = willRemoveRecord.stream().map(TBExamRecord::getId).collect(Collectors.toList());
|
|
|
|
+ // 删除考生作答
|
|
|
|
+ tbExamRecordService.removeByIds(willRemoveRecordIdList);
|
|
|
|
+ // 删除考生作答
|
|
|
|
+ tbAnswerService.remove(new QueryWrapper<TBAnswer>().lambda().in(TBAnswer::getExamRecordId, willRemoveRecordIdList));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // 保存数据
|
|
|
|
+ tbExamStudentService.saveBatch(tbExamStudentList);
|
|
|
|
+ tbExamRecordService.saveBatch(tbExamRecordList);
|
|
|
|
+ tbAnswerService.saveBatch(tbAnswerList);
|
|
}
|
|
}
|
|
}
|
|
}
|