|
@@ -2,15 +2,19 @@ package com.fdkankan.contro.service.impl;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.SceneStatus;
|
|
import com.fdkankan.common.constant.SceneStatus;
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.contro.dto.UploadSceneDTO;
|
|
import com.fdkankan.contro.dto.UploadSceneDTO;
|
|
import com.fdkankan.contro.entity.SceneOrigBd;
|
|
import com.fdkankan.contro.entity.SceneOrigBd;
|
|
import com.fdkankan.contro.entity.ScenePlus;
|
|
import com.fdkankan.contro.entity.ScenePlus;
|
|
|
|
+import com.fdkankan.contro.httpclient.HaixinClient;
|
|
import com.fdkankan.contro.service.IHaixinService;
|
|
import com.fdkankan.contro.service.IHaixinService;
|
|
import com.fdkankan.contro.service.ISceneOrigBdService;
|
|
import com.fdkankan.contro.service.ISceneOrigBdService;
|
|
import com.fdkankan.contro.service.IScenePlusService;
|
|
import com.fdkankan.contro.service.IScenePlusService;
|
|
@@ -21,15 +25,26 @@ import com.fdkankan.model.constants.UploadFilePath;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
public class HaixinServiceImpl implements IHaixinService {
|
|
public class HaixinServiceImpl implements IHaixinService {
|
|
|
|
|
|
|
|
+ private static final String API_FDFS_UPLOAD = "/fdfs/api/file/upload";
|
|
|
|
+ private static final String API_SUBMIT_RENDER_RESULT = "ecs/api/panoramicImageService/submitRenderResult";
|
|
|
|
+
|
|
|
|
+ @Value("${haixin.host}")
|
|
|
|
+ private String haixinHost;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private ISceneOrigBdService sceneOrigBdService;
|
|
private ISceneOrigBdService sceneOrigBdService;
|
|
@Resource
|
|
@Resource
|
|
@@ -38,6 +53,8 @@ public class HaixinServiceImpl implements IHaixinService {
|
|
private FYunFileServiceInterface fileServiceInterface;
|
|
private FYunFileServiceInterface fileServiceInterface;
|
|
@Autowired
|
|
@Autowired
|
|
private IScenePlusService scenePlusService;
|
|
private IScenePlusService scenePlusService;
|
|
|
|
+ @Resource
|
|
|
|
+ private HaixinClient haixinClient;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResultData uploadScene(UploadSceneDTO dto) {
|
|
public ResultData uploadScene(UploadSceneDTO dto) {
|
|
@@ -57,9 +74,9 @@ public class HaixinServiceImpl implements IHaixinService {
|
|
|
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
String taskId = scenePlus.getTaskId();
|
|
String taskId = scenePlus.getTaskId();
|
|
- String kNo = scenePlus.getKNo();
|
|
|
|
|
|
|
|
- String zipPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + num + ".zip";
|
|
|
|
|
|
+ String zipDir = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "haixin/";
|
|
|
|
+ String zipPath = zipDir + num + ".zip";
|
|
if(buildSuccess){//计算成功,把原始资源打压缩包
|
|
if(buildSuccess){//计算成功,把原始资源打压缩包
|
|
//复制scene_edit_data/num/data/mapping目录到view目录
|
|
//复制scene_edit_data/num/data/mapping目录到view目录
|
|
String editMappingPath = "/oss/4dkankan/" + String.format(UploadFilePath.DATA_EDIT_PATH, num) + "mapping";
|
|
String editMappingPath = "/oss/4dkankan/" + String.format(UploadFilePath.DATA_EDIT_PATH, num) + "mapping";
|
|
@@ -74,16 +91,37 @@ public class HaixinServiceImpl implements IHaixinService {
|
|
|
|
|
|
//打压缩包
|
|
//打压缩包
|
|
this.zip(viewPath, zipPath);
|
|
this.zip(viewPath, zipPath);
|
|
- }
|
|
|
|
|
|
|
|
- // TODO: 2025/2/14 发送压缩包 推送计算状态
|
|
|
|
|
|
+ //上传到fastdf
|
|
|
|
+ String url = haixinHost.concat(API_FDFS_UPLOAD);
|
|
|
|
+ List<File> files = FileUtil.loopFiles(zipDir);
|
|
|
|
+ List<String> fileNameRemoteList = new ArrayList<>();
|
|
|
|
+ String finalUrl = url;
|
|
|
|
+ files.stream().forEach(file->{
|
|
|
|
+ JSONObject jsonObject = haixinClient.uploadToFdfs(finalUrl, file.getAbsolutePath());
|
|
|
|
+ JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
+ fileNameRemoteList.add(data.getString("fileNameRemote"));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //通知计算结果
|
|
|
|
+ url = haixinHost.concat(API_SUBMIT_RENDER_RESULT);
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ for (String fileNameRemote : fileNameRemoteList) {
|
|
|
|
+ sb.append(",").append(fileNameRemote);
|
|
|
|
+ }
|
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
|
+ params.put("vendor","A0BF");
|
|
|
|
+ params.put("projectId", taskId);
|
|
|
|
+ params.put("packetPath", sb.substring(1));
|
|
|
|
+ haixinClient.postJson(url, params);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void zip(String sourcePath, String zipPath) throws Exception {
|
|
private void zip(String sourcePath, String zipPath) throws Exception {
|
|
FileUtil.mkParentDirs(zipPath);
|
|
FileUtil.mkParentDirs(zipPath);
|
|
- String cmd = "cd " + sourcePath + " && zip -r " + zipPath + " *";//&& mv -f " + zipPath + " " + target
|
|
|
|
|
|
+ String cmd = "cd " + sourcePath + " && zip -r -s 2048M" + zipPath + " *";//&& mv -f " + zipPath + " " + target
|
|
CmdUtils.callLineSh(cmd, 200);
|
|
CmdUtils.callLineSh(cmd, 200);
|
|
}
|
|
}
|
|
}
|
|
}
|