|
@@ -13,10 +13,7 @@ import com.qmth.distributed.print.business.bean.dto.PdfDto;
|
|
|
import com.qmth.distributed.print.business.bean.params.ArraysParams;
|
|
|
import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
-import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.MakeMethodEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.UploadFileEnum;
|
|
|
+import com.qmth.distributed.print.business.enums.*;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
|
import com.qmth.distributed.print.business.util.ConvertUtil;
|
|
@@ -431,25 +428,32 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
Cell cell = row.getCell(index);
|
|
|
String cellValue = String.valueOf(ExcelUtil.convert(cell));
|
|
|
-
|
|
|
- if ("学号".equals(name)) {
|
|
|
+ // TODO: 2021/4/20 可以优化
|
|
|
+ if (ExaminationDBFieldsEnum.STUDENT_CODE.getDesc().equals(name)) {
|
|
|
studentCode = cellValue;
|
|
|
- } else if ("姓名".equals(name)) {
|
|
|
+ ConvertUtil.verifyLength(studentCode,10, ExaminationDBFieldsEnum.STUDENT_CODE.getDesc());
|
|
|
+ } else if (ExaminationDBFieldsEnum.STUDENT_NAME.getDesc().equals(name)) {
|
|
|
studentName = cellValue;
|
|
|
- } else if ("课程代码".equals(name)) {
|
|
|
+ ConvertUtil.verifyLength(studentName,15,ExaminationDBFieldsEnum.STUDENT_NAME.getDesc());
|
|
|
+ } else if (ExaminationDBFieldsEnum.COURSE_CODE.getDesc().equals(name)) {
|
|
|
courseCode = cellValue;
|
|
|
- } else if ("课程名称".equals(name)) {
|
|
|
+ ConvertUtil.verifyLength(courseCode,10,ExaminationDBFieldsEnum.COURSE_CODE.getDesc());
|
|
|
+ } else if (ExaminationDBFieldsEnum.COURSE_NAME.getDesc().equals(name)) {
|
|
|
courseName = cellValue;
|
|
|
- } else if ("考点".equals(name)) {
|
|
|
+ ConvertUtil.verifyLength(courseName,20,ExaminationDBFieldsEnum.COURSE_NAME.getDesc());
|
|
|
+ } else if (ExaminationDBFieldsEnum.EXAM_PLACE.getDesc().equals(name)) {
|
|
|
examPlace = cellValue;
|
|
|
- } else if ("考场".equals(name)) {
|
|
|
+ ConvertUtil.verifyLength(examPlace,10,ExaminationDBFieldsEnum.EXAM_PLACE.getDesc());
|
|
|
+ } else if (ExaminationDBFieldsEnum.EXAM_ROOM.getDesc().equals(name)) {
|
|
|
examRoom = cellValue;
|
|
|
- } else if ("考试日期".equals(name)) {
|
|
|
+ ConvertUtil.verifyLength(examRoom,10,ExaminationDBFieldsEnum.EXAM_ROOM.getDesc());
|
|
|
+ } else if (ExaminationDBFieldsEnum.EXAM_DATE.getDesc().equals(name)) {
|
|
|
examDate = cellValue;
|
|
|
- } else if ("考试时间".equals(name)) {
|
|
|
+ } else if (ExaminationDBFieldsEnum.EXAM_TIME.getDesc().equals(name)) {
|
|
|
examTime = cellValue;
|
|
|
- } else if ("试卷编号".equals(name)) {
|
|
|
+ } else if (ExaminationDBFieldsEnum.PAPER_NUMBER.getDesc().equals(name)) {
|
|
|
paperNumber = cellValue;
|
|
|
+ ConvertUtil.verifyLength(paperNumber,15,ExaminationDBFieldsEnum.PAPER_NUMBER.getDesc());
|
|
|
} else {
|
|
|
if ("primary".equals(level)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("有数据库不需要的必选字段 : " + name);
|
|
@@ -490,7 +494,23 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
dataMap.put("printPlanName", printPlanName);
|
|
|
dataList.add(dataMap);
|
|
|
}
|
|
|
- System.out.println("dataList = " + JSON.toJSONString(dataList));
|
|
|
+ // 校验课程代码和试卷编号在印刷计划下是1对1的关系
|
|
|
+ List<String> courseCodeList = dataList.stream().map(e -> String.valueOf(e.get("courseCode"))).distinct().collect(Collectors.toList());
|
|
|
+ List<String> paperNumberList = dataList.stream().map(e -> String.valueOf(e.get("paperNumber"))).distinct().collect(Collectors.toList());
|
|
|
+ for (String courseCode : courseCodeList) {
|
|
|
+ List<String> tmp = dataList.stream().filter(e -> courseCode.equals(String.valueOf(e.get("courseCode"))))
|
|
|
+ .map(e -> String.valueOf(e.get("paperNumber"))).distinct().collect(Collectors.toList());
|
|
|
+ if (tmp.size() != 1){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程代码为 " + courseCode + ",对应多个试卷编号 : " + tmp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String paperNumber : paperNumberList) {
|
|
|
+ List<String> tmp = dataList.stream().filter(e -> paperNumber.equals(String.valueOf(e.get("paperNumber"))))
|
|
|
+ .map(e -> String.valueOf(e.get("courseCode"))).distinct().collect(Collectors.toList());
|
|
|
+ if (tmp.size() != 1){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷编号为 " + paperNumber + ",对应多个课程代码 : " + tmp);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 删除印刷计划下的考务数据
|
|
|
examDetailService.deleteExaminationData(printPlanId);
|