|
@@ -5,7 +5,6 @@ import cn.hutool.core.util.ReflectUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.google.gson.Gson;
|
|
|
import com.qmth.boot.tools.models.ByteArray;
|
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
|
import com.qmth.distributed.print.business.cache.CreatePdfCacheUtil;
|
|
@@ -52,8 +51,8 @@ public class CreatePdfUtil {
|
|
|
@Resource
|
|
|
BasicAttachmentService basicAttachmentService;
|
|
|
|
|
|
- @Resource
|
|
|
- FreemarkerUtil freemarkerUtil;
|
|
|
+// @Resource
|
|
|
+// FreemarkerUtil freemarkerUtil;
|
|
|
|
|
|
@Resource
|
|
|
@Lazy
|
|
@@ -102,8 +101,9 @@ public class CreatePdfUtil {
|
|
|
* @param basicAttachment
|
|
|
* @param ordinaryPdfList
|
|
|
* @param printCount
|
|
|
+ * @param fileTempList
|
|
|
*/
|
|
|
- public void createCheckIn(ExamDetail examDetail, BasicAttachment basicAttachment, List<PdfDto> ordinaryPdfList, Integer printCount) throws Exception {
|
|
|
+ public void createCheckIn(ExamDetail examDetail, BasicAttachment basicAttachment, List<PdfDto> ordinaryPdfList, Integer printCount, List<File> fileTempList) throws Exception {
|
|
|
Optional.ofNullable(basicAttachment).orElseThrow(() -> ExceptionResultEnum.ATTACHMENT_IS_NULL.exception());
|
|
|
|
|
|
String type = basicAttachment.getType();
|
|
@@ -148,143 +148,143 @@ public class CreatePdfUtil {
|
|
|
ordinaryPdfList.add(new PdfDto(localFile.getPath(), PageSizeEnum.A4, pdfDto.getPageCount()));
|
|
|
}
|
|
|
} else {
|
|
|
- printCommonService.saveAttachmentPdf(ClassifyEnum.CHECK_IN, examDetail, basicAttachment, ordinaryPdfList, printCount, 0);
|
|
|
+ printCommonService.saveAttachmentPdf(ClassifyEnum.CHECK_IN, examDetail, basicAttachment, ordinaryPdfList, printCount, 0, fileTempList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 生成卷袋贴
|
|
|
- *
|
|
|
- * @param tag
|
|
|
- * @param basicAttachment
|
|
|
- * @param schoolName
|
|
|
- * @param examStudentList
|
|
|
- * @param variablePdfList
|
|
|
- * @param printCount
|
|
|
- * @param examDetailCourseList
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- public void createPaperPackage(boolean tag, BasicAttachment basicAttachment, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer printCount, List<ExamDetailCourse> examDetailCourseList) throws IOException {
|
|
|
- if (Objects.isNull(basicAttachment)) {
|
|
|
- throw ExceptionResultEnum.ATTACHMENT_IS_NULL.exception();
|
|
|
- }
|
|
|
- Map<String, Object> htmlMap = new HashMap<>();
|
|
|
- if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
|
|
|
- List<String> paperNumbers = examDetailCourseList.stream().map(s -> s.getPaperNumber()).collect(Collectors.toList());
|
|
|
- List<String> courseCodes = examDetailCourseList.stream().map(s -> s.getCourseCode()).collect(Collectors.toList());
|
|
|
- List<String> courseNames = examDetailCourseList.stream().map(s -> s.getCourseName()).collect(Collectors.toList());
|
|
|
- htmlMap.put("courseName", String.join(", ", courseNames));
|
|
|
- htmlMap.put("courseCode", String.join(", ", paperNumbers));
|
|
|
- // 学院
|
|
|
-// Set<String> stringSet = new HashSet<>();
|
|
|
-// List<BasicCourse> basicCourses = basicCourseService.findBySchoolIdAndCourseCode(examDetail.getSchoolId(), courseCodes);
|
|
|
-// for (BasicCourse basicCours : basicCourses) {
|
|
|
-// List<SysOrg> sysOrgs = sysOrgService.findParentsByOrgId(basicCours.getTeachingRoomId());
|
|
|
-// Set<String> collegeName = sysOrgs.stream().filter(m -> OrgTypeEnum.COLLEGE.equals(m.getType())).map(m -> m.getName()).collect(Collectors.toSet());
|
|
|
-// if (CollectionUtils.isEmpty(collegeName)) {
|
|
|
-// collegeName = sysOrgs.stream().filter(m -> OrgTypeEnum.FACULTY.equals(m.getType())).map(m -> m.getName()).collect(Collectors.toSet());
|
|
|
-// }
|
|
|
-// if (!CollectionUtils.isEmpty(collegeName)) {
|
|
|
-// stringSet.addAll(collegeName);
|
|
|
-// }
|
|
|
+// /**
|
|
|
+// * 生成卷袋贴
|
|
|
+// *
|
|
|
+// * @param tag
|
|
|
+// * @param basicAttachment
|
|
|
+// * @param schoolName
|
|
|
+// * @param examStudentList
|
|
|
+// * @param variablePdfList
|
|
|
+// * @param printCount
|
|
|
+// * @param examDetailCourseList
|
|
|
+// * @throws IOException
|
|
|
+// */
|
|
|
+// public void createPaperPackage(boolean tag, BasicAttachment basicAttachment, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer printCount, List<ExamDetailCourse> examDetailCourseList) throws IOException {
|
|
|
+// if (Objects.isNull(basicAttachment)) {
|
|
|
+// throw ExceptionResultEnum.ATTACHMENT_IS_NULL.exception();
|
|
|
+// }
|
|
|
+// Map<String, Object> htmlMap = new HashMap<>();
|
|
|
+// if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
|
|
|
+// List<String> paperNumbers = examDetailCourseList.stream().map(s -> s.getPaperNumber()).collect(Collectors.toList());
|
|
|
+// List<String> courseCodes = examDetailCourseList.stream().map(s -> s.getCourseCode()).collect(Collectors.toList());
|
|
|
+// List<String> courseNames = examDetailCourseList.stream().map(s -> s.getCourseName()).collect(Collectors.toList());
|
|
|
+// htmlMap.put("courseName", String.join(", ", courseNames));
|
|
|
+// htmlMap.put("courseCode", String.join(", ", paperNumbers));
|
|
|
+// // 学院
|
|
|
+//// Set<String> stringSet = new HashSet<>();
|
|
|
+//// List<BasicCourse> basicCourses = basicCourseService.findBySchoolIdAndCourseCode(examDetail.getSchoolId(), courseCodes);
|
|
|
+//// for (BasicCourse basicCours : basicCourses) {
|
|
|
+//// List<SysOrg> sysOrgs = sysOrgService.findParentsByOrgId(basicCours.getTeachingRoomId());
|
|
|
+//// Set<String> collegeName = sysOrgs.stream().filter(m -> OrgTypeEnum.COLLEGE.equals(m.getType())).map(m -> m.getName()).collect(Collectors.toSet());
|
|
|
+//// if (CollectionUtils.isEmpty(collegeName)) {
|
|
|
+//// collegeName = sysOrgs.stream().filter(m -> OrgTypeEnum.FACULTY.equals(m.getType())).map(m -> m.getName()).collect(Collectors.toSet());
|
|
|
+//// }
|
|
|
+//// if (!CollectionUtils.isEmpty(collegeName)) {
|
|
|
+//// stringSet.addAll(collegeName);
|
|
|
+//// }
|
|
|
+//// }
|
|
|
+//// htmlMap.put("collegeName", CollectionUtils.isEmpty(stringSet) ? "" : String.join(",", stringSet));
|
|
|
+// } else {
|
|
|
+// htmlMap.put("courseName", "");
|
|
|
+// htmlMap.put("courseCode", "");
|
|
|
+// htmlMap.put("collegeName", "");
|
|
|
+// }
|
|
|
+// Set<Long> clazzIdSet = new HashSet<>();
|
|
|
+// for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
+// String clazzInfo = examDetailCourse.getClazzId();
|
|
|
+// if (SystemConstant.strNotNull(clazzInfo)) {
|
|
|
+// Set<Long> clazzIdSetCell = Arrays.stream(clazzInfo.split(",")).map(SystemConstant::convertIdToLong).collect(Collectors.toSet());
|
|
|
+// clazzIdSet.addAll(clazzIdSetCell);
|
|
|
// }
|
|
|
-// htmlMap.put("collegeName", CollectionUtils.isEmpty(stringSet) ? "" : String.join(",", stringSet));
|
|
|
- } else {
|
|
|
- htmlMap.put("courseName", "");
|
|
|
- htmlMap.put("courseCode", "");
|
|
|
- htmlMap.put("collegeName", "");
|
|
|
- }
|
|
|
- Set<Long> clazzIdSet = new HashSet<>();
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
- String clazzInfo = examDetailCourse.getClazzId();
|
|
|
- if (SystemConstant.strNotNull(clazzInfo)) {
|
|
|
- Set<Long> clazzIdSetCell = Arrays.stream(clazzInfo.split(",")).map(SystemConstant::convertIdToLong).collect(Collectors.toSet());
|
|
|
- clazzIdSet.addAll(clazzIdSetCell);
|
|
|
- }
|
|
|
- }
|
|
|
- List<Long> classIds = new ArrayList<>(clazzIdSet);
|
|
|
-
|
|
|
-// String campusName = CollectionUtils.isEmpty(classIds) ? "" : basicCampusService.findCampusNamesByClazzIdList(classIds, ",");
|
|
|
- htmlMap.put("schoolName", schoolName);
|
|
|
-// htmlMap.put("campusName", campusName);
|
|
|
- htmlMap.put("examSite", examDetail.getExamPlace());
|
|
|
- htmlMap.put("examRoom", examDetail.getExamRoom());
|
|
|
- htmlMap.put("startTime", DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
- htmlMap.put("endTime", DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
- htmlMap.put("paperCode", examDetail.getPackageCode());
|
|
|
- htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
|
|
|
-
|
|
|
- List<String> extendColumnList = examStudentList.stream().map(m -> m.getExtendFields()).distinct().collect(Collectors.toList());
|
|
|
- Set<String> startCollege = new HashSet();
|
|
|
- Set<String> className = new HashSet();
|
|
|
- Set<String> proctorCollege = new HashSet();
|
|
|
- Set<String> examManager = new HashSet();
|
|
|
-
|
|
|
- String className1 = examDetailService.findClazzNamesByClazzIds(classIds, ",");
|
|
|
-
|
|
|
- if (Objects.nonNull(extendColumnList) && extendColumnList.size() > 0) {
|
|
|
- for (String s : extendColumnList) {
|
|
|
- List<Map> mapList = JSONObject.parseArray(s, Map.class);
|
|
|
- for (Map map : mapList) {
|
|
|
- if (Objects.equals("startCollege", map.get("code").toString())) {
|
|
|
- startCollege.add(map.get("value").toString());
|
|
|
- }
|
|
|
- if (Objects.equals("className", map.get("code").toString())) {
|
|
|
- className.add(map.get("value").toString());
|
|
|
- }
|
|
|
- if (Objects.equals("proctorCollege", map.get("code").toString())) {
|
|
|
- proctorCollege.add(map.get("value").toString());
|
|
|
- }
|
|
|
- if (Objects.equals("examManager", map.get("code").toString())) {
|
|
|
- examManager.add(map.get("value").toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- htmlMap.put("startCollege", String.join(",", startCollege));
|
|
|
- htmlMap.put("className", StringUtils.isNotBlank(className1) ? className1 : String.join(",", className));
|
|
|
- htmlMap.put("proctorCollege", String.join(",", proctorCollege));
|
|
|
- htmlMap.put("examManager", String.join(",", examManager));
|
|
|
-
|
|
|
-// List<ExamStudent> tempList = examStudentList.stream().filter(s -> (Objects.nonNull(s.getSiteNumber()) && !Objects.equals("", s.getSiteNumber().trim()))).collect(Collectors.toList());
|
|
|
-// String minSite = "", maxSite = "";
|
|
|
-// if (Objects.nonNull(tempList) && tempList.size() > 0) {
|
|
|
-// minSite = tempList.stream().min((a, b) -> a.getSiteNumber().compareTo(b.getSiteNumber())).get().getSiteNumber();
|
|
|
-// maxSite = tempList.stream().max((a, b) -> a.getSiteNumber().compareTo(b.getSiteNumber())).get().getSiteNumber();
|
|
|
// }
|
|
|
-
|
|
|
- Optional<ExamStudentCourseDto> minSite = null;
|
|
|
- Optional<ExamStudentCourseDto> maxSite = null;
|
|
|
- List<ExamStudentCourseDto> tempList = examStudentList.stream().filter(s -> (Objects.nonNull(s.getSiteNumber()) && !Objects.equals("", s.getSiteNumber().trim()))).collect(Collectors.toList());
|
|
|
- if (Objects.nonNull(tempList) && tempList.size() > 0) {
|
|
|
-// for (ExamStudentCourseDto e : tempList) {
|
|
|
-// char[] chars = e.getSiteNumber().toLowerCase().toCharArray();
|
|
|
-// String ascii = "";
|
|
|
-// for (int i = 0; i < chars.length; i++) {
|
|
|
-// ascii = ascii + chars[i];
|
|
|
+// List<Long> classIds = new ArrayList<>(clazzIdSet);
|
|
|
+//
|
|
|
+//// String campusName = CollectionUtils.isEmpty(classIds) ? "" : basicCampusService.findCampusNamesByClazzIdList(classIds, ",");
|
|
|
+// htmlMap.put("schoolName", schoolName);
|
|
|
+//// htmlMap.put("campusName", campusName);
|
|
|
+// htmlMap.put("examSite", examDetail.getExamPlace());
|
|
|
+// htmlMap.put("examRoom", examDetail.getExamRoom());
|
|
|
+// htmlMap.put("startTime", DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
+// htmlMap.put("endTime", DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
+// htmlMap.put("paperCode", examDetail.getPackageCode());
|
|
|
+// htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
|
|
|
+//
|
|
|
+// List<String> extendColumnList = examStudentList.stream().map(m -> m.getExtendFields()).distinct().collect(Collectors.toList());
|
|
|
+// Set<String> startCollege = new HashSet();
|
|
|
+// Set<String> className = new HashSet();
|
|
|
+// Set<String> proctorCollege = new HashSet();
|
|
|
+// Set<String> examManager = new HashSet();
|
|
|
+//
|
|
|
+// String className1 = examDetailService.findClazzNamesByClazzIds(classIds, ",");
|
|
|
+//
|
|
|
+// if (Objects.nonNull(extendColumnList) && extendColumnList.size() > 0) {
|
|
|
+// for (String s : extendColumnList) {
|
|
|
+// List<Map> mapList = JSONObject.parseArray(s, Map.class);
|
|
|
+// for (Map map : mapList) {
|
|
|
+// if (Objects.equals("startCollege", map.get("code").toString())) {
|
|
|
+// startCollege.add(map.get("value").toString());
|
|
|
+// }
|
|
|
+// if (Objects.equals("className", map.get("code").toString())) {
|
|
|
+// className.add(map.get("value").toString());
|
|
|
+// }
|
|
|
+// if (Objects.equals("proctorCollege", map.get("code").toString())) {
|
|
|
+// proctorCollege.add(map.get("value").toString());
|
|
|
+// }
|
|
|
+// if (Objects.equals("examManager", map.get("code").toString())) {
|
|
|
+// examManager.add(map.get("value").toString());
|
|
|
+// }
|
|
|
// }
|
|
|
-// e.setAscii(ascii.hashCode());
|
|
|
// }
|
|
|
- minSite = tempList.stream().min(Comparator.comparing(s -> s.getSiteNumber().hashCode()));
|
|
|
- maxSite = tempList.stream().max(Comparator.comparing(s -> s.getSiteNumber().hashCode()));
|
|
|
- }
|
|
|
-
|
|
|
- htmlMap.put("minSite", Optional.ofNullable(minSite).map(s -> s.get().getSiteNumber()).orElse(""));
|
|
|
- htmlMap.put("maxSite", Optional.ofNullable(maxSite).map(s -> s.get().getSiteNumber()).orElse(""));
|
|
|
- htmlMap.put("studentCount", examStudentList != null && examStudentList.size() > 0 ? examStudentList.size() : examDetail.getPrintCount());
|
|
|
-
|
|
|
- String tagValue = tag ? "订" : null;
|
|
|
- htmlMap.put("tag", tagValue);
|
|
|
-
|
|
|
- htmlMap.computeIfAbsent("basicAttachment", v -> basicAttachment);
|
|
|
- htmlMap.computeIfAbsent("variablePdfList", v -> variablePdfList);
|
|
|
- htmlMap.computeIfAbsent("printCount", v -> printCount);
|
|
|
- htmlMap.computeIfAbsent("sequence", v -> 1);
|
|
|
- htmlMap.computeIfAbsent("examDetail", v -> examDetail);
|
|
|
- htmlMap.computeIfAbsent("printType", v -> ClassifyEnum.PACKAGE);
|
|
|
- freemarkerUtil.createPaperPackage(htmlMap);
|
|
|
- }
|
|
|
+// }
|
|
|
+//
|
|
|
+// htmlMap.put("startCollege", String.join(",", startCollege));
|
|
|
+// htmlMap.put("className", StringUtils.isNotBlank(className1) ? className1 : String.join(",", className));
|
|
|
+// htmlMap.put("proctorCollege", String.join(",", proctorCollege));
|
|
|
+// htmlMap.put("examManager", String.join(",", examManager));
|
|
|
+//
|
|
|
+//// List<ExamStudent> tempList = examStudentList.stream().filter(s -> (Objects.nonNull(s.getSiteNumber()) && !Objects.equals("", s.getSiteNumber().trim()))).collect(Collectors.toList());
|
|
|
+//// String minSite = "", maxSite = "";
|
|
|
+//// if (Objects.nonNull(tempList) && tempList.size() > 0) {
|
|
|
+//// minSite = tempList.stream().min((a, b) -> a.getSiteNumber().compareTo(b.getSiteNumber())).get().getSiteNumber();
|
|
|
+//// maxSite = tempList.stream().max((a, b) -> a.getSiteNumber().compareTo(b.getSiteNumber())).get().getSiteNumber();
|
|
|
+//// }
|
|
|
+//
|
|
|
+// Optional<ExamStudentCourseDto> minSite = null;
|
|
|
+// Optional<ExamStudentCourseDto> maxSite = null;
|
|
|
+// List<ExamStudentCourseDto> tempList = examStudentList.stream().filter(s -> (Objects.nonNull(s.getSiteNumber()) && !Objects.equals("", s.getSiteNumber().trim()))).collect(Collectors.toList());
|
|
|
+// if (Objects.nonNull(tempList) && tempList.size() > 0) {
|
|
|
+//// for (ExamStudentCourseDto e : tempList) {
|
|
|
+//// char[] chars = e.getSiteNumber().toLowerCase().toCharArray();
|
|
|
+//// String ascii = "";
|
|
|
+//// for (int i = 0; i < chars.length; i++) {
|
|
|
+//// ascii = ascii + chars[i];
|
|
|
+//// }
|
|
|
+//// e.setAscii(ascii.hashCode());
|
|
|
+//// }
|
|
|
+// minSite = tempList.stream().min(Comparator.comparing(s -> s.getSiteNumber().hashCode()));
|
|
|
+// maxSite = tempList.stream().max(Comparator.comparing(s -> s.getSiteNumber().hashCode()));
|
|
|
+// }
|
|
|
+//
|
|
|
+// htmlMap.put("minSite", Optional.ofNullable(minSite).map(s -> s.get().getSiteNumber()).orElse(""));
|
|
|
+// htmlMap.put("maxSite", Optional.ofNullable(maxSite).map(s -> s.get().getSiteNumber()).orElse(""));
|
|
|
+// htmlMap.put("studentCount", examStudentList != null && examStudentList.size() > 0 ? examStudentList.size() : examDetail.getPrintCount());
|
|
|
+//
|
|
|
+// String tagValue = tag ? "订" : null;
|
|
|
+// htmlMap.put("tag", tagValue);
|
|
|
+//
|
|
|
+// htmlMap.computeIfAbsent("basicAttachment", v -> basicAttachment);
|
|
|
+// htmlMap.computeIfAbsent("variablePdfList", v -> variablePdfList);
|
|
|
+// htmlMap.computeIfAbsent("printCount", v -> printCount);
|
|
|
+// htmlMap.computeIfAbsent("sequence", v -> 1);
|
|
|
+// htmlMap.computeIfAbsent("examDetail", v -> examDetail);
|
|
|
+// htmlMap.computeIfAbsent("printType", v -> ClassifyEnum.PACKAGE);
|
|
|
+// freemarkerUtil.createPaperPackage(htmlMap);
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 生成卷袋贴
|
|
@@ -294,8 +294,9 @@ public class CreatePdfUtil {
|
|
|
* @param variablePdfList
|
|
|
* @param printCount
|
|
|
* @param examDetailCourseList
|
|
|
+ * @param fileTempList
|
|
|
*/
|
|
|
- public void createPaperPackage(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer printCount, List<ExamDetailCourse> examDetailCourseList, Long examId) {
|
|
|
+ public void createPaperPackage(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer printCount, List<ExamDetailCourse> examDetailCourseList, Long examId, List<File> fileTempList) {
|
|
|
BasicTemplate basicTemplate = basicTemplateService.getById(templateId);
|
|
|
if (Objects.isNull(basicTemplate)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("印品数据有误");
|
|
@@ -443,201 +444,201 @@ public class CreatePdfUtil {
|
|
|
}
|
|
|
}
|
|
|
pdfPackageDto.setBasicPlate(basicPlate);
|
|
|
- printCommonService.saveAttachmentPackagePdf(pdfPackageDto, examDetail, variablePdfList, printCount);
|
|
|
+ printCommonService.saveAttachmentPackagePdf(pdfPackageDto, examDetail, variablePdfList, printCount, fileTempList);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 创建签到表
|
|
|
- *
|
|
|
- * @param basicAttachment
|
|
|
- * @param schoolName
|
|
|
- * @param examDetail
|
|
|
- * @param examStudentList
|
|
|
- * @param variablePdfList
|
|
|
- * @param printCount
|
|
|
- * @param examDetailCourseList
|
|
|
- */
|
|
|
- public void createSignBook(BasicAttachment basicAttachment, String schoolName, ExamDetail
|
|
|
- examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer
|
|
|
- printCount, List<ExamDetailCourse> examDetailCourseList) throws IOException {
|
|
|
- if (Objects.isNull(basicAttachment)) {
|
|
|
- throw ExceptionResultEnum.ATTACHMENT_IS_NULL.exception();
|
|
|
- }
|
|
|
- Map<String, Object> htmlMap = new HashMap<>();
|
|
|
- if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
|
|
|
- List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
|
|
|
- List<String> courseNames = examDetailCourseList.stream().map(ExamDetailCourse::getCourseName).collect(Collectors.toList());
|
|
|
- htmlMap.put("courseName", String.join(", ", courseNames));
|
|
|
- htmlMap.put("courseCode", String.join(", ", paperNumbers));
|
|
|
- } else {
|
|
|
- htmlMap.put("courseName", "");
|
|
|
- htmlMap.put("courseCode", "");
|
|
|
- }
|
|
|
- htmlMap.put("schoolName", schoolName);
|
|
|
- htmlMap.put("examRoom", examDetail.getExamRoom());
|
|
|
-
|
|
|
- List<String> extendColumnList = examStudentList.stream().map(ExamStudent::getExtendFields).distinct().collect(Collectors.toList());
|
|
|
- Set<String> classTeacher = new HashSet();
|
|
|
- if (extendColumnList.size() > 0) {
|
|
|
- for (String s : extendColumnList) {
|
|
|
- List<Map> mapList = JSONObject.parseArray(s, Map.class);
|
|
|
- for (Map map : mapList) {
|
|
|
- if (Objects.equals("classTeacher", map.get("code").toString())) {
|
|
|
- classTeacher.add(map.get("value").toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- htmlMap.put("classTeacher", String.join(",", classTeacher));
|
|
|
- htmlMap.put("startTime", DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
- htmlMap.put("endTime", DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
- htmlMap.put("paperCode", examDetail.getPackageCode());
|
|
|
- htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
|
|
|
-
|
|
|
- int pageSize = 60;
|
|
|
- int halfPageSize = pageSize / 2;
|
|
|
-
|
|
|
- if (examStudentList.size() > 0) {
|
|
|
- int totalCount = examStudentList.size();
|
|
|
- List<Map> subList = new ArrayList<>();
|
|
|
- int pageCount = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
|
|
|
- for (int i = 0; i < pageCount; i++) {
|
|
|
- Map subMap = new HashMap();
|
|
|
- subMap.put("index", i + 1);
|
|
|
- int studentCount;
|
|
|
- List<ExamStudentCourseDto> subStudents;
|
|
|
- if (pageCount == 1) {
|
|
|
- studentCount = totalCount;
|
|
|
- subStudents = examStudentList;
|
|
|
- } else if (i == pageCount - 1) {
|
|
|
- studentCount = totalCount - (pageCount - 1) * pageSize;
|
|
|
- subStudents = examStudentList.subList(pageSize * i, examStudentList.size());
|
|
|
- } else {
|
|
|
- studentCount = pageSize;
|
|
|
- subStudents = examStudentList.subList(pageSize * i, pageSize * (i + 1));
|
|
|
- }
|
|
|
- subMap.put("studentCount", totalCount);
|
|
|
- List<ExamStudentDto> examStudentList1 = new ArrayList<>();
|
|
|
- List<ExamStudentDto> examStudentList2 = new ArrayList<>();
|
|
|
-
|
|
|
- Gson gson = new Gson();
|
|
|
- int mod = subStudents.size() % 2;
|
|
|
- int htmlTableCount = mod == 0 ? subStudents.size() / 2 : subStudents.size() / 2 + 1;
|
|
|
- for (int j = 0; j < htmlTableCount; j++) {
|
|
|
- ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
- examStudentDto.setIndex(j + 1);
|
|
|
- String clazzName = getClassName(examStudentDto);
|
|
|
- examStudentDto.setClazzName(clazzName);
|
|
|
- examStudentList1.add(examStudentDto);
|
|
|
- }
|
|
|
- for (int j = htmlTableCount; j < subStudents.size(); j++) {
|
|
|
- ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
- examStudentDto.setIndex(j + 1);
|
|
|
- String clazzName = getClassName(examStudentDto);
|
|
|
- examStudentDto.setClazzName(clazzName);
|
|
|
- examStudentList2.add(examStudentDto);
|
|
|
- }
|
|
|
-// if (examStudentList1.size() > examStudentList2.size()) {
|
|
|
-// for (int j = subStudents.size() - htmlTableCount; j < examStudentList1.size(); j++) {
|
|
|
-// examStudentList2.add(new ExamStudentDto());
|
|
|
+// /**
|
|
|
+// * 创建签到表
|
|
|
+// *
|
|
|
+// * @param basicAttachment
|
|
|
+// * @param schoolName
|
|
|
+// * @param examDetail
|
|
|
+// * @param examStudentList
|
|
|
+// * @param variablePdfList
|
|
|
+// * @param printCount
|
|
|
+// * @param examDetailCourseList
|
|
|
+// */
|
|
|
+// public void createSignBook(BasicAttachment basicAttachment, String schoolName, ExamDetail
|
|
|
+// examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer
|
|
|
+// printCount, List<ExamDetailCourse> examDetailCourseList) throws IOException {
|
|
|
+// if (Objects.isNull(basicAttachment)) {
|
|
|
+// throw ExceptionResultEnum.ATTACHMENT_IS_NULL.exception();
|
|
|
+// }
|
|
|
+// Map<String, Object> htmlMap = new HashMap<>();
|
|
|
+// if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
|
|
|
+// List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
|
|
|
+// List<String> courseNames = examDetailCourseList.stream().map(ExamDetailCourse::getCourseName).collect(Collectors.toList());
|
|
|
+// htmlMap.put("courseName", String.join(", ", courseNames));
|
|
|
+// htmlMap.put("courseCode", String.join(", ", paperNumbers));
|
|
|
+// } else {
|
|
|
+// htmlMap.put("courseName", "");
|
|
|
+// htmlMap.put("courseCode", "");
|
|
|
+// }
|
|
|
+// htmlMap.put("schoolName", schoolName);
|
|
|
+// htmlMap.put("examRoom", examDetail.getExamRoom());
|
|
|
+//
|
|
|
+// List<String> extendColumnList = examStudentList.stream().map(ExamStudent::getExtendFields).distinct().collect(Collectors.toList());
|
|
|
+// Set<String> classTeacher = new HashSet();
|
|
|
+// if (extendColumnList.size() > 0) {
|
|
|
+// for (String s : extendColumnList) {
|
|
|
+// List<Map> mapList = JSONObject.parseArray(s, Map.class);
|
|
|
+// for (Map map : mapList) {
|
|
|
+// if (Objects.equals("classTeacher", map.get("code").toString())) {
|
|
|
+// classTeacher.add(map.get("value").toString());
|
|
|
// }
|
|
|
// }
|
|
|
- if (examStudentList1.size() < halfPageSize) {
|
|
|
- int examStudentList1Size = examStudentList1.size();
|
|
|
- for (int j = 0; j < halfPageSize - examStudentList1Size; j++) {
|
|
|
- ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
- examStudentDto.setIndex(null);
|
|
|
- examStudentDto.setSiteNumber("");
|
|
|
- examStudentDto.setStudentName("");
|
|
|
- examStudentDto.setClazzName("");
|
|
|
- examStudentList1.add(examStudentDto);
|
|
|
- }
|
|
|
- }
|
|
|
- if (examStudentList2.size() < halfPageSize) {
|
|
|
- int examStudentList2Size = examStudentList2.size();
|
|
|
- for (int j = 0; j < halfPageSize - examStudentList2Size; j++) {
|
|
|
- ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
- examStudentDto.setIndex(null);
|
|
|
- examStudentDto.setSiteNumber("");
|
|
|
- examStudentDto.setStudentName("");
|
|
|
- examStudentDto.setClazzName("");
|
|
|
- examStudentList2.add(examStudentDto);
|
|
|
- }
|
|
|
- }
|
|
|
- subMap.put("studentList1", examStudentList1);
|
|
|
- subMap.put("studentList2", examStudentList2);
|
|
|
- subList.add(subMap);
|
|
|
- }
|
|
|
- htmlMap.put("subList", subList);
|
|
|
- } else {
|
|
|
- int totalCount = examDetail.getPrintCount();
|
|
|
- List<Map> subList = new ArrayList<>();
|
|
|
- int pageCount = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
|
|
|
- for (int i = 0; i < pageCount; i++) {
|
|
|
- Map subMap = new HashMap();
|
|
|
- subMap.put("index", i + 1);
|
|
|
- int studentCount;
|
|
|
- if (pageCount == 1) {
|
|
|
- studentCount = pageSize;
|
|
|
- } else if (i == pageCount - 1) {
|
|
|
- studentCount = totalCount - (pageCount - 1) * pageSize;
|
|
|
- } else {
|
|
|
- studentCount = pageSize;
|
|
|
- }
|
|
|
- subMap.put("studentCount", totalCount);
|
|
|
- List<ExamStudentDto> examStudentList1 = new ArrayList<>();
|
|
|
- List<ExamStudentDto> examStudentList2 = new ArrayList<>();
|
|
|
-
|
|
|
- int mod = studentCount % 2;
|
|
|
- int htmlTableCount = mod == 0 ? studentCount / 2 : studentCount / 2 + 1;
|
|
|
- for (int j = 0; j < htmlTableCount; j++) {
|
|
|
- ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
- examStudentDto.setIndex(null);
|
|
|
- examStudentDto.setStudentName("");
|
|
|
- examStudentDto.setClazzName("");
|
|
|
- examStudentList1.add(examStudentDto);
|
|
|
- }
|
|
|
- for (int j = htmlTableCount; j < studentCount; j++) {
|
|
|
- ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
- examStudentDto.setIndex(null);
|
|
|
- examStudentDto.setStudentName("");
|
|
|
- examStudentDto.setClazzName("");
|
|
|
- examStudentList2.add(examStudentDto);
|
|
|
- }
|
|
|
- if (examStudentList1.size() < halfPageSize) {
|
|
|
- for (int j = 0; j < halfPageSize - examStudentList1.size(); j++) {
|
|
|
- ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
- examStudentDto.setIndex(null);
|
|
|
- examStudentDto.setSiteNumber("");
|
|
|
- examStudentDto.setStudentName("");
|
|
|
- examStudentDto.setClazzName("");
|
|
|
- examStudentList1.add(examStudentDto);
|
|
|
- }
|
|
|
- }
|
|
|
- if (examStudentList2.size() < halfPageSize) {
|
|
|
- for (int j = 0; j < halfPageSize - examStudentList2.size(); j++) {
|
|
|
- ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
- examStudentDto.setIndex(null);
|
|
|
- examStudentDto.setSiteNumber("");
|
|
|
- examStudentDto.setStudentName("");
|
|
|
- examStudentDto.setClazzName("");
|
|
|
- examStudentList2.add(examStudentDto);
|
|
|
- }
|
|
|
- }
|
|
|
- subMap.put("studentList1", examStudentList1);
|
|
|
- subMap.put("studentList2", examStudentList2);
|
|
|
- subList.add(subMap);
|
|
|
- }
|
|
|
- htmlMap.put("subList", subList);
|
|
|
- }
|
|
|
- htmlMap.computeIfAbsent("basicAttachment", v -> basicAttachment);
|
|
|
- htmlMap.computeIfAbsent("variablePdfList", v -> variablePdfList);
|
|
|
- htmlMap.computeIfAbsent("printCount", v -> printCount);
|
|
|
- htmlMap.computeIfAbsent("sequence", v -> 2);
|
|
|
- htmlMap.computeIfAbsent("examDetail", v -> examDetail);
|
|
|
- htmlMap.computeIfAbsent("printType", v -> ClassifyEnum.SIGN);
|
|
|
- freemarkerUtil.createSignBook(htmlMap);
|
|
|
- }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// htmlMap.put("classTeacher", String.join(",", classTeacher));
|
|
|
+// htmlMap.put("startTime", DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
+// htmlMap.put("endTime", DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DEFAULT_DATE_PATTERN));
|
|
|
+// htmlMap.put("paperCode", examDetail.getPackageCode());
|
|
|
+// htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
|
|
|
+//
|
|
|
+// int pageSize = 60;
|
|
|
+// int halfPageSize = pageSize / 2;
|
|
|
+//
|
|
|
+// if (examStudentList.size() > 0) {
|
|
|
+// int totalCount = examStudentList.size();
|
|
|
+// List<Map> subList = new ArrayList<>();
|
|
|
+// int pageCount = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
|
|
|
+// for (int i = 0; i < pageCount; i++) {
|
|
|
+// Map subMap = new HashMap();
|
|
|
+// subMap.put("index", i + 1);
|
|
|
+// int studentCount;
|
|
|
+// List<ExamStudentCourseDto> subStudents;
|
|
|
+// if (pageCount == 1) {
|
|
|
+// studentCount = totalCount;
|
|
|
+// subStudents = examStudentList;
|
|
|
+// } else if (i == pageCount - 1) {
|
|
|
+// studentCount = totalCount - (pageCount - 1) * pageSize;
|
|
|
+// subStudents = examStudentList.subList(pageSize * i, examStudentList.size());
|
|
|
+// } else {
|
|
|
+// studentCount = pageSize;
|
|
|
+// subStudents = examStudentList.subList(pageSize * i, pageSize * (i + 1));
|
|
|
+// }
|
|
|
+// subMap.put("studentCount", totalCount);
|
|
|
+// List<ExamStudentDto> examStudentList1 = new ArrayList<>();
|
|
|
+// List<ExamStudentDto> examStudentList2 = new ArrayList<>();
|
|
|
+//
|
|
|
+// Gson gson = new Gson();
|
|
|
+// int mod = subStudents.size() % 2;
|
|
|
+// int htmlTableCount = mod == 0 ? subStudents.size() / 2 : subStudents.size() / 2 + 1;
|
|
|
+// for (int j = 0; j < htmlTableCount; j++) {
|
|
|
+// ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
+// examStudentDto.setIndex(j + 1);
|
|
|
+// String clazzName = getClassName(examStudentDto);
|
|
|
+// examStudentDto.setClazzName(clazzName);
|
|
|
+// examStudentList1.add(examStudentDto);
|
|
|
+// }
|
|
|
+// for (int j = htmlTableCount; j < subStudents.size(); j++) {
|
|
|
+// ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
+// examStudentDto.setIndex(j + 1);
|
|
|
+// String clazzName = getClassName(examStudentDto);
|
|
|
+// examStudentDto.setClazzName(clazzName);
|
|
|
+// examStudentList2.add(examStudentDto);
|
|
|
+// }
|
|
|
+//// if (examStudentList1.size() > examStudentList2.size()) {
|
|
|
+//// for (int j = subStudents.size() - htmlTableCount; j < examStudentList1.size(); j++) {
|
|
|
+//// examStudentList2.add(new ExamStudentDto());
|
|
|
+//// }
|
|
|
+//// }
|
|
|
+// if (examStudentList1.size() < halfPageSize) {
|
|
|
+// int examStudentList1Size = examStudentList1.size();
|
|
|
+// for (int j = 0; j < halfPageSize - examStudentList1Size; j++) {
|
|
|
+// ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
+// examStudentDto.setIndex(null);
|
|
|
+// examStudentDto.setSiteNumber("");
|
|
|
+// examStudentDto.setStudentName("");
|
|
|
+// examStudentDto.setClazzName("");
|
|
|
+// examStudentList1.add(examStudentDto);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (examStudentList2.size() < halfPageSize) {
|
|
|
+// int examStudentList2Size = examStudentList2.size();
|
|
|
+// for (int j = 0; j < halfPageSize - examStudentList2Size; j++) {
|
|
|
+// ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
+// examStudentDto.setIndex(null);
|
|
|
+// examStudentDto.setSiteNumber("");
|
|
|
+// examStudentDto.setStudentName("");
|
|
|
+// examStudentDto.setClazzName("");
|
|
|
+// examStudentList2.add(examStudentDto);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// subMap.put("studentList1", examStudentList1);
|
|
|
+// subMap.put("studentList2", examStudentList2);
|
|
|
+// subList.add(subMap);
|
|
|
+// }
|
|
|
+// htmlMap.put("subList", subList);
|
|
|
+// } else {
|
|
|
+// int totalCount = examDetail.getPrintCount();
|
|
|
+// List<Map> subList = new ArrayList<>();
|
|
|
+// int pageCount = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
|
|
|
+// for (int i = 0; i < pageCount; i++) {
|
|
|
+// Map subMap = new HashMap();
|
|
|
+// subMap.put("index", i + 1);
|
|
|
+// int studentCount;
|
|
|
+// if (pageCount == 1) {
|
|
|
+// studentCount = pageSize;
|
|
|
+// } else if (i == pageCount - 1) {
|
|
|
+// studentCount = totalCount - (pageCount - 1) * pageSize;
|
|
|
+// } else {
|
|
|
+// studentCount = pageSize;
|
|
|
+// }
|
|
|
+// subMap.put("studentCount", totalCount);
|
|
|
+// List<ExamStudentDto> examStudentList1 = new ArrayList<>();
|
|
|
+// List<ExamStudentDto> examStudentList2 = new ArrayList<>();
|
|
|
+//
|
|
|
+// int mod = studentCount % 2;
|
|
|
+// int htmlTableCount = mod == 0 ? studentCount / 2 : studentCount / 2 + 1;
|
|
|
+// for (int j = 0; j < htmlTableCount; j++) {
|
|
|
+// ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
+// examStudentDto.setIndex(null);
|
|
|
+// examStudentDto.setStudentName("");
|
|
|
+// examStudentDto.setClazzName("");
|
|
|
+// examStudentList1.add(examStudentDto);
|
|
|
+// }
|
|
|
+// for (int j = htmlTableCount; j < studentCount; j++) {
|
|
|
+// ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
+// examStudentDto.setIndex(null);
|
|
|
+// examStudentDto.setStudentName("");
|
|
|
+// examStudentDto.setClazzName("");
|
|
|
+// examStudentList2.add(examStudentDto);
|
|
|
+// }
|
|
|
+// if (examStudentList1.size() < halfPageSize) {
|
|
|
+// for (int j = 0; j < halfPageSize - examStudentList1.size(); j++) {
|
|
|
+// ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
+// examStudentDto.setIndex(null);
|
|
|
+// examStudentDto.setSiteNumber("");
|
|
|
+// examStudentDto.setStudentName("");
|
|
|
+// examStudentDto.setClazzName("");
|
|
|
+// examStudentList1.add(examStudentDto);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (examStudentList2.size() < halfPageSize) {
|
|
|
+// for (int j = 0; j < halfPageSize - examStudentList2.size(); j++) {
|
|
|
+// ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
+// examStudentDto.setIndex(null);
|
|
|
+// examStudentDto.setSiteNumber("");
|
|
|
+// examStudentDto.setStudentName("");
|
|
|
+// examStudentDto.setClazzName("");
|
|
|
+// examStudentList2.add(examStudentDto);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// subMap.put("studentList1", examStudentList1);
|
|
|
+// subMap.put("studentList2", examStudentList2);
|
|
|
+// subList.add(subMap);
|
|
|
+// }
|
|
|
+// htmlMap.put("subList", subList);
|
|
|
+// }
|
|
|
+// htmlMap.computeIfAbsent("basicAttachment", v -> basicAttachment);
|
|
|
+// htmlMap.computeIfAbsent("variablePdfList", v -> variablePdfList);
|
|
|
+// htmlMap.computeIfAbsent("printCount", v -> printCount);
|
|
|
+// htmlMap.computeIfAbsent("sequence", v -> 2);
|
|
|
+// htmlMap.computeIfAbsent("examDetail", v -> examDetail);
|
|
|
+// htmlMap.computeIfAbsent("printType", v -> ClassifyEnum.SIGN);
|
|
|
+// freemarkerUtil.createSignBook(htmlMap);
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 创建签到表
|
|
@@ -649,8 +650,9 @@ public class CreatePdfUtil {
|
|
|
* @param variablePdfList
|
|
|
* @param printCount
|
|
|
* @param examDetailCourseList
|
|
|
+ * @param fileTempList
|
|
|
*/
|
|
|
- public void createSignBook(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer printCount, List<ExamDetailCourse> examDetailCourseList) {
|
|
|
+ public void createSignBook(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer printCount, List<ExamDetailCourse> examDetailCourseList, List<File> fileTempList) {
|
|
|
BasicTemplate basicTemplate = basicTemplateService.getById(templateId);
|
|
|
if (Objects.isNull(basicTemplate)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("印品数据有误");
|
|
@@ -766,7 +768,7 @@ public class CreatePdfUtil {
|
|
|
}
|
|
|
pdfFillDto.setStudentPlate(studentPlate);
|
|
|
|
|
|
- printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, variablePdfList, printCount);
|
|
|
+ printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, variablePdfList, printCount, fileTempList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -907,8 +909,9 @@ public class CreatePdfUtil {
|
|
|
*
|
|
|
* @param paperType 抽取的试卷型(多个用,分隔)
|
|
|
* @param examTaskDetail 命题任务上传试卷信息
|
|
|
+ * @param fileTempList
|
|
|
*/
|
|
|
- public List<PaperPdfDto> getPaperPdfFile(String paperType, ExamTaskDetail examTaskDetail) throws Exception {
|
|
|
+ public List<PaperPdfDto> getPaperPdfFile(String paperType, ExamTaskDetail examTaskDetail, List<File> fileTempList) throws Exception {
|
|
|
String[] paperTypes = paperType.split(",");
|
|
|
List<PaperPdfDto> paperPdfDtoList = new ArrayList<>();
|
|
|
PaperPdfDto paperPdfDto = null;
|
|
@@ -925,7 +928,7 @@ public class CreatePdfUtil {
|
|
|
// 返回抽中的试卷
|
|
|
for (String type : paperTypes) {
|
|
|
if (Objects.equals(name.toUpperCase(), type.toUpperCase())) {
|
|
|
- File file = teachcloudCommonService.getFile(basicAttachment.getPath(), false);
|
|
|
+ File file = teachcloudCommonService.getFile(basicAttachment.getPath(), false, fileTempList);
|
|
|
int pages = (int) object.get("pages");
|
|
|
|
|
|
PageSizeEnum pageSizeEnum = PageSizeEnum.valueOf((String) jsonObject.get("pageSize"));
|
|
@@ -1047,17 +1050,18 @@ public class CreatePdfUtil {
|
|
|
/**
|
|
|
* 合并A3 pdf
|
|
|
*
|
|
|
+ * @param fileTempList
|
|
|
* @param list
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public String mergeA3Pdf(List<PdfDto>... list) throws IOException {
|
|
|
+ public String mergeA3Pdf(List<File> fileTempList, List<PdfDto>... list) throws IOException {
|
|
|
List<PdfDto> mergePdfA3List = new ArrayList<>();
|
|
|
for (int i = 0; i < list.length; i++) {
|
|
|
mergePdfA3List.addAll(list[i]);
|
|
|
}
|
|
|
List<String> pathA3List = mergePdfA3List.stream().map(PdfDto::getPath).collect(Collectors.toList());
|
|
|
- return PdfUtil.mergePdf(pathA3List.toArray(new String[mergePdfA3List.size()]), null);
|
|
|
+ return PdfUtil.mergePdf(pathA3List.toArray(new String[mergePdfA3List.size()]), null, fileTempList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1067,39 +1071,36 @@ public class CreatePdfUtil {
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public String mergeA4Pdf(List<PdfDto>... list) throws IOException {
|
|
|
+ public String mergeA4Pdf(List<File> fileTempList, List<PdfDto>... list) throws IOException {
|
|
|
List<PdfDto> mergePdfA4List = new ArrayList<>();
|
|
|
for (int i = 0; i < list.length; i++) {
|
|
|
mergePdfA4List.addAll(list[i]);
|
|
|
}
|
|
|
List<String> pathA4List = mergePdfA4List.stream().map(PdfDto::getPath).collect(Collectors.toList());
|
|
|
- return PdfUtil.mergePdf(pathA4List.toArray(new String[mergePdfA4List.size()]), null);
|
|
|
+ return PdfUtil.mergePdf(pathA4List.toArray(new String[mergePdfA4List.size()]), null, fileTempList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 合并pdf后保存数据库
|
|
|
*
|
|
|
- * @param dirNameA4
|
|
|
* @param dirNamePaper
|
|
|
* @param dirNameCardA3
|
|
|
* @param tbTask
|
|
|
* @param userId
|
|
|
* @param examDetail
|
|
|
* @param basicExam
|
|
|
- * @param mergePdfDeleteList
|
|
|
+ * @param fileTempList
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public BasicAttachment mergePdfSaveDb(String dirNameA4,
|
|
|
- String dirNamePaper,
|
|
|
+ public BasicAttachment mergePdfSaveDb(String dirNamePaper,
|
|
|
String dirNameCardA3,
|
|
|
TBTask tbTask,
|
|
|
Long userId,
|
|
|
ExamDetail examDetail,
|
|
|
BasicExam basicExam,
|
|
|
- List<PdfDto> mergePdfDeleteList) throws Exception {
|
|
|
- boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
+ List<File> fileTempList) throws Exception {
|
|
|
File localA4PdfFile = null, localPaperPdfFile = null, localA3PdfCardFile = null;
|
|
|
BasicAttachment basicAttachment = null;
|
|
|
// 试卷+题卡
|
|
@@ -1152,10 +1153,11 @@ public class CreatePdfUtil {
|
|
|
* @param basicCardRule 题卡规则
|
|
|
*/
|
|
|
public BasicAttachment examStudentHtml(String studentContent, ExamStudent examStudent, String
|
|
|
- paperType, ExamDetail examDetail, ExamDetailCourse examDetailCourse, Long
|
|
|
- userId, List<PdfDto> examStudentPdfList, BasicCardRule basicCardRule) throws IOException {
|
|
|
+ paperType, ExamDetail examDetail, ExamDetailCourse examDetailCourse,
|
|
|
+ Long userId, List<PdfDto> examStudentPdfList, BasicCardRule basicCardRule,
|
|
|
+ List<File> fileTempList) throws IOException {
|
|
|
String studentHtml = studentContent;
|
|
|
- /*if (Objects.nonNull(examStudent.getExtendFields())) {
|
|
|
+ /*if (Objects.nonNull(examStudent.getExtendFields())) {
|
|
|
JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(examStudent.getExtendFields());//扩展字段
|
|
|
if (Objects.nonNull(jsonObjectExtend)) {
|
|
|
int i = 0;
|
|
@@ -1196,7 +1198,7 @@ public class CreatePdfUtil {
|
|
|
studentHtml = studentHtml.replaceAll("\\$\\{paperNumber\\}", examDetailCourse.getPaperNumber());*/
|
|
|
|
|
|
//学生题卡
|
|
|
- BasicAttachment examStudentAttachment = printCommonService.saveAttachmentHtml(examDetail.getSchoolId() + "|" + examDetailCourse.getCourseCode() + (examStudent != null && examStudent.getTicketNumber() != null ? "|" + examStudent.getTicketNumber() : ""), studentHtml, userId, examStudentPdfList);
|
|
|
+ BasicAttachment examStudentAttachment = printCommonService.saveAttachmentHtml(examDetail.getSchoolId() + "|" + examDetailCourse.getCourseCode() + (examStudent != null && examStudent.getTicketNumber() != null ? "|" + examStudent.getTicketNumber() : ""), studentHtml, userId, examStudentPdfList, fileTempList);
|
|
|
if (examStudent != null) {
|
|
|
examStudent.setAttachmentId(examStudentAttachment.getId());
|
|
|
}
|
|
@@ -1307,8 +1309,9 @@ public class CreatePdfUtil {
|
|
|
* @param userId 当前用户ID
|
|
|
* @param cardPdfList 备用题卡集合
|
|
|
* @param basicCardRule 题卡规则对象
|
|
|
+ * @param fileTempList
|
|
|
*/
|
|
|
- public BasicAttachment cardHtml(String sequence, String cardContent, ExamDetail examDetail, ExamDetailCourse examDetailCourse, String paperType, JSONArray jsonArray, Long userId, List<PdfDto> cardPdfList, BasicCardRule basicCardRule) throws
|
|
|
+ public BasicAttachment cardHtml(String sequence, String cardContent, ExamDetail examDetail, ExamDetailCourse examDetailCourse, String paperType, JSONArray jsonArray, Long userId, List<PdfDto> cardPdfList, BasicCardRule basicCardRule, List<File> fileTempList) throws
|
|
|
IOException {
|
|
|
//通用题卡
|
|
|
String cardTemp = cardContent;
|
|
@@ -1359,7 +1362,7 @@ public class CreatePdfUtil {
|
|
|
cardTemp = cardTemp.replaceAll("<div class=\"page-box page-box-A4 page-box-0 page-box-less\">", packageCodeDiv);
|
|
|
}
|
|
|
|
|
|
- BasicAttachment cardAttachment = printCommonService.saveAttachmentHtml(examDetail.getSchoolId() + "|" + examDetailCourse.getCourseCode(), cardTemp, userId, cardPdfList);
|
|
|
+ BasicAttachment cardAttachment = printCommonService.saveAttachmentHtml(examDetail.getSchoolId() + "|" + examDetailCourse.getCourseCode(), cardTemp, userId, cardPdfList, fileTempList);
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("name", paperType);
|
|
|
object.put("examDetailCourseId", examDetailCourse.getId());
|