Ver código fonte

Merge remote-tracking branch 'origin/release' into project-jp-test

dengsixing 5 meses atrás
pai
commit
5651eeae5f

+ 7 - 0
src/main/java/com/fdkankan/scene/service/IWbService.java

@@ -0,0 +1,7 @@
+package com.fdkankan.scene.service;
+
+public interface IWbService {
+
+    void sendMq(String num);
+
+}

+ 53 - 29
src/main/java/com/fdkankan/scene/service/impl/BoxModelServiceImpl.java

@@ -2,6 +2,7 @@ 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.JSONArray;
@@ -43,6 +44,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
+
 /**
  * <p>
  * TODO
@@ -55,7 +58,7 @@ import org.springframework.web.multipart.MultipartFile;
 @Service
 public class BoxModelServiceImpl implements IBoxModelService {
 
-    @Autowired
+    @Resource
     private FYunFileServiceInterface fYunFileService;
     @Autowired
     private IScenePlusService scenePlusService;
@@ -78,40 +81,55 @@ public class BoxModelServiceImpl implements IBoxModelService {
             throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
         }
 
-        if(!FileUtils.checkFileSizeIsLimit(file.getSize(), 5, "M")){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7023, "5M");
-        }
+//        if(!FileUtils.checkFileSizeIsLimit(file.getSize(), 5, "M")){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_7023, "5M");
+//        }
         String path = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "boxModel/" + sid + "/";
-        String zipPath = path + file.getOriginalFilename();
-        String srcPath = path + "data/";
-        String glbPath = path + sid + ".glb";
-
-        FileUtil.del(path);
-        FileUtil.mkParentDirs(zipPath);
-        file.transferTo(new File(zipPath));
-
-        //解压
-        ZipUtil.unzip(zipPath,srcPath);
-
-        //校验是否包含目录,如果包含目录提示错误
-        File srcFile = new File(srcPath);
-        Arrays.stream(srcFile.listFiles()).forEach(subFile->{
-            if(subFile.isDirectory()){
-                throw new BusinessException(ErrorCode.FAILURE_CODE_5065);
+        try {
+            String zipPath = path + file.getOriginalFilename();
+            String srcPath = path + "data/";
+            String glbPath = path + sid + ".glb";
+
+            FileUtil.del(path);
+            FileUtil.mkParentDirs(zipPath);
+            file.transferTo(new File(zipPath));
+
+            //解压
+            ZipUtil.unzip(zipPath,srcPath, CharsetUtil.CHARSET_GBK);
+
+            //校验是否包含目录,如果包含目录提示错误
+            File srcFile = new File(srcPath);
+            Arrays.stream(srcFile.listFiles()).forEach(subFile->{
+                if(subFile.isDirectory()){
+                    throw new BusinessException(ErrorCode.FAILURE_CODE_5065);
+                }
+            });
+
+            //转glb
+            OBJToGLBUtil.objToGlb(srcPath, glbPath);
+
+            if(!ComputerUtil.checkComputeCompleted(glbPath, 10, 2000)){
+                throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
             }
-        });
 
-        //转glb
-        OBJToGLBUtil.objToGlb(srcPath, glbPath);
+            //上传glb
+            fYunFileService.uploadFile(bucket, glbPath, String.format(UploadFilePath.USER_EDIT_PATH, num) + "boxModels/" + sid + ".glb");
 
-        if(!ComputerUtil.checkComputeCompleted(glbPath, 3, 2000)){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
-        }
+            //上传原始obj相关文件
+            List<File> files = FileUtil.loopFiles(srcPath);
+            files.stream().forEach(v->{
+                String ossKey = String.format(UploadFilePath.USER_EDIT_PATH, num) + "boxModels/" + sid + "/" + v.getAbsolutePath().replace(srcPath, "");
+                fYunFileService.uploadFile(v.getAbsolutePath(), ossKey);
+            });
 
-        //上传glb
-        fYunFileService.uploadFile(bucket, glbPath, String.format(UploadFilePath.USER_EDIT_PATH, num) + "boxModels/" + sid + ".glb");
+            return ResultData.ok(sid + ".glb");
 
-        return ResultData.ok(sid + ".glb");
+        }catch (Exception e){
+            log.error("上传三维模型失败", e);
+            throw e;
+        }finally {
+            FileUtil.del(path);
+        }
     }
 
     public static void main(String[] args) {
@@ -158,6 +176,12 @@ public class BoxModelServiceImpl implements IBoxModelService {
         //写数据库
         this.updateBoxModels(sceneEditInfo, boxModels);
 
+        //删除oss文件
+        String glbKey = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + "boxModels/" + param.getSid() + ".glb";
+        fYunFileService.deleteFile(glbKey);
+        String modelPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + "boxModels/" + param.getSid();
+        fYunFileService.deleteFolder(modelPath);
+
         return ResultData.ok();
     }
 

+ 5 - 0
src/main/java/com/fdkankan/scene/service/impl/SceneEditInfoServiceImpl.java

@@ -118,6 +118,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
     private ISceneDrawService sceneDrawService;
     @Autowired
     private ISceneDynamicPanelService sceneDynamicPanelService;
+    @Autowired
+    private IWbService wbService;
 
     @Transactional
     @Override
@@ -316,6 +318,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         scenePlus.setHouseType(this.existsHouseType(bucket, num));
         scenePlusService.updateById(scenePlus);
 
+        //推送文保系统
+        wbService.sendMq(num);
+
         return ResultData.ok();
     }
 

+ 50 - 0
src/main/java/com/fdkankan/scene/service/impl/WbServiceImpl.java

@@ -0,0 +1,50 @@
+package com.fdkankan.scene.service.impl;
+
+import com.fdkankan.common.constant.SceneSource;
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+import com.fdkankan.scene.entity.Camera;
+import com.fdkankan.scene.entity.CameraDetail;
+import com.fdkankan.scene.entity.ScenePlus;
+import com.fdkankan.scene.service.ICameraDetailService;
+import com.fdkankan.scene.service.ICameraService;
+import com.fdkankan.scene.service.IScenePlusService;
+import com.fdkankan.scene.service.IWbService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+@Slf4j
+@Service
+public class WbServiceImpl implements IWbService {
+
+    @Autowired
+    private RabbitMqProducer mqProducer;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private ICameraService cameraService;
+    @Autowired
+    private ICameraDetailService cameraDetailService;
+
+    @Override
+    public void sendMq(String num) {
+        try {
+            ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+            Camera camera = cameraService.getById(scenePlus.getCameraId());
+            CameraDetail cameraDetail = cameraDetailService.findByCameraId(camera.getId());
+            if(Objects.isNull(cameraDetail.getCompanyId()) || cameraDetail.getCompanyId() != 26 || scenePlus.getSceneSource() != SceneSource.ZT.code().intValue()){
+                return;
+            }
+            Map<String, Object> params = new HashMap<>();
+            params.put("sceneCode", num);
+            params.put("sceneName", scenePlus.getTitle());
+            mqProducer.sendByWorkQueue("relics-update-name-queue", params);
+        }catch (Exception e){
+            log.error("发送看见场景到全景看看失败, num:{}", num, e);
+        }
+    }
+}