|
@@ -1,8 +1,12 @@
|
|
|
package com.fdkankan.manage_jp.service.impl;
|
|
|
|
|
|
+import cn.hutool.cache.CacheUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
|
+import cn.hutool.extra.qrcode.QrConfig;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fdkankan.common.constant.SceneVersionType;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.image.MatrixToImageWriterUtil;
|
|
@@ -12,12 +16,14 @@ import com.fdkankan.manage_jp.service.IScene3dNumService;
|
|
|
import com.fdkankan.manage_jp.util.SceneResourcePath;
|
|
|
import com.fdkankan.manage_jp.util.SnowflakeIdGenerator;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.Date;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -75,17 +81,36 @@ public class SceneCommonService {
|
|
|
return newDataSource;
|
|
|
}
|
|
|
|
|
|
- public void createNewQrCode(String newNum, String webSite){
|
|
|
- try {
|
|
|
- String outPathZh = SceneResourcePath.qrCodeBasePath + newNum + ".png";
|
|
|
- String outPathEn = SceneResourcePath.qrCodeBasePath + newNum + "_en.png";
|
|
|
- MatrixToImageWriterUtil.createQRCode(webSite, outPathZh, false,null);
|
|
|
- MatrixToImageWriterUtil.createQRCode(webSite + "&lang=en", outPathEn, false, null);
|
|
|
-
|
|
|
- fYunFileServiceInterface.uploadFile(outPathZh, String.format(SceneResourcePath.DOWNLOADS_QRCODE, newNum) + newNum + ".png");
|
|
|
- fYunFileServiceInterface.uploadFile(outPathEn, String.format(SceneResourcePath.DOWNLOADS_QRCODE, newNum) + newNum + "_en.png");
|
|
|
+ public void createNewQrCode(String sceneVersion,String logoPath ,String newNum, String webSite){
|
|
|
+ String localLogoPath = null;
|
|
|
+ try {
|
|
|
+ if(StringUtils.isNotBlank(logoPath)){
|
|
|
+ if(sceneVersion.equals(SceneVersionType.V3.code())){
|
|
|
+ localLogoPath =SceneResourcePath.nasBasePath + logoPath;
|
|
|
+ }else{
|
|
|
+ localLogoPath = SceneResourcePath.qrCodeBasePath + newNum +"/logo/logo.png";
|
|
|
+ fYunFileServiceInterface.downloadFile(logoPath,localLogoPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String outPathZh = SceneResourcePath.qrCodeBasePath + newNum + ".png";
|
|
|
+ String outPathEn = SceneResourcePath.qrCodeBasePath + newNum + "_en.png";
|
|
|
+ QrConfig qrConfig = QrConfig.create();
|
|
|
+ qrConfig.setWidth(1024);
|
|
|
+ qrConfig.setHeight(1024);
|
|
|
+ if(!ObjectUtils.isEmpty(localLogoPath)){
|
|
|
+ qrConfig.setImg(localLogoPath);
|
|
|
+ }
|
|
|
+ QrCodeUtil.generate(webSite, qrConfig, FileUtil.file(outPathZh));
|
|
|
+ QrCodeUtil.generate(webSite + "&lang=en", qrConfig, FileUtil.file(outPathEn));
|
|
|
+
|
|
|
+ fYunFileServiceInterface.uploadFile(outPathZh, String.format(SceneResourcePath.DOWNLOADS_QRCODE, newNum) + newNum + ".png");
|
|
|
+ fYunFileServiceInterface.uploadFile(outPathEn, String.format(SceneResourcePath.DOWNLOADS_QRCODE, newNum) + newNum + "_en.png");
|
|
|
}catch (Exception e){
|
|
|
log.info("copy-scene-error:{},newNum:{},error:{}",newNum,e);
|
|
|
+ }finally {
|
|
|
+ if(StringUtils.isNotBlank(logoPath)){
|
|
|
+ FileUtil.del(localLogoPath);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|