|
@@ -8,13 +8,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
import com.fdkankan.common.constant.SceneKind;
|
|
import com.fdkankan.common.constant.SceneKind;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
|
+import com.fdkankan.common.util.*;
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.ucenter.common.PageInfo;
|
|
import com.fdkankan.ucenter.common.PageInfo;
|
|
-import com.fdkankan.common.util.FileUtils;
|
|
|
|
-import com.fdkankan.common.util.JwtUtil;
|
|
|
|
-import com.fdkankan.common.util.RandomUtil;
|
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.image.MatrixToImageWriterUtil;
|
|
import com.fdkankan.image.MatrixToImageWriterUtil;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
@@ -116,6 +114,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
@Value("${queue.modeling.obj.modeling-pre}")
|
|
@Value("${queue.modeling.obj.modeling-pre}")
|
|
private String queueObjModelingPre;
|
|
private String queueObjModelingPre;
|
|
|
|
+ @Value("${oss.bucket}")
|
|
|
|
+ private String bucket;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private RabbitMqProducer mqProducer;
|
|
private RabbitMqProducer mqProducer;
|
|
@@ -179,22 +179,28 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ScenePlus> plusWr = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ScenePlus> plusWr = new LambdaQueryWrapper<>();
|
|
Long count = 0L;
|
|
Long count = 0L;
|
|
- if(payStatus == 1){ //解封,判断用户权益,用户会员权益无限容量
|
|
|
|
|
|
+ if(payStatus == 1){ //解封,判断用户权益,用户会员权益无限容量
|
|
count = userIncrementService.getValidCountByCameraId(cameraId);
|
|
count = userIncrementService.getValidCountByCameraId(cameraId);
|
|
wrapper.orderByAsc(ScenePro::getCreateTime);
|
|
wrapper.orderByAsc(ScenePro::getCreateTime);
|
|
plusWr.orderByAsc(ScenePlus::getCreateTime);
|
|
plusWr.orderByAsc(ScenePlus::getCreateTime);
|
|
|
|
+ wrapper.eq(ScenePro::getPayStatus,-2);
|
|
|
|
+ plusWr.eq(ScenePlus::getPayStatus,-2);
|
|
}else {
|
|
}else {
|
|
wrapper.orderByDesc(ScenePro::getCreateTime);
|
|
wrapper.orderByDesc(ScenePro::getCreateTime);
|
|
plusWr.orderByDesc(ScenePlus::getCreateTime);
|
|
plusWr.orderByDesc(ScenePlus::getCreateTime);
|
|
|
|
+ wrapper.eq(ScenePro::getPayStatus,1);
|
|
|
|
+ plusWr.eq(ScenePlus::getPayStatus,1);
|
|
}
|
|
}
|
|
|
|
+
|
|
wrapper.eq(ScenePro::getCameraId,cameraId)
|
|
wrapper.eq(ScenePro::getCameraId,cameraId)
|
|
- .eq(ScenePro::getPayStatus,payStatus)
|
|
|
|
.eq(ScenePro::getSceneScheme,4)
|
|
.eq(ScenePro::getSceneScheme,4)
|
|
.eq(ScenePro::getIsUpgrade,0);
|
|
.eq(ScenePro::getIsUpgrade,0);
|
|
- plusWr.eq(ScenePlus::getCameraId,cameraId)
|
|
|
|
- .eq(ScenePlus::getPayStatus,payStatus);
|
|
|
|
|
|
+
|
|
|
|
+ plusWr.eq(ScenePlus::getCameraId,cameraId);
|
|
|
|
+
|
|
List<ScenePro> list = this.list(wrapper);
|
|
List<ScenePro> list = this.list(wrapper);
|
|
List<ScenePlus> plusList = scenePlusService.list(plusWr);
|
|
List<ScenePlus> plusList = scenePlusService.list(plusWr);
|
|
|
|
+
|
|
Long beyondSpace = Math.abs(cameraDetail.getUsedSpace() - cameraDetail.getTotalSpace());
|
|
Long beyondSpace = Math.abs(cameraDetail.getUsedSpace() - cameraDetail.getTotalSpace());
|
|
Long accumulateSpace = 0L;
|
|
Long accumulateSpace = 0L;
|
|
List<Long> lockedIds = new ArrayList<>();
|
|
List<Long> lockedIds = new ArrayList<>();
|
|
@@ -406,12 +412,32 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
|
|
throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
|
|
}
|
|
}
|
|
String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
|
|
String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
|
|
|
|
+ String title = scenePro == null ? scenePlus.getTitle() : scenePro.getSceneName();
|
|
|
|
+ String newTitle = title.concat("(copy)");
|
|
|
|
+
|
|
|
|
+ Long sceneId = scenePro == null ? scenePlus.getId() :scenePro.getId();
|
|
|
|
+ Long newSceneId = null;
|
|
|
|
+ FolderScene folderScene = folderSceneService.getByType(sceneId, null);
|
|
|
|
+ String time = DateUtil.date2String(new Date(),DateUtil.YYYYMMDDHHMMSSSSS_DATA_FORMAT);
|
|
|
|
+
|
|
|
|
|
|
if(scenePro !=null){ //v3场景复制
|
|
if(scenePro !=null){ //v3场景复制
|
|
- this.copyV3Scene(scenePro,newNum,detailEntity);
|
|
|
|
|
|
+ log.info("场景复制--V3--OldNum:{},oldTitle:{},newNum:{},newTitle:{}",
|
|
|
|
+ scenePro.getNum(),scenePro.getSceneName(),newNum,newTitle);
|
|
|
|
+ scenePro.setSceneName(newTitle);
|
|
|
|
+ newSceneId = this.copyV3Scene(scenePro, newNum, detailEntity,time);
|
|
}
|
|
}
|
|
if(scenePlus != null){ //v4场景复制
|
|
if(scenePlus != null){ //v4场景复制
|
|
- scenePlusService.copyV4Scene(scenePlus,newNum,detailEntity);
|
|
|
|
|
|
+ log.info("场景复制--V4--OldNum:{},oldTitle:{},newNum:{},newTitle:{}",
|
|
|
|
+ scenePlus.getNum(),scenePlus.getTitle(),newNum,newTitle);
|
|
|
|
+ scenePlus.setTitle(newTitle);
|
|
|
|
+ newSceneId = scenePlusService.copyV4Scene(scenePlus,newNum,detailEntity,time);
|
|
|
|
+ }
|
|
|
|
+ log.info("场景复制--完成--sceneId:{}",newSceneId);
|
|
|
|
+ if(newSceneId != null && folderScene!= null){
|
|
|
|
+ folderScene.setId(null);
|
|
|
|
+ folderScene.setSceneId(newSceneId);
|
|
|
|
+ folderSceneService.save(folderScene);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -430,7 +456,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void copyV3Scene(ScenePro oldScene,String newNum,CameraDetail cameraDetail) throws Exception {
|
|
|
|
|
|
+ public Long copyV3Scene(ScenePro oldScene,String newNum,CameraDetail cameraDetail,String time) throws Exception {
|
|
SceneProEdit oldEditScene = sceneProEditService.getByProId(oldScene.getId());
|
|
SceneProEdit oldEditScene = sceneProEditService.getByProId(oldScene.getId());
|
|
|
|
|
|
String oldNum = oldScene.getNum();
|
|
String oldNum = oldScene.getNum();
|
|
@@ -438,20 +464,38 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
oldScene.setId(null);
|
|
oldScene.setId(null);
|
|
oldScene.setStatus(0);
|
|
oldScene.setStatus(0);
|
|
oldScene.setNum(newNum);
|
|
oldScene.setNum(newNum);
|
|
- oldScene.setSceneName(oldScene.getSceneName().concat("(copy)"));
|
|
|
|
oldScene.setWebSite(oldScene.getWebSite().replace(oldScene.getNum(), newNum));
|
|
oldScene.setWebSite(oldScene.getWebSite().replace(oldScene.getNum(), newNum));
|
|
oldScene.setThumb(oldScene.getThumb().replace(oldScene.getNum(), newNum));
|
|
oldScene.setThumb(oldScene.getThumb().replace(oldScene.getNum(), newNum));
|
|
- oldScene.setVideos(oldScene.getVideos().replace(oldNum,newNum));
|
|
|
|
|
|
+ oldScene.setVideos(this.setVideos(oldScene.getVideos(),oldNum,newNum));
|
|
oldScene.setViewCount(0);
|
|
oldScene.setViewCount(0);
|
|
String preDataSource = oldScene.getDataSource();
|
|
String preDataSource = oldScene.getDataSource();
|
|
- oldScene.setDataSource(this.setDataSource(preDataSource,oldScene.getSceneSource()));
|
|
|
|
|
|
+ String newDataSource = this.setDataSource(preDataSource,time);
|
|
|
|
+ oldScene.setDataSource(newDataSource);
|
|
|
|
|
|
this.save(oldScene);
|
|
this.save(oldScene);
|
|
|
|
+ //更新video
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
|
+ if(StringUtils.isNotEmpty(oldScene.getVideos())){
|
|
|
|
+ object = JSONObject.parseObject(oldScene.getVideos());
|
|
|
|
+ if(object.containsKey("upPath")){
|
|
|
|
+ String upPath = object.getString("upPath");
|
|
|
|
+ upPath = upPath.replace(oldNum,newNum);
|
|
|
|
+ object.put("upPath",upPath);
|
|
|
|
+ }
|
|
|
|
+ oldScene.setVideos(object.toJSONString());
|
|
|
|
+ log.info("更新 scene.json");
|
|
|
|
+ map.put("videos",oldScene.getVideos());
|
|
|
|
+ }
|
|
|
|
+ map.put("sceneName",oldScene.getSceneName());
|
|
|
|
+ map.put("webSite",oldScene.getWebSite());
|
|
|
|
+ map.put("thumb",oldScene.getThumb());
|
|
|
|
+ map.put("num",oldScene.getNum());
|
|
|
|
+ map.put("id",oldScene.getId());
|
|
|
|
+ map.put("dataSource",oldScene.getDataSource());
|
|
|
|
|
|
sceneCopyLogService.saveByNum(oldNum,newNum,oldScene.getUserId());
|
|
sceneCopyLogService.saveByNum(oldNum,newNum,oldScene.getUserId());
|
|
//复制完成更新相机容量
|
|
//复制完成更新相机容量
|
|
- cameraDetail.setUsedSpace(cameraDetail.getUsedSpace() + oldScene.getSpace());
|
|
|
|
- cameraDetailService.updateById(cameraDetail);
|
|
|
|
|
|
|
|
oldEditScene.setId(null);
|
|
oldEditScene.setId(null);
|
|
oldEditScene.setProId(oldScene.getId());
|
|
oldEditScene.setProId(oldScene.getId());
|
|
@@ -467,14 +511,31 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
CompletableFuture.runAsync(() -> {
|
|
CompletableFuture.runAsync(() -> {
|
|
try {
|
|
try {
|
|
log.info("开始复制场景-{}", new Date());
|
|
log.info("开始复制场景-{}", new Date());
|
|
-
|
|
|
|
|
|
+ String buildModelPath = ConstantFilePath.BUILD_MODEL_PATH;
|
|
|
|
+ if(oldScene.getSceneSource().equals(4)){
|
|
|
|
+ buildModelPath = ConstantFilePath.BUILD_MODEL_LASER_PATH;
|
|
|
|
+ }
|
|
|
|
+ this.copyFdage(preDataSource,newDataSource,buildModelPath,time);
|
|
//oss复制计算结果资源
|
|
//oss复制计算结果资源
|
|
- this.copyOssSource("v3",oldNum,newNum);
|
|
|
|
- this.copyLocalSource(oldNum,newNum);
|
|
|
|
-
|
|
|
|
- updateSceneJson("v3",oldScene.getVideos(),newNum,oldScene.getSceneName(),oldScene.getWebSite(),oldScene.getThumb(),oldScene.getId());
|
|
|
|
|
|
+ downloadFromOldNumFromOss(oldNum, newNum);
|
|
|
|
+ // 复制本地secen.json
|
|
|
|
+ copyOldSceneLocalToNew(oldNum, newNum);
|
|
|
|
+ FileUtils.writeJsonFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + File.separator + "scene.json", map);
|
|
//上传资源到oss
|
|
//上传资源到oss
|
|
uploadNewSceneToOss(newNum);
|
|
uploadNewSceneToOss(newNum);
|
|
|
|
+
|
|
|
|
+ FileUtils.delFolder(ConstantFilePath.SCENE_PATH + "images/images" + newNum);
|
|
|
|
+ FileUtils.delFolder(ConstantFilePath.SCENE_PATH + "data/data" + newNum);
|
|
|
|
+ FileUtils.delFolder(ConstantFilePath.SCENE_PATH + "voice/voice" + newNum);
|
|
|
|
+ FileUtils.delFolder(ConstantFilePath.SCENE_PATH + "video/video" + newNum);
|
|
|
|
+
|
|
|
|
+ FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"images/images" + oldNum,ConstantFilePath.SCENE_PATH +"images/images" + newNum);
|
|
|
|
+ FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"data/data" + oldNum,ConstantFilePath.SCENE_PATH +"data/data" + newNum);
|
|
|
|
+ FileUtils.writeJsonFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + File.separator + "scene.json", map);
|
|
|
|
+ reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/link-scene.json",oldNum, newNum);
|
|
|
|
+ reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/hot.json",oldNum, newNum);
|
|
|
|
+ FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"voice/voice" + oldNum,ConstantFilePath.SCENE_PATH +"voice/voice" + newNum);
|
|
|
|
+ FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"video/video" + oldNum,ConstantFilePath.SCENE_PATH +"video/video" + newNum);
|
|
oldScene.setStatus(-2);
|
|
oldScene.setStatus(-2);
|
|
this.updateById(oldScene);
|
|
this.updateById(oldScene);
|
|
log.info("复制场景结束-{}", new Date());
|
|
log.info("复制场景结束-{}", new Date());
|
|
@@ -482,69 +543,83 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
log.error("复制场景异常", e);
|
|
log.error("复制场景异常", e);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+ return oldScene.getId();
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public String setDataSource(String preDataSource,Integer sceneSource) throws Exception {
|
|
|
|
- String datasourceFix;
|
|
|
|
- String newDataSource;
|
|
|
|
- // 判断场景是否拷贝过
|
|
|
|
- ScenePro entity;
|
|
|
|
- do{
|
|
|
|
- datasourceFix = RandomUtil.generateShortUuid();
|
|
|
|
- entity = this.findByFileId(preDataSource.concat(datasourceFix));
|
|
|
|
- }while(!ObjectUtils.isEmpty(entity));
|
|
|
|
- newDataSource = datasourceFix.concat(datasourceFix);
|
|
|
|
-
|
|
|
|
- //oss复制源文件
|
|
|
|
- String buildModelPath = ConstantFilePath.BUILD_MODEL_PATH;
|
|
|
|
- if(sceneSource.equals(4)){
|
|
|
|
- buildModelPath = ConstantFilePath.BUILD_MODEL_LASER_PATH;
|
|
|
|
- }
|
|
|
|
- CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX +newDataSource.replace(buildModelPath, "")+"/", newDataSource);
|
|
|
|
-
|
|
|
|
- List<String> urlList = new ArrayList<>();
|
|
|
|
- FileUtils.readfilePath(newDataSource, urlList);
|
|
|
|
- Map<String,String> fileMap = new HashMap<>();
|
|
|
|
- for(String url : urlList){
|
|
|
|
- fileMap.put(url, ConstantFilePath.OSS_PREFIX + url.replace(buildModelPath, ""));
|
|
|
|
- }
|
|
|
|
- fYunFileService.uploadMulFiles(fileMap);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 从旧场景下载资源
|
|
|
|
+ * @param sceneNum
|
|
|
|
+ * @param newNum
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ private void downloadFromOldNumFromOss(String sceneNum, String newNum) throws Exception {
|
|
|
|
+ CreateObjUtil.ossUtilCp("images/images" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "images/images" + newNum);
|
|
|
|
+ CreateObjUtil.ossUtilCp("data/data" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "data/data" + newNum);
|
|
|
|
+ CreateObjUtil.ossUtilCp("voice/voice" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "voice/voice" + newNum);
|
|
|
|
+ CreateObjUtil.ossUtilCp("video/video" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "video/video" + newNum);
|
|
|
|
+ }
|
|
|
|
|
|
- FileUtils.delAllFile(newDataSource);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 从本地旧场景拷贝资源到新场景
|
|
|
|
+ * @param sceneNum
|
|
|
|
+ * @param newNum
|
|
|
|
+ */
|
|
|
|
+ private void copyOldSceneLocalToNew(String sceneNum, String newNum) throws Exception {
|
|
|
|
+ FileUtils.copyFolderAllFiles(ConstantFilePath.SCENE_PATH + "data/data" + sceneNum + "/",
|
|
|
|
+ ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/", true);
|
|
|
|
|
|
- FileUtils.copyFolderAllFiles(preDataSource+"/",newDataSource+"/", true);
|
|
|
|
- return datasourceFix.concat(datasourceFix);
|
|
|
|
|
|
+ reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/link-scene.json",sceneNum, newNum);
|
|
|
|
+ reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/hot.json",sceneNum, newNum);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public void copyOssSource(String type ,String sceneNum, String newNum) throws Exception {
|
|
|
|
- List<String > copyList = new ArrayList<>();
|
|
|
|
- if(type.equals("v3")){
|
|
|
|
- copyList.add("images/images" + sceneNum);
|
|
|
|
- copyList.add("data/data" + sceneNum);
|
|
|
|
- copyList.add("voice/voice" + sceneNum);
|
|
|
|
- copyList.add("video/video"+ sceneNum);
|
|
|
|
- }else if(type.equals("v4")){
|
|
|
|
- String oldEditPath = String.format(UploadFilePath.EDIT_PATH, sceneNum);
|
|
|
|
- String oldViewPath = String.format(UploadFilePath.VIEW_PATH, sceneNum);
|
|
|
|
- copyList.add(oldEditPath);
|
|
|
|
- copyList.add(oldViewPath);
|
|
|
|
|
|
+ public void copyFdage(String oldDataSource,String newDataSource,String buildModelPath,String time) throws Exception {
|
|
|
|
+
|
|
|
|
+ CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + oldDataSource.replace(buildModelPath, "")+"/", newDataSource);
|
|
|
|
+ // 修改data.fdage
|
|
|
|
+ String data = FileUtils.readFile(newDataSource + "/data.fdage");
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
|
+ if(ObjectUtils.isEmpty(jsonObject)){
|
|
|
|
+ log.error("data.fdage文件不存在");
|
|
|
|
+ throw new BusinessException(-1,"拷贝场景出错,data.fdage文件不存在");
|
|
}
|
|
}
|
|
- for (String sourcePath : copyList) {
|
|
|
|
- fYunFileService.copyFileInBucket(sourcePath,sourcePath.replaceAll(sceneNum,newNum));
|
|
|
|
|
|
+ jsonObject.put("uuidtime",time);
|
|
|
|
+ FileUtils.writeFile(newDataSource + "/data.fdage", jsonObject.toJSONString());
|
|
|
|
+ CreateObjUtil.ossUtilCpFolder(newDataSource, bucket.concat("/" + ConstantFilePath.OSS_PREFIX + newDataSource.replace(buildModelPath, "")));
|
|
|
|
+
|
|
|
|
+ // 复制计算结果
|
|
|
|
+ CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + oldDataSource.concat("_results/").replace(buildModelPath, ""), newDataSource.concat("_results"));
|
|
|
|
+ if(new File(newDataSource.concat("_results")).exists()){
|
|
|
|
+ CreateObjUtil.ossUtilCpFolder(newDataSource.concat("_results"),bucket.concat("/" + ConstantFilePath.OSS_PREFIX + newDataSource.concat("_results").replace(buildModelPath, "")));
|
|
|
|
+ FileUtils.delAllFile(newDataSource.concat("_results"));
|
|
}
|
|
}
|
|
|
|
+ FileUtils.delAllFile(newDataSource);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ FileUtils.copyFolderAllFiles(oldDataSource+"/",newDataSource+"/", true);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public String setDataSource(String preDataSource,String time) throws Exception {
|
|
|
|
+ SnowflakeIdGenerator snowflakeIdGenerator = new SnowflakeIdGenerator(0,1);
|
|
|
|
+ String[] datasource = preDataSource.split("/");
|
|
|
|
+ datasource[4] = snowflakeIdGenerator.nextId()+"";
|
|
|
|
+ datasource[5] = datasource[5].split("_")[0] + "_" + time;
|
|
|
|
+ return Arrays.stream(datasource).collect(Collectors.joining("/"));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void copyLocalSource(String sceneNum, String newNum) throws Exception {
|
|
|
|
- FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"images/images" + sceneNum,ConstantFilePath.SCENE_PATH +"images/images" + newNum);
|
|
|
|
- FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"data/data" + sceneNum,ConstantFilePath.SCENE_PATH +"data/data" + newNum);
|
|
|
|
- reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/link-scene.json",sceneNum, newNum);
|
|
|
|
- reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/hot.json",sceneNum, newNum);
|
|
|
|
- FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"voice/voice" + sceneNum,ConstantFilePath.SCENE_PATH +"voice/voice" + newNum);
|
|
|
|
- FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"video/video" + sceneNum,ConstantFilePath.SCENE_PATH +"video/video" + newNum);
|
|
|
|
|
|
+ public String setVideos(String videos,String oldNum,String newNum) {
|
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
|
+ if(StringUtils.isNotEmpty(videos)){
|
|
|
|
+ object = JSONObject.parseObject(videos);
|
|
|
|
+ if(object.containsKey("upPath")){
|
|
|
|
+ String upPath = object.getString("upPath");
|
|
|
|
+ upPath = upPath.replace(oldNum,newNum);
|
|
|
|
+ object.put("upPath",upPath);
|
|
|
|
+ }
|
|
|
|
+ log.info("更新 scene.json");
|
|
|
|
+ }
|
|
|
|
+ return object.toJSONString();
|
|
}
|
|
}
|
|
|
|
|
|
private void reloadFile(String filePath,String sceneNum, String newNum) throws Exception {
|
|
private void reloadFile(String filePath,String sceneNum, String newNum) throws Exception {
|
|
@@ -562,39 +637,10 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
* @param newNum
|
|
* @param newNum
|
|
*/
|
|
*/
|
|
private void uploadNewSceneToOss(String newNum) {
|
|
private void uploadNewSceneToOss(String newNum) {
|
|
- Map<String, String> map = new HashMap();
|
|
|
|
- List<String> urlList = new ArrayList<>();
|
|
|
|
- FileUtils.readfilePath(ConstantFilePath.SCENE_PATH + "images/images" + newNum, urlList);
|
|
|
|
- FileUtils.readfilePath(ConstantFilePath.SCENE_PATH + "data/data" + newNum, urlList);
|
|
|
|
- FileUtils.readfilePath(ConstantFilePath.SCENE_PATH + "voice/voice" + newNum, urlList);
|
|
|
|
- FileUtils.readfilePath(ConstantFilePath.SCENE_PATH + "video/video" + newNum, urlList);
|
|
|
|
- for(String url : urlList){
|
|
|
|
- map.put(url, url.replace(ConstantFilePath.SCENE_PATH, ""));
|
|
|
|
- }
|
|
|
|
- fYunFileService.uploadMulFiles(map);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void updateSceneJson(String type,String videos,String newNum,String sceneName,String webSite,String thumb,Long id) throws Exception {
|
|
|
|
- //更新video
|
|
|
|
- HashMap<String,Object> map = new HashMap<>();
|
|
|
|
- map.put("videos",videos);
|
|
|
|
- map.put("sceneName",sceneName);
|
|
|
|
- map.put("webSite",webSite);
|
|
|
|
- map.put("thumb",thumb);
|
|
|
|
- map.put("num",newNum);
|
|
|
|
- map.put("id",id);
|
|
|
|
- String uploadPath ;
|
|
|
|
- String localPath = ConstantFilePath.SCENE_PATH + "data/data" + newNum + File.separator + "scene.json";
|
|
|
|
- if(type.equals("v3")){
|
|
|
|
- uploadPath = localPath.replace(ConstantFilePath.SCENE_PATH, "");
|
|
|
|
- }else {
|
|
|
|
- uploadPath =localPath.replace(ConstantFilePath.SCENE_V4_PATH, "");
|
|
|
|
- }
|
|
|
|
- FileUtils.writeJsonFile(localPath, map);
|
|
|
|
- if(type.equals("v4")){
|
|
|
|
- fYunFileService.uploadFile(localPath,uploadPath);
|
|
|
|
- }
|
|
|
|
|
|
+ CreateObjUtil.ossUtilCpFolder("/mnt/4Dkankan/scene/images/images" + newNum, bucket.concat("/images/images") + newNum);
|
|
|
|
+ CreateObjUtil.ossUtilCpFolder("/mnt/4Dkankan/scene/data/data" + newNum, bucket.concat("/data/data") + newNum);
|
|
|
|
+ CreateObjUtil.ossUtilCpFolder("/mnt/4Dkankan/scene/voice/voice" + newNum, bucket.concat("/voice/voice") + newNum);
|
|
|
|
+ CreateObjUtil.ossUtilCpFolder("/mnt/4Dkankan/scene/video/video" + newNum, bucket.concat("/video/video") + newNum);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|