From 965affeeaa7196749722d2dba2c59665e80c0451 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Fri, 19 Nov 2021 20:05:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=97=A5=E5=BF=97=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?bootstrap.yml=E6=96=87=E4=BB=B6=E4=B8=AD=E7=9A=84=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=E8=B5=84=E6=BA=90=E4=BD=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=BA=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E9=9C=80=E6=9C=AC=E5=9C=B0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=EF=BC=8C=E5=9C=A8yml=E4=B8=AD=E5=88=87=E6=8D=A2=E4=B8=BA?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83=E5=8D=B3?= =?UTF-8?q?=E5=8F=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/utils/img/QrImgUtils.java | 19 ++++++++++++------- .../src/main/resources/bootstrap.yml | 4 ++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/utils/img/QrImgUtils.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/utils/img/QrImgUtils.java index cd7d898d..41a4b230 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/utils/img/QrImgUtils.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/utils/img/QrImgUtils.java @@ -45,30 +45,35 @@ public class QrImgUtils { chargingStationName, name, String.valueOf(letterMap.get(forIndex)), - new File(environment.getProperty("fullImgDestPath")+finallyImgFileName) - ); + new File(environment.getProperty("fullImgDestPath") + finallyImgFileName) + ); + + System.out.println("===================》完整二维码图片生成成功"); //4.上传图片至服务器 // 创建OSSClient实例 OSSClient ossClient = new OSSClient(environment.getProperty("oss.endpoint"), environment.getProperty("oss.access-key"), environment.getProperty("oss.secret-key")); // 上传文件流 - ossClient.putObject(environment.getProperty("oss.bucket-name"), xhpcTerminal.getPileSerialNumber() + "/" + finallyImgFileName, new File(environment.getProperty("destPath") + "/" + finallyImgFileName)); + ossClient.putObject(environment.getProperty("oss.bucket-name"), xhpcTerminal.getPileSerialNumber() + "/" + finallyImgFileName, new File(environment.getProperty("destPath") + File.separatorChar + finallyImgFileName)); ossClient.shutdown(); + System.out.println("===================》将完整二维码上传至阿里云成功"); + //5.将放在阿里云上的生成的图片的路径和图片所对应的终端的id放入数据库xhpc_img表中 Long terminalId = xhpcTerminal.getTerminalId(); xhpcImgMapper.insert(xhpcTerminal.getPileSerialNumber() + "/" + finallyImgFileName, terminalId); - + System.out.println("===================》将阿里云上的图片地址放入数据库"); //6.删除生成的二维码图片 - File QrImg = new File(environment.getProperty("destPath") + "\\" + qrFileName); + File QrImg = new File(environment.getProperty("destPath") + File.separatorChar + qrFileName); QrImg.delete(); - //7.删除生成本地生成的完整图片 + //7.删除本地生成的完整图片 File finallyImg = new File(environment.getProperty("fullImgDestPath") + finallyImgFileName); finallyImg.delete(); - + System.out.println("==================》已删除本地生成的完成二维码图片"); } catch (Exception e) { e.printStackTrace(); System.out.println(e.getMessage()); + System.out.println("二维码生成图片失败,请检查生成二维码所需要的资源路径是否正确"); } } } diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-charging-station/src/main/resources/bootstrap.yml index e8ecce9f..cbd1a1bc 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/bootstrap.yml @@ -26,10 +26,14 @@ spring: #二维码Logo图片获取位置: +#imgPath: "D:\\Enterprise_Resources\\XiaoHuaMaterialImgs\\xhcd_logo.png" imgPath: "/www/wwwroot/xhpc.scxhua.com/xhpc-charging-stion/logo.png" #生成的二维码存放位置: +#destPath: "D:\\Enterprise_Resources\\XiaoHuaFullImgs" destPath: "/www/wwwroot/xhpc.scxhua.com/xhpc-charging-stion/XiaoHuaFullImgs" #生成的最终完整图片的存放位置: +#fullImgDestPath: "D:\\Enterprise_Resources\\XiaoHuaFullImgs\\" fullImgDestPath: "/www/wwwroot/xhpc.scxhua.com/xhpc-charging-stion/XiaoHuaFullImgs/" #底图图片存放位置: +#bottomImg: "D:\\Enterprise_Resources\\XiaoHuaMaterialImgs\\BottomImg.png" bottomImg: "/www/wwwroot/xhpc.scxhua.com/xhpc-charging-stion/BottomImg.png" \ No newline at end of file