|
@@ -7,6 +7,8 @@ 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.extra.qrcode.QrCodeUtil;
|
|
|
+import cn.hutool.extra.qrcode.QrConfig;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -25,7 +27,6 @@ import com.fdkankan.contro.common.Result;
|
|
|
import com.fdkankan.contro.constant.RedisConstants;
|
|
|
import com.fdkankan.contro.entity.*;
|
|
|
import com.fdkankan.contro.mapper.ISceneFileBuildMapper;
|
|
|
-import com.fdkankan.contro.service.ICommonService;
|
|
|
import com.fdkankan.contro.service.*;
|
|
|
import com.fdkankan.contro.vo.ResponseSceneFile;
|
|
|
import com.fdkankan.contro.vo.ScenePlusVO;
|
|
@@ -33,21 +34,21 @@ import com.fdkankan.contro.vo.SendCallAlgorithmParam;
|
|
|
import com.fdkankan.fyun.config.FYunFileConfig;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.fyun.local.constant.LocalConstants;
|
|
|
+import com.fdkankan.image.MatrixToImageWriterUtil;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
-import com.fdkankan.redis.util.RedisLockUtil;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
-import com.fdkankan.web.response.Result;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import com.fdkankan.web.util.RSAEncrypt;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import net.lingala.zip4j.core.ZipFile;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.joda.time.DateTime;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
@@ -56,8 +57,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
@@ -65,10 +66,6 @@ import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.*;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -177,9 +174,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
@Autowired
|
|
|
private ICompanyService companyService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RedisLockUtil redisLockUtil;
|
|
|
-
|
|
|
private RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
|
@Autowired
|
|
@@ -203,6 +197,15 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
@Autowired
|
|
|
private ISceneColdStorageService sceneColdStorageService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISceneProService sceneProService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISceneProEditService sceneProEditService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFdkkLaserService fdkkLaserService;
|
|
|
+
|
|
|
@Override
|
|
|
public SceneFileBuild findByFileId(String fileId) {
|
|
|
|
|
@@ -359,7 +362,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
int rebuild = CommonStatus.YES.code();
|
|
|
if (ObjectUtils.isEmpty(scenePlus)) {
|
|
|
|
|
|
-
|
|
|
//清除超容量场景记录
|
|
|
exceedSpaceSceneService.repeal(camera.getId(), fileId, unicode);
|
|
|
|
|
@@ -407,11 +409,11 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
log.info("上传icon成功....");
|
|
|
}
|
|
|
|
|
|
- return buildScenePost(dataSource, jsonObject, buildType, cameraType, sceneNum, cameraDetail, rebuild,icon);
|
|
|
+ return buildScenePost(dataSource, jsonObject, buildType, cameraType, sceneNum, camera, cameraDetail, rebuild,icon);
|
|
|
}
|
|
|
|
|
|
private ScenePlusVO buildScenePost(String dataSource, JSONObject jsonObject, String buildType, long cameraType,
|
|
|
- String sceneNum, CameraDetail cameraDetail, int rebuild,String icon) throws Exception {
|
|
|
+ String sceneNum, Camera camera, CameraDetail cameraDetail, int rebuild,String icon) throws Exception {
|
|
|
String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
|
|
|
|
|
|
String userName = null;
|
|
@@ -442,6 +444,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
fYunFileService.uploadFile(ConstantFilePath.LOGO_PATH + "logo-main-en.png", imgViewPath + "logo-main-en.png");
|
|
|
}
|
|
|
String algorithm = jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location")) ? "sfm" : "slam";
|
|
|
+ String unicode = jsonObject.getString("creator") + "_" + jsonObject.getString("uuidtime");
|
|
|
|
|
|
ScenePlusVO scenePlusVO = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(), jsonObject.getString("creator"),
|
|
|
jsonObject.getString("pwd"), unicode,cameraType, dataSource, icon, cameraDetail.getUserId(), userName,algorithm,
|
|
@@ -1006,6 +1009,150 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
return scenePlusVO;
|
|
|
}
|
|
|
|
|
|
+ public ScenePlusVO createScenePro(String projectNum, Long cameraId, String cameraName, String phoneId, String sceneKey,
|
|
|
+ String unicode, Long cameraType, String fileId, String pic, Long userId, String userName,
|
|
|
+ String algorithm, Integer sceneShootCount, String sceneName,String sceneDec,
|
|
|
+ Integer sceneType, String gps,Integer resolution, String firmwareVersion, String buildType
|
|
|
+ )throws Exception{
|
|
|
+
|
|
|
+
|
|
|
+ ScenePro scene = sceneProService.getByNum(projectNum);
|
|
|
+ SceneProEdit sceneEdit = sceneProEditService.getByProId(scene.getId());
|
|
|
+
|
|
|
+ scene.setCameraId(cameraId);
|
|
|
+ scene.setPhoneId(phoneId);
|
|
|
+ scene.setNum(projectNum);
|
|
|
+ scene.setSpace(0L);
|
|
|
+
|
|
|
+ if (pic != null && pic.length() > 5) {
|
|
|
+ scene.setThumb(pic);
|
|
|
+ } else {
|
|
|
+ scene.setThumb(ConstantUrl.DEFAULT_SCENE_PIC);
|
|
|
+ }
|
|
|
+ scene.setThumb(scene.getThumb().concat("?t=") + System.currentTimeMillis());
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(userName)) {
|
|
|
+ scene.setUserId(userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sceneShootCount == null) {
|
|
|
+ scene.setShootCount(0);
|
|
|
+ } else {
|
|
|
+ scene.setShootCount(sceneShootCount);
|
|
|
+ }
|
|
|
+ if (sceneName != null) {
|
|
|
+ scene.setSceneName(sceneName);
|
|
|
+ }
|
|
|
+ if (sceneDec != null) {
|
|
|
+ scene.setSceneDec("<p>" + new String(sceneDec.getBytes("UTF-8")) + "</p>");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sceneType != null) {
|
|
|
+ scene.setSceneType(sceneType);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (gps != null && !gps.trim().equals("")) {
|
|
|
+ scene.setGps(gps);
|
|
|
+ }
|
|
|
+
|
|
|
+ scene.setAlgorithm(algorithm);
|
|
|
+ if(!org.springframework.util.StringUtils.isEmpty(firmwareVersion)){
|
|
|
+ scene.setFirmwareVersion(firmwareVersion);
|
|
|
+ }
|
|
|
+ scene.setBuildType(buildType);
|
|
|
+ log.info("场景记录添加到数据库:"+projectNum);
|
|
|
+
|
|
|
+ scene.setStatus(0);
|
|
|
+ scene.setPayStatus(0);
|
|
|
+ scene.setRecStatus("A");
|
|
|
+ scene.setCreateTime(new Date());
|
|
|
+ if (sceneName != null) {
|
|
|
+ scene.setSceneName(sceneName);
|
|
|
+ }
|
|
|
+ if (sceneType != null) {
|
|
|
+ scene.setSceneType(sceneType);
|
|
|
+ }
|
|
|
+ sceneProService.updateById(scene);
|
|
|
+
|
|
|
+ sceneEdit.setNeedKey(0);
|
|
|
+ if (cameraType.longValue() != 14 && !ObjectUtils.isEmpty(sceneKey)) {
|
|
|
+ sceneEdit.setNeedKey(1);
|
|
|
+ sceneEdit.setSceneKey(sceneKey);
|
|
|
+ }
|
|
|
+ sceneEdit.setProId(scene.getId());
|
|
|
+ sceneEdit.setMapVisi(1);
|
|
|
+ sceneEdit.setTourVisi(1);
|
|
|
+ sceneEdit.setVrVisi(1);
|
|
|
+ sceneEdit.setCadImgVisi(1);
|
|
|
+ sceneEdit.setPanoVisi(1);
|
|
|
+ sceneEdit.setOverlay(null);
|
|
|
+ sceneEdit.setM2dVisi(1);
|
|
|
+ sceneEdit.setPlayData(null);
|
|
|
+ sceneEdit.setFloorLogo("0");
|
|
|
+ sceneEdit.setM3dVisi(1);
|
|
|
+ sceneEdit.setJumpScene(false);
|
|
|
+ sceneEdit.setMeasureVisi(0);
|
|
|
+ sceneEdit.setFloorLogoSize(100);
|
|
|
+ sceneEdit.setUpdateTime(new Date());
|
|
|
+ sceneEdit.setRecStatus("A");
|
|
|
+ sceneEdit.setFloorPublishVer(sceneEdit.getFloorEditVer() + 1);
|
|
|
+ sceneEdit.setFloorEditVer(sceneEdit.getFloorEditVer() + 1);
|
|
|
+ sceneEdit.setVersion(sceneEdit.getVersion() + 1);
|
|
|
+ sceneEdit.setImagesVersion(sceneEdit.getImagesVersion() + 1);
|
|
|
+
|
|
|
+ sceneProEditService.updateById(sceneEdit);
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject scenejson = JSONObject.parseObject(JSONObject.toJSONString(scene));
|
|
|
+ scenejson.put("thumbImg", 0);
|
|
|
+ scenejson.put("version", sceneEdit.getVersion());
|
|
|
+ scenejson.put("floorLogo", 0);
|
|
|
+ if(!ObjectUtils.isEmpty(sceneKey)){
|
|
|
+ scenejson.put("sceneKey", sceneKey);
|
|
|
+ scenejson.put("public", 1);
|
|
|
+ }else{
|
|
|
+ scenejson.put("sceneKey", "");
|
|
|
+ scenejson.put("public", 0);
|
|
|
+ }
|
|
|
+ if(cameraType.longValue() < 4 || cameraType.longValue() == 5 || cameraType.longValue() == 6){
|
|
|
+ scenejson.put("visions", 1);
|
|
|
+ }else {
|
|
|
+ scenejson.put("visions", 2);
|
|
|
+ }
|
|
|
+ scenejson.put("createTime", new DateTime(new Date()).toString("yyyy-MM-dd HH:mm"));
|
|
|
+
|
|
|
+ scenejson.put("floorPublishVer", sceneEdit.getFloorPublishVer());
|
|
|
+ scenejson.put("floorEditVer", sceneEdit.getFloorEditVer());
|
|
|
+ scenejson.put("rulerVisi", sceneEdit.getRulerVisi());
|
|
|
+ scenejson.put("entry", null);
|
|
|
+
|
|
|
+ if(!org.springframework.util.StringUtils.isEmpty(sceneEdit.getHotsIds())){
|
|
|
+ scenejson.put("hots", 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ File file = new File(ConstantFilePath.SCENE_PATH+"data/data"+projectNum);
|
|
|
+ if(!file.exists()||!file.isDirectory())
|
|
|
+ {
|
|
|
+ file.mkdirs();
|
|
|
+ }
|
|
|
+ FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"scene.json", scenejson.toString());
|
|
|
+
|
|
|
+ //生成二维码
|
|
|
+ MatrixToImageWriterUtil.createQRCode(scene.getWebSite(), ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+".png",false, null);
|
|
|
+ MatrixToImageWriterUtil.createQRCode(scene.getWebSite() + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+"_en.png",false, null);
|
|
|
+ log.info("二维码生成完成");
|
|
|
+
|
|
|
+ ScenePlusVO scenePlusVO = new ScenePlusVO();
|
|
|
+ scenePlusVO.setSceneStatus(scene.getStatus());
|
|
|
+ scenePlusVO.setThumb(scene.getThumb());
|
|
|
+ scenePlusVO.setPayStatus(scene.getPayStatus());
|
|
|
+ scenePlusVO.setId(scene.getId());
|
|
|
+ scenePlusVO.setNum(scene.getNum());
|
|
|
+ scenePlusVO.setWebSite(scene.getWebSite());
|
|
|
+ scenePlusVO.setDataSource(scene.getDataSource());
|
|
|
+ return scenePlusVO;
|
|
|
+ }
|
|
|
+
|
|
|
public BuildSceneCallMessage getBuildSceneMqMessage(String projectNum,
|
|
|
Long cameraType, String algorithm, Integer resolution,
|
|
|
String buildType, String dataSource) {
|
|
@@ -1064,7 +1211,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
|
|
|
if(Objects.nonNull(scenePro) && (Objects.isNull(scenePro.getIsUpgrade())
|
|
|
|| scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue())){
|
|
|
- return rebuildV3Scene(scenePro,num,force);
|
|
|
+// return rebuildV3Scene(scenePro,num,force);
|
|
|
}
|
|
|
|
|
|
if(Objects.isNull(scenePlus)){
|
|
@@ -1183,56 +1330,56 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
|
|
|
}
|
|
|
|
|
|
- public ResultData rebuildV3Scene(ScenePro scenePro,String num,Boolean force) throws IOException {
|
|
|
-
|
|
|
- JSONObject configJson = JSONObject.parseObject(FileUtils.readFile(configJsonPath));
|
|
|
- String folderName = configJson.getString("id");
|
|
|
- String customUserId = configJson.getString("customUserId");
|
|
|
- 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.setUpdateTime(new Date());
|
|
|
- scenePreService.updateById(scenePre);
|
|
|
- log.info("异步开始上传文件");
|
|
|
- // 上传oaas
|
|
|
- fYunFileService.uploadFileByCommand(dataPath, ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
-
|
|
|
- //删除本地压缩包,防止补拍上传文件不一致
|
|
|
- FileUtil.del(parentPath);
|
|
|
-
|
|
|
- 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();
|
|
|
- }
|
|
|
+// public ResultData rebuildV3Scene(ScenePro scenePro,String num,Boolean force) throws IOException {
|
|
|
+//
|
|
|
+// JSONObject configJson = JSONObject.parseObject(FileUtils.readFile(configJsonPath));
|
|
|
+// String folderName = configJson.getString("id");
|
|
|
+// String customUserId = configJson.getString("customUserId");
|
|
|
+// 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.setUpdateTime(new Date());
|
|
|
+// scenePreService.updateById(scenePre);
|
|
|
+// log.info("异步开始上传文件");
|
|
|
+// // 上传oaas
|
|
|
+// fYunFileService.uploadFileByCommand(dataPath, ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
+//
|
|
|
+// //删除本地压缩包,防止补拍上传文件不一致
|
|
|
+// FileUtil.del(parentPath);
|
|
|
+//
|
|
|
+// 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();
|
|
|
+// }
|
|
|
|
|
|
private String getFileIdByFolderName(String folderName) {
|
|
|
// 检测是否有生成
|
|
@@ -1415,135 +1562,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
return scenePlusVO;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ResultData copyDataAndBuild(String sourceBucet,String dataSource, String sceneVer) throws Exception {
|
|
|
- if(!SceneVersionType.V3.code().equals(sceneVer)
|
|
|
- && !SceneVersionType.V4.code().equals(sceneVer)){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_FORMAT_ERROR.code(),"版本有误,请填写 V3 或者 V4");
|
|
|
- }
|
|
|
-
|
|
|
- String fYunPath = ConstantFilePath.OSS_PREFIX + dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
|
|
|
- .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
|
|
|
-// if(!ObjectUtils.isEmpty(sourceBucet)){
|
|
|
-// fYunFileService.copyFileBetweenBucket(sourceBucet,fYunPath,fYunFileConfig.getBucket(),fYunPath);
|
|
|
-// }
|
|
|
- // 下载data.fdage
|
|
|
- JSONObject fdageData = JSONObject.parseObject(fYunFileService.getFileContent(fYunPath + "/data.fdage"));
|
|
|
- if(ObjectUtils.isEmpty(fdageData)){
|
|
|
- throw new BusinessException(ErrorCode.SYSTEM_ERROR.code(),"4dage 文件不存在");
|
|
|
- }
|
|
|
- String cameraName = fdageData.getJSONObject("cam").getString("uuid");
|
|
|
- Camera cameraEntity = cameraService.getByChildName(cameraName);
|
|
|
- if(cameraEntity == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_6003);
|
|
|
- }
|
|
|
-
|
|
|
- CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraEntity.getId());
|
|
|
- if(detailEntity == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_6003);
|
|
|
- }
|
|
|
-
|
|
|
- // 拷贝资源至新的资源路径
|
|
|
- String[] newDataPath = dataSource.split("/");
|
|
|
- newDataPath[4] = newDataPath[4] + "_" + System.currentTimeMillis();
|
|
|
- String time = DateExtUtil.format(Calendar.getInstance().getTime(), DateExtUtil.dateStyle11);
|
|
|
- newDataPath[5] = newDataPath[5].split("_")[0] + "_" + time;
|
|
|
- String newDataSource = Arrays.stream(newDataPath).collect(Collectors.joining("/"));
|
|
|
-
|
|
|
- String newFYunPath = ConstantFilePath.OSS_PREFIX + newDataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
|
|
|
- .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
|
|
|
-
|
|
|
- List<ScenePro> pros = sceneProService.list(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getDataSource, newDataSource));
|
|
|
- if (CollUtil.isNotEmpty(pros)) {
|
|
|
- return ResultData.error(ErrorCode.PARAM_ERROR.code(),newDataSource + "已存在,请勿重复添加!");
|
|
|
- }
|
|
|
- List<ScenePlusExt> plusExts = scenePlusExtService.list(new LambdaQueryWrapper<ScenePlusExt>().eq(ScenePlusExt::getDataSource, newDataSource));
|
|
|
- if (CollUtil.isNotEmpty(plusExts)) {
|
|
|
- return ResultData.error(ErrorCode.PARAM_ERROR.code(),newDataSource + "已存在,请勿重复添加!");
|
|
|
- }
|
|
|
- List<String> newFyunFileList = fYunFileService.listRemoteFiles(newFYunPath);
|
|
|
- if(CollUtil.isNotEmpty(newFyunFileList)){
|
|
|
- return ResultData.error(ErrorCode.PARAM_ERROR.code(),newFYunPath + "已存在,请勿重复添加!");
|
|
|
- }
|
|
|
-
|
|
|
- String sceneNum = scene3dNumService.generateSceneNum(detailEntity.getType());
|
|
|
-
|
|
|
- //写入日志表
|
|
|
- SceneCopyDistinctEnv sceneCopyDistinctEnv = new SceneCopyDistinctEnv();
|
|
|
- sceneCopyDistinctEnv.setNum(sceneNum);
|
|
|
- sceneCopyDistinctEnv.setSrcDataSource(dataSource);
|
|
|
- sceneCopyDistinctEnv.setTargetDataSource(newDataSource);
|
|
|
- sceneCopyDistinctEnvService.save(sceneCopyDistinctEnv);
|
|
|
-
|
|
|
- ExecutorService executor = ThreadUtil.newSingleExecutor();
|
|
|
- try {
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
- try {
|
|
|
- fYunFileService.copyFileBetweenBucket(sourceBucet, fYunPath, fYunFileConfig.getBucket(), newFYunPath);
|
|
|
-
|
|
|
- fdageData.put("uuidtime",time);
|
|
|
- fYunFileService.uploadFile(fdageData.toJSONString().getBytes(),newFYunPath+"/data.fdage");
|
|
|
-
|
|
|
- Long cameraType = 11L;
|
|
|
- //判断是否转台相机
|
|
|
- if (detailEntity.getType() == 9) {
|
|
|
- cameraType = 13L;
|
|
|
- }
|
|
|
-
|
|
|
- if (detailEntity.getType() == 10) {
|
|
|
- cameraType = 14L;
|
|
|
- }
|
|
|
-
|
|
|
- String icon = null;
|
|
|
- String imgViewPath = null;
|
|
|
- switch (sceneVer) {
|
|
|
- case "V3":
|
|
|
- imgViewPath = String.format(ConstantFilePath.IMAGE_PATH_FORMAT, sceneNum);
|
|
|
- if(fdageData.containsKey("icon") && StringUtils.isNotEmpty(fdageData.getString("icon"))){
|
|
|
- String ossPath = ConstantFilePath.OSS_PREFIX + newDataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
|
|
|
- .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
|
|
|
- fYunFileService.copyFileInBucket(ossPath + File.separator + fdageData.getString("icon"),imgViewPath + fdageData.getString("icon"));
|
|
|
- icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
|
|
|
- }
|
|
|
- buildV3Scene2(newDataSource,fdageData,cameraType,sceneNum,cameraEntity,detailEntity,icon);
|
|
|
- break;
|
|
|
- case "V4":
|
|
|
- imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
|
|
|
- if(fdageData.containsKey("icon") && StringUtils.isNotEmpty(fdageData.getString("icon"))){
|
|
|
- String ossPath = ConstantFilePath.OSS_PREFIX + newDataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
|
|
|
- .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
|
|
|
- fYunFileService.copyFileInBucket(ossPath + File.separator + fdageData.getString("icon"),imgViewPath + fdageData.getString("icon"));
|
|
|
- icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
|
|
|
- }
|
|
|
- buildScenePost(newDataSource, fdageData, "V3", cameraType, sceneNum, detailEntity, 0, icon);
|
|
|
- if (cameraType == 14) {
|
|
|
- // 通知激光系统
|
|
|
- ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneNum);
|
|
|
- String userName = null;
|
|
|
- if (!ObjectUtils.isEmpty(detailEntity.getUserId())) {
|
|
|
- userName = userService.getSSOUserByUserId(detailEntity.getUserId()).getUserName();
|
|
|
- }
|
|
|
- fdkkLaserService.saveScene(scenePlus, fdageData.getString("pwd"), cameraEntity, userName, false);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- }catch (Exception e){
|
|
|
- log.error("复制场景异常", e);
|
|
|
- }
|
|
|
- }, executor).whenComplete((reslut, e) -> {
|
|
|
- log.info("复制场景souceDataSource:{},newDataSource:{}结束-{}",dataSource,newDataSource, new Date());
|
|
|
- });
|
|
|
- }catch (Exception e){
|
|
|
- log.error("线程错误:{}",e);
|
|
|
- }finally {
|
|
|
- executor.shutdown();
|
|
|
- }
|
|
|
- Map<String,Object> result = new HashMap<>();
|
|
|
- result.put("code",sceneNum);
|
|
|
- result.put("newDataSource",newDataSource);
|
|
|
- return ResultData.ok(result);
|
|
|
- }
|
|
|
|
|
|
private void buildV3Scene2(String dataSource,JSONObject jsonObject,long cameraType,String sceneNum,Camera cameraEntity,CameraDetail detailEntity,String icon) throws Exception {
|
|
|
|
|
@@ -1826,8 +1844,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
-@Override
|
|
|
-public ResultData uploadFile(MultipartFile file, String params) throws Exception {
|
|
|
+ @Override
|
|
|
+ public ResultData uploadFile(MultipartFile file, String params) throws Exception {
|
|
|
|
|
|
log.info("upload-params: "+params);
|
|
|
if (StringUtils.isEmpty(params)){
|
|
@@ -1982,8 +2000,8 @@ public ResultData uploadFile(MultipartFile file, String params) throws Exception
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-@Override
|
|
|
-public ResultData sendCallAlgorithm(SendCallAlgorithmParam param) throws Exception {
|
|
|
+ @Override
|
|
|
+ public ResultData sendCallAlgorithm(SendCallAlgorithmParam param) throws Exception {
|
|
|
log.info("sendCallAlgorithm 参数为:{}", JSONObject.toJSONString(param));
|
|
|
|
|
|
String filePath = param.getFilepath();
|
|
@@ -2002,12 +2020,12 @@ public ResultData sendCallAlgorithm(SendCallAlgorithmParam param) throws Excepti
|
|
|
SendCallAlgorithmDetail detail = param.getDetails();
|
|
|
String uploadType = detail.getUploadType();
|
|
|
if(StrUtil.isNotEmpty(uploadType) && "log".equals(uploadType)){
|
|
|
- return ResultData.ok();
|
|
|
+ return ResultData.ok();
|
|
|
}
|
|
|
Integer fileChunkSum = detail.getFileChunkSum();
|
|
|
String uuid = detail.getUuid();
|
|
|
if(Objects.isNull(fileChunkSum) || StrUtil.isBlank(uuid)){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(), "details参数中fileChunkSum和uuid不能为空");
|
|
|
+ throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(), "details参数中fileChunkSum和uuid不能为空");
|
|
|
}
|
|
|
|
|
|
String snCode = uuid.split("_")[0];
|
|
@@ -2017,27 +2035,27 @@ public ResultData sendCallAlgorithm(SendCallAlgorithmParam param) throws Excepti
|
|
|
// }
|
|
|
Camera camera = cameraService.getByChildName(snCode);
|
|
|
if(Objects.isNull(camera)){
|
|
|
- throw new BusinessException(ErrorCode.CAMERA_BIND_NO_EXIST.code(), "相机未入库");
|
|
|
+ throw new BusinessException(ErrorCode.CAMERA_BIND_NO_EXIST.code(), "相机未入库");
|
|
|
}
|
|
|
|
|
|
String localFilePath = parentPath.concat(File.separator).concat(uuid).concat(".zip");
|
|
|
try {
|
|
|
- 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){
|
|
|
- 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("压缩包分卷不完整,请继续上传剩余的分卷");
|
|
|
+ return ResultData.ok("压缩包分卷不完整,请继续上传剩余的分卷");
|
|
|
}
|
|
|
|
|
|
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();
|
|
@@ -2050,81 +2068,81 @@ public ResultData sendCallAlgorithm(SendCallAlgorithmParam param) throws Excepti
|
|
|
// 异步解压资源文件上传
|
|
|
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);
|
|
|
- }
|
|
|
+ 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;
|
|
|
- }
|
|
|
- configJsonPath = item;
|
|
|
- }
|
|
|
- String dataPath = FileUtil.getParent(configJsonPath, 1);
|
|
|
+ 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
|
|
|
- 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 customUserId = configJson.getString("customUserId");
|
|
|
- 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 customUserId = configJson.getString("customUserId");
|
|
|
+ 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.setUpdateTime(new Date());
|
|
|
- scenePreService.updateById(scenePre);
|
|
|
- log.info("异步开始上传文件");
|
|
|
- // 上传oaas
|
|
|
- fYunFileService.uploadFileByCommand(dataPath, ConstantFilePath.OSS_PREFIX.concat(subFolder));
|
|
|
+ // 检测是否有生成
|
|
|
+ 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);
|
|
|
|
|
|
- //删除本地压缩包,防止补拍上传文件不一致
|
|
|
- FileUtil.del(parentPath);
|
|
|
+ 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("通知计算成功");
|
|
|
+ //删除本地压缩包,防止补拍上传文件不一致
|
|
|
+ FileUtil.del(parentPath);
|
|
|
|
|
|
- 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);
|
|
|
+ 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();
|
|
|
+ executor.shutdown();
|
|
|
}
|
|
|
return ResultData.ok();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
}
|