|
@@ -0,0 +1,163 @@
|
|
|
+package com.fdkankan.scene.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import com.fdkankan.scene.entity.ScenePlus;
|
|
|
+import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.scene.service.IRepairDataService;
|
|
|
+import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.scene.service.IScenePlusService;
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class RepairDataServiceImpl implements IRepairDataService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData repairSceneResultData(String num) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ScenePlus> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(StrUtil.isNotEmpty(num)){
|
|
|
+ wrapper.eq(ScenePlus::getNum, num);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> faildNumList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<ScenePlus> list = scenePlusService.list(wrapper);
|
|
|
+
|
|
|
+ if(CollUtil.isNotEmpty(list)){
|
|
|
+ list.parallelStream().forEach(plus->{
|
|
|
+ try {
|
|
|
+ String ossResultPath = String.format(UploadFilePath.scene_result_data_path, plus.getNum());
|
|
|
+
|
|
|
+ boolean flag = FileUtil.exist(ossResultPath);
|
|
|
+ String test = redisUtil.get("scene:result:upload:num:" + plus.getNum());
|
|
|
+ if(StrUtil.isEmpty(test) && !flag){
|
|
|
+
|
|
|
+ Map<String, String> uploadMap = new HashMap<>();
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(plus.getId());
|
|
|
+ String dataSource = scenePlusExt.getDataSource();
|
|
|
+ if(StrUtil.isNotEmpty(dataSource)){
|
|
|
+
|
|
|
+ //上传caches/images
|
|
|
+ String localCachesImagePath = dataSource + "/caches/images/";
|
|
|
+ String ossCachesImagePath = ossResultPath + "caches/images/";
|
|
|
+ //先清除旧的全景图
|
|
|
+ if(FileUtil.exist(localCachesImagePath)){
|
|
|
+ fYunFileService.uploadFileByCommand(localCachesImagePath, ossCachesImagePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传vision.txt
|
|
|
+ String localVisionPath = dataSource + "/results/vision.txt";
|
|
|
+ String ossVisionJsonPath = String.format(UploadFilePath.IMG_VIEW_PATH, plus.getNum()) + "vision.txt";
|
|
|
+ if(FileUtil.exist(localVisionPath)){
|
|
|
+ uploadMap.put(localVisionPath, ossVisionJsonPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传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);
|
|
|
+ }
|
|
|
+
|
|
|
+ //户型图上传
|
|
|
+ String floorCadPath = dataSource + "/results/floorplan_cad";
|
|
|
+ String dataViewPath = UploadFilePath.DATA_VIEW_PATH + "floor-cad-%s.%s";
|
|
|
+ //清除原有旧的cad图
|
|
|
+ List<String> floorCadList = FileUtils.getFileList(floorCadPath);
|
|
|
+ if(CollUtil.isNotEmpty(floorCadList)){
|
|
|
+ floorCadList.stream().forEach(str->{
|
|
|
+ String substring = str.substring(str.lastIndexOf(File.separator) + 1);
|
|
|
+ String[] arr = substring.split("floor");
|
|
|
+ String[] arr2 = arr[1].split("\\.");
|
|
|
+ //上传到用户编辑目录
|
|
|
+ uploadMap.put(str, String.format(dataViewPath, plus.getNum(), arr2[0], arr2[1]));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传深时场景生成obj需要的文件
|
|
|
+ String localReconstruction = dataSource + "/caches/reconstruction/";
|
|
|
+ String ossReconstruction = ossResultPath + "caches/reconstruction/";
|
|
|
+ if(FileUtil.exist(localReconstruction)){
|
|
|
+ fYunFileService.uploadFileByCommand(localReconstruction, ossReconstruction);
|
|
|
+ }
|
|
|
+ String localDepthmap = dataSource + "/caches/depthmap/";
|
|
|
+ String ossDepthmap = ossResultPath + "caches/depthmap/";
|
|
|
+ if(FileUtil.exist(localDepthmap)){
|
|
|
+ fYunFileService.uploadFileByCommand(localDepthmap, ossDepthmap);
|
|
|
+ }
|
|
|
+ String localDepthmapAsc = dataSource + "/caches/depthmap_csc/";
|
|
|
+ String ossDepthmapAsc = ossResultPath + "caches/depthmap_csc/";
|
|
|
+ if(FileUtil.exist(localDepthmapAsc)){
|
|
|
+ fYunFileService.uploadFileByCommand(localDepthmapAsc, ossDepthmapAsc);
|
|
|
+ }
|
|
|
+ String localPanoramaJson = dataSource + "/caches/panorama.json";
|
|
|
+ String ossPanoramaJson = ossResultPath + "caches/panorama.json";
|
|
|
+ if(FileUtil.exist(localPanoramaJson)){
|
|
|
+ fYunFileService.uploadFile(localPanoramaJson, ossPanoramaJson);
|
|
|
+ }
|
|
|
+ String localLaserPly = dataSource + "/results/laserData/laser.ply";
|
|
|
+ String ossLaserPly = ossResultPath + "results/laserData/laser.ply";
|
|
|
+ if(FileUtil.exist(localLaserPly)){
|
|
|
+ fYunFileService.uploadFile(localLaserPly, ossLaserPly);
|
|
|
+ }
|
|
|
+ String localFloorGroupFixJson = dataSource + "/caches/floor_group_fix.json";
|
|
|
+ String ossFloorGroupFixJson = ossResultPath + "caches/floor_group_fix.json";
|
|
|
+ if(FileUtil.exist(localFloorGroupFixJson)){
|
|
|
+ fYunFileService.uploadFile(localFloorGroupFixJson, ossFloorGroupFixJson);
|
|
|
+ }
|
|
|
+ String localDepthmapVis = dataSource + "/caches/depthmap_vis";
|
|
|
+ String ossDepthmapVis = ossResultPath + "caches/depthmap_vis";
|
|
|
+ if(FileUtil.exist(localDepthmapVis)){
|
|
|
+ fYunFileService.uploadFileByCommand(localDepthmapVis, ossDepthmapVis);
|
|
|
+ }
|
|
|
+
|
|
|
+ //开始上传
|
|
|
+ fYunFileService.uploadMulFiles(uploadMap);
|
|
|
+
|
|
|
+ }
|
|
|
+ redisUtil.set("scene:result:upload:num:" + plus.getNum(), "1");
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("上传结算结果失败,num=" + plus.getNum(), e);
|
|
|
+ faildNumList.add(plus.getNum());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|