瀏覽代碼

优化场景码加载逻辑

tianboguang 3 年之前
父節點
當前提交
21642d66bb

+ 0 - 82
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -7,9 +7,7 @@ import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 场景文件上传模块
@@ -33,54 +31,6 @@ public class SceneFileController{
         return sceneFileBuildService.preUpload(params);
     }
 
-
-
-    /**
-     * 获取文件上传的状态
-     * @param params
-     * @return
-     * @throws Exception
-     */
-    @PostMapping("getProgress")
-    public ResponseSceneFile getProgress(String params) throws Exception {
-        return sceneFileBuildService.getProgress(params);
-    }
-
-    /**
-     * 单个文件上传
-     * @param file
-     * @param params
-     * @return
-     */
-    @PostMapping("upload")
-    public ResultData upload(@RequestParam(value = "file",required = false) MultipartFile file,
-                             String params) throws Exception {
-        return sceneFileBuildService.uploadFile(file, params);
-    }
-
-    /**
-     * 上传大文件
-     * @param file
-     * @return
-     * @throws
-     */
-    @PostMapping("uploadBigFile")
-    public ResultData uploadBigFile(@RequestParam(value = "file",required = false) MultipartFile file,
-                                String params) throws Exception {
-        return sceneFileBuildService.uploadFile(file, params);
-    }
-
-    /**
-     * 更新fileid文件的上传状态  -- 作废
-     *
-     * @param params
-     * @return
-     */
-    @PostMapping("uploadSuccess")
-    public ResultData uploadSuccess(String params) throws Exception {
-        return sceneFileBuildService.uploadSuccess(params);
-    }
-
     /**
      * 更新fileid文件的上传状态  - 后端八目上传逻辑
      *
@@ -102,36 +52,4 @@ public class SceneFileController{
     public ResultData turntableUploadSuccess(String params) throws Exception {
         return sceneFileBuildService.turntableUploadSuccess(params);
     }
-
-    /**
-     * 获取亚马逊S3文件上传url
-     *
-     * @return
-     */
-    @PostMapping("getS3UploadUrl")
-    public ResultData getS3UploadUrl(String params) throws Exception {
-        return sceneFileBuildService.getS3UploadUrl(params);
-    }
-
-    /**
-     * 计算双目场景 - 新双目相机上传 小红屋
-     *
-     * @return
-     */
-    @PostMapping("buildLiteScene")
-    public ResultData buildLiteScene(String prefix, String dataFdage, String zipName, String userName, String password, String oldNum) throws Exception{
-        return sceneFileBuildService.buildLiteScene(prefix, dataFdage, zipName, userName, password, oldNum);
-
-
-    }
-
-    /**
-     * 获取亚马逊S3文件上传url
-     * @return
-     */
-    @PostMapping("buildScene")
-    public ResultData buildScene(String prefix, String unicode, String zip, String dataFdage) throws Exception{
-        return sceneFileBuildService.buildScene(prefix, unicode, zip, dataFdage);
-    }
-
 }

+ 10 - 1
src/main/java/com/fdkankan/contro/mapper/IScene3dNumMapper.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fdkankan.contro.entity.Scene3dNum;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
 import java.util.List;
 
@@ -18,8 +20,15 @@ import java.util.List;
 @Mapper
 public interface IScene3dNumMapper extends BaseMapper<Scene3dNum> {
 
-    List<String> findSceneNum();
+    @Select("SELECT num FROM t_scene_3d_num  WHERE used = 0 AND rec_status = 'A' LIMIT #{pageSize}")
+    List<String> findSceneNum(@Param("pageSize") int pageSize);
 
+    @Update("<script>" +
+            "update t_scene_3d_num set used = 1 , update_time = now() where code in " +
+            "<foreach item='num' collection='sceneCodes' open='(' separator=',' close=')'>" +
+            "  #{num}" +
+            " </foreach>" +
+            "</script>")
     void updateUsedStatus(@Param("sceneCodes") List<String> sceneCodes);
 
 }

+ 0 - 20
src/main/java/com/fdkankan/contro/service/ICameraSpaceService.java

