Browse Source

Merge branch 'test' into releases

lyhzzz 2 years ago
parent
commit
12ce31ea20

+ 3 - 0
src/main/java/com/fdkankan/ucenter/constant/QrCodeFilePath.java

@@ -9,4 +9,7 @@ public class QrCodeFilePath {
     public static final String LOGIN_QR_CODE_PATH = "/mnt/4Dkankan/login/qrcode/";
     public static final String ALI_QRCODE_FOLDER = "/mnt/4Dkankan/alicode/";
     public static final String WEIXIN_QRCODE_FOLDER = "/mnt/4Dkankan/weixincode/";
+
+    public static final String LOGO_IMAGE_LOCAL = "/mnt/4Dkankan/login/qrcode/logo.jpg";
+    public static final String LOGO_IMAGE_OSS = "ucenter/image/logo.jpg";
 }

+ 4 - 1
src/main/java/com/fdkankan/ucenter/service/ISceneProService.java

@@ -89,4 +89,7 @@ public interface ISceneProService extends IService<ScenePro> {
     Page<SceneVo> pageListAndFolder(Page<Object> page, SceneParam param);
 
     Object getScenes(String username, RequestScene param);
-}
+
+     void updateOssStatus(String path,Integer payStatus) ;
+
+    }

+ 11 - 3
src/main/java/com/fdkankan/ucenter/service/impl/LoginService.java

@@ -8,6 +8,7 @@ import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.common.util.JwtUtil;
 import com.fdkankan.common.util.NumberUtils;
 import com.fdkankan.common.util.SecurityUtil;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.image.MatrixToImageWriterUtil;
 import com.fdkankan.ucenter.common.MailUtil;
 import com.fdkankan.ucenter.common.constants.ConstantFilePath;
@@ -30,6 +31,8 @@ import com.fdkankan.ucenter.vo.request.LoginParam;
 import com.fdkankan.ucenter.vo.request.RegisterParam;
 import com.fdkankan.ucenter.vo.response.LoginVo;
 import com.fdkankan.ucenter.vo.response.UserVo;
