BuildSceneReceiver.java 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. //package com.fdkankan.modeling.receiver;
  2. //
  3. //import cn.hutool.core.date.DateUtil;
  4. //import com.alibaba.fastjson.JSONArray;
  5. //import com.alibaba.fastjson.JSONObject;
  6. //import com.fdkankan.common.util.ComputerUtil;
  7. //import com.fdkankan.modeling.constants.RedisKey;
  8. //import com.fdkankan.modeling.constants.SysConstants;
  9. //import com.fdkankan.modeling.entity.SceneFileBuild;
  10. //import com.fdkankan.modeling.entity.ScenePro;
  11. //import com.fdkankan.modeling.entity.SceneProExt;
  12. //import com.fdkankan.modeling.feign.UserFeign;
  13. //import com.fdkankan.modeling.push.PushMessageConfig;
  14. //import com.fdkankan.modeling.service.ISceneFileBuildService;
  15. //import com.fdkankan.modeling.service.ISceneProExtService;
  16. //import com.fdkankan.modeling.service.ISceneProService;
  17. //import com.fdkankan.modeling.service.ISceneService;
  18. //import com.fdkankan.modeling.utils.DingDingUtils;
  19. //import com.fdkankan.modeling.utils.PushMsgUtil;
  20. //import com.fdkankan.mq.message.BuildSceneMqMessage;
  21. //import com.fdkankan.common.util.UploadToOssUtil;
  22. //import com.fdkankan.platform.api.vo.User;
  23. //import com.fdkankan.redis.util.RedisUtil;
  24. //import com.fdkankan.common.constant.ConstantFilePath;
  25. //import com.fdkankan.common.constant.ConstantUrl;
  26. //import com.fdkankan.common.utils.CreateObjUtil;
  27. //import com.fdkankan.common.utils.FileUtil;
  28. //import com.fdkankan.common.utils.FileUtils;
  29. //import com.taobao.api.ApiException;
  30. //import lombok.extern.log4j.Log4j2;
  31. //import org.apache.commons.lang3.StringUtils;
  32. //import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
  33. //import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
  34. //import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
  35. //import org.apache.rocketmq.common.message.MessageExt;
  36. //import org.springframework.beans.factory.annotation.Autowired;
  37. //import org.springframework.beans.factory.annotation.Value;
  38. //import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  39. //import org.springframework.data.redis.core.RedisTemplate;
  40. //import org.springframework.stereotype.Component;
  41. //import org.springframework.util.CollectionUtils;
  42. //import org.springframework.util.ObjectUtils;
  43. //import org.springframework.web.client.RestTemplate;
  44. //
  45. //import javax.annotation.Resource;
  46. //import java.io.*;
  47. //import java.security.InvalidKeyException;
  48. //import java.security.NoSuchAlgorithmException;
  49. //import java.time.Duration;
  50. //import java.time.temporal.ChronoUnit;
  51. //import java.util.Date;
  52. //import java.util.HashMap;
  53. //import java.util.List;
  54. //import java.util.Map;
  55. //import java.util.concurrent.*;
  56. //
  57. //import static com.fdkankan.modeling.push.PushMessageConfig.*;
  58. //
  59. //
  60. //@Log4j2
  61. //@Component
  62. //@ConditionalOnProperty(name = "rabbitmq.queue.enable",havingValue = "true")
  63. //public class BuildSceneReceiver implements MessageListenerConcurrently {
  64. //
  65. // @Autowired
  66. // private ISceneService sceneService;
  67. // @Autowired
  68. // private ISceneProService sceneProService;
  69. // @Autowired
  70. // private UserFeign userFeign;
  71. // @Autowired
  72. // private ISceneFileBuildService sceneFileBuildService;
  73. //
  74. // @Autowired
  75. // private ISceneProExtService sceneProExtService;
  76. //
  77. // @Autowired
  78. // RedisUtil redisUtil;
  79. // @Autowired
  80. // RedisTemplate redisTemplate;
  81. //
  82. // private RestTemplate restTemplate = new RestTemplate();
  83. //
  84. // @Value("${4dkk.laserService.host}")
  85. // private String laserHost;
  86. //
  87. // @Value("${oss.type}")
  88. // private String ossType;
  89. //
  90. // @Value("${oss.url.prefix}")
  91. // private String prefixAli;
  92. //
  93. //
  94. // @Resource
  95. // private UploadToOssUtil uploadUtils;
  96. //
  97. // @Override
  98. // public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgExt,
  99. // ConsumeConcurrentlyContext consumeConcurrentlyContext) {
  100. // if (CollectionUtils.isEmpty(msgExt)) {
  101. // log.error("消息内容为空,退出构建,当前服务器id:{}", SysConstants.hostName);
  102. // return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
  103. // }
  104. // MessageExt messageExt = msgExt.get(0);
  105. // BuildSceneMqMessage message = JSONObject.parseObject(messageExt.getBody(), BuildSceneMqMessage.class);
  106. // log.info("开始处理消息,消息队列:{},消息内容:{}", consumeConcurrentlyContext.getMessageQueue().getTopic(),
  107. // JSONObject.toJSONString(message));
  108. // process(message);
  109. // return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
  110. // }
  111. //
  112. // public void process(BuildSceneMqMessage message) {
  113. // final ExecutorService exec = Executors.newFixedThreadPool(1);
  114. // Callable<String> call = (Callable<String>) () -> {
  115. // //开始执行耗时操作
  116. // try {
  117. // String key = RedisKey.SCENE_BUILDING + message.getSceneNum();
  118. // // 获取缓存锁,防止重复消费
  119. // Long building = redisUtil.incr(key, 1);
  120. // if (building.compareTo(1L) != 0) {
  121. // log.error("场景正在构建中,退出构建,当前服务器id:{},参数:{}", SysConstants.hostName, JSONObject.toJSONString(message));
  122. // } else {
  123. // redisTemplate.expire(key, Duration.of(SysConstants.modelTimeOut, ChronoUnit.HOURS));
  124. // }
  125. // //休眠2秒等待数据入库
  126. // Thread.sleep(2000L);
  127. // try {
  128. // FileUtils.writeFile("/opt/hosts/running.txt", DateUtil.formatDateTime(new Date()));
  129. // String tomcatLog = "scenenum:" + message.getSceneNum() + "\ntime:" + DateUtil.formatDateTime(new Date()) +
  130. // " action:create hostname:" + SysConstants.hostName;
  131. // //打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
  132. // FileWriter writer = new FileWriter("/mnt/elastic_log/tomcat" + "_" + message.getSceneNum() + ".log", true);
  133. // writer.write(tomcatLog);
  134. // writer.close();
  135. // } catch (Exception e) {
  136. // e.printStackTrace();
  137. // }
  138. //
  139. // buildScene(message);
  140. // redisUtil.del(key);
  141. // try {
  142. // FileUtils.deleteFile("/opt/hosts/running.txt");
  143. // String tomcatLog = "scenenum:" + message.getSceneNum() + "\ntime:" + DateUtil.formatDateTime(new Date()) +
  144. // " action:delete hostname:" + SysConstants.hostName;
  145. // //打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
  146. // FileWriter writer = new FileWriter("/mnt/elastic_log/tomcat" + "_" + message.getSceneNum() + "log", true);
  147. // writer.write(tomcatLog);
  148. // writer.close();
  149. // } catch (Exception e) {
  150. // e.printStackTrace();
  151. // }
  152. // } catch (Exception e) {
  153. // e.printStackTrace();
  154. // sceneService.updateStatus(message.getSceneNum(), -1);
  155. // BuildSceneReceiver.this.handFail("计算失败", message);
  156. // }
  157. // log.info("场景生成好了***");
  158. // return "success";
  159. // };
  160. // Future<String> future = exec.submit(call);
  161. // try {
  162. // future.get(SysConstants.modelTimeOut, TimeUnit.HOURS); //任务处理超时时间设为 24个小时
  163. // } catch (TimeoutException ex) {
  164. // ex.printStackTrace();
  165. // StringWriter trace=new StringWriter();
  166. // ex.printStackTrace(new PrintWriter(trace));
  167. // log.error("超时了");
  168. // log.error(trace.toString());
  169. // FileUtils.deleteFile("/opt/hosts/running.txt");
  170. // future.cancel(true);
  171. // handFail("计算超时",message);
  172. // } catch (Exception e) {
  173. // e.printStackTrace();
  174. // StringWriter trace=new StringWriter();
  175. // e.printStackTrace(new PrintWriter(trace));
  176. // log.error(trace.toString());
  177. // FileUtils.deleteFile("/opt/hosts/running.txt");
  178. // future.cancel(true);
  179. // handFail("计算失败",message);
  180. // }
  181. //
  182. // }
  183. //
  184. // private void buildScene(BuildSceneMqMessage message){
  185. // String projectNum = null;
  186. // SceneFileBuild sceneFileBuildEntity = null;
  187. // ScenePro scene = null;
  188. // SceneProExt sceneProExt = null;
  189. // try{
  190. // if(StringUtils.equals(message.getIsStandardization(),"1")){
  191. // //表示标定算法
  192. // ComputerUtil.computerCalibration(message.getPath());
  193. // return;
  194. // }
  195. //
  196. // String unicode = message.getUnicode();
  197. // String path = message.getPath();
  198. // String prefix = message.getPrefix();
  199. // String imgsName = message.getImgsName();
  200. // projectNum = message.getSceneNum();
  201. // String userName = message.getUserName();
  202. // //不同的相机不同的方法
  203. // String cameraType = message.getCameraType();
  204. // String algorithm = message.getAlgorithm();
  205. // String fileId = message.getFileId();
  206. // String cameraName = message.getCameraName();
  207. // //0表示有4k图,1表示没有
  208. // String resolution = message.getResolution();
  209. //
  210. // //判断调用V2还是V3版本的算法
  211. // String buildType = ObjectUtils.isEmpty(message.getBuildType()) ? "V2" : message.getBuildType();
  212. //
  213. //
  214. // log.info("执行数据库操作--前");
  215. // // TODO: 2022/1/6 这里从消息体中取出
  216. // sceneFileBuildEntity = sceneFileBuildService.findByFileId(fileId);
  217. // log.info("执行数据库操作--后");
  218. //
  219. // Map<String, String> dataMap = ComputerUtil.getTypeString(cameraType, algorithm,
  220. // resolution);
  221. // String splitType = dataMap.get("splitType");
  222. // String skyboxType = dataMap.get("skyboxType");
  223. // String dataDescribe = dataMap.get("dataDescribe");
  224. //
  225. // log.info("用的算法是:"+algorithm);
  226. // log.info("用的相机是:"+ (Integer.parseInt(cameraType) < 4 ? "单球目" : "双球目(八目)"));
  227. // Map<String,String> map = new HashMap<>();
  228. //
  229. // //该场景使用的容量
  230. // Long space = 0L;
  231. // //支付状态
  232. // int payStatus = 0;
  233. // //4表示硬件部研发的双球目相机,其余为旧版本相机
  234. // if(Integer.parseInt(cameraType) < 3){
  235. //
  236. // for(int i = 0;i<5;++i){
  237. // try{
  238. // FileUtils.downLoadFromUrl(prefix+imgsName+"?m="+new Date().getTime(), imgsName,
  239. // path + File.separator + "capture");
  240. // FileUtils.decompress(path + File.separator + "capture" +File.separator+imgsName,
  241. // path + File.separator + "capture") ;
  242. // break;
  243. // }
  244. // catch(Exception e){
  245. // e.printStackTrace();
  246. // StringWriter trace=new StringWriter();
  247. // e.printStackTrace(new PrintWriter(trace));
  248. // log.error(trace.toString());
  249. // if(i<4)
  250. // {
  251. // FileUtils.deleteFile(path + File.separator + "capture" +File.separator+imgsName);
  252. // FileUtils.delFolder(path + File.separator + "capture" +File.separator+"images");
  253. // }
  254. // Thread.sleep(10000);
  255. // }
  256. // }
  257. //
  258. // FileUtils.deleteFile(path + File.separator + "capture" +File.separator+"zip.Zip");
  259. //
  260. // String data = FileUtils.readFile(path + File.separator + "capture" +File.separator+"data.fdage");
  261. // JSONObject dataJson = new JSONObject();
  262. // if(data!=null){
  263. // dataJson = JSONObject.parseObject(data);
  264. // if(dataJson.containsKey("imgs")){
  265. // splitType = "SPLIT_V4";
  266. // }
  267. // }
  268. // //生成project.json和data.json供算法部使用
  269. // ComputerUtil.createJson(path, splitType, skyboxType, dataDescribe, projectNum, path);
  270. // //计算模型并返回需要上传oss的文件集合
  271. // map = ComputerUtil.computer(projectNum, path, buildType);
  272. //
  273. // uploadUtils.uploadMulFiles(map);
  274. // log.info("双目上完oss结束修改数据:"+projectNum);
  275. // sceneService.updateTime(projectNum, space, payStatus);
  276. // } else {
  277. //
  278. // //休眠1秒,否则可能获取不到场景资源
  279. // Thread.sleep(1000);
  280. // scene = sceneProService.findBySceneNum(projectNum);
  281. // sceneProExt = sceneProExtService.getBySceneProId(scene.getId());
  282. // if(scene == null){
  283. // log.info(projectNum + ":场景不存在");
  284. // handFail("场景不存在",message);
  285. // return;
  286. // }
  287. //
  288. // long start = System.currentTimeMillis();
  289. //
  290. // //cameraType=5为新版本双目, cameraType=6为小红屋新版本双目
  291. // if(Integer.parseInt(cameraType) == 5 || Integer.parseInt(cameraType) == 6){
  292. // path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
  293. //
  294. // //下载zip包,并解压
  295. // FileUtils.downLoadFromUrl(prefix + "/" + imgsName + "?m=" + System.currentTimeMillis(), imgsName, path + File.separator + "capture");
  296. // FileUtils.decompress(path + File.separator + "capture" + File.separator + imgsName,
  297. // path + File.separator + "capture") ;
  298. // FileUtil.delFile(path + File.separator + "capture" + File.separator + imgsName);
  299. // }else if(Integer.parseInt(cameraType) == 14 ) {
  300. // CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + cameraName.replace("4DKKPRO_", "")
  301. // .replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator
  302. // + unicode + File.separator,
  303. // ConstantFilePath.BUILD_MODEL_LASER_PATH + cameraName.replace("4DKKPRO_", "")
  304. // .replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator
  305. // + unicode + File.separator + "capture");
  306. // path = ConstantFilePath.BUILD_MODEL_LASER_PATH + cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode;
  307. // } else if(Integer.parseInt(cameraType) >= 4 ) {
  308. // CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + cameraName.replace("4DKKPRO_", "")
  309. // .replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator
  310. // + unicode + File.separator,
  311. // ConstantFilePath.BUILD_MODEL_PATH + cameraName.replace("4DKKPRO_", "")
  312. // .replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator
  313. // + unicode + File.separator + "capture");
  314. // path = ConstantFilePath.BUILD_MODEL_PATH + cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode;
  315. // }
  316. // String data = FileUtils.readFile(path + File.separator + "capture" +File.separator+"data.fdage");
  317. // //获取data.fdage的内容
  318. // JSONObject dataJson = new JSONObject();
  319. // if(data!=null){
  320. // dataJson = JSONObject.parseObject(data);
  321. // }
  322. // //判断是否计算过资源,若计算过删除缓存
  323. // File caches = new File(path + File.separator + "caches");
  324. // if(caches.exists()){
  325. // for(File deleteFile : caches.listFiles()){
  326. // if(new File(path + "_images").exists()){
  327. // if(deleteFile.isDirectory()){
  328. // FileUtils.delAllFile(deleteFile.getAbsolutePath());
  329. // }else {
  330. // FileUtils.deleteFile(deleteFile.getAbsolutePath());
  331. // }
  332. // }
  333. // else if(!deleteFile.getAbsolutePath().contains("images")){
  334. // if(deleteFile.isDirectory()){
  335. // FileUtils.delAllFile(deleteFile.getAbsolutePath());
  336. // }else {
  337. // FileUtils.deleteFile(deleteFile.getAbsolutePath());
  338. // }
  339. // }
  340. // }
  341. // }
  342. // if(new File(path + File.separator + "results").exists()){
  343. // FileUtils.delAllFile(path + File.separator + "results");
  344. // }
  345. //
  346. // //生成project.json和data.json供算法部使用
  347. // log.info("path:" + path);
  348. //
  349. // if(dataJson.containsKey("videoVersion") && StringUtils.isNotEmpty(dataJson.getString("videoVersion")) && Integer.parseInt(dataJson.getString("videoVersion")) < 4){
  350. // //v2版本使用4k算法
  351. // skyboxType = "SKYBOX_V6";
  352. // }
  353. //
  354. // ComputerUtil.createJson(path, splitType, skyboxType, dataDescribe, projectNum, path);
  355. // //计算模型并返回需要上传oss的文件集合
  356. // map = ComputerUtil.computer(projectNum, path, buildType);
  357. //
  358. // if(Integer.parseInt(cameraType) == 5 || Integer.parseInt(cameraType) == 6){
  359. // map.put(path + File.separator + "capture/stitch_params.txt", "data/data" + projectNum + "/stitch_params.txt");
  360. // }
  361. // map.put(path + File.separator + "capture/Up.xml", "data/data" + projectNum + "/Up.xml");
  362. // map.put(path + File.separator + "capture/Up2.xml", "data/data" + projectNum + "/Up2.xml");
  363. //
  364. // if(Integer.parseInt(cameraType) == 13){
  365. // //转台相机
  366. // map.put(path + File.separator + "capture/Up.txt", "data/data" + projectNum + "/Up.txt");
  367. // map.put(path + File.separator + "capture/Up2.txt", "data/data" + projectNum + "/Up2.txt");
  368. // }
  369. //
  370. // uploadUtils.uploadMulFiles(map);
  371. // payStatus = 1;
  372. //
  373. // File spaceFile = null;
  374. // for (String key : map.keySet()) {
  375. // spaceFile = new File(key);
  376. // if(spaceFile.exists()){
  377. // space += spaceFile.length();
  378. // }
  379. // }
  380. //
  381. // log.info("八目上完oss结束修改数据:"+projectNum);
  382. //
  383. // //获取upload中的video视频名称
  384. // String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
  385. // com.alibaba.fastjson.JSONObject uploadJson = null;
  386. // JSONArray array = null;
  387. // if(uploadData!=null) {
  388. // uploadJson = com.alibaba.fastjson.JSONObject.parseObject(uploadData);
  389. // array = uploadJson.getJSONArray("upload");
  390. // }
  391. // com.alibaba.fastjson.JSONObject fileJson = null;
  392. // String fileName = "";
  393. //
  394. // //读取videos_hdr_param.json, 保存点位视频的value
  395. // Map<String, Object> videoMap = new HashMap<>();
  396. // String videosHdr = FileUtils.readFile(path + File.separator + "results/videos/videos_hdr_param.json");
  397. // JSONArray videoArray = null;
  398. // if(StringUtils.isNotEmpty(videosHdr)){
  399. // videoArray = com.alibaba.fastjson.JSONObject.parseObject(videosHdr).getJSONArray("hdr_param");
  400. // }
  401. // if(videoArray != null){
  402. // for(int i = 0, len = videoArray.size(); i < len; i++) {
  403. // videoMap.put(videoArray.getJSONObject(i).getString("name"), videoArray.getJSONObject(i).getString("value"));
  404. // if(videoArray.getJSONObject(i).containsKey("fov")){
  405. // videoMap.put(videoArray.getJSONObject(i).getString("name") + "_fov", videoArray.getJSONObject(i).getString("fov"));
  406. // }
  407. // }
  408. // }
  409. //
  410. // //计算ts文件的大小,并拼接成json格式
  411. // JSONArray jsonArray = new JSONArray();
  412. // com.alibaba.fastjson.JSONObject videoJson = null;
  413. // com.alibaba.fastjson.JSONObject videosJson = new com.alibaba.fastjson.JSONObject();
  414. // long videoSize = 0L;
  415. // for(int i = 0, len = array.size(); i < len; i++) {
  416. // fileJson = array.getJSONObject(i);
  417. // fileName = fileJson.getString("file");
  418. // if(fileJson.getIntValue("clazz") == 11 && fileName.contains(".mp4") && !fileName.contains("-ios.mp4")){
  419. // videoJson = new com.alibaba.fastjson.JSONObject();
  420. // videoJson.put("id", fileName.substring(
  421. // 0, fileName.lastIndexOf(".")).replace("videos/", ""));
  422. //
  423. // //如果ts文件存在,就计算ts大小
  424. // if(new File(path + File.separator + "results" +File.separator+ fileName.replace(".mp4", ".ts")).exists()){
  425. // videoSize = new File(path + File.separator + "results" +File.separator+ fileName.replace(".mp4", ".ts")).length();
  426. // videoJson.put("tsSize", videoSize);
  427. // }
  428. // if(videoMap.containsKey(videoJson.get("id"))){
  429. // videoJson.put("value", videoMap.get(videoJson.get("id")));
  430. // }
  431. // if(videoMap.containsKey(videoJson.get("id") + "_fov")){
  432. // videoJson.put("blend_fov", videoMap.get(videoJson.get("id") + "_fov"));
  433. // }else {
  434. // videoJson.put("blend_fov", 7);
  435. // }
  436. // jsonArray.add(videoJson);
  437. // }
  438. // }
  439. //
  440. // videosJson.put("data", jsonArray);
  441. // if(dataJson.containsKey("videoVersion") && StringUtils.isNotEmpty(dataJson.getString("videoVersion")) && Integer.parseInt(dataJson.getString("videoVersion")) >= 4){
  442. // videosJson.put("version", 3);
  443. // if("oss".equals(ossType)){
  444. // videosJson.put("upPath", prefixAli + "data/data" + projectNum + "/Up.xml");
  445. // }
  446. // if("s3".equals(ossType)){
  447. // videosJson.put("upPath", ConstantUrl.PREFIX_AWS + "data/data" + projectNum + "/Up.xml");
  448. // }
  449. // if(Integer.parseInt(cameraType) == 13){
  450. // //转台相机
  451. // videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
  452. // }
  453. // }else {
  454. // videosJson.put("version", 1);
  455. // if("oss".equals(ossType)){
  456. // videosJson.put("upPath", prefixAli + "data/data" + projectNum + "/Up2.xml");
  457. // }
  458. // if("s3".equals(ossType)){
  459. // videosJson.put("upPath", ConstantUrl.PREFIX_AWS + "data/data" + projectNum + "/Up2.xml");
  460. // }
  461. //
  462. // if(Integer.parseInt(cameraType) == 13){
  463. // //转台相机
  464. // videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
  465. // }
  466. // }
  467. //
  468. // if(Integer.parseInt(cameraType) == 5 || Integer.parseInt(cameraType) == 6){
  469. // videosJson.put("version", 1);
  470. // if("oss".equals(ossType)){
  471. // videosJson.put("upPath", prefixAli + "data/data" + projectNum + "/stitch_params.txt");
  472. // }
  473. // if("s3".equals(ossType)){
  474. // videosJson.put("upPath", ConstantUrl.PREFIX_AWS + "data/data" + projectNum + "/stitch_params.txt");
  475. // }
  476. // }
  477. //
  478. // long computeTime = (System.currentTimeMillis() - start) / 1000;
  479. // sceneProService.updateTime(projectNum, space, payStatus, videosJson.toJSONString(), computeTime);
  480. //
  481. // //更新scene.json里面的video数据
  482. // StringBuffer dataBuf = new StringBuffer()
  483. // .append("data").append(File.separator)
  484. // .append("data").append(projectNum)
  485. // .append(File.separator);
  486. // StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf.toString());
  487. // String strsceneInfos = FileUtils.readFile(dataBuffer.toString() + "scene.json");
  488. // com.alibaba.fastjson.JSONObject scenejson = new com.alibaba.fastjson.JSONObject();
  489. // if(strsceneInfos!=null){
  490. // scenejson = com.alibaba.fastjson.JSONObject.parseObject(strsceneInfos);
  491. // }
  492. // scenejson.put("videos", videosJson.toJSONString());
  493. // FileUtils.writeFile(dataBuffer.toString() + "scene.json", scenejson.toString());
  494. //
  495. // User userEntity = userFeign.findByUserName(userName);
  496. // if(userEntity == null){
  497. // userFeign.updateUserUsedSpaceBySceneNum(null, projectNum);
  498. // }else {
  499. // userFeign.updateUserUsedSpaceBySceneNum(userEntity.getId(), projectNum);
  500. // }
  501. // if (sceneFileBuildEntity != null){
  502. // sceneFileBuildEntity.setBuildStatus(3);
  503. // sceneFileBuildService.updateById(sceneFileBuildEntity);
  504. // }
  505. //
  506. // //根据data.fdage推送计算完成的消息
  507. // log.info("推送消息,渠道是 {}, 手机token是 {}", dataJson.get("pushChannel"), dataJson.get("pushToken"));
  508. // if(dataJson.containsKey("pushChannel") && dataJson.containsKey("pushToken")){
  509. // try{
  510. // if(!"s3".equals(ossType)){
  511. // PushMessageConfig demo = null;
  512. // if(dataJson.getIntValue("pushChannel") == 0){
  513. //
  514. // if(Integer.parseInt(cameraType) == 10 || Integer.parseInt(cameraType) == 13){
  515. // //ios
  516. // log.info("IOS_KEY:{}, IOS_SECRET:{}", IOS_KEY_Z, IOS_SECRET_Z);
  517. // demo = new PushMessageConfig(IOS_KEY_Z, IOS_SECRET_Z);
  518. // demo.sendIOSUnicast(dataJson.getString("pushToken"),
  519. // "四维看看Minion", scene.getSceneName() + "计算完成", "您上传的" + scene.getSceneName() + "计算完成,点击查看",
  520. // scene.getWebSite());
  521. // }else {
  522. // //ios
  523. // log.info("IOS_KEY:{}, IOS_SECRET:{}", IOS_KEY, IOS_SECRET);
  524. // demo = new PushMessageConfig(IOS_KEY, IOS_SECRET);
  525. // demo.sendIOSUnicast(dataJson.getString("pushToken"),
  526. // "四维看看Pro", scene.getSceneName() + "计算完成", "您上传的" + scene.getSceneName() + "计算完成,点击查看",
  527. // scene.getWebSite());
  528. // }
  529. //
  530. // }else {
  531. // if(Integer.parseInt(cameraType) == 10 || Integer.parseInt(cameraType) == 13){
  532. // //ios
  533. // //安卓
  534. // log.info("ANDROID_KEY:{}, ANDROID_SECRET:{}", ANDROID_KEY_Z, ANDROID_SECRET_Z);
  535. // demo = new PushMessageConfig(ANDROID_KEY_Z, ANDROID_SECRET_Z);
  536. // demo.sendAndroidUnicast2(dataJson.getString("pushToken"),
  537. // "四维看看Minion", scene.getSceneName() + "计算完成", "您上传的" + scene.getSceneName() + "计算完成,点击查看",
  538. // scene.getWebSite());
  539. // }else {
  540. // //安卓
  541. // log.info("ANDROID_KEY:{}, ANDROID_SECRET:{}", ANDROID_KEY, ANDROID_SECRET);
  542. // demo = new PushMessageConfig(ANDROID_KEY, ANDROID_SECRET);
  543. // demo.sendAndroidUnicast(dataJson.getString("pushToken"),
  544. // "四维看看Pro", scene.getSceneName() + "计算完成", "您上传的" + scene.getSceneName() + "计算完成,点击查看",
  545. // scene.getWebSite());
  546. // }
  547. // }
  548. //
  549. // }else {
  550. // PushMsgUtil.googlePushMsg(dataJson.getString("pushToken"),
  551. // scene.getSceneName() + "计算完成", "您上传的" + scene.getSceneName() + "计算完成,点击查看",
  552. // scene.getWebSite());
  553. // }
  554. // log.info("消息推送结束!");
  555. // }catch (Exception e){
  556. // log.info("推送消息失败:");
  557. // e.printStackTrace();
  558. // }
  559. // }
  560. //
  561. // //计算成功 激光转台相机推送
  562. // log.info("激光转台相机 同步 请求 ");
  563. // if(Integer.parseInt(cameraType) == 14){
  564. // try {
  565. // String title = "";
  566. // if(StringUtils.isNotEmpty(scene.getSceneName())){
  567. // title = scene.getSceneName();
  568. // }
  569. // String dataSource = sceneProExt.getDataSource();
  570. // String jgPath = dataSource;
  571. // //创建目录
  572. // if(dataSource.lastIndexOf("/")!=-1){
  573. // jgPath = jgPath + "_laserData";
  574. // }else{
  575. // jgPath = jgPath.substring(0,jgPath.length()-1) + "_laserData";
  576. // }
  577. //
  578. // FileUtils.createDir(jgPath+"/extras");
  579. //
  580. // log.info("生成 激光相机目录 " + jgPath);
  581. // //生成data.json
  582. // JSONObject jgDataJson = new JSONObject();
  583. // jgDataJson.put("split_type", "SPLIT_V15");
  584. // jgDataJson.put("skybox_type", "SKYBOX_V5");
  585. // jgDataJson.put("extras", null);
  586. // FileUtils.writeFile(jgPath + File.separator + "data.json", jgDataJson.toString());
  587. //
  588. // CreateObjUtil.cpfile(dataSource + "/results/laserData/cover", jgPath+"/extras/");
  589. // CreateObjUtil.cplaserfile(dataSource + "/results/laserData", jgPath+File.separator);
  590. //
  591. // //激光相机
  592. // String url = laserHost+"/indoor/{sceneCode}/api/init?path="
  593. // + jgPath + File.separator + "laserData" + "&title="+ title
  594. // + "&childName=" + cameraName + "&createTime=" + scene.getCreateTime()
  595. // + "&snCode="+ cameraName;
  596. //
  597. // if(scene.getUserId()!=null){
  598. // url = url + "&userId=" + scene.getUserId();
  599. // }
  600. //
  601. // if(StringUtils.isNotEmpty(userName)){
  602. // url = url + "&phone=" + userName;
  603. // }
  604. //
  605. // url = url.replace("{sceneCode}",scene.getSceneCode());
  606. // log.info("激光转台相机 同步 :" + url);
  607. // com.alibaba.fastjson.JSONObject hotListJson =
  608. // com.alibaba.fastjson.JSONObject.parseObject(restTemplate.getForObject(url,String.class));
  609. // log.info("激光转台相机 同步结束 :" + hotListJson);
  610. // }catch (Exception e){
  611. // e.printStackTrace();
  612. // handFail("激光转台相机同步失败",message);
  613. // }
  614. // }
  615. // }
  616. //
  617. // CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
  618. // } catch(Exception e){
  619. // log.error("计算大场景失败"+projectNum);
  620. // sceneService.updateStatus(projectNum, -1);
  621. // if (sceneFileBuildEntity != null){
  622. // sceneFileBuildEntity.setBuildStatus(-1);
  623. // sceneFileBuildService.updateById(sceneFileBuildEntity);
  624. // }
  625. // e.printStackTrace();
  626. // StringWriter trace=new StringWriter();
  627. // e.printStackTrace(new PrintWriter(trace));
  628. // log.error(trace.toString());
  629. // handFail("计算失败",message);
  630. // }finally {
  631. // try{
  632. // scene = sceneProService.findBySceneNum(projectNum);
  633. // if(scene != null){
  634. // com.alibaba.fastjson.JSONObject statusJson = new com.alibaba.fastjson.JSONObject();
  635. // //临时将-2改成1,app还没完全更新
  636. // int status = sceneProExt.getSceneStatus();
  637. // if(status == -2){
  638. // status = 1;
  639. // }else if(status == -1){
  640. // // 失败状态不予显示到客户端
  641. // status = 0;
  642. // }
  643. // statusJson.put("status", status);
  644. // statusJson.put("webSite", scene.getWebSite());
  645. // statusJson.put("sceneNum", scene.getSceneCode());
  646. // statusJson.put("thumb", scene.getThumb());
  647. // statusJson.put("payStatus", sceneProExt.getPayStatus());
  648. // FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"status.json", statusJson.toString());
  649. // uploadUtils.upload(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"status.json",
  650. // "data/data"+projectNum+File.separator+"status.json");
  651. //
  652. // //上送日志
  653. // uploadUtils.upload(sceneProExt.getDataSource()+File.separator+"console.log",
  654. // "build_log/"+scene.getSceneCode()+File.separator+"console.log");
  655. //
  656. //
  657. // }
  658. // }catch (Exception e){
  659. // e.printStackTrace();
  660. // }
  661. // }
  662. // }
  663. //
  664. // private void handFail(String reason,BuildSceneMqMessage message){
  665. // String serverPath = message.getPath().substring(0,message.getPath().lastIndexOf("/")+1).concat(message.getPrefix());
  666. // handFail(reason,serverPath,message.getSceneNum());
  667. // }
  668. //
  669. // private void handFail(String reason,String serverPath,String num){
  670. // // 释放缓存锁
  671. // redisTemplate.delete(RedisKey.SCENE_BUILDING + num);
  672. // CompletableFuture.runAsync(() -> {
  673. // try {
  674. // DingDingUtils.sendMsgToDingRobot(reason,serverPath,num);
  675. // } catch (ApiException | UnsupportedEncodingException | NoSuchAlgorithmException | InvalidKeyException apiException) {
  676. // apiException.printStackTrace();
  677. // }
  678. // });
  679. // }
  680. //}