@@ -1,20 +0,0 @@
-package com.fdkankan.contro.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.fdkankan.contro.entity.CameraSpace;
-import com.fdkankan.contro.vo.ResponseCameraSpace;
-
-import java.util.List;
-
-/**
- * <p>
- * 相机容量表 服务类
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-public interface ICameraSpaceService extends IService<CameraSpace> {
-
-    List<ResponseCameraSpace> getVoListByCameraId(Long cameraId);
-}

+ 0 - 17
src/main/java/com/fdkankan/contro/service/IManagerService.java

@@ -1,17 +0,0 @@
-package com.fdkankan.contro.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.fdkankan.contro.entity.Manager;
-
-/**
- * <p>
- * 管理员表 服务类
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-public interface IManagerService extends IService<Manager> {
-
-
-}

+ 2 - 4
src/main/java/com/fdkankan/contro/service/IScene3dNumService.java

@@ -15,9 +15,7 @@ import java.util.List;
  */
 public interface IScene3dNumService extends IService<Scene3dNum> {
 
-    List<String> findSceneNum();
-
-    Scene3dNum findByNum(String sceneCode);
+    List<String> findSceneNum(int pageSize);
 //
     void updateUsedStatus(List<String> nums);
 
@@ -30,7 +28,7 @@ public interface IScene3dNumService extends IService<Scene3dNum> {
     /**
      * 批量生成场景码并放入码池
      */
-    void batchCreateSceneNum();
+    void batchCreateSceneNum(boolean force);
 
 
 

+ 0 - 13
src/main/java/com/fdkankan/contro/service/ISceneFileBuildService.java

@@ -20,21 +20,8 @@ public interface ISceneFileBuildService extends IService<SceneFileBuild> {
 
     ResponseSceneFile preUpload(String params) throws Exception;
 
-    ResponseSceneFile getProgress(String params) throws Exception;
-
-    ResultData uploadFile(MultipartFile file, String params) throws Exception;
-
-    ResultData uploadSuccess(String params) throws Exception;
-
     ResultData uploadSuccessBuild(String params) throws Exception;
 
     ResultData turntableUploadSuccess(String params) throws Exception;
 
-    ResultData getS3UploadUrl(String params) throws Exception;
-
-    ResultData buildLiteScene(String prefix, String dataFdage, String zipName, String userName,
-                              String password, String oldNum) throws Exception;
-
-    ResultData buildScene(String prefix, String unicode, String zip, String dataFdage) throws Exception;
-
 }

+ 0 - 32
src/main/java/com/fdkankan/contro/service/impl/CameraSpaceServiceImpl.java

@@ -1,32 +0,0 @@
-package com.fdkankan.contro.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fdkankan.contro.entity.CameraSpace;
-import com.fdkankan.contro.mapper.ICameraSpaceMapper;
-import com.fdkankan.contro.service.ICameraSpaceService;
-import com.fdkankan.contro.vo.ResponseCameraSpace;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * <p>
- * 相机容量表 服务实现类
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-@Service
-public class CameraSpaceServiceImpl extends ServiceImpl<ICameraSpaceMapper, CameraSpace> implements ICameraSpaceService {
-
-    @Resource
-    private ICameraSpaceMapper cameraSpaceMapper;
-
-    @Override
-    public List<ResponseCameraSpace> getVoListByCameraId(Long cameraId) {
-        return cameraSpaceMapper.getVoListByCameraId(cameraId);
-    }
-
-}

+ 0 - 20
src/main/java/com/fdkankan/contro/service/impl/ManagerServiceImpl.java

@@ -1,20 +0,0 @@
-package com.fdkankan.contro.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fdkankan.contro.entity.Manager;
-import com.fdkankan.contro.mapper.IManagerMapper;
-import com.fdkankan.contro.service.IManagerService;
-import org.springframework.stereotype.Service;
-
-/**
- * <p>
- * 管理员表 服务实现类
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-@Service
-public class ManagerServiceImpl extends ServiceImpl<IManagerMapper, Manager> implements IManagerService {
-
-}

+ 40 - 59
src/main/java/com/fdkankan/contro/service/impl/Scene3dNumServiceImpl.java

@@ -1,12 +1,10 @@
 package com.fdkankan.contro.service.impl;
 
-import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.common.constant.CommonStatus;
 import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.constant.TbStatus;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.RandomUtil;
 import com.fdkankan.contro.entity.Scene3dNum;
@@ -21,11 +19,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.util.HashSet;
 import java.util.List;
 import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
 /**
@@ -40,13 +40,14 @@ import java.util.stream.Collectors;
 @Service
 public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3dNum> implements IScene3dNumService {
 
-    private
-
     @Autowired
-    RedisUtil redisUtil;
+    private RedisUtil redisUtil;
     @Autowired
-    RedisLockUtil redisLockUtil;
-    @Value("${scene.num.threshold:1000}")
+    private RedisLockUtil redisLockUtil;
+
+    @Value("${scene.num.cachePageSize:500}")
+    private int cachePageSize;
+    @Value("${scene.num.threshold:10000}")
     private int threshold;
     @Value("${scene.num.prefix:V4-}")
     private String numPrefix;
@@ -61,23 +62,29 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
             return addPrefix(sceneNum,cameraType);
         }
         // 分布式加锁
-        Long loading =  redisUtil.incr(RedisLockKey.LOCK_FDKANKAN_SCENE_NUMS, 1);
-        if (loading.compareTo(1L) == 0) {
+        boolean lock =  redisLockUtil.lock(RedisLockKey.LOCK_FDKANKAN_SCENE_NUMS, RedisKey.EXPIRE_TIME_10_MINUTE);
+        if (lock) {
             try {
-                log.info("开始从数据库加载场景码");
-                List<String> nums = this.findSceneNum();
-                this.updateUsedStatus(nums);
+                log.info("开始加载场景码缓存");
+                List<String> nums = this.findSceneNum(cachePageSize);
+                if(CollectionUtils.isEmpty(nums)){
+                    batchCreateSceneNum(true);
+                    nums = this.findSceneNum(cachePageSize);
+                }else{
+                    CompletableFuture.runAsync(() -> batchCreateSceneNum(false));
+                }
                 redisUtil.lRightPushAll(RedisKey.FDKANKAN_SCENE_NUMS, nums);
-                log.info("场景码加载完成");
+                this.updateUsedStatus(nums);
+                log.info("场景码加载缓存完成");
             } catch (Exception e) {
-                log.error("场景码加载失败", e);
+                log.error("场景码加载缓存失败", e);
             } finally {
-                redisUtil.decr(RedisLockKey.LOCK_FDKANKAN_SCENE_NUMS, 1);
+                redisLockUtil.unlockLua(RedisLockKey.LOCK_FDKANKAN_SCENE_NUMS);
             }
         }else{
-            // 等待1秒加载缓存
+            // 等待2秒加载缓存
             try {
-                Thread.sleep(1000);
+                Thread.sleep(2000);
             } catch (InterruptedException e) {
                 e.printStackTrace();
             }
@@ -98,28 +105,33 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
     }
 
     @Override
-    public void batchCreateSceneNum() {
-
+    public void batchCreateSceneNum(boolean force) {
         String lockKey = String.format(RedisLockKey.LOCK_BATCH_CREATE_NUM);
         boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_10_MINUTE);
         if(!lock){
             return;
         }
         try {
-            long count = this.count(
-                new LambdaQueryWrapper<Scene3dNum>().eq(Scene3dNum::getUsed, CommonStatus.NO.code()));
-            if(count > threshold){
-                return;
+            if (!force) {
+                long count = this.count(new LambdaQueryWrapper<Scene3dNum>().eq(Scene3dNum::getUsed, CommonStatus.NO.code()));
+                if (count > threshold) {
+                    return;
+                }
             }
             int batchCnt = threshold / batchSize + (threshold % batchSize > 0 ? 1 : 0);
             for (int i = 0; i < batchCnt; i++){
                 Set<String> numSet = this.turnCreateSceneNum(batchSize);
-                List<Scene3dNum> scene3dNumList = numSet.stream().map(num -> {
+                List<Scene3dNum> scene3dNumList = numSet.parallelStream().map(num -> {
                     Scene3dNum scene3dNum = new Scene3dNum();
                     scene3dNum.setNum(num);
                     return scene3dNum;
                 }).collect(Collectors.toList());
-                this.saveBatch(scene3dNumList);
+                try{
+                    this.saveBatch(scene3dNumList);
+                }catch (Exception e){
+                    log.error("场景码插入异常!");
+                    e.printStackTrace();
+                }
             }
         }finally {
             redisLockUtil.unlockLua(lockKey);
@@ -127,47 +139,16 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
     }
 
     private Set<String> turnCreateSceneNum(int cnt){
-
-        String num;
         Set<String> numSet = new HashSet<>();
         for(int i = 0; i < cnt; i++){
-            num = numPrefix + RandomUtil.generateShortUuid();
-            numSet.add(num);
-        }
-        List<Scene3dNum> existList = this.list(
-            new LambdaQueryWrapper<Scene3dNum>()
-                .in(Scene3dNum::getNum, numSet));
-
-        Set<String> existNumSet = null;
-        if(CollUtil.isNotEmpty(existList)){
-            existNumSet = existList.stream().map(Scene3dNum::getNum).collect(Collectors.toSet());
-        }
-        if(CollUtil.isNotEmpty(existNumSet)){
-            numSet.removeAll(existNumSet);
-        }
-        if(numSet.size() < cnt){
-            numSet.addAll(this.turnCreateSceneNum(cnt - numSet.size()));
+            numSet.add(numPrefix + RandomUtil.generateShortUuid());
         }
         return numSet;
     }
 
-
-
-
-
     @Override
-    public List<String> findSceneNum() {
-        return baseMapper.findSceneNum();
-    }
-
-    @Override
-    public Scene3dNum findByNum(String sceneCode) {
-        List<Scene3dNum> list = this.list(new LambdaQueryWrapper<Scene3dNum>()
-                .eq(Scene3dNum::getNum, sceneCode));
-        if(CollUtil.isEmpty(list)){
-            return null;
-        }
-        return list.get(0);
+    public List<String> findSceneNum(int pageSize) {
+        return baseMapper.findSceneNum(pageSize);
     }
 
     @Override

+ 0 - 539
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -4,8 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -32,11 +30,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
-import java.io.IOException;
-import java.time.LocalDate;
 import java.util.*;
 
 /**
@@ -56,9 +51,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     @Value("${main.url}")
     private String mainUrl;
 
-    @Value("${scene.pro.url}")
-    private String sceneProUrl;
-
     @Value("${scene.pro.new.url}")
     private String sceneProNewUrl;
 
@@ -71,23 +63,11 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     @Value("${ecs.type}")
     private String ecsType;
 
-    @Value("${unCalculated.company.ids:#{null}}")
-    private String[] unCalculatedCompanyIds;
-
     @Value("${queue.modeling.modeling-call}")
     private String queueModelingCall;
     @Value("${queue.modeling.modeling-pre}")
     private String queueModelingPre;
 
-    @Value("${queue.modeling.video-a}")
-    private String queueVideoA;
-
-    @Value("${queue.modeling.pic-a}")
-    private String queuePicA;
-
-    @Autowired
-    private ISceneFileUploadService sceneFileUploadService;
-
     @Autowired
     private RedisUtil redisUtil;
 
@@ -241,313 +221,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return list.get(0);
     }
 
-    @Override
-    public ResponseSceneFile getProgress(String params) throws Exception {
-        log.info("getProgress-params:{} ", params);
-        if (StrUtil.isEmpty(params)){
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        params = params.replaceAll("%2B", "+");
-        Base64 base64 = new Base64();
-        String cipher = params;
-        // 私钥解密过程
-        byte[] res = RSAEncrypt.decrypt(RSAEncrypt.loadPrivateKeyByStr(RSAEncrypt.loadPrivateKeyByFile()),
-                base64.decode(cipher));
-        String restr = new String(res, "UTF-8");
-        log.debug("getProgress-params解密结果:{}" , restr);
-        String[] strArr = restr.split(SPLICE);
-        if (strArr.length != 3) {
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        String fileId = strArr[0];
-        String chunk = strArr[1];
-
-        chunk = chunk.split(SPLICE)[0];
-        SceneFileUpload sceneFileUpload = sceneFileUploadService.findByFileIdAndChunk(fileId, Integer.valueOf(chunk));
-
-        ResponseSceneFile responseSceneFile = new ResponseSceneFile();
-        responseSceneFile.setUploadStatus(sceneFileUpload != null ? sceneFileUpload.getUploadStatus() : -1);
-        return responseSceneFile;
-    }
-
-    @Override
-    public ResultData uploadFile(MultipartFile file, String params) throws Exception{
-        log.info("upload-params: "+params);
-        if (StringUtils.isEmpty(params)){
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        params = params.replaceAll("%2B", "+");
-        Base64 base64 = new Base64();
-        String cipher = params;
-        // 私钥解密过程
-        byte[] res = RSAEncrypt.decrypt(RSAEncrypt.loadPrivateKeyByStr(RSAEncrypt.loadPrivateKeyByFile()),
-                base64.decode(cipher));
-        String restr = new String(res, "UTF-8");
-        log.debug("upload-params解密结果:{}", restr);
-        String[] strArr = restr.split(SPLICE);
-        if (strArr.length != 6) {
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        String mac = strArr[0];
-        String fileId = strArr[1];
-        String picNum = strArr[2];
-        String md5 = strArr[3];
-        String chunk = strArr[4];
-
-        ResultData result = null;
-        if (file.isEmpty()){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5048);
-        }
-        if (StringUtils.isEmpty(fileId)){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5049);
-        }
-        if (picNum == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5050);
-        }
-        if (StringUtils.isEmpty(mac)){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5044);
-        }
-        if (StringUtils.isEmpty(md5)){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5051);
-        }
-        long size = file.getSize();
-        log.warn("fileId:"+fileId+"---picNum:"+picNum+"---size:"+size+"---md5:"+md5+"---mac:"+mac);
-        chunk = chunk.split(SPLICE)[0];
-        // 获取文件名
-        String fileName = file.getOriginalFilename();
-        log.info("上传的文件名为:" + fileName);
-        // 获取文件的后缀名
-        String suffixName = fileName.substring(fileName.lastIndexOf("."));
-        log.info("上传的后缀名为:" + suffixName);
-        Object folderNameObject = redisUtil.get(fileId);
-        String folderName = folderNameObject == null ? null : (String)folderNameObject;
-        if(StrUtil.isEmpty(folderName)){
-            String dataSource = scenePlusService.getDataSourceLikeUnicode("/" + fileId + "/");
-            if(StrUtil.isNotEmpty(dataSource)){
-                folderName = dataSource.substring(dataSource.lastIndexOf("/") + 1);
-            }
-        }
-        // 1. 判断该文件是否已经上传过
-        // 2. 如果已经上传过,判断MD5值和文件大小是否相等。如果相等,更新数据记录。如果不相等,删除该文件,重新上传。
-        // 3. 如果未上传过,需要上传。
-        StringBuffer filePathBuffer = new StringBuffer(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator).append("capture");
-        StringBuffer sb = new StringBuffer(routeConfig.getHardDisk()).append(filePathBuffer.toString()).append(File.separator).append(fileName);
-
-        boolean needUpload = false;
-        File dbFile = new File(sb.toString());
-        if (dbFile.exists()){
-            String fileMD5 = FileMd5Util.getFileMD5(dbFile);
-            if (md5.equals(fileMD5) && dbFile.length() == size){
-                log.warn("文件已存在,MD5和文件大小一致。");
-
-                SceneFileUpload uploadEntity = sceneFileUploadService.findByFileIdAndChunk(fileId, Integer.valueOf(chunk));
-                if (uploadEntity != null){
-                    uploadEntity.setSize((int) size);
-                    uploadEntity.setMd5(md5);
-                    uploadEntity.setFilePath(sb.toString());
-                    uploadEntity.setFileSourceName(fileName);
-                    uploadEntity.setUploadStatus(UploadStatus.SUCCESS.code());
-                    sceneFileUploadService.updateById(uploadEntity);
-                }else{
-                    SceneFileUpload sceneFileUploadEntity = new SceneFileUpload();
-                    sceneFileUploadEntity.setSize((int) size);
-                    sceneFileUploadEntity.setMd5(md5);
-                    sceneFileUploadEntity.setFilePath(sb.toString());
-                    sceneFileUploadEntity.setFileSourceName(fileName);
-                    sceneFileUploadEntity.setUploadStatus(UploadStatus.SUCCESS.code());
-                    sceneFileUploadEntity.setFileId(fileId);
-                    sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
-                    sceneFileUploadEntity.setRecStatus(RecStatus.VALID.code());
-                    sceneFileUploadService.save(sceneFileUploadEntity);
-                }
-                result = ResultData.ok();
-            }else if (!md5.equals(fileMD5)) {
-                log.warn("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
-                FileUtil.delFile(sb.toString());
-                needUpload = true;
-            }else if (dbFile.length() != size){
-                log.warn("文件已上传,文件大小不一致。上传失败");
-                FileUtil.delFile(sb.toString());
-                needUpload = true;
-            }
-        }else {
-            log.warn("文件不存在,需要重新上传");
-            needUpload = true;
-        }
-
-        // 4. 上传成功后,校验MD5和文件大小是否相等
-        // 5. 如果相等,更新数据记录。如果不相等,返回上传失败结果。
-        try {
-            if (needUpload){
-                String name = fileName.substring(0, fileName.lastIndexOf("."));
-                String filePath = this.saveFile(file, filePathBuffer.toString(), name);
-                File uploadFile = new File(filePath);
-                String fileMD5 = FileMd5Util.getFileMD5(uploadFile);
-
-                SceneFileUpload sceneFileUploadEntity = new SceneFileUpload();
-                sceneFileUploadEntity.setSize((int) size);
-                sceneFileUploadEntity.setMd5(md5);
-                sceneFileUploadEntity.setFilePath(sb.toString());
-                sceneFileUploadEntity.setFileSourceName(fileName);
-                sceneFileUploadEntity.setFileId(fileId);
-                sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
-                sceneFileUploadEntity.setRecStatus(RecStatus.VALID.code());
-
-                if (md5.equals(fileMD5) && uploadFile.length() == size){
-                    log.warn("文件已上传,MD5和文件大小一致。上传成功");
-                    sceneFileUploadEntity.setUploadStatus(1);
-                    sceneFileUploadService.save(sceneFileUploadEntity);
-                    result = ResultData.ok();
-                }else if (!md5.equals(fileMD5)) {
-                    log.warn("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
-                    sceneFileUploadEntity.setUploadStatus(-1);
-                    sceneFileUploadService.save(sceneFileUploadEntity);
-                    result = ResultData.error(ErrorCode.FAILURE_CODE_5052);
-                }else if (uploadFile.length() != size){
-                    log.warn("文件已上传,文件大小不一致。上传失败");
-                    sceneFileUploadEntity.setUploadStatus(-1);
-                    sceneFileUploadService.save(sceneFileUploadEntity);
-                    result = ResultData.error(ErrorCode.FAILURE_CODE_5052);
-                }
-            }
-        }catch (IllegalStateException | IOException e) {
-            log.error(ErrorCode.FAILURE_CODE_5052.message(), e);
-            result = ResultData.error(ErrorCode.FAILURE_CODE_5052);
-        }
-        return result;
-    }
-
-    public String saveFile(MultipartFile file, String filePath, String fileId) throws IOException {
-        //扩展名格式
-        String extName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
-        String name;
-        /*
-          指定上传目录
-         */
-        if (filePath != null && !"".equals(filePath.trim())) {
-            name = designatedUp(filePath, fileId, file);
-            return name;
-        }
-        /*
-          默认上传目录
-         */
-        //图片类型文件
-        if (this.inArray(routeConfig.getImageType(), extName)) {
-            filePath = routeConfig.getImageFolder();
-        }
-        //视频类型文件
-        else if (this.inArray(routeConfig.getVideoType(), extName)) {
-            filePath = routeConfig.getVideoFolder();
-        }
-        //文档类型文件
-        else if (this.inArray(routeConfig.getDocumentType(), extName)) {
-            filePath = routeConfig.getDocumentFolder();
-        }
-        //音频类型文件
-        else if (this.inArray(routeConfig.getMusicType(), extName)) {
-            filePath = routeConfig.getMusicFolder();
-        } else {
-            return "This upload type is not supported temporarily";
-        }
-        name = myfileUp(filePath, file);
-        return name;
-    }
-
-    /**
-     * 默认上传文件到文件夹
-     *
-     * @param folder 默认文件夹
-     * @param file   上传的文件
-     * @return
-     */
-    private String myfileUp(String folder, MultipartFile file) throws IOException {
-        LocalDate today = LocalDate.now();
-        String saveName = File.separator + today.getYear() + "." + today.getMonthValue() + File.separator;
-        String fileCode = UUID.randomUUID().toString().trim().replaceAll("-", "");
-        String returnName = FileUpload.fileUp(file, routeConfig.getHardDisk() + File.separator + folder + saveName, fileCode);
-        saveName = folder + File.separator + saveName + File.separator + returnName;
-        log.warn("This file has been uploaded: " + saveName);
-        return saveName;
-    }
-
-    /**
-     * 判断数组中是否包含某个元素
-     *
-     * @param array   类型的数组
-     * @param element 被检查的类型
-     * @return
-     */
-    private boolean inArray(String[] array, String element) {
-        boolean flag = false;
-        for (String type : array) {
-            if (element.equals(type)) {
-                flag = true;
-                break;
-            }
-        }
-        return flag;
-    }
-
-    /**
-     * 指定目录上传文件
-     *
-     * @param folder 指定文件夹
-     * @param file   上传文件
-     * @return
-     */
-    private String designatedUp(String folder, String fileId, MultipartFile file) throws IOException {
-        StringBuffer sb = new StringBuffer(routeConfig.getHardDisk()).append(File.separator).append(folder);
-        String returnName = FileUpload.fileUp(file, sb.toString(), fileId);
-        String filePathName = sb.toString() + File.separator + File.separator + returnName;
-        log.warn("This file has been uploaded: " + filePathName);
-        return filePathName;
-    }
-
-    @Override
-    public ResultData uploadSuccess(String params) throws Exception {
-        log.info("uploadSuccess-params: " + params);
-        if (StrUtil.isEmpty(params)) {
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        params = params.replaceAll("%2B", "+");
-        Base64 base64 = new Base64();
-        String cipher = params;
-        // 私钥解密过程
-        byte[] res = RSAEncrypt.decrypt(RSAEncrypt.loadPrivateKeyByStr(RSAEncrypt.loadPrivateKeyByFile()),
-                base64.decode(cipher));
-        String restr = new String(res, "UTF-8");
-        log.debug("uploadSuccess-params解密结果:" + restr);
-        String[] strArr = restr.split(SPLICE);
-        if (strArr.length != 3) {
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        String mac = strArr[0];
-        String fileId = strArr[1];
-        Object folderNameObject = redisUtil.get(fileId);
-        String folderName = folderNameObject == null ? null : (String)folderNameObject;
-        if(StringUtils.isEmpty(folderName)){
-            String dataSource = scenePlusService.getDataSourceLikeUnicode("/" + fileId + "/");
-            if(StrUtil.isNotEmpty(dataSource)){
-                folderName = dataSource.substring(dataSource.lastIndexOf("/") + 1);
-            }
-
-            if(StringUtils.isEmpty(folderName)){
-                SceneFileBuild sceneFileBuild = this.findByFileId(fileId);
-                if(sceneFileBuild != null){
-                    folderName = sceneFileBuild.getUnicode();
-                }
-            }
-        }
-        StringBuilder filePathBuffer = new StringBuilder(routeConfig.getHardDisk()).append(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator).append("capture").append(File.separator);
-        boolean flag = this.uploadSuccess(fileId, filePathBuffer);
-
-        if(flag){
-            //调用建模的方法
-        }
-        buildScene(filePathBuffer.toString(), fileId, false, null);
-        return ResultData.ok();
-    }
-
     public void buildScene(String filePath, String fileId, boolean fromOss, String prefix) throws Exception{
         //获取解压后的资源的data.fdage中的数据
         String data = FileUtils.readFile(filePath + "data.fdage");
@@ -814,19 +487,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         }
     }
 
-    public boolean uploadSuccess(String fileId, StringBuilder filePathBuffer) {
-        SceneFileBuild sceneFileBuild = findByFileId(fileId);
-        if (Objects.isNull(sceneFileBuild))
-            return false;
-
-        Long uploadSuccessCount = sceneFileUploadService.countUploadSuccessByFileId(fileId);
-        sceneFileBuild.setUploadStatus(UploadStatus.SUCCESS.code());
-        sceneFileBuild.setChunks(Integer.valueOf(uploadSuccessCount.toString()));
-        sceneFileBuild.setUpdateTime(Calendar.getInstance().getTime());
-        this.updateById(sceneFileBuild);
-        return true;
-    }
-
     @Override
     public ResultData uploadSuccessBuild(String params) throws Exception {
         log.info("uploadSuccessBuild-params: " + params);
@@ -1421,203 +1081,4 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         mqMsg.setThumb(thumb);
         return mqMsg;
     }
-
-    @Override
-    public ResultData getS3UploadUrl(String params) throws Exception {
-        if (StringUtils.isEmpty(params)) {
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        JSONObject jsonObject = JSON.parseObject(params);
-        if(jsonObject == null){
-            throw new BusinessException(ErrorCode.PARAM_FORMAT_ERROR);
-        }
-        JSONArray files = jsonObject.getJSONArray("Files");
-        if(files == null){
-            throw new BusinessException(ErrorCode.PARAM_FORMAT_ERROR);
-        }
-        List<String> urls = new ArrayList<>();
-        for(int i = 0, len = files.size(); i < len; i++){
-            urls.add(files.getJSONObject(i).getString("filename"));
-        }
-        return ResultData.ok(uploadToOssUtil.getUploadS3Url(urls));
-    }
-
-    @Override
-    public ResultData buildLiteScene(String prefix, String dataFdage, String zipName, String userName, String password, String oldNum) throws Exception{
-        log.info("参数-prefix: {}, dataFdage: {}, zipName: {}, password: {}, userName: {}", prefix,
-                dataFdage, zipName, password, userName);
-
-        if(StringUtils.isEmpty(prefix) || StringUtils.isEmpty(dataFdage) || StringUtils.isEmpty(zipName) ||
-                StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)){
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-
-        Camera camera = cameraService.getByChildName(userName);
-        if(camera == null){
-            camera = cameraService.getBySnCode(userName);
-        }
-        if (camera == null){
-            throw new BusinessException(CameraConstant.FAILURE_6003);
-        }
-        if(!password.equals(camera.getChildPassword())){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_3014);
-        }
-        CameraDetail cameraDetail = cameraDetailService.getByCameraId(camera.getId());
-        if(cameraDetail == null){
-            throw new BusinessException(CameraConstant.FAILURE_6003);
-        }
-        String unicode = prefix.substring(prefix.lastIndexOf("/") + 1);
-        String path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
-
-        //下载data.fdage
-        FileUtils.downLoadFromUrl(prefix + "/" + dataFdage + "?m=" + System.currentTimeMillis(), dataFdage, path + File.separator + "capture");
-        String data = FileUtils.readFile(path + File.separator + "capture/" + dataFdage);
-        JSONObject jsonObject = JSONObject.parseObject(data);
-        if(jsonObject == null){
-            log.info("data.fdage不存在");
-            throw new BusinessException(CameraConstant.FAILURE_6009);
-        }
-
-        String sceneNum = "";
-        //查看场景中的文件目录是否有改文件id,有则重新计算改场景,无则新建场景
-        ScenePlus scenePlus = scenePlusService.getByFileId("/" + unicode);
-        int rebuild = 1;
-        if(StrUtil.isNotEmpty(oldNum)){
-            sceneNum = oldNum;
-        }else {
-
-            if(scenePlus != null){
-                sceneNum = scenePlus.getNum();
-                //重算的场景,先移除该场景对应的容量
-                scenePlusService.resetSpace(sceneNum);
-            }else {
-                sceneNum = scene3dNumService.generateSceneNum(cameraDetail.getType());
-                rebuild = 0;
-            }
-        }
-
-        String localDataPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, sceneNum);
-        String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
-        String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum);
-
-        String cameraName = jsonObject.getJSONObject("cam").getString("uuid");
-        log.info("查询相机:" + cameraName);
-        camera = cameraService.getByChildName(cameraName);
-        if(camera ==  null){
-            log.error("该相机不存在:" + cameraName);
-            //偶现data.fdage给的相机码多了或少了4DKKPRO_
-            if(cameraName.contains("4DKKPRO_")){
-                camera = cameraService.getByChildName(cameraName.replace("4DKKPRO_", ""));
-            }else {
-                camera = cameraService.getByChildName("4DKKPRO_" + cameraName);
-            }
-            if(camera == null){
-                throw new BusinessException(CameraConstant.FAILURE_6003);
-            }
-        }
-
-
-
-        String icon = null;
-        if(jsonObject.containsKey("icon") && StrUtil.isNotEmpty(jsonObject.getString("icon"))){
-            //下载封面图icon
-            FileUtils.downLoadFromUrl(prefix + "/" + jsonObject.getString("icon") + "?m=" + System.currentTimeMillis(), jsonObject.getString("icon"), path + File.separator + "capture");
-            uploadToOssUtil.upload(path + File.separator + "capture" + File.separator +
-                    jsonObject.getString("icon"), imgViewPath + jsonObject.getString("icon"));
-            icon = prefixAli + imgViewPath + jsonObject.getString("icon");
-            if(StorageType.AWS.code().equals(type)){
-                icon = ConstantUrl.PREFIX_AWS + imgViewPath + jsonObject.getString("icon");
-            }
-        }
-
-        JSONObject firmwareVersion = new JSONObject();
-        if(jsonObject.containsKey("camSoftwareVersion") && StrUtil.isNotEmpty(jsonObject.getString("camSoftwareVersion"))){
-            firmwareVersion.put("camSoftwareVersion", jsonObject.getString("camSoftwareVersion"));
-        }
-
-        if(jsonObject.containsKey("version") && StrUtil.isNotEmpty(jsonObject.getString("version"))){
-            firmwareVersion.put("version", jsonObject.getString("version"));
-        }
-
-        String sceneUrl = mainUrl + sceneProNewUrl;
-        String buildType = "V3";
-        //表示新款双目
-        Long cameraType = 5L;
-        if(jsonObject.getJSONObject("cam").getIntValue("type") == 5){
-
-            //6表示小红屋双目
-            cameraType = 6L;
-        }
-
-        Object[] objects = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(),
-                jsonObject.getString("creator"),
-                jsonObject.getString("pwd"), unicode,
-                cameraType, "", prefix, zipName, icon, "0", cameraDetail.getUserId(), userName,
-                jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location"))
-                        ? "sfm" : "slam",
-                jsonObject.getJSONArray("points").size(), jsonObject.getString("name"),
-                jsonObject.getString("info"),
-                jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
-                4, firmwareVersion.toString(), sceneUrl, buildType, ecsType,
-                cameraDetail.getCooperationUser());
-        BuildSceneCallMessage mqMessage = (BuildSceneCallMessage)objects[1];
-        ScenePlusVO scenePlusVO = (ScenePlusVO) objects[0];
-
-        if(scenePlusVO == null){
-            log.info("双目相机入库失败");
-            return ResultData.error(ErrorCode.FAILURE_CODE_5056);
-        }
-        JSONObject statusJson = new JSONObject();
-        //临时将-2改成1,app还没完全更新
-        statusJson.put("status", scenePlusVO.getSceneStatus() == -2? 1 : scenePlusVO.getSceneStatus());
-        statusJson.put("webSite", scenePlusVO.getWebSite());
-        statusJson.put("sceneNum", scenePlusVO.getNum());
-        statusJson.put("thumb", scenePlusVO.getThumb());
-        statusJson.put("payStatus", scenePlusVO.getPayStatus());
-        FileUtils.writeFile(localDataPath + "status.json", statusJson.toString());
-        uploadToOssUtil.upload(localDataPath + "status.json", dataViewPath + "status.json");
-
-        //删除oss的houst_floor.json
-        uploadToOssUtil.delete(dataViewPath + "houst_floor.json");
-
-        rabbitMqProducer.sendByWorkQueue(queueModelingPre, mqMessage);
-
-        Map<String, String> map = new HashMap<>();
-        map.put("sceneNum", sceneNum);
-        map.put("sceneUrl", sceneUrl + sceneNum);
-        return ResultData.ok(map);
-
-
-    }
-
-    @Override
-    public ResultData buildScene(String prefix, String unicode, String zip, String dataFdage) throws Exception{
-
-        String data = FileUtils.readFile(ConstantFilePath.BUILD_MODEL_PATH + unicode + "/data.fdage");
-        JSONObject jsonObject = JSONObject.parseObject(data);
-        String cameraName = jsonObject.getJSONObject("cam").getString("uuid");
-
-        log.info("查询相机:" + cameraName);
-        Camera cameraEntity = cameraService.getByChildName(cameraName);
-        if(cameraEntity ==  null){
-            log.error("该相机不存在:" + cameraName);
-            //偶现data.fdage给的相机码多了或少了4DKKPRO_
-            if(cameraName.contains("4DKKPRO_")){
-                cameraEntity = cameraService.getByChildName(cameraName.replace("4DKKPRO_", ""));
-            }else {
-                cameraEntity = cameraService.getByChildName("4DKKPRO_" + cameraName);
-            }
-            if(cameraEntity == null){
-                throw new BusinessException(CameraConstant.FAILURE_6003);
-            }
-        }
-        CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraEntity.getId());
-        if(detailEntity ==  null){
-            log.error("该相机详情不存在:" + cameraName);
-            throw new BusinessException(CameraConstant.FAILURE_6003);
-        }
-        String sceneNum = scene3dNumService.generateSceneNum(detailEntity.getType());
-
-        return ResultData.ok(mainUrl + sceneProNewUrl + sceneNum);
-    }
 }