|
@@ -89,6 +89,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
private BasicExamService basicExamService;
|
|
private BasicExamService basicExamService;
|
|
@Resource
|
|
@Resource
|
|
private PictureManageService pictureManageService;
|
|
private PictureManageService pictureManageService;
|
|
|
|
+ @Resource
|
|
private BasicFieldService basicFieldService;
|
|
private BasicFieldService basicFieldService;
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@@ -303,14 +304,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
DownloadPictureParams downLoadPaperParams = JSON.parseObject(tbTask.getRemark(), DownloadPictureParams.class);
|
|
DownloadPictureParams downLoadPaperParams = JSON.parseObject(tbTask.getRemark(), DownloadPictureParams.class);
|
|
List<PictureManageDetailResult> studentList = pictureManageService.listPictureResult(downLoadPaperParams);
|
|
List<PictureManageDetailResult> studentList = pictureManageService.listPictureResult(downLoadPaperParams);
|
|
-
|
|
|
|
|
|
+
|
|
rootPath = fileStoreUtil.buildPath(UploadFileEnum.DOWNLOAD, true, String.valueOf(System.currentTimeMillis()));
|
|
rootPath = fileStoreUtil.buildPath(UploadFileEnum.DOWNLOAD, true, String.valueOf(System.currentTimeMillis()));
|
|
String dirName = SystemConstant.getUuid() + SystemConstant.ZIP_SUFFIX;
|
|
String dirName = SystemConstant.getUuid() + SystemConstant.ZIP_SUFFIX;
|
|
zipFile = new File(rootPath + dirName);
|
|
zipFile = new File(rootPath + dirName);
|
|
if (!zipFile.getParentFile().exists()) {
|
|
if (!zipFile.getParentFile().exists()) {
|
|
boolean dirSuccess = zipFile.getParentFile().mkdirs();
|
|
boolean dirSuccess = zipFile.getParentFile().mkdirs();
|
|
- if(!dirSuccess){
|
|
|
|
- log.error(String.format("[图片管理],目录创建失败,dirPath:%s",rootPath));
|
|
|
|
|
|
+ if (!dirSuccess) {
|
|
|
|
+ log.error(String.format("[图片管理],目录创建失败,dirPath:%s", rootPath));
|
|
throw ExceptionResultEnum.ERROR.exception("目录创建失败");
|
|
throw ExceptionResultEnum.ERROR.exception("目录创建失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -320,7 +321,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
Map<Long, Integer> successMap = new HashMap<>();
|
|
Map<Long, Integer> successMap = new HashMap<>();
|
|
Map<Long, Integer> errorMap = new HashMap<>();
|
|
Map<Long, Integer> errorMap = new HashMap<>();
|
|
|
|
|
|
- for(PictureManageDetailResult student : studentList) {
|
|
|
|
|
|
+ for (PictureManageDetailResult student : studentList) {
|
|
Long studentId = student.getStudentId();
|
|
Long studentId = student.getStudentId();
|
|
successMap.putIfAbsent(studentId, 0);
|
|
successMap.putIfAbsent(studentId, 0);
|
|
errorMap.putIfAbsent(studentId, 0);
|
|
errorMap.putIfAbsent(studentId, 0);
|
|
@@ -348,7 +349,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(sourceFileList)) {
|
|
if (!CollectionUtils.isEmpty(sourceFileList)) {
|
|
@@ -383,8 +384,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
if (Objects.nonNull(dictionaryConfig.sysDomain()) && fileStoreUtil.isOssStore() && Objects.nonNull(zipFile)) {
|
|
if (Objects.nonNull(dictionaryConfig.sysDomain()) && fileStoreUtil.isOssStore() && Objects.nonNull(zipFile)) {
|
|
boolean success = zipFile.delete();
|
|
boolean success = zipFile.delete();
|
|
- if(!success) {
|
|
|
|
- log.warn(String.format("[图片管理],临时zip目录删除失败,zipPath:%s",zipFile.getPath()));
|
|
|
|
|
|
+ if (!success) {
|
|
|
|
+ log.warn(String.format("[图片管理],临时zip目录删除失败,zipPath:%s", zipFile.getPath()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -392,7 +393,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
|
|
|
|
private void createPictureDownloadExcel(String zipLocalRootPath, List<PictureManageDetailResult> list, Map<Long, Integer> successMap,
|
|
private void createPictureDownloadExcel(String zipLocalRootPath, List<PictureManageDetailResult> list, Map<Long, Integer> successMap,
|
|
- Map<Long, Integer> errorMap) throws IOException {
|
|
|
|
|
|
+ Map<Long, Integer> errorMap) throws IOException {
|
|
String fileName = "下载记录清单.xlsx";
|
|
String fileName = "下载记录清单.xlsx";
|
|
XSSFWorkbook wb = new XSSFWorkbook();
|
|
XSSFWorkbook wb = new XSSFWorkbook();
|
|
XSSFSheet sheet = wb.createSheet("数据");
|
|
XSSFSheet sheet = wb.createSheet("数据");
|
|
@@ -448,7 +449,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
XSSFRow headRow = sheet.createRow(0);
|
|
XSSFRow headRow = sheet.createRow(0);
|
|
// 表头
|
|
// 表头
|
|
- String[] fieldsNameList = {"学号", "姓名", "学期", "考试", "扫描批次号", "课程名称(代码)","任课老师", "教学班", "学院", "专业", "班级", "绑定图片数量(张)", "下载成功数量(页)", "下载失败(页)"};
|
|
|
|
|
|
+ String[] fieldsNameList = {"学号", "姓名", "学期", "考试", "扫描批次号", "课程名称(代码)", "任课老师", "教学班", "学院", "专业", "班级", "绑定图片数量(张)", "下载成功数量(页)", "下载失败(页)"};
|
|
for (int i = 0; i < fieldsNameList.length; i++) {
|
|
for (int i = 0; i < fieldsNameList.length; i++) {
|
|
XSSFCell cell = headRow.createCell(i);
|
|
XSSFCell cell = headRow.createCell(i);
|
|
cell.setCellValue(fieldsNameList[i]);
|
|
cell.setCellValue(fieldsNameList[i]);
|
|
@@ -487,7 +488,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
XSSFCell cell5 = row.createCell(5);
|
|
XSSFCell cell5 = row.createCell(5);
|
|
cell5.setCellStyle(lockStyle);
|
|
cell5.setCellStyle(lockStyle);
|
|
cell5.setCellStyle(dataStyle);
|
|
cell5.setCellStyle(dataStyle);
|
|
- cell5.setCellValue(result.getCourseName()+"("+result.getCourseCode()+")");
|
|
|
|
|
|
+ cell5.setCellValue(result.getCourseName() + "(" + result.getCourseCode() + ")");
|
|
|
|
|
|
XSSFCell cell6 = row.createCell(6);
|
|
XSSFCell cell6 = row.createCell(6);
|
|
cell6.setCellStyle(lockStyle);
|
|
cell6.setCellStyle(lockStyle);
|
|
@@ -580,7 +581,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
List<PaperScanTask> paperScanTaskList = paperScanTaskService.listByExamId(examId);
|
|
List<PaperScanTask> paperScanTaskList = paperScanTaskService.listByExamId(examId);
|
|
Map<String, StoreTypeEnum> stringStoreTypeMap = paperScanTaskList.stream().collect(Collectors.toMap(PaperScanTask::getCourseCode, PaperScanTask::getStoreType));
|
|
Map<String, StoreTypeEnum> stringStoreTypeMap = paperScanTaskList.stream().collect(Collectors.toMap(PaperScanTask::getCourseCode, PaperScanTask::getStoreType));
|
|
|
|
|
|
- Map<String, String> courseMap = examStudentList.stream().collect(Collectors.toMap(ExamStudent::getCourseCode, ExamStudent::getCourseName));
|
|
|
|
|
|
+ Map<String, String> courseMap = examStudentList.stream().collect(Collectors.toMap(ExamStudent::getCourseCode, ExamStudent::getCourseName, (v1, v2) -> v2));
|
|
Map<String, List<String>> studentCodeMap = new HashMap<>();
|
|
Map<String, List<String>> studentCodeMap = new HashMap<>();
|
|
// 是否有错误提示
|
|
// 是否有错误提示
|
|
boolean hasError = false;
|
|
boolean hasError = false;
|
|
@@ -590,7 +591,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
BeanUtils.copyProperties(examStudentImport, examStudent);
|
|
BeanUtils.copyProperties(examStudentImport, examStudent);
|
|
examStudent.setExtendFields(CollectionUtils.isNotEmpty(examStudentImport.getExtendFieldList()) ? JSON.toJSONString(examStudentImport.getExtendFieldList()) : null);
|
|
examStudent.setExtendFields(CollectionUtils.isNotEmpty(examStudentImport.getExtendFieldList()) ? JSON.toJSONString(examStudentImport.getExtendFieldList()) : null);
|
|
|
|
|
|
- StringJoiner stringJoiner = new StringJoiner(";");
|
|
|
|
// 学号去掉空格
|
|
// 学号去掉空格
|
|
examStudent.setStudentCode(StringUtils.isNotBlank(examStudentImport.getStudentCode()) ? StringUtils.deleteWhitespace(examStudentImport.getStudentCode()) : null);
|
|
examStudent.setStudentCode(StringUtils.isNotBlank(examStudentImport.getStudentCode()) ? StringUtils.deleteWhitespace(examStudentImport.getStudentCode()) : null);
|
|
// 课程代码去掉空格
|
|
// 课程代码去掉空格
|
|
@@ -655,45 +655,41 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
String key = examStudent.getCourseCode() + SystemConstant.HYPHEN + examStudent.getStudentCode();
|
|
String key = examStudent.getCourseCode() + SystemConstant.HYPHEN + examStudent.getStudentCode();
|
|
if (courseIdStudentCodeMap.containsKey(key)) {
|
|
if (courseIdStudentCodeMap.containsKey(key)) {
|
|
ExamStudent student = courseIdStudentCodeMap.get(key);
|
|
ExamStudent student = courseIdStudentCodeMap.get(key);
|
|
-
|
|
|
|
// 校验存储方式
|
|
// 校验存储方式
|
|
if (stringStoreTypeMap.containsKey(examStudent.getCourseCode())) {
|
|
if (stringStoreTypeMap.containsKey(examStudent.getCourseCode())) {
|
|
- StoreTypeEnum courseCodeStoreType = stringStoreTypeMap.get(examStudent.getCourseCode());
|
|
|
|
- if (StoreTypeEnum.ROOM.equals(courseCodeStoreType) && !examStudent.getExamRoom().equals(student.getExamRoom())) {
|
|
|
|
- errorMsg.add("考场不能更改,原考场为[" + student.getExamRoom() + "]");
|
|
|
|
- }
|
|
|
|
- if (StoreTypeEnum.CLASS.equals(courseCodeStoreType) && !examStudent.getClassName().equals(student.getClassName())) {
|
|
|
|
- errorMsg.add("班级不能更改,原班级为[" + student.getClassName() + "]");
|
|
|
|
|
|
+ // 已扫描,不能修改考场或班级
|
|
|
|
+ if (paperLibraryService.countByStudentId(student.getId()) > 0) {
|
|
|
|
+ StoreTypeEnum courseCodeStoreType = stringStoreTypeMap.get(examStudent.getCourseCode());
|
|
|
|
+ if (StoreTypeEnum.ROOM.equals(courseCodeStoreType) && !examStudent.getExamRoom().equals(student.getExamRoom())) {
|
|
|
|
+ errorMsg.add("考生已扫描,不能更改考场,原考场为[" + student.getExamRoom() + "]");
|
|
|
|
+ }
|
|
|
|
+ if (StoreTypeEnum.CLASS.equals(courseCodeStoreType) && !examStudent.getClassName().equals(student.getClassName())) {
|
|
|
|
+ errorMsg.add("考生已扫描,不能更改班级,原班级为[" + student.getClassName() + "]");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
examStudent.setId(student.getId());
|
|
examStudent.setId(student.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (StringUtils.isNotBlank(errorMsg.toString())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
- }
|
|
|
|
|
|
+ if (errorMsg.toString().length() > 0) {
|
|
|
|
+ examStudentImport.setErrorMsg(errorMsg.toString());
|
|
|
|
+ } else {
|
|
|
|
|
|
- if (examStudent.getId() == null) {
|
|
|
|
- examStudent.setId(SystemConstant.getDbUuid());
|
|
|
|
- }
|
|
|
|
- examStudent.setSchoolId(sysUser.getSchoolId());
|
|
|
|
- examStudent.setSemesterId(semesterId);
|
|
|
|
- examStudent.setExamId(examId);
|
|
|
|
- examStudent.setCreateId(sysUser.getId());
|
|
|
|
- examStudent.setCreateTime(System.currentTimeMillis());
|
|
|
|
-
|
|
|
|
- if (stringJoiner.toString().length() > 0) {
|
|
|
|
- examStudentImport.setErrorMsg(stringJoiner.toString());
|
|
|
|
|
|
+ if (examStudent.getId() == null) {
|
|
|
|
+ examStudent.setId(SystemConstant.getDbUuid());
|
|
|
|
+ }
|
|
|
|
+ examStudent.setSchoolId(sysUser.getSchoolId());
|
|
|
|
+ examStudent.setSemesterId(semesterId);
|
|
|
|
+ examStudent.setExamId(examId);
|
|
|
|
+ examStudent.setCreateId(sysUser.getId());
|
|
|
|
+ examStudent.setCreateTime(System.currentTimeMillis());
|
|
|
|
+ examStudents.add(examStudent);
|
|
}
|
|
}
|
|
|
|
|
|
- if (!hasError && stringJoiner.toString().length() > 0) {
|
|
|
|
|
|
+ if (!hasError && errorMsg.toString().length() > 0) {
|
|
hasError = true;
|
|
hasError = true;
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (stringJoiner.toString().length() == 0) {
|
|
|
|
- examStudents.add(examStudent);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
map.put(SystemConstant.ERROR_DATA_LIST, examStudentImportList);
|
|
map.put(SystemConstant.ERROR_DATA_LIST, examStudentImportList);
|
|
@@ -848,7 +844,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
|
|
|
|
private ExamStudentParseDto parseImportExamStudentData(Long schoolId, InputStream inputStream) {
|
|
private ExamStudentParseDto parseImportExamStudentData(Long schoolId, InputStream inputStream) {
|
|
- ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, inputStream, 1);
|
|
|
|
|
|
+ ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, inputStream, 0);
|
|
List<DataMap> dataMapList;
|
|
List<DataMap> dataMapList;
|
|
try {
|
|
try {
|
|
dataMapList = excelReader.getDataMapList();
|
|
dataMapList = excelReader.getDataMapList();
|
|
@@ -864,7 +860,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
// 必填字段
|
|
// 必填字段
|
|
Map<String, BasicField> requiredMap = basicFieldList.stream().filter(m -> m.getBasicField()).collect(Collectors.toMap(BasicField::getName, e -> e));
|
|
Map<String, BasicField> requiredMap = basicFieldList.stream().filter(m -> m.getBasicField()).collect(Collectors.toMap(BasicField::getName, e -> e));
|
|
// 扩展字段
|
|
// 扩展字段
|
|
- Map<String, BasicField> extendMap = basicFieldList.stream().filter(m -> !m.getBasicField()).collect(Collectors.toMap(BasicField::getName, e -> e));
|
|
|
|
|
|
+ Map<String, BasicField> extendMap = basicFieldList.stream().filter(m -> !m.getBasicField() && m.getEnable()).collect(Collectors.toMap(BasicField::getName, e -> e));
|
|
|
|
|
|
// 通用规则表头
|
|
// 通用规则表头
|
|
List<String> actualTitleList = Stream.concat(requiredMap.keySet().stream(), extendMap.keySet().stream()).collect(Collectors.toList());
|
|
List<String> actualTitleList = Stream.concat(requiredMap.keySet().stream(), extendMap.keySet().stream()).collect(Collectors.toList());
|