|
@@ -10,6 +10,7 @@ import com.google.common.reflect.TypeToken;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.itextpdf.text.DocumentException;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
+import com.qmth.teachcloud.common.bean.result.ExcelResult;
|
|
|
import com.qmth.teachcloud.common.bean.vo.PrintPathVo;
|
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
|
import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
|
|
@@ -2062,7 +2063,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public Map<String, Object> executeImportBasicExamStudentLogic(Map<String, Object> map) throws Exception {
|
|
|
-
|
|
|
SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
InputStream inputStream = (InputStream) map.get("inputStream");
|
|
|
Long examId = SystemConstant.convertIdToLong(String.valueOf(map.get("examId")));
|
|
@@ -2084,110 +2084,92 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
BaseEntity::getId));
|
|
|
// excel中学生学号和学生字典对象关系
|
|
|
Map<String, BasicExamStudent> studentCodeObjMap = new HashMap<>();
|
|
|
- List<BasicExamStudentDto> errorDataList = new ArrayList<>();
|
|
|
AtomicInteger successInteger = new AtomicInteger(0);
|
|
|
AtomicInteger exceptionInteger = new AtomicInteger(0);
|
|
|
|
|
|
- ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicExamStudentDto.class),
|
|
|
- (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
+ ExcelResult<BasicExamStudentDto> excelResult = ConvertUtil.analyzeExcel(inputStream, BasicExamStudentDto.class,
|
|
|
+ true, 1);
|
|
|
+ List<BasicExamStudentDto> basicExamStudentDtoList = excelResult.getDatasource();
|
|
|
+ boolean success = excelResult.isSuccess();
|
|
|
+ for (BasicExamStudentDto basicExamStudentDto : basicExamStudentDtoList) {
|
|
|
+ List<String> errorMsgList = new ArrayList<>();
|
|
|
+ // 行索引
|
|
|
+ String courseName = basicExamStudentDto.getCourseName();
|
|
|
+ String courseCode = basicExamStudentDto.getCourseCode();
|
|
|
+ String studentName = basicExamStudentDto.getStudentName();
|
|
|
+ String studentCode = basicExamStudentDto.getStudentCode();
|
|
|
+ String college = basicExamStudentDto.getCollege();
|
|
|
+ String major = basicExamStudentDto.getMajor();
|
|
|
+ String teachClazz = basicExamStudentDto.getTeachClazz();
|
|
|
+ String paperNumber = basicExamStudentDto.getPaperNumber();
|
|
|
+ String teacherName = basicExamStudentDto.getTeacherName();
|
|
|
+ String teacherCode = basicExamStudentDto.getTeacherCode();
|
|
|
+ String examDate = basicExamStudentDto.getExamDate();
|
|
|
+ String examTime = basicExamStudentDto.getExamTime();
|
|
|
+ String examPlace = basicExamStudentDto.getExamPlace();
|
|
|
+ String examRoom = basicExamStudentDto.getExamRoom();
|
|
|
|
|
|
- for (int i = 0; i < finalExcelList.size(); i++) {
|
|
|
- LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
|
- List<Object> basicExamStudentDtoList = excelMap.get(i);
|
|
|
- // 无数据,跳过
|
|
|
- if (CollectionUtils.isEmpty(basicExamStudentDtoList)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- for (int y = 0; y < Objects.requireNonNull(basicExamStudentDtoList).size(); y++) {
|
|
|
- List<String> errorMsgList = new ArrayList<>();
|
|
|
- // 行索引
|
|
|
- BasicExamStudentDto basicExamStudentDto = (BasicExamStudentDto) basicExamStudentDtoList.get(
|
|
|
- y);
|
|
|
- String courseName = StringUtils.trimToNull(basicExamStudentDto.getCourseName());
|
|
|
- String courseCode = StringUtils.trimToNull(basicExamStudentDto.getCourseCode());
|
|
|
- String studentName = StringUtils.trimToNull(basicExamStudentDto.getStudentName());
|
|
|
- String studentCode = StringUtils.trimToNull(basicExamStudentDto.getStudentCode());
|
|
|
- String college = StringUtils.trimToNull(basicExamStudentDto.getCollege());
|
|
|
- String major = StringUtils.trimToNull(basicExamStudentDto.getMajor());
|
|
|
- String teachClazz = StringUtils.trimToNull(basicExamStudentDto.getTeachClazz());
|
|
|
- String paperNumber = StringUtils.trimToNull(basicExamStudentDto.getPaperNumber());
|
|
|
- String teacherName = StringUtils.trimToNull(basicExamStudentDto.getTeacherName());
|
|
|
- String teacherCode = StringUtils.trimToNull(basicExamStudentDto.getTeacherCode());
|
|
|
- String examDate = StringUtils.trimToNull(basicExamStudentDto.getExamDate());
|
|
|
- String examTime = StringUtils.trimToNull(basicExamStudentDto.getExamTime());
|
|
|
- String examPlace = StringUtils.trimToNull(basicExamStudentDto.getExamPlace());
|
|
|
- String examRoom = StringUtils.trimToNull(basicExamStudentDto.getExamRoom());
|
|
|
-
|
|
|
- // 本行全部列为空,跳过
|
|
|
- if (StringUtils.isAllBlank(courseName, courseCode, studentName, studentCode, college, major,
|
|
|
- teachClazz, paperNumber, teacherName, teacherCode, examDate, examTime, examPlace,
|
|
|
- examRoom)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- Long examStartTime = null;
|
|
|
- Long examEndTime = null;
|
|
|
- try {
|
|
|
- if (SystemConstant.strNotNull(examDate) && SystemConstant.strNotNull(examTime)) {
|
|
|
- Map<String, Object> timeMap = ConvertUtil.analyzeStartAndEndTime(examDate, examTime);
|
|
|
- examStartTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("startTime")));
|
|
|
- examEndTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("endTime")));
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- errorMsgList.add(e.getMessage());
|
|
|
- }
|
|
|
+ Long examStartTime = null;
|
|
|
+ Long examEndTime = null;
|
|
|
+ try {
|
|
|
+ if (SystemConstant.strNotNull(examDate) && SystemConstant.strNotNull(examTime)) {
|
|
|
+ Map<String, Object> timeMap = ConvertUtil.analyzeStartAndEndTime(examDate, examTime);
|
|
|
+ examStartTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("startTime")));
|
|
|
+ examEndTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("endTime")));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ errorMsgList.add(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = examId + SystemConstant.HYPHEN + courseCode + SystemConstant.HYPHEN + studentCode;
|
|
|
+ Long id = null;
|
|
|
+ if (studentCodeIdMap.containsKey(key)) {
|
|
|
+ id = studentCodeIdMap.get(key);
|
|
|
+ }
|
|
|
+ BasicExamStudentParam basicExamStudentParam = new BasicExamStudentParam();
|
|
|
+ basicExamStudentParam.setId(id);
|
|
|
+ basicExamStudentParam.setSemesterId(semesterId);
|
|
|
+ basicExamStudentParam.setExamId(examId);
|
|
|
+ basicExamStudentParam.setCourseCode(courseCode);
|
|
|
+ basicExamStudentParam.setStudentName(studentName);
|
|
|
+ basicExamStudentParam.setStudentCode(studentCode);
|
|
|
+ basicExamStudentParam.setCollege(college);
|
|
|
+ basicExamStudentParam.setMajor(major);
|
|
|
+ basicExamStudentParam.setTeachClazz(teachClazz);
|
|
|
+ basicExamStudentParam.setPaperNumber(paperNumber);
|
|
|
+ basicExamStudentParam.setTeacherName(teacherName);
|
|
|
+ basicExamStudentParam.setTeacherCode(teacherCode);
|
|
|
+ basicExamStudentParam.setExamStartTime(examStartTime);
|
|
|
+ basicExamStudentParam.setExamEndTime(examEndTime);
|
|
|
+ basicExamStudentParam.setExamPlace(examPlace);
|
|
|
+ basicExamStudentParam.setExamRoom(examRoom);
|
|
|
+ try {
|
|
|
+ BasicExamStudent basicExamStudent = basicExamStudentService.editEntityHelp(basicExamStudentParam,
|
|
|
+ requestUser);
|
|
|
+ // 考试课程下学号重复 后面的替换前面的
|
|
|
+ studentCodeObjMap.put(key, basicExamStudent);
|
|
|
+ } catch (Exception e) {
|
|
|
+ errorMsgList.add(e.getMessage());
|
|
|
+ }
|
|
|
|
|
|
- String key = examId + SystemConstant.HYPHEN + courseCode + SystemConstant.HYPHEN + studentCode;
|
|
|
- Long id = null;
|
|
|
- if (studentCodeIdMap.containsKey(key)) {
|
|
|
- id = studentCodeIdMap.get(key);
|
|
|
- }
|
|
|
- BasicExamStudentParam basicExamStudentParam = new BasicExamStudentParam();
|
|
|
- basicExamStudentParam.setId(id);
|
|
|
- basicExamStudentParam.setSemesterId(semesterId);
|
|
|
- basicExamStudentParam.setExamId(examId);
|
|
|
- basicExamStudentParam.setCourseCode(courseCode);
|
|
|
- basicExamStudentParam.setStudentName(studentName);
|
|
|
- basicExamStudentParam.setStudentCode(studentCode);
|
|
|
- basicExamStudentParam.setCollege(college);
|
|
|
- basicExamStudentParam.setMajor(major);
|
|
|
- basicExamStudentParam.setTeachClazz(teachClazz);
|
|
|
- basicExamStudentParam.setPaperNumber(paperNumber);
|
|
|
- basicExamStudentParam.setTeacherName(teacherName);
|
|
|
- basicExamStudentParam.setTeacherCode(teacherCode);
|
|
|
- basicExamStudentParam.setExamStartTime(examStartTime);
|
|
|
- basicExamStudentParam.setExamEndTime(examEndTime);
|
|
|
- basicExamStudentParam.setExamPlace(examPlace);
|
|
|
- basicExamStudentParam.setExamRoom(examRoom);
|
|
|
- try {
|
|
|
- BasicExamStudent basicExamStudent = basicExamStudentService.editEntityHelp(
|
|
|
- basicExamStudentParam, requestUser);
|
|
|
- // 考试课程下学号重复 后面的替换前面的
|
|
|
- studentCodeObjMap.put(key, basicExamStudent);
|
|
|
- } catch (Exception e) {
|
|
|
- errorMsgList.add(e.getMessage());
|
|
|
- }
|
|
|
+ if (CollectionUtils.isNotEmpty(errorMsgList)) {
|
|
|
+ basicExamStudentDto.setErrorMsg(basicExamStudentDto.getErrorMsg() + ";" + String.join(";", errorMsgList));
|
|
|
+ exceptionInteger.getAndIncrement();
|
|
|
+ } else {
|
|
|
+ successInteger.getAndIncrement();
|
|
|
+ }
|
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(errorMsgList)) {
|
|
|
- basicExamStudentDto.setErrorMsg(String.join(";", errorMsgList));
|
|
|
- exceptionInteger.getAndIncrement();
|
|
|
- } else {
|
|
|
- successInteger.getAndIncrement();
|
|
|
- }
|
|
|
- errorDataList.add(basicExamStudentDto);
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if (errorDataList.stream().anyMatch(e -> SystemConstant.strNotNull(e.getErrorMsg()))) {
|
|
|
- map.put(SystemConstant.ERROR_DATA_LIST, errorDataList);
|
|
|
- } else {
|
|
|
- List<BasicExamStudent> basicExamStudentList = new ArrayList<>(studentCodeObjMap.values());
|
|
|
- map.put(SystemConstant.DATASOURCE, basicExamStudentList);
|
|
|
- }
|
|
|
- map.put(SystemConstant.DATA_COUNT, errorDataList.size());
|
|
|
- map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
|
|
|
- map.put(SystemConstant.ERROR_DATA_COUNT, exceptionInteger.get());
|
|
|
- return finalExcelList;
|
|
|
- }, 2);
|
|
|
+ if (basicExamStudentDtoList.stream().anyMatch(e -> SystemConstant.strNotNull(e.getErrorMsg()))) {
|
|
|
+ map.put(SystemConstant.ERROR_DATA_LIST, basicExamStudentDtoList);
|
|
|
+ } else {
|
|
|
+ List<BasicExamStudent> basicExamStudentList = new ArrayList<>(studentCodeObjMap.values());
|
|
|
+ map.put(SystemConstant.DATASOURCE, basicExamStudentList);
|
|
|
+ }
|
|
|
+ map.put(SystemConstant.DATA_COUNT, basicExamStudentDtoList.size());
|
|
|
+ map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
|
|
|
+ map.put(SystemConstant.ERROR_DATA_COUNT, exceptionInteger.get());
|
|
|
return map;
|
|
|
}
|
|
|
|