|
@@ -178,14 +178,19 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
|
|
|
List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
|
|
|
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
- List<String> variablePdfList = new ArrayList<>();//变量印品(签到表、卷袋贴)
|
|
|
- List<String> ordinaryPdfList = new ArrayList<>();//普通印品(登记表)
|
|
|
- List<String> paperPdfList = new ArrayList<>();//所有试卷
|
|
|
- List<String> examStudentPdfList = new ArrayList<>();//所有题卡
|
|
|
- List<String> backUpPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
- List<String> cardPdfList = new ArrayList<>();//备份题卡
|
|
|
+ List<String> variablePdfList = new ArrayList<>();//变量印品(签到表、卷袋贴)
|
|
|
+ List<String> ordinaryPdfList = new ArrayList<>();//普通印品(登记表)
|
|
|
+ List<String> paperPdfList = new ArrayList<>();//所有试卷
|
|
|
+ List<String> examStudentPdfList = new ArrayList<>();//所有题卡
|
|
|
+ List<String> backupPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
+ List<String> cardPdfList = new ArrayList<>();//备份题卡
|
|
|
+
|
|
|
+ if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
|
|
|
+ //获取普通印品
|
|
|
+ JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
|
|
|
+ }
|
|
|
|
|
|
+ for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
//查询试卷
|
|
|
QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
|
|
|
examTaskQueryWrapper.lambda().eq(ExamTask::getSchoolId, sysUser.getSchoolId())
|
|
@@ -220,7 +225,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
String paperType = getPaperType(examPrintPlan, examTaskDetail);
|
|
|
|
|
|
//获取试卷pdf
|
|
|
- getPaperPdf(examTaskDetail, paperPdfList);
|
|
|
+ getPaperPdf(examTaskDetail, examPrintPlan.getBackupCount(), paperPdfList, backupPaperPdfList);
|
|
|
|
|
|
basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
|
for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
@@ -240,7 +245,25 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
.eq(ExamStudent::getExamDetailCourseId, examTaskDetail.getId());
|
|
|
List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
|
|
+ Integer signVariableBackupCount = null, packagVariableBackupCount = null;
|
|
|
for (ExamStudent t : examStudentList) {
|
|
|
+ if (Objects.nonNull(examPrintPlan.getVariableContent())) {
|
|
|
+ //获取变量印品
|
|
|
+ JSONArray jsonArrayVariable = JSONArray.parseArray(examPrintPlan.getVariableContent());
|
|
|
+ for (int i = 0; i < jsonArrayVariable.size(); i++) {
|
|
|
+ JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
|
|
|
+ String type = (String) jsonObjectVariable.get("type");
|
|
|
+ Long templeteId = (Long) jsonObjectVariable.get("templeteId");
|
|
|
+ BasicAttachment basicAttachment = basicAttachmentService.getById(templeteId);
|
|
|
+ if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
|
+ signVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
|
+// String filePath = basicAttachment.getPath();
|
|
|
+// ossUtil.ossDownload();
|
|
|
+ } else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAG")) {//卷袋贴
|
|
|
+ packagVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
basicAttachmentList.add(examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentPdfList));
|
|
|
}
|
|
|
examStudentService.saveOrUpdateBatch(examStudentList);
|
|
@@ -248,12 +271,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
|
}
|
|
|
examCardDetailService.saveOrUpdateBatch(examCardDetailList);
|
|
|
-
|
|
|
- //合并pdf
|
|
|
- basicAttachmentList.add(mergePdf(tbTask, examDetail, sysUser.getId(), paperPdfList, cardPdfList, examStudentPdfList));
|
|
|
}
|
|
|
examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
|
}
|
|
|
+ //合并pdf
|
|
|
+ basicAttachmentList.add(mergePdf(tbTask, examDetail, sysUser.getId(), variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
|
+
|
|
|
//最后一步删除附件
|
|
|
deleteAttachment(attachmentIds);
|
|
|
} catch (Exception e) {
|
|
@@ -305,10 +328,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
* 获取试卷pdf
|
|
|
*
|
|
|
* @param examTaskDetail
|
|
|
- * @param paperPdfList
|
|
|
+ * @param backupCount
|
|
|
+ * @param pdfList
|
|
|
+ * @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public void getPaperPdf(ExamTaskDetail examTaskDetail, List<String> paperPdfList) throws IOException {
|
|
|
+ public void getPaperPdf(ExamTaskDetail examTaskDetail, Integer backupCount, List<String>... pdfList) throws IOException {
|
|
|
JSONObject jsonObjectPaper = JSONObject.parseObject(examTaskDetail.getPaperAttachmentIds());
|
|
|
JSONArray jsonArrayPaper = jsonObjectPaper.getJSONArray("paper");
|
|
|
for (int i = 0; i < jsonArrayPaper.size(); i++) {
|
|
@@ -316,7 +341,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
if (Objects.nonNull(object.get("attachmentId"))) {
|
|
|
Long attachmentId = Long.parseLong(String.valueOf(object.get("attachmentId")));
|
|
|
BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
- paperPdfList.add(commonService.getFile(basicAttachment.getPath(), false));
|
|
|
+ String filePath = commonService.getFile(basicAttachment.getPath(), false);
|
|
|
+ pdfList[0].add(filePath);
|
|
|
+ for (int j = 1; j <= backupCount; j++) {
|
|
|
+ pdfList[1].add(filePath);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -371,9 +400,9 @@ 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<>();
|
|
|
- mergePdfList.addAll(list[0]);
|
|
|
- mergePdfList.addAll(list[1]);
|
|
|
- mergePdfList.addAll(list[2]);
|
|
|
+ for (int i = 0; i < list.length; i++) {
|
|
|
+ mergePdfList.addAll(list[i]);
|
|
|
+ }
|
|
|
String dirName = PdfUtil.mergePdf(mergePdfList.toArray(new String[mergePdfList.size()]), null);
|
|
|
File localPdfFile = new File(stringJoiner.toString() + File.separator + dirName);
|
|
|
BasicAttachment basicAttachment = basicAttachmentService.saveAttachmentPdf(dirName, userId);
|