|
@@ -4,8 +4,10 @@ import cn.hutool.core.codec.Base64;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
import cn.hutool.core.lang.UUID;
|
|
|
|
|
+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 cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -17,16 +19,21 @@ import com.fdkankan.common.constant.SceneStatus;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
|
|
|
+import com.fdkankan.contro.bean.SceneJsonBean;
|
|
|
import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
|
|
import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
|
|
|
|
|
+import com.fdkankan.contro.constant.ApiConstant;
|
|
|
import com.fdkankan.contro.constant.ZipConstant;
|
|
import com.fdkankan.contro.constant.ZipConstant;
|
|
|
import com.fdkankan.contro.entity.*;
|
|
import com.fdkankan.contro.entity.*;
|
|
|
|
|
+import com.fdkankan.contro.httpclient.MyClient;
|
|
|
import com.fdkankan.contro.mq.service.IBuildLogService;
|
|
import com.fdkankan.contro.mq.service.IBuildLogService;
|
|
|
import com.fdkankan.contro.service.*;
|
|
import com.fdkankan.contro.service.*;
|
|
|
|
|
+import com.fdkankan.contro.util.SceneSourceUtil;
|
|
|
import com.fdkankan.contro.vo.SendCallAlgorithmParam;
|
|
import com.fdkankan.contro.vo.SendCallAlgorithmParam;
|
|
|
import com.fdkankan.contro.vo.UploadSceneOrigParamVo;
|
|
import com.fdkankan.contro.vo.UploadSceneOrigParamVo;
|
|
|
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.rabbitmq.util.RabbitMqProducer;
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
|
|
+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;
|
|
@@ -74,6 +81,12 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
private IBuildLogService buildLogService;
|
|
private IBuildLogService buildLogService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IJyUserService jyUserService;
|
|
private IJyUserService jyUserService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IScene3dNumService scene3dNumService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICameraService cameraService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICameraDetailService cameraDetailService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void checkFileWhole(String uuid, String dataSource, JSONObject fdageData) {
|
|
public void checkFileWhole(String uuid, String dataSource, JSONObject fdageData) {
|
|
@@ -232,7 +245,7 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void uploadSceneOrig(UploadSceneOrigParamVo param) throws Exception {
|
|
|
|
|
|
|
+ public void uploadScene(UploadSceneOrigParamVo param) throws Exception {
|
|
|
|
|
|
|
|
User user = userService.getById(param.getUserId());
|
|
User user = userService.getById(param.getUserId());
|
|
|
if(Objects.isNull(user)){
|
|
if(Objects.isNull(user)){
|
|
@@ -244,41 +257,137 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
String zipDir = "/oss/4dkankan/bd_server/";
|
|
String zipDir = "/oss/4dkankan/bd_server/";
|
|
|
fYunFileService.downloadFileByCommand(zipDir + zipName, param.getFilePath());
|
|
fYunFileService.downloadFileByCommand(zipDir + zipName, param.getFilePath());
|
|
|
|
|
|
|
|
- //解压缩
|
|
|
|
|
- ZipFile zipFile = new ZipFile(new File(zipDir + zipName));
|
|
|
|
|
- if (zipFile.isEncrypted()) {
|
|
|
|
|
- zipFile.setPassword(ZipConstant.zipPassword);
|
|
|
|
|
- zipFile.extractAll(zipDir + uuid);
|
|
|
|
|
- } else {
|
|
|
|
|
- ZipUtil.unzip(zipDir + zipName, zipDir + uuid);
|
|
|
|
|
|
|
+ Camera camera = null;
|
|
|
|
|
+ CameraDetail cameraDetail = null;
|
|
|
|
|
+ String sceneNum = null;
|
|
|
|
|
+ if(param.getSourceType().equals("orig")){//原始资源
|
|
|
|
|
+ String dataFdageStr = com.fdkankan.contro.util.ZipUtil.readUtf8(zipDir + zipName, "data.fdage");
|
|
|
|
|
+ if(StrUtil.isEmpty(dataFdageStr) || JSONUtil.isJson(dataFdageStr)){
|
|
|
|
|
+ throw new BusinessException(60027, "data.fdage文件数据异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject dataFdage = JSON.parseObject(dataFdageStr);
|
|
|
|
|
+ String snCode = dataFdage.getJSONObject("cam").getString("uuid");
|
|
|
|
|
+ String uuidTime = dataFdage.getString("uuidtime");
|
|
|
|
|
+ String uniCode = snCode + "_" + uuidTime;
|
|
|
|
|
+ int camType = dataFdage.getJSONObject("cam").getIntValue("type");
|
|
|
|
|
+ Map<String, Object> instorage = cameraService.instorage(camType, snCode);
|
|
|
|
|
+ cameraDetail = (CameraDetail) instorage.get("cameraDetail");
|
|
|
|
|
+
|
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByFileId(uniCode);
|
|
|
|
|
+ if(scenePlus == null){
|
|
|
|
|
+ scenePlus = new ScenePlus();
|
|
|
|
|
+ sceneNum = scene3dNumService.generateSceneNum(cameraDetail.getType());
|
|
|
|
|
+ scenePlus.setNum(sceneNum);
|
|
|
|
|
+ scenePlus.setCameraId(cameraDetail.getCameraId());
|
|
|
|
|
+ scenePlus.setSceneSource(SceneSourceUtil.getSceneSourceByCamType(cameraDetail.getType()));
|
|
|
|
|
+ }
|
|
|
|
|
+ scenePlus.setTitle(dataFdage.getString("name"));
|
|
|
|
|
+ scenePlus.setUserId(user.getId());
|
|
|
|
|
+ scenePlus.setUpdateTime(null);
|
|
|
|
|
+ scenePlus.setSceneStatus(SceneStatus.wait.code());
|
|
|
|
|
+ scenePlusService.saveOrUpdate(scenePlus);
|
|
|
|
|
+
|
|
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
|
|
+ if(scenePlusExt == null){
|
|
|
|
|
+ scenePlusExt = new ScenePlusExt();
|
|
|
|
|
+ scenePlusExt.setPlusId(scenePlus.getId());
|
|
|
|
|
+ String fileId = sceneFileBuildService.getFileId(snCode, uniCode);
|
|
|
|
|
+ scenePlusExt.setDataSource(ConstantFilePath.BUILD_MODEL_PATH + snCode + File.separator + fileId + File.separator + uniCode);
|
|
|
|
|
+ scenePlusExtService.save(scenePlusExt);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }else{//离线包
|
|
|
|
|
+ String sceneJsonStr = com.fdkankan.contro.util.ZipUtil.readUtf8(zipDir + zipName, "scene.json");
|
|
|
|
|
+ if(StrUtil.isEmpty(sceneJsonStr) || JSONUtil.isJson(sceneJsonStr)){
|
|
|
|
|
+ throw new BusinessException(60027, "scene.json文件数据异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject sceneJson = JSON.parseObject(sceneJsonStr);
|
|
|
|
|
+ int camType = sceneJson.getInteger("camType");
|
|
|
|
|
+ String snCode = sceneJson.getString("snCode");
|
|
|
|
|
+ Map<String, Object> instorage = cameraService.instorage(camType, snCode);
|
|
|
|
|
+ cameraDetail = (CameraDetail) instorage.get("cameraDetail");
|
|
|
|
|
+ ScenePlus scenePlus = new ScenePlus();
|
|
|
|
|
+ sceneNum = scene3dNumService.generateSceneNum(cameraDetail.getType());
|
|
|
|
|
+ scenePlus.setNum(sceneNum);
|
|
|
|
|
+ scenePlus.setCameraId(cameraDetail.getCameraId());
|
|
|
|
|
+ scenePlus.setSceneSource(SceneSourceUtil.getSceneSourceByCamType(cameraDetail.getType()));
|
|
|
|
|
+ scenePlus.setTitle(sceneJson.getString("title"));
|
|
|
|
|
+ scenePlus.setUserId(user.getId());
|
|
|
|
|
+ scenePlus.setUpdateTime(null);
|
|
|
|
|
+ scenePlus.setSceneStatus(SceneStatus.wait.code());
|
|
|
|
|
+ scenePlusService.save(scenePlus);
|
|
|
|
|
+ ScenePlusExt scenePlusExt = new ScenePlusExt();
|
|
|
|
|
+ scenePlusExt.setPlusId(scenePlus.getId());
|
|
|
|
|
+ String uniCode = snCode + DateExtUtil.format(new Date(), DateExtUtil.dateStyle11);
|
|
|
|
|
+ String fileId = sceneFileBuildService.getFileId(snCode, uniCode);
|
|
|
|
|
+ scenePlusExt.setDataSource(ConstantFilePath.BUILD_MODEL_PATH + snCode + File.separator + fileId + File.separator + uniCode);
|
|
|
|
|
+ scenePlusExtService.save(scenePlusExt);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //去读data.fdage
|
|
|
|
|
- String dataFdagePath = zipDir + uuid + "/data.fdage";
|
|
|
|
|
- if(!FileUtil.exist(dataFdagePath)){
|
|
|
|
|
- log.warn("---------dataFdagePath:{}", dataFdagePath);
|
|
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_4002.code(), ErrorCode.FAILURE_CODE_4002.formatMessage("data.fdage"));
|
|
|
|
|
- }
|
|
|
|
|
- JSONObject dataFdageObj = JSONObject.parseObject(FileUtil.readUtf8String(dataFdagePath));
|
|
|
|
|
- int camType = dataFdageObj.getJSONObject("cam").getIntValue("type");
|
|
|
|
|
- String snCode = dataFdageObj.getJSONObject("cam").getString("uuid");
|
|
|
|
|
- String uuidTime = dataFdageObj.getString("uuidtime");
|
|
|
|
|
- String uniCode = snCode + "_" + uuidTime;
|
|
|
|
|
- String fileId = sceneFileBuildService.getFileId(snCode, uniCode);
|
|
|
|
|
- String homePath = "/oss/4dkankan/" + ConstantFilePath.OSS_PREFIX + snCode + "/" + fileId + "/" + uniCode;
|
|
|
|
|
- FileUtil.mkdir(homePath);
|
|
|
|
|
- String cpCmd = "cp -p -r " + zipDir + uuid + "/* " + homePath;
|
|
|
|
|
- CmdUtils.callLineSh(cpCmd);
|
|
|
|
|
-
|
|
|
|
|
- String params = snCode + "#" + fileId + "#" + uniCode;
|
|
|
|
|
- String encode = Base64.encode(RSAEncrypt.encrypt(RSAEncrypt.loadPublicKeyByStr(RSAEncrypt.loadPublicKeyByFile()), params.getBytes(StandardCharsets.UTF_8)));
|
|
|
|
|
- if(camType == 9 || camType == 10 || camType == 11){
|
|
|
|
|
- sceneFileBuildService.turntableUploadSuccess(encode, user);
|
|
|
|
|
- }else{
|
|
|
|
|
- sceneFileBuildService.uploadSuccessBuild(encode, user);
|
|
|
|
|
|
|
+ //发mq做异步处理
|
|
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
|
|
+ content.put("zipPath", zipDir + zipName);
|
|
|
|
|
+ content.put("num", sceneNum);
|
|
|
|
|
+ content.put("sourceType", param.getSourceType());
|
|
|
|
|
+ mqProducer.sendByWorkQueue("manage-upload-scene", content);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void checkUploadSceneOrig(JSONObject dataFdageJson, Long userId){
|
|
|
|
|
+ String uuidtime = dataFdageJson.getString("uuidtime");
|
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByFileId(uuidtime);
|
|
|
|
|
+ if(scenePlus == null){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(scenePlus.getUserId() != null){
|
|
|
|
|
+ JyUser jyUser = jyUserService.getByUserId(scenePlus.getUserId());
|
|
|
|
|
+ if(jyUser != null && !jyUser.getId().equals(userId)){
|
|
|
|
|
+ throw new BusinessException(60042, "此场景属于-" + jyUser.getRyNo());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(jyUser != null){
|
|
|
|
|
+ throw new BusinessException(60043, "此场景此前已上传过");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void checkUploadSceneOffline(String zipPath) throws Exception {
|
|
|
|
|
+ String sceneJsonStr = com.fdkankan.contro.util.ZipUtil.readUtf8(zipPath, "scene.json");
|
|
|
|
|
+ if(StrUtil.isEmpty(sceneJsonStr) || !JSONUtil.isJson(sceneJsonStr)){
|
|
|
|
|
+ throw new BusinessException(60027, "scene.json文件数据异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(sceneJsonStr);
|
|
|
|
|
+ //校验版本
|
|
|
|
|
+ String offlineVersion = jsonObject.getString("offlineVersion");
|
|
|
|
|
+ String platformVersion = "2.2.0";//从数据中获取
|
|
|
|
|
+ if (offlineVersion == null || platformVersion == null) {
|
|
|
|
|
+ throw new BusinessException(60127, "版本不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String[] offParts = offlineVersion.split(".");
|
|
|
|
|
+ String[] pfParts = platformVersion.split(".");
|
|
|
|
|
+
|
|
|
|
|
+ // 至少需要两位版本号
|
|
|
|
|
+ if (offParts.length < 2 || pfParts.length < 2) {
|
|
|
|
|
+ throw new BusinessException(60127, "版本不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 比较前两位
|
|
|
|
|
+ if (!offParts[0].equals(pfParts[0]) || !offParts[1].equals(pfParts[1])) {
|
|
|
|
|
+ throw new BusinessException(60127, "版本不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 前两位一致,检查第三位
|
|
|
|
|
+ if (!offParts[2].equals(pfParts[2])) {
|
|
|
|
|
+ throw new BusinessException(60128, "小版本版本不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String num = jsonObject.getString("num");
|
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
|
|
+ if(scenePlus != null){
|
|
|
|
|
+ throw new BusinessException(60128, "场景已存在,不能重复导入");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void noticeBuildBd(String ossHost, String uuid, String dir) {
|
|
public void noticeBuildBd(String ossHost, String uuid, String dir) {
|