瀏覽代碼

Merge branch 'project-jmga-2.2.0-2.0.1' into project-jmga-dev

dengsixing 3 周之前
父節點
當前提交
75b0e0f011

+ 29 - 0
src/main/java/com/fdkankan/contro/constant/ModelingControlRespCode.java

@@ -0,0 +1,29 @@
+package com.fdkankan.contro.constant;
+
+public enum ModelingControlRespCode {
+
+    FILE_EMPTY_UPLOADEDOP(90000, "缺少fileUploadedOp.cam"),
+    FILE_EMPTY(90000, "缺少文件"),
+    ;
+
+    private Integer code;
+    private String message;
+
+    private ModelingControlRespCode(Integer code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public Integer code() {
+        return this.code;
+    }
+
+    public String message() {
+        return this.message;
+    }
+
+    public String formatMessage(Object... args) {
+        return String.format(this.message, args);
+    }
+
+}

+ 8 - 0
src/main/java/com/fdkankan/contro/constant/RedisKeyExt.java

@@ -0,0 +1,8 @@
+package com.fdkankan.contro.constant;
+
+public class RedisKeyExt {
+
+    public final static String CAM_FILE_LIST = "cam_file_list:@unicode@";
+
+
+}

+ 5 - 1
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -264,7 +264,11 @@ public class SceneFileController{
         String localPath = parentPath + details.getIndex() + details.getFileName();
         String localPath = parentPath + details.getIndex() + details.getFileName();
         FileUtil.mkParentDirs(localPath);
         FileUtil.mkParentDirs(localPath);
         String url = "https://survey.4dkankan.com"  + localPath.replace("4dkankan/", "");
         String url = "https://survey.4dkankan.com"  + localPath.replace("4dkankan/", "");
-        file.transferTo(new File(localPath));
+        if(details.getFileName().equals("data.fdage")){
+            file.transferTo(new File(parentPath + details.getFileName()));
+        }else{
+            file.transferTo(new File(localPath));
+        }
 
 
         SendCallAlgorithmParam param = new SendCallAlgorithmParam();
         SendCallAlgorithmParam param = new SendCallAlgorithmParam();
         param.setFilepath(url);
         param.setFilepath(url);

+ 0 - 1
src/main/java/com/fdkankan/contro/mq/listener/UpdateSceneStatusListener.java

@@ -3,7 +3,6 @@ package com.fdkankan.contro.mq.listener;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.model.constants.UploadFilePath;

+ 35 - 7
src/main/java/com/fdkankan/contro/mq/listener/UploadShootingListener.java

@@ -6,12 +6,8 @@ import com.fdkankan.common.constant.CommonStatus;
 import com.fdkankan.common.constant.CommonSuccessStatus;
 import com.fdkankan.common.constant.CommonSuccessStatus;
 import com.fdkankan.common.constant.SceneStatus;
 import com.fdkankan.common.constant.SceneStatus;
 import com.fdkankan.contro.constant.RedisConstants;
 import com.fdkankan.contro.constant.RedisConstants;
-import com.fdkankan.contro.entity.OrigFileUpload;
-import com.fdkankan.contro.entity.OrigFileUploadBatch;
-import com.fdkankan.contro.entity.ScenePlus;
-import com.fdkankan.contro.service.IOrigFileUploadBatchService;
-import com.fdkankan.contro.service.IOrigFileUploadService;
-import com.fdkankan.contro.service.IScenePlusService;
+import com.fdkankan.contro.entity.*;
+import com.fdkankan.contro.service.*;
 import com.fdkankan.contro.util.HttpUtilExt;
 import com.fdkankan.contro.util.HttpUtilExt;
 import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
@@ -42,6 +38,16 @@ public class UploadShootingListener {
     private IScenePlusService scenePlusService;
     private IScenePlusService scenePlusService;
     @Resource
     @Resource
     private RedisUtil redisUtil;
     private RedisUtil redisUtil;
+    @Autowired
+    private ICommonService commonService;
+    @Autowired
+    private ISceneEditInfoService sceneEditInfoService;
+    @Autowired
+    private ISceneEditInfoExtService sceneEditInfoExtService;
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
+    @Autowired
+    private ISceneEditControlsService sceneEditControlsService;
 
 
 
 
     @RabbitListener(
     @RabbitListener(
@@ -55,6 +61,22 @@ public class UploadShootingListener {
         Integer index = params.getInteger("index");
         Integer index = params.getInteger("index");
         String uuid = params.getString("uuid");
         String uuid = params.getString("uuid");
         try {
         try {
+
+            //查出所有uuid相关的上传中的点位批次号
+
+            //遍历检查点位相关文件是否齐全,如果齐全改为进入计算
+
+            //下载文件
+
+            //调用算法
+
+            //上传文件
+
+            //写表
+
+            //处理删除点位
+
+
             List<OrigFileUpload> fileUploadList = origFileUploadService.getByBatchId(batchId);
             List<OrigFileUpload> fileUploadList = origFileUploadService.getByBatchId(batchId);
             String path = ConstantFilePath.BUILD_MODEL_PATH + "upload_while_shooting/" + uuid + "/" + index + "/";
             String path = ConstantFilePath.BUILD_MODEL_PATH + "upload_while_shooting/" + uuid + "/" + index + "/";
             for (OrigFileUpload origFileUpload : fileUploadList) {
             for (OrigFileUpload origFileUpload : fileUploadList) {
@@ -91,8 +113,14 @@ public class UploadShootingListener {
             }
             }
             if(status == CommonSuccessStatus.SUCCESS.code()){
             if(status == CommonSuccessStatus.SUCCESS.code()){
                 status = SceneStatus.PREVIEW.code();
                 status = SceneStatus.PREVIEW.code();
+                ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+                SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
+                SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
+                SceneEditControls sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
+                commonService.writeSceneJson(num,new JSONObject(), sceneEditInfo,
+                        sceneEditInfoExt,sceneEditControls, scenePlus,scenePlusExt, null);
             }else{
             }else{
-                log.info("点云系统处理失败,num:{}", num);
+                status = SceneStatus.FAILD.code();
             }
             }
             scenePlus.setSceneStatus(status);
             scenePlus.setSceneStatus(status);
             scenePlusService.updateById(scenePlus);
             scenePlusService.updateById(scenePlus);

+ 2 - 0
src/main/java/com/fdkankan/contro/service/ICommonService.java

@@ -59,4 +59,6 @@ public interface ICommonService {
     void uploadFloorplanAi(String num, String path) throws IOException;
     void uploadFloorplanAi(String num, String path) throws IOException;
 
 
     boolean detFloorPlanAi(String num, String path, LinkedHashMap<Integer, Boolean> detFloorplan) throws IOException;
     boolean detFloorPlanAi(String num, String path, LinkedHashMap<Integer, Boolean> detFloorplan) throws IOException;
+
+    Set<String> checkUploadFile(String sn, String fileId, String unicode, String type);
 }
 }

+ 4 - 0
src/main/java/com/fdkankan/contro/service/ISceneFileUploadService.java

@@ -3,6 +3,8 @@ package com.fdkankan.contro.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.contro.entity.SceneFileUpload;
 import com.fdkankan.contro.entity.SceneFileUpload;
 
 
+import java.util.List;
+
 /**
 /**
  * <p>
  * <p>
  * 场景文件上传表 服务类
  * 场景文件上传表 服务类
@@ -16,4 +18,6 @@ public interface ISceneFileUploadService extends IService<SceneFileUpload> {
     SceneFileUpload findByFileIdAndChunk(String fileId, Integer valueOf);
     SceneFileUpload findByFileIdAndChunk(String fileId, Integer valueOf);
 
 
     Long countUploadSuccessByFileId(String fileId);
     Long countUploadSuccessByFileId(String fileId);
+
+    List<SceneFileUpload> listUploadSuccessByFileId(String fileId);
 }
 }

+ 31 - 0
src/main/java/com/fdkankan/contro/service/impl/CommonServiceImpl.java

@@ -14,8 +14,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.common.constant.CommonStatus;
 import com.fdkankan.common.constant.CommonStatus;
 import com.fdkankan.common.constant.PayStatus;
 import com.fdkankan.common.constant.PayStatus;
 import com.fdkankan.common.constant.SpaceType;
 import com.fdkankan.common.constant.SpaceType;
+import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.bean.SceneJsonBean;
 import com.fdkankan.contro.bean.SceneJsonBean;
+import com.fdkankan.contro.constant.ModelingControlRespCode;
+import com.fdkankan.contro.constant.RedisKeyExt;
 import com.fdkankan.contro.controller.DetectType;
 import com.fdkankan.contro.controller.DetectType;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.factory.UserEditData.UserEditDataHandler;
 import com.fdkankan.contro.factory.UserEditData.UserEditDataHandler;
@@ -113,6 +116,8 @@ public class CommonServiceImpl implements ICommonService {
     private ISceneMarkShapeService sceneMarkShapeService;
     private ISceneMarkShapeService sceneMarkShapeService;
     @Autowired
     @Autowired
     private SceneShapeEnumService sceneShapeEnumService;
     private SceneShapeEnumService sceneShapeEnumService;
+    @Autowired
+    private ISceneFileUploadService sceneFileUploadService;
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {
         String infoJsonPath = "D:\\test\\info.json";
         String infoJsonPath = "D:\\test\\info.json";
@@ -677,5 +682,31 @@ public class CommonServiceImpl implements ICommonService {
         }
         }
     }
     }
 
 
+    @Override
+    public Set<String> checkUploadFile(String sn, String fileId, String unicode, String type) {
+
+        String fileUploadedOpName = "fileUploadedOp.cam";
+        String redisKey = RedisKeyExt.CAM_FILE_LIST.replace("@unicode@", unicode);
+        if("local".equals(type)){//局域网版
+            String fileUploadedOpKey = new StringBuilder( ConstantFilePath.OSS_PREFIX).append(sn).append(File.separator).append(fileId).append(File.separator).append(unicode).append(File.separator).append(fileUploadedOpName).toString();
+            if(!fYunFileService.fileExist(fileUploadedOpKey)){
+                throw new BusinessException(ModelingControlRespCode.FILE_EMPTY_UPLOADEDOP.code(), ModelingControlRespCode.FILE_EMPTY_UPLOADEDOP.message());
+            }
+            String fileUploadedOpPath = "/oss/4dkankan/" + fileUploadedOpKey;
+            List<String> fileList = FileUtil.readUtf8Lines(fileUploadedOpPath);
+            if(CollUtil.isEmpty(fileList)){
+                return null;
+            }
+            Set<String> notExistFiles = fileList.stream().filter(v -> !redisUtil.sExists(redisKey, v)).collect(Collectors.toSet());
+            List<SceneFileUpload> sceneFileUploads = sceneFileUploadService.listUploadSuccessByFileId(fileId);
+            Set<String> dbFileList = new HashSet<>();
+            for (SceneFileUpload sceneFileUpload : sceneFileUploads) {
+                dbFileList.add(sceneFileUpload.getSize() + "_" + sceneFileUpload.getFileSourceName().trim());
+            }
+            Set<String> result = notExistFiles.stream().filter(v -> !dbFileList.contains(v)).map(v -> v.split("_")[1]).collect(Collectors.toSet());
 
 
+            return result;
+        }
+        return null;
+    }
 }
 }

+ 106 - 91
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -24,9 +24,7 @@ import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.*;
 import com.fdkankan.common.util.*;
 import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
 import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
 import com.fdkankan.contro.common.Result;
 import com.fdkankan.contro.common.Result;
-import com.fdkankan.contro.constant.ApiConstant;
-import com.fdkankan.contro.constant.RedisConstants;
-import com.fdkankan.contro.constant.ZipConstant;
+import com.fdkankan.contro.constant.*;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.enums.CameraTypeEnum;
 import com.fdkankan.contro.enums.CameraTypeEnum;
 import com.fdkankan.contro.httpclient.MyClient;
 import com.fdkankan.contro.httpclient.MyClient;
@@ -727,6 +725,12 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         String buildType = "V2";
         String buildType = "V2";
         Long cameraType = 10L;
         Long cameraType = 10L;
 
 
+        Set<String> notExistsFiles = commonService.checkUploadFile(mac, fileId, folderName, fYunFileConfig.getFyunType());
+        if(CollUtil.isNotEmpty(notExistsFiles)){
+            log.error("文件缺失, unicode:{}, 缺失文件:{}", folderName, notExistsFiles);
+            throw new BusinessException(ModelingControlRespCode.FILE_EMPTY.code(), ModelingControlRespCode.FILE_EMPTY.message());
+        }
+
         if(!fYunFileService.fileExist(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage")){
         if(!fYunFileService.fileExist(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage")){
             log.error("data.fdage文件不存在");
             log.error("data.fdage文件不存在");
             throw new BusinessException(CameraConstant.FAILURE_6009);
             throw new BusinessException(CameraConstant.FAILURE_6009);
@@ -879,6 +883,13 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         //云目录
         //云目录
         StringBuilder prefixBuffer = new StringBuilder(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator);
         StringBuilder prefixBuffer = new StringBuilder(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator);
 
 
+        Set<String> notExistsFiles = commonService.checkUploadFile(mac, fileId, folderName, fYunFileConfig.getFyunType());
+        if(CollUtil.isNotEmpty(notExistsFiles)){
+            log.error("文件缺失, unicode:{}, 缺失文件:{}", folderName, notExistsFiles);
+            throw new BusinessException(ModelingControlRespCode.FILE_EMPTY.code(), ModelingControlRespCode.FILE_EMPTY.message());
+        }
+
+
         if(!fYunFileService.fileExist(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage")){
         if(!fYunFileService.fileExist(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage")){
             log.error("data.fdage文件不存在");
             log.error("data.fdage文件不存在");
             throw new BusinessException(CameraConstant.FAILURE_6009);
             throw new BusinessException(CameraConstant.FAILURE_6009);
@@ -2043,7 +2054,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
 
         log.info("upload-params: "+params);
         log.info("upload-params: "+params);
         if (StringUtils.isEmpty(params)){
         if (StringUtils.isEmpty(params)){
-        throw new BusinessException(ErrorCode.PARAM_REQUIRED);
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
         }
         }
         params = params.replaceAll("%2B", "+");
         params = params.replaceAll("%2B", "+");
         Base64 base64 = new Base64();
         Base64 base64 = new Base64();
@@ -2055,7 +2066,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         log.info("upload-params解密结果:" + restr);
         log.info("upload-params解密结果:" + restr);
         String[] strArr = restr.split(SPLICE);
         String[] strArr = restr.split(SPLICE);
         if (strArr.length != 6) {
         if (strArr.length != 6) {
-        throw new BusinessException(ErrorCode.PARAM_REQUIRED);
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
         }
         }
         String mac = strArr[0];
         String mac = strArr[0];
         String fileId = strArr[1];
         String fileId = strArr[1];
@@ -2067,24 +2078,24 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
 
         ResultData result = null;
         ResultData result = null;
         if (file.isEmpty()){
         if (file.isEmpty()){
-        log.error("文件为空。");
-        throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"文件为空。");
+            log.error("文件为空。");
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"文件为空。");
         }
         }
         if (StringUtils.isEmpty(fileId)){
         if (StringUtils.isEmpty(fileId)){
-        log.error("文件Id为空。");
-        throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"文件Id为空。");
+            log.error("文件Id为空。");
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"文件Id为空。");
         }
         }
         if (picNum == null){
         if (picNum == null){
-        log.error("照片数目为空。");
-        throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"照片数目为空。");
+            log.error("照片数目为空。");
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"照片数目为空。");
         }
         }
         if (StringUtils.isEmpty(mac)){
         if (StringUtils.isEmpty(mac)){
-        log.error("mac为空。");
-        throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"mac为空。");
+            log.error("mac为空。");
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"mac为空。");
         }
         }
         if (StringUtils.isEmpty(md5)){
         if (StringUtils.isEmpty(md5)){
-        log.error("md5为空。");
-        throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"md5为空。");
+            log.error("md5为空。");
+            throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(),"md5为空。");
         }
         }
         long size = file.getSize();
         long size = file.getSize();
         log.info("mac:{}, fileId:{}, picNum:{}, md5:{}, chunk:{}", mac, fileId, picNum, md5, chunk);
         log.info("mac:{}, fileId:{}, picNum:{}, md5:{}, chunk:{}", mac, fileId, picNum, md5, chunk);
@@ -2095,13 +2106,13 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         // 获取文件的后缀名
         // 获取文件的后缀名
         String folderName = redisUtil.get(String.format(RedisConstants.FILEID_FOLDER_BUILD, fileId));
         String folderName = redisUtil.get(String.format(RedisConstants.FILEID_FOLDER_BUILD, fileId));
         if(StringUtils.isEmpty(folderName)){
         if(StringUtils.isEmpty(folderName)){
-        SceneFileBuild fileBuild = findByFileId(fileId);
-        if(ObjectUtils.isEmpty(fileBuild)){
-        log.error("数据不正常,fileBuild没找到");
-        throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
-        }
-        folderName = fileBuild.getUnicode();
-        redisUtil.set(String.format(RedisConstants.FILEID_FOLDER_BUILD, fileId), folderName,2 * 24 * 60 * 60);
+            SceneFileBuild fileBuild = findByFileId(fileId);
+            if(ObjectUtils.isEmpty(fileBuild)){
+                log.error("数据不正常,fileBuild没找到");
+                throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
+            }
+            folderName = fileBuild.getUnicode();
+            redisUtil.set(String.format(RedisConstants.FILEID_FOLDER_BUILD, fileId), folderName,2 * 24 * 60 * 60);
         }
         }
         // 1. 判断该文件是否已经上传过
         // 1. 判断该文件是否已经上传过
         // 2. 如果已经上传过,判断MD5值和文件大小是否相等。如果相等,更新数据记录。如果不相等,删除该文件,重新上传。
         // 2. 如果已经上传过,判断MD5值和文件大小是否相等。如果相等,更新数据记录。如果不相等,删除该文件,重新上传。
@@ -2112,87 +2123,91 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
                 .concat(filePath).concat(File.separator).concat(dir).concat(fileName);
                 .concat(filePath).concat(File.separator).concat(dir).concat(fileName);
         log.info("yunFilePath:{}", yunFilePath);
         log.info("yunFilePath:{}", yunFilePath);
 
 
+        String key = RedisKeyExt.CAM_FILE_LIST.replace("@unicode@", folderName);
+        String value = size + "_" + fileName;
         boolean needUpload = false;
         boolean needUpload = false;
         File yunFile = new File(yunFilePath);
         File yunFile = new File(yunFilePath);
         if (yunFile.exists()){
         if (yunFile.exists()){
-        String fileMD5 = FileMd5Util.getFileMD5(yunFile);
-        if (md5.equals(fileMD5) && yunFile.length() == size){
-        log.info("文件已存在,MD5和文件大小一致。");
-        SceneFileUpload uploadEntity = sceneFileUploadService.findByFileIdAndChunk(fileId, Integer.valueOf(chunk));
-        if (uploadEntity != null){
-        uploadEntity.setSize((int) size);
-        uploadEntity.setMd5(md5);
-        uploadEntity.setFilePath(yunFilePath);
-        uploadEntity.setFileSourceName(fileName);
-        uploadEntity.setUploadStatus(1);
-        sceneFileUploadService.updateById(uploadEntity);
-        }else{
-        SceneFileUpload sceneFileUploadEntity = new SceneFileUpload();
-        sceneFileUploadEntity.setSize((int) size);
-        sceneFileUploadEntity.setMd5(md5);
-        sceneFileUploadEntity.setFilePath(yunFilePath.toString());
-        sceneFileUploadEntity.setFileSourceName(fileName);
-        sceneFileUploadEntity.setUploadStatus(1);
-        sceneFileUploadEntity.setFileId(fileId);
-        sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
-        sceneFileUploadService.save(sceneFileUploadEntity);
-        }
-        result = ResultData.ok();
-        }else if (!md5.equals(fileMD5)) {
-        log.error("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
-        FileUtils.delFile(yunFilePath.toString());
-        needUpload = true;
-        }else if (yunFile.length() != size){
-        log.error("文件已上传,文件大小不一致。上传失败");
-        FileUtils.delFile(yunFilePath);
-        needUpload = true;
-        }
+            String fileMD5 = FileMd5Util.getFileMD5(yunFile);
+            if (md5.equals(fileMD5) && yunFile.length() == size){
+                log.info("文件已存在,MD5和文件大小一致。");
+                SceneFileUpload uploadEntity = sceneFileUploadService.findByFileIdAndChunk(fileId, Integer.valueOf(chunk));
+                if (uploadEntity != null){
+                    uploadEntity.setSize((int) size);
+                    uploadEntity.setMd5(md5);
+                    uploadEntity.setFilePath(yunFilePath);
+                    uploadEntity.setFileSourceName(fileName);
+                    uploadEntity.setUploadStatus(1);
+                    sceneFileUploadService.updateById(uploadEntity);
+                }else{
+                    SceneFileUpload sceneFileUploadEntity = new SceneFileUpload();
+                    sceneFileUploadEntity.setSize((int) size);
+                    sceneFileUploadEntity.setMd5(md5);
+                    sceneFileUploadEntity.setFilePath(yunFilePath.toString());
+                    sceneFileUploadEntity.setFileSourceName(fileName);
+                    sceneFileUploadEntity.setUploadStatus(1);
+                    sceneFileUploadEntity.setFileId(fileId);
+                    sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
+                    sceneFileUploadService.save(sceneFileUploadEntity);
+                }
+                redisUtil.sSet(key, value);
+
+                result = ResultData.ok();
+            }else if (!md5.equals(fileMD5)) {
+                log.warn("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
+                FileUtils.delFile(yunFilePath.toString());
+                needUpload = true;
+            }else if (yunFile.length() != size){
+                log.warn("文件已上传,文件大小不一致。上传失败");
+                FileUtils.delFile(yunFilePath);
+                needUpload = true;
+            }
         }else {
         }else {
-        log.error("文件不存在,需要重新上传");
-        needUpload = true;
+            log.info("文件不存在,需要重新上传");
+            needUpload = true;
         }
         }
 
 
         // 4. 上传成功后,校验MD5和文件大小是否相等
         // 4. 上传成功后,校验MD5和文件大小是否相等
         // 5. 如果相等,更新数据记录。如果不相等,返回上传失败结果。
         // 5. 如果相等,更新数据记录。如果不相等,返回上传失败结果。
         try {
         try {
-        if (needUpload){
-            fYunFileService.uploadFile(file.getInputStream(),ConstantFilePath.OSS_PREFIX.concat(filePath).concat(File.separator).concat(dir).concat(fileName));
-        File uploadFile = new File(yunFilePath);
-        String fileMD5 = FileMd5Util.getFileMD5(uploadFile);
-
-        SceneFileUpload sceneFileUploadEntity = new SceneFileUpload();
-        sceneFileUploadEntity.setSize((int) size);
-        sceneFileUploadEntity.setMd5(md5);
-        sceneFileUploadEntity.setFilePath(yunFilePath);
-        sceneFileUploadEntity.setFileSourceName(fileName);
-        sceneFileUploadEntity.setFileId(fileId);
-        sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
-
-        if (md5.equals(fileMD5) && uploadFile.length() == size){
-        log.info("文件已上传,MD5和文件大小一致。上传成功");
-
-        sceneFileUploadEntity.setUploadStatus(1);
-        sceneFileUploadService.save(sceneFileUploadEntity);
-        result = ResultData.ok();
-        }else if (!md5.equals(fileMD5)) {
-        log.error("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
-        sceneFileUploadEntity.setUploadStatus(-1);
-        sceneFileUploadService.save(sceneFileUploadEntity);
-        result = ResultData.error(ErrorCode.SYSTEM_ERROR,"上传失败, 请重新上传。");
-        }else if (uploadFile.length() != size){
-        log.error("文件已上传,文件大小不一致。上传失败");
-        sceneFileUploadEntity.setUploadStatus(-1);
-        sceneFileUploadService.save(sceneFileUploadEntity);
-        result = ResultData.error(ErrorCode.SYSTEM_ERROR,"上传失败, 请重新上传。");
-        }
-        }
+            if (needUpload){
+                fYunFileService.uploadFile(file.getInputStream(),ConstantFilePath.OSS_PREFIX.concat(filePath).concat(File.separator).concat(dir).concat(fileName));
+                File uploadFile = new File(yunFilePath);
+                String fileMD5 = FileMd5Util.getFileMD5(uploadFile);
+
+                SceneFileUpload sceneFileUploadEntity = new SceneFileUpload();
+                sceneFileUploadEntity.setSize((int) size);
+                sceneFileUploadEntity.setMd5(md5);
+                sceneFileUploadEntity.setFilePath(yunFilePath);
+                sceneFileUploadEntity.setFileSourceName(fileName);
+                sceneFileUploadEntity.setFileId(fileId);
+                sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
+
+                if (md5.equals(fileMD5) && uploadFile.length() == size){
+                    log.info("文件已上传,MD5和文件大小一致。上传成功");
+                    sceneFileUploadEntity.setUploadStatus(1);
+                    sceneFileUploadService.save(sceneFileUploadEntity);
+                    redisUtil.sSet(key, value);
+                    result = ResultData.ok();
+                }else if (!md5.equals(fileMD5)) {
+                    log.error("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
+                    sceneFileUploadEntity.setUploadStatus(-1);
+                    sceneFileUploadService.save(sceneFileUploadEntity);
+                    result = ResultData.error(ErrorCode.SYSTEM_ERROR,"上传失败, 请重新上传。");
+                }else if (uploadFile.length() != size){
+                    log.error("文件已上传,文件大小不一致。上传失败");
+                    sceneFileUploadEntity.setUploadStatus(-1);
+                    sceneFileUploadService.save(sceneFileUploadEntity);
+                    result = ResultData.error(ErrorCode.SYSTEM_ERROR,"上传失败, 请重新上传。");
+                }
+            }
         }catch (IllegalStateException | IOException e) {
         }catch (IllegalStateException | IOException e) {
-        log.error("上传失败, 请重新上传,md5:{},chunk:{}", md5, chunk);
-        log.error("上传失败", e);
-        result = ResultData.error(ErrorCode.SYSTEM_ERROR,"上传失败, 请重新上传。");
+            log.error("上传失败, 请重新上传,md5:{},chunk:{}", md5, chunk);
+            log.error("上传失败", e);
+            result = ResultData.error(ErrorCode.SYSTEM_ERROR,"上传失败, 请重新上传。");
         }
         }
         return result;
         return result;
-        }
+    }
 
 
     @Override
     @Override
     public ResultData sendCallAlgorithm(SendCallAlgorithmParam param) throws Exception {
     public ResultData sendCallAlgorithm(SendCallAlgorithmParam param) throws Exception {

+ 9 - 1
src/main/java/com/fdkankan/contro/service/impl/SceneFileUploadServiceImpl.java

@@ -3,7 +3,6 @@ package com.fdkankan.contro.service.impl;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fdkankan.common.constant.TbStatus;
 import com.fdkankan.common.constant.UploadStatus;
 import com.fdkankan.common.constant.UploadStatus;
 import com.fdkankan.contro.entity.SceneFileUpload;
 import com.fdkankan.contro.entity.SceneFileUpload;
 import com.fdkankan.contro.mapper.ISceneFileUploadMapper;
 import com.fdkankan.contro.mapper.ISceneFileUploadMapper;
@@ -33,6 +32,15 @@ public class SceneFileUploadServiceImpl extends ServiceImpl<ISceneFileUploadMapp
     }
     }
 
 
     @Override
     @Override
+    public List<SceneFileUpload> listUploadSuccessByFileId(String fileId) {
+        return this.list(new LambdaQueryWrapper<SceneFileUpload>()
+                .select(SceneFileUpload::getFileSourceName, SceneFileUpload::getSize)
+                .eq(SceneFileUpload::getFileId, fileId)
+                .eq(SceneFileUpload::getUploadStatus ,UploadStatus.SUCCESS.code()).orderByAsc(SceneFileUpload::getId));
+
+    }
+
+    @Override
     public SceneFileUpload findByFileIdAndChunk(String fileId, Integer chunk) {
     public SceneFileUpload findByFileIdAndChunk(String fileId, Integer chunk) {
 
 
         List<SceneFileUpload> list = this.list(new LambdaQueryWrapper<SceneFileUpload>()
         List<SceneFileUpload> list = this.list(new LambdaQueryWrapper<SceneFileUpload>()