|
@@ -209,19 +209,29 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
|
|
* 保存附件
|
|
* 保存附件
|
|
*
|
|
*
|
|
* @param basicAttachment
|
|
* @param basicAttachment
|
|
- * @param variablePdfList
|
|
|
|
|
|
+ * @param pdfList
|
|
* @param printCount
|
|
* @param printCount
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public BasicAttachment saveAttachmentPdf(BasicAttachment basicAttachment, List<String> variablePdfList, Integer printCount) throws IOException {
|
|
|
|
|
|
+ public BasicAttachment saveAttachmentPdf(BasicAttachment basicAttachment, List<String> pdfList, Integer printCount) throws IOException {
|
|
boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
|
|
JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
|
|
- String filePath = (String) jsonObject.get(SystemConstant.HTML_PATH);
|
|
|
|
- String url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
|
|
|
|
- File htmlFile = new File(url);
|
|
|
|
|
|
+ String type = basicAttachment.getType();
|
|
|
|
+ String filePath = null;
|
|
|
|
+ String url = null;
|
|
|
|
+ File htmlFile = null;
|
|
|
|
+ if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.FTL_PREFIX)) {
|
|
|
|
+ filePath = (String) jsonObject.get(SystemConstant.HTML_PATH);
|
|
|
|
+ url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
|
|
|
|
+ htmlFile = new File(url);
|
|
|
|
+ } else if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.HTML_PREFIX)) {
|
|
|
|
+ filePath = (String) jsonObject.get(SystemConstant.PATH);
|
|
|
|
+ url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
|
|
|
|
+ htmlFile = ossUtil.ossDownload(filePath, url);
|
|
|
|
+ }
|
|
String pdfDirName = filePath.replaceAll(SystemConstant.HTML_PREFIX, SystemConstant.PDF_PREFIX).replaceAll(UploadFileEnum.HTML.name().toLowerCase(), UploadFileEnum.PDF.name().toLowerCase());
|
|
String pdfDirName = filePath.replaceAll(SystemConstant.HTML_PREFIX, SystemConstant.PDF_PREFIX).replaceAll(UploadFileEnum.HTML.name().toLowerCase(), UploadFileEnum.PDF.name().toLowerCase());
|
|
String destUrl = SystemConstant.PDF_TEMP_FILES_DIR + File.separator + pdfDirName;
|
|
String destUrl = SystemConstant.PDF_TEMP_FILES_DIR + File.separator + pdfDirName;
|
|
HtmlToPdfUtil.convert(htmlFile.getPath(), destUrl, PageSizeEnum.A4);
|
|
HtmlToPdfUtil.convert(htmlFile.getPath(), destUrl, PageSizeEnum.A4);
|
|
@@ -234,15 +244,23 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
|
|
if (oss) {//上传至oss
|
|
if (oss) {//上传至oss
|
|
ossUtil.ossUpload(pdfDirName, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(fileMd5)));
|
|
ossUtil.ossUpload(pdfDirName, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(fileMd5)));
|
|
jsonObject.put(SystemConstant.PDF_PATH, pdfDirName);
|
|
jsonObject.put(SystemConstant.PDF_PATH, pdfDirName);
|
|
- jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
|
|
|
|
- UploadFileEnum.FILE,
|
|
|
|
- UploadFileEnum.HTML,
|
|
|
|
- UploadFileEnum.PDF
|
|
|
|
- });
|
|
|
|
|
|
+ if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.FTL_PREFIX)) {
|
|
|
|
+ jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
|
|
|
|
+ UploadFileEnum.FILE,
|
|
|
|
+ UploadFileEnum.HTML,
|
|
|
|
+ UploadFileEnum.PDF
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
|
|
|
|
+ UploadFileEnum.FILE,
|
|
|
|
+ UploadFileEnum.PDF
|
|
|
|
+ });
|
|
|
|
+ htmlFile.delete();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
basicAttachment.setPath(jsonObject.toJSONString());
|
|
basicAttachment.setPath(jsonObject.toJSONString());
|
|
for (int i = 0; i < printCount; i++) {
|
|
for (int i = 0; i < printCount; i++) {
|
|
- variablePdfList.add(pdfFile.getPath());
|
|
|
|
|
|
+ pdfList.add(pdfFile.getPath());
|
|
}
|
|
}
|
|
this.updateById(basicAttachment);
|
|
this.updateById(basicAttachment);
|
|
return basicAttachment;
|
|
return basicAttachment;
|