dengsixing 3 years ago
parent
commit
1493d872b7

+ 2 - 18
4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/SceneController.java

@@ -9,6 +9,7 @@ import com.fdkankan.common.constant.PayStatus;
 import com.fdkankan.common.constant.SceneInfoReqType;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.response.ResultData;
+import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.scene.entity.SceneEditInfo;
 import com.fdkankan.scene.entity.ScenePro;
 import com.fdkankan.scene.service.*;
@@ -240,24 +241,7 @@ public class SceneController {
      */
     @PostMapping(value = "/check/key")
     public ResultData checkKey(@RequestBody @Validated SceneCheckKeyParamVO param) throws Exception {
-        ScenePro scenePro = sceneProService.getOne(
-            new LambdaQueryWrapper<ScenePro>()
-                .eq(ScenePro::getNum, param.getNum())
-                .eq(ScenePro::getPayStatus,PayStatus.PAY.code()));
-        if (Objects.isNull(scenePro)) {
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
-        }
-        SceneEditInfo sceneEditInfo = sceneEditInfoService.getBySceneProId(scenePro.getId());
-
-        if (Objects.isNull(sceneEditInfo)) {
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
-        }
-
-        if(!param.getPassword().equals(sceneEditInfo.getScenePassword())){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5021);
-        }
-
-        return ResultData.ok();
+        return sceneEditInfoService.checkKey(param);
     }
 
 //    /**

+ 4 - 0
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/ISceneEditInfoService.java

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.scene.vo.*;
 import java.io.IOException;
 import java.util.List;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.multipart.MultipartFile;
 
 /**
@@ -50,6 +52,8 @@ public interface ISceneEditInfoService extends IService<SceneEditInfo> {
 
     ResultData sceneSync(String num, String type, String floorPlanJson, String ajkJson, String cameraJson, MultipartFile[] files) throws Exception;
 
+    ResultData checkKey(SceneCheckKeyParamVO param) throws Exception;
+
 
 
 

+ 48 - 7
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneEditInfoServiceImpl.java

@@ -406,9 +406,10 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         String sceneJson = redisUtil.get(key);
         SceneInfoVO sceneInfoVO = null;
         //先查询redis
-        if(StrUtil.isNotEmpty(sceneJson)){
+        if(StrUtil.isNotEmpty(sceneJson)) {
             sceneInfoVO = JSON.parseObject(sceneJson, SceneInfoVO.class);
             this.setExtData(sceneInfoVO, scenePro.getCameraId());
+            sceneInfoVO.setScenePassword(null);
             return sceneInfoVO;
         }
 
@@ -419,6 +420,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
             return null;
         sceneInfoVO = JSON.parseObject(objectContent, SceneInfoVO.class);
         this.setExtData(sceneInfoVO, scenePro.getCameraId());
+        sceneInfoVO.setScenePassword(null);
         redisUtil.set(key, JSON.toJSONString(sceneInfoVO));
 
         return sceneInfoVO;
@@ -678,8 +680,6 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         uploadFileList.stream().forEach(filePath->{
             map.put(filePath, filePath.replace(targetImagesPath, imgCachePath));
         });
-        //上传模型文件到缓存目录
-        uploadToOssUtil.uploadMulFiles(map);
 
         String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
         if(StorageType.AWS.code().equals(this.type)){
@@ -729,7 +729,13 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         }
         CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", target + File.separator + "capture/");
         CreateObjUtil.build3dModel(target , "1");
-        String uploadData = FileUtils.readFile(target + File.separator + "results" +File.separator+"upload.json");
+
+        String uploadJsonPath= target + File.separator + "results" +File.separator+"upload.json";
+        boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 3, 5000);
+        if(!exist){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5042);
+        }
+        String uploadData = FileUtils.readFile(uploadJsonPath);
         JSONObject uploadJson = null;
         JSONArray array = null;
         if(uploadData!=null) {
@@ -778,6 +784,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
                 continue;
             }
         }
+        if(map.size()>0) {
+            uploadToOssUtil.uploadMulFiles(map);
+        }
 
         return null;
     }
@@ -919,12 +928,13 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
     }
 
     @Override
-    public ResultData uploadBallScreenVideo(String num, String fileName, MultipartFile file)
-        throws Exception {
+    public ResultData uploadBallScreenVideo(String num, String fileName, MultipartFile file) throws Exception {
 
+        //校验格式
         if(!fileName.endsWith(".mp4")){
             throw new BusinessException(ErrorCode.FAILURE_CODE_7007.code(), ErrorCode.FAILURE_CODE_7007.formatMessage("mp4"));
         }
+        String videosViewPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, num);
 
         ScenePro scenePro = sceneProService.findBySceneNum(num);
         if(scenePro == null){
@@ -932,6 +942,25 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         }
         SceneProExt sceneProExt = sceneProExtService.findBySceneProId(scenePro.getId());
 
+        //校验文件名
+        String videos = scenePro.getVideos();
+        if(StrUtil.isEmpty(videos)){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_7012);
+        }
+        JSONObject videosJson = JSON.parseObject(videos);
+        JSONArray dataArr = videosJson.getJSONArray("data");
+        boolean exists = false;
+        for (Object o : dataArr) {
+            JSONObject jsonObject =  (JSONObject)o;
+            if(jsonObject.getString("id").equals(fileName.replace(".mp4", ""))){
+                exists = true;
+                break;
+            }
+        }
+        if(!exists){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_7012);
+        }
+
         String path = sceneProExt.getDataSource();
 
         if(path != null && !"".equals(path) && path.startsWith("http")){
@@ -956,7 +985,6 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
             throw new BusinessException(ErrorCode.FAILURE_CODE_7009);
         }
 
-        String videosViewPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, num);
         for(String videoName : video.list()){
             log.info("球幕视频名称:{}", videoName);
             uploadToOssUtil.upload(target + File.separator + "extras/video/" + videoName,videosViewPath + videoName);
@@ -1155,6 +1183,19 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         return ResultData.ok();
     }
 
+    @Override
+    public ResultData checkKey(SceneCheckKeyParamVO param) throws Exception {
+
+        String sceneJson = redisUtil.get(String.format(RedisKey.SCENE_JSON, param.getNum()));
+        SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
+
+        if(!param.getPassword().equals(sceneJsonBean.getScenePassword())){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5021);
+        }
+
+        return ResultData.ok();
+    }
+
     private void updateBoxVideos(SceneEditInfo sceneEditInfo, Long sceneProId, String boxVideos){
         if(Objects.isNull(sceneEditInfo)){
             sceneEditInfo = new SceneEditInfo();

+ 8 - 6
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -3596,17 +3596,19 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
             if(data.isDirectory()){
                 throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
             }
-            if(data.getName().endsWith(".obj") && objFlag){
-                throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
-            }
 
             if(data.getName().endsWith(".jpg") || data.getName().endsWith(".png")){
                 if(!FileUtils.checkFileSizeIsLimit(data.length(), 1.5, "M")){
                     throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
                 }
             }
-
-            if(data.getName().endsWith(".obj") && !objFlag){
+            if(data.getName().endsWith(".obj")){
+                if(objFlag){
+                    throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
+                }
+                if(!data.getName().equals("mesh.obj")){
+                    throw new BusinessException(ErrorCode.FAILURE_CODE_5060);
+                }
                 if(!FileUtils.checkFileSizeIsLimit(data.length(), 20, "M")){
                     throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
                 }
@@ -3625,7 +3627,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
         //压缩文件中必须有且仅有一个obj和mtl文件,否则抛出异常
         if(!mtlFlag && !objFlag){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5059);
         }
     }