dengsixing 5 months ago
parent
commit
8ac92f9831

+ 15 - 2
src/main/java/com/fdkankan/scene/service/impl/CommonServiceImpl.java

@@ -11,12 +11,17 @@ import com.fdkankan.model.utils.CreateObjUtil;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.scene.bean.SceneJsonBean;
 import com.fdkankan.scene.bean.SceneJsonBean;
+import com.fdkankan.scene.entity.ScenePlus;
+import com.fdkankan.scene.entity.ScenePlusExt;
 import com.fdkankan.scene.factory.UserEditData.UserEditDataHandler;
 import com.fdkankan.scene.factory.UserEditData.UserEditDataHandler;
 import com.fdkankan.scene.factory.UserEditData.UserEditDataHandlerFactory;
 import com.fdkankan.scene.factory.UserEditData.UserEditDataHandlerFactory;
 import com.fdkankan.scene.oss.OssUtil;
 import com.fdkankan.scene.oss.OssUtil;
 import com.fdkankan.scene.service.ICommonService;
 import com.fdkankan.scene.service.ICommonService;
+import com.fdkankan.scene.service.IScenePlusExtService;
+import com.fdkankan.scene.service.IScenePlusService;
 import com.fdkankan.scene.util.MergeVideoUtil;
 import com.fdkankan.scene.util.MergeVideoUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
