|
@@ -21,7 +21,6 @@ import com.qmth.distributed.print.business.enums.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
import com.qmth.distributed.print.business.util.CreatePdfUtil;
|
|
import com.qmth.distributed.print.business.util.CreatePdfUtil;
|
|
-import com.qmth.distributed.print.business.util.CreatePrintPdfUtil;
|
|
|
|
import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
|
|
import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
@@ -65,7 +64,6 @@ import java.lang.reflect.Field;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
-import java.util.function.Function;
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -721,10 +719,42 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
List<ExaminationImportDto> examinationImportDtoList = new ArrayList<>();
|
|
List<ExaminationImportDto> examinationImportDtoList = new ArrayList<>();
|
|
|
|
|
|
- // excel中的数据错误
|
|
|
|
- StringJoiner errorRowDate = new StringJoiner(";\r\n");
|
|
|
|
|
|
+ // 文件中课程代码对应的课程名称Map
|
|
|
|
+ Map<String, String> courseCodeNameInExcelMap = new HashMap<>();
|
|
|
|
+ // 课程管理中课程代码-课程名
|
|
|
|
+ Map<String, String> courseCodeNameInBasicCourseMap = new HashMap<>();
|
|
|
|
+ List<BasicCourse> basicCourseList = basicCourseService.list(new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getSchoolId, schoolId));
|
|
|
|
+ basicCourseList.forEach(e -> {
|
|
|
|
+ courseCodeNameInBasicCourseMap.put(e.getCode(), e.getName());
|
|
|
|
+ });
|
|
|
|
+ // 考号重复数据次数
|
|
|
|
+ Map<String, Integer> ticketNumberMap = new HashMap<>();
|
|
|
|
+ // 文件中试卷编号对应多个课程代码
|
|
|
|
+ Map<String, String> paperNumberWithCourseCodeInExcelMap = new HashMap<>();
|
|
|
|
+ // 试卷编号在考试下有多个命题任务map
|
|
|
|
+ Map<String, Integer> paperNumberWithExamTaskMap = new HashMap<>();
|
|
|
|
+ // 命题任务中试卷编号对应的课程代码map
|
|
|
|
+ Map<String, String> paperNumberWithCourseCodeInExamTaskMap = new HashMap<>();
|
|
|
|
+ List<ExamTask> examTaskList = examTaskService.list(new QueryWrapper<ExamTask>()
|
|
|
|
+ .lambda()
|
|
|
|
+ .eq(ExamTask::getSchoolId, schoolId)
|
|
|
|
+ .eq(ExamTask::getExamId, examId));
|
|
|
|
+ for (ExamTask examTask : examTaskList) {
|
|
|
|
+ String paperNumber = examTask.getPaperNumber();
|
|
|
|
+ String courseCode = examTask.getCourseCode();
|
|
|
|
+ paperNumberWithCourseCodeInExamTaskMap.put(paperNumber, courseCode);
|
|
|
|
+ if (paperNumberWithExamTaskMap.containsKey(paperNumber)) {
|
|
|
|
+ int count = paperNumberWithExamTaskMap.get(paperNumber);
|
|
|
|
+ paperNumberWithExamTaskMap.put(paperNumber, count);
|
|
|
|
+ } else {
|
|
|
|
+ paperNumberWithExamTaskMap.put(paperNumber, 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// 从第三行开始为数据(第一行说明,第二行表头,第三行往后为数据)
|
|
// 从第三行开始为数据(第一行说明,第二行表头,第三行往后为数据)
|
|
for (int r = 2; r < totalRows; r++) {
|
|
for (int r = 2; r < totalRows; r++) {
|
|
|
|
+ // excel中的数据错误
|
|
|
|
+ StringJoiner errorRowDate = new StringJoiner(";\r\n");
|
|
Row row = sheet.getRow(r);
|
|
Row row = sheet.getRow(r);
|
|
if (ExcelUtil.isRowAllCellEmpty(row, head)) {
|
|
if (ExcelUtil.isRowAllCellEmpty(row, head)) {
|
|
// excel中整行为空,直接跳过
|
|
// excel中整行为空,直接跳过
|
|
@@ -745,14 +775,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
if (Objects.nonNull(row)) {
|
|
if (Objects.nonNull(row)) {
|
|
Cell cell = row.getCell(index);
|
|
Cell cell = row.getCell(index);
|
|
- if (cell == null) {
|
|
|
|
- errorRowDate.add("第" + (r + 1) + "行,第" + (index + 1) + "列,字段[" + name + "]必填");
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
String cellValue = String.valueOf(ExcelUtil.convert(cell));
|
|
String cellValue = String.valueOf(ExcelUtil.convert(cell));
|
|
if (cellValue == null || cellValue.length() < 1 || cellValue.equals("null")) {
|
|
if (cellValue == null || cellValue.length() < 1 || cellValue.equals("null")) {
|
|
|
|
+ cellValue = "";
|
|
errorRowDate.add("第" + (r + 1) + "行,第" + (index + 1) + "列,字段[" + name + "]必填");
|
|
errorRowDate.add("第" + (r + 1) + "行,第" + (index + 1) + "列,字段[" + name + "]必填");
|
|
- continue;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
for (Field examinationImportDtoField : examinationImportDtoFields) {
|
|
for (Field examinationImportDtoField : examinationImportDtoFields) {
|
|
@@ -785,90 +811,91 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ examinationImportDto.setSecondaryFieldList(secondaryFieldList);
|
|
|
|
+ examinationImportDto.setSchoolId(schoolId);
|
|
// 解析时间
|
|
// 解析时间
|
|
try {
|
|
try {
|
|
Map<String, Object> timeMap = ConvertUtil.analyzeStartAndEndTime(examinationImportDto.getExamDate(), examinationImportDto.getExamTime());
|
|
Map<String, Object> timeMap = ConvertUtil.analyzeStartAndEndTime(examinationImportDto.getExamDate(), examinationImportDto.getExamTime());
|
|
String examStartTime = String.valueOf(timeMap.get("startTime"));
|
|
String examStartTime = String.valueOf(timeMap.get("startTime"));
|
|
String examEndTime = String.valueOf(timeMap.get("endTime"));
|
|
String examEndTime = String.valueOf(timeMap.get("endTime"));
|
|
-
|
|
|
|
- examinationImportDto.setSecondaryFieldList(secondaryFieldList);
|
|
|
|
examinationImportDto.setExamStartTime(examStartTime);
|
|
examinationImportDto.setExamStartTime(examStartTime);
|
|
examinationImportDto.setExamEndTime(examEndTime);
|
|
examinationImportDto.setExamEndTime(examEndTime);
|
|
- examinationImportDto.setSchoolId(schoolId);
|
|
|
|
- examinationImportDtoList.add(examinationImportDto);
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
errorRowDate.add(e.getMessage());
|
|
errorRowDate.add(e.getMessage());
|
|
}
|
|
}
|
|
- examinationImportDto.setErrorMessage(errorRowDate.toString());
|
|
|
|
- }
|
|
|
|
- List<String> errorList = examinationImportDtoList.stream()
|
|
|
|
- .map(ExaminationImportDto::getErrorMessage)
|
|
|
|
- .filter(SystemConstant::strNotNull)
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- if (!CollectionUtils.isEmpty(errorList)){
|
|
|
|
- // 优先处理excel每个独立行的数据异常
|
|
|
|
- map.put(SystemConstant.ERROR_DATA_LIST,examinationImportDtoList);
|
|
|
|
- map.put("fieldsDtoList",fieldsDtoList);
|
|
|
|
- return map;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // 整体错误信息字符串
|
|
|
|
- StringJoiner errorString = new StringJoiner(";\r\n");
|
|
|
|
- // 课程代码map(同一课程代码,有不同课程名称)
|
|
|
|
- Map<String, Set<String>> courseCodeMap = examinationImportDtoList.stream().collect(Collectors.groupingBy(ExaminationImportDto::getCourseCode, Collectors.mapping(ExaminationImportDto::getCourseName, Collectors.toSet())));
|
|
|
|
- for (Map.Entry<String, Set<String>> entry : courseCodeMap.entrySet()) {
|
|
|
|
- String courseCode = entry.getKey();
|
|
|
|
- List<String> courseNames = new ArrayList<>(entry.getValue());
|
|
|
|
- if (courseNames.size() > 1) {
|
|
|
|
- errorString.add(String.format("文件中课程代码[%s]对应多个不同的课程名称[%s]", courseCode, String.join(",", courseNames)));
|
|
|
|
- } else {
|
|
|
|
- QueryWrapper<BasicCourse> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.lambda().eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode);
|
|
|
|
- BasicCourse basicCourse = basicCourseService.getOne(queryWrapper);
|
|
|
|
- String courseName = courseNames.get(0);
|
|
|
|
- if (basicCourse != null && !basicCourse.getName().equals(courseName)) {
|
|
|
|
- errorString.add(String.format("文件中课程代码[%s]对应课程名称为[%s],课程管理中对应课程名称为[%s]", courseCode, courseName, basicCourse.getName()));
|
|
|
|
|
|
+ // 唯一关系校验
|
|
|
|
+ String courseCode = examinationImportDto.getCourseCode();
|
|
|
|
+ String courseName = examinationImportDto.getCourseName();
|
|
|
|
+ String paperNumber = examinationImportDto.getPaperNumber();
|
|
|
|
+ String ticketNumber = examinationImportDto.getTicketNumber();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (!SystemConstant.isOneNull(courseCode, courseName)) {
|
|
|
|
+ // 校验1 - 文件中课程代码对应多个不同的课程名称
|
|
|
|
+ if (courseCodeNameInExcelMap.containsKey(courseCode)) {
|
|
|
|
+ String name = courseCodeNameInExcelMap.get(courseCode);
|
|
|
|
+ if (!courseName.equals(name)) {
|
|
|
|
+ errorRowDate.add("文件中课程代码[" + courseCode + "]对应多个不同的课程名称");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ courseCodeNameInExcelMap.put(courseCode, courseName);
|
|
|
|
+ }
|
|
|
|
+ // 校验2 - 文件中课程代码对应的课程名称和课程管理中对应课程名称不一致
|
|
|
|
+ String basicName = courseCodeNameInBasicCourseMap.get(courseCode);
|
|
|
|
+ if (!courseName.equals(basicName)) {
|
|
|
|
+ errorRowDate.add(String.format("文件中课程代码[%s]对应课程名称为[%s],课程管理中对应课程名称为[%s]", courseCode, courseName, basicName));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- // 准考证号map(同一准考证号,多次出现)
|
|
|
|
- Map<String, Long> ticketNumberMap = examinationImportDtoList.stream().filter(m -> StringUtils.isNotBlank(m.getTicketNumber())).collect(Collectors.groupingBy(ExaminationImportDto::getTicketNumber, Collectors.counting()));
|
|
|
|
- for (Map.Entry<String, Long> entry : ticketNumberMap.entrySet()) {
|
|
|
|
- String ticketNumber = entry.getKey();
|
|
|
|
- Long count = entry.getValue();
|
|
|
|
- if (count > 1) {
|
|
|
|
- errorString.add(String.format("文件中考号[%s]有[%s]条重复数据", ticketNumber, count));
|
|
|
|
|
|
+ if (!SystemConstant.isOneNull(ticketNumber)) {
|
|
|
|
+ // 检验3 - 文件中考号有重复数据
|
|
|
|
+ if (ticketNumberMap.containsKey(ticketNumber)) {
|
|
|
|
+ errorRowDate.add("文件中考号[" + ticketNumber + "]有重复数据");
|
|
|
|
+ } else {
|
|
|
|
+ ticketNumberMap.put(ticketNumber, 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- // 试卷编号map(同一试卷编号,有不同课程代码)
|
|
|
|
- Map<String, Set<String>> paperNumberMap = examinationImportDtoList.stream().collect(Collectors.groupingBy(ExaminationImportDto::getPaperNumber, Collectors.mapping(ExaminationImportDto::getCourseCode, Collectors.toSet())));
|
|
|
|
- for (Map.Entry<String, Set<String>> entry : courseCodeMap.entrySet()) {
|
|
|
|
- String paperNumber = entry.getKey();
|
|
|
|
- List<String> courseCodes = new ArrayList<>(entry.getValue());
|
|
|
|
- if (courseCodes.size() > 1) {
|
|
|
|
- errorString.add(String.format("文件中试卷编号[%s]对应多个不同的课程代码[%s]", paperNumber, String.join(",", courseCodes)));
|
|
|
|
- } else {
|
|
|
|
- List<ExamTask> examTaskList = examTaskService.list(new QueryWrapper<ExamTask>().lambda()
|
|
|
|
- .eq(ExamTask::getSchoolId, schoolId)
|
|
|
|
- .eq(ExamTask::getExamId, examId)
|
|
|
|
- .eq(ExamTask::getPaperNumber, paperNumber));
|
|
|
|
- if (examTaskList.size() > 1) {
|
|
|
|
- errorString.add(String.format("试卷编号[%s]在考试[%s]下有多条命题任务,请联系管理员处理", paperNumber, basicExam.getName()));
|
|
|
|
- } else if (examTaskList.size() == 1) {
|
|
|
|
- ExamTask examTask = examTaskList.get(0);
|
|
|
|
- String courseCode = courseCodes.get(0);
|
|
|
|
- if (!examTask.getCourseCode().equals(courseCode)) {
|
|
|
|
- errorString.add(String.format("文件中试卷编号[%s]对应课程代码为[%s],命题任务中对应课程代码为[%s]", paperNumber, courseCode, examTask.getCourseCode()));
|
|
|
|
|
|
+ if (!SystemConstant.isOneNull(paperNumber, courseCode)) {
|
|
|
|
+ // 检验4 - 文件中试卷编号[%s]对应多个不同的课程代码[%s]
|
|
|
|
+ if (paperNumberWithCourseCodeInExcelMap.containsKey(paperNumber)) {
|
|
|
|
+ String code = paperNumberWithCourseCodeInExcelMap.get(paperNumber);
|
|
|
|
+ if (!courseCode.equals(code)) {
|
|
|
|
+ errorRowDate.add(String.format("文件中试卷编号[%s]对应多个不同的课程代码", paperNumber));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ paperNumberWithCourseCodeInExcelMap.put(paperNumber, courseCode);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (SystemConstant.strNotNull(paperNumber)) {
|
|
|
|
+ //检验5 - 试卷编号[%s]在考试[%s]下有多条命题任务,请联系管理员处理
|
|
|
|
+ if (paperNumberWithExamTaskMap.containsKey(paperNumber)) {
|
|
|
|
+ int count = paperNumberWithExamTaskMap.get(paperNumber);
|
|
|
|
+ if (count > 1) {
|
|
|
|
+ errorRowDate.add(String.format("试卷编号[%s]在考试[%s]下有多条命题任务,请联系管理员处理", paperNumber, count));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (!SystemConstant.isOneNull(paperNumber, courseCode)) {
|
|
|
|
+ //检验6 - 文件中试卷编号[%s]对应课程代码为[%s],命题任务中对应课程代码为[%s]
|
|
|
|
+ if (paperNumberWithCourseCodeInExamTaskMap.containsKey(paperNumber)) {
|
|
|
|
+ String code = paperNumberWithCourseCodeInExamTaskMap.get(paperNumber);
|
|
|
|
+ if (!courseCode.equals(code)) {
|
|
|
|
+ errorRowDate.add(String.format("文件中试卷编号[%s]对应课程代码为[%s],命题任务中对应课程代码为[%s]", paperNumber, courseCode, code));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ examinationImportDto.setErrorMessage(errorRowDate.toString());
|
|
|
|
+ examinationImportDtoList.add(examinationImportDto);
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 错误异常抛出去
|
|
|
|
- if (errorString.length() > 0) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception(errorString.toString());
|
|
|
|
|
|
+ List<String> errorList = examinationImportDtoList.stream()
|
|
|
|
+ .map(ExaminationImportDto::getErrorMessage)
|
|
|
|
+ .filter(SystemConstant::strNotNull)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (!CollectionUtils.isEmpty(errorList)) {
|
|
|
|
+ // 优先处理excel每个独立行的数据异常
|
|
|
|
+ map.put(SystemConstant.ERROR_DATA_LIST, examinationImportDtoList);
|
|
|
|
+ map.put("fieldsDtoList", fieldsDtoList);
|
|
|
|
+ return map;
|
|
}
|
|
}
|
|
|
|
|
|
// 按考点+开始时间+课程代码+考场排序
|
|
// 按考点+开始时间+课程代码+考场排序
|