|
@@ -242,7 +242,7 @@ public class CreatePdfUtil {
|
|
|
|
|
|
htmlMap.put("minSite", Optional.ofNullable(minSite).map(s -> s.get().getSiteNumber()).orElse(""));
|
|
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("maxSite", Optional.ofNullable(maxSite).map(s -> s.get().getSiteNumber()).orElse(""));
|
|
- htmlMap.put("studentCount", examStudentList.size());
|
|
|
|
|
|
+ htmlMap.put("studentCount", examStudentList != null && examStudentList.size() > 0 ? examStudentList.size() : examDetail.getPrintCount());
|
|
|
|
|
|
String tagValue = tag ? "订" : null;
|
|
String tagValue = tag ? "订" : null;
|
|
htmlMap.put("tag", tagValue);
|
|
htmlMap.put("tag", tagValue);
|
|
@@ -302,10 +302,10 @@ public class CreatePdfUtil {
|
|
htmlMap.put("paperCode", examDetail.getPackageCode());
|
|
htmlMap.put("paperCode", examDetail.getPackageCode());
|
|
htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
|
|
htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
|
|
|
|
|
|
- int totalCount = examStudentList.size();
|
|
|
|
- if (totalCount > 0) {
|
|
|
|
|
|
+ if (examStudentList.size() > 0) {
|
|
|
|
+ int totalCount = examStudentList.size();
|
|
List<Map> subList = new ArrayList<>();
|
|
List<Map> subList = new ArrayList<>();
|
|
- int pageCount = totalCount % 80 == 0 ? totalCount / 80 : totalCount / 80 + 1;
|
|
|
|
|
|
+ int pageCount = totalCount % 70 == 0 ? totalCount / 70 : totalCount / 70 + 1;
|
|
for (int i = 0; i < pageCount; i++) {
|
|
for (int i = 0; i < pageCount; i++) {
|
|
Map subMap = new HashMap();
|
|
Map subMap = new HashMap();
|
|
subMap.put("index", i + 1);
|
|
subMap.put("index", i + 1);
|
|
@@ -314,14 +314,14 @@ public class CreatePdfUtil {
|
|
if (pageCount == 1) {
|
|
if (pageCount == 1) {
|
|
studentCount = totalCount;
|
|
studentCount = totalCount;
|
|
subStudents = examStudentList;
|
|
subStudents = examStudentList;
|
|
- } else if (pageCount > 1 && i == pageCount - 1) {
|
|
|
|
- studentCount = totalCount - (pageCount - 1) * 80;
|
|
|
|
- subStudents = examStudentList.subList(80 * i, examStudentList.size());
|
|
|
|
|
|
+ } else if (i == pageCount - 1) {
|
|
|
|
+ studentCount = totalCount - (pageCount - 1) * 70;
|
|
|
|
+ subStudents = examStudentList.subList(70 * i, examStudentList.size());
|
|
} else {
|
|
} else {
|
|
- studentCount = 80;
|
|
|
|
- subStudents = examStudentList.subList(80 * i, 80 * (i + 1));
|
|
|
|
|
|
+ studentCount = 70;
|
|
|
|
+ subStudents = examStudentList.subList(70 * i, 70 * (i + 1));
|
|
}
|
|
}
|
|
- subMap.put("studentCount", studentCount);
|
|
|
|
|
|
+ subMap.put("studentCount", totalCount);
|
|
List<ExamStudentDto> examStudentList1 = new ArrayList<>();
|
|
List<ExamStudentDto> examStudentList1 = new ArrayList<>();
|
|
List<ExamStudentDto> examStudentList2 = new ArrayList<>();
|
|
List<ExamStudentDto> examStudentList2 = new ArrayList<>();
|
|
|
|
|
|
@@ -356,6 +356,53 @@ public class CreatePdfUtil {
|
|
subList.add(subMap);
|
|
subList.add(subMap);
|
|
}
|
|
}
|
|
htmlMap.put("subList", subList);
|
|
htmlMap.put("subList", subList);
|
|
|
|
+ } else {
|
|
|
|
+ int totalCount = examDetail.getPrintCount();
|
|
|
|
+ List<Map> subList = new ArrayList<>();
|
|
|
|
+ int pageCount = totalCount % 70 == 0 ? totalCount / 70 : totalCount / 70 + 1;
|
|
|
|
+ for (int i = 0; i < pageCount; i++) {
|
|
|
|
+ Map subMap = new HashMap();
|
|
|
|
+ subMap.put("index", i + 1);
|
|
|
|
+ int studentCount;
|
|
|
|
+ if (pageCount == 1) {
|
|
|
|
+ studentCount = 70;
|
|
|
|
+ } else if (i == pageCount - 1) {
|
|
|
|
+ studentCount = totalCount - (pageCount - 1) * 70;
|
|
|
|
+ } else {
|
|
|
|
+ studentCount = 70;
|
|
|
|
+ }
|
|
|
|
+ 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(j + 1);
|
|
|
|
+ examStudentDto.setName("");
|
|
|
|
+ examStudentDto.setExtendColumn("");
|
|
|
|
+ examStudentDto.setExtendFields("");
|
|
|
|
+ examStudentList1.add(examStudentDto);
|
|
|
|
+ }
|
|
|
|
+ for (int j = htmlTableCount; j < studentCount; j++) {
|
|
|
|
+ ExamStudentDto examStudentDto = new ExamStudentDto();
|
|
|
|
+ examStudentDto.setIndex(j + 1);
|
|
|
|
+ examStudentDto.setName("");
|
|
|
|
+ examStudentDto.setExtendColumn("");
|
|
|
|
+ examStudentDto.setExtendFields("");
|
|
|
|
+ examStudentList2.add(examStudentDto);
|
|
|
|
+ }
|
|
|
|
+ if (examStudentList1.size() > examStudentList2.size()) {
|
|
|
|
+ for (int j = studentCount - htmlTableCount; j < examStudentList1.size(); j++) {
|
|
|
|
+ examStudentList2.add(new ExamStudentDto());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ subMap.put("studentList1", examStudentList1);
|
|
|
|
+ subMap.put("studentList2", examStudentList2);
|
|
|
|
+ subList.add(subMap);
|
|
|
|
+ }
|
|
|
|
+ htmlMap.put("subList", subList);
|
|
}
|
|
}
|
|
htmlMap.computeIfAbsent("basicAttachment", v -> basicAttachment);
|
|
htmlMap.computeIfAbsent("basicAttachment", v -> basicAttachment);
|
|
htmlMap.computeIfAbsent("variablePdfList", v -> variablePdfList);
|
|
htmlMap.computeIfAbsent("variablePdfList", v -> variablePdfList);
|
|
@@ -778,13 +825,14 @@ public class CreatePdfUtil {
|
|
*
|
|
*
|
|
* @param studentContent 题卡html内容
|
|
* @param studentContent 题卡html内容
|
|
* @param examStudent 考生对象
|
|
* @param examStudent 考生对象
|
|
|
|
+ * @param tempPaperType
|
|
* @param examDetail 考场对象
|
|
* @param examDetail 考场对象
|
|
* @param examDetailCourse 考场课程对象
|
|
* @param examDetailCourse 考场课程对象
|
|
* @param userId 当前用户ID
|
|
* @param userId 当前用户ID
|
|
* @param examStudentPdfList 考生题卡集合
|
|
* @param examStudentPdfList 考生题卡集合
|
|
* @param basicCardRule 题卡规则
|
|
* @param basicCardRule 题卡规则
|
|
*/
|
|
*/
|
|
- public BasicAttachment examStudentHtml(String studentContent, ExamStudent examStudent, ExamDetail examDetail, ExamDetailCourse examDetailCourse, Long userId, List<PdfDto> examStudentPdfList, BasicCardRule basicCardRule) throws IOException {
|
|
|
|
|
|
+ public BasicAttachment examStudentHtml(String studentContent, ExamStudent examStudent, String paperType, ExamDetail examDetail, ExamDetailCourse examDetailCourse, Long userId, List<PdfDto> examStudentPdfList, BasicCardRule basicCardRule) throws IOException {
|
|
String studentHtml = studentContent;
|
|
String studentHtml = studentContent;
|
|
/*if (Objects.nonNull(examStudent.getExtendFields())) {
|
|
/*if (Objects.nonNull(examStudent.getExtendFields())) {
|
|
JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(examStudent.getExtendFields());//扩展字段
|
|
JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(examStudent.getExtendFields());//扩展字段
|
|
@@ -801,9 +849,9 @@ public class CreatePdfUtil {
|
|
studentHtml = studentHtml.replaceAll("\\$\\{examNumber\\}", examStudent != null && examStudent.getTicketNumber() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getTicketNumber(), false) : "");
|
|
studentHtml = studentHtml.replaceAll("\\$\\{examNumber\\}", examStudent != null && examStudent.getTicketNumber() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getTicketNumber(), false) : "");
|
|
studentHtml = studentHtml.replaceAll("\\$\\{examNumberStr\\}", examStudent != null && examStudent.getTicketNumber() != null ? examStudent.getTicketNumber() : "");
|
|
studentHtml = studentHtml.replaceAll("\\$\\{examNumberStr\\}", examStudent != null && examStudent.getTicketNumber() != null ? examStudent.getTicketNumber() : "");
|
|
// 随机生成学生试卷条码并将图片转成base64
|
|
// 随机生成学生试卷条码并将图片转成base64
|
|
- studentHtml = studentHtml.replaceAll("\\$\\{paperType\\}", examStudent != null && examStudent.getPaperType() != null ? GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(examStudent.getPaperType()), false) : "");
|
|
|
|
|
|
+ studentHtml = studentHtml.replaceAll("\\$\\{paperType\\}", examStudent != null && examStudent.getPaperType() != null ? GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(examStudent.getPaperType()), false) : StringUtils.isNotBlank(paperType) ? GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false) : "");
|
|
// 替换考生卷型
|
|
// 替换考生卷型
|
|
- studentHtml = studentHtml.replaceAll("\\$\\{paperTypeName\\}", examStudent != null && examStudent.getPaperType() != null ? examStudent.getPaperType() : "");
|
|
|
|
|
|
+ studentHtml = studentHtml.replaceAll("\\$\\{paperTypeName\\}", examStudent != null && examStudent.getPaperType() != null ? examStudent.getPaperType() : StringUtils.isNotBlank(paperType) ? paperType : "");
|
|
|
|
|
|
// 根据题卡规则必选字段,替换相应值,没有则“”
|
|
// 根据题卡规则必选字段,替换相应值,没有则“”
|
|
List<StudentExtendDto> studentExtendDtos = createExtendObject(examStudent, basicCardRule);
|
|
List<StudentExtendDto> studentExtendDtos = createExtendObject(examStudent, basicCardRule);
|
|
@@ -833,7 +881,7 @@ public class CreatePdfUtil {
|
|
|
|
|
|
//学生题卡
|
|
//学生题卡
|
|
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);
|
|
- if(examStudent != null) {
|
|
|
|
|
|
+ if (examStudent != null) {
|
|
examStudent.setAttachmentId(examStudentAttachment.getId());
|
|
examStudent.setAttachmentId(examStudentAttachment.getId());
|
|
}
|
|
}
|
|
return examStudentAttachment;
|
|
return examStudentAttachment;
|