|
@@ -1,27 +1,22 @@
|
|
package com.fdkankan.contro.service.impl;
|
|
package com.fdkankan.contro.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.fdkankan.common.constant.ErrorCode;
|
|
|
|
-import com.fdkankan.common.constant.HttpCode;
|
|
|
|
-import com.fdkankan.common.exception.BusinessException;
|
|
|
|
|
|
+import com.fdkankan.common.util.DateUtil;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.contro.entity.Camera;
|
|
import com.fdkankan.contro.entity.Camera;
|
|
import com.fdkankan.contro.entity.ScenePlus;
|
|
import com.fdkankan.contro.entity.ScenePlus;
|
|
import com.fdkankan.contro.entity.ScenePlusExt;
|
|
import com.fdkankan.contro.entity.ScenePlusExt;
|
|
-import com.fdkankan.contro.entity.User;
|
|
|
|
-import com.fdkankan.contro.service.ICameraService;
|
|
|
|
import com.fdkankan.contro.service.IFdkkLaserService;
|
|
import com.fdkankan.contro.service.IFdkkLaserService;
|
|
-import com.fdkankan.contro.service.IUserService;
|
|
|
|
|
|
+import com.fdkankan.contro.service.IScenePlusService;
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
import com.fdkankan.web.response.Result;
|
|
import com.fdkankan.web.response.Result;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
@@ -32,49 +27,42 @@ import java.util.Map;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class IFdkkLaserServiceImpl implements IFdkkLaserService {
|
|
public class IFdkkLaserServiceImpl implements IFdkkLaserService {
|
|
|
|
|
|
- private final String UPDATE_SCENE_STATUS_URL_TEMPLATE="/indoor/%s/scene/useStatus/%s";
|
|
|
|
- private final String UPGRADE_TO_V4="/api/user/scene?num=%s";
|
|
|
|
- private final String EDIT_LASER_BUILD_STATUS_URL="/laser/4dage/scene/editBuildStatus";
|
|
|
|
- private final String DISABLE_COOPERATION_SCENE_URL="/laser/4dage/scene/cooperation/disable";
|
|
|
|
- private final String ENABLE_COOPERATION_CAMERA_URL="/laser/4dage/scene/cooperation/cameraSave";
|
|
|
|
- private final String GET_LASER_SCENE_USER_URL="/laser/4dage/getSceneNum";
|
|
|
|
- private final String GET_LASER_SCENE_CODE_URL="/laser/4dage/scene/getScenesBySnCode";
|
|
|
|
- private final String GET_LASER_SCENE_CNT_URL="/laser/4dage/scene/getSceneNumByCamera";
|
|
|
|
|
|
+ private final String SAVE_SCENE_URL_TEMPLATE = "/laser/init/%s/saveOrEdit";
|
|
|
|
+ private final String EDIT_LASER_BUILD_STATUS_URL = "/laser/4dage/scene/editBuildStatus";
|
|
|
|
+ private final String ENABLE_COOPERATION_CAMERA_URL = "/laser/4dage/scene/cooperation/cameraSave";
|
|
|
|
|
|
@Value("${4dkk.laserService.host}")
|
|
@Value("${4dkk.laserService.host}")
|
|
private String laserHost;
|
|
private String laserHost;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private ICameraService cameraService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private IUserService userService;
|
|
|
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
|
|
|
private RestTemplate restTemplate = new RestTemplate();
|
|
private RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
|
- public void updateSceneStatus(String sceneCode,int status){
|
|
|
|
- String url = laserHost + String.format(UPDATE_SCENE_STATUS_URL_TEMPLATE,sceneCode,status);
|
|
|
|
- ResponseEntity<Result> response = restTemplate.getForEntity(url, Result.class);
|
|
|
|
- if(response.getStatusCode() != HttpStatus.OK){
|
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7001);
|
|
|
|
|
|
+ public void updateSceneStatus(String sceneCode, int sceneStatus, String path) {
|
|
|
|
+ String url = laserHost + String.format(SAVE_SCENE_URL_TEMPLATE, sceneCode);
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ params.put("sceneCode", sceneCode);
|
|
|
|
+ params.put("status", sceneStatus);
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneCode);
|
|
|
|
+ params.put("createTime", DateUtil.date2String(scenePlus.getCreateTime(), null));
|
|
|
|
+ if (!ObjectUtils.isEmpty(path)) {
|
|
|
|
+ params.put("path", path);
|
|
}
|
|
}
|
|
- if(response.getBody().getCode() != HttpCode.SC_SUCCESS){
|
|
|
|
- throw new BusinessException(response.getBody().getCode(), response.getBody().getMsg());
|
|
|
|
|
|
+ log.info("自研激光转台相机同步,url:{},params:{}", url, JSONObject.toJSONString(params));
|
|
|
|
+ ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
|
|
|
|
+ log.info("自研激光转台相机同步,url:{},params:{},结果:{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
|
|
|
|
+ if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()) {
|
|
|
|
+ log.error("激光场景状态同步失败!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void syncBuildResult(ScenePlus scenePlus, ScenePlusExt scenePlusExt) {
|
|
public void syncBuildResult(ScenePlus scenePlus, ScenePlusExt scenePlusExt) {
|
|
log.info("激光转台相机构建结果 同步 请求 ");
|
|
log.info("激光转台相机构建结果 同步 请求 ");
|
|
try {
|
|
try {
|
|
- String title = "";
|
|
|
|
- String sceneName = scenePlus.getTitle();
|
|
|
|
- if (StringUtils.isNotEmpty(sceneName)) {
|
|
|
|
- title = sceneName;
|
|
|
|
- }
|
|
|
|
- String dataSource = scenePlusExt.getDataSource();
|
|
|
|
- String jgPath = dataSource;
|
|
|
|
|
|
+ String jgPath = scenePlusExt.getDataSource();
|
|
//创建目录
|
|
//创建目录
|
|
- if (dataSource.lastIndexOf("/") != -1) {
|
|
|
|
|
|
+ if (scenePlusExt.getDataSource().lastIndexOf("/") != -1) {
|
|
jgPath = jgPath + "_laserData";
|
|
jgPath = jgPath + "_laserData";
|
|
} else {
|
|
} else {
|
|
jgPath = jgPath.substring(0, jgPath.length() - 1) + "_laserData";
|
|
jgPath = jgPath.substring(0, jgPath.length() - 1) + "_laserData";
|
|
@@ -90,31 +78,14 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
|
|
jgDataJson.put("extras", null);
|
|
jgDataJson.put("extras", null);
|
|
FileUtils.writeFile(jgPath + File.separator + "data.json", jgDataJson.toString());
|
|
FileUtils.writeFile(jgPath + File.separator + "data.json", jgDataJson.toString());
|
|
|
|
|
|
- CreateObjUtil.cpfile(dataSource + "/results/laserData/cover", jgPath + "/extras/");
|
|
|
|
- CreateObjUtil.cplaserfile(dataSource + "/results/laserData", jgPath + File.separator);
|
|
|
|
-
|
|
|
|
- Camera camera = cameraService.getById(scenePlus.getCameraId());
|
|
|
|
- String cameraName = camera.getChildName();
|
|
|
|
- //激光相机
|
|
|
|
- String url = laserHost + "/indoor/{sceneCode}/service/init?path="
|
|
|
|
- + jgPath + File.separator + "laserData" + "&title=" + title
|
|
|
|
- + "&childName=" + cameraName + "&createTime=" + scenePlus.getCreateTime()
|
|
|
|
- + "&snCode=" + cameraName;
|
|
|
|
-
|
|
|
|
- if (scenePlus.getUserId() != null) {
|
|
|
|
- url = url + "&userId=" + scenePlus.getUserId();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- User user = userService.getById(scenePlus.getUserId());
|
|
|
|
|
|
+ // result/mesh/mesh.obj --> jgPath/laserData/laser.obj
|
|
|
|
+ log.info("开始拷贝obj文件");
|
|
|
|
+ FileUtils.copyFolderAllFiles(scenePlusExt.getDataSource() + "/results/mesh", jgPath + "/laserData/mesh/", true);
|
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(user)) {
|
|
|
|
- url = url + "&phone=" + user.getUserName();
|
|
|
|
- }
|
|
|
|
|
|
+ CreateObjUtil.cpfile(scenePlusExt.getDataSource() + "/results/laserData/cover", jgPath + "/extras/");
|
|
|
|
+ CreateObjUtil.cplaserfile(scenePlusExt.getDataSource() + "/results/laserData", jgPath + File.separator);
|
|
|
|
|
|
- url = url.replace("{sceneCode}", scenePlus.getNum());
|
|
|
|
- log.info("激光转台相机 同步 :" + url);
|
|
|
|
- JSONObject hotListJson = JSONObject.parseObject(restTemplate.getForObject(url, String.class));
|
|
|
|
- log.info("激光转台相机 同步结束 :" + hotListJson);
|
|
|
|
|
|
+ updateSceneStatus(scenePlus.getNum(), 2, jgPath + File.separator + "laserData");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("激光转台相机同步失败", e);
|
|
log.error("激光转台相机同步失败", e);
|
|
}
|
|
}
|
|
@@ -123,15 +94,39 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
|
|
@Override
|
|
@Override
|
|
public void pushBuildStatusToLaserSystem(String projectNum, String laserObjFilePath) {
|
|
public void pushBuildStatusToLaserSystem(String projectNum, String laserObjFilePath) {
|
|
String url = laserHost + EDIT_LASER_BUILD_STATUS_URL;
|
|
String url = laserHost + EDIT_LASER_BUILD_STATUS_URL;
|
|
- Map<String,String> params = new HashMap<>();
|
|
|
|
- params.put("sceneCode",projectNum);
|
|
|
|
- params.put("objPath",laserObjFilePath);
|
|
|
|
- log.info("激光系统同步BuildStatus,url:{},params:{}",ENABLE_COOPERATION_CAMERA_URL, JSONObject.toJSONString(params));
|
|
|
|
- ResponseEntity<com.fdkankan.contro.common.Result> responseEntity = restTemplate.postForEntity(url,params, com.fdkankan.contro.common.Result.class);
|
|
|
|
- log.info("激光系统同步BuildStatus,url:{},params:{},结果:{}",url, JSONObject.toJSONString(params),JSONObject.toJSONString(responseEntity.getBody()));
|
|
|
|
- if(responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()){
|
|
|
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
|
+ params.put("sceneCode", projectNum);
|
|
|
|
+ params.put("objPath", laserObjFilePath);
|
|
|
|
+ log.info("激光系统同步BuildStatus,url:{},params:{}", ENABLE_COOPERATION_CAMERA_URL, JSONObject.toJSONString(params));
|
|
|
|
+ ResponseEntity<com.fdkankan.contro.common.Result> responseEntity = restTemplate.postForEntity(url, params, com.fdkankan.contro.common.Result.class);
|
|
|
|
+ log.info("激光系统同步BuildStatus,url:{},params:{},结果:{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
|
|
|
|
+ if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()) {
|
|
log.error("激光系统同步BuildStatus");
|
|
log.error("激光系统同步BuildStatus");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void saveScene(ScenePlus sceneProEntity, String scenePassword, Camera cameraEntity, String phone, boolean rebuild) {
|
|
|
|
+ String url = laserHost + String.format(SAVE_SCENE_URL_TEMPLATE, sceneProEntity.getNum());
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ params.put("childName", cameraEntity.getChildName());
|
|
|
|
+ params.put("createTime", DateUtil.date2String(sceneProEntity.getCreateTime(), null));
|
|
|
|
+ params.put("phone", phone);
|
|
|
|
+ params.put("sceneCode", sceneProEntity.getNum());
|
|
|
|
+ params.put("snCode", cameraEntity.getSnCode());
|
|
|
|
+ params.put("status", sceneProEntity.getSceneStatus());
|
|
|
|
+ if (!rebuild) {
|
|
|
|
+ params.put("password", scenePassword);
|
|
|
|
+ } else {
|
|
|
|
+ params.put("status", 4);
|
|
|
|
+ }
|
|
|
|
+ params.put("title", sceneProEntity.getTitle());
|
|
|
|
+ params.put("userId", sceneProEntity.getUserId());
|
|
|
|
+ log.info("自研激光转台相机同步,url:{},params:{}", url, JSONObject.toJSONString(params));
|
|
|
|
+ ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
|
|
|
|
+ log.info("自研激光转台相机同步,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
|
|
|
|
+ if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()) {
|
|
|
|
+ log.error("激光场景状态同步失败!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|