|
@@ -20,14 +20,12 @@ import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
|
import com.qmth.distributed.print.business.util.*;
|
|
|
import com.qmth.distributed.print.business.util.excel.ExcelError;
|
|
|
-import com.qmth.distributed.print.common.contant.SpringContextHolder;
|
|
|
import com.qmth.distributed.print.common.contant.SystemConstant;
|
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.distributed.print.common.util.Base64Util;
|
|
|
import com.qmth.distributed.print.common.util.HexUtils;
|
|
|
import com.qmth.distributed.print.common.util.ResultUtil;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
@@ -222,6 +220,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
|
|
|
for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
+ List<String> paperPdfTempList = new ArrayList<>();//所有试卷
|
|
|
+ List<String> examStudentTempPdfList = new ArrayList<>();//所有题卡
|
|
|
+ List<String> backupPaperTempPdfList = new ArrayList<>();//备份试卷
|
|
|
+ List<String> cardPdfTempList = new ArrayList<>();//备份题卡
|
|
|
+
|
|
|
//查询试卷
|
|
|
QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
|
|
|
examTaskQueryWrapper.lambda().eq(ExamTask::getSchoolId, sysUser.getSchoolId())
|
|
@@ -256,7 +259,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
String paperType = getPaperType(examPrintPlan, examTaskDetail);
|
|
|
|
|
|
//获取试卷pdf
|
|
|
- getPaperPdf(examTaskDetail, examPrintPlan.getBackupCount(), paperPdfList, backupPaperPdfList);
|
|
|
+ getPaperPdf(examTaskDetail, examPrintPlan.getBackupCount(), paperPdfTempList, backupPaperTempPdfList);
|
|
|
+ paperPdfList.addAll(paperPdfTempList);
|
|
|
+ backupPaperPdfList.addAll(backupPaperTempPdfList);
|
|
|
|
|
|
basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
|
for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
@@ -267,8 +272,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
String studentContent = cardContent;
|
|
|
|
|
|
for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
|
|
|
- basicAttachmentList.add(cardHtml(cardContent, paperType, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfList));
|
|
|
+ basicAttachmentList.add(cardHtml(cardContent, paperType, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList));
|
|
|
}
|
|
|
+ cardPdfList.addAll(cardPdfTempList);
|
|
|
|
|
|
//查询考生
|
|
|
QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
@@ -294,8 +300,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
|
|
|
for (ExamStudent t : examStudentList) {
|
|
|
- basicAttachmentList.add(examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentPdfList));
|
|
|
+ basicAttachmentList.add(examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentTempPdfList));
|
|
|
}
|
|
|
+ examStudentPdfList.addAll(examStudentTempPdfList);
|
|
|
examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
jsonObject.put("card", jsonArray);
|
|
|
examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
@@ -303,7 +310,15 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
examCardDetailService.saveOrUpdateBatch(examCardDetailList);
|
|
|
}
|
|
|
examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
|
+
|
|
|
+ Integer paperPageA3 = 0;
|
|
|
+ Integer cardPageA3 = 0;
|
|
|
+ paperPageA3 = paperPageA3 + paperPdfTempList.size() + backupPaperTempPdfList.size();
|
|
|
+ cardPageA3 = cardPageA3 + examStudentTempPdfList.size() + cardPdfTempList.size();
|
|
|
+ examDetailCourse.setPaperPagesA3(paperPageA3);
|
|
|
+ examDetailCourse.setCardPagesA3(cardPageA3);
|
|
|
}
|
|
|
+ detailCourseService.saveOrUpdateBatch(examDetailCourseList);
|
|
|
//合并pdf
|
|
|
basicAttachmentList.add(mergePdf(tbTask, examDetail, sysUser.getId(), variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
|
}
|
|
@@ -363,7 +378,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
ExcelUtil.excelMake(ExaminationResult.class, examinationResultList, outputStream);
|
|
|
InputStream in = new ByteArrayInputStream(outputStream.toByteArray());
|
|
|
- IoUtil.copy(in,outputStream);
|
|
|
+ IoUtil.copy(in, outputStream);
|
|
|
|
|
|
// UploadFileEnum.FILE/
|
|
|
LocalDateTime nowTime = LocalDateTime.now();
|
|
@@ -377,7 +392,7 @@ 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("\\\\", "/");
|
|
|
// File file = new File(dirName);
|
|
|
// ConvertUtil.inputStream2File(in,file);
|
|
|
ossUtil.ossUpload(dirName, in, DigestUtils.md5Hex(in));
|
|
@@ -790,7 +805,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
public BasicAttachment mergePdf(TBTask tbTask, ExamDetail examDetail, Long userId, List<String>... list) throws IOException {
|
|
|
StringJoiner stringJoiner = new StringJoiner("").add(SystemConstant.PDF_TEMP_FILES_DIR).add(File.separator);
|
|
|
List<String> mergePdfList = new ArrayList<>();
|
|
|
+ int pageA3Count = 0;
|
|
|
+ int pageA4Count = 0;
|
|
|
for (int i = 0; i < list.length; i++) {
|
|
|
+ if (i < 2) {
|
|
|
+ pageA4Count = pageA4Count + list[i].size();
|
|
|
+ } else {
|
|
|
+ pageA3Count = pageA3Count + list[i].size();
|
|
|
+ }
|
|
|
mergePdfList.addAll(list[i]);
|
|
|
}
|
|
|
String dirName = PdfUtil.mergePdf(mergePdfList.toArray(new String[mergePdfList.size()]), null);
|
|
@@ -799,6 +821,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
tbTask.setImportFileName(basicAttachment.getName());
|
|
|
tbTask.setImportFilePath(basicAttachment.getPath());
|
|
|
examDetail.setAttachmentId(basicAttachment.getId());
|
|
|
+ examDetail.setPagesA3(pageA3Count);
|
|
|
+ examDetail.setPagesA4(pageA4Count);
|
|
|
detailService.saveOrUpdate(examDetail);
|
|
|
ossUtil.ossUpload(dirName, localPdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(localPdfFile)))));
|
|
|
localPdfFile.delete();
|