|
@@ -7,13 +7,49 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.fdkankan.common.constant.*;
|
|
|
+import com.fdkankan.common.constant.CameraConstant;
|
|
|
+import com.fdkankan.common.constant.CommonStatus;
|
|
|
+import com.fdkankan.common.constant.ConstantUrl;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.RecStatus;
|
|
|
+import com.fdkankan.common.constant.SceneStatus;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
-import com.fdkankan.common.util.*;
|
|
|
-import com.fdkankan.contro.entity.*;
|
|
|
+import com.fdkankan.common.util.DateExtUtil;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.common.util.SnowflakeIdGenerator;
|
|
|
+import com.fdkankan.contro.entity.Camera;
|
|
|
+import com.fdkankan.contro.entity.CameraDetail;
|
|
|
+import com.fdkankan.contro.entity.Company;
|
|
|
+import com.fdkankan.contro.entity.SSOUser;
|
|
|
+import com.fdkankan.contro.entity.SceneCooperation;
|
|
|
+import com.fdkankan.contro.entity.SceneEditControls;
|
|
|
+import com.fdkankan.contro.entity.SceneEditInfo;
|
|
|
+import com.fdkankan.contro.entity.SceneEditInfoExt;
|
|
|
+import com.fdkankan.contro.entity.SceneFileBuild;
|
|
|
+import com.fdkankan.contro.entity.ScenePlus;
|
|
|
+import com.fdkankan.contro.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.contro.entity.ScenePro;
|
|
|
+import com.fdkankan.contro.entity.SceneResourceCamera;
|
|
|
+import com.fdkankan.contro.entity.SceneResourceCooperation;
|
|
|
import com.fdkankan.contro.mapper.ISceneFileBuildMapper;
|
|
|
-import com.fdkankan.contro.service.*;
|
|
|
+import com.fdkankan.contro.service.ICameraDetailService;
|
|
|
+import com.fdkankan.contro.service.ICameraService;
|
|
|
+import com.fdkankan.contro.service.ICompanyService;
|
|
|
+import com.fdkankan.contro.service.IFdkkLaserService;
|
|
|
+import com.fdkankan.contro.service.IScene3dNumService;
|
|
|
+import com.fdkankan.contro.service.ISceneCooperationService;
|
|
|
+import com.fdkankan.contro.service.ISceneEditControlsService;
|
|
|
+import com.fdkankan.contro.service.ISceneEditInfoExtService;
|
|
|
+import com.fdkankan.contro.service.ISceneEditInfoService;
|
|
|
+import com.fdkankan.contro.service.ISceneFileBuildService;
|
|
|
+import com.fdkankan.contro.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.contro.service.IScenePlusService;
|
|
|
+import com.fdkankan.contro.service.ISceneProService;
|
|
|
+import com.fdkankan.contro.service.ISceneResourceCameraService;
|
|
|
+import com.fdkankan.contro.service.ISceneResourceCooperationService;
|
|
|
+import com.fdkankan.contro.service.IUserService;
|
|
|
import com.fdkankan.contro.vo.ResponseSceneFile;
|
|
|
import com.fdkankan.contro.vo.ScenePlusVO;
|
|
|
import com.fdkankan.fyun.config.FYunFileConfig;
|
|
@@ -30,6 +66,13 @@ import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.web.config.FileRouteConfig;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import com.fdkankan.web.util.RSAEncrypt;
|
|
|
+import java.io.File;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -38,9 +81,6 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
/**
|
|
|
* <p>
|
|
|
* 场景文件建模表 服务实现类
|
|
@@ -65,6 +105,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
private String queueModelingCall;
|
|
|
@Value("${queue.modeling.modeling-pre}")
|
|
|
private String queueModelingPre;
|
|
|
+ @Value("${fyun.type}")
|
|
|
+ private String fyunType;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
@@ -116,6 +158,11 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
@Autowired
|
|
|
private FYunFileConfig fYunFileConfig;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISceneProService sceneProService;
|
|
|
+ @Autowired
|
|
|
+ private IFdkkLaserService fdkkLaserService;
|
|
|
+
|
|
|
@Override
|
|
|
public SceneFileBuild findByFileId(String fileId) {
|
|
|
|
|
@@ -356,7 +403,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
if(fromOss){
|
|
|
objects = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(), jsonObject.getString("creator"),
|
|
|
jsonObject.getString("pwd"), unicode,
|
|
|
- cameraType, String.valueOf(fileId), prefix, "", icon, "0", cameraDetail.getUserId(), userName,
|
|
|
+ cameraType, fileId, prefix, "", 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,
|
|
@@ -1036,4 +1083,177 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
mqMsg.setThumb(thumb);
|
|
|
return mqMsg;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData rebuildScene(String num) {
|
|
|
+
|
|
|
+ ScenePro scenePro = sceneProService.getByNum(num);
|
|
|
+ //如果是v3场景,不允许重算,需要升级v4后再调此接口进行重算
|
|
|
+ if(Objects.nonNull(scenePro)
|
|
|
+ && (Objects.isNull(scenePro.getIsUpgrade())
|
|
|
+ || scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue())){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5064);
|
|
|
+ }
|
|
|
+
|
|
|
+ ScenePlusVO scenePlusVO = null;
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ }
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String path = scenePlusExt.getDataSource();
|
|
|
+ Integer sceneSource = scenePlus.getSceneSource();
|
|
|
+ String dataSource = scenePlusExt.getDataSource();
|
|
|
+ Long sceneUserId = scenePlus.getUserId();
|
|
|
+ String buildType = scenePlusExt.getBuildType();
|
|
|
+ Integer sceneStatus = scenePlus.getSceneStatus();
|
|
|
+ String webSite = scenePlusExt.getWebSite();
|
|
|
+ String thumb = scenePlusExt.getThumb();
|
|
|
+ Integer payStatus = scenePlus.getPayStatus();
|
|
|
+ Integer sceneScheme = scenePlusExt.getSceneScheme();
|
|
|
+ Long sceneId = scenePlus.getId();
|
|
|
+ String sceneName = scenePlus.getTitle();
|
|
|
+ Date createTime = scenePlus.getCreateTime();
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
+
|
|
|
+ //重新计算时需要删除文件夹,否知使用缓存
|
|
|
+ FileUtils.delAllFile(path + File.separator + "results");
|
|
|
+
|
|
|
+ String fileId = path.split("/")[path.split("/").length - 2];
|
|
|
+ log.info("fileId:" + fileId);
|
|
|
+ //获取解压后的资源的data.fdage中的数据
|
|
|
+ File folderPath = new File(path);
|
|
|
+
|
|
|
+ if (fyunType.equals(FYunTypeEnum.AWS.code())) {
|
|
|
+ fYunFileService.downloadFileByCommand(bucket, path + "/capture/",
|
|
|
+ ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, ""));
|
|
|
+ } else {
|
|
|
+ String dataFdageOssPath =
|
|
|
+ ConstantFilePath.OSS_PREFIX +
|
|
|
+ path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
|
|
|
+ .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage";
|
|
|
+ fYunFileService.downloadFileByCommand(bucket, path + "/capture/data.fdage", dataFdageOssPath);
|
|
|
+ }
|
|
|
+ String data = FileUtils.readFile(folderPath.getAbsolutePath() + File.separator + "capture" + File.separator + "data.fdage");
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(data);
|
|
|
+ if(ObjectUtils.isEmpty(jsonObject)){
|
|
|
+ log.error("data.fdage文件不存在");
|
|
|
+ return ResultData.error(CameraConstant.FAILURE_6009.code(), CameraConstant.FAILURE_6009.message());
|
|
|
+ }
|
|
|
+
|
|
|
+ String sceneUrl = mainUrl +"/"+sceneProNewUrl;
|
|
|
+
|
|
|
+ //有points字段的是八目
|
|
|
+ if (!jsonObject.containsKey("points")) {
|
|
|
+// String cameraName = jsonObject.getString("camid");
|
|
|
+// Camera camera = cameraService.getByChildName(cameraName);
|
|
|
+// if (camera == null) {
|
|
|
+// log.error("该相机不存在:" + cameraName);
|
|
|
+// throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
|
+// }
|
|
|
+//
|
|
|
+// CameraDetail detail = cameraDetailService.getByCameraId(camera.getId());
|
|
|
+// if (detail == null) {
|
|
|
+// log.error("该相机详情不存在:" + cameraName);
|
|
|
+// throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
|
+// }
|
|
|
+//
|
|
|
+// Long userId = null;
|
|
|
+// String userName = null;
|
|
|
+//
|
|
|
+// if (detail.getUserId() != null) {
|
|
|
+// SSOUser user = userService.getSSOUserByUserId(detail.getUserId());
|
|
|
+// if (user == null) {
|
|
|
+// log.error("用户id不存在:" + detail.getUserId());
|
|
|
+// } else {
|
|
|
+// userId = user.getId();
|
|
|
+// userName = user.getUserName();
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// //13表示转台
|
|
|
+// Long cameraType = 13L;
|
|
|
+// //激光转台 八目相机占用 10 和 11
|
|
|
+// if(jsonObject.getJSONObject("cam").getIntValue("type") == 10){
|
|
|
+// //激光转台
|
|
|
+// cameraType = 14L;
|
|
|
+// }
|
|
|
+//
|
|
|
+// String unicode = jsonObject.getString("creator") + "_" + jsonObject.getString("uuidtime");
|
|
|
+// Object[] objects = this.createScenePlus(num, camera.getId(), camera.getChildName(), jsonObject.getString("creator"),
|
|
|
+// jsonObject.getString("pwd"), unicode,
|
|
|
+// detail.getType(), fileId, "http://creator.4dkankan.com/" + unicode + File.separator, "zip.Zip",
|
|
|
+// jsonObject.getString("scenePic"), "0", userId, userName,
|
|
|
+// jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location")) ? "sfm" : "slam",
|
|
|
+// jsonObject.getJSONArray("imgs").size(), jsonObject.getString("name"), jsonObject.getString("info"),
|
|
|
+// jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), 1,
|
|
|
+// jsonObject.getInteger("resolution"), sceneUrl, buildType, null);
|
|
|
+// BuildSceneCallMessage mqMessage = (BuildSceneCallMessage)objects[1];
|
|
|
+// scenePlusVO = (ScenePlusVO) objects[0];
|
|
|
+ } else {
|
|
|
+ String cameraName = jsonObject.getJSONObject("cam").getString("uuid");
|
|
|
+ String userName = null;
|
|
|
+ if (!ObjectUtils.isEmpty(sceneUserId)) {
|
|
|
+ SSOUser user = userService.getSSOUserByUserId(sceneUserId);
|
|
|
+ userName = user.getUserName();
|
|
|
+ }
|
|
|
+ //重算的场景,先移除该场景对应的容量
|
|
|
+ scenePlusService.resetSpace(num);
|
|
|
+
|
|
|
+ JSONObject statusJson = new JSONObject();
|
|
|
+ //临时将-2改成1,app还没完全更新
|
|
|
+ statusJson.put("status", sceneStatus == -2 ? 1 : sceneStatus);
|
|
|
+ statusJson.put("webSite", webSite);
|
|
|
+ statusJson.put("sceneNum", num);
|
|
|
+ statusJson.put("thumb", thumb);
|
|
|
+ statusJson.put("payStatus", payStatus);
|
|
|
+ String statusJsonLocalPath = ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json";
|
|
|
+ String statusJsonOssPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "status.json";
|
|
|
+ FileUtils.writeFile(statusJsonLocalPath, statusJson.toString());
|
|
|
+ fYunFileService.uploadFile(bucket, statusJsonLocalPath, statusJsonOssPath);
|
|
|
+ String unicode = jsonObject.getString("creator") + "_" + jsonObject.getString("uuidtime");
|
|
|
+
|
|
|
+ Long cameraType = (long)sceneScheme == 3 ? 12 : (long)sceneScheme;
|
|
|
+ //判断是否转台相机
|
|
|
+ if(sceneSource == 3){
|
|
|
+ cameraType = 13L;
|
|
|
+ }
|
|
|
+ if(sceneSource == 4){
|
|
|
+ cameraType = 14L;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(sceneSource == 4){
|
|
|
+ fdkkLaserService.updateSceneStatus(num,0);
|
|
|
+ BuildSceneCallMessage buildSceneMqMessage =this.getBuildSceneMqMessage(
|
|
|
+ num, cameraName, unicode, cameraType, fileId,
|
|
|
+ dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
|
|
|
+ .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH,"")+ File.separator,
|
|
|
+ "zip.Zip", "0",
|
|
|
+ userName, jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location")) ? "sfm" : "slam",
|
|
|
+ jsonObject.getInteger("resolution"), buildType,
|
|
|
+ ConstantFilePath.BUILD_MODEL_LASER_PATH + unicode, sceneId, sceneName,
|
|
|
+ webSite, createTime, sceneUserId, dataSource, sceneStatus, payStatus, thumb);
|
|
|
+ rabbitMqProducer.sendByWorkQueue(queueModelingPre, buildSceneMqMessage);
|
|
|
+ }else{
|
|
|
+ BuildSceneCallMessage buildSceneMqMessage =this.getBuildSceneMqMessage(
|
|
|
+ num, cameraName, unicode, cameraType, fileId,
|
|
|
+ dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
|
|
|
+ .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH,"")+ File.separator,
|
|
|
+ "zip.Zip", "0",
|
|
|
+ userName, jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location")) ? "sfm" : "slam",
|
|
|
+ jsonObject.getInteger("resolution"), buildType,
|
|
|
+ ConstantFilePath.BUILD_MODEL_PATH + unicode, sceneId, sceneName,
|
|
|
+ webSite, createTime, sceneUserId, dataSource, sceneStatus, payStatus, thumb);
|
|
|
+
|
|
|
+ rabbitMqProducer.sendByWorkQueue(queueModelingPre, buildSceneMqMessage);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
|
|
|
+ .set(ScenePlus::getSceneStatus, SceneStatus.wait.code())
|
|
|
+ .eq(ScenePlus::getNum, num));
|
|
|
+
|
|
|
+ }
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
}
|