diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java index 0f547efb..25518037 100644 --- a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java @@ -164,7 +164,12 @@ public class InvoicesController { }else { invoicesDO.setDuplicateMark(Byte.valueOf(AccountingStatusEnum.UN_DUPLICATE_INVOICE.getValue())); } - String url = getUrl(multipartFile); + String url=""; + if (fileExtension.equalsIgnoreCase("ofd")) { + url = getUrl(multipartFile, UUID.randomUUID()+".ofd", "ofd"); + }else { + url = getUrl(multipartFile, "other", "other"); + } invoicesDO.setFileUrl(url); invoicesService.createInvoices(invoicesDO); return success(invoicesDO); @@ -190,8 +195,12 @@ public class InvoicesController { * @param file * @return */ - private String getUrl(MultipartFile file) throws Exception{ + private String getUrl(MultipartFile file,String name, String path) throws Exception{ String url=""; + if (path.equals("ofd")){ + url = fileService.createFile(name, path, IoUtil.readBytes(file.getInputStream())); + return url; + } url = fileService.createFile(null, null, IoUtil.readBytes(file.getInputStream())); return url; } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java index 0732765d..199c64a9 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java @@ -52,7 +52,12 @@ public class FileServiceImpl implements FileService { // 上传到文件存储器 FileClient client = fileConfigService.getMasterFileClient(); Assert.notNull(client, "客户端(master) 不能为空"); - String url = client.upload(content, path, type); + String url=""; + if (path.equals("ofd")) { + url = client.upload(content, name, "application/ofd"); + }else { + url = client.upload(content, path, type); + } // 保存到数据库 FileDO file = new FileDO(); @@ -60,7 +65,12 @@ public class FileServiceImpl implements FileService { file.setName(name); file.setPath(path); file.setUrl(url); - file.setType(type); + if (path.equals("ofd")) { + file.setType("application/ofd"); + }else { + file.setType(type); + } + file.setSize(content.length); fileMapper.insert(file); return url;