|
@@ -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();
|