|
@@ -8,6 +8,7 @@ import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.ZipUtil;
|
|
import cn.hutool.core.util.ZipUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -19,14 +20,16 @@ import com.fdkankan.common.util.DateExtUtil;
|
|
import com.fdkankan.common.util.FileMd5Util;
|
|
import com.fdkankan.common.util.FileMd5Util;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.common.util.SnowflakeIdGenerator;
|
|
import com.fdkankan.common.util.SnowflakeIdGenerator;
|
|
|
|
+import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
|
|
|
|
+import com.fdkankan.contro.common.Result;
|
|
import com.fdkankan.contro.constant.RedisConstants;
|
|
import com.fdkankan.contro.constant.RedisConstants;
|
|
import com.fdkankan.contro.entity.*;
|
|
import com.fdkankan.contro.entity.*;
|
|
import com.fdkankan.contro.mapper.ISceneFileBuildMapper;
|
|
import com.fdkankan.contro.mapper.ISceneFileBuildMapper;
|
|
import com.fdkankan.contro.service.*;
|
|
import com.fdkankan.contro.service.*;
|
|
import com.fdkankan.contro.vo.ResponseSceneFile;
|
|
import com.fdkankan.contro.vo.ResponseSceneFile;
|
|
import com.fdkankan.contro.vo.ScenePlusVO;
|
|
import com.fdkankan.contro.vo.ScenePlusVO;
|
|
|
|
+import com.fdkankan.contro.vo.SendCallAlgorithmParam;
|
|
import com.fdkankan.fyun.config.FYunFileConfig;
|
|
import com.fdkankan.fyun.config.FYunFileConfig;
|
|
-import com.fdkankan.fyun.constant.FYunTypeEnum;
|
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.fyun.local.constant.LocalConstants;
|
|
import com.fdkankan.fyun.local.constant.LocalConstants;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
@@ -39,14 +42,12 @@ import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.web.util.RSAEncrypt;
|
|
import com.fdkankan.web.util.RSAEncrypt;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import net.lingala.zip4j.core.ZipFile;
|
|
import net.lingala.zip4j.core.ZipFile;
|
|
-import net.lingala.zip4j.exception.ZipException;
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
import org.apache.commons.codec.binary.Base64;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.util.ObjectUtils;
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
@@ -860,35 +861,55 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResultData sendCallAlgorithm(@RequestBody Map<String,Object> params) throws Exception {
|
|
|
|
- log.info("sendCallAlgorithm 参数为:{}", JSONObject.toJSONString(params));
|
|
|
|
- List<String> filePaths = (List<String>) params.get("filepath");
|
|
|
|
- if(CollUtil.isEmpty(filePaths)){
|
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
|
|
|
+ public ResultData sendCallAlgorithm(SendCallAlgorithmParam param) throws Exception {
|
|
|
|
+ log.info("sendCallAlgorithm 参数为:{}", JSONObject.toJSONString(param));
|
|
|
|
+
|
|
|
|
+ String filePath = param.getFilepath();
|
|
|
|
+ String details = param.getDetails().replace("base64_urlsafe:","").replaceAll("-","+").replaceAll("_","/").concat("==");
|
|
|
|
+ try {
|
|
|
|
+ details = cn.hutool.core.codec.Base64.decodeStr(details);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("details解密报错,details:{}", details);
|
|
|
|
+ log.error("details解密报错", e);
|
|
|
|
+ return ResultData.error(ErrorCode.PARAM_FORMAT_ERROR);
|
|
}
|
|
}
|
|
- String uuid = UUID.randomUUID().toString();
|
|
|
|
|
|
+ SendCallAlgorithmDetail detail = JSON.parseObject(details, SendCallAlgorithmDetail.class);
|
|
|
|
+ Integer fileChunkSum = detail.getFileChunkSum();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String uuid = detail.getUuid();
|
|
|
|
+ String snCode = uuid.split("_")[0];
|
|
String parentPath = sendCallAlgorithmPath.concat(uuid);
|
|
String parentPath = sendCallAlgorithmPath.concat(uuid);
|
|
- if(FileUtil.exist(parentPath)){
|
|
|
|
- FileUtil.del(parentPath);
|
|
|
|
|
|
+// if(FileUtil.exist(parentPath)){
|
|
|
|
+// FileUtil.del(parentPath);
|
|
|
|
+// }
|
|
|
|
+ Camera camera = cameraService.getByChildName(snCode);
|
|
|
|
+ if(Objects.isNull(camera)){
|
|
|
|
+ throw new BusinessException(ErrorCode.CAMERA_BIND_NO_EXIST.code(), "相机未入库");
|
|
}
|
|
}
|
|
|
|
|
|
String localFilePath = parentPath.concat(File.separator).concat(uuid).concat(".zip");
|
|
String localFilePath = parentPath.concat(File.separator).concat(uuid).concat(".zip");
|
|
try {
|
|
try {
|
|
- for (String filePath : filePaths) {
|
|
|
|
- String extName = FileUtil.extName(filePath);
|
|
|
|
- String subFilePath = parentPath.concat(File.separator).concat(uuid).concat(".").concat(extName);
|
|
|
|
- FileUtil.mkParentDirs(localFilePath);
|
|
|
|
- HttpUtil.downloadFile(filePath, subFilePath);
|
|
|
|
- }
|
|
|
|
|
|
+ String extName = FileUtil.extName(filePath);
|
|
|
|
+ String subFilePath = parentPath.concat(File.separator).concat(uuid).concat(".").concat(extName);
|
|
|
|
+ FileUtil.mkParentDirs(localFilePath);
|
|
|
|
+ HttpUtil.downloadFile(filePath, subFilePath);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5063.code(), "原始资源压缩包下载失败");
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5063.code(), "原始资源压缩包下载失败");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //检测压缩包分卷是否与detail中的总数一样
|
|
|
|
+ List<String> fileNames = FileUtil.listFileNames(parentPath);
|
|
|
|
+ if(fileNames.size() != fileChunkSum){
|
|
|
|
+ return ResultData.ok("压缩包分卷不完整,请继续上传剩余的分卷");
|
|
|
|
+ }
|
|
|
|
+
|
|
if(!FileUtil.exist(localFilePath)){
|
|
if(!FileUtil.exist(localFilePath)){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5063.code(), "zip压缩包不存在");
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5063.code(), "zip压缩包不存在");
|
|
}
|
|
}
|
|
|
|
|
|
ScenePre scenePre = new ScenePre();
|
|
ScenePre scenePre = new ScenePre();
|
|
- scenePre.setZipPath(localFilePath);
|
|
|
|
|
|
+ scenePre.setZipPath(parentPath);
|
|
scenePre.setCreateTime(new Date());
|
|
scenePre.setCreateTime(new Date());
|
|
scenePre.setUpdateTime(new Date());
|
|
scenePre.setUpdateTime(new Date());
|
|
scenePre.setStatus(0);
|
|
scenePre.setStatus(0);
|
|
@@ -927,20 +948,14 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
|
|
|
JSONObject configJson = JSONObject.parseObject(FileUtils.readFile(configJsonPath));
|
|
JSONObject configJson = JSONObject.parseObject(FileUtils.readFile(configJsonPath));
|
|
String folderName = configJson.getString("id");
|
|
String folderName = configJson.getString("id");
|
|
- String sncode = configJson.getString("sn");
|
|
|
|
String customUserId = configJson.getString("customUserId");
|
|
String customUserId = configJson.getString("customUserId");
|
|
- if(StrUtil.isBlank(folderName) || StrUtil.isBlank(sncode)){
|
|
|
|
|
|
+ if(StrUtil.isBlank(folderName) || StrUtil.isBlank(snCode)){
|
|
throw new RuntimeException("config.json 文件有误!");
|
|
throw new RuntimeException("config.json 文件有误!");
|
|
}
|
|
}
|
|
|
|
|
|
- Camera camera = cameraService.getByChildName(sncode);
|
|
|
|
- if(Objects.isNull(camera)){
|
|
|
|
- throw new BusinessException(ErrorCode.CAMERA_BIND_NO_EXIST.code(), "相机未入库");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// 检测是否有生成
|
|
// 检测是否有生成
|
|
String fileId = getFileIdByFolderName(folderName);
|
|
String fileId = getFileIdByFolderName(folderName);
|
|
- String subFolder = sncode.concat(File.separator).concat(fileId).concat(File.separator).concat(folderName);
|
|
|
|
|
|
+ String subFolder = snCode.concat(File.separator).concat(fileId).concat(File.separator).concat(folderName);
|
|
// 解压获取dataSource 并上传资源到OSS
|
|
// 解压获取dataSource 并上传资源到OSS
|
|
String dataSource = ConstantFilePath.BUILD_MODEL_PATH.concat(subFolder);
|
|
String dataSource = ConstantFilePath.BUILD_MODEL_PATH.concat(subFolder);
|
|
log.info("dataSource 为:{}", dataSource);
|
|
log.info("dataSource 为:{}", dataSource);
|
|
@@ -953,8 +968,10 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
// 上传oaas
|
|
// 上传oaas
|
|
fYunFileService.uploadFileByCommand(dataPath, ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
fYunFileService.uploadFileByCommand(dataPath, ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
|
|
|
- scenePre.setOssPath(ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
|
|
|
+ //删除本地压缩包,防止补拍上传文件不一致
|
|
|
|
+ FileUtil.del(parentPath);
|
|
|
|
|
|
|
|
+ scenePre.setOssPath(ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
scenePre.setStatus(2);
|
|
scenePre.setStatus(2);
|
|
scenePre.setUpdateTime(new Date());
|
|
scenePre.setUpdateTime(new Date());
|
|
scenePreService.updateById(scenePre);
|
|
scenePreService.updateById(scenePre);
|
|
@@ -978,13 +995,19 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) throws ZipException {
|
|
|
|
-// ZipUtil.unzip("D:\\test\\KJ-07UBv9PY4TU.zip","D:\\test");
|
|
|
|
- ZipFile zipFile = new ZipFile(new File("D:\\test\\KJ-07UBv9PY4TU.zip"));
|
|
|
|
- zipFile.setPassword("");
|
|
|
|
- zipFile.extractAll("D:\\test");
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ String details = "{\"camType\":\"kj\",\"uploadType\":\"log\",\"uuid\":\"90d95cdb5_202211141023024060\",\"fileChunkSum\":4,\"fileChunkNum\":0}";
|
|
|
|
+ String encode = cn.hutool.core.codec.Base64.encode(details);
|
|
|
|
+ System.out.println(encode);
|
|
|
|
+ String details2 = "base64_urlsafe:".concat(encode.replaceAll("\\+", "-").replaceAll("/", "_"));
|
|
|
|
+ System.out.println(details2);
|
|
|
|
+ String details3 = details2.replace("base64_urlsafe:","").replaceAll("-","+").replaceAll("_","/").concat("==");
|
|
|
|
+ System.out.println(details3);
|
|
|
|
+ String s = cn.hutool.core.codec.Base64.decodeStr(details3);
|
|
|
|
+ System.out.println(s);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
private String getFileIdByFolderName(String folderName) {
|
|
private String getFileIdByFolderName(String folderName) {
|
|
// 检测是否有生成
|
|
// 检测是否有生成
|
|
String fileId = redisUtil.get(String.format(RedisConstants.FOLDER_FILEID_BUILD, folderName));
|
|
String fileId = redisUtil.get(String.format(RedisConstants.FOLDER_FILEID_BUILD, folderName));
|