@@ -34,6 +39,10 @@ public class CommonServiceImpl implements ICommonService {
     private OssUtil ossUtil;
     private OssUtil ossUtil;
     @Resource
     @Resource
     private RedisUtil redisUtil;
     private RedisUtil redisUtil;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
 
 
     @Override
     @Override
     public void initUserEditData(String num, Set<String> bizs, Map<String, Map<String ,Object>> params) {
     public void initUserEditData(String num, Set<String> bizs, Map<String, Map<String ,Object>> params) {
@@ -76,12 +85,14 @@ public class CommonServiceImpl implements ICommonService {
 
 
     @Override
     @Override
     public void updateViewGetInfo(String num, Map<String, Object> param) {
     public void updateViewGetInfo(String num, Map<String, Object> param) {
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
         JSONObject infoJson = this.getInfoJson(num);
         JSONObject infoJson = this.getInfoJson(num);
         param.keySet().stream().forEach(k->{
         param.keySet().stream().forEach(k->{
             infoJson.put(k, param.get(k));
             infoJson.put(k, param.get(k));
         });
         });
         String sceneJsonKey = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
         String sceneJsonKey = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
-        fYunFileService.uploadFile(infoJson.toJSONString().getBytes(StandardCharsets.UTF_8), sceneJsonKey);
+        ossUtil.uploadFileBytes(scenePlusExt.getYunFileBucket(), sceneJsonKey, infoJson.toJSONString().getBytes(StandardCharsets.UTF_8));
 
 
         String redisKey = String.format(RedisKey.SCENE_JSON, num);
         String redisKey = String.format(RedisKey.SCENE_JSON, num);
         redisUtil.del(redisKey);
         redisUtil.del(redisKey);
@@ -89,8 +100,10 @@ public class CommonServiceImpl implements ICommonService {
 
 
     @Override
     @Override
     public JSONObject getInfoJson(String num) {
     public JSONObject getInfoJson(String num) {
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
         String sceneJsonKey = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
         String sceneJsonKey = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
-        String fileContent = fYunFileService.getFileContent(sceneJsonKey);
+        String fileContent = ossUtil.getFileContent(scenePlusExt.getYunFileBucket(), sceneJsonKey);
         return JSON.parseObject(fileContent);
         return JSON.parseObject(fileContent);
     }
     }
 }
 }

+ 124 - 125
src/main/java/com/fdkankan/scene/service/impl/RemovePortraitServiceImpl.java

@@ -1,125 +1,124 @@
-package com.fdkankan.scene.service.impl;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.CharsetUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.core.util.ZipUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.*;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.common.util.FileUtils;
-import com.fdkankan.fyun.face.FYunFileServiceInterface;
-import com.fdkankan.model.constants.ConstantFilePath;
-import com.fdkankan.model.constants.UploadFilePath;
-import com.fdkankan.model.utils.CreateObjUtil;
-import com.fdkankan.model.utils.SceneUtil;
-import com.fdkankan.scene.entity.SceneAsynOperLog;
-import com.fdkankan.scene.entity.ScenePlus;
-import com.fdkankan.scene.entity.ScenePlusExt;
-import com.fdkankan.scene.service.*;
-import com.fdkankan.scene.vo.UploadPanoramaVO;
-import com.fdkankan.web.response.ResultData;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.io.File;
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-import java.util.stream.Collectors;
-
-@Slf4j
-@Service
-public class RemovePortraitServiceImpl implements IRemovePortraitService {
-
-    @Autowired
-    private IScenePlusService scenePlusService;
-    @Autowired
-    private IScenePlusExtService scenePlusExtService;
-    @Resource
-    private FYunFileServiceInterface fileServiceInterface;
-    @Autowired
-    private ISceneEditInfoService sceneEditInfoService;
-    @Resource
-    private FYunFileServiceInterface fYunFileService;
-    @Autowired
-    private ISceneAsynOperLogService sceneAsynOperLogService;
-
-    @Override
-    public void removePortrait(JSONObject param) throws Exception {
-        String num = param.getString("num");
-
-        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
-        if(scenePlus.getRemovePortrait() == CommonOperStatus.WAITING.code()){
-            return;
-        }
-        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
-        String bucket = scenePlusExt.getYunFileBucket();
-        //原始计算根目录
-        String uuid = UUID.randomUUID().toString();
-        //全景图计算根目录
-        String target = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + uuid;
-        //解压缩文件存放目录
-        String targetImagesPath = target + "/extras/images/";
-        //更新状态为进行中
-        scenePlus.setRemovePortrait(CommonOperStatus.WAITING.code());
-        scenePlusService.updateById(scenePlus);
-        try {
-            //下载文件
-            String cacheImagesPath = String.format(UploadFilePath.scene_result_data_path, num) + "caches/images/";
-            List<String> imagesList = fileServiceInterface.listRemoteFiles(cacheImagesPath);
-            if(CollUtil.isEmpty(imagesList)){
-                return;
-            }
-
-            imagesList.stream().forEach(key->{
-                if(key.endsWith(".jpg")){
-                    fileServiceInterface.downloadFile(key, targetImagesPath + FileUtil.getName(key));
-                }
-            });
-
-            String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
-            fileServiceInterface.downloadFile(imgViewPath + "vision.txt", target + File.separator + "extras" + File.separator + "vision.txt");
-
-            //data.json增加extras为执行重建算法
-            JSONObject floorplanJson = new JSONObject();
-            floorplanJson.put("has_source_images", true);
-            floorplanJson.put("has_vision_txt", true);
-
-            JSONObject dataJson = new JSONObject();
-            dataJson.put("extras", floorplanJson);
-            dataJson.put("split_type", "SPLIT_V28");
-            //V5表示不需要生成high,low文件
-            String skyboxType = "SKYBOX_V6";
-            if(scenePlusExt.getSceneScheme() == 11){
-                skyboxType = "SKYBOX_V7";
-            }
-            //sceneScheme为3切成瓦片图
-            if(scenePlusExt.getSceneScheme() == 3){
-                if("4k".equals(scenePlusExt.getSceneResolution())){
-                    skyboxType = "SKYBOX_V14";
-                }else{
-                    skyboxType = "SKYBOX_V13";
-                }
-            }
-            dataJson.put("skybox_type", skyboxType);
-            FileUtil.writeUtf8String(dataJson.toJSONString(), target + File.separator+"data.json");
-
-            sceneEditInfoService.uploadPanoramaHandler(num,bucket,target,imgViewPath,new ArrayList<>(),targetImagesPath, "removePortrait");
-            scenePlus.setRemovePortrait(CommonOperStatus.SUCCESS.code());
-
-            //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
-            sceneAsynOperLogService.cleanLog(num, SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code());
-
-        }catch (Exception e){
-            log.error("抹除人像失败,num:{}", num, e);
-            scenePlus.setRemovePortrait(CommonOperStatus.FAILD.code());
-        }finally {
-            FileUtil.del(target);
-            scenePlusService.updateById(scenePlus);
-        }
-    }
-}
+//package com.fdkankan.scene.service.impl;
+//
+//import cn.hutool.core.collection.CollUtil;
+//import cn.hutool.core.io.FileUtil;
+//import cn.hutool.core.util.CharsetUtil;
+//import cn.hutool.core.util.StrUtil;
+//import cn.hutool.core.util.ZipUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.alibaba.fastjson.JSONObject;
+//import com.fdkankan.common.constant.*;
+//import com.fdkankan.common.exception.BusinessException;
+//import com.fdkankan.common.util.FileUtils;
+//import com.fdkankan.model.constants.ConstantFilePath;
+//import com.fdkankan.model.constants.UploadFilePath;
+//import com.fdkankan.model.utils.CreateObjUtil;
+//import com.fdkankan.model.utils.SceneUtil;
+//import com.fdkankan.scene.entity.SceneAsynOperLog;
+//import com.fdkankan.scene.entity.ScenePlus;
+//import com.fdkankan.scene.entity.ScenePlusExt;
+//import com.fdkankan.scene.service.*;
+//import com.fdkankan.scene.vo.UploadPanoramaVO;
+//import com.fdkankan.web.response.ResultData;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//
+//import javax.annotation.Resource;
+//import java.io.File;
+//import java.util.*;
+//import java.util.concurrent.CompletableFuture;
+//import java.util.stream.Collectors;
+//
+//@Slf4j
+//@Service
+//public class RemovePortraitServiceImpl implements IRemovePortraitService {
+//
+//    @Autowired
+//    private IScenePlusService scenePlusService;
+//    @Autowired
+//    private IScenePlusExtService scenePlusExtService;
+//    @Resource
+//    private FYunFileServiceInterface fileServiceInterface;
+//    @Autowired
+//    private ISceneEditInfoService sceneEditInfoService;
+//    @Resource
+//    private FYunFileServiceInterface fYunFileService;
+//    @Autowired
+//    private ISceneAsynOperLogService sceneAsynOperLogService;
+//
+//    @Override
+//    public void removePortrait(JSONObject param) throws Exception {
+//        String num = param.getString("num");
+//
+//        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+//        if(scenePlus.getRemovePortrait() == CommonOperStatus.WAITING.code()){
+//            return;
+//        }
+//        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+//        String bucket = scenePlusExt.getYunFileBucket();
+//        //原始计算根目录
+//        String uuid = UUID.randomUUID().toString();
+//        //全景图计算根目录
+//        String target = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + uuid;
+//        //解压缩文件存放目录
+//        String targetImagesPath = target + "/extras/images/";
+//        //更新状态为进行中
+//        scenePlus.setRemovePortrait(CommonOperStatus.WAITING.code());
+//        scenePlusService.updateById(scenePlus);
+//        try {
+//            //下载文件
+//            String cacheImagesPath = String.format(UploadFilePath.scene_result_data_path, num) + "caches/images/";
+//            List<String> imagesList = fileServiceInterface.listRemoteFiles(cacheImagesPath);
+//            if(CollUtil.isEmpty(imagesList)){
+//                return;
+//            }
+//
+//            imagesList.stream().forEach(key->{
+//                if(key.endsWith(".jpg")){
+//                    fileServiceInterface.downloadFile(key, targetImagesPath + FileUtil.getName(key));
+//                }
+//            });
+//
+//            String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
+//            fileServiceInterface.downloadFile(imgViewPath + "vision.txt", target + File.separator + "extras" + File.separator + "vision.txt");
+//
+//            //data.json增加extras为执行重建算法
+//            JSONObject floorplanJson = new JSONObject();
+//            floorplanJson.put("has_source_images", true);
+//            floorplanJson.put("has_vision_txt", true);
+//
+//            JSONObject dataJson = new JSONObject();
+//            dataJson.put("extras", floorplanJson);
+//            dataJson.put("split_type", "SPLIT_V28");
+//            //V5表示不需要生成high,low文件
+//            String skyboxType = "SKYBOX_V6";
+//            if(scenePlusExt.getSceneScheme() == 11){
+//                skyboxType = "SKYBOX_V7";
+//            }
+//            //sceneScheme为3切成瓦片图
+//            if(scenePlusExt.getSceneScheme() == 3){
+//                if("4k".equals(scenePlusExt.getSceneResolution())){
+//                    skyboxType = "SKYBOX_V14";
+//                }else{
+//                    skyboxType = "SKYBOX_V13";
+//                }
+//            }
+//            dataJson.put("skybox_type", skyboxType);
+//            FileUtil.writeUtf8String(dataJson.toJSONString(), target + File.separator+"data.json");
+//
+//            sceneEditInfoService.uploadPanoramaHandler(num,bucket,target,imgViewPath,new ArrayList<>(),targetImagesPath, "removePortrait");
+//            scenePlus.setRemovePortrait(CommonOperStatus.SUCCESS.code());
+//
+//            //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
+//            sceneAsynOperLogService.cleanLog(num, SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code());
+//
+//        }catch (Exception e){
+//            log.error("抹除人像失败,num:{}", num, e);
+//            scenePlus.setRemovePortrait(CommonOperStatus.FAILD.code());
+//        }finally {
+//            FileUtil.del(target);
+//            scenePlusService.updateById(scenePlus);
+//        }
+//    }
+//}

+ 31 - 16
src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -67,6 +67,7 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.FileSystemException;
 import java.util.*;
 import java.util.*;
 import java.util.Map.Entry;
 import java.util.Map.Entry;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CompletableFuture;
@@ -191,6 +192,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
 
     @Override
     @Override
     public ResultData uploadTagImg(String num, MultipartFile file, String sid, Integer size, Integer tileSize) throws Exception {
     public ResultData uploadTagImg(String num, MultipartFile file, String sid, Integer size, Integer tileSize) throws Exception {
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
         String extName = FileUtil.extName(file.getOriginalFilename());
         String extName = FileUtil.extName(file.getOriginalFilename());
         String fragmentPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "hot_img_fragment/";
         String fragmentPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "hot_img_fragment/";
         String workPath = fragmentPath + sid;
         String workPath = fragmentPath + sid;
@@ -241,11 +244,11 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
 
             //上传
             //上传
             uploadMap.entrySet().stream().forEach(entry->{
             uploadMap.entrySet().stream().forEach(entry->{
-                fYunFileService.uploadFile(entry.getKey(), entry.getValue());
+                ossUtil.uploadFile(scenePlusExt.getYunFileBucket(), entry.getValue(), entry.getKey(), false);
             });
             });
 
 
             //上传原图
             //上传原图
-            fYunFileService.uploadFile(origFilePath, ossPath + sid + "." + extName);
+            ossUtil.uploadFile(scenePlusExt.getYunFileBucket(), ossPath + sid + "." + extName, origFilePath, false);
 
 
         }finally {
         }finally {
             FileUtil.del(workPath);
             FileUtil.del(workPath);
@@ -263,10 +266,16 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
 
     @Override
     @Override
     public ResultData deleteTagImg(DeleteSidListParamVO param) {
     public ResultData deleteTagImg(DeleteSidListParamVO param) {
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
+        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
         param.getSidList().stream().forEach(sid->{
         param.getSidList().stream().forEach(sid->{
             String ossPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + "hotspot/" + sid + "/";
             String ossPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + "hotspot/" + sid + "/";
-            if(CollUtil.isNotEmpty(fYunFileService.listRemoteFiles(ossPath))){
-                fYunFileService.deleteFolder(ossPath);
+            if(CollUtil.isNotEmpty(ossUtil.listFiles(scenePlusExt.getYunFileBucket(), ossPath))){
+                try {
+                    ossUtil.deleteObject(scenePlusExt.getYunFileBucket(), ossPath);
+                } catch (FileSystemException e) {
+                    throw new RuntimeException(e);
+                }
             }
             }
         });
         });
 
 
@@ -643,6 +652,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         if(CollUtil.isEmpty(hotdataList)){
         if(CollUtil.isEmpty(hotdataList)){
             return;
             return;
         }
         }
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
         //删除图片音频视频等资源文件
         //删除图片音频视频等资源文件
         List<String> deleteFileList = new ArrayList<>();
         List<String> deleteFileList = new ArrayList<>();
         List<String> deleteKeys = new ArrayList<>();
         List<String> deleteKeys = new ArrayList<>();
@@ -706,7 +717,11 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         }
         }
         if(CollUtil.isNotEmpty(deleteKeys)){
         if(CollUtil.isNotEmpty(deleteKeys)){
             deleteKeys.stream().forEach(key->{
             deleteKeys.stream().forEach(key->{
-                fYunFileService.deleteFolder(key);
+                try {
+                    ossUtil.deleteObject(scenePlusExt.getYunFileBucket(), key);
+                } catch (FileSystemException e) {
+                    throw new RuntimeException(e);
+                }
             });
             });
         }
         }
 
 
@@ -1331,17 +1346,17 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         return url;
         return url;
     }
     }
 
 
-    public static void main(String[] args) {
-        File copy = FileUtil.copy(new File("D:\\4DMega\\4DKK_PROGRAM_STATIC\\scene_view_data/1680825957743071232/data/mesh/"),
-                new File("/mnt/4Dkankan/scene_v4/1680825957743071232/data"), true);
-
-        Element rootElement = XmlUtil.getRootElement(document);
-        Element size = XmlUtil.getElement(rootElement, "Size");
-        String Height = size.getAttribute("Height");
-        String Width = size.getAttribute("Width");
-
-        System.out.println(123);
-    }
+//    public static void main(String[] args) {
+//        File copy = FileUtil.copy(new File("D:\\4DMega\\4DKK_PROGRAM_STATIC\\scene_view_data/1680825957743071232/data/mesh/"),
+//                new File("/mnt/4Dkankan/scene_v4/1680825957743071232/data"), true);
+//
+//        Element rootElement = XmlUtil.getRootElement(document);
+//        Element size = XmlUtil.getElement(rootElement, "Size");
+//        String Height = size.getAttribute("Height");
+//        String Width = size.getAttribute("Width");
+//
+//        System.out.println(123);
+//    }
 
 
 
 
     private String downloadModel4Dam(String num, String bucket){
     private String downloadModel4Dam(String num, String bucket){