|
@@ -29,6 +29,7 @@ import com.fdkankan.scene.mapper.ISceneFileBuildMapper;
|
|
|
import com.fdkankan.scene.service.*;
|
|
|
import com.fdkankan.scene.vo.BuildSceneParamVO;
|
|
|
import com.fdkankan.scene.vo.ResponseSceneFile;
|
|
|
+import com.fdkankan.scene.vo.SceneParamVO;
|
|
|
import com.fdkankan.scene.vo.SceneVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
@@ -42,6 +43,8 @@ import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.xml.transform.Result;
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.File;
|
|
@@ -129,6 +132,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
ISceneService sceneService;
|
|
|
@Autowired
|
|
|
ISceneExtService sceneExtService;
|
|
|
+ @Autowired
|
|
|
+ IFdkkLaserService fdkkLaserService;
|
|
|
|
|
|
@Override
|
|
|
public SceneFileBuild findByFileId(String fileId) {
|
|
@@ -1974,6 +1979,155 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
return filePathName;
|
|
|
}
|
|
|
|
|
|
+ public ResultData rebuildScene(String sceneCode) throws Exception {
|
|
|
+ if (StringUtils.isEmpty(sceneCode)) {
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
+ }
|
|
|
+
|
|
|
+ ScenePro scenePro = sceneProService.findBySceneNum(sceneCode);
|
|
|
+ SceneProExt sceneProExt = null;
|
|
|
+ ScenePO scenePO = null;
|
|
|
+ String path = "";
|
|
|
+ if(scenePro == null){
|
|
|
+ scenePO = sceneService.findBySceneNum(sceneCode);
|
|
|
+ if(scenePO == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ }else {
|
|
|
+ path = ConstantFilePath.BUILD_MODEL_PATH + scenePO.getDataSource().split("/")[scenePO.getDataSource().split("/").length - 2];
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ sceneProExt = sceneProExtService.findBySceneProId(scenePro.getId());
|
|
|
+ path = sceneProExt.getDataSource();
|
|
|
+
|
|
|
+ }
|
|
|
+ //重新计算时需要删除文件夹,否知使用缓存
|
|
|
+ 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 ("s3".equals(type)) {
|
|
|
+ CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, ""),
|
|
|
+ path + "/capture/");
|
|
|
+ } else {
|
|
|
+ if(scenePro!=null && sceneProExt.getSceneSource().equals(4)){
|
|
|
+ CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage", path + "/capture/");
|
|
|
+ }else{
|
|
|
+ CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", path + "/capture/");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ //有points字段的是八目
|
|
|
+ if (!jsonObject.containsKey("points")) {
|
|
|
+ String cameraName = jsonObject.getString("camid");
|
|
|
+ ResultData<Camera> cameraResult = platformGoodsClient.getCameraByChildName(cameraName);
|
|
|
+ Camera camera = cameraResult.getData();
|
|
|
+ if (camera == null) {
|
|
|
+ log.error("该相机不存在:" + cameraName);
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
|
+ }
|
|
|
+
|
|
|
+ ResultData<CameraDetail> detailResult = platformGoodsClient.getCameraDetailByCameraId(camera.getId());
|
|
|
+ CameraDetail detail = detailResult.getData();
|
|
|
+ if (detail == null) {
|
|
|
+ log.error("该相机详情不存在:" + cameraName);
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_6003);
|
|
|
+ }
|
|
|
+
|
|
|
+ Long userId = null;
|
|
|
+ String userName = null;
|
|
|
+
|
|
|
+ if (detail.getUserId() != null) {
|
|
|
+ ResultData<SSOUser> ssoUserResult = platformUserClient.getSSOUserByUserId(detail.getUserId());
|
|
|
+ SSOUser user = ssoUserResult.getData();
|
|
|
+ if (user == null) {
|
|
|
+ log.error("用户id不存在:" + detail.getUserId());
|
|
|
+ } else {
|
|
|
+ userId = user.getId();
|
|
|
+ userName = user.getUserName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String unicode = jsonObject.getString("creator") + "_" + jsonObject.getString("uuidtime");
|
|
|
+ scenePO = this.createScene(sceneCode, camera.getId(),
|
|
|
+ cameraName, jsonObject.getString("creator"),
|
|
|
+ jsonObject.getString("pwd"), unicode, detail.getGoodsId(),
|
|
|
+ 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, mainUrl + sceneUrl, ecsType);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ String cameraName = jsonObject.getJSONObject("cam").getString("uuid");
|
|
|
+ String userName = null;
|
|
|
+ if (!ObjectUtils.isEmpty(scenePro.getUserId())) {
|
|
|
+ ResultData<SSOUser> ssoUserResult = platformUserClient.getSSOUserByUserId(scenePro.getUserId());
|
|
|
+ SSOUser user = ssoUserResult.getData();
|
|
|
+ userName = user.getUserName();
|
|
|
+ }
|
|
|
+ String buildType = scenePro.getBuildType();
|
|
|
+ //重算的场景,先移除该场景对应的容量
|
|
|
+ sceneProService.rebuildReduceSpaceBySceneNum(sceneCode);
|
|
|
+
|
|
|
+ JSONObject statusJson = new JSONObject();
|
|
|
+ //临时将-2改成1,app还没完全更新
|
|
|
+ statusJson.put("status", scenePro.getSceneStatus() == -2 ? 1 : scenePro.getSceneStatus());
|
|
|
+ statusJson.put("webSite", scenePro.getWebSite());
|
|
|
+ statusJson.put("sceneNum", scenePro.getSceneCode());
|
|
|
+ statusJson.put("thumb", scenePro.getThumb());
|
|
|
+ statusJson.put("payStatus", scenePro.getPayStatus());
|
|
|
+ FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data/data" + sceneCode + File.separator + "status.json", statusJson.toString());
|
|
|
+ uploadToOssUtil.upload(ConstantFilePath.SCENE_PATH + "data/data" + sceneCode + File.separator + "status.json",
|
|
|
+ "data/data" + sceneCode + File.separator + "status.json");
|
|
|
+ String unicode = jsonObject.getString("creator") + "_" + jsonObject.getString("uuidtime");
|
|
|
+
|
|
|
+ Long cameraType = (long)scenePro.getSceneScheme() == 3? 12 : (long)scenePro.getSceneScheme();
|
|
|
+ //判断是否转台相机
|
|
|
+ if(scenePro != null && sceneProExt.getSceneSource() == 3){
|
|
|
+ cameraType = 13L;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(scenePro != null && sceneProExt.getSceneSource() == 4){
|
|
|
+ cameraType = 14L;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(sceneProExt.getSceneSource().intValue() == 4){
|
|
|
+ fdkkLaserService.updateSceneStatus(sceneCode,0);
|
|
|
+ String mqMsg = ComputerUtil.getMQMsg(sceneCode,cameraName,unicode,cameraType,fileId,
|
|
|
+ sceneProExt.getDataSource().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);
|
|
|
+ mqProducer.syncSend(topicLaserA, mqMsg.concat(":;1"));
|
|
|
+ }else{
|
|
|
+ String mqMsg = ComputerUtil.getMQMsg(sceneCode,cameraName,unicode,cameraType,fileId,
|
|
|
+ sceneProExt.getDataSource().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);
|
|
|
+ mqProducer.syncSend(topicModelingA, mqMsg.concat(":;1"));
|
|
|
+ }
|
|
|
+ sceneProService.updateStatus(sceneCode,0);
|
|
|
+ // 更新imageVersion
|
|
|
+ sceneProEditService.updateImageVersionByProId(scenePro.getId());
|
|
|
+ }
|
|
|
+ log.error("生成新的场景重新计算");
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
// ScenePro scenePro = new ScenePro();
|
|
|
// scenePro.setCameraId(1l);
|