|
@@ -3,6 +3,7 @@ package com.fdkankan.contro.service.impl;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
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 com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -844,38 +845,14 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
public ResultData sendCallAlgorithm(@RequestBody Map<String,String> params) throws Exception {
|
|
public ResultData sendCallAlgorithm(@RequestBody Map<String,String> params) throws Exception {
|
|
log.info("sendCallAlgorithm 参数为:{}", JSONObject.toJSONString(params));
|
|
log.info("sendCallAlgorithm 参数为:{}", JSONObject.toJSONString(params));
|
|
String filePath = params.get("filePath");
|
|
String filePath = params.get("filePath");
|
|
- String userName = params.get("userName");
|
|
|
|
- if(org.apache.commons.lang3.ObjectUtils.isEmpty(filePath)){
|
|
|
|
|
|
+ if(StrUtil.isBlank(filePath)){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
}
|
|
}
|
|
- if(!filePath.endsWith(File.separator)){
|
|
|
|
- filePath = filePath.concat(File.separator);
|
|
|
|
- }
|
|
|
|
- // 读取本地文件并校验文件
|
|
|
|
- // 读取config.json
|
|
|
|
-// if(!new File(filePath+"config.json").exists()){
|
|
|
|
-// throw new BusinessException(ErrorCode.FAILURE_CODE_4001,filePath+"config.json");
|
|
|
|
-// }
|
|
|
|
|
|
|
|
- JSONObject configJson = JSONObject.parseObject(FileUtils.readFile(filePath + "config.json"));
|
|
|
|
- String folderName = configJson.getString("id");
|
|
|
|
- String sncode = configJson.getString("sn");
|
|
|
|
- String zipFileName = configJson.getString("zipFileName");
|
|
|
|
- if(org.apache.commons.lang3.ObjectUtils.isEmpty(folderName) || org.apache.commons.lang3.ObjectUtils.isEmpty(sncode) || org.apache.commons.lang3.ObjectUtils.isEmpty(zipFileName)){
|
|
|
|
- throw new BusinessException(ErrorCode.PARAM_ERROR,"config.json 文件有误!");
|
|
|
|
- }
|
|
|
|
|
|
+ String zipFileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
|
|
|
+ String zipName = FileUtil.mainName(zipFileName);
|
|
|
|
|
|
ScenePre scenePre = new ScenePre();
|
|
ScenePre scenePre = new 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.setUsername(userName);
|
|
|
|
scenePre.setZipPath(filePath);
|
|
scenePre.setZipPath(filePath);
|
|
scenePre.setCreateTime(new Date());
|
|
scenePre.setCreateTime(new Date());
|
|
scenePre.setUpdateTime(new Date());
|
|
scenePre.setUpdateTime(new Date());
|
|
@@ -883,19 +860,41 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
scenePreService.save(scenePre);
|
|
scenePreService.save(scenePre);
|
|
|
|
|
|
// 异步解压资源文件上传
|
|
// 异步解压资源文件上传
|
|
- String finalFilePath = filePath;
|
|
|
|
|
|
+ String finalFilePath = FileUtil.getParent(filePath, 1);
|
|
CompletableFuture.runAsync(() -> {
|
|
CompletableFuture.runAsync(() -> {
|
|
try {
|
|
try {
|
|
log.info("开始异步解压文件");
|
|
log.info("开始异步解压文件");
|
|
- ZipFile zipFile = new ZipFile(new File(finalFilePath.concat(zipFileName)));
|
|
|
|
|
|
+ ZipFile zipFile = new ZipFile(new File(filePath));
|
|
if (zipFile.isEncrypted()) {
|
|
if (zipFile.isEncrypted()) {
|
|
String pwd = zipFileName.substring(0, 5).concat(zipFileName.substring(0, 5));
|
|
String pwd = zipFileName.substring(0, 5).concat(zipFileName.substring(0, 5));
|
|
zipFile.setPassword(pwd);
|
|
zipFile.setPassword(pwd);
|
|
zipFile.extractAll(finalFilePath);
|
|
zipFile.extractAll(finalFilePath);
|
|
} else {
|
|
} else {
|
|
- ZipUtil.unzip(finalFilePath.concat(zipFileName), finalFilePath);
|
|
|
|
|
|
+ ZipUtil.unzip(filePath, finalFilePath);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 读取本地文件并校验文件
|
|
|
|
+ // 读取config.json
|
|
|
|
+ String configJsonPath = finalFilePath.concat(File.separator).concat(zipName).concat(File.separator).concat("config.json");
|
|
|
|
+ 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 文件有误!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 检测是否有生成
|
|
|
|
+ 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.setStatus(1);
|
|
scenePre.setUpdateTime(new Date());
|
|
scenePre.setUpdateTime(new Date());
|
|
scenePreService.updateById(scenePre);
|
|
scenePreService.updateById(scenePre);
|
|
@@ -1031,7 +1030,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
|
|
icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
|
|
log.info("上传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);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
Map<String,Object> result = new HashMap<>();
|
|
Map<String,Object> result = new HashMap<>();
|
|
@@ -1054,7 +1053,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
firmwareVersion.put("version", jsonObject.getString("version"));
|
|
firmwareVersion.put("version", jsonObject.getString("version"));
|
|
}
|
|
}
|
|
|
|
|
|
- String sceneUrl = mainUrl + "/" + sceneProNewUrl;
|
|
|
|
|
|
+ String sceneUrl = "/" + sceneProNewUrl;
|
|
|
|
|
|
//重算的场景,先移除该场景对应的容量
|
|
//重算的场景,先移除该场景对应的容量
|
|
if (rebuild == 1) {
|
|
if (rebuild == 1) {
|
|
@@ -1070,13 +1069,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
String unicode = jsonObject.getString("creator") + "_" + jsonObject.getString("uuidtime");
|
|
String unicode = jsonObject.getString("creator") + "_" + jsonObject.getString("uuidtime");
|
|
|
|
|
|
ScenePlusVO scenePlusVO = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(), jsonObject.getString("creator"),
|
|
ScenePlusVO scenePlusVO = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(), jsonObject.getString("creator"),
|
|
- jsonObject.getString("pwd"), unicode, cameraType, fileId, icon, cameraDetail.getUserId(), userName,algorithm,
|
|
|
|
- jsonObject.getJSONArray("points").size(), jsonObject.getString("name"), jsonObject.getString("info"),
|
|
|
|
- jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
|
|
|
|
- jsonObject.getInteger("resolution"), firmwareVersion.toString(), sceneUrl, buildType, cameraDetail.getCooperationUser());
|
|
|
|
-
|
|
|
|
- ScenePlusVO scenePlusVO = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(), jsonObject.getString("creator"),
|
|
|
|
- jsonObject.getString("pwd"), unicode, cameraType, dataSource, icon,user.getId() , user.getUserName(),algorithm,
|
|
|
|
|
|
+ jsonObject.getString("pwd"), unicode, cameraType, dataSource, icon, cameraDetail.getUserId() , null, algorithm,
|
|
jsonObject.getJSONArray("points").size(), jsonObject.getString("name"), jsonObject.getString("info"),
|
|
jsonObject.getJSONArray("points").size(), jsonObject.getString("name"), jsonObject.getString("info"),
|
|
jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
|
|
jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
|
|
jsonObject.getInteger("resolution"), firmwareVersion.toString(), sceneUrl, buildType, cameraDetail.getCooperationUser());
|
|
jsonObject.getInteger("resolution"), firmwareVersion.toString(), sceneUrl, buildType, cameraDetail.getCooperationUser());
|