From b1978bb176d1ad2600a5e10b8b2937e3202508d2 Mon Sep 17 00:00:00 2001 From: "LAPTOP-0SF788NU\\admin" <3306174053@qq.com> Date: Wed, 8 Nov 2023 14:38:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=85=E5=86=8C=E7=AE=A1=E7=90=86-=E6=9D=A1?= =?UTF-8?q?=E7=A0=81=E6=97=A0=E6=B3=95=E6=89=AB=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/packages/PackagesServiceImpl.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/packages/PackagesServiceImpl.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/packages/PackagesServiceImpl.java index e04f0488..3dc9a1a9 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/packages/PackagesServiceImpl.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/packages/PackagesServiceImpl.java @@ -149,18 +149,22 @@ public class PackagesServiceImpl implements PackagesService { * @return */ private String getUrl(PackagesDO packages){ - try { // InetAddress address = InetAddress.getLocalHost();//获取的是本地的IP地址 // String hostAddress = address.getHostAddress(); - File buf = BarcodeUtil.generateBarCode(webUrl+"/info?codeValue="+packages.getCaseNum()+"-"+ packages.getCatalogNum()+"-"+ packages.getFilesNum(), "QR_CODE", + File buf = BarcodeUtil.generateBarCode(packages.getCaseNum()+"-"+ packages.getCatalogNum()+"-"+ packages.getFilesNum(), "QR_CODE", "./tmp/Packages/" + packages.getCaseNum()+"-"+ packages.getCatalogNum()+"-"+ packages.getFilesNum() + ".png"); MultipartFile file = FileUtils.getMultipartFile(buf); - String url=""; - url = fileService.createFile(null, null, IoUtil.readBytes(file.getInputStream())); + String url= null; + try { + url = fileService.createFile(file.getOriginalFilename(), null, IoUtil.readBytes(file.getInputStream())); return url; } catch (IOException e) { Log.error(e.toString()); - return ""; + return null; + }finally { + if(buf!=null && buf.exists()){ + FileUtils.deleteFile(buf.getAbsolutePath()); + } } }