|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.distributed.print.business.util;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -88,6 +89,7 @@ public class CreatePdfUtil {
|
|
|
/**
|
|
|
* 生成卷袋贴
|
|
|
*
|
|
|
+ * @param tag
|
|
|
* @param basicAttachment
|
|
|
* @param schoolName
|
|
|
* @param examDetailCourse
|
|
@@ -96,33 +98,76 @@ public class CreatePdfUtil {
|
|
|
* @param printCount
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public void createPaperPackage(BasicAttachment basicAttachment, String schoolName, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
|
|
|
+ public void createPaperPackage(boolean tag, BasicAttachment basicAttachment, String schoolName, ExamDetail examDetail, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
|
|
|
if (Objects.isNull(basicAttachment)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("找不到附件");
|
|
|
}
|
|
|
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("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", 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");
|
|
|
+ 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();
|
|
|
+
|
|
|
+ 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", String.join(",", className));
|
|
|
+ htmlMap.put("proctorCollege", String.join(",", proctorCollege));
|
|
|
+ htmlMap.put("examManager", String.join(",", examManager));
|
|
|
+
|
|
|
+ String minSite = examStudentList.stream().min((a, b) -> {
|
|
|
+ if (Objects.nonNull(a.getSiteNumber()) && Objects.nonNull(a.getSiteNumber())) {
|
|
|
+ return a.getSiteNumber().compareTo(b.getSiteNumber());
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }).get().getSiteNumber();
|
|
|
+ minSite = Objects.isNull(minSite) ? "" : minSite;
|
|
|
+
|
|
|
+ String maxSite = examStudentList.stream().max((a, b) -> {
|
|
|
+ if (Objects.nonNull(a.getSiteNumber()) && Objects.nonNull(a.getSiteNumber())) {
|
|
|
+ return a.getSiteNumber().compareTo(b.getSiteNumber());
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }).get().getSiteNumber();
|
|
|
+ maxSite = Objects.isNull(maxSite) ? "" : maxSite;
|
|
|
|
|
|
- htmlMap.put("minSite", "测试minSite1");
|
|
|
- htmlMap.put("maxSite", "测试maxSite1");
|
|
|
+ htmlMap.put("minSite", minSite);
|
|
|
+ htmlMap.put("maxSite", maxSite);
|
|
|
htmlMap.put("studentCount", examStudentList.size());
|
|
|
|
|
|
- htmlMap.put("tag", "测试tag1");
|
|
|
+ htmlMap.put("tag", tag ? "订" : "");
|
|
|
|
|
|
htmlMap.computeIfAbsent("basicAttachment", v -> basicAttachment);
|
|
|
htmlMap.computeIfAbsent("variablePdfList", v -> variablePdfList);
|
|
@@ -135,6 +180,7 @@ public class CreatePdfUtil {
|
|
|
*
|
|
|
* @param basicAttachment
|
|
|
* @param schoolName
|
|
|
+ * @param examDetail
|
|
|
* @param examDetailCourse
|
|
|
* @param examStudentList
|
|
|
* @param variablePdfList
|
|
@@ -150,9 +196,22 @@ public class CreatePdfUtil {
|
|
|
htmlMap.put("courseName", examDetailCourse.getCourseName());
|
|
|
htmlMap.put("courseCode", examDetailCourse.getCourseCode());
|
|
|
htmlMap.put("examRoom", examDetail.getExamRoom());
|
|
|
- htmlMap.put("classTeacher", "测试老师1");
|
|
|
- htmlMap.put("startTime", "2021-04-13 00:00:00");
|
|
|
- htmlMap.put("endTime", "2021-04-14 00:00:00");
|
|
|
+
|
|
|
+ List<String> extendColumnList = examStudentList.stream().map(m -> m.getExtendFields()).distinct().collect(Collectors.toList());
|
|
|
+ Set<String> classTeacher = new HashSet();
|
|
|
+ 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("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", examDetailCourse.getPaperNumber());
|
|
|
htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetailCourse.getPaperNumber(), false));
|
|
|
|
|
@@ -245,13 +304,15 @@ public class CreatePdfUtil {
|
|
|
/**
|
|
|
* 获取试卷pdf
|
|
|
*
|
|
|
+ * @param paperType
|
|
|
* @param examTaskDetail
|
|
|
* @param backupCount
|
|
|
* @param pdfList
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public void getPaperPdf(ExamTaskDetail examTaskDetail, Integer backupCount, List<PdfDto>... pdfList) throws IOException {
|
|
|
+ public boolean getPaperPdf(String paperType, ExamTaskDetail examTaskDetail, Integer backupCount, List<PdfDto>... pdfList) throws IOException {
|
|
|
+ boolean tag = true;
|
|
|
JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
|
|
|
for (int i = 0; i < jsonArrayPaper.size(); i++) {
|
|
|
JSONObject object = (JSONObject) jsonArrayPaper.get(i);
|
|
@@ -261,14 +322,20 @@ public class CreatePdfUtil {
|
|
|
if (Objects.isNull(basicAttachment)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("找不到附件");
|
|
|
}
|
|
|
- File file = commonService.getFile(basicAttachment.getPath(), false);
|
|
|
- int pageCount = PdfUtil.addPdfPage(file);
|
|
|
- pdfList[0].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pageCount));
|
|
|
- for (int j = 1; j <= backupCount; j++) {
|
|
|
- pdfList[1].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pageCount));
|
|
|
+ String name = (String) object.get("name");
|
|
|
+ if (Objects.equals(name.toUpperCase(), paperType.toUpperCase())) {
|
|
|
+ File file = commonService.getFile(basicAttachment.getPath(), false);
|
|
|
+ int pages = (int) object.get("pages");
|
|
|
+ tag = pages > 2 ? true : false;
|
|
|
+ int pageCount = PdfUtil.addPdfPage(file);
|
|
|
+ pdfList[0].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pageCount));
|
|
|
+ for (int j = 1; j <= backupCount; j++) {
|
|
|
+ pdfList[1].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pageCount));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return tag;
|
|
|
}
|
|
|
|
|
|
/**
|