|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
@@ -52,6 +53,7 @@ import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -69,6 +71,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
|
|
|
private static final String sendCallAlgorithmPath = "/mnt/sendCallAlgorithm/";
|
|
|
|
|
|
+ private static final String zipPassword = "a3ad34136de359536af553f9e7f3cefd";
|
|
|
+
|
|
|
@Value("${main.url}")
|
|
|
private String mainUrl;
|
|
|
@Value("${fyun.type}")
|
|
@@ -885,82 +889,86 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
scenePreService.save(scenePre);
|
|
|
|
|
|
// 异步解压资源文件上传
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
- try {
|
|
|
- log.info("开始异步解压文件");
|
|
|
- ZipFile zipFile = new ZipFile(new File(localFilePath));
|
|
|
- if (zipFile.isEncrypted()) {
|
|
|
- String pwd = "948e2948e2";
|
|
|
-// String pwd = "916ed916ed";
|
|
|
- zipFile.setPassword(pwd);
|
|
|
- zipFile.extractAll(parentPath);
|
|
|
- } else {
|
|
|
- ZipUtil.unzip(localFilePath, parentPath);
|
|
|
- }
|
|
|
+ ExecutorService executor = ThreadUtil.newSingleExecutor();
|
|
|
+ try {
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ try {
|
|
|
+ log.info("开始异步解压文件");
|
|
|
+ ZipFile zipFile = new ZipFile(new File(localFilePath));
|
|
|
+ if (zipFile.isEncrypted()) {
|
|
|
+ zipFile.setPassword(zipPassword);
|
|
|
+ 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;
|
|
|
+ List<String> filePathList = FileUtils.list(new File(parentPath));
|
|
|
+ String configJsonPath = null;
|
|
|
+ for (String item : filePathList) {
|
|
|
+ if(!item.contains("config.json")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ configJsonPath = item;
|
|
|
}
|
|
|
- configJsonPath = item;
|
|
|
- }
|
|
|
- String dataPath = FileUtil.getParent(configJsonPath, 1);
|
|
|
+ String dataPath = FileUtil.getParent(configJsonPath, 1);
|
|
|
|
|
|
- // 读取本地文件并校验文件
|
|
|
- // 读取config.json
|
|
|
- log.info("config.json路径:{}", configJsonPath);
|
|
|
- if(!FileUtil.exist(configJsonPath)){
|
|
|
- throw new RuntimeException("config.json 文件有误!");
|
|
|
- }
|
|
|
+ // 读取本地文件并校验文件
|
|
|
+ // 读取config.json
|
|
|
+ log.info("config.json路径:{}", configJsonPath);
|
|
|
+ if(!FileUtil.exist(configJsonPath)){
|
|
|
+ throw new RuntimeException("config.json 文件有误!");
|
|
|
+ }
|
|
|
|
|
|
- JSONObject configJson = JSONObject.parseObject(FileUtils.readFile(configJsonPath));
|
|
|
- String folderName = configJson.getString("id");
|
|
|
- String sncode = configJson.getString("sn");
|
|
|
- if(StrUtil.isBlank(folderName) || StrUtil.isBlank(sncode)){
|
|
|
- throw new RuntimeException("config.json 文件有误!");
|
|
|
- }
|
|
|
+ JSONObject configJson = JSONObject.parseObject(FileUtils.readFile(configJsonPath));
|
|
|
+ String folderName = configJson.getString("id");
|
|
|
+ String sncode = configJson.getString("sn");
|
|
|
+ String customUserId = configJson.getString("customUserId");
|
|
|
+ if(StrUtil.isBlank(folderName) || StrUtil.isBlank(sncode)){
|
|
|
+ throw new RuntimeException("config.json 文件有误!");
|
|
|
+ }
|
|
|
|
|
|
- Camera camera = cameraService.getByChildName(sncode);
|
|
|
- if(Objects.isNull(camera)){
|
|
|
- throw new BusinessException(ErrorCode.CAMERA_BIND_NO_EXIST.code(), "相机未入库");
|
|
|
- }
|
|
|
+ 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);
|
|
|
- // 解压获取dataSource 并上传资源到OSS
|
|
|
- String dataSource = ConstantFilePath.BUILD_MODEL_PATH.concat(subFolder);
|
|
|
- log.info("dataSource 为:{}", dataSource);
|
|
|
-
|
|
|
- scenePre.setFileId(fileId);
|
|
|
- scenePre.setStatus(1);
|
|
|
- scenePre.setUpdateTime(new Date());
|
|
|
- scenePreService.updateById(scenePre);
|
|
|
- log.info("异步开始上传文件");
|
|
|
- // 上传oaas
|
|
|
- fYunFileService.uploadFileByCommand(dataPath, ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
-
|
|
|
- scenePre.setOssPath(ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
-
|
|
|
- scenePre.setStatus(2);
|
|
|
- scenePre.setUpdateTime(new Date());
|
|
|
- scenePreService.updateById(scenePre);
|
|
|
- log.info("文件上传成功,开始通知计算");
|
|
|
- // 通知计算
|
|
|
- this.copyDataAndBuild(null, dataSource, "V4", null);
|
|
|
- log.info("通知计算成功");
|
|
|
-
|
|
|
- scenePre.setStatus(3);
|
|
|
- scenePre.setUpdateTime(new Date());
|
|
|
- scenePreService.updateById(scenePre);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("上传失败", e);
|
|
|
- scenePre.setStatus(CommonSuccessStatus.Fail.code());
|
|
|
- scenePreService.updateById(scenePre);
|
|
|
- }
|
|
|
- });
|
|
|
+ // 检测是否有生成
|
|
|
+ String fileId = getFileIdByFolderName(folderName);
|
|
|
+ String subFolder = sncode.concat(File.separator).concat(fileId).concat(File.separator).concat(folderName);
|
|
|
+ // 解压获取dataSource 并上传资源到OSS
|
|
|
+ String dataSource = ConstantFilePath.BUILD_MODEL_PATH.concat(subFolder);
|
|
|
+ log.info("dataSource 为:{}", dataSource);
|
|
|
+
|
|
|
+ scenePre.setFileId(fileId);
|
|
|
+ scenePre.setStatus(1);
|
|
|
+ scenePre.setUpdateTime(new Date());
|
|
|
+ scenePreService.updateById(scenePre);
|
|
|
+ log.info("异步开始上传文件");
|
|
|
+ // 上传oaas
|
|
|
+ fYunFileService.uploadFileByCommand(dataPath, ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
+
|
|
|
+ scenePre.setOssPath(ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
+
|
|
|
+ scenePre.setStatus(2);
|
|
|
+ scenePre.setUpdateTime(new Date());
|
|
|
+ scenePreService.updateById(scenePre);
|
|
|
+ log.info("文件上传成功,开始通知计算");
|
|
|
+ // 通知计算
|
|
|
+ this.copyDataAndBuild(null, dataSource, "V4", null, customUserId);
|
|
|
+ log.info("通知计算成功");
|
|
|
+
|
|
|
+ scenePre.setStatus(3);
|
|
|
+ scenePre.setUpdateTime(new Date());
|
|
|
+ scenePreService.updateById(scenePre);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("上传失败", e);
|
|
|
+ scenePre.setStatus(CommonSuccessStatus.Fail.code());
|
|
|
+ scenePreService.updateById(scenePre);
|
|
|
+ }
|
|
|
+ }, executor);
|
|
|
+ }finally {
|
|
|
+ executor.shutdown();
|
|
|
+ }
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
@@ -1011,7 +1019,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
return fileId;
|
|
|
}
|
|
|
|
|
|
- public ResultData copyDataAndBuild(String sourceBucet,String dataSource,String sceneVer,User user) throws Exception {
|
|
|
+ public ResultData copyDataAndBuild(String sourceBucet,String dataSource,String sceneVer,User user, String customUserId) throws Exception {
|
|
|
if(!StringUtils.equals(sceneVer,"V3") && ! StringUtils.equals(sceneVer,"V4")){
|
|
|
throw new BusinessException(ErrorCode.PARAM_FORMAT_ERROR.code(),"版本有误,请填写 V3 或者 V4");
|
|
|
}
|
|
@@ -1071,7 +1079,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
|
|
|
log.info("上传icon成功....");
|
|
|
}
|
|
|
- buildScenePost(dataSource, fdageData, "V3", cameraType, sceneNum, cameraEntity, detailEntity, rebuild, icon, user);
|
|
|
+ buildScenePost(dataSource, fdageData, "V3", cameraType, sceneNum, cameraEntity, detailEntity, rebuild, icon, user, customUserId);
|
|
|
break;
|
|
|
}
|
|
|
Map<String,Object> result = new HashMap<>();
|
|
@@ -1080,7 +1088,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
}
|
|
|
|
|
|
private ScenePlusVO buildScenePost(String dataSource, JSONObject jsonObject, String buildType, long cameraType,
|
|
|
- String sceneNum, Camera camera, CameraDetail cameraDetail, int rebuild,String icon,User user) throws Exception {
|
|
|
+ String sceneNum, Camera camera, CameraDetail cameraDetail, int rebuild,String icon,User user, String customUserId) throws Exception {
|
|
|
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);
|
|
@@ -1138,6 +1146,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
}
|
|
|
}
|
|
|
mqMessage.getExt().put("deleteExtras", true);
|
|
|
+ mqMessage.getExt().put("customUserId", customUserId);
|
|
|
rabbitMqProducer.sendByWorkQueue(queueModelingPre, mqMessage);
|
|
|
|
|
|
return scenePlusVO;
|