Pārlūkot izejas kodu

v4.12.0 上传模型 异步

dengsixing 1 gadu atpakaļ
vecāks
revīzija
04f3f0e633

+ 4 - 4
src/main/java/com/fdkankan/scene/controller/SceneEditController.java

@@ -196,8 +196,8 @@ public class SceneEditController extends BaseController {
      **/
     @CheckPermit
     @PostMapping(value = "/downloadModel")
-    public ResultData downloadTexData(@RequestParam("num") String num) throws Exception {
-        return sceneProService.downloadTexData(num);
+    public ResultData downloadModel(@RequestParam("num") String num) throws Exception {
+        return sceneProService.downloadModel(num);
     }
 
     /**
@@ -212,8 +212,8 @@ public class SceneEditController extends BaseController {
      **/
     @CheckPermit
     @PostMapping(value = "/uploadModel")
-    public ResultData uploadObjAndImg(@RequestParam("num") String num, @RequestParam("file") MultipartFile file) throws Exception {
-        return sceneProService.uploadObjAndImg(num, file);
+    public ResultData uploadModel(@RequestParam("num") String num, @RequestParam("file") MultipartFile file) throws Exception {
+        return sceneProService.uploadModel(num, file);
     }
 
     /**

+ 7 - 1
src/main/java/com/fdkankan/scene/service/ISceneAsynOperLogService.java

@@ -1,5 +1,7 @@
 package com.fdkankan.scene.service;
 
+import com.fdkankan.common.constant.SceneAsynFuncType;
+import com.fdkankan.common.constant.SceneAsynOperType;
 import com.fdkankan.scene.entity.SceneAsynOperLog;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.scene.vo.SceneAsynOperLogParamVO;
@@ -12,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
  *  服务类
  * </p>
  *
- * @author 
+ * @author
  * @since 2022-12-07
  */
 public interface ISceneAsynOperLogService extends IService<SceneAsynOperLog> {
@@ -21,4 +23,8 @@ public interface ISceneAsynOperLogService extends IService<SceneAsynOperLog> {
 
     void cleanDownloadPanorama();
 
+    void checkSceneAsynOper(String num, String operType, String module, String function);
+
+    void cleanLog(String num, String moduleType, String funcType, String... operTypes);
+
 }

+ 2 - 2
src/main/java/com/fdkankan/scene/service/ISceneProService.java

@@ -46,9 +46,9 @@ public interface ISceneProService extends IService<ScenePro> {
 
     void updateUserIdByCameraId(Long userId, Long cameraId);
 
-    ResultData uploadObjAndImg(String num, MultipartFile file) throws Exception;
+    ResultData uploadModel(String num, MultipartFile file) throws Exception;
 
-    ResultData downloadTexData(String num) throws Exception;
+    ResultData downloadModel(String num) throws Exception;
 
     ScenePro getByNum(String num);
 

+ 38 - 6
src/main/java/com/fdkankan/scene/service/impl/SceneAsynOperLogServiceImpl.java

@@ -3,14 +3,12 @@ package com.fdkankan.scene.service.impl;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.fdkankan.common.constant.CommonOperStatus;
-import com.fdkankan.common.constant.CommonStatus;
-import com.fdkankan.common.constant.SceneAsynFuncType;
-import com.fdkankan.common.constant.SceneAsynModuleType;
-import com.fdkankan.common.constant.SceneAsynOperType;
+import com.fdkankan.common.constant.*;
+import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.scene.entity.SceneAsynOperLog;
 import com.fdkankan.scene.mapper.ISceneAsynOperLogMapper;
@@ -19,6 +17,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.scene.vo.SceneAsynOperLogParamVO;
 import com.fdkankan.web.response.ResultData;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -31,7 +30,7 @@ import org.springframework.stereotype.Service;
  *  服务实现类
  * </p>
  *
- * @author 
+ * @author
  * @since 2022-12-07
  */
 @Slf4j
@@ -115,4 +114,37 @@ public class SceneAsynOperLogServiceImpl extends ServiceImpl<ISceneAsynOperLogMa
         });
 
     }
+
+    @Override
+    public void checkSceneAsynOper(String num, String operType, String module, String function) {
+        LambdaQueryWrapper<SceneAsynOperLog> queryWrapper =
+                new LambdaQueryWrapper<SceneAsynOperLog>()
+                        .eq(SceneAsynOperLog::getNum,num)
+                        .eq(SceneAsynOperLog::getState, CommonOperStatus.WAITING.code());
+        if(StrUtil.isNotEmpty(operType)){
+            queryWrapper.eq(SceneAsynOperLog::getOperType, operType);
+        }
+        if(StrUtil.isNotEmpty(module)){
+            queryWrapper.eq(SceneAsynOperLog::getModule, module);
+        }
+        if(StrUtil.isNotEmpty(function)){
+            queryWrapper.eq(SceneAsynOperLog::getFunc, function);
+        }
+        List<SceneAsynOperLog> waittingLogList = this.list(queryWrapper);
+        if(CollUtil.isNotEmpty(waittingLogList)){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5066);
+        }
+    }
+
+    @Override
+    public void cleanLog(String num, String moduleType, String funcType, String... operTypes) {
+        LambdaQueryWrapper<SceneAsynOperLog> wrapper = new LambdaQueryWrapper<SceneAsynOperLog>()
+                .eq(SceneAsynOperLog::getNum, num)
+                .eq(SceneAsynOperLog::getModule, moduleType)
+                .eq(SceneAsynOperLog::getFunc, funcType);
+        if(ArrayUtil.isNotEmpty(operTypes)){
+            wrapper.in(SceneAsynOperLog::getOperType, operTypes);
+        }
+        this.remove(wrapper);
+    }
 }

