From 09d9d173ed67fac27b7ba724d1026189180468ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E6=98=8E=E6=85=A7?= <1191093413@qq.com> Date: Mon, 11 Mar 2024 10:40:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=A5=A8=E6=96=87=E4=BB=B6=E5=AD=98?= =?UTF-8?q?=E5=82=A8=EF=BC=9A=E6=9C=AC=E5=9C=B0=E4=B8=8A=E4=BC=A0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=B0=83=E7=94=A8=E5=B7=B2=E6=9C=89=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 2 -- .../api/ElephantInvoiceApiV6ServiceImpl.java | 27 +++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/jianshui-admin/src/main/resources/application.yml b/jianshui-admin/src/main/resources/application.yml index 971af7c..4fdd526 100644 --- a/jianshui-admin/src/main/resources/application.yml +++ b/jianshui-admin/src/main/resources/application.yml @@ -122,7 +122,5 @@ srm: invoice: file: save: - #本地存储时配置路径使用 - path: /invoice/file/upload # 文件上传方式 0:数据库 1:oss 2:本地 type: 1 diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java index 6015d58..656d6cb 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java @@ -626,7 +626,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { saveFileUseOss(defaultStorage,invoice,ddfpxx); //配置文件存储类型2为本地存储 }else if (Constants.STRING_2.equals(type)){ - saveFileUseLocal(environment,invoice,ddfpxx,fileName); + saveFileUseLocal(invoice,ddfpxx); } } } @@ -724,26 +724,29 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { return response; } - private void saveFileUseLocal(Environment environment,Invoice invoice,DDFPXX ddfpxx,String fileName) { + private void saveFileUseLocal(Invoice invoice,DDFPXX ddfpxx) { try { + + IStorageService service = storageFactory.getStorageInstance(Constants.LOCAL); + byte[] pdfBytes = Base64.decode(ddfpxx.getPDFZJL()); + + AjaxResult upload = service.upload(pdfBytes, ""); + //文件名称 - fileName = fileName+ Constants.POINT + (StringUtils.equals(ddfpxx.getZJLLX(), Constants.PDF_UPCASE) ? Constants.PDF : Constants.OFD); +// fileName = fileName+ Constants.POINT + (StringUtils.equals(ddfpxx.getZJLLX(), Constants.PDF_UPCASE) ? Constants.PDF : Constants.OFD); //文件写入路径 - String targetFilePath = environment.getProperty(Constants.INVOICE_FILE_SAVE_PATH) + fileName; +// String targetFilePath = environment.getProperty(Constants.INVOICE_FILE_SAVE_PATH) + fileName; // 创建一个输出流对象,用于将数据写入到本地文件,如果文件存在则会覆盖 - FileOutputStream fileOutputStream = new FileOutputStream(targetFilePath, false); +// FileOutputStream fileOutputStream = new FileOutputStream(targetFilePath, false); // 直接将字节数组写入到输出流(即本地文件) - fileOutputStream.write(pdfBytes); +// fileOutputStream.write(pdfBytes); // 完成写入后关闭流 - fileOutputStream.close(); +// fileOutputStream.close(); //拼接url - IStorageService service = storageFactory.getStorageInstance(Constants.LOCAL); - - AjaxResult upload = service.upload(targetFilePath, ""); StorageUrlDTO uploadResultDTO = (StorageUrlDTO) upload.get(Constants.DATA); @@ -760,10 +763,6 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { if (StringUtils.equals(ddfpxx.getZJLLX(), Constants.OFD_UPCASE)) { invoice.setcOfdUrl(pdfUrl); } - }catch (UnsupportedEncodingException e){ - log.error("编码转换异常",e); - }catch (IOException e){ - log.error("文件写入异常",e); }catch (Exception e){ log.error("文件保存异常",e); }