|
@@ -21,15 +21,18 @@ import com.fdkankan.fyun.config.FYunFileConfig;
|
|
|
import com.fdkankan.fyun.constant.FYunTypeEnum;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.image.MatrixToImageWriterUtil;
|
|
|
+import com.fdkankan.model.constants.ConstantFileName;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.model.utils.CreateHouseJsonUtil;
|
|
|
+import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
import com.fdkankan.push.config.PushMessageConfig;
|
|
|
import com.fdkankan.push.utils.PushMsgUtil;
|
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -84,17 +87,20 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
|
|
|
private IUserIncrementService userIncrementService;
|
|
|
|
|
|
@Override
|
|
|
- public void buildScenePost(BuildSceneResultMqMessage message) {
|
|
|
+ public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
|
|
|
Integer cameraType = Integer.parseInt(message.getCameraType());
|
|
|
String sceneCode = message.getSceneCode();
|
|
|
String fileId = message.getFileId();
|
|
|
Integer payStatus = message.getPayStatus();
|
|
|
Long computeTime = message.getComputeTime();
|
|
|
- Boolean buildSuccess = message.getBuildSuccess();
|
|
|
- Integer videoVersion = message.getVideoVersion();
|
|
|
|
|
|
- Map<String, String> uploadFiles = message.getUploadFiles();
|
|
|
String path = message.getPath();
|
|
|
+
|
|
|
+ Boolean buildSuccess = message.getBuildSuccess();
|
|
|
+ Integer videoVersion = getVideoVersion(path + File.separator + "capture" +File.separator+"data.fdage");
|
|
|
+
|
|
|
+ Map<String, String> uploadFiles = getUploadFiles(path);
|
|
|
+
|
|
|
Integer pushChannel = message.getPushChannel();
|
|
|
String pushToken = message.getPushToken();
|
|
|
String prefix = message.getPrefix();
|
|
@@ -203,6 +209,120 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private Map<String, String> getUploadFiles(String path) throws Exception {
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByFileId(path);
|
|
|
+ if (ObjectUtils.isEmpty(scenePlus)) {
|
|
|
+ throw new Exception("未找到场景信息:" + path);
|
|
|
+ }
|
|
|
+
|
|
|
+ String projectNum = scenePlus.getNum();
|
|
|
+
|
|
|
+ String dataPath = String.format(ConstantFilePath.DATA_PATH_FORMAT, projectNum);
|
|
|
+ String imagesPath = String.format(ConstantFilePath.IMAGE_PATH_FORMAT, projectNum);
|
|
|
+ String videoPath = String.format(ConstantFilePath.VIDEO_PATH_FORMAT, projectNum);
|
|
|
+ String resultsPath = path + File.separator + "results" + File.separator;
|
|
|
+
|
|
|
+ String uploadJsonPath = resultsPath + "upload.json";
|
|
|
+ String uploadData = FileUtils.readFile(uploadJsonPath);
|
|
|
+ log.info("upload.json 文件路径:{}, 内容:{}", uploadJsonPath, uploadData);
|
|
|
+ JSONArray array = JSONObject.parseObject(uploadData).getJSONArray("upload");
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject fileJson = null;
|
|
|
+ String fileName = "";
|
|
|
+
|
|
|
+ Map<String, String> map = new HashMap();
|
|
|
+
|
|
|
+ for (int i = 0; i < array.size(); ++i) {
|
|
|
+ fileJson = array.getJSONObject(i);
|
|
|
+ fileName = fileJson.getString("file");
|
|
|
+ String filePath = resultsPath + fileName;
|
|
|
+
|
|
|
+ if (!(new File(filePath)).exists()) {
|
|
|
+ throw new Exception(filePath + "文件不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("vision2.txt".equals(fileName)) {
|
|
|
+ CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision2.txt", resultsPath + "vision2.modeldata");
|
|
|
+ map.put(resultsPath + "vision2.modeldata", imagesPath + "vision2.modeldata");
|
|
|
+ map.put(resultsPath + "vision2.txt", imagesPath + "vision2.txt");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fileJson.getIntValue("clazz") == 2) {
|
|
|
+ map.put(filePath, imagesPath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
|
|
|
+ } else if (fileJson.getIntValue("clazz") == 3) {
|
|
|
+ map.put(filePath, imagesPath + "pan/high/" + fileName.replace("high/", ""));
|
|
|
+ } else if (fileJson.getIntValue("clazz") == 4) {
|
|
|
+ map.put(filePath, imagesPath + "pan/low/" + fileName.replace("low/", ""));
|
|
|
+ } else if (fileJson.getIntValue("clazz") == 5) {
|
|
|
+ map.put(filePath, imagesPath + fileName);
|
|
|
+ } else if (fileJson.getIntValue("clazz") == 7) {
|
|
|
+ map.put(filePath, imagesPath + fileName);
|
|
|
+ } else if (fileJson.getIntValue("clazz") == 10) {
|
|
|
+ String updown = FileUtils.readFile(filePath);
|
|
|
+ JSONObject updownJson = JSONObject.parseObject(updown);
|
|
|
+ FileUtils.writeFile("/mnt/4Dkankan/scene/" + dataPath + fileName.replace("updown", "mapping"), updownJson.toString());
|
|
|
+ String mappingOssPath = String.format("scene_edit_data/%s/data/", projectNum) + fileName.replace("updown", "mapping");
|
|
|
+ map.put(filePath, mappingOssPath);
|
|
|
+ } else {
|
|
|
+ if (fileJson.getIntValue("clazz") == 11 || fileJson.getIntValue("clazz") == 12) {
|
|
|
+ map.put(filePath, videoPath + fileName.replace("videos/", ""));
|
|
|
+ if (fileName.contains(".mp4")) {
|
|
|
+ map.put(resultsPath + fileName.replace("mp4", "flv"), videoPath + fileName.replace("videos/", "").replace("mp4", "flv"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fileJson.getIntValue("clazz") == 16) {
|
|
|
+ map.put(filePath, dataPath + fileName);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fileJson.getIntValue("clazz") == 18) {
|
|
|
+ map.put(filePath, imagesPath + fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CreateObjUtil.convertTxtToDam(resultsPath + "tex" + File.separator + "modeldata.txt", resultsPath + ConstantFileName.modelUUID + "_50k.dam");
|
|
|
+ CreateObjUtil.convertDamToLzma(resultsPath);
|
|
|
+ CreateObjUtil.convertTxtToDam(resultsPath + "tex" + File.separator + "modeldata.txt", resultsPath + ConstantFileName.modelUUID + "_50k.dam");
|
|
|
+ CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision.txt", resultsPath + "vision.modeldata");
|
|
|
+ map.put(resultsPath + "vision.txt", imagesPath + "vision.txt");
|
|
|
+ map.put(resultsPath + "vision.modeldata", imagesPath + "vision.modeldata");
|
|
|
+
|
|
|
+ log.info("数据转换完成:" + projectNum);
|
|
|
+ File file = new File(resultsPath + ConstantFileName.modelUUID + "_50k.dam.lzma");
|
|
|
+
|
|
|
+ while (!file.exists()) {
|
|
|
+ Thread.sleep(60000L);
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put(resultsPath + ConstantFileName.modelUUID + "_50k.dam.lzma", imagesPath + ConstantFileName.modelUUID + "_50k.dam.lzma");
|
|
|
+ map.put(resultsPath + ConstantFileName.modelUUID + "_50k.dam", imagesPath + ConstantFileName.modelUUID + "_50k.dam");
|
|
|
+ FileUtil.touch("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum);
|
|
|
+ FileUtils.copyFile(resultsPath + "floorplan.json", "/mnt/4Dkankan/scene/" + dataPath + "floor.json", true);
|
|
|
+ log.info("floor.json路径:" + resultsPath + "floor.json");
|
|
|
+ map.put(resultsPath + "floorplan.json", dataPath + "floor.json");
|
|
|
+ map.put(resultsPath + "floorplan_cad.json", dataPath + "floorplan_cad.json");
|
|
|
+ map.put(path + File.separator + "capture/stitch_params.txt", dataPath + "stitch_params.txt");
|
|
|
+ map.put(path + File.separator + "capture/Up.xml", dataPath + "Up.xml");
|
|
|
+ map.put(path + File.separator + "capture/Up2.xml", dataPath + "Up2.xml");
|
|
|
+ map.put(path + File.separator + "capture/Up.txt", dataPath + "Up.txt");
|
|
|
+ map.put(path + File.separator + "capture/Up2.txt", dataPath + "Up2.txt");
|
|
|
+ return map;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getVideoVersion(String dataFdagePath) {
|
|
|
+ log.info("dataFdagePath 文件路径 :{}", dataFdagePath);
|
|
|
+ String data = FileUtils.readFile(dataFdagePath);
|
|
|
+ //获取data.fdage的内容
|
|
|
+ JSONObject dataJson = new JSONObject();
|
|
|
+ if(data!=null){
|
|
|
+ dataJson = JSONObject.parseObject(data);
|
|
|
+ }
|
|
|
+ return dataJson.getInteger("videoVersion");
|
|
|
+ }
|
|
|
+
|
|
|
private void uploadFloorCad(String path, String num, Map<String, String> uploadFiles){
|
|
|
|
|
|
//户型图上传
|
|
@@ -441,15 +561,7 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
|
|
|
}
|
|
|
|
|
|
private Long calUseSpace(Map<String, String> uploadFile) {
|
|
|
- File spaceFile = null;
|
|
|
- long space = 0L;
|
|
|
- for (String key : uploadFile.keySet()) {
|
|
|
- spaceFile = new File(key);
|
|
|
- if(spaceFile.exists()){
|
|
|
- space += spaceFile.length();
|
|
|
- }
|
|
|
- }
|
|
|
- return space;
|
|
|
+ return uploadFile.keySet().stream().map(File::new).filter(File::exists).mapToLong(File::length).sum();
|
|
|
}
|
|
|
|
|
|
private void sealScene(boolean arrearCap, Long scenePlusId, Long sceneProId){
|
|
@@ -473,43 +585,35 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
|
|
|
**/
|
|
|
private void updateDb4Sm(String num, long space){
|
|
|
List<ScenePlus> ScenePlusList = scenePlusService.list(
|
|
|
- new LambdaQueryWrapper<ScenePlus>()
|
|
|
- .select(ScenePlus::getId)
|
|
|
- .eq(ScenePlus::getNum, num));
|
|
|
+ new LambdaQueryWrapper<ScenePlus>().select(ScenePlus::getId).eq(ScenePlus::getNum, num));
|
|
|
|
|
|
- if(CollUtil.isNotEmpty(ScenePlusList))
|
|
|
+ if(CollUtil.isEmpty(ScenePlusList)){
|
|
|
return ;
|
|
|
- List<Long> sceneIds = ScenePlusList.stream().map(scene -> {
|
|
|
- return scene.getId();
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> sceneIds = ScenePlusList.stream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
|
|
|
|
//更新场景创建时间
|
|
|
- scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
|
|
|
- .in(ScenePlus::getId, sceneIds)
|
|
|
+ scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>().in(ScenePlus::getId, sceneIds)
|
|
|
.set(ScenePlus::getCreateTime, Calendar.getInstance().getTime())
|
|
|
.set(ScenePlus::getSceneStatus, SceneStatus.NO_DISPLAY.code()));
|
|
|
|
|
|
//更新使用容量
|
|
|
- scenePlusExtService.update(
|
|
|
- new LambdaUpdateWrapper<ScenePlusExt>()
|
|
|
- .in(ScenePlusExt::getPlusId, sceneIds)
|
|
|
- .set(ScenePlusExt::getSpace, space));
|
|
|
+ scenePlusExtService.update(new LambdaUpdateWrapper<ScenePlusExt>()
|
|
|
+ .in(ScenePlusExt::getPlusId, sceneIds).set(ScenePlusExt::getSpace, space));
|
|
|
}
|
|
|
|
|
|
private ScenePlus updateDbPlus(String num, Long space, Integer payStatus, String videosJson, Long computeTime, String fileId) throws Exception{
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
List<ScenePlus> list = scenePlusService.list(
|
|
|
- new LambdaQueryWrapper<ScenePlus>()
|
|
|
- .select(ScenePlus::getId)
|
|
|
- .eq(ScenePlus::getNum, num));
|
|
|
- if(scenePlus == null || CollUtil.isEmpty(list))
|
|
|
+ new LambdaQueryWrapper<ScenePlus>().select(ScenePlus::getId).eq(ScenePlus::getNum, num));
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
return null;
|
|
|
+ }
|
|
|
|
|
|
//修改场景状态 空间 支付状态 计算时间
|
|
|
- List<Long> scenePlusIds = list.stream().map(plus -> {
|
|
|
- return plus.getId();
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ List<Long> scenePlusIds = list.stream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
|
|
|
|
scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
|
|
|
.in(ScenePlus::getId, scenePlusIds)
|