完成编辑桩生成桩所对应的终端时,生成其二维码图片,上传到阿里云,然后删除本地生成的二维码图片功能

This commit is contained in:
wen 2021-09-09 15:19:09 +08:00
parent ce71a862e2
commit 7bd3fe22ca
2 changed files with 55 additions and 3 deletions

View File

@ -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<String> noSet = new HashSet<>();
noSet.add(serialNumber);
powerPileService.addPileWhitelist(chargingStationId, noSet);
// HashSet<String> noSet = new HashSet<>();
// noSet.add(serialNumber);
// powerPileService.addPileWhitelist(chargingStationId, noSet);
}
xhpcChargingPileMapper.updaeXhpcChargingPile(xhpcChargingPile);
return AjaxResult.success();

View File

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