|
@@ -0,0 +1,96 @@
|
|
|
+package com.fdkankan.contro.mq.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.contro.mq.service.ICommonService;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.fdkankan.model.utils.FloorPlanUserUtil;
|
|
|
+import com.fdkankan.model.utils.SceneUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class CommonServiceImpl implements ICommonService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void uploadBuildResultData(String num, String dataSource, String version) {
|
|
|
+
|
|
|
+ Map<String, String> uploadMap = new HashMap<>();
|
|
|
+
|
|
|
+ String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
|
|
|
+
|
|
|
+ //上传caches/images
|
|
|
+ String localCachesImagePath = dataSource + "/caches/images/";
|
|
|
+ String ossCachesImagePath = ossResultPath + "caches/images/";
|
|
|
+ //先清除旧的全景图
|
|
|
+ fYunFileServiceInterface.deleteFolder(ossCachesImagePath);
|
|
|
+ if(FileUtil.exist(localCachesImagePath)){
|
|
|
+ List<String> imagesList = FileUtil.listFileNames(localCachesImagePath);
|
|
|
+ if(CollUtil.isNotEmpty(imagesList)){
|
|
|
+ String ossVisionPath = String.format(UploadFilePath.IMG_VIEW_PATH, num) + "vision.txt";
|
|
|
+ String visionPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "vision.txt";
|
|
|
+ fYunFileServiceInterface.downloadFile(ossVisionPath, visionPath);
|
|
|
+ List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
|
|
|
+ imagesList.stream().forEach(fileName -> {
|
|
|
+ if (panoramaImageList.contains(fileName)) {
|
|
|
+ String srcPath = localCachesImagePath + fileName;
|
|
|
+ String ossPath = ossCachesImagePath + fileName;
|
|
|
+ uploadMap.put(srcPath, ossPath);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传project.json
|
|
|
+ String localProjectJsonPath = dataSource + "/project.json";
|
|
|
+ String ossProjectJsonPath = ossResultPath + "project.json";
|
|
|
+ if(FileUtil.exist(localProjectJsonPath)){
|
|
|
+ uploadMap.put(localProjectJsonPath, ossProjectJsonPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传data.json
|
|
|
+ String localDataJsonPath = dataSource + "/data.json";
|
|
|
+ String ossDataJsonPath = ossResultPath + "data.json";
|
|
|
+ if(FileUtil.exist(localDataJsonPath)){
|
|
|
+ uploadMap.put(localDataJsonPath, ossDataJsonPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ //开始上传
|
|
|
+ fYunFileServiceInterface.uploadMulFiles(uploadMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void uploadFloorplanJson(String num, String dataSource) throws Exception{
|
|
|
+ String floorPlanCardFilePath = dataSource + File.separator + "results/floorplan_cad.json";
|
|
|
+ if (!new File(floorPlanCardFilePath).exists()) {
|
|
|
+ log.error("floorplan_cad.json 文件不存在,文件路径:{}", floorPlanCardFilePath);
|
|
|
+ throw new Exception("floorplan_cad.json 文件不存在,文件路径:" + floorPlanCardFilePath);
|
|
|
+ }
|
|
|
+ JSONObject json = FloorPlanUserUtil.createFloorPlanUserJson(floorPlanCardFilePath);
|
|
|
+ if(Objects.isNull(json)){
|
|
|
+ log.error("生成floorplan.json失败,cadPath:", floorPlanCardFilePath);
|
|
|
+ throw new Exception("生成floorplan.json失败,cadPath:" + floorPlanCardFilePath);
|
|
|
+
|
|
|
+ }
|
|
|
+ String hourseTypeJsonPath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "floorplan.json";
|
|
|
+ fYunFileServiceInterface.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
|
|
|
+ hourseTypeJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "floorplan.json";
|
|
|
+ fYunFileServiceInterface.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
|
|
|
+ }
|
|
|
+}
|