|
@@ -169,6 +169,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
//这里为保存附件html的逻辑
|
|
|
//查询题卡详情是否有附件id,有的话则把以前的附件删除
|
|
|
Set<Long> attachmentIds = null;
|
|
|
+ Set<File> ftlList = null;
|
|
|
|
|
|
//查询printPlan
|
|
|
ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
|
|
@@ -187,6 +188,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
throw ExceptionResultEnum.ERROR.exception("考务计划为空");
|
|
|
}
|
|
|
attachmentIds = Objects.isNull(attachmentIds) ? attachmentIds = new HashSet<>() : attachmentIds;
|
|
|
+ ftlList = Objects.isNull(ftlList) ? ftlList = new HashSet<>() : ftlList;
|
|
|
for (ExamDetail examDetail : examDetailList) {
|
|
|
if (Objects.nonNull(examDetail.getAttachmentId())) {
|
|
|
attachmentIds.add(examDetail.getAttachmentId());
|
|
@@ -264,7 +266,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
.eq(ExamStudent::getExamDetailCourseId, examTaskDetail.getId());
|
|
|
List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
|
|
- Integer signVariableBackupCount = null, packagVariableBackupCount = null;
|
|
|
if (Objects.nonNull(examPrintPlan.getVariableContent())) {
|
|
|
//获取变量印品
|
|
|
JSONArray jsonArrayVariable = JSONArray.parseArray(examPrintPlan.getVariableContent());
|
|
@@ -273,12 +274,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
String type = (String) jsonObjectVariable.get("type");
|
|
|
Long attachmentId = (Long) jsonObjectVariable.get("attachmentId");
|
|
|
BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
- commonService.getFile(basicAttachment.getPath(), false);
|
|
|
+ ftlList.add(commonService.getFile(basicAttachment.getPath(), false));
|
|
|
if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
|
- signVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
|
- createSignBook(basicAttachment, basicSchool.getName(), examDetailCourse, examStudentList, variablePdfList);
|
|
|
+ createSignBook(basicAttachment, basicSchool.getName(), examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
} else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAG")) {//卷袋贴
|
|
|
- packagVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
|
+ createPaperPackage(basicAttachment, basicSchool.getName(), examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -298,7 +298,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
basicAttachmentList.add(mergePdf(tbTask, examDetail, sysUser.getId(), variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
|
}
|
|
|
//最后一步删除附件
|
|
|
- deleteAttachment(attachmentIds);
|
|
|
+ deleteAttachment(attachmentIds, ftlList);
|
|
|
} catch (Exception e) {
|
|
|
log.error("请求出错", e);
|
|
|
basicAttachmentService.batchDeleteAttachment(basicAttachmentList);
|
|
@@ -366,12 +366,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
stringJoiner.add(File.separator).add(SystemConstant.getUuid()).add(".").add(SystemConstant.XLSX);
|
|
|
|
|
|
- String dirName = stringJoiner.toString().replaceAll("\\\\","/");
|
|
|
+ String dirName = stringJoiner.toString().replaceAll("\\\\", "/");
|
|
|
ossUtil.ossUpload(dirName, in, DigestUtils.md5Hex(in));
|
|
|
jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
|
|
|
jsonObject.put(SystemConstant.PATH, dirName);
|
|
|
jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE.getTitle());
|
|
|
- map.put("path",jsonObject.toString());
|
|
|
+ map.put("path", jsonObject.toString());
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -527,20 +527,61 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 创建签到表
|
|
|
+ * 生成卷袋贴
|
|
|
*
|
|
|
* @param basicAttachment
|
|
|
* @param schoolName
|
|
|
* @param examDetailCourse
|
|
|
* @param examStudentList
|
|
|
* @param variablePdfList
|
|
|
+ * @param printCount
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- private void createSignBook(BasicAttachment basicAttachment, String schoolName, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<String> variablePdfList) throws IOException {
|
|
|
+ private void createPaperPackage(BasicAttachment basicAttachment, String schoolName, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<String> variablePdfList, Integer printCount) throws IOException {
|
|
|
Map<String, Object> htmlMap = new HashMap<>();
|
|
|
htmlMap.put("examDetailCourseId", examDetailCourse.getId());
|
|
|
htmlMap.put("schoolName", schoolName);
|
|
|
+ htmlMap.put("examName", "测试exam1");
|
|
|
+ htmlMap.put("courseName", examDetailCourse.getCourseName());
|
|
|
+ htmlMap.put("courseCode", examDetailCourse.getCourseCode());
|
|
|
+ htmlMap.put("examSite", "测试examSite1");
|
|
|
+ htmlMap.put("examRoom", "测试examRoom1");
|
|
|
+ htmlMap.put("startTime", "2021-04-13 00:00:00");
|
|
|
+ htmlMap.put("endTime", "2021-04-14 00:00:00");
|
|
|
+ htmlMap.put("paperCode", examDetailCourse.getPaperNumber());
|
|
|
+ htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetailCourse.getPaperNumber(), false));
|
|
|
+
|
|
|
+ htmlMap.put("startCollege", "测试startCollege1");
|
|
|
+ htmlMap.put("className", "测试className1");
|
|
|
+ htmlMap.put("proctorCollege", "测试proctorCollege1");
|
|
|
+ htmlMap.put("examManager", "测试examManager1");
|
|
|
+
|
|
|
+ htmlMap.put("minSite", "测试minSite1");
|
|
|
+ htmlMap.put("maxSite", "测试maxSite1");
|
|
|
+ htmlMap.put("studentCount", examStudentList.size());
|
|
|
+
|
|
|
+ htmlMap.put("tag", "测试tag1");
|
|
|
+
|
|
|
+ htmlMap.computeIfAbsent("basicAttachment", v -> basicAttachment);
|
|
|
+ htmlMap.computeIfAbsent("variablePdfList", v -> variablePdfList);
|
|
|
+ htmlMap.computeIfAbsent("printCount", v -> printCount);
|
|
|
+ freemarkerUtil.createPaperPackage(htmlMap);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建签到表
|
|
|
+ *
|
|
|
+ * @param basicAttachment
|
|
|
+ * @param schoolName
|
|
|
+ * @param examDetailCourse
|
|
|
+ * @param examStudentList
|
|
|
+ * @param variablePdfList
|
|
|
+ * @param printCount
|
|
|
+ */
|
|
|
+ private void createSignBook(BasicAttachment basicAttachment, String schoolName, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<String> variablePdfList, Integer printCount) throws IOException {
|
|
|
+ Map<String, Object> htmlMap = new HashMap<>();
|
|
|
+ htmlMap.put("examDetailCourseId", examDetailCourse.getId());
|
|
|
+ htmlMap.put("schoolName", schoolName);
|
|
|
htmlMap.put("courseName", examDetailCourse.getCourseName());
|
|
|
htmlMap.put("courseCode", examDetailCourse.getCourseCode());
|
|
|
htmlMap.put("examName", "测试exam1");
|
|
@@ -600,6 +641,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
htmlMap.computeIfAbsent("basicAttachment", v -> basicAttachment);
|
|
|
htmlMap.computeIfAbsent("variablePdfList", v -> variablePdfList);
|
|
|
+ htmlMap.computeIfAbsent("printCount", v -> printCount);
|
|
|
freemarkerUtil.createSignBook(htmlMap);
|
|
|
}
|
|
|
|
|
@@ -735,14 +777,20 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
* 删除附件
|
|
|
*
|
|
|
* @param attachmentIds
|
|
|
+ * @param ftlList
|
|
|
*/
|
|
|
- public void deleteAttachment(Set<Long> attachmentIds) {
|
|
|
+ public void deleteAttachment(Set<Long> attachmentIds, Set<File> ftlList) {
|
|
|
if (Objects.nonNull(attachmentIds) && attachmentIds.size() > 0) {
|
|
|
QueryWrapper<BasicAttachment> basicAttachmentQueryWrapper = new QueryWrapper<>();
|
|
|
basicAttachmentQueryWrapper.lambda().in(BasicAttachment::getId, attachmentIds);
|
|
|
basicAttachmentService.batchDeleteAttachment(basicAttachmentService.list(basicAttachmentQueryWrapper));
|
|
|
basicAttachmentService.removeByIds(attachmentIds);
|
|
|
}
|
|
|
+ if (Objects.nonNull(ftlList) && ftlList.size() > 0) {
|
|
|
+ for (File file : ftlList) {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|