BuildSceneServiceImpl.java 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. package com.fdkankan.contro.mq.service.impl;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.io.FileUtil;
  4. import cn.hutool.core.util.StrUtil;
  5. import cn.hutool.extra.qrcode.QrCodeUtil;
  6. import cn.hutool.extra.qrcode.QrConfig;
  7. import cn.hutool.http.ContentType;
  8. import cn.hutool.http.HttpUtil;
  9. import com.alibaba.fastjson.JSON;
  10. import com.alibaba.fastjson.JSONArray;
  11. import com.alibaba.fastjson.JSONObject;
  12. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  13. import com.fdkankan.common.constant.*;
  14. import com.fdkankan.common.util.DateUtil;
  15. import com.fdkankan.common.util.FileUtils;
  16. import com.fdkankan.contro.bean.SyncLaserResultBean;
  17. import com.fdkankan.contro.constant.UserEditDataType;
  18. import com.fdkankan.contro.entity.*;
  19. import com.fdkankan.contro.mq.service.IBuildSceneService;
  20. import com.fdkankan.contro.service.*;
  21. import com.fdkankan.contro.util.HttpUtilExt;
  22. import com.fdkankan.fyun.config.FYunFileConfig;
  23. import com.fdkankan.fyun.constant.FYunTypeEnum;
  24. import com.fdkankan.fyun.face.FYunFileServiceInterface;
  25. import com.fdkankan.model.constants.ConstantFileName;
  26. import com.fdkankan.model.constants.ConstantFilePath;
  27. import com.fdkankan.model.constants.UploadFilePath;
  28. import com.fdkankan.model.enums.ModelTypeEnums;
  29. import com.fdkankan.model.utils.CreateHouseJsonUtil;
  30. import com.fdkankan.model.utils.CreateObjUtil;
  31. import com.fdkankan.model.utils.SceneUtil;
  32. import com.fdkankan.push.config.PushMessageConfig;
  33. import com.fdkankan.push.utils.PushMsgUtil;
  34. import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
  35. import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
  36. import com.fdkankan.rabbitmq.util.RabbitMqProducer;
  37. import com.fdkankan.redis.constant.RedisKey;
  38. import com.fdkankan.redis.util.RedisUtil;
  39. import lombok.extern.slf4j.Slf4j;
  40. import org.apache.commons.lang3.ObjectUtils;
  41. import org.apache.commons.lang3.StringUtils;
  42. import org.apache.http.HttpHeaders;
  43. import org.springframework.beans.factory.annotation.Autowired;
  44. import org.springframework.beans.factory.annotation.Value;
  45. import org.springframework.cloud.context.config.annotation.RefreshScope;
  46. import org.springframework.stereotype.Service;
  47. import javax.annotation.Resource;
  48. import java.io.File;
  49. import java.io.IOException;
  50. import java.util.*;
  51. import java.util.Map.Entry;
  52. import java.util.stream.Collectors;
  53. /**
  54. * <p>
  55. * </p>
  56. *
  57. * @author dengsixing
  58. * @since 2022/4/20
  59. **/
  60. @Slf4j
  61. @Service
  62. @RefreshScope
  63. public class BuildSceneServiceImpl implements IBuildSceneService {
  64. @Value("${queue.modeling.modeling-call}")
  65. private String queueModelingCall;
  66. @Value("${queue.modeling.single.modeling-call}")
  67. private String singleModelingCall;
  68. @Value("${model.type:#{null}}")
  69. private String modelType;
  70. @Value("${model.modelKind:3dtiles}")
  71. private String modelKind;
  72. @Value("#{'${model.3dtiles.sceneSource:}'.split(',')}")
  73. private List<Integer> sdTilesSceneSourceList;
  74. @Value("${env:gn}")
  75. private String env;
  76. @Value("#{'${build.scene.post.not-delete-nas-nums:}'.split(',')}")
  77. private List<String> notDeleteNasNumList;
  78. @Value("4dkk.laserService.bucket")
  79. private String laserBucket;
  80. @Autowired
  81. private RabbitMqProducer mqProducer;
  82. @Resource
  83. private FYunFileServiceInterface fYunFileService;
  84. @Autowired
  85. private ICameraDetailService cameraDetailService;
  86. @Autowired
  87. private ISceneEditInfoService sceneEditInfoService;
  88. @Autowired
  89. private ISceneEditControlsService sceneEditControlsService;
  90. @Autowired
  91. private FYunFileConfig fYunFileConfig;
  92. @Autowired
  93. private RedisUtil redisUtil;
  94. @Autowired
  95. private IScenePlusService scenePlusService;
  96. @Autowired
  97. private IScenePlusExtService scenePlusExtService;
  98. @Autowired
  99. private ISceneEditInfoExtService sceneEditInfoExtService;
  100. @Autowired
  101. private IUserIncrementService userIncrementService;
  102. @Autowired
  103. private IFdkkLaserService fdkkLaserService;
  104. // @Autowired
  105. // private IBuildSceneDTService buildSceneDTService;
  106. @Autowired
  107. private IIncrementTypeService incrementTypeService;
  108. @Autowired
  109. private ICompanyService companyService;
  110. @Autowired
  111. private ISceneAsynOperLogService sceneAsynOperLogService;
  112. @Autowired
  113. private ICommonService commonService;
  114. @Autowired
  115. private ISceneBuildProcessLogService sceneBuildProcessLogService;
  116. @Autowired
  117. private ISceneColdStorageService sceneColdStorageService;
  118. @Autowired
  119. private IOrigFileUploadBatchService origFileUploadBatchService;
  120. @Autowired
  121. private IOrigFileUploadService origFileUploadService;
  122. @Autowired
  123. private ILinkPanService linkPanService;
  124. @Autowired
  125. private IJmgaService jmgaService;
  126. private IHaixinService haixinService;
  127. @Override
  128. public void buildScenePre(BuildSceneCallMessage message) throws Exception{
  129. boolean success = false;
  130. String num = message.getSceneNum();
  131. String filename = (String)message.getExt().get("filename");
  132. try {
  133. //重新计算时需要删除文件夹,否知使用缓存
  134. if(new File(message.getPath() + File.separator + "results").exists()){
  135. FileUtils.deleteDirectory(message.getPath() + File.separator + "results");
  136. }
  137. //由于刘强说caches会影响计算结果,所以这里删除caches
  138. if(new File(message.getPath() + File.separator + "caches").exists()){
  139. FileUtils.deleteDirectory(message.getPath() + File.separator + "caches");
  140. }
  141. //删除project.json文件
  142. FileUtil.del(message.getPath().concat(File.separator).concat("project.json"));
  143. //删除点位校准数据
  144. if (Objects.nonNull(message.getExt())
  145. && message.getExt().containsKey("deleteExtras")
  146. && (Boolean) message.getExt().get("deleteExtras")) {
  147. String extras = String.format(UploadFilePath.scene_result_data_path, num).concat("extras");
  148. if(CollUtil.isNotEmpty(fYunFileService.listRemoteFiles(extras))){
  149. fYunFileService.deleteFolder(extras);
  150. }
  151. FileUtil.del(message.getPath() + "/extras");
  152. }
  153. //下载资源到本地
  154. this.downLoadSource(message, message.getPath());
  155. List<String> linkPanTargetList = linkPanService.genLinkPanPre(num);
  156. if(CollUtil.isNotEmpty(linkPanTargetList)){
  157. Map<String, Object> ext = message.getExt();
  158. if(Objects.isNull(ext)){
  159. ext = new HashMap<>();
  160. message.setExt(ext);
  161. }
  162. ext.put("linkPanTargetList", linkPanTargetList);
  163. }
  164. JSONObject fdageJson = JSONObject.parseObject(FileUtils.readFile(message.getPath().concat("/capture/data.fdage")));
  165. boolean rewrite = false;
  166. // 兼容旧的数据,防止OnlyExportMeshObj标志未删除掉
  167. if (fdageJson.containsKey("OnlyExportMeshObj")) {
  168. log.info("data.fdage 包含 OnlyExportMeshObj,进行去除!");
  169. // 写入data.fdage 防止重算
  170. fdageJson.remove("OnlyExportMeshObj");
  171. String ossPath = getOssPath(message.getPath());
  172. fYunFileService.uploadFile(fdageJson.toJSONString().getBytes(), ossPath + "data.fdage");
  173. rewrite = true;
  174. }
  175. if (!ObjectUtils.isEmpty(modelType)) {
  176. // 修改dataFdage文件
  177. fdageJson.put("modelType", modelType);
  178. rewrite = true;
  179. }
  180. if (rewrite) {
  181. FileUtils.writeFile(message.getPath().concat("/capture/data.fdage"), fdageJson.toJSONString());
  182. }
  183. message.getBuildContext().put("cameraType",message.getCameraType());
  184. //查询是否超过比例50%,如果超过,则启动128G服务器弹性伸缩
  185. Float maxRate = fdageJson.getFloat("maxRate");
  186. if(env.equals("gn") && Objects.nonNull(maxRate) && maxRate > 50){
  187. Map<String, Object> ext = message.getExt();
  188. if(Objects.isNull(ext)){
  189. ext = new HashMap<>();
  190. message.setExt(ext);
  191. }
  192. ext.put("128G", 1);
  193. }
  194. mqProducer.sendByWorkQueue(queueModelingCall, message);
  195. log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
  196. }catch (Exception e){
  197. log.error("场景计算前置处理出错,num"+num, e);
  198. this.sendFailToLaser(num);
  199. haixinService.noticHaixin(num, false);
  200. throw e;
  201. }
  202. }
  203. private void downloadOrigFile(String batchId, String dataSource){
  204. if(StrUtil.isEmpty(batchId)){
  205. return;
  206. }
  207. List<OrigFileUpload> fileList = origFileUploadService.getByBatchId(batchId);
  208. if(CollUtil.isEmpty(fileList)){
  209. return;
  210. }
  211. String homePath = "/oss/4dkankan/" + SceneUtil.getHomePath(dataSource);
  212. for (OrigFileUpload origFileUpload : fileList) {
  213. int times = 0;
  214. String filePath = homePath.concat(origFileUpload.getFileName());
  215. do{
  216. try {
  217. ++times;
  218. HttpUtil.downloadFile(origFileUpload.getFileUrl(), new File(filePath), 10 * 60 * 1000);
  219. if(FileUtil.exist(filePath)){
  220. break;
  221. }
  222. }catch (Exception e){
  223. log.info("原始文件第{}次下载失败,fileUrl:{}, filePath:{}", origFileUpload.getFileUrl(), filePath);
  224. }
  225. }while (times < 4);
  226. if(!FileUtil.exist(filePath)){
  227. throw new RuntimeException("原始文件下载失败,fileUrl:" + origFileUpload.getFileUrl() + ", filePath:" + filePath);
  228. }
  229. }
  230. }
  231. private void downloadOrigFile4Yzl(String batchId, String dataSource){
  232. if(StrUtil.isEmpty(batchId)){
  233. return;
  234. }
  235. OrigFileUpload sceneUpData = origFileUploadService.getByBatchIdAndFileName(batchId, "scene_up_data.txt");
  236. String sceneUpDataPath = dataSource + "/" + "scene_up_data.txt";
  237. HttpUtilExt.downloadFileAndCheck(sceneUpData.getFileUrl(), sceneUpDataPath, 60000);
  238. String sceneUpDataStr = FileUtil.readUtf8String(sceneUpDataPath);
  239. JSONArray fileJsonArray = JSON.parseArray(sceneUpDataStr);
  240. Map<String, String> fileMap = fileJsonArray.stream().collect(Collectors.toMap(v -> ((JSONObject) v).getString("fileName"), v -> ((JSONObject) v).getString("filePath")));
  241. List<OrigFileUpload> fileList = origFileUploadService.getByBatchId(batchId);
  242. if(CollUtil.isEmpty(fileList)){
  243. return;
  244. }
  245. String homePath = "/oss/4dkankan/" + SceneUtil.getHomePath(dataSource);
  246. for (OrigFileUpload origFileUpload : fileList) {
  247. String relativeFilePath = fileMap.get(origFileUpload.getFileName());
  248. if(StrUtil.isEmpty(relativeFilePath)){
  249. continue;
  250. }
  251. int times = 0;
  252. String filePath = homePath.concat(relativeFilePath);
  253. do{
  254. try {
  255. ++times;
  256. HttpUtil.downloadFile(origFileUpload.getFileUrl(), new File(filePath), 10 * 60 * 1000);
  257. if(FileUtil.exist(filePath)){
  258. break;
  259. }
  260. }catch (Exception e){
  261. log.info("原始文件第{}次下载失败,fileUrl:{}, filePath:{}", origFileUpload.getFileUrl(), filePath);
  262. }
  263. }while (times < 4);
  264. if(!FileUtil.exist(filePath)){
  265. throw new RuntimeException("原始文件下载失败,fileUrl:" + origFileUpload.getFileUrl() + ", filePath:" + filePath);
  266. }
  267. }
  268. }
  269. private String getOssPath(String path) {
  270. String ossPath = ConstantFilePath.OSS_PREFIX
  271. + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
  272. .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
  273. if (!ossPath.endsWith("/")) {
  274. ossPath = ossPath.concat("/");
  275. }
  276. return ossPath;
  277. }
  278. @Override
  279. public void downLoadSource(BuildSceneCallMessage buildSceneMqMessage,String path){
  280. String ossPath = getOssPath(path);
  281. fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
  282. }
  283. @Override
  284. public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
  285. String sceneCode = message.getBuildContext().get("sceneNum").toString();
  286. String filename = (String)message.getExt().get("filename");
  287. String path = message.getPath();
  288. boolean status = false;
  289. try {
  290. // 上传计算日志
  291. //如果是重复计算,没有走到计算逻辑,不需要上传日志文件
  292. log.info("开始上传计算日志");
  293. String buildLogPath = String.format(UploadFilePath.BUILD_LOG_PATH, sceneCode);
  294. fYunFileService.uploadFile(path + File.separator + "console.log", buildLogPath + "console.log");
  295. log.info("计算日志上传完成");
  296. JSONObject fdageData = getFdageData(path + File.separator + "capture" +File.separator+"data.fdage");
  297. String uuid = fdageData.getString("creator") + "_" + fdageData.getString("uuidtime");
  298. if (!message.getBuildSuccess()) {
  299. log.error("建模失败,修改状态为失败状态");
  300. scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
  301. .set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
  302. .eq(ScenePlus::getNum, sceneCode));
  303. this.sendFailToLaser(sceneCode);
  304. redisUtil.set(String.format(RedisKey.SCENE_BUILD_FINISH_NUM, sceneCode), "-1");
  305. return;
  306. }
  307. ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneCode);
  308. Integer cameraType = Integer.parseInt(message.getBuildContext().get("cameraType").toString());
  309. Map<String, String> uploadFiles = getUploadFiles(scenePlus,path,cameraType,fdageData);
  310. scenePlus.setPayStatus(PayStatus.PAY.code());
  311. scenePlus.setUpdateTime(new Date());
  312. scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
  313. Integer videoVersion = fdageData.getInteger("videoVersion");
  314. //读取计算结果文件生成videosJson
  315. JSONObject videosJson = this.getVideosJson(path, videoVersion, sceneCode, cameraType);
  316. ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  317. boolean isObj = fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1;
  318. //上传全景图俯视图
  319. this.uploadFloorCad(path, sceneCode, uploadFiles);
  320. Integer hasAi = this.uploadFreespace(sceneCode, path, uploadFiles);
  321. scenePlus.setHasAi(hasAi);
  322. log.info("开始上传场景计算结果数据,num:{}", sceneCode);
  323. //由于3dtiles算法mesh文件发生变化,所以这里需要先清除一下oss的mesh目录,避免存在旧算法obj文件
  324. fYunFileService.deleteFolder(String.format(UploadFilePath.DATA_VIEW_PATH, sceneCode) + "mesh");
  325. fYunFileService.deleteFolder(String.format(UploadFilePath.IMG_VIEW_PATH, sceneCode) + ModelKind.THREE_D_TILE.code());
  326. //上传文件
  327. fYunFileService.uploadMulFiles(uploadFiles);
  328. //修改oss上dam的内容编码
  329. // Map<String,String> damFileHeaders = new HashMap<>();
  330. // damFileHeaders.put("Content-Encoding","gzip");
  331. // String damPath = path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam";
  332. // fYunFileService.uploadFile(damPath, String.format(UploadFilePath.IMG_VIEW_PATH, sceneCode) + ConstantFileName.modelUUID + "_50k.dam", damFileHeaders);
  333. //拷贝部分文件到编辑目录,用于用户编辑
  334. this.copyToEditDir(sceneCode);
  335. //计算完毕后,同步全景图到缓存目录
  336. // this.cachePanorama(path, sceneCode);
  337. //生成houseTypejson并上传
  338. boolean existHouseType = this.uploadHouseTypeJson(sceneCode, path);
  339. scenePlus.setHouseType(existHouseType ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue());
  340. //生成场景关联数据
  341. Integer links = linkPanService.genLinkPanPost(sceneCode);
  342. //生成floorpan.json
  343. commonService.uploadFloorplanJson(sceneCode, path);
  344. //江门需求,算法识别平面图
  345. commonService.uploadFloorplanAi(sceneCode, path);
  346. LinkedHashMap<Integer, Boolean> detFloorplan = message.getDetFloorplan();
  347. boolean hasFloorplanAi = commonService.detFloorPlanAi(sceneCode, path, detFloorplan);
  348. if(hasFloorplanAi){
  349. scenePlus.setHasFloorplanAi(CommonStatus.YES.code().intValue());
  350. }else{
  351. scenePlus.setHasFloorplanAi(CommonStatus.NO.code().intValue());
  352. }
  353. //重置异步操作记录
  354. commonService.removeSceneAsynOperLog(sceneCode);
  355. //清除用户编辑业务数据
  356. Set<String> bizs = new HashSet<>();
  357. bizs.add(UserEditDataType.BOX_MODEL.message());
  358. bizs.add(UserEditDataType.FLOORPLAN.message());
  359. bizs.add(UserEditDataType.FILTERS.message());
  360. commonService.initUserEditData(sceneCode, bizs, null);
  361. //上传计算结果文件
  362. commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
  363. //容量统计
  364. Long space = commonService.getSpace(sceneCode);
  365. //写入数据库
  366. this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),isObj,scenePlusExt);
  367. Object[] editInfoArr = commonService.updateEditInfo(scenePlus);
  368. SceneEditInfo sceneEditInfo = (SceneEditInfo)editInfoArr[0];
  369. SceneEditInfoExt sceneEditInfoExt = (SceneEditInfoExt)editInfoArr[1];
  370. SceneEditControls sceneEditControls = (SceneEditControls)editInfoArr[2];
  371. sceneEditInfoExt.setLinks(links);
  372. sceneEditInfoExtService.updateById(sceneEditInfoExt);
  373. //更新场景主表
  374. //如果相机容量不足,需要把场景的paystatus改为容量不足状态
  375. scenePlus.setPayStatus(commonService.getPayStatus(scenePlus.getCameraId(), space));
  376. //统计原始资源大小
  377. scenePlusExt.setOrigSpace(FileUtil.size(new File(path.concat(File.separator).concat("capture"))));
  378. scenePlusExt.setOrientation(fdageData.getString("orientation"));
  379. if (cameraType == 14) {
  380. //计算成功 激光转台相机 同步 请求
  381. fdkkLaserService.syncBuildResult(
  382. SyncLaserResultBean.builder()
  383. .num(sceneCode).dataSource(path)
  384. .sceneStatus(2)
  385. .createTime(scenePlus.getCreateTime())
  386. .shootCount(scenePlusExt.getShootCount())
  387. .payStatus(scenePlus.getPayStatus())
  388. .mixture(scenePlusExt.getMixture())
  389. .version(SceneVersionType.V4.code()).build());
  390. sceneEditControlsService.update(new LambdaUpdateWrapper<SceneEditControls>().set(SceneEditControls::getShowMap,0)
  391. .eq(SceneEditControls::getEditInfoId,sceneEditInfo.getId()));
  392. sceneEditControls.setShowMap(0);
  393. } else if (new File(path + "/results/laserData/vision_edit.txt").exists()) {
  394. fdkkLaserService.cloudPointBuild(sceneCode,path);
  395. }
  396. log.info("生成scene.json上传oss并设置缓存,num:{}", sceneCode);
  397. CameraDetail cameraDetail = cameraDetailService.getByCameraId(scenePlus.getCameraId());
  398. Company company = !ObjectUtils.isEmpty(cameraDetail.getCompanyId()) ? companyService.getById(cameraDetail.getCompanyId()) : null;
  399. //写scene.json
  400. commonService.writeSceneJson(sceneCode, videosJson,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
  401. String qrLogo = !ObjectUtils.isEmpty(company) && !ObjectUtils.isEmpty(company.getQrLogo()) ? company.getQrLogo() : null;
  402. qrLogo = ObjectUtils.isEmpty(qrLogo) && !ObjectUtils.isEmpty(sceneEditInfoExt.getShareLogoImg()) ? fYunFileConfig.getHost().concat(sceneEditInfoExt.getShareLogoImg()) : null;
  403. createQrCode(sceneCode, scenePlusExt, qrLogo);
  404. //计算成功,通知APP
  405. Integer pushChannel = fdageData.getInteger("pushChannel");
  406. String pushToken = fdageData.getString("pushToken");
  407. this.pushMsgToApp(pushChannel,pushToken, cameraType, scenePlus.getTitle(), scenePlusExt.getWebSite());
  408. //删除计算目录
  409. // if(CollUtil.isEmpty(notDeleteNasNumList) || !notDeleteNasNumList.contains(sceneCode)){
  410. // CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
  411. // }
  412. //更新场景主表
  413. //如果相机容量不足,需要把场景的paystatus改为容量不足状态
  414. if (cameraType != 14) {
  415. scenePlus.setPayStatus(commonService.getPayStatus(scenePlus.getCameraId(), space));
  416. }
  417. this.uploadStatusJson(scenePlus, scenePlusExt);
  418. scenePlusService.updateById(scenePlus);
  419. scenePlusExtService.updateById(scenePlusExt);
  420. //国际环境需要发邮件通知
  421. if("eur".equals(env)){
  422. commonService.sendEmail(sceneCode);
  423. }
  424. //推送ai识别平面图mq
  425. this.sendMqForAiPano(sceneCode);
  426. redisUtil.set(String.format(RedisKey.SCENE_BUILD_FINISH_NUM, sceneCode), "1");
  427. status = true;
  428. log.info("场景计算结果处理结束,场景码:{}", sceneCode);
  429. }catch (Exception e){
  430. log.error("场景计算结果处理出错,num"+sceneCode, e);
  431. // buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
  432. this.sendFailToLaser(sceneCode);
  433. throw e;
  434. }finally {
  435. //海鑫需求,下载展示目录,打压缩包,进行推送
  436. haixinService.noticHaixin(sceneCode, status);
  437. }
  438. }
  439. private Integer uploadFreespace(String num, String path, Map<String, String> map){
  440. String floor0pngPath = "/results/floorplan/floor_0.png";
  441. String plyPath = path + "/results/laserData/cover/final_freespace.ply";
  442. String pngPath = path + "/results/laserData/cover/final_freespace.png";
  443. String infoJsonPath = path + "/results/laserData/cover/info.json";
  444. Integer hasAi = CommonStatus.NO.code().intValue();
  445. if(FileUtil.exist(floor0pngPath) || FileUtil.exist(plyPath)){
  446. hasAi = CommonStatus.YES.code().intValue();
  447. map.put(plyPath, String.format(UploadFilePath.IMG_VIEW_PATH, num) + "cover/" + FileUtil.getName(plyPath));
  448. }
  449. if(FileUtil.exist(pngPath)){
  450. map.put(pngPath, String.format(UploadFilePath.IMG_VIEW_PATH, num) + "cover/" + FileUtil.getName(pngPath));
  451. }
  452. if(FileUtil.exist(infoJsonPath)){
  453. map.put(infoJsonPath, String.format(UploadFilePath.IMG_VIEW_PATH, num) + "cover/" + FileUtil.getName(infoJsonPath));
  454. }
  455. return hasAi;
  456. }
  457. private void sendMqForBcgn(String num){
  458. Map<String, String> map = new HashMap<>();
  459. map.put("num", num);
  460. mqProducer.sendByWorkQueue("detect-queue", map);
  461. }
  462. private void sendMqForAiPano(String num){
  463. Map<String, String> map = new HashMap<>();
  464. map.put("num", num);
  465. mqProducer.sendByWorkQueue("detect-queue-pano", map);
  466. }
  467. private Map<String, String> getUploadFiles(ScenePlus scenePlus,String path,Integer cameraType,JSONObject fdageData) throws Exception {
  468. if (ObjectUtils.isEmpty(scenePlus)) {
  469. throw new Exception("未找到场景信息:" + path);
  470. }
  471. String projectNum = scenePlus.getNum();
  472. String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, projectNum);
  473. String imagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, projectNum);
  474. String videoPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, projectNum);
  475. String resultsPath = path + File.separator + "results" + File.separator;
  476. String uploadData = FileUtils.readFile(resultsPath + "upload.json");
  477. JSONArray array = JSONObject.parseObject(uploadData).getJSONArray("upload");
  478. JSONObject fileJson = null;
  479. String fileName = "";
  480. Map<String, String> map = new HashMap();
  481. for (int i = 0; i < array.size(); ++i) {
  482. fileJson = array.getJSONObject(i);
  483. fileName = fileJson.getString("file");
  484. String filePath = resultsPath + fileName;
  485. if (!(new File(filePath)).exists()) {
  486. throw new Exception(filePath + "文件不存在");
  487. }
  488. if ("vision2.txt".equals(fileName)) {
  489. CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision2.txt", resultsPath + "vision2.modeldata");
  490. map.put(resultsPath + "vision2.modeldata", imagesPath + "vision2.modeldata");
  491. map.put(resultsPath + "vision2.txt", imagesPath + "vision2.txt");
  492. }
  493. if (fileJson.getIntValue("clazz") == 2) {
  494. map.put(filePath, imagesPath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
  495. } else if (fileJson.getIntValue("clazz") == 3) {
  496. map.put(filePath, imagesPath + "pan/high/" + fileName.replace("high/", ""));
  497. } else if (fileJson.getIntValue("clazz") == 4) {
  498. map.put(filePath, imagesPath + "pan/low/" + fileName.replace("low/", ""));
  499. } else if (fileJson.getIntValue("clazz") == 5) {
  500. map.put(filePath, imagesPath + fileName);
  501. } else if (fileJson.getIntValue("clazz") == 7) {
  502. map.put(filePath, imagesPath + fileName);
  503. } else if (fileJson.getIntValue("clazz") == 10) {
  504. String updown = FileUtils.readFile(filePath);
  505. JSONObject updownJson = JSONObject.parseObject(updown);
  506. String mappingOssPath = String.format("scene_edit_data/%s/data/", projectNum) + fileName.replace("updown", "mapping");
  507. map.put(filePath, mappingOssPath);
  508. } else {
  509. if (fileJson.getIntValue("clazz") == 11 || fileJson.getIntValue("clazz") == 12) {
  510. map.put(filePath, videoPath + fileName.replace("videos/", ""));
  511. if (fileName.contains(".mp4")) {
  512. map.put(resultsPath + fileName.replace("mp4", "flv"), videoPath + fileName.replace("videos/", "").replace("mp4", "flv"));
  513. }
  514. }
  515. if (fileJson.getIntValue("clazz") == 16) {
  516. map.put(filePath, dataViewPath + fileName);
  517. }
  518. if (fileJson.getIntValue("clazz") == 18) {
  519. map.put(filePath, imagesPath + fileName);
  520. }
  521. }
  522. }
  523. //exportMeshObj这个是字段由app写入的
  524. boolean genModel = true;//是否生成模型 默认生成,深时场景要根据 exportMeshObj判断是否生成
  525. if(!ObjectUtils.isEmpty(cameraType)
  526. && cameraType == 14
  527. && (!fdageData.containsKey("exportMeshObj") || fdageData.getIntValue("exportMeshObj") != 1)){
  528. genModel = false;
  529. }
  530. boolean gen3dTiles = true;//是否生成3dtiles模型 默认生成
  531. if(!ModelKind.THREE_D_TILE.code().equals(modelKind)
  532. || CollUtil.isEmpty(sdTilesSceneSourceList)
  533. || !sdTilesSceneSourceList.contains(scenePlus.getSceneSource())){
  534. gen3dTiles = false;
  535. }
  536. if(genModel){
  537. if (!gen3dTiles) {
  538. String damPath = path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam";
  539. CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", damPath);
  540. // FileUtil.writeBytes(ZipUtil.gzip(new File(damPath)), damPath);
  541. map.put(damPath, imagesPath + ConstantFileName.modelUUID + "_50k.dam");
  542. }else{
  543. List<String> list = FileUtils.list(new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
  544. if(CollUtil.isEmpty(list)){
  545. log.error("3dtiles目录异常,3dtiles地址:{}", new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
  546. throw new Exception("3dtiles目录异常");
  547. }
  548. list.stream().forEach(str->{
  549. map.put(str, str.replace(path + File.separator + "results" + File.separator, imagesPath));
  550. });
  551. }
  552. }
  553. CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision.txt", resultsPath + "vision.modeldata");
  554. map.put(resultsPath + "vision.txt", imagesPath + "vision.txt");
  555. map.put(resultsPath + "vision.modeldata", imagesPath + "vision.modeldata");
  556. log.info("数据转换完成:" + projectNum);
  557. if(!new File("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum).exists()){
  558. FileUtil.mkdir("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum);
  559. }
  560. // map.put(resultsPath + "floorplan.json", dataViewPath + "floor.json");
  561. map.put(resultsPath + "floorplan_cad.json", dataViewPath + "floorplan_cad.json");
  562. map.put(path + File.separator + "capture/stitch_params.txt", dataViewPath + "stitch_params.txt");
  563. map.put(path + File.separator + "capture/Up.xml", dataViewPath + "Up.xml");
  564. map.put(path + File.separator + "capture/Up2.xml", dataViewPath + "Up2.xml");
  565. map.put(path + File.separator + "capture/Up.txt", dataViewPath + "Up.txt");
  566. map.put(path + File.separator + "capture/Up2.txt", dataViewPath + "Up2.txt");
  567. return map;
  568. }
  569. private JSONObject getFdageData(String dataFdagePath) {
  570. log.info("dataFdagePath 文件路径 :{}", dataFdagePath);
  571. String data = FileUtils.readFile(dataFdagePath);
  572. //获取data.fdage的内容
  573. JSONObject dataJson = new JSONObject();
  574. if(data!=null){
  575. dataJson = JSONObject.parseObject(data);
  576. }
  577. return dataJson;
  578. }
  579. private void uploadFloorCad(String path, String num, Map<String, String> uploadFiles){
  580. //户型图上传
  581. String dataViewPath = UploadFilePath.DATA_VIEW_PATH + "floor-cad-%s.%s";
  582. String floorCadPath = path + "/results/floorplan_cad";
  583. List<String> floorCadList = FileUtils.getFileList(floorCadPath);
  584. if(CollUtil.isNotEmpty(floorCadList)){
  585. floorCadList.stream().forEach(str->{
  586. String substring = str.substring(str.lastIndexOf(File.separator) + 1);
  587. String[] arr = substring.split("floor");
  588. String[] arr2 = arr[1].split("\\.");
  589. uploadFiles.put(str, String.format(dataViewPath, num, arr2[0], arr2[1]));
  590. });
  591. }
  592. }
  593. private void uploadStatusJson(ScenePlus scenePlus, ScenePlusExt scenePlusExt){
  594. String num = scenePlus.getNum();
  595. String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
  596. Integer status = 1;
  597. if(scenePlus.getSceneSource() == 4 || scenePlus.getSceneSource() == 5){//如果是激光场景,需要激光系统那边完全处理好之后再发mq通知更新状态
  598. status = 0;
  599. }
  600. // 上传status JSON.
  601. JSONObject statusJson = new JSONObject();
  602. //临时将-2改成1,app还没完全更新
  603. statusJson.put("status", status);
  604. statusJson.put("webSite", scenePlusExt.getWebSite());
  605. statusJson.put("sceneNum", num);
  606. statusJson.put("thumb", scenePlusExt.getThumb());
  607. statusJson.put("payStatus", scenePlus.getPayStatus());
  608. statusJson.put("sceneScheme", scenePlusExt.getSceneScheme());
  609. FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json", statusJson.toString());
  610. Map<String,String> headers = new HashMap<>();
  611. headers.put(HttpHeaders.CONTENT_TYPE, ContentType.JSON.getValue());
  612. fYunFileService.uploadFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json", dataViewPath + "status.json", headers);
  613. }
  614. private void createQrCode(String num, ScenePlusExt scenePlusExt, String qrLogo) {
  615. String localLogoPath = null;
  616. if (!ObjectUtils.isEmpty(qrLogo)) {
  617. try {
  618. localLogoPath = ConstantFilePath.AGENT_PATH + qrLogo.substring(qrLogo.lastIndexOf("//") + 1);
  619. HttpUtil.downloadFile(qrLogo, localLogoPath);
  620. } catch (Exception e) {
  621. log.error("公司logo下载失败:{}", qrLogo);
  622. localLogoPath = null;
  623. }
  624. }
  625. //生成二维码
  626. String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +".png";
  627. String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +"_en.png";
  628. QrConfig qrConfig = QrConfig.create();
  629. qrConfig.setWidth(1024);
  630. qrConfig.setHeight(1024);
  631. if(StrUtil.isNotEmpty(localLogoPath)){
  632. qrConfig.setImg(localLogoPath);
  633. }
  634. QrCodeUtil.generate(scenePlusExt.getWebSite(), qrConfig, FileUtil.file(outPathZh));
  635. QrCodeUtil.generate(scenePlusExt.getWebSite() + "&lang=en", qrConfig, FileUtil.file(outPathEn));
  636. //上传二维码
  637. fYunFileService.uploadFile(outPathZh, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + ".png");
  638. fYunFileService.uploadFile(outPathEn, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + "_en.png");
  639. if(!ObjectUtils.isEmpty(localLogoPath)){
  640. FileUtils.deleteFile(localLogoPath);
  641. }
  642. }
  643. private void pushMsgToApp(Integer pushChannel, String pushToken, int cameraType, String sceneName, String webSite){
  644. log.info("推送消息,渠道是 {}, 手机token是 {}", pushChannel, pushToken);
  645. if(Objects.isNull(pushChannel) || StrUtil.isBlank(pushToken)){
  646. return;
  647. }
  648. String title = sceneName + "计算完成";
  649. String body = "您上传的" + sceneName + "计算完成,点击查看";
  650. try{
  651. if(FYunTypeEnum.AWS.code().equals(fYunFileService.getFyunType())){
  652. PushMsgUtil.googlePushMsg(ConstantFilePath.BASE_PATH + "/refreshToken.json", pushToken,
  653. title, body , webSite);
  654. return;
  655. }
  656. PushMessageConfig pushConfig = null;
  657. if(pushChannel == 0){
  658. if(cameraType == 10 || cameraType == 13){
  659. //ios
  660. pushConfig = new PushMessageConfig(PushMessageConfig.IOS_KEY_Z, PushMessageConfig.IOS_SECRET_Z);
  661. pushConfig.sendIOSUnicast(pushToken, "四维看看Minion",title, body, webSite);
  662. }else {
  663. //ios
  664. pushConfig = new PushMessageConfig(PushMessageConfig.IOS_KEY, PushMessageConfig.IOS_SECRET);
  665. pushConfig.sendIOSUnicast(pushToken, "四维看看Pro",title, body, webSite);
  666. }
  667. }else {
  668. if(cameraType == 10 || cameraType == 13){
  669. //ios
  670. //安卓
  671. pushConfig = new PushMessageConfig(PushMessageConfig.ANDROID_KEY_Z, PushMessageConfig.ANDROID_SECRET_Z);
  672. pushConfig.sendAndroidUnicast2(pushToken, "四维看看Minion",title, body, webSite);
  673. }else {
  674. //安卓
  675. pushConfig = new PushMessageConfig(PushMessageConfig.ANDROID_KEY, PushMessageConfig.ANDROID_SECRET);
  676. pushConfig.sendAndroidUnicast(pushToken, "四维看看Pro",title, body, webSite);
  677. }
  678. }
  679. log.info("消息推送结束!");
  680. }catch (Exception e){
  681. log.error("推送消息失败:", e);
  682. }
  683. }
  684. private void copyToEditDir(String num) throws IOException {
  685. String editImagesPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
  686. String viewImagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
  687. String editDataPath = String.format(UploadFilePath.DATA_EDIT_PATH, num);
  688. String viewDataPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
  689. Map<String, String> map = new HashMap<>();
  690. map.put(editImagesPath + "vision.modeldata", viewImagesPath + "vision.modeldata");
  691. map.put(editImagesPath + "vision2.modeldata", viewImagesPath + "vision2.modeldata");
  692. map.put(editDataPath + "floorplan_cad.json", viewDataPath + "floorplan_cad.json");
  693. for (Entry<String, String> entry : map.entrySet()) {
  694. fYunFileService.copyFileInBucket(entry.getValue(), entry.getKey());
  695. }
  696. }
  697. private JSONObject getVideosJson(String path, Integer videoVersion, String projectNum, int cameraType) throws Exception {
  698. //读取videos_hdr_param.json, 保存点位视频的value
  699. Map<String, Object> videoMap = new HashMap<>();
  700. String videosHdr = FileUtils.readFile(path + File.separator + "results/videos/videos_hdr_param.json");
  701. JSONArray videoArray = null;
  702. if(StringUtils.isNotEmpty(videosHdr)){
  703. videoArray = JSONObject.parseObject(videosHdr).getJSONArray("hdr_param");
  704. }
  705. if(videoArray != null){
  706. for(int i = 0, len = videoArray.size(); i < len; i++) {
  707. videoMap.put(videoArray.getJSONObject(i).getString("name"), videoArray.getJSONObject(i).getString("value"));
  708. if(videoArray.getJSONObject(i).containsKey("fov")){
  709. videoMap.put(videoArray.getJSONObject(i).getString("name") + "_fov", videoArray.getJSONObject(i).getString("fov"));
  710. }
  711. }
  712. }
  713. //获取upload中的video视频名称
  714. String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
  715. JSONObject uploadJson = null;
  716. JSONArray array = null;
  717. if(uploadData!=null) {
  718. uploadJson = JSONObject.parseObject(uploadData);
  719. array = uploadJson.getJSONArray("upload");
  720. }
  721. JSONObject fileJson = null;
  722. String fileName = "";
  723. //计算ts文件的大小,并拼接成json格式
  724. JSONArray jsonArray = new JSONArray();
  725. JSONObject videoJson = null;
  726. JSONObject videosJson = new JSONObject();
  727. long videoSize = 0L;
  728. for(int i = 0, len = array.size(); i < len; i++) {
  729. fileJson = array.getJSONObject(i);
  730. fileName = fileJson.getString("file");
  731. if(fileJson.getIntValue("clazz") == 11 && fileName.contains(".mp4") && !fileName.contains("-ios.mp4")){
  732. videoJson = new JSONObject();
  733. videoJson.put("id", fileName.substring(
  734. 0, fileName.lastIndexOf(".")).replace("videos/", ""));
  735. //如果ts文件存在,就计算ts大小
  736. if(new File(path + File.separator + "results" +File.separator+ fileName.replace(".mp4", ".ts")).exists()){
  737. videoSize = new File(path + File.separator + "results" +File.separator+ fileName.replace(".mp4", ".ts")).length();
  738. videoJson.put("tsSize", videoSize);
  739. }
  740. if(videoMap.containsKey(videoJson.get("id"))){
  741. videoJson.put("value", videoMap.get(videoJson.get("id")));
  742. }
  743. if(videoMap.containsKey(videoJson.get("id") + "_fov")){
  744. videoJson.put("blend_fov", videoMap.get(videoJson.get("id") + "_fov"));
  745. }else {
  746. videoJson.put("blend_fov", 7);
  747. }
  748. jsonArray.add(videoJson);
  749. }
  750. }
  751. videosJson.put("data", jsonArray);
  752. if(Objects.nonNull(videoVersion) && videoVersion >= 4){
  753. videosJson.put("version", 3);
  754. videosJson.put("upPath", String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "Up.xml");
  755. if(cameraType == 13 || cameraType == 14){
  756. //转台相机
  757. videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
  758. }
  759. }else {
  760. videosJson.put("version", 1);
  761. videosJson.put("upPath", String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "Up2.xml");
  762. if(cameraType == 13 || cameraType == 14){
  763. //转台相机
  764. videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
  765. }
  766. }
  767. if(cameraType == 5 || cameraType == 6){
  768. videosJson.put("version", 1);
  769. videosJson.put("upPath", String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "stitch_params.txt");
  770. }
  771. return videosJson;
  772. }
  773. private void updateDbPlus(int sceneSource,Long space,String videosJson, Long computeTime,boolean isObj,ScenePlusExt scenePlusExt){
  774. scenePlusExt.setSpace(space);
  775. scenePlusExt.setComputeTime(computeTime.toString());
  776. scenePlusExt.setAlgorithmTime(new Date());
  777. scenePlusExt.setVideos(videosJson);
  778. scenePlusExt.setIsObj(isObj ? 1 : 0);
  779. if(ModelTypeEnums.TILE_CODE.equals(modelType)){
  780. scenePlusExt.setSceneScheme(3);
  781. }
  782. switch (SceneSource.get(sceneSource)){
  783. case BM:
  784. scenePlusExt.setSceneResolution(SceneResolution.two_K.code());
  785. scenePlusExt.setSceneFrom(SceneFrom.PRO.code());
  786. break;
  787. case SM:
  788. scenePlusExt.setSceneResolution(SceneResolution.one_k.code());
  789. scenePlusExt.setSceneFrom(SceneFrom.LITE.code());
  790. break;
  791. case ZT:
  792. scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
  793. scenePlusExt.setSceneFrom(SceneFrom.MINION.code());
  794. break;
  795. case JG:
  796. scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
  797. scenePlusExt.setSceneFrom(SceneFrom.LASER.code());
  798. break;
  799. case SG:
  800. scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
  801. scenePlusExt.setSceneFrom(SceneFrom.LASER.code());
  802. break;
  803. }
  804. String sceneKind = scenePlusExt.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code();
  805. scenePlusExt.setSceneKind(sceneKind);
  806. // scenePlusExt.setModelKind(modelKind);
  807. //统计点位数量
  808. Map<String, Integer> result = this.getShootCount(scenePlusExt);
  809. Integer shootCount = result.get("shootCount");
  810. Integer mixture = result.get("mixture");
  811. scenePlusExt.setShootCount(shootCount);
  812. scenePlusExt.setMixture(mixture);
  813. scenePlusExtService.updateById(scenePlusExt);
  814. }
  815. private Map<String, Integer> getShootCount(ScenePlusExt scenePlusExt){
  816. Map<String, Integer> result = new HashMap<>();
  817. Integer shootCount = 0;
  818. Integer mixture = Objects.isNull(scenePlusExt.getMixture()) ? 0 : scenePlusExt.getMixture();
  819. String homePath = SceneUtil.getHomePath(scenePlusExt.getDataSource());
  820. JSONObject dataFdageObj = JSON.parseObject(fYunFileService.getFileContent(homePath.concat("data.fdage")));
  821. if(Objects.nonNull(dataFdageObj)){
  822. JSONArray points = dataFdageObj.getJSONArray("points");
  823. if(CollUtil.isNotEmpty(points)){
  824. shootCount = points.size();
  825. }
  826. }
  827. if(Objects.nonNull(shootCount) && shootCount > 0){
  828. if(Objects.nonNull(scenePlusExt.getLocation()) && scenePlusExt.getLocation() == 6){
  829. mixture = CommonStatus.YES.code().intValue();
  830. }
  831. }else{
  832. String slamDataStr = fYunFileService.getFileContent(homePath.concat("slam_data.json"));
  833. JSONObject slamDataObj = JSON.parseObject(slamDataStr);
  834. if(Objects.nonNull(slamDataObj)){
  835. JSONArray viewsInfo = slamDataObj.getJSONArray("views_info");
  836. if(CollUtil.isNotEmpty(viewsInfo)){
  837. shootCount = viewsInfo.stream().mapToInt(info -> {
  838. return ((JSONObject) info).getJSONArray("list_pose").size();
  839. }).sum();
  840. }
  841. }
  842. mixture = CommonStatus.NO.code().intValue();
  843. }
  844. result.put("shootCount", shootCount);
  845. result.put("mixture", mixture);
  846. return result;
  847. }
  848. public static void main(String[] args) {
  849. // JSONObject dataFdageObj = JSON.parseObject(null);
  850. // System.out.println(dataFdageObj);
  851. String test ="{\"rebuild\":\"0\",\"flexibility\":0,\"isStandardization\":null,\"createTime\":null,\"resultReceiverMqName\":null,\"buildContext\":{\"sceneNum\":\"SG-jm-JT77TjCZwF5\",\"cameraType\":\"14\"},\"computeTime\":446,\"buildSuccess\":true,\"path\":\"/mnt/data/bpvt00006/1328767184540794880/bpvt00006_202412301634030230\",\"hostName\":null,\"ext\":{\"deleteExtras\":true,\"detFloorplan\":{\"0\":true,\"4\":true,\"3\":true,\"1\":true},\"location\":4,\"linkPanTargetList\":[\"/mnt/data/bpvt00006/1328767184540794880/bpvt00006_202412301634030230/linkPan/panorama/0_pano_0\",\"/mnt/data/bpvt00006/1328767184540794880/bpvt00006_202412301634030230/linkPan/panorama/1_pano_0\"]},\"errorType\":null}";
  852. BuildSceneResultMqMessage message = JSONObject.parseObject(test, BuildSceneResultMqMessage.class);
  853. Map<String, Object> ext = message.getExt();
  854. JSONObject detFloorplanObj = (JSONObject)ext.get("detFloorplan");
  855. for (String s : detFloorplanObj.keySet()) {
  856. System.out.println(s + ":" + detFloorplanObj.getBoolean(s));
  857. }
  858. }
  859. public boolean uploadHouseTypeJson(String num, String dataSource) {
  860. String floorPlanCardFilePath = dataSource + File.separator + "results/floorplan_cad.json";
  861. if (!new File(floorPlanCardFilePath).exists()) {
  862. log.warn("floorplan_cad.json 文件不存在,文件路径:{}", floorPlanCardFilePath);
  863. return false;
  864. }
  865. JSONObject json = CreateHouseJsonUtil.createHouseTypeJsonByCad(floorPlanCardFilePath);
  866. if(Objects.isNull(json)){
  867. return false;
  868. }
  869. String hourseTypeJsonPath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "houseType.json";
  870. fYunFileService.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
  871. hourseTypeJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "houseType.json";
  872. fYunFileService.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
  873. return true;
  874. }
  875. private void sendFailToLaser(String num){
  876. ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  877. if(SceneSource.JG.code() != scenePlus.getSceneSource().intValue() && SceneSource.SG.code() != scenePlus.getSceneSource().intValue()){
  878. return;
  879. }
  880. Map<String, Object> params = new HashMap<>();
  881. params.put("sceneCode", num);
  882. params.put("status", 1);
  883. params.put("createTime", DateUtil.date2String(scenePlus.getCreateTime(), null));
  884. params.put("algorithmTime", DateUtil.date2String(Calendar.getInstance().getTime(), null));
  885. params.put("sceneSource", scenePlus.getSceneSource());
  886. fdkkLaserService.syncFailResult(params);
  887. }
  888. }