|
@@ -1,7 +1,18 @@
|
|
|
package com.fdkankan.scene.service.impl;
|
|
|
+import cn.hutool.core.net.multipart.UploadFile;
|
|
|
+import cn.hutool.core.util.CharsetUtil;
|
|
|
+import com.fdkankan.common.constant.CommonOperStatus;
|
|
|
+import com.fdkankan.common.constant.SceneAsynFuncType;
|
|
|
+import com.fdkankan.common.constant.SceneAsynModuleType;
|
|
|
+import com.fdkankan.common.constant.SceneAsynOperType;
|
|
|
+import com.fdkankan.common.util.MD5;
|
|
|
+import com.fdkankan.scene.vo.SaveFiltersParamVO;
|
|
|
+import io.opencensus.metrics.LongGauge;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -22,6 +33,16 @@ import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.model.utils.CreateHouseJsonUtil;
|
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
+import com.fdkankan.common.util.FileMd5Util;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.fyun.constant.FYunTypeEnum;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.fdkankan.model.utils.ComputerUtil;
|
|
|
+import com.fdkankan.model.utils.CreateHouseJsonUtil;
|
|
|
+import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
+import com.fdkankan.model.utils.SceneUtil;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.constant.RedisLockKey;
|
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
@@ -35,6 +56,10 @@ import com.fdkankan.scene.bean.StyleBean;
|
|
|
import com.fdkankan.scene.bean.TagBean;
|
|
|
import com.fdkankan.scene.bean.VertexBean;
|
|
|
import com.fdkankan.scene.bean.WallBean;
|
|
|
+import com.fdkankan.scene.entity.CameraDetail;
|
|
|
+import com.fdkankan.scene.entity.Company;
|
|
|
+import com.fdkankan.scene.entity.SceneAsynOperLog;
|
|
|
+import com.fdkankan.scene.entity.SceneDataDownload;
|
|
|
import com.fdkankan.scene.entity.SceneEditControls;
|
|
|
import com.fdkankan.scene.entity.SceneEditInfo;
|
|
|
import com.fdkankan.scene.entity.SceneEditInfoExt;
|
|
@@ -43,6 +68,9 @@ import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
import com.fdkankan.scene.mapper.ISceneEditInfoMapper;
|
|
|
import com.fdkankan.scene.oss.OssUtil;
|
|
|
import com.fdkankan.scene.service.ILaserService;
|
|
|
+import com.fdkankan.scene.service.ICameraDetailService;
|
|
|
+import com.fdkankan.scene.service.ICompanyService;
|
|
|
+import com.fdkankan.scene.service.ISceneAsynOperLogService;
|
|
|
import com.fdkankan.scene.service.ISceneDataDownloadService;
|
|
|
import com.fdkankan.scene.service.ISceneEditControlsService;
|
|
|
import com.fdkankan.scene.service.ISceneEditInfoExtService;
|
|
@@ -51,9 +79,11 @@ import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
import com.fdkankan.scene.service.IScenePlusService;
|
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
|
import com.fdkankan.scene.service.ISceneUploadService;
|
|
|
+import com.fdkankan.scene.service.ISurveillanceService;
|
|
|
import com.fdkankan.scene.vo.BallScreenVideoParamVO;
|
|
|
import com.fdkankan.scene.vo.BaseDataParamVO;
|
|
|
import com.fdkankan.scene.vo.BaseFileParamVO;
|
|
|
+import com.fdkankan.scene.vo.BaseSceneParamVO;
|
|
|
import com.fdkankan.scene.vo.DeleteFileParamVO;
|
|
|
import com.fdkankan.scene.vo.DeleteLinkPanParamVO;
|
|
|
import com.fdkankan.scene.vo.DeleteLinkSceneStylesParamVO;
|
|
@@ -70,6 +100,9 @@ import com.fdkankan.scene.vo.SceneEditInfoVO;
|
|
|
import com.fdkankan.scene.vo.SceneInfoParamVO;
|
|
|
import com.fdkankan.scene.vo.SceneInfoVO;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
+import com.fdkankan.scene.vo.SurveillanceVO;
|
|
|
+import com.fdkankan.scene.vo.UploadPanoramaVO;
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.errorprone.annotations.Var;
|
|
|
import java.io.File;
|
|
@@ -86,6 +119,8 @@ import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
+import java.util.UUID;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -108,8 +143,13 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper, SceneEditInfo> implements ISceneEditInfoService {
|
|
|
|
|
|
@Value("${ecs.checkFile.maxTimes:5}")
|
|
|
+ @Value("${fyun.host}")
|
|
|
+ private String ossUrlPrefix;
|
|
|
+ @Value("${fyun.type}")
|
|
|
+ private String fyunType;
|
|
|
+ @Value("${ecs.checkFile.maxTimes:20}")
|
|
|
private int maxCheckTimes;
|
|
|
- @Value("${ecs.checkFile.waitTime:5000}")
|
|
|
+ @Value("${ecs.checkFile.waitTime:1000}")
|
|
|
private int waitTime;
|
|
|
|
|
|
@Autowired
|
|
@@ -135,6 +175,11 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
@Autowired
|
|
|
private ILaserService laserService;
|
|
|
|
|
|
+ private ICompanyService companyService;
|
|
|
+ @Autowired
|
|
|
+ private ISurveillanceService surveillanceService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneAsynOperLogService sceneAsynOperLogService;
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
@@ -239,6 +284,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
SceneJsonBean sceneJson = new SceneJsonBean();
|
|
|
BeanUtil.copyProperties(sceneEditInfoExt, sceneJson);
|
|
|
BeanUtil.copyProperties(sceneEditInfo, sceneJson);
|
|
|
+ sceneJson.setFloorPlanUpload(JSON.parseArray(sceneEditInfo.getFloorPlanUpload()));
|
|
|
SceneEditControlsVO sceneEditControlsVO = BeanUtil.copyProperties(sceneEditControls, SceneEditControlsVO.class);
|
|
|
sceneJson.setControls(sceneEditControlsVO);
|
|
|
sceneJson.setNum(num);
|
|
@@ -247,6 +293,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
sceneJson.setSceneResolution(scenePlusExt.getSceneResolution());
|
|
|
sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
|
|
|
sceneJson.setSceneKind(scenePlusExt.getSceneKind());
|
|
|
+ sceneJson.setModelKind(scenePlusExt.getModelKind());
|
|
|
if(StrUtil.isNotEmpty(scenePlusExt.getVideos())){
|
|
|
sceneJson.setVideos(scenePlusExt.getVideos());
|
|
|
}
|
|
@@ -260,6 +307,12 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
//发布场景关联相关数据
|
|
|
// this.publicLinkSceneData(num, bucket);
|
|
|
|
|
|
+ //发布滤镜数据
|
|
|
+ this.publicFilterData(num, sceneEditInfoExt.getFilters(), bucket);
|
|
|
+
|
|
|
+ //发布摄像头数据
|
|
|
+ this.publicSurveillance(num, sceneEditInfoExt.getSurveillances(), bucket);
|
|
|
+
|
|
|
//本地写sceneJson文件
|
|
|
String localSceneJsonPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "scene.json";
|
|
|
FileUtils.writeFile(localSceneJsonPath, JSON.toJSONString(sceneJson));
|
|
@@ -290,15 +343,55 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
|
|
|
sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
|
|
|
|
|
|
+ scenePlus.setTitle(sceneEditInfo.getTitle());
|
|
|
+ scenePlus.setDescription(sceneEditInfo.getDescription());
|
|
|
+ scenePlus.setHouseType(this.existsHouseType(bucket, num));
|
|
|
+ scenePlusService.updateById(scenePlus);
|
|
|
+
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
+ private int existsHouseType(String bucket, String num){
|
|
|
+ String houseTypePath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "houseType.json";
|
|
|
+ boolean exist = fYunFileService.fileExist(bucket, houseTypePath);
|
|
|
+ return exist ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void publicSurveillance(String num, Integer surveillances, String bucket) throws IOException {
|
|
|
+ String surveillanceJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "surveillance.json";
|
|
|
+ if(surveillances == CommonStatus.NO.code().intValue()){
|
|
|
+ fYunFileService.deleteFile(bucket, surveillanceJsonPath);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<SurveillanceVO> surveillanceList = surveillanceService.listSurveillance(num);
|
|
|
+ fYunFileService.uploadFile(bucket, JSON.toJSONString(surveillanceList).getBytes(StandardCharsets.UTF_8), surveillanceJsonPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void publicFilterData(String num, int filters, String bucket) throws IOException {
|
|
|
+
|
|
|
+ String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
|
|
|
+ if(filters == CommonStatus.NO.code()){
|
|
|
+ fYunFileService.deleteFile(bucket, userEditPath + "filter.json");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String key = String.format(RedisKey.SCENE_filter_DATA, num);
|
|
|
+ List<String> list = redisUtil.lGet(key, 0, -1);
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ list.stream().forEach(str->jsonArray.add(JSON.parseObject(str)));
|
|
|
+ fYunFileService.uploadFile(bucket, JSON.toJSONBytes(jsonArray), userEditPath + "filter.json");
|
|
|
+ }
|
|
|
+
|
|
|
public void publicLinkSceneData(String num, String bucket) throws IOException {
|
|
|
|
|
|
String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
|
String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
|
|
|
String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
|
|
|
+ //清除发布目录中的场景关联图片
|
|
|
+ if(fYunFileService.fileExist(bucket,imgViewPath + "panorama")){
|
|
|
+ fYunFileService.deleteFolder(bucket,imgViewPath + "panorama");
|
|
|
+ }
|
|
|
+
|
|
|
//生成links.json并上传到发布目录
|
|
|
String linkPanKey = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
|
|
|
Map<String, String> linkPanMap = redisUtil.hmget(linkPanKey);
|
|
@@ -321,23 +414,28 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
private void publicHotData(String sceneNum, SceneEditInfo sceneEditInfo, String bucket) throws IOException {
|
|
|
String hotDataKey = String.format(RedisKey.SCENE_HOT_DATA, sceneNum);
|
|
|
Map<String, String> hotMap = redisUtil.hmget(hotDataKey);
|
|
|
- List<String> hotList = Lists.newArrayList();
|
|
|
- hotMap.entrySet().stream().forEach(entry->{
|
|
|
- if(StrUtil.isNotEmpty(entry.getValue())){
|
|
|
- hotList.add(entry.getValue());
|
|
|
- }
|
|
|
- });
|
|
|
- if(CollUtil.isNotEmpty(hotList)){
|
|
|
- JSONArray jsonhots = new JSONArray();
|
|
|
- hotList.stream().forEach(hot->{
|
|
|
- jsonhots.add(JSONObject.parseObject(hot));
|
|
|
- });
|
|
|
- String hotJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, sceneNum) + "hot.json";
|
|
|
- ossUtil.uploadFileBytes(hotJsonPath, jsonhots.toString().getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
- //修改tags状态为是,标识有热点数据
|
|
|
- this.saveTagsToSceneEditInfo(sceneNum, sceneEditInfo);
|
|
|
+ JSONArray tags = new JSONArray();
|
|
|
+ if(CollUtil.isNotEmpty(hotMap)){
|
|
|
+ List<TagBean> tagBeanList = hotMap.entrySet().stream().map(entry -> {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(entry.getValue());
|
|
|
+ return TagBean.builder()
|
|
|
+ .createTime(jsonObject.getLong("createTime"))
|
|
|
+ .tag(jsonObject).build();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //按创建时间倒叙排序
|
|
|
+ tagBeanList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
|
|
|
+
|
|
|
+ //移除createTime字段
|
|
|
+ tagBeanList.stream().forEach(tagBean -> {
|
|
|
+ tags.add(tagBean.getTag());
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
+ String hotJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, sceneNum) + "hot.json";
|
|
|
+ ossUtil.uploadFileBytes(hotJsonPath, jsonhots.toString().getBytes(StandardCharsets.UTF_8));
|
|
|
+// this.saveTagsToSceneEditInfo(sceneNum, sceneEditInfo);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -364,6 +462,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
* @return com.fdkankan.scene.vo.SceneInfoVO
|
|
|
**/
|
|
|
private SceneInfoVO getSceneInfo4Edit(String num) throws Exception{
|
|
|
+
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
if(Objects.isNull(scenePlus)){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
@@ -379,6 +478,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
SceneInfoVO sceneInfoVO = new SceneInfoVO();
|
|
|
BeanUtil.copyProperties(sceneEditInfoExt, sceneInfoVO);
|
|
|
BeanUtil.copyProperties(sceneEditInfo, sceneInfoVO);
|
|
|
+ sceneInfoVO.setFloorPlanUpload(JSON.parseArray(sceneEditInfo.getFloorPlanUpload()));
|
|
|
if(Objects.isNull(sceneInfoVO.getFloorPlanAngle())){
|
|
|
sceneInfoVO.setFloorPlanAngle(0f);
|
|
|
}
|
|
@@ -392,12 +492,72 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
sceneInfoVO.setSceneResolution(scenePlusExt.getSceneResolution());
|
|
|
sceneInfoVO.setSceneFrom(scenePlusExt.getSceneFrom());
|
|
|
sceneInfoVO.setSceneKind(scenePlusExt.getSceneKind());
|
|
|
+ sceneInfoVO.setModelKind(scenePlusExt.getModelKind());
|
|
|
sceneInfoVO.setVideos(scenePlusExt.getVideos());
|
|
|
-// sceneInfoVO.setMosaicList(this.getMosaicList(num));
|
|
|
+ if(CommonStatus.YES.code().intValue() == sceneEditInfoExt.getMosaic()){
|
|
|
+ sceneInfoVO.setMosaicList(this.getMosaicList(num));
|
|
|
+ }
|
|
|
+
|
|
|
+ this.SortBoxVideos(sceneInfoVO);
|
|
|
|
|
|
return sceneInfoVO;
|
|
|
}
|
|
|
|
|
|
+ private void SortBoxVideos(SceneInfoVO sceneInfoVO){
|
|
|
+ String boxVideos = sceneInfoVO.getBoxVideos();
|
|
|
+ if(StrUtil.isEmpty(boxVideos)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray boxVideoArr = JSON.parseArray(boxVideos);
|
|
|
+ if(CollUtil.isEmpty(boxVideoArr)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<TagBean> tagBeanList = boxVideoArr.stream().map(o -> {
|
|
|
+ JSONObject item = (JSONObject) o;
|
|
|
+ return TagBean.builder()
|
|
|
+ .createTime(item.getLong("createTime"))
|
|
|
+ .tag(item).build();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //按创建时间倒叙排序
|
|
|
+ tagBeanList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
|
|
|
+
|
|
|
+ //移除createTime字段
|
|
|
+ List<JSONObject> boxVideoList = tagBeanList.stream().map(tagBean -> {
|
|
|
+ JSONObject tag = tagBean.getTag();
|
|
|
+ tag.remove("createTime");
|
|
|
+ return tag;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ sceneInfoVO.setBoxVideos(JSON.toJSONString(boxVideoList));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ getInfo接口返回字段扩展
|
|
|
+ * </p>
|
|
|
+ * @author dengsixing
|
|
|
+ * @date 2022/3/9
|
|
|
+ **/
|
|
|
+ private void setExtData(SceneInfoVO sceneInfoVO, Long cameraId) throws Exception{
|
|
|
+
|
|
|
+ if(Objects.isNull(cameraId)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ CameraDetail cameraDetail = cameraDetailService.findByCameraId(cameraId);
|
|
|
+ if(Objects.isNull(cameraDetail)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7010);
|
|
|
+ }
|
|
|
+ if(Objects.isNull(cameraDetail.getCompanyId())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Company company = companyService.getById(cameraDetail.getCompanyId());
|
|
|
+ if(Objects.isNull(company)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ sceneInfoVO.setDataSync(company.getDataSync());
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -436,6 +596,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
//如果redis没找到,从scene.json中获取
|
|
|
String objectName = String.format(ConstantFilePath.SCENE_VIEW_DATA_DATA_SCENEJSON, num);
|
|
|
String objectContent = ossUtil.getFileContent(objectName);
|
|
|
+ log.info("获取scene.json内容,path:{}, content:{}", objectName, objectContent);
|
|
|
if(StrUtil.isEmpty(objectContent))
|
|
|
return null;
|
|
|
sceneInfoVO = JSON.parseObject(objectContent, SceneInfoVO.class);
|
|
@@ -477,14 +638,16 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
//处理户型图数据
|
|
|
//上传floorplan_user.json文件
|
|
|
FileUtils.writeFile(localDataPath + "floorplan_user.json", floorJsonData);
|
|
|
- ossUtil.uploadFile(editUserPath + "floorplan_user.json", localDataPath + "floorplan_user.json", false);
|
|
|
+ ossUtil.uploadFile(editUserPath + "floorplan_user.json", localDataPath + "floorplan.json", false);
|
|
|
|
|
|
//写入数据库
|
|
|
Byte floorPlanUser = null;
|
|
|
if(StrUtil.isNotEmpty(floorJsonData)){
|
|
|
JSONObject houseTypeJson = CreateHouseJsonUtil
|
|
|
.createHouseTypeJsonByUser(localDataPath + "floorplan_user.json");
|
|
|
- ossUtil.uploadFileBytes(editUserPath + "houseType.json", houseTypeJson.toJSONString().getBytes(StandardCharsets.UTF_8));
|
|
|
+ if(Objects.nonNull(houseTypeJson)) {
|
|
|
+ ossUtil.uploadFileBytes(editUserPath + "houseType.json", houseTypeJson.toJSONString().getBytes(StandardCharsets.UTF_8));
|
|
|
+ }
|
|
|
|
|
|
floorPlanUser = CommonStatus.YES.code();
|
|
|
}
|
|
@@ -773,9 +936,11 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
String sceneJson = redisUtil.get(key);
|
|
|
if(StrUtil.isNotEmpty(sceneJson)){
|
|
|
SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
|
|
|
- sceneJsonBean.setVersion(version);
|
|
|
+ if(Objects.nonNull(version)){
|
|
|
+ sceneJsonBean.setVersion(version);
|
|
|
+ }
|
|
|
if(Objects.nonNull(imgVersion)){
|
|
|
- sceneJsonBean.setImgVersion(imgVersion + 1);
|
|
|
+ sceneJsonBean.setImgVersion(imgVersion);
|
|
|
}
|
|
|
redisUtil.set(key, JSON.toJSONString(sceneJsonBean));
|
|
|
}
|
|
@@ -785,9 +950,11 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
sceneJson = ossUtil.getFileContent(sceneJsonPath);
|
|
|
if(StrUtil.isNotEmpty(sceneJson)){
|
|
|
SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
|
|
|
- sceneJsonBean.setVersion(version);
|
|
|
+ if(Objects.nonNull(version)){
|
|
|
+ sceneJsonBean.setVersion(version);
|
|
|
+ }
|
|
|
if(Objects.nonNull(imgVersion)){
|
|
|
- sceneJsonBean.setImgVersion(imgVersion + 1);
|
|
|
+ sceneJsonBean.setImgVersion(imgVersion);
|
|
|
}
|
|
|
ossUtil.uploadFileBytes(sceneJsonPath, JSON.toJSONString(sceneJsonBean).getBytes(StandardCharsets.UTF_8));
|
|
|
}
|
|
@@ -1556,6 +1723,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
if(exist){
|
|
|
return;
|
|
|
}
|
|
|
+// String uuid = cn.hutool.core.lang.UUID.randomUUID().toString();
|
|
|
String lockKey = String.format(RedisLockKey.LOCK_MOSAIC_DATA_SYNC, num);
|
|
|
boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
if(!lock){
|
|
@@ -1566,8 +1734,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
if(exist){
|
|
|
return;
|
|
|
}
|
|
|
- String filePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
|
|
|
- String mosaicData = FileUtils.readFile(filePath + "mosaic.json");
|
|
|
+ String filePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "mosaic.json";
|
|
|
+ String mosaicData = FileUtils.readUtf8String(filePath);
|
|
|
if(StrUtil.isEmpty(mosaicData)){
|
|
|
return;
|
|
|
}
|
|
@@ -1606,16 +1774,16 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
jsonArr.add(JSONObject.parseObject(mosaic));
|
|
|
});
|
|
|
|
|
|
-
|
|
|
+ String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
|
|
|
String lockKey = String.format(RedisLockKey.LOCK_MOSAIC_JSON, num);
|
|
|
- boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
+ boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
if(!lock){
|
|
|
return;
|
|
|
}
|
|
|
try{
|
|
|
FileUtils.writeFile(mosaicPath, jsonArr.toJSONString());
|
|
|
}finally {
|
|
|
- redisLockUtil.unlockLua(lockKey);
|
|
|
+ redisLockUtil.unlockLua(lockKey, lockVal);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1833,14 +2001,19 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
List<String> deletDataList = redisUtil.hMultiGet(key, deleteSidList);
|
|
|
if(CollUtil.isEmpty(deletDataList))
|
|
|
return;
|
|
|
+ List<String> thumbNameList = deleteSidList.stream().map(sid -> {
|
|
|
+ String linkPan = redisUtil.hget(key, sid);
|
|
|
+ JSONObject linkPanObj = JSON.parseObject(linkPan);
|
|
|
+ return FileUtil.getPrefix(linkPanObj.getString("thumb"));
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
//从redis中移除热点数据
|
|
|
redisUtil.hdel(key, deleteSidList.toArray());
|
|
|
|
|
|
//删除oss文件
|
|
|
String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
|
- deleteSidList.stream().forEach(sid->{
|
|
|
- ossUtil.deleteObject(imgEditPath + "panorama_edit/" + sid);
|
|
|
+ thumbNameList.stream().forEach(thumbName->{
|
|
|
+ ossUtil.deleteObject(imgEditPath + "panorama_edit/" + thumbName);
|
|
|
});
|
|
|
|
|
|
}
|
|
@@ -1994,15 +2167,16 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
jsonObject.put("styles", styleList);
|
|
|
|
|
|
String linkScenePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "links.json";
|
|
|
+ String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
|
|
|
String lockKey = String.format(RedisLockKey.LOCK_LINK_SCENE_JSON, num);
|
|
|
- boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
+ boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
if(!lock){
|
|
|
return;
|
|
|
}
|
|
|
try{
|
|
|
cn.hutool.core.io.FileUtil.writeUtf8String(jsonObject.toJSONString(), linkScenePath);
|
|
|
}finally {
|
|
|
- redisLockUtil.unlockLua(lockKey);
|
|
|
+ redisLockUtil.unlockLua(lockKey, lockVal);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2043,7 +2217,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
return;
|
|
|
}
|
|
|
String lockKey = String.format(RedisLockKey.LOCK_LINKPAN_STYLES_SYNC, num);
|
|
|
- boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
+ String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
|
|
|
+ boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
if(!lock){
|
|
|
throw new BusinessException(ErrorCode.SYSTEM_BUSY);
|
|
|
}
|
|
@@ -2053,7 +2228,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
return;
|
|
|
}
|
|
|
String linkSceneFilePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
|
|
|
- String linkSceneData = FileUtils.readFile(linkSceneFilePath + "links.json");
|
|
|
+ String linkSceneData = FileUtils.readUtf8String(linkSceneFilePath + "links.json");
|
|
|
if(StrUtil.isEmpty(linkSceneData)){
|
|
|
return;
|
|
|
}
|
|
@@ -2070,7 +2245,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
redisUtil.hmset(key, styleMap);
|
|
|
}finally {
|
|
|
- redisLockUtil.unlockLua(lockKey);
|
|
|
+ redisLockUtil.unlockLua(lockKey, lockVal);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -2104,7 +2279,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
return;
|
|
|
}
|
|
|
String lockKey = String.format(RedisLockKey.LOCK_LINKPAN_DATA_SYNC, num);
|
|
|
- boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
+ String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
|
|
|
+ boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
if(!lock){
|
|
|
throw new BusinessException(ErrorCode.SYSTEM_BUSY);
|
|
|
}
|
|
@@ -2114,7 +2290,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
return;
|
|
|
}
|
|
|
String linkSceneFilePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
|
|
|
- String linkSceneData = FileUtils.readFile(linkSceneFilePath + "links.json");
|
|
|
+ String linkSceneData = FileUtils.readUtf8String(linkSceneFilePath + "links.json");
|
|
|
if(StrUtil.isEmpty(linkSceneData)){
|
|
|
return;
|
|
|
}
|
|
@@ -2130,7 +2306,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
redisUtil.hmset(key, map);
|
|
|
}finally {
|
|
|
- redisLockUtil.unlockLua(lockKey);
|
|
|
+ redisLockUtil.unlockLua(lockKey, lockVal);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2186,11 +2362,23 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}else {
|
|
|
boxVideosJson = new JSONArray();
|
|
|
}
|
|
|
+ if(boxVideosJson.size() > 0){
|
|
|
+ int i = 1;
|
|
|
+ long timeInMillis = Calendar.getInstance().getTimeInMillis();
|
|
|
+ for (Object o : boxVideosJson) {
|
|
|
+ JSONObject item = (JSONObject)o;
|
|
|
+ if(Objects.nonNull(item.getLong("createTime"))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ item.put("createTime", timeInMillis - (i++));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
String result = null;
|
|
|
//删除
|
|
|
if(type == OperationType.DELETE.code()){
|
|
|
- Set<String> deleteFile = new HashSet<>();
|
|
|
+ Set<String> deleteVidoeFile = new HashSet<>();
|
|
|
+ Set<String> deletePicFile = new HashSet<>();
|
|
|
if(boxVideosJson.size() == 0)
|
|
|
return null;
|
|
|
for(int i=0;i<boxVideosJson.size();++i){
|
|
@@ -2199,11 +2387,11 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
String poster = ele.getString("poster");
|
|
|
if(StrUtil.isNotEmpty(poster))
|
|
|
- deleteFile.add(poster);
|
|
|
+ deletePicFile.add(poster);
|
|
|
String url = ele.getString("url");
|
|
|
if(StrUtil.isNotEmpty(url)){
|
|
|
- deleteFile.add(url);
|
|
|
- deleteFile.add(url.replace(".mp4",".flv"));
|
|
|
+ deleteVidoeFile.add(url);
|
|
|
+ deleteVidoeFile.add(url.replace(".mp4",".flv"));
|
|
|
}
|
|
|
|
|
|
boxVideosJson.remove(i);
|
|
@@ -2211,27 +2399,34 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
//删除资源文件
|
|
|
- if(CollUtil.isNotEmpty(deleteFile))
|
|
|
+ if(CollUtil.isNotEmpty(deleteVidoeFile))
|
|
|
sceneUploadService.delete(
|
|
|
DeleteFileParamVO.builder().num(num)
|
|
|
.bizType(FileBizType.BOX_VIDEO.code())
|
|
|
- .fileNames(new ArrayList<>(deleteFile)).build());
|
|
|
+ .fileNames(new ArrayList<>(deleteVidoeFile)).build());
|
|
|
+ //删除资源文件
|
|
|
+ if(CollUtil.isNotEmpty(deleteVidoeFile))
|
|
|
+ sceneUploadService.delete(
|
|
|
+ DeleteFileParamVO.builder().num(num)
|
|
|
+ .bizType(FileBizType.BOX_POSTER.code())
|
|
|
+ .fileNames(new ArrayList<>(deletePicFile)).build());
|
|
|
}else{
|
|
|
|
|
|
- // -: 2022/3/1 目前需求只保留一个,所以这里先注释掉,sid不同时,不追加
|
|
|
+ boxVideo.put("createTime", Calendar.getInstance().getTimeInMillis());
|
|
|
+
|
|
|
//更新
|
|
|
-// boolean exist = false;
|
|
|
-// for(int i=0;i<boxVideosJson.size();++i){
|
|
|
-// JSONObject ele = boxVideosJson.getJSONObject(i);
|
|
|
-// if(ele.getString("sid").equals(sid)){
|
|
|
-// boxVideosJson.set(i, boxVideo);
|
|
|
-// exist = true;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// //新增
|
|
|
-// if(!exist){
|
|
|
-// boxVideosJson.add(boxVideo);
|
|
|
-// }
|
|
|
+ boolean exist = false;
|
|
|
+ for(int i=0;i<boxVideosJson.size();++i){
|
|
|
+ JSONObject ele = boxVideosJson.getJSONObject(i);
|
|
|
+ if(ele.getString("sid").equals(sid)){
|
|
|
+ boxVideosJson.set(i, boxVideo);
|
|
|
+ exist = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //新增
|
|
|
+ if(!exist){
|
|
|
+ boxVideosJson.add(boxVideo);
|
|
|
+ }
|
|
|
|
|
|
boxVideosJson.clear();
|
|
|
boxVideosJson.add(boxVideo);
|
|
@@ -2426,4 +2621,111 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData saveFilter(SaveFiltersParamVO param) throws Exception {
|
|
|
+
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = String.format(RedisKey.SCENE_filter_DATA, param.getNum());
|
|
|
+ JSONArray filterArr = JSON.parseArray(param.getData());
|
|
|
+ int filters = CommonStatus.YES.code();
|
|
|
+ if(CollUtil.isEmpty(filterArr)){
|
|
|
+ filters = CommonStatus.NO.code();
|
|
|
+ redisUtil.del(key);
|
|
|
+ }else{
|
|
|
+ List<String> filterList = filterArr.stream().map(item->JSON.toJSONString(item)).collect(Collectors.toList());
|
|
|
+ redisUtil.lRightPushAll(key, filterList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //写本地文件,作为备份
|
|
|
+ this.writeFilter(param.getNum());
|
|
|
+
|
|
|
+ //如果页面选择恢复默认,filters字段值为否
|
|
|
+ if(Objects.nonNull(param.getReset()) && param.getReset() == CommonStatus.YES.code().intValue()){
|
|
|
+ filters = CommonStatus.NO.code();
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新数据库
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByScenePlusId(scenePlus.getId());
|
|
|
+ sceneEditInfoExt.setFilters(filters);
|
|
|
+ sceneEditInfoExtService.updateById(sceneEditInfoExt);
|
|
|
+
|
|
|
+ return ResultData.ok();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void writeFilter(String num) throws Exception{
|
|
|
+
|
|
|
+ String filterPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "filter.json";
|
|
|
+
|
|
|
+ String key = String.format(RedisKey.SCENE_filter_DATA, num);
|
|
|
+ List<String> filters = redisUtil.lGet(key, 0, -1);
|
|
|
+ if(CollUtil.isEmpty(filters)){
|
|
|
+ FileUtils.deleteFile(filterPath);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String lockKey = String.format(RedisLockKey.LOCK_filter_JSON, num);
|
|
|
+ String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
|
|
|
+ boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
+ if(!lock){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ FileUtils.writeFile(filterPath, JSON.toJSONString(filters));
|
|
|
+ }finally {
|
|
|
+ redisLockUtil.unlockLua(lockKey, lockVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void syncFiltersFromFileToRedis(String num) throws Exception{
|
|
|
+
|
|
|
+ String key = String.format(RedisKey.SCENE_filter_DATA, num);
|
|
|
+ boolean exist = redisUtil.hasKey(key);
|
|
|
+ if(exist){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String lockKey = String.format(RedisLockKey.LOCK_FILTER_DATA_SYNC, num);
|
|
|
+ String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
|
|
|
+ boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
|
|
|
+ if(!lock){
|
|
|
+ throw new BusinessException(ErrorCode.SYSTEM_BUSY);
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ exist = redisUtil.hasKey(key);
|
|
|
+ if(exist){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String filePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
|
|
|
+ String filterData = FileUtils.readUtf8String(filePath + "filter.json");
|
|
|
+ if(StrUtil.isEmpty(filterData)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = JSON.parseArray(filterData);
|
|
|
+ if(CollUtil.isEmpty(jsonArray)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ redisUtil.lRightPushAll(key, jsonArray.stream().collect(Collectors.toList()));
|
|
|
+ }finally {
|
|
|
+ redisLockUtil.unlockLua(lockKey, lockVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData listFilter(BaseSceneParamVO param) throws Exception {
|
|
|
+
|
|
|
+ //同步数据
|
|
|
+ this.syncFiltersFromFileToRedis(param.getNum());
|
|
|
+
|
|
|
+ //查询redis
|
|
|
+ String key = String.format(RedisKey.SCENE_filter_DATA, param.getNum());
|
|
|
+ List<String> list = redisUtil.lGet(key, 0, -1);
|
|
|
+ List<JSONObject> collect =
|
|
|
+ list.stream().map(str -> JSON.parseObject(str)).collect(Collectors.toList());
|
|
|
+ return ResultData.ok(collect);
|
|
|
+ }
|
|
|
}
|