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); +// } +}