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); }