|
@@ -99,6 +99,7 @@ import java.io.IOException;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Objects;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
@@ -1220,10 +1221,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
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 + "文件不存在");
|
|
|
+ if (!new File(target + File.separator + "results" + File.separator + fileName).exists()) {
|
|
|
+ throw new Exception(target + File.separator + "results" + File.separator + fileName + "文件不存在");
|
|
|
}
|
|
|
|
|
|
//high文件夹
|
|
@@ -2810,4 +2809,171 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
list.stream().map(str -> JSON.parseObject(str)).collect(Collectors.toList());
|
|
|
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_V18");
|
|
|
+ //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);
|
|
|
+ }
|
|
|
}
|