|
@@ -4,8 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -32,11 +30,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -56,9 +51,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
@Value("${main.url}")
|
|
|
private String mainUrl;
|
|
|
|
|
|
- @Value("${scene.pro.url}")
|
|
|
- private String sceneProUrl;
|
|
|
-
|
|
|
@Value("${scene.pro.new.url}")
|
|
|
private String sceneProNewUrl;
|
|
|
|
|
@@ -71,23 +63,11 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
@Value("${ecs.type}")
|
|
|
private String ecsType;
|
|
|
|
|
|
- @Value("${unCalculated.company.ids:#{null}}")
|
|
|
- private String[] unCalculatedCompanyIds;
|
|
|
-
|
|
|
@Value("${queue.modeling.modeling-call}")
|
|
|
private String queueModelingCall;
|
|
|
@Value("${queue.modeling.modeling-pre}")
|
|
|
private String queueModelingPre;
|
|
|
|
|
|
- @Value("${queue.modeling.video-a}")
|
|
|
- private String queueVideoA;
|
|
|
-
|
|
|
- @Value("${queue.modeling.pic-a}")
|
|
|
- private String queuePicA;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ISceneFileUploadService sceneFileUploadService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
@@ -241,313 +221,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
return list.get(0);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ResponseSceneFile getProgress(String params) throws Exception {
|
|
|
- log.info("getProgress-params:{} ", params);
|
|
|
- if (StrUtil.isEmpty(params)){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
- params = params.replaceAll("%2B", "+");
|
|
|
- Base64 base64 = new Base64();
|
|
|
- String cipher = params;
|
|
|
- // 私钥解密过程
|
|
|
- byte[] res = RSAEncrypt.decrypt(RSAEncrypt.loadPrivateKeyByStr(RSAEncrypt.loadPrivateKeyByFile()),
|
|
|
- base64.decode(cipher));
|
|
|
- String restr = new String(res, "UTF-8");
|
|
|
- log.debug("getProgress-params解密结果:{}" , restr);
|
|
|
- String[] strArr = restr.split(SPLICE);
|
|
|
- if (strArr.length != 3) {
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
- String fileId = strArr[0];
|
|
|
- String chunk = strArr[1];
|
|
|
-
|
|
|
- chunk = chunk.split(SPLICE)[0];
|
|
|
- SceneFileUpload sceneFileUpload = sceneFileUploadService.findByFileIdAndChunk(fileId, Integer.valueOf(chunk));
|
|
|
-
|
|
|
- ResponseSceneFile responseSceneFile = new ResponseSceneFile();
|
|
|
- responseSceneFile.setUploadStatus(sceneFileUpload != null ? sceneFileUpload.getUploadStatus() : -1);
|
|
|
- return responseSceneFile;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ResultData uploadFile(MultipartFile file, String params) throws Exception{
|
|
|
- log.info("upload-params: "+params);
|
|
|
- if (StringUtils.isEmpty(params)){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
- params = params.replaceAll("%2B", "+");
|
|
|
- Base64 base64 = new Base64();
|
|
|
- String cipher = params;
|
|
|
- // 私钥解密过程
|
|
|
- byte[] res = RSAEncrypt.decrypt(RSAEncrypt.loadPrivateKeyByStr(RSAEncrypt.loadPrivateKeyByFile()),
|
|
|
- base64.decode(cipher));
|
|
|
- String restr = new String(res, "UTF-8");
|
|
|
- log.debug("upload-params解密结果:{}", restr);
|
|
|
- String[] strArr = restr.split(SPLICE);
|
|
|
- if (strArr.length != 6) {
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
- String mac = strArr[0];
|
|
|
- String fileId = strArr[1];
|
|
|
- String picNum = strArr[2];
|
|
|
- String md5 = strArr[3];
|
|
|
- String chunk = strArr[4];
|
|
|
-
|
|
|
- ResultData result = null;
|
|
|
- if (file.isEmpty()){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5048);
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(fileId)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5049);
|
|
|
- }
|
|
|
- if (picNum == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5050);
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(mac)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5044);
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(md5)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5051);
|
|
|
- }
|
|
|
- long size = file.getSize();
|
|
|
- log.warn("fileId:"+fileId+"---picNum:"+picNum+"---size:"+size+"---md5:"+md5+"---mac:"+mac);
|
|
|
- chunk = chunk.split(SPLICE)[0];
|
|
|
- // 获取文件名
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
- log.info("上传的文件名为:" + fileName);
|
|
|
- // 获取文件的后缀名
|
|
|
- String suffixName = fileName.substring(fileName.lastIndexOf("."));
|
|
|
- log.info("上传的后缀名为:" + suffixName);
|
|
|
- Object folderNameObject = redisUtil.get(fileId);
|
|
|
- String folderName = folderNameObject == null ? null : (String)folderNameObject;
|
|
|
- if(StrUtil.isEmpty(folderName)){
|
|
|
- String dataSource = scenePlusService.getDataSourceLikeUnicode("/" + fileId + "/");
|
|
|
- if(StrUtil.isNotEmpty(dataSource)){
|
|
|
- folderName = dataSource.substring(dataSource.lastIndexOf("/") + 1);
|
|
|
- }
|
|
|
- }
|
|
|
- // 1. 判断该文件是否已经上传过
|
|
|
- // 2. 如果已经上传过,判断MD5值和文件大小是否相等。如果相等,更新数据记录。如果不相等,删除该文件,重新上传。
|
|
|
- // 3. 如果未上传过,需要上传。
|
|
|
- StringBuffer filePathBuffer = new StringBuffer(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator).append("capture");
|
|
|
- StringBuffer sb = new StringBuffer(routeConfig.getHardDisk()).append(filePathBuffer.toString()).append(File.separator).append(fileName);
|
|
|
-
|
|
|
- boolean needUpload = false;
|
|
|
- File dbFile = new File(sb.toString());
|
|
|
- if (dbFile.exists()){
|
|
|
- String fileMD5 = FileMd5Util.getFileMD5(dbFile);
|
|
|
- if (md5.equals(fileMD5) && dbFile.length() == size){
|
|
|
- log.warn("文件已存在,MD5和文件大小一致。");
|
|
|
-
|
|
|
- SceneFileUpload uploadEntity = sceneFileUploadService.findByFileIdAndChunk(fileId, Integer.valueOf(chunk));
|
|
|
- if (uploadEntity != null){
|
|
|
- uploadEntity.setSize((int) size);
|
|
|
- uploadEntity.setMd5(md5);
|
|
|
- uploadEntity.setFilePath(sb.toString());
|
|
|
- uploadEntity.setFileSourceName(fileName);
|
|
|
- uploadEntity.setUploadStatus(UploadStatus.SUCCESS.code());
|
|
|
- sceneFileUploadService.updateById(uploadEntity);
|
|
|
- }else{
|
|
|
- SceneFileUpload sceneFileUploadEntity = new SceneFileUpload();
|
|
|
- sceneFileUploadEntity.setSize((int) size);
|
|
|
- sceneFileUploadEntity.setMd5(md5);
|
|
|
- sceneFileUploadEntity.setFilePath(sb.toString());
|
|
|
- sceneFileUploadEntity.setFileSourceName(fileName);
|
|
|
- sceneFileUploadEntity.setUploadStatus(UploadStatus.SUCCESS.code());
|
|
|
- sceneFileUploadEntity.setFileId(fileId);
|
|
|
- sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
|
|
|
- sceneFileUploadEntity.setRecStatus(RecStatus.VALID.code());
|
|
|
- sceneFileUploadService.save(sceneFileUploadEntity);
|
|
|
- }
|
|
|
- result = ResultData.ok();
|
|
|
- }else if (!md5.equals(fileMD5)) {
|
|
|
- log.warn("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
|
|
|
- FileUtil.delFile(sb.toString());
|
|
|
- needUpload = true;
|
|
|
- }else if (dbFile.length() != size){
|
|
|
- log.warn("文件已上传,文件大小不一致。上传失败");
|
|
|
- FileUtil.delFile(sb.toString());
|
|
|
- needUpload = true;
|
|
|
- }
|
|
|
- }else {
|
|
|
- log.warn("文件不存在,需要重新上传");
|
|
|
- needUpload = true;
|
|
|
- }
|
|
|
-
|
|
|
- // 4. 上传成功后,校验MD5和文件大小是否相等
|
|
|
- // 5. 如果相等,更新数据记录。如果不相等,返回上传失败结果。
|
|
|
- try {
|
|
|
- if (needUpload){
|
|
|
- String name = fileName.substring(0, fileName.lastIndexOf("."));
|
|
|
- String filePath = this.saveFile(file, filePathBuffer.toString(), name);
|
|
|
- File uploadFile = new File(filePath);
|
|
|
- String fileMD5 = FileMd5Util.getFileMD5(uploadFile);
|
|
|
-
|
|
|
- SceneFileUpload sceneFileUploadEntity = new SceneFileUpload();
|
|
|
- sceneFileUploadEntity.setSize((int) size);
|
|
|
- sceneFileUploadEntity.setMd5(md5);
|
|
|
- sceneFileUploadEntity.setFilePath(sb.toString());
|
|
|
- sceneFileUploadEntity.setFileSourceName(fileName);
|
|
|
- sceneFileUploadEntity.setFileId(fileId);
|
|
|
- sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
|
|
|
- sceneFileUploadEntity.setRecStatus(RecStatus.VALID.code());
|
|
|
-
|
|
|
- if (md5.equals(fileMD5) && uploadFile.length() == size){
|
|
|
- log.warn("文件已上传,MD5和文件大小一致。上传成功");
|
|
|
- sceneFileUploadEntity.setUploadStatus(1);
|
|
|
- sceneFileUploadService.save(sceneFileUploadEntity);
|
|
|
- result = ResultData.ok();
|
|
|
- }else if (!md5.equals(fileMD5)) {
|
|
|
- log.warn("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
|
|
|
- sceneFileUploadEntity.setUploadStatus(-1);
|
|
|
- sceneFileUploadService.save(sceneFileUploadEntity);
|
|
|
- result = ResultData.error(ErrorCode.FAILURE_CODE_5052);
|
|
|
- }else if (uploadFile.length() != size){
|
|
|
- log.warn("文件已上传,文件大小不一致。上传失败");
|
|
|
- sceneFileUploadEntity.setUploadStatus(-1);
|
|
|
- sceneFileUploadService.save(sceneFileUploadEntity);
|
|
|
- result = ResultData.error(ErrorCode.FAILURE_CODE_5052);
|
|
|
- }
|
|
|
- }
|
|
|
- }catch (IllegalStateException | IOException e) {
|
|
|
- log.error(ErrorCode.FAILURE_CODE_5052.message(), e);
|
|
|
- result = ResultData.error(ErrorCode.FAILURE_CODE_5052);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- public String saveFile(MultipartFile file, String filePath, String fileId) throws IOException {
|
|
|
- //扩展名格式
|
|
|
- String extName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
|
|
- String name;
|
|
|
- /*
|
|
|
- 指定上传目录
|
|
|
- */
|
|
|
- if (filePath != null && !"".equals(filePath.trim())) {
|
|
|
- name = designatedUp(filePath, fileId, file);
|
|
|
- return name;
|
|
|
- }
|
|
|
- /*
|
|
|
- 默认上传目录
|
|
|
- */
|
|
|
- //图片类型文件
|
|
|
- if (this.inArray(routeConfig.getImageType(), extName)) {
|
|
|
- filePath = routeConfig.getImageFolder();
|
|
|
- }
|
|
|
- //视频类型文件
|
|
|
- else if (this.inArray(routeConfig.getVideoType(), extName)) {
|
|
|
- filePath = routeConfig.getVideoFolder();
|
|
|
- }
|
|
|
- //文档类型文件
|
|
|
- else if (this.inArray(routeConfig.getDocumentType(), extName)) {
|
|
|
- filePath = routeConfig.getDocumentFolder();
|
|
|
- }
|
|
|
- //音频类型文件
|
|
|
- else if (this.inArray(routeConfig.getMusicType(), extName)) {
|
|
|
- filePath = routeConfig.getMusicFolder();
|
|
|
- } else {
|
|
|
- return "This upload type is not supported temporarily";
|
|
|
- }
|
|
|
- name = myfileUp(filePath, file);
|
|
|
- return name;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 默认上传文件到文件夹
|
|
|
- *
|
|
|
- * @param folder 默认文件夹
|
|
|
- * @param file 上传的文件
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String myfileUp(String folder, MultipartFile file) throws IOException {
|
|
|
- LocalDate today = LocalDate.now();
|
|
|
- String saveName = File.separator + today.getYear() + "." + today.getMonthValue() + File.separator;
|
|
|
- String fileCode = UUID.randomUUID().toString().trim().replaceAll("-", "");
|
|
|
- String returnName = FileUpload.fileUp(file, routeConfig.getHardDisk() + File.separator + folder + saveName, fileCode);
|
|
|
- saveName = folder + File.separator + saveName + File.separator + returnName;
|
|
|
- log.warn("This file has been uploaded: " + saveName);
|
|
|
- return saveName;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 判断数组中是否包含某个元素
|
|
|
- *
|
|
|
- * @param array 类型的数组
|
|
|
- * @param element 被检查的类型
|
|
|
- * @return
|
|
|
- */
|
|
|
- private boolean inArray(String[] array, String element) {
|
|
|
- boolean flag = false;
|
|
|
- for (String type : array) {
|
|
|
- if (element.equals(type)) {
|
|
|
- flag = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- return flag;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 指定目录上传文件
|
|
|
- *
|
|
|
- * @param folder 指定文件夹
|
|
|
- * @param file 上传文件
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String designatedUp(String folder, String fileId, MultipartFile file) throws IOException {
|
|
|
- StringBuffer sb = new StringBuffer(routeConfig.getHardDisk()).append(File.separator).append(folder);
|
|
|
- String returnName = FileUpload.fileUp(file, sb.toString(), fileId);
|
|
|
- String filePathName = sb.toString() + File.separator + File.separator + returnName;
|
|
|
- log.warn("This file has been uploaded: " + filePathName);
|
|
|
- return filePathName;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ResultData uploadSuccess(String params) throws Exception {
|
|
|
- log.info("uploadSuccess-params: " + params);
|
|
|
- if (StrUtil.isEmpty(params)) {
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
- params = params.replaceAll("%2B", "+");
|
|
|
- Base64 base64 = new Base64();
|
|
|
- String cipher = params;
|
|
|
- // 私钥解密过程
|
|
|
- byte[] res = RSAEncrypt.decrypt(RSAEncrypt.loadPrivateKeyByStr(RSAEncrypt.loadPrivateKeyByFile()),
|
|
|
- base64.decode(cipher));
|
|
|
- String restr = new String(res, "UTF-8");
|
|
|
- log.debug("uploadSuccess-params解密结果:" + restr);
|
|
|
- String[] strArr = restr.split(SPLICE);
|
|
|
- if (strArr.length != 3) {
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
- String mac = strArr[0];
|
|
|
- String fileId = strArr[1];
|
|
|
- Object folderNameObject = redisUtil.get(fileId);
|
|
|
- String folderName = folderNameObject == null ? null : (String)folderNameObject;
|
|
|
- if(StringUtils.isEmpty(folderName)){
|
|
|
- String dataSource = scenePlusService.getDataSourceLikeUnicode("/" + fileId + "/");
|
|
|
- if(StrUtil.isNotEmpty(dataSource)){
|
|
|
- folderName = dataSource.substring(dataSource.lastIndexOf("/") + 1);
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isEmpty(folderName)){
|
|
|
- SceneFileBuild sceneFileBuild = this.findByFileId(fileId);
|
|
|
- if(sceneFileBuild != null){
|
|
|
- folderName = sceneFileBuild.getUnicode();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- StringBuilder filePathBuffer = new StringBuilder(routeConfig.getHardDisk()).append(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator).append("capture").append(File.separator);
|
|
|
- boolean flag = this.uploadSuccess(fileId, filePathBuffer);
|
|
|
-
|
|
|
- if(flag){
|
|
|
- //调用建模的方法
|
|
|
- }
|
|
|
- buildScene(filePathBuffer.toString(), fileId, false, null);
|
|
|
- return ResultData.ok();
|
|
|
- }
|
|
|
-
|
|
|
public void buildScene(String filePath, String fileId, boolean fromOss, String prefix) throws Exception{
|
|
|
//获取解压后的资源的data.fdage中的数据
|
|
|
String data = FileUtils.readFile(filePath + "data.fdage");
|
|
@@ -814,19 +487,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public boolean uploadSuccess(String fileId, StringBuilder filePathBuffer) {
|
|
|
- SceneFileBuild sceneFileBuild = findByFileId(fileId);
|
|
|
- if (Objects.isNull(sceneFileBuild))
|
|
|
- return false;
|
|
|
-
|
|
|
- Long uploadSuccessCount = sceneFileUploadService.countUploadSuccessByFileId(fileId);
|
|
|
- sceneFileBuild.setUploadStatus(UploadStatus.SUCCESS.code());
|
|
|
- sceneFileBuild.setChunks(Integer.valueOf(uploadSuccessCount.toString()));
|
|
|
- sceneFileBuild.setUpdateTime(Calendar.getInstance().getTime());
|
|
|
- this.updateById(sceneFileBuild);
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public ResultData uploadSuccessBuild(String params) throws Exception {
|
|
|
log.info("uploadSuccessBuild-params: " + params);
|
|
@@ -1421,203 +1081,4 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
mqMsg.setThumb(thumb);
|
|
|
return mqMsg;
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public ResultData getS3UploadUrl(String params) throws Exception {
|
|
|
- if (StringUtils.isEmpty(params)) {
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
- JSONObject jsonObject = JSON.parseObject(params);
|
|
|
- if(jsonObject == null){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_FORMAT_ERROR);
|
|
|
- }
|
|
|
- JSONArray files = jsonObject.getJSONArray("Files");
|
|
|
- if(files == null){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_FORMAT_ERROR);
|
|
|
- }
|
|
|
- List<String> urls = new ArrayList<>();
|
|
|
- for(int i = 0, len = files.size(); i < len; i++){
|
|
|
- urls.add(files.getJSONObject(i).getString("filename"));
|
|
|
- }
|
|
|
- return ResultData.ok(uploadToOssUtil.getUploadS3Url(urls));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ResultData buildLiteScene(String prefix, String dataFdage, String zipName, String userName, String password, String oldNum) throws Exception{
|
|
|
- log.info("参数-prefix: {}, dataFdage: {}, zipName: {}, password: {}, userName: {}", prefix,
|
|
|
- dataFdage, zipName, password, userName);
|
|
|
-
|
|
|
- if(StringUtils.isEmpty(prefix) || StringUtils.isEmpty(dataFdage) || StringUtils.isEmpty(zipName) ||
|
|
|
- StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
-
|
|
|
- Camera camera = cameraService.getByChildName(userName);
|
|
|
- if(camera == null){
|
|
|
- camera = cameraService.getBySnCode(userName);
|
|
|
- }
|
|
|
- if (camera == null){
|
|
|
- throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
|
- }
|
|
|
- if(!password.equals(camera.getChildPassword())){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_3014);
|
|
|
- }
|
|
|
- CameraDetail cameraDetail = cameraDetailService.getByCameraId(camera.getId());
|
|
|
- if(cameraDetail == null){
|
|
|
- throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
|
- }
|
|
|
- String unicode = prefix.substring(prefix.lastIndexOf("/") + 1);
|
|
|
- String path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
|
|
|
-
|
|
|
- //下载data.fdage
|
|
|
- FileUtils.downLoadFromUrl(prefix + "/" + dataFdage + "?m=" + System.currentTimeMillis(), dataFdage, path + File.separator + "capture");
|
|
|
- String data = FileUtils.readFile(path + File.separator + "capture/" + dataFdage);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
- if(jsonObject == null){
|
|
|
- log.info("data.fdage不存在");
|
|
|
- throw new BusinessException(CameraConstant.FAILURE_6009);
|
|
|
- }
|
|
|
-
|
|
|
- String sceneNum = "";
|
|
|
- //查看场景中的文件目录是否有改文件id,有则重新计算改场景,无则新建场景
|
|
|
- ScenePlus scenePlus = scenePlusService.getByFileId("/" + unicode);
|
|
|
- int rebuild = 1;
|
|
|
- if(StrUtil.isNotEmpty(oldNum)){
|
|
|
- sceneNum = oldNum;
|
|
|
- }else {
|
|
|
-
|
|
|
- if(scenePlus != null){
|
|
|
- sceneNum = scenePlus.getNum();
|
|
|
- //重算的场景,先移除该场景对应的容量
|
|
|
- scenePlusService.resetSpace(sceneNum);
|
|
|
- }else {
|
|
|
- sceneNum = scene3dNumService.generateSceneNum(cameraDetail.getType());
|
|
|
- rebuild = 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- String cameraName = jsonObject.getJSONObject("cam").getString("uuid");
|
|
|
- log.info("查询相机:" + cameraName);
|
|
|
- camera = cameraService.getByChildName(cameraName);
|
|
|
- if(camera == null){
|
|
|
- log.error("该相机不存在:" + cameraName);
|
|
|
- //偶现data.fdage给的相机码多了或少了4DKKPRO_
|
|
|
- if(cameraName.contains("4DKKPRO_")){
|
|
|
- camera = cameraService.getByChildName(cameraName.replace("4DKKPRO_", ""));
|
|
|
- }else {
|
|
|
- camera = cameraService.getByChildName("4DKKPRO_" + cameraName);
|
|
|
- }
|
|
|
- if(camera == null){
|
|
|
- throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- String icon = null;
|
|
|
- if(jsonObject.containsKey("icon") && StrUtil.isNotEmpty(jsonObject.getString("icon"))){
|
|
|
- //下载封面图icon
|
|
|
- FileUtils.downLoadFromUrl(prefix + "/" + jsonObject.getString("icon") + "?m=" + System.currentTimeMillis(), jsonObject.getString("icon"), path + File.separator + "capture");
|
|
|
- uploadToOssUtil.upload(path + File.separator + "capture" + File.separator +
|
|
|
- jsonObject.getString("icon"), imgViewPath + jsonObject.getString("icon"));
|
|
|
- icon = prefixAli + imgViewPath + jsonObject.getString("icon");
|
|
|
- if(StorageType.AWS.code().equals(type)){
|
|
|
- icon = ConstantUrl.PREFIX_AWS + imgViewPath + jsonObject.getString("icon");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject firmwareVersion = new JSONObject();
|
|
|
- if(jsonObject.containsKey("camSoftwareVersion") && StrUtil.isNotEmpty(jsonObject.getString("camSoftwareVersion"))){
|
|
|
- firmwareVersion.put("camSoftwareVersion", jsonObject.getString("camSoftwareVersion"));
|
|
|
- }
|
|
|
-
|
|
|
- if(jsonObject.containsKey("version") && StrUtil.isNotEmpty(jsonObject.getString("version"))){
|
|
|
- firmwareVersion.put("version", jsonObject.getString("version"));
|
|
|
- }
|
|
|
-
|
|
|
- String sceneUrl = mainUrl + sceneProNewUrl;
|
|
|
- String buildType = "V3";
|
|
|
- //表示新款双目
|
|
|
- Long cameraType = 5L;
|
|
|
- if(jsonObject.getJSONObject("cam").getIntValue("type") == 5){
|
|
|
-
|
|
|
- //6表示小红屋双目
|
|
|
- cameraType = 6L;
|
|
|
- }
|
|
|
-
|
|
|
- Object[] objects = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(),
|
|
|
- jsonObject.getString("creator"),
|
|
|
- jsonObject.getString("pwd"), unicode,
|
|
|
- cameraType, "", prefix, zipName, icon, "0", cameraDetail.getUserId(), userName,
|
|
|
- jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location"))
|
|
|
- ? "sfm" : "slam",
|
|
|
- jsonObject.getJSONArray("points").size(), jsonObject.getString("name"),
|
|
|
- jsonObject.getString("info"),
|
|
|
- jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
|
|
|
- 4, firmwareVersion.toString(), sceneUrl, buildType, ecsType,
|
|
|
- cameraDetail.getCooperationUser());
|
|
|
- BuildSceneCallMessage mqMessage = (BuildSceneCallMessage)objects[1];
|
|
|
- ScenePlusVO scenePlusVO = (ScenePlusVO) objects[0];
|
|
|
-
|
|
|
- if(scenePlusVO == null){
|
|
|
- log.info("双目相机入库失败");
|
|
|
- return ResultData.error(ErrorCode.FAILURE_CODE_5056);
|
|
|
- }
|
|
|
- JSONObject statusJson = new JSONObject();
|
|
|
- //临时将-2改成1,app还没完全更新
|
|
|
- statusJson.put("status", scenePlusVO.getSceneStatus() == -2? 1 : scenePlusVO.getSceneStatus());
|
|
|
- statusJson.put("webSite", scenePlusVO.getWebSite());
|
|
|
- statusJson.put("sceneNum", scenePlusVO.getNum());
|
|
|
- statusJson.put("thumb", scenePlusVO.getThumb());
|
|
|
- statusJson.put("payStatus", scenePlusVO.getPayStatus());
|
|
|
- FileUtils.writeFile(localDataPath + "status.json", statusJson.toString());
|
|
|
- uploadToOssUtil.upload(localDataPath + "status.json", dataViewPath + "status.json");
|
|
|
-
|
|
|
- //删除oss的houst_floor.json
|
|
|
- uploadToOssUtil.delete(dataViewPath + "houst_floor.json");
|
|
|
-
|
|
|
- rabbitMqProducer.sendByWorkQueue(queueModelingPre, mqMessage);
|
|
|
-
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- map.put("sceneNum", sceneNum);
|
|
|
- map.put("sceneUrl", sceneUrl + sceneNum);
|
|
|
- return ResultData.ok(map);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ResultData buildScene(String prefix, String unicode, String zip, String dataFdage) throws Exception{
|
|
|
-
|
|
|
- String data = FileUtils.readFile(ConstantFilePath.BUILD_MODEL_PATH + unicode + "/data.fdage");
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
- String cameraName = jsonObject.getJSONObject("cam").getString("uuid");
|
|
|
-
|
|
|
- log.info("查询相机:" + cameraName);
|
|
|
- Camera cameraEntity = cameraService.getByChildName(cameraName);
|
|
|
- if(cameraEntity == null){
|
|
|
- log.error("该相机不存在:" + cameraName);
|
|
|
- //偶现data.fdage给的相机码多了或少了4DKKPRO_
|
|
|
- if(cameraName.contains("4DKKPRO_")){
|
|
|
- cameraEntity = cameraService.getByChildName(cameraName.replace("4DKKPRO_", ""));
|
|
|
- }else {
|
|
|
- cameraEntity = cameraService.getByChildName("4DKKPRO_" + cameraName);
|
|
|
- }
|
|
|
- if(cameraEntity == null){
|
|
|
- throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
|
- }
|
|
|
- }
|
|
|
- CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraEntity.getId());
|
|
|
- if(detailEntity == null){
|
|
|
- log.error("该相机详情不存在:" + cameraName);
|
|
|
- throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
|
- }
|
|
|
- String sceneNum = scene3dNumService.generateSceneNum(detailEntity.getType());
|
|
|
-
|
|
|
- return ResultData.ok(mainUrl + sceneProNewUrl + sceneNum);
|
|
|
- }
|
|
|
}
|