|
@@ -1,7 +1,11 @@
|
|
|
package com.fdkankan.ucenter.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
|
+import cn.hutool.extra.qrcode.QrConfig;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -9,6 +13,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.SceneVersionType;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.image.MatrixToImageWriterUtil;
|
|
@@ -39,6 +44,7 @@ import com.fdkankan.ucenter.vo.SceneEditControlsVO;
|
|
|
import com.fdkankan.ucenter.vo.request.RequestScene;
|
|
|
import com.fdkankan.ucenter.vo.response.SceneVo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -84,6 +90,8 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
|
|
|
ISceneCopyLogService sceneCopyLogService;
|
|
|
@Autowired
|
|
|
private IUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyService companyService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -296,12 +304,8 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
|
|
|
redisUtil.del(String.format(RedisKey.SCENE_JSON, num));
|
|
|
|
|
|
// 生成二维码
|
|
|
- String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/" + newNum + ".png";
|
|
|
- String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/" + newNum + "_en.png";
|
|
|
- MatrixToImageWriterUtil.createQRCode(plusExt.getWebSite(), outPathZh, false,null);
|
|
|
- MatrixToImageWriterUtil.createQRCode(plusExt.getWebSite() + "&lang=en", outPathEn, false, null);
|
|
|
- fYunFileServiceInterface.uploadFile(outPathZh, String.format(UploadFilePath.DOWNLOADS_QRCODE, newNum) + newNum + ".png");
|
|
|
- fYunFileServiceInterface.uploadFile(outPathEn, String.format(UploadFilePath.DOWNLOADS_QRCODE, newNum) + newNum + "_en.png");
|
|
|
+ this.createQrCode(newNum, scenePlus.getCameraId(), plusExt.getWebSite(), sceneEditInfoExt.getShareLogoImg(), SceneVersionType.V4.code());
|
|
|
+
|
|
|
scenePlus.setSceneStatus(-2);
|
|
|
this.updateById(scenePlus);
|
|
|
|
|
@@ -331,6 +335,60 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
|
|
|
return scenePlus.getId();
|
|
|
}
|
|
|
|
|
|
+ public void createQrCode(String num, Long cameraId, String website, String shareLogoImg, String sceneVersion) {
|
|
|
+
|
|
|
+ String localLogoPath = null;
|
|
|
+ String qrLogo = StrUtil.isEmpty(shareLogoImg) ? null : shareLogoImg;
|
|
|
+ if(sceneVersion.equals(SceneVersionType.V3.code()) && StrUtil.isNotEmpty(qrLogo) && FileUtil.exist(ConstantFilePath.SCENE_PATH + qrLogo)){
|
|
|
+ localLogoPath = ConstantFilePath.SCENE_PATH + qrLogo;
|
|
|
+ }else{
|
|
|
+ if(StrUtil.isEmpty(qrLogo)){
|
|
|
+ CameraDetail cameraDetail = null;
|
|
|
+ Company company = null;
|
|
|
+ if(Objects.nonNull(cameraId)){
|
|
|
+ cameraDetail = cameraDetailService.getByCameraId(cameraId);
|
|
|
+ if(Objects.nonNull(cameraDetail)){
|
|
|
+ company = !ObjectUtils.isEmpty(cameraDetail.getCompanyId()) ? companyService.getById(cameraDetail.getCompanyId()) : null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ qrLogo = !ObjectUtils.isEmpty(company) && !ObjectUtils.isEmpty(company.getQrLogo()) ? company.getQrLogo() : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(qrLogo)) {
|
|
|
+ try {
|
|
|
+ localLogoPath = ConstantFilePath.SCENE_PATH + "qrLogo/" + qrLogo.substring(qrLogo.lastIndexOf("//") + 1);
|
|
|
+ HttpUtil.downloadFile(qrLogo, localLogoPath);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("logo下载失败:{}", qrLogo);
|
|
|
+ localLogoPath = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //生成二维码
|
|
|
+ String outPathZh = com.fdkankan.model.constants.ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +".png";
|
|
|
+ String outPathEn = com.fdkankan.model.constants.ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +"_en.png";
|
|
|
+ QrConfig qrConfig = QrConfig.create();
|
|
|
+ qrConfig.setWidth(512);
|
|
|
+ qrConfig.setHeight(512);
|
|
|
+ if(!ObjectUtils.isEmpty(localLogoPath)){
|
|
|
+ qrConfig.setImg(localLogoPath);
|
|
|
+ }
|
|
|
+ QrCodeUtil.generate(website, qrConfig, FileUtil.file(outPathZh));
|
|
|
+ QrCodeUtil.generate(website + "&lang=en", qrConfig, FileUtil.file(outPathEn));
|
|
|
+
|
|
|
+ //上传二维码
|
|
|
+ if(sceneVersion.equals(SceneVersionType.V4.code())){
|
|
|
+ fYunFileServiceInterface.uploadFile(outPathZh, String.format(com.fdkankan.model.constants.UploadFilePath.DOWNLOADS_QRCODE, num) + num + ".png");
|
|
|
+ fYunFileServiceInterface.uploadFile(outPathEn, String.format(com.fdkankan.model.constants.UploadFilePath.DOWNLOADS_QRCODE, num) + num + "_en.png");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!ObjectUtils.isEmpty(localLogoPath)){
|
|
|
+ FileUtils.deleteFile(localLogoPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Result pageSceneWithHouseType(RequestScene param, String token) {
|
|
|
User ssoUser = userService.getByToken(token);
|