From 7bd3fe22caa83b37fd28122a23d4bb3ea6ed45f2 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Thu, 9 Sep 2021 15:19:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BC=96=E8=BE=91=E6=A1=A9?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=A1=A9=E6=89=80=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E7=BB=88=E7=AB=AF=E6=97=B6=EF=BC=8C=E7=94=9F=E6=88=90=E5=85=B6?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=9B=BE=E7=89=87=EF=BC=8C=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=88=B0=E9=98=BF=E9=87=8C=E4=BA=91=EF=BC=8C=E7=84=B6?= =?UTF-8?q?=E5=90=8E=E5=88=A0=E9=99=A4=E6=9C=AC=E5=9C=B0=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=9B=BE=E7=89=87=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/XhpcChargingPileServiceImpl.java | 11 +++-- .../test/java/com/xhpc/test/TestQrUtil.java | 47 +++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 xhpc-modules/xhpc-charging-station/src/test/java/com/xhpc/test/TestQrUtil.java diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java index 9bb78c12..096e21e6 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java @@ -187,12 +187,17 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService { xhpcTerminal.setStatus(0); xhpcTerminal.setRateModelId(rateModelId); xhpcTerminalMapper.addXhpcTerminal(xhpcTerminal); + + //生成二维码图片,并上传 + QrImgUtils.uploadImg(xhpcTerminal,String.valueOf(chargingPileId),environment,xhpcImgMapper); + } + } //插入redis 桩的编号 - HashSet noSet = new HashSet<>(); - noSet.add(serialNumber); - powerPileService.addPileWhitelist(chargingStationId, noSet); +// HashSet noSet = new HashSet<>(); +// noSet.add(serialNumber); +// powerPileService.addPileWhitelist(chargingStationId, noSet); } xhpcChargingPileMapper.updaeXhpcChargingPile(xhpcChargingPile); return AjaxResult.success(); diff --git a/xhpc-modules/xhpc-charging-station/src/test/java/com/xhpc/test/TestQrUtil.java b/xhpc-modules/xhpc-charging-station/src/test/java/com/xhpc/test/TestQrUtil.java new file mode 100644 index 00000000..2c46e4d1 --- /dev/null +++ b/xhpc-modules/xhpc-charging-station/src/test/java/com/xhpc/test/TestQrUtil.java @@ -0,0 +1,47 @@ +package com.xhpc.test; + +import cn.hutool.core.date.DateUtil; +import com.aliyun.oss.OSSClient; +import com.xhpc.charging.station.utils.QRCodeUtil; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; + +import java.io.File; +import java.util.Date; + +public class TestQrUtil { + +// //上传图片全局变量 +// @Autowired +// private Environment environment; +// @Autowired +// private IXhpcImgService iXhpcImgService; +// +// @Test +// public void test02() throws Exception { +// QRCodeUtil.encode("https://xhpc.scxhua.com?pNum=6985214589654702","C:\\Users\\14554\\Desktop\\公司项目\\图片\\小华充电logo.png","C:\\Users\\14554\\Desktop\\公司项目\\图片\\小华充电二维码",false,"pNum=6985214589654702"); +// } +// +// @Test +// public void test03() throws Exception { +// +// Date date = new Date(); +// String s = date.toString(); +// String fileName = DateUtil.format(date, "yyyyMMddHHmmssSSS")+"6985214589654702"; +//// DateUtil.parse(s,"yyyyMMddHHmmssSSS"); +// System.out.println(fileName); +// QRCodeUtil.encode("https://xhpc.scxhua.com?pNum=6985214589654702","C:\\Users\\14554\\Desktop\\公司项目\\图片\\小华充电logo.png","C:\\Users\\14554\\Desktop\\公司项目\\图片\\小华充电二维码",false,fileName); +// +// //3.上传图片至服务器 +// // 创建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"), fileName, new File("C:\\Users\\14554\\Desktop\\公司项目\\图片\\小华充电二维码"+"/"+fileName+".png")); +// ossClient.shutdown(); +// +// XhpcImg xhpcImg = new XhpcImg(); +// xhpcImg.setUrl(fileName); +// iXhpcImgService.insert(xhpcImg); +// } +}