|
@@ -861,26 +861,24 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
if(StrUtil.isBlank(filePath)){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
}
|
|
|
-
|
|
|
- String zipFileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
|
|
- String zipName = FileUtil.mainName(zipFileName);
|
|
|
- String snCode = zipName.split("_")[0];
|
|
|
-
|
|
|
- Camera camera = cameraService.getByChildName(snCode);
|
|
|
- if(Objects.isNull(camera)){
|
|
|
- throw new BusinessException(ErrorCode.CAMERA_BIND_NO_EXIST.code(), "相机未入库");
|
|
|
- }
|
|
|
-
|
|
|
- String parentPath = sendCallAlgorithmPath.concat(zipName);
|
|
|
- String localFilePath = parentPath.concat(File.separator).concat(zipFileName);
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
+ String parentPath = sendCallAlgorithmPath.concat(uuid);
|
|
|
+ String localFilePath = parentPath.concat(File.separator).concat(uuid).concat(".zip");
|
|
|
if(FileUtil.exist(parentPath)){
|
|
|
FileUtil.del(parentPath);
|
|
|
}
|
|
|
FileUtil.mkParentDirs(localFilePath);
|
|
|
- HttpUtil.downloadFile(filePath, localFilePath);
|
|
|
+ try {
|
|
|
+ HttpUtil.downloadFile(filePath, localFilePath);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
|
|
|
+ }
|
|
|
+ if(!FileUtil.exist(localFilePath)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
|
|
|
+ }
|
|
|
|
|
|
ScenePre scenePre = new ScenePre();
|
|
|
- scenePre.setZipPath(filePath);
|
|
|
+ scenePre.setZipPath(localFilePath);
|
|
|
scenePre.setCreateTime(new Date());
|
|
|
scenePre.setUpdateTime(new Date());
|
|
|
scenePre.setStatus(0);
|
|
@@ -892,16 +890,26 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
log.info("开始异步解压文件");
|
|
|
ZipFile zipFile = new ZipFile(new File(localFilePath));
|
|
|
if (zipFile.isEncrypted()) {
|
|
|
- String pwd = zipFileName.substring(0, 5).concat(zipFileName.substring(0, 5));
|
|
|
+ String pwd = "948e2948e2";
|
|
|
+// String pwd = "916ed916ed";
|
|
|
zipFile.setPassword(pwd);
|
|
|
zipFile.extractAll(parentPath);
|
|
|
} else {
|
|
|
ZipUtil.unzip(localFilePath, parentPath);
|
|
|
}
|
|
|
|
|
|
+ List<String> filePathList = FileUtils.list(new File(parentPath));
|
|
|
+ String configJsonPath = null;
|
|
|
+ for (String item : filePathList) {
|
|
|
+ if(!item.contains("config.json")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ configJsonPath = item;
|
|
|
+ }
|
|
|
+ String dataPath = FileUtil.getParent(configJsonPath, 1);
|
|
|
+
|
|
|
// 读取本地文件并校验文件
|
|
|
// 读取config.json
|
|
|
- String configJsonPath = parentPath.concat(File.separator).concat(zipName).concat(File.separator).concat("config.json");
|
|
|
log.info("config.json路径:{}", configJsonPath);
|
|
|
if(!FileUtil.exist(configJsonPath)){
|
|
|
throw new RuntimeException("config.json 文件有误!");
|
|
@@ -914,6 +922,11 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
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 subFolder = sncode.concat(File.separator).concat(fileId).concat(File.separator).concat(folderName);
|
|
@@ -927,7 +940,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
scenePreService.updateById(scenePre);
|
|
|
log.info("异步开始上传文件");
|
|
|
// 上传oaas
|
|
|
- fYunFileService.uploadFileByCommand(parentPath.concat(File.separator).concat(zipName), ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
+ fYunFileService.uploadFileByCommand(dataPath, ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
|
|
|
scenePre.setOssPath(ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
|
|
@@ -943,8 +956,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
scenePre.setUpdateTime(new Date());
|
|
|
scenePreService.updateById(scenePre);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
log.error("上传失败", e);
|
|
|
+ scenePre.setStatus(CommonSuccessStatus.Fail.code());
|
|
|
+ scenePreService.updateById(scenePre);
|
|
|
}
|
|
|
});
|
|
|
return ResultData.ok();
|