|
@@ -41,6 +41,7 @@ import com.fdkankan.scene.bean.RequestSceneProV4;
|
|
import com.fdkankan.scene.bean.SceneJsonBean;
|
|
import com.fdkankan.scene.bean.SceneJsonBean;
|
|
import com.fdkankan.scene.bean.SegmentBean;
|
|
import com.fdkankan.scene.bean.SegmentBean;
|
|
import com.fdkankan.scene.bean.StyleBean;
|
|
import com.fdkankan.scene.bean.StyleBean;
|
|
|
|
+import com.fdkankan.scene.bean.SurveillanceBean;
|
|
import com.fdkankan.scene.bean.TagBean;
|
|
import com.fdkankan.scene.bean.TagBean;
|
|
import com.fdkankan.scene.bean.VertexBean;
|
|
import com.fdkankan.scene.bean.VertexBean;
|
|
import com.fdkankan.scene.bean.WallBean;
|
|
import com.fdkankan.scene.bean.WallBean;
|
|
@@ -54,6 +55,7 @@ import com.fdkankan.scene.entity.ScenePlus;
|
|
import com.fdkankan.scene.entity.ScenePlusExt;
|
|
import com.fdkankan.scene.entity.ScenePlusExt;
|
|
import com.fdkankan.scene.entity.ScenePro;
|
|
import com.fdkankan.scene.entity.ScenePro;
|
|
import com.fdkankan.scene.entity.SceneProV3;
|
|
import com.fdkankan.scene.entity.SceneProV3;
|
|
|
|
+import com.fdkankan.scene.entity.Surveillance;
|
|
import com.fdkankan.scene.factory.FloorLogoHandlerFactory;
|
|
import com.fdkankan.scene.factory.FloorLogoHandlerFactory;
|
|
import com.fdkankan.scene.factory.MusicHandlerFactory;
|
|
import com.fdkankan.scene.factory.MusicHandlerFactory;
|
|
import com.fdkankan.scene.factory.ScreenshotHandlerFactory;
|
|
import com.fdkankan.scene.factory.ScreenshotHandlerFactory;
|
|
@@ -68,6 +70,7 @@ import com.fdkankan.scene.service.IScenePlusService;
|
|
import com.fdkankan.scene.service.ISceneProExtService;
|
|
import com.fdkankan.scene.service.ISceneProExtService;
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
import com.fdkankan.scene.service.ISceneUploadService;
|
|
import com.fdkankan.scene.service.ISceneUploadService;
|
|
|
|
+import com.fdkankan.scene.service.ISurveillanceService;
|
|
import com.fdkankan.scene.vo.*;
|
|
import com.fdkankan.scene.vo.*;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.errorprone.annotations.Var;
|
|
import com.google.errorprone.annotations.Var;
|
|
@@ -166,6 +169,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
private FdkankanMiniClient fdkankanMiniClient;
|
|
private FdkankanMiniClient fdkankanMiniClient;
|
|
@Autowired
|
|
@Autowired
|
|
private ISceneUploadService sceneUploadService;
|
|
private ISceneUploadService sceneUploadService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISurveillanceService surveillanceService;
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
@@ -292,6 +297,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
//发布滤镜数据
|
|
//发布滤镜数据
|
|
this.publicFilterData(num, sceneEditInfoExt.getFilters());
|
|
this.publicFilterData(num, sceneEditInfoExt.getFilters());
|
|
|
|
|
|
|
|
+ //发布摄像头数据
|
|
|
|
+ this.publicSurveillance(num, sceneEditInfoExt.getSurveillances());
|
|
|
|
+
|
|
//本地写sceneJson文件
|
|
//本地写sceneJson文件
|
|
String localSceneJsonPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "scene.json";
|
|
String localSceneJsonPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "scene.json";
|
|
FileUtils.writeFile(localSceneJsonPath, JSON.toJSONString(sceneJson));
|
|
FileUtils.writeFile(localSceneJsonPath, JSON.toJSONString(sceneJson));
|
|
@@ -340,6 +348,17 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void publicSurveillance(String num, Integer surveillances) throws IOException {
|
|
|
|
+ String surveillanceJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "surveillance.json";
|
|
|
|
+ if(surveillances == CommonStatus.NO.code().intValue()){
|
|
|
|
+ uploadToOssUtil.delete(surveillanceJsonPath);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List<Surveillance> surveillanceList = surveillanceService.listSurveillance(num);
|
|
|
|
+ List<SurveillanceBean> surveillanceBeanList = BeanUtil.copyToList(surveillanceList, SurveillanceBean.class);
|
|
|
|
+ uploadToOssUtil.upload(JSON.toJSONString(surveillanceBeanList).getBytes(StandardCharsets.UTF_8), surveillanceJsonPath);
|
|
|
|
+ }
|
|
|
|
+
|
|
public void publicLinkSceneData(String num) throws IOException {
|
|
public void publicLinkSceneData(String num) throws IOException {
|
|
|
|
|
|
String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
@@ -2810,170 +2829,4 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
return ResultData.ok(collect);
|
|
return ResultData.ok(collect);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public ResultData uploadROIImage(String num, String filter) throws Exception {
|
|
|
|
-
|
|
|
|
- JSONObject filterObj = JSON.parseObject(filter);
|
|
|
|
-
|
|
|
|
- ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
|
- if(Objects.isNull(scenePlus)){
|
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
- }
|
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
|
- if(Objects.isNull(scenePlusExt)){
|
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
- }
|
|
|
|
- SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByScenePlusId(scenePlus.getId());
|
|
|
|
-
|
|
|
|
- String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
|
-
|
|
|
|
- String path = scenePlusExt.getDataSource();
|
|
|
|
-
|
|
|
|
- if(!ObjectUtils.isEmpty(path) && path.startsWith("http")){
|
|
|
|
- path = ConstantFilePath.BUILD_MODEL_PATH + File.separator + path.split("/")[path.split("/").length - 2];
|
|
|
|
- }
|
|
|
|
- String target = path + "_roi";
|
|
|
|
-
|
|
|
|
- FileUtils.deleteDirectory(target);
|
|
|
|
-
|
|
|
|
- //文件上传的位置可以自定义
|
|
|
|
- String filePath = target + "/extras" + "/images/";
|
|
|
|
- File imageFile = new File(filePath);
|
|
|
|
- if(!imageFile.getParentFile().exists()){
|
|
|
|
- imageFile.getParentFile().mkdirs();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- FileUtils.copyFolderAllFiles(path + "/caches/images/", filePath, true);
|
|
|
|
-
|
|
|
|
- String roiFilter = sceneEditInfoExt.getRoiFilter();
|
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
|
- if(StrUtil.isNotEmpty(roiFilter)){
|
|
|
|
- jsonArray = JSONArray.parseArray(roiFilter);
|
|
|
|
- }
|
|
|
|
- jsonArray.add(filterObj);
|
|
|
|
-
|
|
|
|
- // 准备算法数据
|
|
|
|
- Map<String, JSONObject> panoIdMap = new HashMap<>();
|
|
|
|
- jsonArray.stream().forEach(item -> {
|
|
|
|
- JSONObject obj = (JSONObject)item;
|
|
|
|
- String panoId = obj.getString("panoId");
|
|
|
|
- if(panoIdMap.containsKey(panoId)){
|
|
|
|
- panoIdMap.get(panoId).getJSONArray("rect").addAll(obj.getJSONArray("rect"));
|
|
|
|
- }else{
|
|
|
|
- panoIdMap.put(panoId, obj);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- JSONObject roiImageJSon = new JSONObject();
|
|
|
|
- roiImageJSon.put("batch",panoIdMap.values());
|
|
|
|
-
|
|
|
|
- FileUtils.writeFile(target + "/extras" + "/image-ROI.json", JSON.toJSONString(roiImageJSon,SerializerFeature.DisableCircularReferenceDetect));
|
|
|
|
-
|
|
|
|
- FileUtils.copyFile(path + "/results/vision.txt", target + "/extras/vision.txt", true);
|
|
|
|
- FileUtils.copyFile(path + "/results/vision2.txt", target + "/extras/vision2.txt", true);
|
|
|
|
-
|
|
|
|
- FileUtils.copyFile(path + "/data.json", target + "/data.json", true);
|
|
|
|
-
|
|
|
|
- String data = FileUtils.readFile(target + File.separator+"data.json");
|
|
|
|
- if(data != null){
|
|
|
|
- JSONObject floorplanJson = new JSONObject();
|
|
|
|
- floorplanJson.put("has_source_images", true);
|
|
|
|
- floorplanJson.put("has_vision_txt", true);
|
|
|
|
-
|
|
|
|
- JSONObject dataJson = JSONObject.parseObject(data);
|
|
|
|
- dataJson.put("extras", floorplanJson);
|
|
|
|
- dataJson.put("split_type", "SPLIT_V24");
|
|
|
|
- //V5表示不需要生成high,low文件
|
|
|
|
- String skyboxType = "SKYBOX_V6";
|
|
|
|
- if(scenePlusExt.getSceneScheme() == 11){
|
|
|
|
- skyboxType = "SKYBOX_V7";
|
|
|
|
- }
|
|
|
|
- //sceneScheme为3切成瓦片图
|
|
|
|
- if(scenePlusExt.getSceneScheme() == 3){
|
|
|
|
- if("4k".equals(scenePlusExt.getSceneResolution())){
|
|
|
|
- skyboxType = "SKYBOX_V14";
|
|
|
|
- }else{
|
|
|
|
- skyboxType = "SKYBOX_V13";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- dataJson.put("skybox_type", skyboxType);
|
|
|
|
- FileUtils.writeFile(target + File.separator+"data.json", new String(dataJson.toString().getBytes(), "UTF-8"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- FileUtils.copyFile(path + File.separator + "project.json", target + File.separator+"project.json", true);
|
|
|
|
-
|
|
|
|
- //进行计算
|
|
|
|
- log.info("风格滤镜:开始建模——" + num);
|
|
|
|
- CreateObjUtil.build3dModel2(target , "1");
|
|
|
|
-
|
|
|
|
- //读取upload文件,检验需要上传的文件是否存在
|
|
|
|
- String uploadJsonPath = target + "/results/" + "upload.json";
|
|
|
|
- Thread.sleep(2000);
|
|
|
|
- boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, maxCheckTimes, waitTime);
|
|
|
|
- if(!exist){
|
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
|
- }
|
|
|
|
- String uploadData = FileUtils.readFile(uploadJsonPath);
|
|
|
|
- JSONObject uploadJson = null;
|
|
|
|
- JSONArray array = null;
|
|
|
|
- if(uploadData!=null) {
|
|
|
|
- uploadJson = JSONObject.parseObject(uploadData);
|
|
|
|
- array = uploadJson.getJSONArray("upload");
|
|
|
|
- }
|
|
|
|
- if(array == null){
|
|
|
|
- throw new Exception("upload.json数据出错");
|
|
|
|
- }
|
|
|
|
- Map<String,String> map = new HashMap<String,String>();
|
|
|
|
- JSONObject fileJson = null;
|
|
|
|
- String fileName = "";
|
|
|
|
- for(int i = 0, len = array.size(); i < len; i++){
|
|
|
|
- fileJson = array.getJSONObject(i);
|
|
|
|
- fileName = fileJson.getString("file");
|
|
|
|
- //文件不存在抛出异常
|
|
|
|
- if(!new File(target + File.separator + "results" +File.separator + fileName).exists()){
|
|
|
|
- throw new Exception(target + File.separator + "results" +File.separator + fileName+"文件不存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //high文件夹
|
|
|
|
- if(fileJson.getIntValue("clazz") == 3){
|
|
|
|
- map.put(target + File.separator + "results" +File.separator+ fileName,
|
|
|
|
- imgViewPath+"pan/high/"+ fileName.replace("high/", ""));
|
|
|
|
- }
|
|
|
|
- //low文件夹
|
|
|
|
- if(fileJson.getIntValue("clazz") == 4){
|
|
|
|
- map.put(target + File.separator + "results" +File.separator+ fileName,
|
|
|
|
- imgViewPath+"pan/low/"+ fileName.replace("low/", ""));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
|
|
|
|
- if(fileJson.getIntValue("clazz") == 5){
|
|
|
|
- map.put(target + File.separator + "results" + File.separator+ fileName, imgViewPath + fileName);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //tiles文件夹,亚马逊瓦片图
|
|
|
|
- if(fileJson.getIntValue("clazz") == 7 ){
|
|
|
|
- map.put(target + File.separator + "results" + File.separator+ fileName, imgViewPath + fileName);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for(String imagesName : imageFile.list()){
|
|
|
|
- //覆盖原始图片资源
|
|
|
|
- FileUtils.copyFile(target + File.separator + "extras/images/" + imagesName,
|
|
|
|
- path + File.separator + "caches/images/" + imagesName, true);
|
|
|
|
- FileUtils.deleteFile(target + File.separator + "extras/images/" + imagesName);
|
|
|
|
- }
|
|
|
|
- if(map.size()>0)
|
|
|
|
- uploadToOssUtil.uploadMulFiles(map);
|
|
|
|
-
|
|
|
|
- //更新数据库版本号
|
|
|
|
- SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
|
|
- this.upgradeVersionAndImgVersionById(sceneEditInfo.getId());
|
|
|
|
-
|
|
|
|
- sceneEditInfoExt.setRoiFilter(JSON.toJSONString(jsonArray,SerializerFeature.DisableCircularReferenceDetect));
|
|
|
|
- sceneEditInfoExtService.updateById(sceneEditInfoExt);
|
|
|
|
-
|
|
|
|
- Map<String,Object> result = new HashMap<>(1);
|
|
|
|
- result.put("roiFilter",jsonArray);
|
|
|
|
-
|
|
|
|
- return ResultData.ok(result);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|