ofd文件上传特殊处理

new
JilingLee 1 year ago
parent bec615020e
commit 040512413e

@ -164,7 +164,12 @@ public class InvoicesController {
}else { }else {
invoicesDO.setDuplicateMark(Byte.valueOf(AccountingStatusEnum.UN_DUPLICATE_INVOICE.getValue())); 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); invoicesDO.setFileUrl(url);
invoicesService.createInvoices(invoicesDO); invoicesService.createInvoices(invoicesDO);
return success(invoicesDO); return success(invoicesDO);
@ -190,8 +195,12 @@ public class InvoicesController {
* @param file * @param file
* @return * @return
*/ */
private String getUrl(MultipartFile file) throws Exception{ private String getUrl(MultipartFile file,String name, String path) throws Exception{
String url=""; 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())); url = fileService.createFile(null, null, IoUtil.readBytes(file.getInputStream()));
return url; return url;
} }

@ -52,7 +52,12 @@ public class FileServiceImpl implements FileService {
// 上传到文件存储器 // 上传到文件存储器
FileClient client = fileConfigService.getMasterFileClient(); FileClient client = fileConfigService.getMasterFileClient();
Assert.notNull(client, "客户端(master) 不能为空"); 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(); FileDO file = new FileDO();
@ -60,7 +65,12 @@ public class FileServiceImpl implements FileService {
file.setName(name); file.setName(name);
file.setPath(path); file.setPath(path);
file.setUrl(url); file.setUrl(url);
file.setType(type); if (path.equals("ofd")) {
file.setType("application/ofd");
}else {
file.setType(type);
}
file.setSize(content.length); file.setSize(content.length);
fileMapper.insert(file); fileMapper.insert(file);
return url; return url;

Loading…
Cancel
Save