|
@@ -8,6 +8,7 @@ import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
|
import com.qmth.boot.tools.excel.model.DataMap;
|
|
|
import com.qmth.distributed.print.business.bean.dto.ObjectiveStructDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.SubjectiveStructDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.SubjectiveStructImportDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.importFile.BasicExamStudentImport;
|
|
|
import com.qmth.distributed.print.business.bean.dto.importFile.BasicExamStudentParseDto;
|
|
|
import com.qmth.distributed.print.business.entity.BasicExamRule;
|
|
@@ -23,12 +24,15 @@ import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableDisabledValue;
|
|
|
import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
|
|
|
import com.qmth.teachcloud.common.bean.params.UserSaveParams;
|
|
|
import com.qmth.teachcloud.common.bean.result.ExcelResult;
|
|
|
+import com.qmth.teachcloud.common.bean.result.SysUserResult;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
|
import com.qmth.teachcloud.common.enums.*;
|
|
|
import com.qmth.teachcloud.common.service.*;
|
|
|
import com.qmth.teachcloud.common.util.ConvertUtil;
|
|
|
+import com.qmth.teachcloud.mark.bean.answerbatch.Paper;
|
|
|
import com.qmth.teachcloud.mark.entity.MarkPaper;
|
|
|
+import com.qmth.teachcloud.mark.entity.MarkUserQuestion;
|
|
|
import com.qmth.teachcloud.mark.service.MarkPaperService;
|
|
|
import com.qmth.teachcloud.mark.service.MarkQuestionAnswerService;
|
|
|
import com.qmth.teachcloud.mark.service.MarkQuestionService;
|
|
@@ -1096,271 +1100,205 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
throw ExceptionResultEnum.ERROR.exception("考试不存在");
|
|
|
}
|
|
|
if (!ExamModelEnum.MODEL4.equals(basicExam.getExamModel())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("仅针对模式4的考试可以导入");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("非模式4的考试,无法使用此功能");
|
|
|
}
|
|
|
- SysRole markerRole = sysRoleService.getOne(
|
|
|
- new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.MARKER));
|
|
|
+ SysRole markerRole = sysRoleService.getOne(new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.MARKER));
|
|
|
if (Objects.isNull(markerRole)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("缺少评卷员角色");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("系统中未查询到评卷员角色,请联系管理员");
|
|
|
}
|
|
|
|
|
|
- // 课程编号名称校验
|
|
|
- Map<String, Set<String>> courseCheckMap = basicCourseService.list(
|
|
|
- new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getSchoolId, schoolId)).stream().collect(
|
|
|
- Collectors.toMap(BasicCourse::getCode, v -> new HashSet<>(Collections.singletonList(v.getName())),
|
|
|
- (Set<String> v1, Set<String> v2) -> {
|
|
|
- v1.addAll(v2);
|
|
|
- return v1;
|
|
|
- }));
|
|
|
List<MarkPaper> markPaperList = markPaperService.findMarkPaperListByExamId(examId);
|
|
|
- // 题号重复校验
|
|
|
- // 导入的客观题题号集合
|
|
|
- Set<String> questionNumberCheckSet = new HashSet<>();
|
|
|
- // 该试卷已存在的客观题题号集合
|
|
|
- Set<String> dbObjectiveQuestionNumberSet = markQuestionService.list(
|
|
|
- new QueryWrapper<MarkQuestion>().lambda().eq(MarkQuestion::getExamId, examId)
|
|
|
- .eq(MarkQuestion::getObjective, true)).stream()
|
|
|
- .map(e -> e.getPaperNumber() + SystemConstant.HYPHEN + e.getMainNumber() + SystemConstant.HYPHEN + e.getSubNumber()).collect(Collectors.toSet());
|
|
|
+ Map<String, MarkPaper> markPaperCourseMap = markPaperList.stream().collect(Collectors.toMap(MarkPaper::getCourseCode, Function.identity()));
|
|
|
+ Map<String, MarkPaper> markPaperPaperNumberMap = markPaperList.stream().collect(Collectors.toMap(MarkPaper::getPaperNumber, Function.identity()));
|
|
|
|
|
|
- ExcelResult<SubjectiveStructDto> excelResult = ConvertUtil.analyzeExcel(inputStream, SubjectiveStructDto.class,
|
|
|
- true, 0);
|
|
|
- List<SubjectiveStructDto> subjectiveStructDtoList = excelResult.getDatasource();
|
|
|
- for (SubjectiveStructDto subjectiveStructDto : subjectiveStructDtoList) {
|
|
|
- List<String> excelErrorList = new ArrayList<>();
|
|
|
- // 公共异常提示
|
|
|
- String excelErrorCommonNotice = "";
|
|
|
+ List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndObjective(examId, false);
|
|
|
+ Set<String> subjectivePaperNumberSet = markQuestionList.stream().map(MarkQuestion::getPaperNumber).collect(Collectors.toSet());
|
|
|
|
|
|
- String courseCode = subjectiveStructDto.getCourseCode();
|
|
|
- String courseName = subjectiveStructDto.getCourseName();
|
|
|
- String paperNumber = subjectiveStructDto.getPaperNumber();
|
|
|
- Integer mainNumber = subjectiveStructDto.getMainNumber();
|
|
|
- Integer subNumber = subjectiveStructDto.getSubNumber();
|
|
|
- Integer markerCount = subjectiveStructDto.getMarkerCount();
|
|
|
- String markerCodes = subjectiveStructDto.getMarkerCodes();
|
|
|
- String errorMsg = subjectiveStructDto.getErrorMsg();
|
|
|
+ List<MarkQuestion> markQuestionList1 = markQuestionService.listByExamIdAndObjective(examId, true);
|
|
|
+ Set<String> objectivePaperNumberSet = markQuestionList1.stream().map(m -> SystemConstant.mergeString(SystemConstant.HYPHEN, m.getPaperNumber(), m.getMainNumber(), m.getSubNumber())).collect(Collectors.toSet());
|
|
|
|
|
|
- // 1.题号重复校验
|
|
|
- if (SystemConstant.strNotNull(paperNumber) && mainNumber != null && subNumber != null) {
|
|
|
- excelErrorCommonNotice = String.format("课程代码为[%s],试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ", courseCode,
|
|
|
- paperNumber, mainNumber, subNumber);
|
|
|
- String questionNumberKey =
|
|
|
- courseCode + SystemConstant.HYPHEN + paperNumber + SystemConstant.HYPHEN + mainNumber + SystemConstant.HYPHEN + subNumber;
|
|
|
- if (questionNumberCheckSet.contains(questionNumberKey)) {
|
|
|
- excelErrorList.add("excel中题号重复");
|
|
|
- } else {
|
|
|
- questionNumberCheckSet.add(questionNumberKey);
|
|
|
+ List<SysUserResult> sysUserList = sysUserService.listBySchoolId(schoolId);
|
|
|
+ Map<String, SysUserResult> sysUserMap = sysUserList.stream().collect(Collectors.toMap(SysUserResult::getLoginName, Function.identity()));
|
|
|
+
|
|
|
+ ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, inputStream, 0);
|
|
|
+ List<SubjectiveStructImportDto> subjectiveStructDtoList = excelReader.getObjectList(SubjectiveStructImportDto.class);
|
|
|
+
|
|
|
+ // 课程下试卷编号map
|
|
|
+ Map<String, String> coursePaperNumberMap = new HashMap<>();
|
|
|
+ // 课程、试卷编号下大题号、小题号
|
|
|
+ Map<String, String> coursePaperQuestionMap = new HashMap<>();
|
|
|
+
|
|
|
+ List<MarkQuestion> markQuestions = new ArrayList<>();
|
|
|
+ List<MarkUserQuestion> markUserQuestions = new ArrayList<>();
|
|
|
+ boolean hasError = false;
|
|
|
+ List<SubjectiveStructDto> subjectiveStructDtos = new ArrayList<>();
|
|
|
+ // 按课程+试卷编号分组
|
|
|
+ for (SubjectiveStructImportDto subjectiveStructImportDto : subjectiveStructDtoList) {
|
|
|
+ SubjectiveStructDto subjectiveStructDto = new SubjectiveStructDto();
|
|
|
+ BeanUtils.copyProperties(subjectiveStructImportDto, subjectiveStructDto);
|
|
|
+ try {
|
|
|
+ List<String> errorList = new ArrayList<>();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(subjectiveStructDto.getCourseCode())) {
|
|
|
+ errorList.add("课程代码不能为空");
|
|
|
}
|
|
|
- if (dbObjectiveQuestionNumberSet.contains(questionNumberKey)) {
|
|
|
- excelErrorList.add("该题号已存在客观题中");
|
|
|
+ if (StringUtils.isBlank(subjectiveStructDto.getCourseName())) {
|
|
|
+ errorList.add("课程名称不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(subjectiveStructDto.getPaperNumber())) {
|
|
|
+ errorList.add("试卷编号不能为空");
|
|
|
+ }
|
|
|
+ Integer mainNumber = subjectiveStructDto.getMainNumber();
|
|
|
+ if (mainNumber == null) {
|
|
|
+ errorList.add("大题号不能为空");
|
|
|
+ }
|
|
|
+ Integer subNumber = subjectiveStructDto.getSubNumber();
|
|
|
+ if (subNumber == null) {
|
|
|
+ errorList.add("小题号不能为空");
|
|
|
+ }
|
|
|
+ Double totalScore = subjectiveStructDto.getTotalScore();
|
|
|
+ if (totalScore == null) {
|
|
|
+ errorList.add("小题满分不能为空");
|
|
|
+ }
|
|
|
+ Double intervalScore = subjectiveStructDto.getIntervalScore();
|
|
|
+ if (intervalScore == null) {
|
|
|
+ errorList.add("小题号不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(subjectiveStructDto.getMarkerCodes())) {
|
|
|
+ errorList.add("绑定工号不能为空");
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 2.校验课程代码,课程名称,试卷在考试下是否存在
|
|
|
- if (SystemConstant.strNotNull(courseCode) && SystemConstant.strNotNull(courseName) && SystemConstant.strNotNull(paperNumber)) {
|
|
|
- if (!courseCheckMap.containsKey(courseCode)) {
|
|
|
- excelErrorList.add("课程代码不存在");
|
|
|
- } else if (!courseCheckMap.get(courseCode).contains(courseName)) {
|
|
|
- excelErrorList.add("课程代码名称不匹配");
|
|
|
+ if (CollectionUtils.isNotEmpty(errorList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
}
|
|
|
- if (markPaperList.stream().noneMatch(
|
|
|
- m -> m.getPaperNumber().equals(paperNumber) && m.getCourseCode().equals(courseCode) && m.getCourseName().equals(courseName))) {
|
|
|
- excelErrorList.add("考试课程中不存在该试卷,请先创建试卷");
|
|
|
+
|
|
|
+ if (totalScore < intervalScore) {
|
|
|
+ errorList.add("最小分不能大于小题满分");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 3.评卷员校验
|
|
|
- if (Objects.isNull(markerCount) && Objects.isNull(markerCodes)) {
|
|
|
- excelErrorList.add("[评卷员数量(系统生成)]和[绑定工号(英文逗号分隔)]不能同时为空");
|
|
|
- }
|
|
|
+ String courseCode = subjectiveStructDto.getCourseCode().trim();
|
|
|
+ String courseName = subjectiveStructDto.getCourseName().trim();
|
|
|
+ String paperNumber = subjectiveStructDto.getPaperNumber().trim();
|
|
|
|
|
|
- // 整理异常信息
|
|
|
- if (CollectionUtils.isNotEmpty(excelErrorList)) {
|
|
|
- if (SystemConstant.strNotNull(errorMsg)) {
|
|
|
- errorMsg = errorMsg + "、" + excelErrorCommonNotice + String.join("、", excelErrorList);
|
|
|
+ // 课程是否存在
|
|
|
+ if (!markPaperCourseMap.containsKey(courseCode)) {
|
|
|
+ errorList.add("未查询到此课程");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
} else {
|
|
|
- errorMsg = excelErrorCommonNotice + String.join("、", excelErrorList);
|
|
|
- }
|
|
|
- subjectiveStructDto.setErrorMsg(errorMsg);
|
|
|
- }
|
|
|
- }
|
|
|
- if (subjectiveStructDtoList.stream().anyMatch(e -> SystemConstant.strNotNull(e.getErrorMsg()))) {
|
|
|
- // 抛出excel解析异常
|
|
|
- throw ExceptionResultEnum.ERROR.exception(
|
|
|
- subjectiveStructDtoList.stream().map(SubjectiveStructDto::getErrorMsg).filter(SystemConstant::strNotNull).collect(Collectors.joining(System.lineSeparator())));
|
|
|
- } else {
|
|
|
- List<String> paperErrorList = new ArrayList<>();
|
|
|
- // 试卷编号-> 题目集合 Map
|
|
|
- Map<String, List<SubjectiveStructDto>> paperQuestionsMap = subjectiveStructDtoList.stream().collect(Collectors.groupingBy(SubjectiveStructDto::getPaperNumber));
|
|
|
- paperQuestionsMap.forEach((paperNumber, paperQuestionList) -> {
|
|
|
- // todo 2025-02-25
|
|
|
- if(true) /*(markGroupService.countByExamIdAndPaperNumber(examId, paperNumber) > 0) {
|
|
|
- paperErrorList.add(String.format("[试卷编号]%s,已存在分组,请先删除该试卷的所有分组再导入试题", paperNumber));
|
|
|
- } else */{
|
|
|
- MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(examId, paperNumber);
|
|
|
- Long courseId = markPaper.getCourseId();
|
|
|
- BasicCourse basicCourse = basicCourseService.getById(courseId);
|
|
|
- String orgName;
|
|
|
- Long orgId;
|
|
|
- if (Objects.isNull(basicCourse)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("无法找到课程");
|
|
|
- } else {
|
|
|
- Long teachingRoomId = basicCourse.getTeachingRoomId();
|
|
|
- SysOrg sysOrg = sysOrgService.getById(teachingRoomId);
|
|
|
- if (Objects.isNull(sysOrg)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("无法找到机构");
|
|
|
- }
|
|
|
- orgName = sysOrg.getName();
|
|
|
- orgId = sysOrg.getId();
|
|
|
+ MarkPaper markPaper = markPaperCourseMap.get(courseCode);
|
|
|
+ if (!courseName.equals(markPaper.getCourseName())) {
|
|
|
+ errorList.add("评卷设置中,课程名称为[" + markPaper.getCourseName() + "]");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
}
|
|
|
+ subjectiveStructDto.setCourseId(markPaper.getCourseId());
|
|
|
+ }
|
|
|
|
|
|
- // 优先删除该试卷的主观题
|
|
|
- markQuestionService.remove(
|
|
|
- new QueryWrapper<MarkQuestion>().lambda().eq(MarkQuestion::getExamId, examId)
|
|
|
- .eq(MarkQuestion::getPaperNumber, paperNumber).eq(MarkQuestion::getObjective, false));
|
|
|
-
|
|
|
- // 试卷下分组集合
|
|
|
- List<Integer> groupNumberList = paperQuestionList.stream().map(SubjectiveStructDto::getGroupNumber)
|
|
|
- .distinct().sorted().collect(Collectors.toList());
|
|
|
-
|
|
|
- // 评卷员序号
|
|
|
- AtomicInteger markerNumber = new AtomicInteger(0);
|
|
|
- for (Integer groupNumber : groupNumberList) {
|
|
|
- List<String> groupErrorList = new ArrayList<>();
|
|
|
- // 分组下题目集合
|
|
|
- List<SubjectiveStructDto> groupQuestionList = paperQuestionList.stream()
|
|
|
- .filter(e -> e.getGroupNumber().equals(groupNumber)).collect(Collectors.toList());
|
|
|
-
|
|
|
- String paperNumberGroupNumberNotice = String.format("[试卷编号]%s,[评卷分组(只能用小写数字)]%s,的", paperNumber,
|
|
|
- groupNumber);
|
|
|
-
|
|
|
- Integer markerCount = null;
|
|
|
- String markerCodes = null;
|
|
|
- List<Integer> markerCountList = groupQuestionList.stream().map(SubjectiveStructDto::getMarkerCount).distinct().collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isNotEmpty(markerCountList)) {
|
|
|
- if (markerCountList.size() > 1) {
|
|
|
- groupErrorList.add("[评卷员数量(系统生成)]不一致");
|
|
|
- } else if (markerCountList.size() == 1) {
|
|
|
- markerCount = markerCountList.get(0);
|
|
|
- }
|
|
|
- }
|
|
|
+ // 试卷编号是否存在
|
|
|
+ if (!markPaperPaperNumberMap.containsKey(paperNumber)) {
|
|
|
+ errorList.add("未查询到此试卷编号");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
+ }
|
|
|
|
|
|
- List<String> markerCodesList = groupQuestionList.stream().map(SubjectiveStructDto::getMarkerCodes).distinct().collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isNotEmpty(markerCodesList)) {
|
|
|
- if (markerCodesList.size() > 1) {
|
|
|
- groupErrorList.add("[绑定工号(英文逗号分隔)]不一致");
|
|
|
- } else if (markerCodesList.size() == 1) {
|
|
|
- markerCodes = markerCodesList.get(0);
|
|
|
- }
|
|
|
- }
|
|
|
+ // 试卷编号是否设置了主观题
|
|
|
+ if (subjectivePaperNumberSet.contains(paperNumber)) {
|
|
|
+ errorList.add("试卷编号设置了主观题");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
+ }
|
|
|
|
|
|
- // 组装评卷员信息
|
|
|
- List<MarkUser> markUsers = new ArrayList<>();
|
|
|
- if (SystemConstant.strNotNull(markerCodes)) {
|
|
|
- // 优先以绑定工号为准
|
|
|
- String[] markerCodeArray = markerCodes.split(SystemConstant.COMMA);
|
|
|
- for (String markerCode : markerCodeArray) {
|
|
|
- SysUser sysUser = sysUserService.getOne(
|
|
|
- new QueryWrapper<SysUser>().lambda().eq(SysUser::getSchoolId, schoolId).eq(SysUser::getLoginName, markerCode).last(SystemConstant.LIMIT1));
|
|
|
- if (Objects.isNull(sysUser)) {
|
|
|
- groupErrorList.add(paperNumberGroupNumberNotice + String.format(
|
|
|
- "[绑定工号(英文逗号分隔)]中的%s,在系统中不存在请先创建用户", markerCode));
|
|
|
- } else {
|
|
|
- // 添加评卷员信息
|
|
|
- MarkUser markUser = new MarkUser();
|
|
|
- markUser.setUserId(sysUser.getId());
|
|
|
- markUser.setLoginName(sysUser.getLoginName());
|
|
|
- markUser.setName(sysUser.getRealName());
|
|
|
- markUser.setOrgName(orgName);
|
|
|
- markUsers.add(markUser);
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (Objects.nonNull(markerCount) && markerCount > 0) {
|
|
|
- // 没有绑定工号且评卷员生成数量大于0,生成评卷员(或使用之前工号相同的评卷员)
|
|
|
- for (int i = 0; i < markerCount; i++) {
|
|
|
- int num = markerNumber.incrementAndGet();
|
|
|
- if (num > 99) {
|
|
|
- paperErrorList.add("[试卷编号]%s的[评卷员数量(系统生成)]总有效数量不能超过99");
|
|
|
- break;
|
|
|
- }
|
|
|
- String markerCode = paperNumber + String.format("%02d", num);
|
|
|
-
|
|
|
- SysUser sysUser = sysUserService.getOne(
|
|
|
- new QueryWrapper<SysUser>().lambda().eq(SysUser::getSchoolId, schoolId).eq(SysUser::getLoginName, markerCode).last(SystemConstant.LIMIT1));
|
|
|
-
|
|
|
- MarkUser markUser = new MarkUser();
|
|
|
- markUser.setLoginName(markerCode);
|
|
|
- markUser.setOrgName(orgName);
|
|
|
- markUsers.add(markUser);
|
|
|
- if (Objects.nonNull(sysUser)) {
|
|
|
- markUser.setUserId(sysUser.getId());
|
|
|
- markUser.setName(sysUser.getRealName());
|
|
|
- } else {
|
|
|
- // 创建用户
|
|
|
- UserSaveParams userSaveParams = new UserSaveParams();
|
|
|
- userSaveParams.setSchoolId(schoolId);
|
|
|
- userSaveParams.setLoginName(markerCode);
|
|
|
- userSaveParams.setRealName(markerCode);
|
|
|
- userSaveParams.setCode(markerCode);
|
|
|
- userSaveParams.setPassword(SystemConstant.DEFAULT_PASSWORD);
|
|
|
- userSaveParams.setOrgId(orgId);
|
|
|
- userSaveParams.setEnable(true);
|
|
|
- userSaveParams.setRoleIds(new Long[]{markerRole.getId()});
|
|
|
- try {
|
|
|
- markUser.setUserId(sysUserService.saveUser(userSaveParams, requestUser.getId()));
|
|
|
- markUser.setName(markerCode);
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (CollectionUtils.isEmpty(groupErrorList) && CollectionUtils.isEmpty(paperErrorList)) {
|
|
|
- // 创建评卷试题
|
|
|
- List<MarkQuestion> markQuestionList = paperQuestionList.stream().filter(e -> groupNumber.equals(e.getGroupNumber())).flatMap(e -> {
|
|
|
- MarkQuestion markQuestion = new MarkQuestion();
|
|
|
- markQuestion.setExamId(examId);
|
|
|
- markQuestion.setPaperNumber(paperNumber);
|
|
|
- markQuestion.setPaperType(OptionsEnum.A.getCode());
|
|
|
- markQuestion.setObjective(false);
|
|
|
- markQuestion.setMainNumber(e.getMainNumber());
|
|
|
- markQuestion.setSubNumber(e.getSubNumber());
|
|
|
- markQuestion.setMainTitle(e.getMainTitle());
|
|
|
- markQuestion.setTotalScore(e.getTotalScore());
|
|
|
- markQuestion.setIntervalScore(e.getIntervalScore());
|
|
|
- markQuestion.setQuestionType(QuestionType.QUESTION_ANSWER.getValue());
|
|
|
- return Stream.of(markQuestion);
|
|
|
- }).collect(Collectors.toList());
|
|
|
- markQuestionService.saveBatch(markQuestionList);
|
|
|
-
|
|
|
-// MarkGroupDto markGroupDto = new MarkGroupDto();
|
|
|
-// markGroupDto.setDoubleEnable(false);
|
|
|
-// markGroupDto.setGroupNumber(groupNumber);
|
|
|
-// markGroupDto.setMarkers(markUsers);
|
|
|
-// markGroupDto.setQuestions(markQuestionList);
|
|
|
-// markGroupDto.setPictureConfigs(new ArrayList<>());
|
|
|
-// MarkGroupSingleDto markGroupSingleDto = new MarkGroupSingleDto();
|
|
|
-// markGroupSingleDto.setExamId(examId);
|
|
|
-// markGroupSingleDto.setPaperNumber(paperNumber);
|
|
|
-// markGroupSingleDto.setGroupInfo(markGroupDto);
|
|
|
-// markGroupService.saveGroup(markGroupSingleDto);
|
|
|
- }
|
|
|
- if (CollectionUtils.isNotEmpty(groupErrorList)) {
|
|
|
- String groupErrorMsg = paperNumberGroupNumberNotice + String.join(",", groupErrorList);
|
|
|
- paperErrorList.add(groupErrorMsg);
|
|
|
+ // 校验课程下试卷编号唯一
|
|
|
+ if (coursePaperNumberMap.containsKey(courseCode)) {
|
|
|
+ if (!paperNumber.equals(coursePaperNumberMap.get(courseCode))) {
|
|
|
+ errorList.add("课程存在不同试卷编号");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ coursePaperNumberMap.put(courseCode, paperNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验试卷编号唯一
|
|
|
+ if (coursePaperNumberMap.containsValue(paperNumber)) {
|
|
|
+ for (Map.Entry<String, String> entry : coursePaperNumberMap.entrySet()) {
|
|
|
+ if (entry.getValue().equals(paperNumber) && !courseCode.equals(entry.getKey())) {
|
|
|
+ errorList.add("试卷编号已被其它课程占用");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
- if (CollectionUtils.isNotEmpty(paperErrorList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.join(System.lineSeparator(), paperErrorList));
|
|
|
- }
|
|
|
- // 更改试卷结构状态为已提交
|
|
|
- Set<String> paperNumberSet = paperQuestionsMap.keySet();
|
|
|
- if (CollectionUtils.isNotEmpty(paperNumberSet)) {
|
|
|
- markPaperService.update(new UpdateWrapper<MarkPaper>().lambda().eq(MarkPaper::getExamId, examId)
|
|
|
- .in(MarkPaper::getPaperNumber, paperNumberSet).set(MarkPaper::getQuestionStatus, true));
|
|
|
+
|
|
|
+ // 题号重复校验
|
|
|
+ String coursePaper = SystemConstant.mergeString(SystemConstant.HYPHEN, courseCode, paperNumber);
|
|
|
+ String questionNumber = SystemConstant.mergeString(SystemConstant.HYPHEN, mainNumber, subNumber);
|
|
|
+ if (coursePaperQuestionMap.containsKey(coursePaper)) {
|
|
|
+ if (questionNumber.equals(coursePaperQuestionMap.get(coursePaper))) {
|
|
|
+ errorList.add("存在相同大题号、小题号");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ coursePaperQuestionMap.put(coursePaper, questionNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 题号是否被客观题使用
|
|
|
+ if (objectivePaperNumberSet.contains(SystemConstant.mergeString(SystemConstant.HYPHEN, paperNumber, mainNumber, subNumber))) {
|
|
|
+ errorList.add("大题号、小题号已被客观题使用");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorList));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组装数据
|
|
|
+ assembleSubjectiveImportData(examId, subjectiveStructDto, markQuestions, markUserQuestions, sysUserMap);
|
|
|
+ } catch (Exception e) {
|
|
|
+ hasError = true;
|
|
|
+ subjectiveStructDto.setErrorMsg(e.getMessage());
|
|
|
+ } finally {
|
|
|
+ subjectiveStructDtos.add(subjectiveStructDto);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ map.put(SystemConstant.ERROR_DATA_LIST, subjectiveStructDtos);
|
|
|
+ map.put(SystemConstant.DATASOURCE, markQuestions);
|
|
|
+ map.put(SystemConstant.DATASOURCE1, markUserQuestions);
|
|
|
+ map.put(SystemConstant.DATA_COUNT, subjectiveStructDtos.size());
|
|
|
+ map.put(SystemConstant.HAS_ERROR_DATA, hasError);
|
|
|
+
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+ private void assembleSubjectiveImportData(Long examId, SubjectiveStructDto subjectiveStructDto, List<MarkQuestion> markQuestions, List<MarkUserQuestion> markUserQuestions, Map<String, SysUserResult> sysUserMap) {
|
|
|
+ MarkQuestion markQuestion = new MarkQuestion();
|
|
|
+ markQuestion.setId(SystemConstant.getDbUuid());
|
|
|
+ markQuestion.setExamId(examId);
|
|
|
+ markQuestion.setCourseId(subjectiveStructDto.getCourseId());
|
|
|
+ markQuestion.setPaperNumber(subjectiveStructDto.getPaperNumber());
|
|
|
+ markQuestion.setObjective(false);
|
|
|
+ markQuestion.setMainNumber(subjectiveStructDto.getMainNumber());
|
|
|
+ markQuestion.setSubNumber(subjectiveStructDto.getSubNumber());
|
|
|
+ markQuestion.setMainTitle(subjectiveStructDto.getMainTitle());
|
|
|
+ markQuestion.setOptionCount(0);
|
|
|
+ markQuestion.setQuestionType(QuestionType.QUESTION_ANSWER.getValue());
|
|
|
+ markQuestion.setDoubleRate(0D);// 单评为0,双评为1
|
|
|
+ markQuestion.setTotalScore(subjectiveStructDto.getTotalScore());
|
|
|
+ // 间隔分(整数默认1,小数默认0.5)
|
|
|
+ markQuestion.setIntervalScore(subjectiveStructDto.getIntervalScore());
|
|
|
+ markQuestions.add(markQuestion);
|
|
|
+
|
|
|
+ // 评卷员
|
|
|
+ String markerCodes = subjectiveStructDto.getMarkerCodes();
|
|
|
+ if (StringUtils.isNotBlank(markerCodes)) {
|
|
|
+ for (String code : markerCodes.split(SystemConstant.COMMA)) {
|
|
|
+ if (sysUserMap.containsKey(code.trim())) {
|
|
|
+ MarkUserQuestion markUserQuestion = new MarkUserQuestion();
|
|
|
+ markUserQuestion.setId(SystemConstant.getDbUuid());
|
|
|
+ markUserQuestion.setExamId(examId);
|
|
|
+ markUserQuestion.setPaperNumber(subjectiveStructDto.getPaperNumber());
|
|
|
+ markUserQuestion.setQuestionId(markQuestion.getId());
|
|
|
+ markUserQuestion.setUserId(sysUserMap.get(code.trim()).getId());
|
|
|
+ markUserQuestion.setEnable(true);
|
|
|
+ markUserQuestions.add(markUserQuestion);
|
|
|
+ } else {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("工号" + code + "用户不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|