|
@@ -29,8 +29,8 @@ import com.fdkankan.common.util.FileMd5Util;
|
|
|
import com.fdkankan.common.util.FileUtil;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.common.util.SceneUtil;
|
|
|
-import com.fdkankan.fyun.constant.StorageType;
|
|
|
-import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
|
+import com.fdkankan.fyun.constant.FYunTypeEnum;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.constant.RedisLockKey;
|
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
@@ -124,35 +124,21 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
@Service
|
|
|
public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper, SceneEditInfo> implements ISceneEditInfoService {
|
|
|
|
|
|
- @Value("${oss.prefix.ali}")
|
|
|
- private String prefixAli;
|
|
|
- @Value("${oss.prefix.url}")
|
|
|
+ @Value("${fyun.host}")
|
|
|
private String ossUrlPrefix;
|
|
|
- @Value("${upload.type}")
|
|
|
- private String type;
|
|
|
- @Value("${oss.bucket:4dkankan}")
|
|
|
- private String bucket;
|
|
|
- @Value("${main.url}")
|
|
|
- private String mainUrl;
|
|
|
+ @Value("${fyun.type}")
|
|
|
+ private String fyunType;
|
|
|
@Value("${ecs.checkFile.maxTimes:5}")
|
|
|
private int maxCheckTimes;
|
|
|
@Value("${ecs.checkFile.waitTime:5000}")
|
|
|
private int waitTime;
|
|
|
- @Value("${http.host.4dkankanMini}")
|
|
|
- private String fkankanMiniHost;
|
|
|
- @Value("${http.api-v4.getDataSyncByCameraId}")
|
|
|
- private String URL_GET_DATASYNC_BY_CAMERAID;
|
|
|
- @Value("${http.api-v4.getSceneProByNum}")
|
|
|
- private String URL_GET_SCENEPRO_BY_NUM;
|
|
|
- @Value("${http.api-v4.upgradeToV4ResultSync}")
|
|
|
- private String URL_UPGRADE_TO_V4_RESULT_SYNC;
|
|
|
|
|
|
@Autowired
|
|
|
private ISceneEditControlsService sceneEditControlsService;
|
|
|
@Autowired
|
|
|
private ISceneProService sceneProService;
|
|
|
@Autowired
|
|
|
- private UploadToOssUtil uploadToOssUtil;
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
@Autowired
|
|
|
RedisUtil redisUtil;
|
|
|
@Autowired
|
|
@@ -266,6 +252,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
sceneEditInfoExt.setFloorPlanAngle(0f);
|
|
|
sceneEditInfoExt.setFloorPlanCompass(0f);
|
|
|
}
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
|
|
//生成sceneJson
|
|
|
SceneJsonBean sceneJson = new SceneJsonBean();
|
|
@@ -287,17 +274,17 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
sceneJson.setMosaicList(this.getMosaicList(num));
|
|
|
|
|
|
//处理热点数据,生成hot.json
|
|
|
- this.publicHotData(num, sceneEditInfo);
|
|
|
+ this.publicHotData(num, sceneEditInfo, bucket);
|
|
|
|
|
|
//发布场景关联相关数据
|
|
|
- this.publicLinkSceneData(num);
|
|
|
+ this.publicLinkSceneData(num, bucket);
|
|
|
|
|
|
//本地写sceneJson文件
|
|
|
String localSceneJsonPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "scene.json";
|
|
|
FileUtils.writeFile(localSceneJsonPath, JSON.toJSONString(sceneJson));
|
|
|
//上传sceneJson文件
|
|
|
String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH+"scene.json", num);
|
|
|
- uploadToOssUtil.upload(JSON.toJSONBytes(sceneJson), sceneJsonPath);
|
|
|
+ fYunFileService.uploadFile(bucket, JSON.toJSONBytes(sceneJson), sceneJsonPath);
|
|
|
|
|
|
//sceneJson放入缓存
|
|
|
String key = String.format(RedisKey.SCENE_JSON, num);
|
|
@@ -305,12 +292,12 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
//删除发布数据中的user目录
|
|
|
String publicUserPath = String.format(UploadFilePath.USER_VIEW_PATH, num);
|
|
|
- uploadToOssUtil.deleteFile(publicUserPath);
|
|
|
+ fYunFileService.deleteFile(bucket, publicUserPath);
|
|
|
|
|
|
//复制编辑目录到发布目录
|
|
|
String editPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum());
|
|
|
String viewPath = String.format(UploadFilePath.USER_VIEW_PATH, param.getNum());
|
|
|
- uploadToOssUtil.copyFiles(editPath,viewPath);
|
|
|
+ fYunFileService.copyFileBetweenBucket(bucket, editPath, bucket, viewPath);
|
|
|
|
|
|
//入库
|
|
|
if(sceneEditInfo.getId() == null){
|
|
@@ -325,7 +312,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
- public void publicLinkSceneData(String num) throws IOException {
|
|
|
+ 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);
|
|
@@ -342,15 +329,15 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
linkPanArr.add(JSON.parseObject(linkPan));
|
|
|
});
|
|
|
String linkScenePath = userEditPath + "links.json";
|
|
|
- uploadToOssUtil.upload(linkPanArr.toString().getBytes(), linkScenePath);
|
|
|
+ fYunFileService.uploadFile(bucket, linkPanArr.toString().getBytes(), linkScenePath);
|
|
|
|
|
|
//拷贝编辑目录到发布目录
|
|
|
- uploadToOssUtil.deleteFile(imgViewPath + "panorama");
|
|
|
- uploadToOssUtil.copyFiles(imgEditPath + "panorama",imgViewPath + "panorama");
|
|
|
+ fYunFileService.deleteFile(bucket,imgViewPath + "panorama");
|
|
|
+ fYunFileService.copyFileBetweenBucket(bucket, imgEditPath + "panorama", bucket, imgViewPath + "panorama");
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void publicHotData(String sceneNum, SceneEditInfo sceneEditInfo) throws IOException {
|
|
|
+ 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();
|
|
@@ -365,7 +352,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
jsonhots.add(JSONObject.parseObject(hot));
|
|
|
});
|
|
|
String hotJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, sceneNum) + "hot.json";
|
|
|
- uploadToOssUtil.upload(jsonhots.toString().getBytes(), hotJsonPath);
|
|
|
+ fYunFileService.uploadFile(bucket, jsonhots.toString().getBytes(), hotJsonPath);
|
|
|
|
|
|
//修改tags状态为是,标识有热点数据
|
|
|
this.saveTagsToSceneEditInfo(sceneNum, sceneEditInfo);
|
|
@@ -472,6 +459,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
//校验场景是否为空、封存、计算中
|
|
|
ScenePlus scenePlus = scenePlusService.checkSceneAvail(num);
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
|
|
|
//访问量+1
|
|
|
scenePlusService.updateViewCount(num);
|
|
@@ -494,7 +482,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
//如果redis没找到,从scene.json中获取
|
|
|
String objectName = String.format(ConstantFilePath.SCENE_VIEW_DATA_DATA_SCENEJSON, num);
|
|
|
- String objectContent = uploadToOssUtil.getObjectContent(bucket, objectName);
|
|
|
+ String objectContent = fYunFileService.getFileContent(scenePlusExt.getYunFileBucket(), objectName);
|
|
|
if(StrUtil.isEmpty(objectContent))
|
|
|
return null;
|
|
|
sceneInfoVO = JSON.parseObject(objectContent, SceneInfoVO.class);
|
|
@@ -514,11 +502,12 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
public ResultData saveCad(BaseDataParamVO param) throws Exception {
|
|
|
|
|
|
String num = param.getNum();
|
|
|
-// ScenePro scenePro = sceneProService.findBySceneNum(num);
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
if(Objects.isNull(scenePlus))
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
String editUserPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
|
|
|
String localDataPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
|
|
|
|
|
@@ -535,14 +524,14 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
//处理户型图数据
|
|
|
//上传floorplan_user.json文件
|
|
|
FileUtils.writeFile(localDataPath + "floorplan_user.json", floorJsonData);
|
|
|
- uploadToOssUtil.upload(localDataPath + "floorplan_user.json", editUserPath + "floorplan_user.json");
|
|
|
+ fYunFileService.uploadFile(bucket, localDataPath + "floorplan_user.json", editUserPath + "floorplan_user.json");
|
|
|
|
|
|
//写入数据库
|
|
|
Byte floorPlanUser = null;
|
|
|
if(StrUtil.isNotEmpty(floorJsonData)){
|
|
|
JSONObject houseTypeJson = CreateHouseJsonUtil
|
|
|
.createHouseTypeJsonByUser(localDataPath + "floorplan_user.json");
|
|
|
- uploadToOssUtil.upload(houseTypeJson.toJSONString().getBytes(), editUserPath + "houseType.json");
|
|
|
+ fYunFileService.uploadFile(bucket, houseTypeJson.toJSONString().getBytes(), editUserPath + "houseType.json");
|
|
|
|
|
|
floorPlanUser = CommonStatus.YES.code();
|
|
|
}
|
|
@@ -588,6 +577,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService
|
|
|
.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
String path = scenePlusExt.getDataSource();
|
|
|
|
|
|
//户型图上传
|
|
@@ -599,12 +589,12 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
String substring = str.substring(str.lastIndexOf(File.separator) + 1);
|
|
|
String[] arr = substring.split("floor");
|
|
|
String[] arr2 = arr[1].split("\\.");
|
|
|
- uploadToOssUtil.upload(str, String.format(userEditPath, num, arr2[0], arr2[1]));
|
|
|
+ fYunFileService.uploadFile(bucket, str, String.format(userEditPath, num, arr2[0], arr2[1]));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//根据floorplan_cad.json生成houseType.json
|
|
|
- this.uploadHouseTypeJson(num);
|
|
|
+ this.uploadHouseTypeJson(num, bucket);
|
|
|
|
|
|
SceneEditInfo sceneEditInfoDb = this.getByScenePlusId(scenePlus.getId());
|
|
|
SceneEditInfoExt sceneEditInfoExt = null;
|
|
@@ -635,14 +625,14 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void uploadHouseTypeJson(String num) throws IOException {
|
|
|
+ private void uploadHouseTypeJson(String num, String bucket) throws IOException {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("name", "houseType.json");
|
|
|
result.put("version", "2.1");
|
|
|
|
|
|
String floorplanCadPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan_cad.json";
|
|
|
- String floorcadStr = uploadToOssUtil.getObjectContent(this.bucket, floorplanCadPath);
|
|
|
+ String floorcadStr = fYunFileService.getFileContent(bucket, floorplanCadPath);
|
|
|
|
|
|
JSONObject floorcadObj = JSON.parseObject(floorcadStr);
|
|
|
JSONArray floors = floorcadObj.getJSONArray("floors");
|
|
@@ -661,7 +651,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
String hourseTypeJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "houseType.json";
|
|
|
- uploadToOssUtil.upload(result.toJSONString().getBytes(), hourseTypeJsonPath);
|
|
|
+ fYunFileService.uploadFile(bucket, result.toJSONString().getBytes(), hourseTypeJsonPath);
|
|
|
}
|
|
|
|
|
|
private JSONArray[] createHouseTypeJsonHandler(JSONObject floor){
|
|
@@ -744,8 +734,15 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
@Override
|
|
|
public ResultData renameCad(RenameCadParamVO param) throws IOException {
|
|
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ }
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
+
|
|
|
String key = String.format(UploadFilePath.DATA_VIEW_PATH, param.getNum()) + "floorplan_cad.json";
|
|
|
- String floorplanCadJson = uploadToOssUtil.getObjectContent(this.bucket, key);
|
|
|
+ String floorplanCadJson = fYunFileService.getFileContent(bucket, key);
|
|
|
if(StrUtil.isEmpty(floorplanCadJson)){
|
|
|
return ResultData.ok();
|
|
|
}
|
|
@@ -770,7 +767,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
item.put("name", name);
|
|
|
}
|
|
|
- uploadToOssUtil.upload(jsonObject.toJSONString().getBytes(), key);
|
|
|
+ fYunFileService.uploadFile(bucket, jsonObject.toJSONString().getBytes(), key);
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
@@ -810,7 +807,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void upgradeSceneJsonVersion(String num, int version, Integer imgVersion) throws IOException {
|
|
|
+ public void upgradeSceneJsonVersion(String num, int version, Integer imgVersion, String bucket) throws IOException {
|
|
|
|
|
|
//更新redis缓存版本号
|
|
|
String key = String.format(RedisKey.SCENE_JSON, num);
|
|
@@ -826,14 +823,14 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
//更新oss scene.json版本号
|
|
|
String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
|
|
|
- sceneJson= uploadToOssUtil.getObjectContent(this.bucket, sceneJsonPath);
|
|
|
+ sceneJson= fYunFileService.getFileContent(bucket, sceneJsonPath);
|
|
|
if(StrUtil.isNotEmpty(sceneJson)){
|
|
|
SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
|
|
|
sceneJsonBean.setVersion(version);
|
|
|
if(Objects.nonNull(imgVersion)){
|
|
|
sceneJsonBean.setImgVersion(imgVersion + 1);
|
|
|
}
|
|
|
- uploadToOssUtil.upload(JSON.toJSONString(sceneJsonBean).getBytes(StandardCharsets.UTF_8), sceneJsonPath);
|
|
|
+ fYunFileService.uploadFile(bucket, JSON.toJSONString(sceneJsonBean).getBytes(StandardCharsets.UTF_8), sceneJsonPath);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -849,8 +846,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
if(scenePlus == null){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
}
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService
|
|
|
- .getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
|
|
//原始计算根目录
|
|
|
// String path = "F:\\test";
|
|
@@ -942,8 +939,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
|
String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
- FileUtils.downLoadFromUrl(ossUrlPrefix + imgViewPath + "vision.modeldata" + "?m="+new Date().getTime(),
|
|
|
- "vision.modeldata", target + File.separator + "extras" + File.separator);
|
|
|
+ fYunFileService.downloadFile(bucket, imgViewPath + "vision.modeldata", target + File.separator + "extras" + File.separator + "vision.modeldata");
|
|
|
CreateObjUtil.convertVisionmodeldataToTxt(target + File.separator + "extras" + File.separator + "vision.modeldata",
|
|
|
target + File.separator + "extras" + File.separator + "vision.txt");
|
|
|
|
|
@@ -982,7 +978,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
if(new File(target + File.separator + "results").exists()){
|
|
|
FileUtils.delAllFile(target + File.separator + "results");
|
|
|
}
|
|
|
- if(StorageType.AWS.code().equals(this.type)){
|
|
|
+ if(FYunTypeEnum.AWS.code().equals(fyunType)){
|
|
|
//亚马逊保持旧方式,超链接capture
|
|
|
CreateObjUtil.createSoftConnection(path + File.separator + "capture", target + File.separator + "capture");
|
|
|
}
|
|
@@ -1045,7 +1041,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
}
|
|
|
if(map.size()>0) {
|
|
|
- uploadToOssUtil.uploadMulFiles(map);
|
|
|
+ fYunFileService.uploadMulFiles(bucket, map);
|
|
|
}
|
|
|
|
|
|
//拷贝修改后的全景图到缓存目录
|
|
@@ -1058,7 +1054,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
|
this.upgradeVersionAndImgVersionById(sceneEditInfo.getId());
|
|
|
//更新scenejson缓存和oss文件版本号
|
|
|
- this.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1);
|
|
|
+ this.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1, bucket);
|
|
|
|
|
|
//如果部分成功,则需要返回成功数量和失败列表
|
|
|
if(CollUtil.isNotEmpty(notExistFileList)){
|
|
@@ -1084,6 +1080,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
}
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
String path = scenePlusExt.getDataSource();
|
|
|
|
|
|
String cachePath = String.format(ConstantFilePath.SCENE_CACHE, num);
|
|
@@ -1103,9 +1100,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
if(!cn.hutool.core.io.FileUtil.exist(localFilePath)){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
|
|
|
}
|
|
|
- uploadToOssUtil.upload(localFilePath, ossFilePath);
|
|
|
+ fYunFileService.uploadFile(bucket, localFilePath, ossFilePath);
|
|
|
url = ossUrlPrefix + ossFilePath;
|
|
|
-// FileUtils.downLoadFromUrl(imageUrl, fileName, localImagesPath);
|
|
|
downloadName = fileName;
|
|
|
}else{
|
|
|
if(!cn.hutool.core.io.FileUtil.exist(localImagesPath)
|
|
@@ -1121,7 +1117,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
long end1 = Calendar.getInstance().getTimeInMillis();
|
|
|
log.info("打包耗时:" + (end1 - start));
|
|
|
//上传压缩包
|
|
|
- uploadToOssUtil.uploadBySh(zipPath, String.format(cacheFormat, num) + downloadName);
|
|
|
+ fYunFileService.uploadFileByCommand(bucket, zipPath, String.format(cacheFormat, num) + downloadName);
|
|
|
url = ossUrlPrefix + String.format(cacheFormat, num) + downloadName;
|
|
|
long end2 = Calendar.getInstance().getTimeInMillis();
|
|
|
log.info("上传耗时:" + (end2 - end1));
|
|
@@ -1170,11 +1166,13 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
|
if(Objects.isNull(scenePlus))
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
|
|
SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
|
|
|
|
//转换视频格式
|
|
|
- this.transferToFlv(param.getNum(), param.getFileName());
|
|
|
+ this.transferToFlv(param.getNum(), param.getFileName(), bucket);
|
|
|
|
|
|
//生成boxVideos数据
|
|
|
String boxVideos = this.createBoxVideos(param.getNum(), sid, boxVideo, sceneEditInfo, OperationType.ADDORUPDATE.code());
|
|
@@ -1268,6 +1266,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
}
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
|
|
String path = scenePlusExt.getDataSource();
|
|
|
//校验文件名
|
|
@@ -1313,12 +1312,12 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
for(String videoName : video.list()){
|
|
|
log.info("球幕视频名称:{}", videoName);
|
|
|
- uploadToOssUtil.upload(target + File.separator + "extras/video/" + videoName,videosViewPath + videoName);
|
|
|
+ fYunFileService.uploadFile(bucket, target + File.separator + "extras/video/" + videoName,videosViewPath + videoName);
|
|
|
|
|
|
CreateObjUtil.mp4ToFlv(target + File.separator + "extras/video/" + videoName,
|
|
|
target + File.separator + "extras/video/" + videoName.replace("mp4", "flv"));
|
|
|
|
|
|
- uploadToOssUtil.upload(target + File.separator + "extras/video/" + videoName.replace("mp4", "flv"),videosViewPath + videoName.replace("mp4", "flv"));
|
|
|
+ fYunFileService.uploadFile(bucket, target + File.separator + "extras/video/" + videoName.replace("mp4", "flv"),videosViewPath + videoName.replace("mp4", "flv"));
|
|
|
|
|
|
//覆盖原始视频资源
|
|
|
FileUtils.copyFile(target + File.separator + "extras/video/" + videoName,
|
|
@@ -1330,22 +1329,20 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
|
this.upgradeVersionById(sceneEditInfo.getId());
|
|
|
|
|
|
- //更新scene.json版本号
|
|
|
-// this.upgradeVersionToSceneJson(num);
|
|
|
//更新scenejson缓存和oss文件版本号
|
|
|
- this.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, null);
|
|
|
+ this.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, null, bucket);
|
|
|
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void upgradeVersionToSceneJson(String num) throws Exception{
|
|
|
+ public void upgradeVersionToSceneJson(String num, String bucket) throws Exception{
|
|
|
String key = String.format(RedisKey.SCENE_JSON, num);
|
|
|
String objectName = String.format(ConstantFilePath.SCENE_VIEW_DATA_DATA_SCENEJSON, num);
|
|
|
- String objectContent = uploadToOssUtil.getObjectContent(bucket, objectName);
|
|
|
+ String objectContent = fYunFileService.getFileContent(bucket, objectName);
|
|
|
SceneJsonBean sceneJsonBean = JSON.parseObject(objectContent, SceneJsonBean.class);
|
|
|
sceneJsonBean.setVersion(sceneJsonBean.getVersion() +1);
|
|
|
- uploadToOssUtil.upload(JSON.toJSONString(sceneJsonBean).getBytes(), objectName);
|
|
|
+ fYunFileService.uploadFile(bucket, JSON.toJSONString(sceneJsonBean).getBytes(), objectName);
|
|
|
redisUtil.set(key, JSON.toJSONString(sceneJsonBean));
|
|
|
}
|
|
|
|
|
@@ -1360,13 +1357,12 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
try {
|
|
|
|
|
|
-// ScenePro scenePro = sceneProService.findBySceneNum(num);
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
if(scenePlus == null){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
}
|
|
|
-// SceneProExt sceneProExt = sceneProExtService.findBySceneProId(scenePro.getId());
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
|
|
//更新scene.json文件
|
|
|
String strsceneInfos = FileUtils.readFile(ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + num + File.separator + "scene.json");
|
|
@@ -1492,7 +1488,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
String fileMD5 = FileMd5Util.getFileMD5(new File(zipPath));
|
|
|
|
|
|
- uploadToOssUtil.upload(zipPath, "data_download/" + num + ".zip");
|
|
|
+ fYunFileService.uploadFile(bucket, zipPath, "data_download/" + num + ".zip");
|
|
|
|
|
|
SceneDataDownload sceneDataDownload = sceneDataDownloadService.findBySceneNum(num);
|
|
|
if(sceneDataDownload == null){
|
|
@@ -1519,10 +1515,16 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
@Override
|
|
|
public ResultData checkKey(SceneCheckKeyParamVO param) throws Exception {
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ }
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
SceneJsonBean sceneJsonBean = null;
|
|
|
String sceneJson = redisUtil.get(String.format(RedisKey.SCENE_JSON, param.getNum()));
|
|
|
if(StrUtil.isEmpty(sceneJson)){
|
|
|
- sceneJson = uploadToOssUtil.getObjectContent(bucket,
|
|
|
+ sceneJson = fYunFileService.getFileContent(bucket,
|
|
|
String.format(UploadFilePath.DATA_VIEW_PATH, param.getNum()) + "scene.json");
|
|
|
}
|
|
|
sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
|
|
@@ -1667,6 +1669,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
}
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
|
|
String localDataPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, num);
|
|
|
String localImagesPath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, num);
|
|
@@ -1739,7 +1742,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
cn.hutool.core.io.FileUtil.del(resultPath);
|
|
|
}
|
|
|
//下载data.fdage
|
|
|
- if(StorageType.AWS.code().equals(this.type)){
|
|
|
+ if(FYunTypeEnum.AWS.code().equals(this.fyunType)){
|
|
|
//亚马逊保持旧方式,超链接capture
|
|
|
CreateObjUtil.createSoftConnection(path + File.separator + "capture", capturePath);
|
|
|
}
|
|
@@ -1774,7 +1777,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
//上传全景图
|
|
|
map.put(filePath, imgEditPath + "panorama/" + sid + "/high/" + fileName);
|
|
|
|
|
|
- uploadToOssUtil.uploadMulFiles(map);
|
|
|
+ fYunFileService.uploadMulFiles(bucket, map);
|
|
|
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
result.put("type", type);
|
|
@@ -1842,11 +1845,13 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
|
if (scenePlus == null)
|
|
|
return ResultData.error(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
|
|
List<String> deleteSidList = param.getSidList();
|
|
|
|
|
|
//处理删除状态数据
|
|
|
- this.deletelinkPanData(param.getNum(), deleteSidList);
|
|
|
+ this.deletelinkPanData(param.getNum(), deleteSidList, bucket);
|
|
|
|
|
|
//写入本地文件,作为备份
|
|
|
this.writeLinkScene(param.getNum());
|
|
@@ -1857,7 +1862,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
- private void deletelinkPanData(String num, List<String> deleteSidList) throws Exception {
|
|
|
+ private void deletelinkPanData(String num, List<String> deleteSidList, String bucket) throws Exception {
|
|
|
|
|
|
if(CollUtil.isEmpty(deleteSidList)){
|
|
|
return;
|
|
@@ -1877,7 +1882,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
//删除oss文件
|
|
|
String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
|
deleteSidList.stream().forEach(sid->{
|
|
|
- uploadToOssUtil.deleteFile(imgEditPath + "panorama_edit/" + sid);
|
|
|
+ fYunFileService.deleteFolder(bucket, imgEditPath + "panorama_edit/" + sid);
|
|
|
});
|
|
|
|
|
|
}
|
|
@@ -2360,7 +2365,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private void transferToFlv(String num, String fileName) throws Exception {
|
|
|
+ private void transferToFlv(String num, String fileName, String bucket) throws Exception {
|
|
|
|
|
|
String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
|
|
|
String localImagesPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
|
|
@@ -2377,19 +2382,15 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
}
|
|
|
|
|
|
//从用户编辑目录中下载视频到本地
|
|
|
- if (!StorageType.LOCAL.code().equals(this.type)) {
|
|
|
- String filePath = userEditPath + fileName;
|
|
|
- String imageUrl = ossUrlPrefix + filePath + "?t=" + System.currentTimeMillis();
|
|
|
- FileUtils.downLoadFromUrl(imageUrl, fileName, localImagesPath);
|
|
|
- }
|
|
|
+ String filePath = userEditPath + fileName;
|
|
|
+ fYunFileService.downloadFile(bucket, filePath, localImagesPath + fileName);
|
|
|
|
|
|
//视频格式转换
|
|
|
CreateObjUtil.mp4ToFlv(localFilePath, localFilePath.replace("mp4", "flv"));
|
|
|
|
|
|
//上传
|
|
|
String flvFileName = fileName.replace("mp4", "flv");
|
|
|
-// uploadToOssUtil.upload(localFilePath, userEditPath + fileName);
|
|
|
- uploadToOssUtil.upload(localFilePath.replace("mp4", "flv"), userEditPath+flvFileName);
|
|
|
+ fYunFileService.uploadFile(bucket, localFilePath.replace("mp4", "flv"), userEditPath+flvFileName);
|
|
|
}
|
|
|
|
|
|
@Override
|