+ 3 - 28
src/main/java/com/fdkankan/scene/service/impl/SceneEditInfoServiceImpl.java

@@ -1041,15 +1041,10 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         }
 
         //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
-        this.checkSceneAsynOper(num, null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
+        sceneAsynOperLogService.checkSceneAsynOper(num, null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
 
         //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
-        sceneAsynOperLogService.remove(
-            new LambdaQueryWrapper<SceneAsynOperLog>()
-            .eq(SceneAsynOperLog::getNum, num)
-            .eq(SceneAsynOperLog::getModule, SceneAsynModuleType.UPLOAD_DOWNLOAD.code())
-            .eq(SceneAsynOperLog::getFunc, SceneAsynFuncType.PANORAMIC_IMAGE.code())
-        );
+        sceneAsynOperLogService.cleanLog(num, SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code());
 
 
         ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
@@ -1239,26 +1234,6 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         return ResultData.ok(uploadPanoramaVO);
     }
 
-    private void checkSceneAsynOper(String num, String operType, String module, String function){
-        LambdaQueryWrapper<SceneAsynOperLog> queryWrapper =
-            new LambdaQueryWrapper<SceneAsynOperLog>()
-                .eq(SceneAsynOperLog::getNum,num)
-                .eq(SceneAsynOperLog::getState, CommonOperStatus.WAITING.code());
-        if(StrUtil.isNotEmpty(operType)){
-            queryWrapper.eq(SceneAsynOperLog::getOperType, operType);
-        }
-        if(StrUtil.isNotEmpty(module)){
-            queryWrapper.eq(SceneAsynOperLog::getModule, module);
-        }
-        if(StrUtil.isNotEmpty(function)){
-            queryWrapper.eq(SceneAsynOperLog::getFunc, function);
-        }
-        List<SceneAsynOperLog> waittingLogList = sceneAsynOperLogService.list(queryWrapper);
-        if(CollUtil.isNotEmpty(waittingLogList)){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5066);
-        }
-    }
-
     public void uploadPanoramaHandler(String num, String bucket, String target, String imgViewPath, List<String> uploadFileList, String targetImagesPath) throws Exception {
         CreateObjUtil.build3dModel(target , "1");
 
@@ -1351,7 +1326,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         }
 
         //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
-        this.checkSceneAsynOper(num,null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
+        sceneAsynOperLogService.checkSceneAsynOper(num,null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
 
         ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
         String bucket = scenePlusExt.getYunFileBucket();

+ 3 - 2
src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -683,7 +683,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     }
 
     @Override
-    public ResultData uploadObjAndImg(String num, MultipartFile file) throws Exception{
+    public ResultData uploadModel(String num, MultipartFile file) throws Exception{
         if(StrUtil.isEmpty(num)){
             throw new BusinessException(ServerCode.PARAM_REQUIRED, "num");
         }
@@ -729,6 +729,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         return ResultData.ok();
     }
 
+
     /**
      * 老算法(dam)上传模型逻辑
      * @param num
@@ -1023,7 +1024,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         }
     }
 
-    public ResultData downloadTexData(String num) throws Exception {
+    public ResultData downloadModel(String num) throws Exception {
 
         if(StrUtil.isEmpty(num)){
             throw new BusinessException(ErrorCode.PARAM_REQUIRED);