dengsixing пре 3 година
родитељ
комит
9ca7ea8a55

+ 7 - 7
4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/SceneEditController.java

@@ -616,21 +616,21 @@ public class SceneEditController extends BaseController {
     /**
      * 保存关联全景图
      */
-    @PostMapping(value = "/uploadRelationPanorama")
-    public ResultData uploadRelationPanorama(
+    @PostMapping(value = "/uploadLinkPan")
+    public ResultData uploadLinkPan(
         @RequestParam(value = "num") String num,
         @RequestParam(value = "sid") String sid,
         @RequestParam(value = "fileName") String fileName,
         @RequestParam("file") MultipartFile file) throws Exception{
-        return sceneProService.uploadRelationPanorama(param, file);
+        return sceneEditInfoService.uploadLinkPan(num, sid, fileName, file);
     }
 
     /**
      * 保存关联全景图
      */
-    @PostMapping(value = "/savePanoramaJson")
-    public ResultData savePanoramaJson(@RequestBody FileParamVO param) throws Exception{
-        return sceneProService.savePanoramaJson(param);
+    @PostMapping(value = "/saveLinkPan")
+    public ResultData saveLinkPan(@RequestBody @Validated SaveLinkPanParamVO param) throws Exception{
+        return sceneEditInfoService.saveLinkPan(param);
     }
 
     /**
@@ -924,7 +924,7 @@ public class SceneEditController extends BaseController {
 
     /**
      * 获取场景权限
-     * @param param
+     * @param num 场景码
      * @return
      * @throws Exception
      */

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

@@ -68,7 +68,9 @@ public interface ISceneEditInfoService extends IService<SceneEditInfo> {
 
     ResultData addMosaics(@RequestBody @Validated BaseDataParamVO param) throws Exception;
 
-    ResultData uploadRelationPanorama(String num, String sid, String fileName, MultipartFile file) throws Exception;
+    ResultData uploadLinkPan(String num, String sid, String fileName, MultipartFile file) throws Exception;
+
+    ResultData saveLinkPan(SaveLinkPanParamVO param) throws Exception;
 
 
 

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

@@ -148,8 +148,6 @@ public interface ISceneProService extends IService<ScenePro> {
 
     ResultData deleteUploadBgMusic(FileParamVO param) throws Exception;
 
-    ResultData savePanoramaJson(FileParamVO param) throws Exception;
-
     ResultData copyAndUpdateFloorJson(FileParamVO param) throws Exception;
 
     ResultData updateFloorJson(FileParamVO param) throws Exception;

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

@@ -1678,7 +1678,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
     }
 
     @Override
-    public ResultData uploadRelationPanorama(String num, String sid, String fileName, MultipartFile file) throws Exception {
+    public ResultData uploadLinkPan(String num, String sid, String fileName, MultipartFile file) throws Exception {
 
         ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
         if(scenePlus == null){
@@ -1768,7 +1768,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         Map<String, String> map = new HashMap<>();
         JSONObject fileJson;
         String uploadFile, uploadFilePath;
-        String img;
+        String img = null;
         String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
         for(int i = 0, len = array.size(); i < len; i++){
             fileJson = array.getJSONObject(i);
@@ -1782,7 +1782,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
             //low文件夹
             if(fileJson.getIntValue("clazz") == 4){
-                img = "/results" + File.separator + uploadFile;
+                img = "pan/low/" + uploadFile.replace("low/", "");
                 map.put(uploadFilePath, imgEditPath + "pan/low/" + uploadFile.replace("low/", ""));
                 continue;
             }
@@ -1793,7 +1793,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
             }
 
             //tiles文件夹,亚马逊瓦片图
-            if(fileJson.getIntValue("clazz") == 7 ){
+            if(fileJson.getIntValue("clazz") == 7){
                 map.put(uploadFilePath, imgEditPath + uploadFile);
             }
         }
@@ -1805,11 +1805,125 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
         Map<String, String> result = new HashMap<>();
         result.put("type", type);
-        result.put("img", "scene/" + imagesBuf.toString() + "panorama/" + sid + img);
-        result.put("path", "images/images"+ num + "/panorama_edit/" + sid);
+        result.put("img", img);
+        result.put("path", "panorama_edit/" + sid);
         return ResultData.ok(result);
     }
 
+    @Override
+    public ResultData saveLinkPan(SaveLinkPanParamVO param) throws Exception {
+        String sceneNum = param.getNum();
+        String fileName = param.getFileName();
+        String fileData = param.getFileData();
+        String sid = param.getSid();
+        if(StrUtil.isEmpty(sceneNum) || StrUtil.isEmpty(fileName)){
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
+        }
+
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
+        if(Objects.isNull(scenePlus)){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+        }
+
+        StringBuffer dataBuf = new StringBuffer()
+            .append("data").append(File.separator)
+            .append("data").append(scenePro.getNum())
+            .append(File.separator);
+
+        StringBuffer imagesBuf = new StringBuffer()
+            .append("images").append(File.separator)
+            .append("images").append(scenePro.getNum())
+            .append(File.separator);
+
+        StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf.toString());
+        StringBuffer imagesBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(imagesBuf.toString());
+
+        FileUtils.writeFile(dataBuffer.toString() + fileName, fileData);
+
+        String strsceneInfos = FileUtils.readFile(dataBuffer.toString() + "scene.json");
+        JSONObject scenejson = new JSONObject();
+        if(strsceneInfos!=null) {
+            scenejson = JSONObject.parseObject(strsceneInfos);
+        }
+
+        scenejson.put("uploadPanoramaJson", 1);
+        scenejson.put("version", scenejson.getIntValue("version") + 1);
+        if(StrUtil.isNotEmpty(fileData)){
+            scenejson.put("jumpScene", true);
+        }else {
+            scenejson.put("jumpScene", false);
+        }
+        FileUtils.writeFile(dataBuffer.toString() + "scene.json", scenejson.toString());
+
+        if(StrUtil.isNotEmpty(sid)){
+            String target = imagesBuffer.toString() + "panorama/" + sid;
+            FileUtils.deleteDirectory(target);
+            uploadToOssUtil.deleteFile(imagesBuf.toString() + "panorama_edit/" + sid);
+        }
+
+        return ResultData.ok();
+    }
+
+    private void addOrUpdateLinPan(String num, List<LinkPanParamVO> linkPanList) throws Exception{
+        Map<String, String> addOrUpdateMap = new HashMap<>();
+        int i = 0;
+        for (LinkPanParamVO linkPan : linkPanList) {
+            JSONObject jsonObject = JSON.parseObject(linkPan.getLinkPanData());
+            jsonObject.put("createTime", Calendar.getInstance().getTimeInMillis() + i++);
+            addOrUpdateMap.put(linkPan.getSid(), jsonObject.toJSONString());
+        }
+
+        this.syncHotFromFileToRedis(num);
+
+        //处理新增和修改数据
+        this.addOrUpdateHotDataHandler(num, addOrUpdateMap);
+    }
+
+    /**
+     * <p>
+     保证热点数据安全性,当redis宕机导致热点数据丢失时,可以从文件中读取,恢复到redis
+     * </p>
+     * @author dengsixing
+     * @date 2022/3/3
+     **/
+    private void syncLinPanFromFileToRedis(String num) throws Exception{
+
+        String key = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
+        boolean exist = redisUtil.hasKey(key);
+        if(exist){
+            return;
+        }
+        String lockKey = String.format(RedisLockKey.LOCK_HOT_DATA_SYNC, num);
+        boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_1_MINUTE);
+        if(!lock){
+            throw new BusinessException(ErrorCode.SYSTEM_BUSY);
+        }
+        try{
+            exist = redisUtil.hasKey(key);
+            if(exist){
+                return;
+            }
+            String tagsFilePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
+            String tagsData = FileUtils.readFile(tagsFilePath + "hot.json");
+            if(StrUtil.isEmpty(tagsData)){
+                return;
+            }
+            JSONObject jsonObject = JSON.parseObject(tagsData);
+            JSONArray tagsArr = jsonObject.getJSONArray("tags");
+            if(CollUtil.isEmpty(tagsArr)){
+                return;
+            }
+            Map<String, String> map = new HashMap<>();
+            for (Object o : tagsArr) {
+                JSONObject jo = (JSONObject)o;
+                map.put(jo.getString("sid"), jo.toJSONString());
+            }
+            redisUtil.hmset(key, map);
+        }finally {
+            redisLockUtil.unlockLua(lockKey);
+        }
+    }
+
     private void updateBoxVideos(SceneEditInfo sceneEditInfo, Long scenePlusId, String boxVideos){
         if(Objects.isNull(sceneEditInfo)){
             sceneEditInfo = new SceneEditInfo();

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

@@ -4169,61 +4169,6 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         return ResultData.ok();
     }
 
-
-    @Override
-    public ResultData savePanoramaJson(FileParamVO param) throws Exception {
-        String sceneNum = param.getNum();
-        String fileName = param.getFileName();
-        String fileData = param.getFileData();
-        String sid = param.getSid();
-        if(StrUtil.isEmpty(sceneNum) || StrUtil.isEmpty(fileName)){
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-
-        ScenePro scenePro = baseMapper.findByNum(sceneNum);
-        if(scenePro == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
-        }
-
-        StringBuffer dataBuf = new StringBuffer()
-                .append("data").append(File.separator)
-                .append("data").append(scenePro.getNum())
-                .append(File.separator);
-
-        StringBuffer imagesBuf = new StringBuffer()
-                .append("images").append(File.separator)
-                .append("images").append(scenePro.getNum())
-                .append(File.separator);
-
-        StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf.toString());
-        StringBuffer imagesBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(imagesBuf.toString());
-
-        FileUtils.writeFile(dataBuffer.toString() + fileName, fileData);
-
-        String strsceneInfos = FileUtils.readFile(dataBuffer.toString() + "scene.json");
-        JSONObject scenejson = new JSONObject();
-        if(strsceneInfos!=null) {
-            scenejson = JSONObject.parseObject(strsceneInfos);
-        }
-
-        scenejson.put("uploadPanoramaJson", 1);
-        scenejson.put("version", scenejson.getIntValue("version") + 1);
-        if(StrUtil.isNotEmpty(fileData)){
-            scenejson.put("jumpScene", true);
-        }else {
-            scenejson.put("jumpScene", false);
-        }
-        FileUtils.writeFile(dataBuffer.toString() + "scene.json", scenejson.toString());
-
-        if(StrUtil.isNotEmpty(sid)){
-            String target = imagesBuffer.toString() + "panorama/" + sid;
-            FileUtils.deleteDirectory(target);
-            uploadToOssUtil.deleteFile(imagesBuf.toString() + "panorama_edit/" + sid);
-        }
-
-        return ResultData.ok();
-    }
-
     @Override
     public ResultData copyAndUpdateFloorJson(FileParamVO param) throws Exception{
         String sceneNum = param.getNum();

+ 24 - 0
4dkankan-center-scene/src/main/java/com/fdkankan/scene/vo/LinkPanParamVO.java

@@ -0,0 +1,24 @@
+package com.fdkankan.scene.vo;
+
+import javax.validation.constraints.NotBlank;
+import lombok.Data;
+
+/**
+ * <p>
+ * 场景关联点参数
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/2/8
+ **/
+@Data
+public class LinkPanParamVO {
+
+    @NotBlank(message = "sid不能为空")
+    private String sid;
+
+    private String linkPanData;
+
+
+
+}

+ 33 - 0
4dkankan-center-scene/src/main/java/com/fdkankan/scene/vo/SaveLinkPanParamVO.java

@@ -0,0 +1,33 @@
+package com.fdkankan.scene.vo;
+
+import java.util.List;
+import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import lombok.Data;
+
+/**
+ * <p>
+ * 保存场景关联参数
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/2/8
+ **/
+@Data
+public class SaveLinkPanParamVO {
+
+    @NotBlank(message = "场景码不能为空")
+    private String num;
+
+    @Valid
+    @NotNull(message = "热点数据不能为空")
+    private List<LinkPanParamVO> linkPans;
+
+    @Valid
+    @NotNull(message = "icons数据不能为空")
+    private List<String> styles;
+
+
+
+}