|
@@ -0,0 +1,130 @@
|
|
|
+package com.fdkankan.job.job;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.job.entity.ScenePlus;
|
|
|
+import com.fdkankan.job.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.job.service.IHouseTypeService;
|
|
|
+import com.fdkankan.job.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.job.service.IScenePlusService;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.fdkankan.model.utils.SceneUtil;
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 修复housetype.json文件数据
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author dengsixing
|
|
|
+ * @since 2022/12/16
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class UploadResultDataHandler {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+
|
|
|
+ @XxlJob("uploadResultData")
|
|
|
+ private void repairModelKind(){
|
|
|
+ XxlJobHelper.log("uploadResultData start.....");
|
|
|
+
|
|
|
+ List<String> faildNumList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> numList = null;
|
|
|
+ String nums = XxlJobHelper.getJobParam();
|
|
|
+ if(StrUtil.isNotEmpty(nums)){
|
|
|
+ numList = Arrays.asList(nums.split(","));
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ScenePlus> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(CollUtil.isNotEmpty(numList)){
|
|
|
+ queryWrapper.in(ScenePlus::getNum, numList);
|
|
|
+ }
|
|
|
+ List<ScenePlus> list = scenePlusService.list(queryWrapper);
|
|
|
+
|
|
|
+ if(CollUtil.isEmpty(list)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ list.parallelStream().forEach(plus->{
|
|
|
+ try {
|
|
|
+ String ossResultPath = String.format(UploadFilePath.scene_result_data_path, plus.getNum());
|
|
|
+ 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/";
|
|
|
+ //先清除旧的全景图
|
|
|
+ fYunFileService.deleteFolder(ossCachesImagePath);
|
|
|
+ if(FileUtil.exist(localCachesImagePath)){
|
|
|
+ List<String> imagesList = FileUtil.listFileNames(localCachesImagePath);
|
|
|
+ if(CollUtil.isNotEmpty(imagesList)){
|
|
|
+ String visionPath = dataSource + "/results/vision.txt";
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传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);
|
|
|
+ }
|
|
|
+
|
|
|
+ //开始上传
|
|
|
+ fYunFileService.uploadMulFiles(uploadMap);
|
|
|
+
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("上传结算结果失败,num=" + plus.getNum(), e);
|
|
|
+ faildNumList.add(plus.getNum());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ XxlJobHelper.log("uploadResultData end.....");
|
|
|
+ XxlJobHelper.log("上传失败场景码:" + JSON.toJSONString(faildNumList));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|