ソースを参照

文件存储方式修改

sakuya 3 年 前
コミット
5e3efa5835

+ 6 - 19
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/NotaryOrderServiceImpl.java

@@ -443,27 +443,14 @@ public class NotaryOrderServiceImpl extends ServiceImpl<NotaryOrderMapper, Notar
 		// 生成并保存未签名公证书
 		ModelEntity modelEntity = modelRepository.getModelEntity(notaryOrderEntity.getNotaryOfficeId(), code, "1");
 		String result = "";
-		String htmlFilePath = "";
-		String pdfFilePath = "";
+		String htmlPath = "";
+		String pdfPath = "";
 		try {
 			InputStream inputStream = NotaryNoteServiceImpl.class.getClassLoader().getResourceAsStream("template/note/notary-model.html");
 			result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
 			String content = result.replace("${ModelContent}", TextTempletUtil.replaceContent(modelEntity.getContent(), map));
-			String htmlFileDir = AppConfigInfo.APP_UPLOAD_PATH + "notary-html-" + notaryOrderEntity.getBusinessNo() + "/";
-			Path path = Paths.get(htmlFileDir);
-			if (!Files.exists(path)) {
-				Files.createDirectory(path);
-			}
-			htmlFilePath = htmlFileDir + req.getPartyId() + ".html";
-			Files.write(Paths.get(htmlFilePath), content.getBytes(StandardCharsets.UTF_8));
-			//
-			String pdfFileDir = AppConfigInfo.APP_UPLOAD_PATH + "notary-pdf-" + notaryOrderEntity.getBusinessNo() + "/";
-			path = Paths.get(pdfFileDir);
-			if (!Files.exists(path)) {
-				Files.createDirectory(path);
-			}
-			pdfFilePath = pdfFileDir + req.getPartyId() + ".pdf";
-			HtmlConvertPdf.createPdfFile(content, pdfFilePath);
+			htmlPath = FileUploadUtil.saveHtml(content, notaryOrderEntity.getBusinessNo(), req.getPartyId());
+			pdfPath = FileUploadUtil.savePdf(content, notaryOrderEntity.getBusinessNo(), req.getPartyId());
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -473,8 +460,8 @@ public class NotaryOrderServiceImpl extends ServiceImpl<NotaryOrderMapper, Notar
 		notaryOrderFile.setContractId(req.getPartyId());
 		notaryOrderFile.setCode(code);
 		notaryOrderFile.setDocNo(String.valueOf(currentNum));
-		notaryOrderFile.setHtmlUrl(htmlFilePath);
-		notaryOrderFile.setPdfUrl(pdfFilePath);
+		notaryOrderFile.setHtmlUrl(htmlPath);
+		notaryOrderFile.setPdfUrl(htmlPath);
 		notaryOrderFile.setSortNum(modelEntity.getSort());
 		notaryOrderFile.setCreateTime(new Date());
 		notaryOrderFile.setCreatorId(SecurityUtils.getCurrentUserId());