|
@@ -16,9 +16,14 @@ import com.qmth.distributed.print.business.service.ExamStudentService;
|
|
|
import com.qmth.distributed.print.business.service.PrintCommonService;
|
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.entity.*;
|
|
|
+import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
|
+import com.qmth.teachcloud.common.entity.BasicClazz;
|
|
|
+import com.qmth.teachcloud.common.entity.TBTask;
|
|
|
import com.qmth.teachcloud.common.enums.*;
|
|
|
-import com.qmth.teachcloud.common.service.*;
|
|
|
+import com.qmth.teachcloud.common.service.BasicAttachmentService;
|
|
|
+import com.qmth.teachcloud.common.service.BasicCampusService;
|
|
|
+import com.qmth.teachcloud.common.service.BasicClazzService;
|
|
|
+import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
|
import com.qmth.teachcloud.common.util.ConvertUtil;
|
|
|
import com.qmth.teachcloud.common.util.FileStoreUtil;
|
|
|
import com.qmth.teachcloud.common.util.RedisUtil;
|
|
@@ -77,17 +82,17 @@ public class CreatePdfUtil {
|
|
|
@Resource
|
|
|
BasicCampusService basicCampusService;
|
|
|
|
|
|
- @Resource
|
|
|
- SysOrgService sysOrgService;
|
|
|
+// @Resource
|
|
|
+// SysOrgService sysOrgService;
|
|
|
|
|
|
- @Resource
|
|
|
- BasicCourseService basicCourseService;
|
|
|
+// @Resource
|
|
|
+// BasicCourseService basicCourseService;
|
|
|
|
|
|
@Resource
|
|
|
BasicClazzService basicClazzService;
|
|
|
|
|
|
- @Resource
|
|
|
- BasicSchoolService basicSchoolService;
|
|
|
+// @Resource
|
|
|
+// BasicSchoolService basicSchoolService;
|
|
|
|
|
|
@Resource
|
|
|
ExamDetailService examDetailService;
|
|
@@ -107,7 +112,7 @@ public class CreatePdfUtil {
|
|
|
* @param printCount
|
|
|
*/
|
|
|
public void createCheckIn(ExamDetail examDetail, BasicAttachment basicAttachment, List<PdfDto> ordinaryPdfList, Integer printCount) throws Exception {
|
|
|
- BasicSchool basicSchool = basicSchoolService.getById(examDetail.getSchoolId());
|
|
|
+// BasicSchool basicSchool = basicSchoolService.getById(examDetail.getSchoolId());
|
|
|
// Map<String, List<String>> flowSchoolCodeMap = SystemConstant.getFlowSchoolCodeMap();
|
|
|
if (Objects.isNull(basicAttachment)) {
|
|
|
throw ExceptionResultEnum.ATTACHMENT_IS_NULL.exception();
|
|
@@ -129,7 +134,7 @@ public class CreatePdfUtil {
|
|
|
// } else if (flowSchoolCodeMap.get(SystemConstant.JXZYY_FLOW_KEY).contains(basicSchool.getCode())) {
|
|
|
// ordinaryPdfList.add(new PdfDto(localFile.getPath(), PageSizeEnum.A4, pdfDto.getPageCount()));
|
|
|
// } else {
|
|
|
- ordinaryPdfList.add(new PdfDto(localFile.getPath(), PageSizeEnum.A4, pdfDto.getPageCount()));
|
|
|
+ ordinaryPdfList.add(new PdfDto(localFile.getPath(), PageSizeEnum.A4, pdfDto.getPageCount()));
|
|
|
// }
|
|
|
}
|
|
|
} else {
|
|
@@ -555,11 +560,11 @@ public class CreatePdfUtil {
|
|
|
int pages = dto.getPages();
|
|
|
pagesList.add(pages);
|
|
|
PdfDto pdfDto = PdfUtil.addPdfPage(dto.getFile());
|
|
|
- pdfList.add(new PdfDto(dto.getFile().getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
|
|
|
+ pdfList.add(new PdfDto(dto.getFile().getPath(), dto.getPageSize(), pdfDto.getPageCount()));
|
|
|
}
|
|
|
}
|
|
|
int pageCount = pagesList.stream().mapToInt(Integer::intValue).sum();
|
|
|
- return new PdfDto(PageSizeEnum.A3, pageCount);
|
|
|
+ return new PdfDto(paperPdfDto.get(0).getPageSize(), pageCount);
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
@@ -582,11 +587,11 @@ public class CreatePdfUtil {
|
|
|
tag = pages > 2;
|
|
|
PdfDto pdfDto = PdfUtil.addPdfPage(dto.getFile());
|
|
|
for (int j = 1; j <= backupCount; j++) {
|
|
|
- pdfList.add(new PdfDto(dto.getFile().getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
|
|
|
+ pdfList.add(new PdfDto(dto.getFile().getPath(), dto.getPageSize(), pdfDto.getPageCount()));
|
|
|
}
|
|
|
}
|
|
|
int pageCount = pagesList.stream().mapToInt(Integer::intValue).sum();
|
|
|
- return new PdfDto(PageSizeEnum.A3, pageCount, tag);
|
|
|
+ return new PdfDto(paperPdfDto.get(0).getPageSize(), pageCount, tag);
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
@@ -612,12 +617,17 @@ public class CreatePdfUtil {
|
|
|
throw ExceptionResultEnum.ATTACHMENT_IS_NULL.exception();
|
|
|
}
|
|
|
String name = (String) object.get("name");
|
|
|
+ JSONObject jsonObject = (JSONObject) object.get("original");
|
|
|
// 返回抽中的试卷
|
|
|
for (String type : paperTypes) {
|
|
|
if (Objects.equals(name.toUpperCase(), type.toUpperCase())) {
|
|
|
File file = teachcloudCommonService.getFile(basicAttachment.getPath(), false);
|
|
|
int pages = (int) object.get("pages");
|
|
|
- paperPdfDto = new PaperPdfDto(type, file, pages);
|
|
|
+
|
|
|
+ PageSizeEnum pageSizeEnum = PageSizeEnum.valueOf((String) jsonObject.get("pageSize"));
|
|
|
+ Optional.ofNullable(pageSizeEnum).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未设置pdf格式"));
|
|
|
+
|
|
|
+ paperPdfDto = new PaperPdfDto(type, file, pages, pageSizeEnum);
|
|
|
paperPdfDtoList.add(paperPdfDto);
|
|
|
break;
|
|
|
}
|
|
@@ -766,7 +776,7 @@ public class CreatePdfUtil {
|
|
|
* 合并pdf后保存数据库
|
|
|
*
|
|
|
* @param dirNameA4
|
|
|
- * @param dirNameA3
|
|
|
+ * @param dirNamePaper
|
|
|
* @param dirNameCardA3
|
|
|
* @param tbTask
|
|
|
* @param userId
|
|
@@ -778,7 +788,7 @@ public class CreatePdfUtil {
|
|
|
*/
|
|
|
@Transactional
|
|
|
public BasicAttachment mergePdfSaveDb(String dirNameA4,
|
|
|
- String dirNameA3,
|
|
|
+ String dirNamePaper,
|
|
|
String dirNameCardA3,
|
|
|
TBTask tbTask,
|
|
|
Long userId,
|
|
@@ -788,17 +798,17 @@ public class CreatePdfUtil {
|
|
|
boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
StringJoiner stringJoiner = new StringJoiner("").add(dictionaryConfig.fssLocalPdfDomain().getConfig()).add(File.separator);
|
|
|
// oss上只认"/",windows生成的路径分隔符全部替换为"/"
|
|
|
- File localA4PdfFile = null, localA3PdfFile = null, localA3PdfCardFile = null;
|
|
|
+ File localA4PdfFile = null, localPaperPdfFile = null, localA3PdfCardFile = null;
|
|
|
BasicAttachment basicAttachment = null;
|
|
|
if (Objects.nonNull(dirNameA4)) {
|
|
|
dirNameA4 = dirNameA4.replaceAll("\\\\", "/");
|
|
|
localA4PdfFile = new File(stringJoiner.toString() + File.separator + dirNameA4);
|
|
|
}
|
|
|
// 试卷+题卡
|
|
|
- if (Objects.nonNull(dirNameA3)) {
|
|
|
- dirNameA3 = dirNameA3.replaceAll("\\\\", "/");
|
|
|
- localA3PdfFile = new File(stringJoiner.toString() + File.separator + dirNameA3);
|
|
|
- basicAttachment = basicAttachmentService.saveAttachmentPdf(dirNameA3, userId);
|
|
|
+ if (Objects.nonNull(dirNamePaper)) {
|
|
|
+ dirNamePaper = dirNamePaper.replaceAll("\\\\", "/");
|
|
|
+ localPaperPdfFile = new File(stringJoiner.toString() + File.separator + dirNamePaper);
|
|
|
+ basicAttachment = basicAttachmentService.saveAttachmentPdf(dirNamePaper, userId);
|
|
|
tbTask.setImportFileName(basicAttachment.getName());
|
|
|
tbTask.setImportFilePath(basicAttachment.getPath());
|
|
|
examDetail.setAttachmentId(basicAttachment.getId());
|
|
@@ -816,7 +826,7 @@ public class CreatePdfUtil {
|
|
|
}
|
|
|
examDetail.setCardAttachmentId(basicAttachment.getId());
|
|
|
}
|
|
|
- examDetail.setPagesA3(PdfUtil.getPdfPages(localA3PdfFile));
|
|
|
+ examDetail.setPagesA3(PdfUtil.getPdfPages(localPaperPdfFile));
|
|
|
examDetail.setPagesA4(PdfUtil.getPdfPages(localA4PdfFile));
|
|
|
if (PrintMethodEnum.AUTO == basicExamRule.getPrintMethod()) {
|
|
|
examDetail.setStatus(ExamDetailStatusEnum.WAITING);
|
|
@@ -824,10 +834,10 @@ public class CreatePdfUtil {
|
|
|
examDetail.setStatus(ExamDetailStatusEnum.READY);
|
|
|
}
|
|
|
detailService.saveOrUpdate(examDetail);
|
|
|
- if (Objects.nonNull(localA3PdfFile) && oss) {
|
|
|
+ if (Objects.nonNull(localPaperPdfFile) && oss) {
|
|
|
// ossUtil.ossUpload(dirNameA3, localA3PdfFile, DigestUtils.md5Hex(new FileInputStream(localA3PdfFile)));
|
|
|
- fileStoreUtil.ossUpload(dirNameA3, localA3PdfFile, DigestUtils.md5Hex(new FileInputStream(localA3PdfFile)), fileStoreUtil.getUploadEnumByPath(dirNameA3).getFssType());
|
|
|
- localA3PdfFile.delete();
|
|
|
+ fileStoreUtil.ossUpload(dirNamePaper, localPaperPdfFile, DigestUtils.md5Hex(new FileInputStream(localPaperPdfFile)), fileStoreUtil.getUploadEnumByPath(dirNamePaper).getFssType());
|
|
|
+ localPaperPdfFile.delete();
|
|
|
}
|
|
|
if (Objects.nonNull(localA3PdfCardFile) && oss) {
|
|
|
fileStoreUtil.ossUpload(dirNameCardA3, localA3PdfCardFile, DigestUtils.md5Hex(new FileInputStream(localA3PdfCardFile)), fileStoreUtil.getUploadEnumByPath(dirNameCardA3).getFssType());
|