+
+import java.io.File;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -60,6 +63,8 @@ public class LoginService {
     private String cnCode;
     @Value("${admin.register.validCode:2a22bac40f44af4d3b5fdc20ea706fc5}")
     private String registerValidCode;
+    @Autowired
+    private FYunFileServiceInterface fYunFileServiceInterface;
 
 
     public LoginVo login(LoginParam param) {
@@ -183,8 +188,11 @@ public class LoginService {
     public JSONObject createLoginQrCode() throws Exception {
         String uuid = NumberUtils.getUUID();
         String filePath = QrCodeFilePath.LOGIN_QR_CODE_PATH + uuid + ".png";
-        String path =this.getClass().getResource("/static/img/logo.jpg").getPath();
-        MatrixToImageWriterUtil.createQRCode(NacosProperty.getMainUrl() + "app/index.html?m="+uuid, filePath,true,path);
+        File file = new File(QrCodeFilePath.LOGO_IMAGE_LOCAL);
+        if(!file.exists()){
+            fYunFileServiceInterface.downloadFile(QrCodeFilePath.LOGO_IMAGE_OSS,QrCodeFilePath.LOGO_IMAGE_LOCAL);
+        }
+        MatrixToImageWriterUtil.createQRCode(NacosProperty.getMainUrl() + "app/index.html?m="+uuid, filePath,true,QrCodeFilePath.LOGO_IMAGE_LOCAL);
         JSONObject json = new JSONObject();
         json.put("url", filePath.replace(ConstantFilePath.BASE_PATH, ""));
         json.put("uuid", uuid);
@@ -238,7 +246,7 @@ public class LoginService {
 
         if("1".equals(country)){
             SendMailAcceUtils.sendMail(email, SendMailAcceUtils.EN_CODE_SUBJECT, SendMailAcceUtils.EN_CODE_MSG.replace("${code}", code), null);
-        }if("2".equals(country)){
+        }else if("2".equals(country)){
             SendMailAcceUtils.sendMailUsa(email, SendMailAcceUtils.EN_CODE_SUBJECT_USA, SendMailAcceUtils.EN_CODE_MSG_USA.replace("${code}", code), null);
         }else if("33".equals(country)){
             SendMailAcceUtils.sendMail(email, SendMailAcceUtils.EN_CODE_SUBJECT, MailUtil.EN_CODE_MSG.replace("${code}", code), null);

+ 13 - 4
src/main/java/com/fdkankan/ucenter/service/impl/ScenePlusServiceImpl.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.image.MatrixToImageWriterUtil;
+import com.fdkankan.ucenter.common.OssPath;
 import com.fdkankan.ucenter.common.PageInfo;
 import com.fdkankan.ucenter.common.constants.ConstantFilePath;
 import com.fdkankan.ucenter.common.constants.UploadFilePath;
@@ -158,9 +159,6 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
         scenePlus.setSceneStatus(0);
         this.save(scenePlus);
 
-        cameraDetail.setUsedSpace(cameraDetail.getUsedSpace() + plusExt.getSpace());
-        cameraDetailService.updateById(cameraDetail);
-
         CompletableFuture.runAsync(() -> {
             try {
                 // 拷贝场景编辑资源
@@ -185,8 +183,11 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
                     String newScenePath = ConstantFilePath.SCENE_V4_PATH + newNum;
                     FileUtils.copyDirectiory(scenePath, newScenePath);
                 }
+                String newVideos = plusExt.getVideos();
+                if(StrUtil.isNotEmpty(newVideos)){
+                    newVideos = plusExt.getVideos().replaceAll("/data/data" + num, "/scene_view_data/" + newNum + "/data").replaceAll(num, newNum);
+                }
 
-                String newVideos = plusExt.getVideos().replaceAll("https://4dkk.4dage.com/data/data" + num, "https://4dkk.4dage.com/scene_view_data/" + newNum + "/data");
                 String oldDataSource  = plusExt.getDataSource();
                 String newDataSource =  sceneProService.setDataSource(plusExt.getDataSource(),time);
 
@@ -276,6 +277,14 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
                 fYunFileServiceInterface.uploadFile(outPathEn, String.format(UploadFilePath.DOWNLOADS_QRCODE, newNum) + newNum + "_en.png");
                 scenePlus.setSceneStatus(-2);
                 this.updateById(scenePlus);
+
+                cameraDetail.setUsedSpace(cameraDetail.getUsedSpace() + plusExt.getSpace());
+                cameraDetailService.updateById(cameraDetail);
+
+                if(scenePlus.getPayStatus() == -2){
+                    sceneProService.updateOssStatus(String.format(OssPath.v4_statusPath,scenePlus.getNum()),-2);
+                }
+
                 log.info("复制场景结束-{}", new Date());
                 if(scenePlus.getSceneSource() == 4){  //深时复制
                     String laserPath = laserService.copyDataSource(oldDataSource,plusExt.getDataSource());

+ 30 - 2
src/main/java/com/fdkankan/ucenter/service/impl/SceneProServiceImpl.java

@@ -236,7 +236,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
                 if(incrementType.getCameraCapacity() == -1){
                     totalSpace   = -1L;
                 }else {
-                    totalSpace = incrementType.getCameraCapacity() * 1024 * 1024L;
+                    totalSpace = incrementType.getCameraCapacity() * 1024* 1024 * 1024L;
                 }
             }
         }
@@ -361,7 +361,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     /**
      * 从oss中获取文件,并重写,上传替换
      */
-    private void updateOssStatus(String path,Integer payStatus) {
+    @Override
+    public void updateOssStatus(String path,Integer payStatus) {
         try {
             if(!fYunFileService.fileExist(path)){
                 return;
@@ -657,6 +658,27 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         if(detailEntity == null){
             throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
         }
+        UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
+        if(userIncrement == null){
+            throw new BusinessException(LoginConstant.FAILURE_CODE_3030, LoginConstant.FAILURE_MSG_3030);
+        }
+        IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
+        if(incrementType == null){
+            throw new BusinessException(LoginConstant.FAILURE_CODE_3030, LoginConstant.FAILURE_MSG_3030);
+        }
+        if(incrementType.getCameraCapacity() != -1){
+            Long usedSpace = detailEntity.getUsedSpace();
+            if( scenePro != null && scenePro.getSpace() + usedSpace > incrementType.getCameraCapacity() * 1024 * 1024 * 1024L){
+                scenePro.setPayStatus(-2);
+            }
+            if( scenePlus != null ){
+                ScenePlusExt ext = scenePlusExtService.getByPlusId(scenePlus.getId());
+                if(ext.getSpace() + usedSpace > incrementType.getCameraCapacity() * 1024 * 1024 * 1024L){
+                    scenePlus.setPayStatus(-2);
+                }
+            }
+        }
+
         String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
         String title = scenePro == null ? scenePlus.getTitle() : scenePro.getSceneName();
         String newTitle = title.concat("(copy)");
@@ -785,6 +807,12 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
                 FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"video/video" + oldNum,ConstantFilePath.SCENE_PATH +"video/video" + newNum);
                 oldScene.setStatus(-2);
                 this.updateById(oldScene);
+
+                cameraDetail.setUsedSpace(cameraDetail.getUsedSpace() + oldScene.getSpace());
+                cameraDetailService.updateById(cameraDetail);
+                if(oldScene.getPayStatus() == -2){
+                    this.updateOssStatus(String.format(OssPath.v3_statusPath,oldScene.getNum()),-2);
+                }
                 log.info("复制场景结束-{}", new Date());
                 if(oldScene.getSceneSource() == 4){  //深时复制
                     String laserPath = laserService.copyDataSource(preDataSource,oldScene.getDataSource());