|
@@ -761,6 +761,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
throw ExceptionResultEnum.ERROR.exception("扫描任务不存在");
|
|
throw ExceptionResultEnum.ERROR.exception("扫描任务不存在");
|
|
}
|
|
}
|
|
BasicSchool school = basicSchoolService.getById(scanTask.getSchoolId());
|
|
BasicSchool school = basicSchoolService.getById(scanTask.getSchoolId());
|
|
|
|
+ BasicExam basicExam = basicExamService.getById(scanTask.getExamId());
|
|
|
|
+ BasicSemester basicSemester = basicSemesterService.getById(basicExam.getSemesterId());
|
|
pictureLocalPath = rootPath + File.separator + school.getName();
|
|
pictureLocalPath = rootPath + File.separator + school.getName();
|
|
//查询考生数据
|
|
//查询考生数据
|
|
if (!studentIdList.isEmpty()) {
|
|
if (!studentIdList.isEmpty()) {
|
|
@@ -822,19 +824,17 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
//试卷写入到pdf
|
|
//试卷写入到pdf
|
|
if(!fileList.isEmpty()) {
|
|
if(!fileList.isEmpty()) {
|
|
- String pdfPath = generateStudentPaperPdf(result.getStudentCode(), fileList, school.getName(), courseNameCode);
|
|
|
|
- //更新考生
|
|
|
|
ExamStudent student = examStudentService.getById(result.getStudentId());
|
|
ExamStudent student = examStudentService.getById(result.getStudentId());
|
|
|
|
+ String pdfPath = generateStudentPaperPdf(scanTask,student, result.getStudentCode(), fileList);
|
|
|
|
+ //更新考生
|
|
student.setFilePath(pdfPath);
|
|
student.setFilePath(pdfPath);
|
|
examStudentService.updateById(student);
|
|
examStudentService.updateById(student);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
map.put("size", successMap.size());
|
|
map.put("size", successMap.size());
|
|
-
|
|
|
|
//执行情况写入到excel
|
|
//执行情况写入到excel
|
|
- String path = fileStoreUtil.buildPath(UploadFileEnum.PDF, true);
|
|
|
|
- path += File.separator + school.getName();
|
|
|
|
|
|
+ String path = fileStoreUtil.buildPath(UploadFileEnum.PDF, false, school.getName(), basicSemester.getName(),basicExam.getName());
|
|
createPdfExcel(path, toBeGeneratedList, successMap, errorMap);
|
|
createPdfExcel(path, toBeGeneratedList, successMap, errorMap);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
@@ -847,15 +847,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
- private String generateStudentPaperPdf(String pdfName, List<File> fileList, String... paths) {
|
|
|
|
- StringBuilder pdfRootPath = new StringBuilder(fileStoreUtil.buildPath(UploadFileEnum.PDF, true));
|
|
|
|
- for (String path : paths) {
|
|
|
|
- pdfRootPath.append(File.separator).append(path);
|
|
|
|
- }
|
|
|
|
- File dir = new File(pdfRootPath.toString());
|
|
|
|
|
|
+ private String generateStudentPaperPdf(PaperScanTask paperScanTask, ExamStudent student, String pdfName, List<File> fileList) {
|
|
|
|
+ String pdfRootPath = getPdfRootPath(paperScanTask, student);
|
|
|
|
+ File dir = new File(pdfRootPath);
|
|
if (!dir.exists()) {
|
|
if (!dir.exists()) {
|
|
dir.mkdirs();
|
|
dir.mkdirs();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //文件的完整路径
|
|
String pdfPath = pdfRootPath + File.separator + pdfName + SystemConstant.PDF_SUFFIX;
|
|
String pdfPath = pdfRootPath + File.separator + pdfName + SystemConstant.PDF_SUFFIX;
|
|
|
|
|
|
Document document = null;
|
|
Document document = null;
|
|
@@ -876,6 +875,22 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
return pdfPath;
|
|
return pdfPath;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private String getPdfRootPath(PaperScanTask paperScanTask, ExamStudent examStudent) {
|
|
|
|
+ BasicSchool basicSchool = basicSchoolService.getById(paperScanTask.getSchoolId());
|
|
|
|
+ BasicExam basicExam = basicExamService.getById(paperScanTask.getExamId());
|
|
|
|
+ BasicSemester basicSemester = basicSemesterService.getById(basicExam.getSemesterId());
|
|
|
|
+ String courseNameCode = String.format("%s(%s)", paperScanTask.getCourseName(), paperScanTask.getCourseCode());
|
|
|
|
+ String rootPath = fileStoreUtil.buildPath(UploadFileEnum.PDF, false, basicSchool.getName(), basicSemester.getName(), basicExam.getName(), courseNameCode);
|
|
|
|
+ if (StoreTypeEnum.ROOM.equals(paperScanTask.getStoreType())) {
|
|
|
|
+ rootPath = fileStoreUtil.buildPath(UploadFileEnum.PDF, false, basicSchool.getName(), basicSemester.getName(), basicExam.getName(), courseNameCode, examStudent.getExamRoom());
|
|
|
|
+ } else if (StoreTypeEnum.CLASS.equals(paperScanTask.getStoreType())) {
|
|
|
|
+ rootPath = fileStoreUtil.buildPath(UploadFileEnum.PDF, false, basicSchool.getName(), basicSemester.getName(), basicExam.getName(), courseNameCode, examStudent.getClassName());
|
|
|
|
+ } else if (StoreTypeEnum.COURSE.equals(paperScanTask.getStoreType())) {
|
|
|
|
+ rootPath = fileStoreUtil.buildPath(UploadFileEnum.PDF, false, basicSchool.getName(), basicSemester.getName(), basicExam.getName(), courseNameCode, examStudent.getStudentCode());
|
|
|
|
+ }
|
|
|
|
+ return rootPath;
|
|
|
|
+ }
|
|
|
|
+
|
|
private void createPdfExcel(String path, List<DocManageDetailResult> list, Map<Long, Integer> successMap,
|
|
private void createPdfExcel(String path, List<DocManageDetailResult> list, Map<Long, Integer> successMap,
|
|
Map<Long, Integer> errorMap) throws IOException {
|
|
Map<Long, Integer> errorMap) throws IOException {
|
|
String fileName = "执行清单-" + System.currentTimeMillis() +".xlsx";
|
|
String fileName = "执行清单-" + System.currentTimeMillis() +".xlsx";
|