|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.itextpdf.text.DocumentException;
|
|
import com.itextpdf.text.DocumentException;
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
|
+import com.qmth.distributed.print.business.bean.createPdf.PrintPathVo;
|
|
import com.qmth.distributed.print.business.bean.dto.PdfDto;
|
|
import com.qmth.distributed.print.business.bean.dto.PdfDto;
|
|
import com.qmth.distributed.print.business.bean.dto.PdfPackageDto;
|
|
import com.qmth.distributed.print.business.bean.dto.PdfPackageDto;
|
|
import com.qmth.distributed.print.business.bean.dto.PdfSignDto;
|
|
import com.qmth.distributed.print.business.bean.dto.PdfSignDto;
|
|
@@ -37,6 +38,7 @@ import com.qmth.teachcloud.common.mapper.BasicCourseMapper;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.util.*;
|
|
import com.qmth.teachcloud.common.util.*;
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.io.FilenameUtils;
|
|
import org.apache.commons.io.FilenameUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -44,7 +46,6 @@ import org.slf4j.LoggerFactory;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.FileCopyUtils;
|
|
import org.springframework.util.FileCopyUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
@@ -210,7 +211,6 @@ public class PrintCommonServiceImpl implements PrintCommonService {
|
|
fileTempList.add(pdfFileTemp);
|
|
fileTempList.add(pdfFileTemp);
|
|
HtmlToPdfUtil.convert(htmlFile.getPath(), pdfFileTemp.getPath(), PageSizeEnum.A4);
|
|
HtmlToPdfUtil.convert(htmlFile.getPath(), pdfFileTemp.getPath(), PageSizeEnum.A4);
|
|
|
|
|
|
-// File pdfFile = asposePdfUtil.documentToPdf(htmlFile.getPath(), destUrl, PaperSize.A4);
|
|
|
|
String htmlFileMd5 = DigestUtils.md5Hex(new FileInputStream(htmlFile));
|
|
String htmlFileMd5 = DigestUtils.md5Hex(new FileInputStream(htmlFile));
|
|
String pdfFileMd5 = DigestUtils.md5Hex(new FileInputStream(pdfFileTemp));
|
|
String pdfFileMd5 = DigestUtils.md5Hex(new FileInputStream(pdfFileTemp));
|
|
if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
@@ -220,21 +220,8 @@ public class PrintCommonServiceImpl implements PrintCommonService {
|
|
}
|
|
}
|
|
|
|
|
|
PdfDto pdfDto = PdfUtil.addPdfPage(pdfFileTemp);
|
|
PdfDto pdfDto = PdfUtil.addPdfPage(pdfFileTemp);
|
|
- JSONObject attachmentPath = JSONObject.parseObject(examDetail.getAttachmentPath());
|
|
|
|
- attachmentPath = Objects.isNull(attachmentPath) ? new JSONObject() : attachmentPath;
|
|
|
|
- JSONArray jsonArray = (JSONArray) attachmentPath.get(SystemConstant.PATH);
|
|
|
|
- jsonArray = Objects.isNull(jsonArray) ? new JSONArray() : jsonArray;
|
|
|
|
- JSONObject object = new JSONObject();
|
|
|
|
- object.put("printType", classifyEnum.name());
|
|
|
|
- object.put(SystemConstant.HTML_PATH, filePath);
|
|
|
|
- object.put("htmlMd5", htmlFileMd5);
|
|
|
|
- object.put("pdfMd5", pdfFileMd5);
|
|
|
|
- object.put(SystemConstant.PDF_PATH, pdfDirName);
|
|
|
|
- object.put(SystemConstant.TYPE, ossStr);
|
|
|
|
- object.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.PDF);
|
|
|
|
- jsonArray.add(object);
|
|
|
|
- attachmentPath.put(SystemConstant.PATH, jsonArray);
|
|
|
|
- examDetail.setAttachmentPath(attachmentPath.toJSONString());
|
|
|
|
|
|
+ PrintPathVo printPathVo = new PrintPathVo(classifyEnum, UploadFileEnum.PDF, ossStr, pdfDirName, pdfFileMd5, filePath, htmlFileMd5);
|
|
|
|
+ examDetail.setAttachmentPath(parseAttachmentPath(examDetail.getAttachmentPath(), printPathVo));
|
|
basicAttachment.setPages(pdfDto.getActualPageCount());
|
|
basicAttachment.setPages(pdfDto.getActualPageCount());
|
|
for (int i = 0; i < printCount; i++) {
|
|
for (int i = 0; i < printCount; i++) {
|
|
pdfList.add(new PdfDto(pdfFileTemp.getPath(), PageSizeEnum.A4, pdfDto.getPageCount(), sequence));
|
|
pdfList.add(new PdfDto(pdfFileTemp.getPath(), PageSizeEnum.A4, pdfDto.getPageCount(), sequence));
|
|
@@ -292,20 +279,8 @@ public class PrintCommonServiceImpl implements PrintCommonService {
|
|
fileStoreUtil.localUpload(pdfDirName, new FileInputStream(pdfFileTemp), pdfFileMd5, LocalCatalogEnum.LOCAL_PDF);
|
|
fileStoreUtil.localUpload(pdfDirName, new FileInputStream(pdfFileTemp), pdfFileMd5, LocalCatalogEnum.LOCAL_PDF);
|
|
}
|
|
}
|
|
PdfDto pdfDto = PdfUtil.addPdfPage(pdfFileTemp);
|
|
PdfDto pdfDto = PdfUtil.addPdfPage(pdfFileTemp);
|
|
-
|
|
|
|
- JSONObject attachmentPath = JSONObject.parseObject(examDetail.getAttachmentPath());
|
|
|
|
- attachmentPath = Objects.isNull(attachmentPath) ? new JSONObject() : attachmentPath;
|
|
|
|
- JSONArray jsonArray = (JSONArray) attachmentPath.get(SystemConstant.PATH);
|
|
|
|
- jsonArray = Objects.isNull(jsonArray) ? new JSONArray() : jsonArray;
|
|
|
|
- JSONObject object = new JSONObject();
|
|
|
|
- object.put("printType", ClassifyEnum.SIGN.name());
|
|
|
|
- object.put("pdfMd5", pdfFileMd5);
|
|
|
|
- object.put(SystemConstant.PDF_PATH, pdfDirName);
|
|
|
|
- object.put(SystemConstant.TYPE, ossStr);
|
|
|
|
- object.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.PDF);
|
|
|
|
- jsonArray.add(object);
|
|
|
|
- attachmentPath.put(SystemConstant.PATH, jsonArray);
|
|
|
|
- examDetail.setAttachmentPath(attachmentPath.toJSONString());
|
|
|
|
|
|
+ PrintPathVo printPathVo = new PrintPathVo(ClassifyEnum.SIGN, UploadFileEnum.PDF, ossStr, pdfDirName, pdfFileMd5, null, null);
|
|
|
|
+ examDetail.setAttachmentPath(parseAttachmentPath(examDetail.getAttachmentPath(), printPathVo));
|
|
for (int i = 0; i < printCount; i++) {
|
|
for (int i = 0; i < printCount; i++) {
|
|
pdfList.add(new PdfDto(pdfFileTemp.getPath(), PageSizeEnum.A4, pdfDto.getPageCount(), 2));
|
|
pdfList.add(new PdfDto(pdfFileTemp.getPath(), PageSizeEnum.A4, pdfDto.getPageCount(), 2));
|
|
}
|
|
}
|
|
@@ -319,6 +294,32 @@ public class PrintCommonServiceImpl implements PrintCommonService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String parseAttachmentPath(String attachmentPath, PrintPathVo printPathVo) {
|
|
|
|
+ List<PrintPathVo> printPathVos = new ArrayList<>();
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ if (StringUtils.isNotBlank(attachmentPath)) {
|
|
|
|
+ jsonObject = JSONObject.parseObject(attachmentPath);
|
|
|
|
+ String objectString = jsonObject.getString(SystemConstant.PATH);
|
|
|
|
+ if (StringUtils.isNotBlank(objectString)) {
|
|
|
|
+ printPathVos = JSON.parseArray(objectString, PrintPathVo.class);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<PrintPathVo> finalList = new ArrayList<>();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(printPathVos)) {
|
|
|
|
+ for (PrintPathVo pathVo : printPathVos) {
|
|
|
|
+ if (!pathVo.getPrintType().equals(printPathVo.getPrintType())) {
|
|
|
|
+ finalList.add(pathVo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ finalList.add(printPathVo);
|
|
|
|
+ finalList.sort(Comparator.comparing(PrintPathVo::getIndex));
|
|
|
|
+
|
|
|
|
+ jsonObject.put(SystemConstant.PATH, finalList);
|
|
|
|
+ return jsonObject.toJSONString();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 保存html附件
|
|
* 保存html附件
|
|
*
|
|
*
|
|
@@ -1248,20 +1249,9 @@ public class PrintCommonServiceImpl implements PrintCommonService {
|
|
}
|
|
}
|
|
|
|
|
|
PdfDto pdfDto = PdfUtil.addPdfPage(pdfFileTemp);
|
|
PdfDto pdfDto = PdfUtil.addPdfPage(pdfFileTemp);
|
|
|
|
+ PrintPathVo printPathVo = new PrintPathVo(ClassifyEnum.PACKAGE, UploadFileEnum.PDF, ossStr, pdfDirName, pdfFileMd5, null, null);
|
|
|
|
+ examDetail.setAttachmentPath(parseAttachmentPath(examDetail.getAttachmentPath(), printPathVo));
|
|
|
|
|
|
- JSONObject attachmentPath = JSON.parseObject(examDetail.getAttachmentPath());
|
|
|
|
- attachmentPath = Objects.isNull(attachmentPath) ? new JSONObject() : attachmentPath;
|
|
|
|
- JSONArray jsonArray = (JSONArray) attachmentPath.get(SystemConstant.PATH);
|
|
|
|
- jsonArray = Objects.isNull(jsonArray) ? new JSONArray() : jsonArray;
|
|
|
|
- JSONObject object = new JSONObject();
|
|
|
|
- object.put("printType", ClassifyEnum.PACKAGE.name());
|
|
|
|
- object.put("pdfMd5", pdfFileMd5);
|
|
|
|
- object.put(SystemConstant.PDF_PATH, pdfDirName);
|
|
|
|
- object.put(SystemConstant.TYPE, ossStr);
|
|
|
|
- object.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.PDF);
|
|
|
|
- jsonArray.add(object);
|
|
|
|
- attachmentPath.put(SystemConstant.PATH, jsonArray);
|
|
|
|
- examDetail.setAttachmentPath(attachmentPath.toJSONString());
|
|
|
|
for (int i = 0; i < printCount; i++) {
|
|
for (int i = 0; i < printCount; i++) {
|
|
pdfList.add(new PdfDto(pdfFileTemp.getPath(), PageSizeEnum.A4, pdfDto.getPageCount(), 2));
|
|
pdfList.add(new PdfDto(pdfFileTemp.getPath(), PageSizeEnum.A4, pdfDto.getPageCount(), 2));
|
|
}
|
|
}
|