|
|
@@ -0,0 +1,545 @@
|
|
|
+//
|
|
|
+// Source code recreated from a .class file by IntelliJ IDEA
|
|
|
+// (powered by FernFlower decompiler)
|
|
|
+//
|
|
|
+
|
|
|
+package com.fdkankan.modeling.mq;
|
|
|
+
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fdkankan.modeling.consants.BuildStatusEnum;
|
|
|
+import com.fdkankan.modeling.consants.ConstantFilePath;
|
|
|
+import com.fdkankan.modeling.consants.SysConstants;
|
|
|
+import com.fdkankan.modeling.entity.BuildLog;
|
|
|
+import com.fdkankan.modeling.entity.ScenePro;
|
|
|
+import com.fdkankan.modeling.entity.SceneProEdit;
|
|
|
+import com.fdkankan.modeling.entity.User;
|
|
|
+import com.fdkankan.modeling.exception.BuildException;
|
|
|
+import com.fdkankan.modeling.service.IMqEcsService;
|
|
|
+import com.fdkankan.modeling.service.ISceneProEditService;
|
|
|
+import com.fdkankan.modeling.service.ISceneProService;
|
|
|
+import com.fdkankan.modeling.service.ISceneService;
|
|
|
+import com.fdkankan.modeling.service.IUserService;
|
|
|
+import com.fdkankan.modeling.util.ComputerUtil;
|
|
|
+import com.fdkankan.modeling.util.CreateObjUtil;
|
|
|
+import com.fdkankan.modeling.util.DingDingUtils;
|
|
|
+import com.fdkankan.modeling.util.FileUtils;
|
|
|
+import com.fdkankan.modeling.util.GYUploadToOssUtil;
|
|
|
+import com.fdkankan.modeling.util.UploadToOssUtil;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import com.rabbitmq.client.Channel;
|
|
|
+import java.io.File;
|
|
|
+import java.io.PrintWriter;
|
|
|
+import java.io.StringWriter;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+import java.util.concurrent.Future;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.TimeoutException;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
+import org.springframework.amqp.rabbit.annotation.Queue;
|
|
|
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.messaging.handler.annotation.Header;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class BuildSceneReceiver {
|
|
|
+ private static final Logger log = LogManager.getLogger(BuildSceneReceiver.class);
|
|
|
+ @Autowired
|
|
|
+ private ISceneService sceneService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneProService sceneProService;
|
|
|
+ @Autowired
|
|
|
+ private IUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private UploadToOssUtil uploadToOssUtil;
|
|
|
+ @Autowired
|
|
|
+ private GYUploadToOssUtil gYUploadToOssUtil;
|
|
|
+ @Autowired
|
|
|
+ private ISceneProEditService sceneProEditService;
|
|
|
+ @Value("${gy.company.id}")
|
|
|
+ private String gyCompanyId;
|
|
|
+ @Value("${oss.type}")
|
|
|
+ private String ossType;
|
|
|
+ @Value("${prefix.ali}")
|
|
|
+ private String prefixAli;
|
|
|
+ @Autowired
|
|
|
+ QueueNameService queueNameService;
|
|
|
+ @Autowired
|
|
|
+ IMqEcsService mqEcsService;
|
|
|
+ @Autowired
|
|
|
+ RedisUtil redisUtil;
|
|
|
+ @Autowired
|
|
|
+ ComputerUtil computerUtil;
|
|
|
+
|
|
|
+ public BuildSceneReceiver() {
|
|
|
+ }
|
|
|
+
|
|
|
+ @RabbitListener(
|
|
|
+ queuesToDeclare = {@Queue("#{queueNameService.getQueueName()}")},
|
|
|
+ containerFactory = "rabbitListenerContainerFactory",
|
|
|
+ priority = "${mq.consumerPriority}"
|
|
|
+ )
|
|
|
+ public void process(String content, @Header("amqp_deliveryTag") long deliveryTag, Channel channel) throws Exception {
|
|
|
+ String redisKey = "zfb-modeling:" + content;
|
|
|
+ if (this.redisUtil.hasKey(redisKey)) {
|
|
|
+ log.info("重复计算退出计算:,{}", content);
|
|
|
+ } else {
|
|
|
+ this.redisUtil.set(redisKey, StringUtils.isBlank(SysConstants.hostName) ? "1" : SysConstants.hostName);
|
|
|
+ SysConstants.SYSTEM_BUILDING = true;
|
|
|
+ if (SysConstants.SYSTEM_OFFING) {
|
|
|
+ SysConstants.SYSTEM_BUILDING = false;
|
|
|
+ channel.basicNack(deliveryTag, true, true);
|
|
|
+ log.error("服务实例:{} 正在关闭,退出构建!", SysConstants.hostName);
|
|
|
+ } else if (ObjectUtils.isEmpty(content)) {
|
|
|
+ SysConstants.SYSTEM_BUILDING = false;
|
|
|
+ log.error("消息内容为空,退出构建,当前服务器id:{}", SysConstants.hostName);
|
|
|
+ } else {
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ BuildLog buildLog = new BuildLog(SysConstants.hostName, this.queueNameService.getQueueName(), content);
|
|
|
+ BuildStatusEnum buildStatus = BuildStatusEnum.SUCCESS;
|
|
|
+ ExecutorService executorService = Executors.newFixedThreadPool(1);
|
|
|
+ Future<BuildStatusEnum> future = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ this.preBuild(content, buildLog);
|
|
|
+ future = executorService.submit(() -> {
|
|
|
+ try {
|
|
|
+ this.buildScene(content, buildLog);
|
|
|
+ return BuildStatusEnum.SUCCESS;
|
|
|
+ } catch (Exception var4) {
|
|
|
+ log.error("服务实例:{} 构建异常:", SysConstants.hostName, var4);
|
|
|
+ return BuildStatusEnum.FAILED;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ buildStatus = (BuildStatusEnum)future.get((long)SysConstants.modelTimeOut, TimeUnit.SECONDS);
|
|
|
+ } catch (TimeoutException var18) {
|
|
|
+ log.error("服务实例:{} 构建异常:", SysConstants.hostName, var18);
|
|
|
+ buildStatus = BuildStatusEnum.OVERTIME;
|
|
|
+ } catch (BuildException var19) {
|
|
|
+ buildStatus = var19.getBuildStatus();
|
|
|
+ } catch (Exception var20) {
|
|
|
+ log.error("服务实例:{} 构建异常:", SysConstants.hostName, var20);
|
|
|
+ if (var20.getCause() instanceof BuildException) {
|
|
|
+ buildStatus = ((BuildException)var20.getCause()).getBuildStatus();
|
|
|
+ } else {
|
|
|
+ buildStatus = BuildStatusEnum.FAILED;
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ if (future != null) {
|
|
|
+ future.cancel(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ executorService.shutdown();
|
|
|
+ }
|
|
|
+
|
|
|
+ buildLog.setDuration((System.currentTimeMillis() - start) / 1000L);
|
|
|
+ this.afterBuild(buildStatus, buildLog);
|
|
|
+ this.delNas(buildLog.getSceneNum());
|
|
|
+ SysConstants.SYSTEM_BUILDING = false;
|
|
|
+ this.redisUtil.del(new String[]{redisKey});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void delNas(String sceneNum) {
|
|
|
+ try {
|
|
|
+ ScenePro scenePro = this.sceneProService.findBySceneNum(sceneNum);
|
|
|
+ if (scenePro != null && StringUtils.isNotBlank(scenePro.getDataSource())) {
|
|
|
+ String dataSource = scenePro.getDataSource();
|
|
|
+ this.uploadToOssUtil.uploadDirectory(dataSource, "build_result/" + sceneNum + "/");
|
|
|
+ Thread.sleep(2000L);
|
|
|
+ FileUtil.del(dataSource);
|
|
|
+ this.sceneProService.updateDelBuildResult(scenePro.getId(), 1);
|
|
|
+ }
|
|
|
+ } catch (Exception var4) {
|
|
|
+ log.info("del-build-result-error:{}", var4);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void preBuild(String content, BuildLog logRecord) throws Exception {
|
|
|
+ log.info("服务{} 开始处理队列{} 的消息:{}", SysConstants.hostName, this.queueNameService.getQueueName(), content);
|
|
|
+ Thread.sleep(2000L);
|
|
|
+ String[] strs = content.split(":;");
|
|
|
+ logRecord.setSceneNum(strs[4]);
|
|
|
+ String dataSource;
|
|
|
+ if (strs[2].contains("https:")) {
|
|
|
+ dataSource = strs[1];
|
|
|
+ } else {
|
|
|
+ dataSource = strs[1].substring(0, strs[1].lastIndexOf("/") + 1).concat(strs[2]);
|
|
|
+ }
|
|
|
+
|
|
|
+ logRecord.setDataSource(dataSource);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void buildScene(String content, BuildLog logRecord) throws Exception {
|
|
|
+ String[] strs = content.split(":;");
|
|
|
+ String unicode = strs[0];
|
|
|
+ String path = strs[1];
|
|
|
+ String prefix = strs[2];
|
|
|
+ String imgsName = strs[3];
|
|
|
+ String projectNum = strs[4];
|
|
|
+ String userName = strs[6];
|
|
|
+ String cameraType = strs[7];
|
|
|
+ String algorithm = strs[8];
|
|
|
+ String fileId = strs[9];
|
|
|
+ String cameraName = strs[10];
|
|
|
+ String resolution = strs[11];
|
|
|
+ String buildType = "V2";
|
|
|
+ if (strs.length >= 13) {
|
|
|
+ buildType = strs[12];
|
|
|
+ }
|
|
|
+
|
|
|
+ String rebuild = "0";
|
|
|
+ if (strs.length >= 14) {
|
|
|
+ rebuild = strs[13];
|
|
|
+ }
|
|
|
+
|
|
|
+ logRecord.setBuildType(0);
|
|
|
+ logRecord.setSceneNum(projectNum);
|
|
|
+ log.info("用的算法是:" + algorithm);
|
|
|
+ log.info("用的相机是:" + (Integer.parseInt(cameraType) < 4 ? "单球目" : "双球目(八目)"));
|
|
|
+ String isModel = strs[5];
|
|
|
+ Long space = 0L;
|
|
|
+ int payStatus = 0;
|
|
|
+ String data;
|
|
|
+ Map dataMap;
|
|
|
+ if (Integer.parseInt(cameraType) < 3) {
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ while(i < 5) {
|
|
|
+ try {
|
|
|
+ FileUtils.downLoadFromUrl(prefix + imgsName + "?m=" + (new Date()).getTime(), imgsName, path + File.separator + "capture");
|
|
|
+ FileUtils.decompress(path + File.separator + "capture" + File.separator + imgsName, path + File.separator + "capture");
|
|
|
+ break;
|
|
|
+ } catch (Exception var54) {
|
|
|
+ var54.printStackTrace();
|
|
|
+ StringWriter trace = new StringWriter();
|
|
|
+ var54.printStackTrace(new PrintWriter(trace));
|
|
|
+ log.error(trace.toString());
|
|
|
+ if (i < 4) {
|
|
|
+ FileUtils.deleteFile(path + File.separator + "capture" + File.separator + imgsName);
|
|
|
+ FileUtils.delFolder(path + File.separator + "capture" + File.separator + "images");
|
|
|
+ }
|
|
|
+
|
|
|
+ Thread.sleep(10000L);
|
|
|
+ ++i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ FileUtils.deleteFile(path + File.separator + "capture" + File.separator + "zip.Zip");
|
|
|
+ data = FileUtils.readFile(path + File.separator + "capture" + File.separator + "data.fdage");
|
|
|
+ dataMap = this.computerUtil.getTypeString(cameraType, algorithm, resolution, (JSONObject)null);
|
|
|
+ String splitType = (String)dataMap.get("splitType");
|
|
|
+ data = (String)dataMap.get("skyboxType");
|
|
|
+ String dataDescribe = (String)dataMap.get("dataDescribe");
|
|
|
+ JSONObject dataJson = new JSONObject();
|
|
|
+ if (data != null) {
|
|
|
+ dataJson = JSONObject.parseObject(data);
|
|
|
+ if (dataJson.containsKey("imgs")) {
|
|
|
+ splitType = "SPLIT_V4";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.computerUtil.createJson(path, splitType, data, dataDescribe, projectNum, path);
|
|
|
+ dataMap = this.computerUtil.computer(projectNum, path, buildType, cameraType, dataJson);
|
|
|
+ this.uploadToOssUtil.uploadMulFiles(dataMap);
|
|
|
+ log.info("双目上完oss结束修改数据:" + projectNum);
|
|
|
+ this.sceneService.updateTime(projectNum, space, payStatus);
|
|
|
+ } else {
|
|
|
+ ScenePro scene = this.sceneProService.findBySceneNum(projectNum);
|
|
|
+ if (scene == null) {
|
|
|
+ log.error("场景不存在:{}", projectNum);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ if (Integer.parseInt(cameraType) != 5 && Integer.parseInt(cameraType) != 6) {
|
|
|
+ if (Integer.parseInt(cameraType) == 14) {
|
|
|
+ CreateObjUtil.ossUtilCpWithZfbBucket("home/" + cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode + File.separator, ConstantFilePath.BUILD_MODEL_LASER_PATH + cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode + File.separator + "capture");
|
|
|
+ path = ConstantFilePath.BUILD_MODEL_LASER_PATH + cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode;
|
|
|
+ } else if (Integer.parseInt(cameraType) >= 4) {
|
|
|
+ CreateObjUtil.ossUtilCpWithZfbBucket("home/" + cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode + File.separator, ConstantFilePath.BUILD_MODEL_PATH + cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode + File.separator + "capture");
|
|
|
+ path = ConstantFilePath.BUILD_MODEL_PATH + cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
|
|
|
+ FileUtils.downLoadFromUrl(prefix + "/" + imgsName + "?m=" + System.currentTimeMillis(), imgsName, path + File.separator + "capture");
|
|
|
+ FileUtils.decompress(path + File.separator + "capture" + File.separator + imgsName, path + File.separator + "capture");
|
|
|
+ FileUtils.delFile(path + File.separator + "capture" + File.separator + imgsName);
|
|
|
+ }
|
|
|
+
|
|
|
+ data = FileUtils.readFile(path + File.separator + "capture" + File.separator + "data.fdage");
|
|
|
+ JSONObject dataJson = new JSONObject();
|
|
|
+ if (data != null) {
|
|
|
+ dataJson = JSONObject.parseObject(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ File caches = new File(path + File.separator + "caches");
|
|
|
+ if (caches.exists()) {
|
|
|
+ File[] var61 = caches.listFiles();
|
|
|
+ int var27 = var61.length;
|
|
|
+
|
|
|
+ for(int var28 = 0; var28 < var27; ++var28) {
|
|
|
+ File deleteFile = var61[var28];
|
|
|
+ if ((new File(path + "_images")).exists()) {
|
|
|
+ if (deleteFile.isDirectory()) {
|
|
|
+ FileUtils.delAllFile(deleteFile.getAbsolutePath());
|
|
|
+ } else {
|
|
|
+ FileUtils.deleteFile(deleteFile.getAbsolutePath());
|
|
|
+ }
|
|
|
+ } else if (!deleteFile.getAbsolutePath().contains("images")) {
|
|
|
+ if (deleteFile.isDirectory()) {
|
|
|
+ FileUtils.delAllFile(deleteFile.getAbsolutePath());
|
|
|
+ } else {
|
|
|
+ FileUtils.deleteFile(deleteFile.getAbsolutePath());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((new File(path + File.separator + "results")).exists()) {
|
|
|
+ FileUtils.delAllFile(path + File.separator + "results");
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("path:" + path);
|
|
|
+ dataMap = this.computerUtil.getTypeString(cameraType, algorithm, resolution, dataJson);
|
|
|
+ String splitType = (String)dataMap.get("splitType");
|
|
|
+ String skyboxType = (String)dataMap.get("skyboxType");
|
|
|
+ String dataDescribe = (String)dataMap.get("dataDescribe");
|
|
|
+ if (dataJson.containsKey("videoVersion") && StringUtils.isNotEmpty(dataJson.getString("videoVersion")) && Integer.parseInt(dataJson.getString("videoVersion")) < 4) {
|
|
|
+ skyboxType = "SKYBOX_V6";
|
|
|
+ }
|
|
|
+
|
|
|
+ this.computerUtil.createJson(path, splitType, skyboxType, dataDescribe, projectNum, path);
|
|
|
+ Map<String, String> map = this.computerUtil.computer(projectNum, path, buildType, cameraType, dataJson);
|
|
|
+ if (Integer.parseInt(cameraType) == 5 || Integer.parseInt(cameraType) == 6) {
|
|
|
+ map.put(path + File.separator + "capture/stitch_params.txt", "data/data" + projectNum + "/stitch_params.txt");
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put(path + File.separator + "capture/Up.xml", "data/data" + projectNum + "/Up.xml");
|
|
|
+ map.put(path + File.separator + "capture/Up2.xml", "data/data" + projectNum + "/Up2.xml");
|
|
|
+ if (Integer.parseInt(cameraType) == 13) {
|
|
|
+ map.put(path + File.separator + "capture/Up.txt", "data/data" + projectNum + "/Up.txt");
|
|
|
+ map.put(path + File.separator + "capture/Up2.txt", "data/data" + projectNum + "/Up2.txt");
|
|
|
+ }
|
|
|
+
|
|
|
+ this.uploadToOssUtil.uploadMulFiles(map);
|
|
|
+ payStatus = 1;
|
|
|
+ File spaceFile = null;
|
|
|
+ Iterator var32 = map.keySet().iterator();
|
|
|
+
|
|
|
+ while(var32.hasNext()) {
|
|
|
+ String uploadJson = (String)var32.next();
|
|
|
+ spaceFile = new File(uploadJson);
|
|
|
+ if (spaceFile.exists()) {
|
|
|
+ space = space + spaceFile.length();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("八目上完oss结束修改数据:" + projectNum);
|
|
|
+ String uploadData = FileUtils.readFile(path + File.separator + "results" + File.separator + "upload.json");
|
|
|
+ JSONArray array = null;
|
|
|
+ if (uploadData != null) {
|
|
|
+ JSONObject uploadJson = JSONObject.parseObject(uploadData);
|
|
|
+ array = uploadJson.getJSONArray("upload");
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject fileJson = null;
|
|
|
+ String fileName = "";
|
|
|
+ Map<String, Object> videoMap = new HashMap();
|
|
|
+ String videosHdr = FileUtils.readFile(path + File.separator + "results/videos/videos_hdr_param.json");
|
|
|
+ JSONArray videoArray = null;
|
|
|
+ if (StringUtils.isNotEmpty(videosHdr)) {
|
|
|
+ videoArray = JSONObject.parseObject(videosHdr).getJSONArray("hdr_param");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (videoArray != null) {
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ for(int len = videoArray.size(); i < len; ++i) {
|
|
|
+ videoMap.put(videoArray.getJSONObject(i).getString("name"), videoArray.getJSONObject(i).getString("value"));
|
|
|
+ if (videoArray.getJSONObject(i).containsKey("fov")) {
|
|
|
+ videoMap.put(videoArray.getJSONObject(i).getString("name") + "_fov", videoArray.getJSONObject(i).getString("fov"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ JSONObject videoJson = null;
|
|
|
+ JSONObject videosJson = new JSONObject();
|
|
|
+ long videoSize = 0L;
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ for(int len = array.size(); i < len; ++i) {
|
|
|
+ fileJson = array.getJSONObject(i);
|
|
|
+ fileName = fileJson.getString("file");
|
|
|
+ if (fileJson.getIntValue("clazz") == 11 && fileName.contains(".mp4") && !fileName.contains("-ios.mp4")) {
|
|
|
+ videoJson = new JSONObject();
|
|
|
+ videoJson.put("id", fileName.substring(0, fileName.lastIndexOf(".")).replace("videos/", ""));
|
|
|
+ if ((new File(path + File.separator + "results" + File.separator + fileName.replace(".mp4", ".ts"))).exists()) {
|
|
|
+ videoSize = (new File(path + File.separator + "results" + File.separator + fileName.replace(".mp4", ".ts"))).length();
|
|
|
+ videoJson.put("tsSize", videoSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (videoMap.containsKey(videoJson.get("id"))) {
|
|
|
+ videoJson.put("value", videoMap.get(videoJson.get("id")));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (videoMap.containsKey(videoJson.get("id") + "_fov")) {
|
|
|
+ videoJson.put("blend_fov", videoMap.get(videoJson.get("id") + "_fov"));
|
|
|
+ } else {
|
|
|
+ videoJson.put("blend_fov", 7);
|
|
|
+ }
|
|
|
+
|
|
|
+ jsonArray.add(videoJson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ videosJson.put("data", jsonArray);
|
|
|
+ if (dataJson.containsKey("videoVersion") && StringUtils.isNotEmpty(dataJson.getString("videoVersion")) && Integer.parseInt(dataJson.getString("videoVersion")) >= 4) {
|
|
|
+ videosJson.put("version", 3);
|
|
|
+ if ("oss".equals(this.ossType)) {
|
|
|
+ videosJson.put("upPath", this.prefixAli + "data/data" + projectNum + "/Up.xml");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("s3".equals(this.ossType)) {
|
|
|
+ videosJson.put("upPath", "https://eurs3.4dkankan.com/data/data" + projectNum + "/Up.xml");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Integer.parseInt(cameraType) == 13) {
|
|
|
+ videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ videosJson.put("version", 1);
|
|
|
+ if ("oss".equals(this.ossType)) {
|
|
|
+ videosJson.put("upPath", this.prefixAli + "data/data" + projectNum + "/Up2.xml");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("s3".equals(this.ossType)) {
|
|
|
+ videosJson.put("upPath", "https://eurs3.4dkankan.com/data/data" + projectNum + "/Up2.xml");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Integer.parseInt(cameraType) == 13) {
|
|
|
+ videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Integer.parseInt(cameraType) == 5 || Integer.parseInt(cameraType) == 6) {
|
|
|
+ videosJson.put("version", 1);
|
|
|
+ if ("oss".equals(this.ossType)) {
|
|
|
+ videosJson.put("upPath", this.prefixAli + "data/data" + projectNum + "/stitch_params.txt");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("s3".equals(this.ossType)) {
|
|
|
+ videosJson.put("upPath", "https://eurs3.4dkankan.com/data/data" + projectNum + "/stitch_params.txt");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ long computeTime = (System.currentTimeMillis() - start) / 1000L;
|
|
|
+ this.sceneProService.updateTime(projectNum, space, Integer.valueOf(payStatus), videosJson.toJSONString(), computeTime);
|
|
|
+ StringBuffer dataBuf = (new StringBuffer()).append("data").append(File.separator).append("data").append(projectNum).append(File.separator);
|
|
|
+ StringBuffer dataBuffer = (new StringBuffer("/mnt/4Dkankan/scene/")).append(dataBuf.toString());
|
|
|
+ String strsceneInfos = FileUtils.readFile(dataBuffer.toString() + "scene.json");
|
|
|
+ JSONObject scenejson = new JSONObject();
|
|
|
+ if (strsceneInfos != null) {
|
|
|
+ scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ scenejson.put("videos", videosJson.toJSONString());
|
|
|
+ FileUtils.writeFile(dataBuffer.toString() + "scene.json", scenejson.toString());
|
|
|
+ User userEntity = this.userService.findByUserName(userName);
|
|
|
+ if (userEntity == null) {
|
|
|
+ this.userService.updateUserUsedSpaceBySceneNum((Long)null, projectNum);
|
|
|
+ } else {
|
|
|
+ this.userService.updateUserUsedSpaceBySceneNum(userEntity.getId(), projectNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(scene.getUserId())) {
|
|
|
+ User sceneUser = (User)this.userService.getById(scene.getUserId());
|
|
|
+ if (!ObjectUtils.isEmpty(sceneUser.getCompanyId()) && this.gyCompanyId.equals(sceneUser.getCompanyId() + "")) {
|
|
|
+ this.gYUploadToOssUtil.uploadMulFiles(map);
|
|
|
+ this.gYUploadToOssUtil.upload("/mnt/4Dkankan/scene/data/data" + scene.getNum() + File.separator + "scene.json", "data/data" + scene.getNum() + File.separator + "scene.json");
|
|
|
+ this.gYUploadToOssUtil.upload("/mnt/4Dkankan/scene/images/images" + scene.getNum() + File.separator + "floorLogoImg.png", "images/images" + scene.getNum() + File.separator + "floorLogoImg.png");
|
|
|
+ this.gYUploadToOssUtil.upload("/mnt/4Dkankan/scene/images/images" + scene.getNum() + File.separator + "logo-main.png", "images/images" + scene.getNum() + File.separator + "logo-main.png");
|
|
|
+ this.gYUploadToOssUtil.upload("/mnt/4Dkankan/scene/images/images" + scene.getNum() + File.separator + "logo-main.png", "images/images" + scene.getNum() + File.separator + "logo-main-en.png");
|
|
|
+ SceneProEdit proEdit = this.sceneProEditService.findByProId(scene.getId());
|
|
|
+ if (!ObjectUtils.isEmpty(proEdit.getBgMusicName())) {
|
|
|
+ this.gYUploadToOssUtil.upload("/mnt/4Dkankan/scene/images/images" + scene.getNum() + File.separator + proEdit.getBgMusicName(), "images/images" + scene.getNum() + File.separator + proEdit.getBgMusicName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void afterBuild(BuildStatusEnum buildStatusEnum, BuildLog buildLog) {
|
|
|
+ try {
|
|
|
+ log.info("服务{} 计算结束:{},计算状态:{}", SysConstants.hostName, buildLog.getSceneNum(), buildStatusEnum.getDesc());
|
|
|
+ if (!buildStatusEnum.equals(BuildStatusEnum.REPEAT)) {
|
|
|
+ ScenePro scene = this.sceneProService.findBySceneNum(buildLog.getSceneNum());
|
|
|
+ if (scene != null) {
|
|
|
+ JSONObject statusJson = new JSONObject();
|
|
|
+ int status = scene.getStatus();
|
|
|
+ if (status == -2) {
|
|
|
+ status = 1;
|
|
|
+ } else if (status == -1) {
|
|
|
+ status = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ statusJson.put("status", status);
|
|
|
+ statusJson.put("webSite", scene.getWebSite());
|
|
|
+ statusJson.put("sceneNum", scene.getNum());
|
|
|
+ statusJson.put("thumb", scene.getThumb());
|
|
|
+ statusJson.put("payStatus", scene.getPayStatus());
|
|
|
+ FileUtils.writeFile("/mnt/4Dkankan/scene/data/data" + buildLog.getSceneNum() + File.separator + "status.json", statusJson.toString());
|
|
|
+ this.uploadToOssUtil.upload("/mnt/4Dkankan/scene/data/data" + buildLog.getSceneNum() + File.separator + "status.json", "data/data" + buildLog.getSceneNum() + File.separator + "status.json");
|
|
|
+ this.uploadToOssUtil.upload(scene.getDataSource() + File.separator + "console.log", "build_log/" + scene.getNum() + File.separator + "console.log");
|
|
|
+ buildLog.setLogDetailPath(this.prefixAli + "build_log/" + scene.getNum() + File.separator + "console.log");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ buildLog.setStatus(buildStatusEnum.getStatus());
|
|
|
+ switch (buildLog.getStatus()) {
|
|
|
+ case -2:
|
|
|
+ case -1:
|
|
|
+ this.handFail(buildStatusEnum.getDesc(), buildLog);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ this.handleSuccess(buildLog);
|
|
|
+ }
|
|
|
+ } catch (Exception var6) {
|
|
|
+ var6.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleSuccess(BuildLog buildLog) {
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handFail(String reason, BuildLog buildLog) {
|
|
|
+ this.sceneService.updateStatus(buildLog.getSceneNum(), -1);
|
|
|
+ this.sceneProService.updateStatus(buildLog.getSceneNum(), -1);
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ try {
|
|
|
+ DingDingUtils.sendMsgToDingRobot(reason, buildLog);
|
|
|
+ } catch (Exception var3) {
|
|
|
+ log.info("发送钉钉计算失败消息失败:", var3);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|