BuildSceneServiceImpl.java 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  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 path = message.getPath();
  287. boolean status = false;
  288. try {
  289. // 上传计算日志
  290. //如果是重复计算,没有走到计算逻辑,不需要上传日志文件
  291. log.info("开始上传计算日志");
  292. String buildLogPath = String.format(UploadFilePath.BUILD_LOG_PATH, sceneCode);
  293. fYunFileService.uploadFile(path + File.separator + "console.log", buildLogPath + "console.log");
  294. log.info("计算日志上传完成");
  295. JSONObject fdageData = getFdageData(path + File.separator + "capture" +File.separator+"data.fdage");
  296. String uuid = fdageData.getString("creator") + "_" + fdageData.getString("uuidtime");
  297. if (!message.getBuildSuccess()) {
  298. log.error("建模失败,修改状态为失败状态");
  299. scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
  300. .set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
  301. .eq(ScenePlus::getNum, sceneCode));
  302. this.sendFailToLaser(sceneCode);
  303. redisUtil.set(String.format(RedisKey.SCENE_BUILD_FINISH_NUM, sceneCode), "-1");
  304. return;
  305. }
  306. ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneCode);
  307. Integer cameraType = Integer.parseInt(message.getBuildContext().get("cameraType").toString());
  308. Map<String, String> uploadFiles = getUploadFiles(scenePlus,path,cameraType,fdageData);
  309. scenePlus.setPayStatus(PayStatus.PAY.code());
  310. scenePlus.setUpdateTime(new Date());
  311. scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
  312. Integer videoVersion = fdageData.getInteger("videoVersion");
  313. //读取计算结果文件生成videosJson
  314. JSONObject videosJson = this.getVideosJson(path, videoVersion, sceneCode, cameraType);
  315. ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  316. boolean isObj = fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1;
  317. //上传全景图俯视图
  318. this.uploadFloorCad(path, sceneCode, uploadFiles);
  319. Integer hasAi = this.uploadFreespace(sceneCode, path, uploadFiles);
  320. scenePlus.setHasAi(hasAi);
  321. log.info("开始上传场景计算结果数据,num:{}", sceneCode);
  322. //由于3dtiles算法mesh文件发生变化,所以这里需要先清除一下oss的mesh目录,避免存在旧算法obj文件
  323. fYunFileService.deleteFolder(String.format(UploadFilePath.DATA_VIEW_PATH, sceneCode) + "mesh");
  324. fYunFileService.deleteFolder(String.format(UploadFilePath.IMG_VIEW_PATH, sceneCode) + ModelKind.THREE_D_TILE.code());
  325. //上传文件
  326. fYunFileService.uploadMulFiles(uploadFiles);
  327. //修改oss上dam的内容编码
  328. // Map<String,String> damFileHeaders = new HashMap<>();
  329. // damFileHeaders.put("Content-Encoding","gzip");
  330. // String damPath = path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam";
  331. // fYunFileService.uploadFile(damPath, String.format(UploadFilePath.IMG_VIEW_PATH, sceneCode) + ConstantFileName.modelUUID + "_50k.dam", damFileHeaders);
  332. //拷贝部分文件到编辑目录,用于用户编辑
  333. this.copyToEditDir(sceneCode);
  334. //计算完毕后,同步全景图到缓存目录
  335. // this.cachePanorama(path, sceneCode);
  336. //生成houseTypejson并上传
  337. boolean existHouseType = this.uploadHouseTypeJson(sceneCode, path);
  338. scenePlus.setHouseType(existHouseType ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue());
  339. //生成场景关联数据
  340. Integer links = linkPanService.genLinkPanPost(sceneCode);
  341. //生成floorpan.json
  342. commonService.uploadFloorplanJson(sceneCode, path);
  343. //江门需求,算法识别平面图
  344. commonService.uploadFloorplanAi(sceneCode, path);
  345. LinkedHashMap<Integer, Boolean> detFloorplan = message.getDetFloorplan();
  346. boolean hasFloorplanAi = commonService.detFloorPlanAi(sceneCode, path, detFloorplan);
  347. if(hasFloorplanAi){
  348. scenePlus.setHasFloorplanAi(CommonStatus.YES.code().intValue());
  349. }else{
  350. scenePlus.setHasFloorplanAi(CommonStatus.NO.code().intValue());
  351. }
  352. //重置异步操作记录
  353. commonService.removeSceneAsynOperLog(sceneCode);
  354. //清除用户编辑业务数据
  355. Set<String> bizs = new HashSet<>();
  356. bizs.add(UserEditDataType.BOX_MODEL.message());
  357. bizs.add(UserEditDataType.FLOORPLAN.message());
  358. bizs.add(UserEditDataType.FILTERS.message());
  359. commonService.initUserEditData(sceneCode, bizs, null);
  360. //上传计算结果文件
  361. commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
  362. //容量统计
  363. Long space = commonService.getSpace(sceneCode);
  364. //写入数据库
  365. this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),isObj,scenePlusExt);
  366. Object[] editInfoArr = commonService.updateEditInfo(scenePlus);
  367. SceneEditInfo sceneEditInfo = (SceneEditInfo)editInfoArr[0];
  368. SceneEditInfoExt sceneEditInfoExt = (SceneEditInfoExt)editInfoArr[1];
  369. SceneEditControls sceneEditControls = (SceneEditControls)editInfoArr[2];
  370. sceneEditInfoExt.setLinks(links);
  371. sceneEditInfoExtService.updateById(sceneEditInfoExt);
  372. //更新场景主表
  373. //如果相机容量不足,需要把场景的paystatus改为容量不足状态
  374. scenePlus.setPayStatus(commonService.getPayStatus(scenePlus.getCameraId(), space));
  375. //统计原始资源大小
  376. scenePlusExt.setOrigSpace(FileUtil.size(new File(path.concat(File.separator).concat("capture"))));
  377. scenePlusExt.setOrientation(fdageData.getString("orientation"));
  378. if (cameraType == 14) {
  379. //计算成功 激光转台相机 同步 请求
  380. fdkkLaserService.syncBuildResult(
  381. SyncLaserResultBean.builder()
  382. .num(sceneCode).dataSource(path)
  383. .sceneStatus(2)
  384. .createTime(scenePlus.getCreateTime())
  385. .shootCount(scenePlusExt.getShootCount())
  386. .payStatus(scenePlus.getPayStatus())
  387. .mixture(scenePlusExt.getMixture())
  388. .version(SceneVersionType.V4.code()).build());
  389. sceneEditControlsService.update(new LambdaUpdateWrapper<SceneEditControls>().set(SceneEditControls::getShowMap,0)
  390. .eq(SceneEditControls::getEditInfoId,sceneEditInfo.getId()));
  391. sceneEditControls.setShowMap(0);
  392. } else if (new File(path + "/results/laserData/vision_edit.txt").exists()) {
  393. fdkkLaserService.cloudPointBuild(sceneCode,path);
  394. }
  395. log.info("生成scene.json上传oss并设置缓存,num:{}", sceneCode);
  396. CameraDetail cameraDetail = cameraDetailService.getByCameraId(scenePlus.getCameraId());
  397. Company company = !ObjectUtils.isEmpty(cameraDetail.getCompanyId()) ? companyService.getById(cameraDetail.getCompanyId()) : null;
  398. //写scene.json
  399. commonService.writeSceneJson(sceneCode, videosJson,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
  400. String qrLogo = !ObjectUtils.isEmpty(company) && !ObjectUtils.isEmpty(company.getQrLogo()) ? company.getQrLogo() : null;
  401. qrLogo = ObjectUtils.isEmpty(qrLogo) && !ObjectUtils.isEmpty(sceneEditInfoExt.getShareLogoImg()) ? fYunFileConfig.getHost().concat(sceneEditInfoExt.getShareLogoImg()) : null;
  402. createQrCode(sceneCode, scenePlusExt, qrLogo);
  403. //计算成功,通知APP
  404. Integer pushChannel = fdageData.getInteger("pushChannel");
  405. String pushToken = fdageData.getString("pushToken");
  406. this.pushMsgToApp(pushChannel,pushToken, cameraType, scenePlus.getTitle(), scenePlusExt.getWebSite());
  407. //删除计算目录
  408. // if(CollUtil.isEmpty(notDeleteNasNumList) || !notDeleteNasNumList.contains(sceneCode)){
  409. // CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
  410. // }
  411. //更新场景主表
  412. //如果相机容量不足,需要把场景的paystatus改为容量不足状态
  413. if (cameraType != 14) {
  414. scenePlus.setPayStatus(commonService.getPayStatus(scenePlus.getCameraId(), space));
  415. }
  416. this.uploadStatusJson(scenePlus, scenePlusExt);
  417. scenePlusService.updateById(scenePlus);
  418. scenePlusExtService.updateById(scenePlusExt);
  419. //推送场景码以及案件号到案件系统
  420. Map<String, String> params = new HashMap<>();
  421. params.put("num", sceneCode);
  422. params.put("kNo",scenePlus.getKNo());
  423. mqProducer.sendByWorkQueue("queue-aj-add-scene", params);
  424. //国际环境需要发邮件通知
  425. if("eur".equals(env)){
  426. commonService.sendEmail(sceneCode);
  427. }
  428. //推送ai识别平面图mq
  429. this.sendMqForAiPano(sceneCode);
  430. redisUtil.set(String.format(RedisKey.SCENE_BUILD_FINISH_NUM, sceneCode), "1");
  431. status = true;
  432. log.info("场景计算结果处理结束,场景码:{}", sceneCode);
  433. }catch (Exception e){
  434. log.error("场景计算结果处理出错,num"+sceneCode, e);
  435. // buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
  436. this.sendFailToLaser(sceneCode);
  437. throw e;
  438. }finally {
  439. //海鑫需求,下载展示目录,打压缩包,进行推送
  440. haixinService.noticHaixin(sceneCode, status);
  441. }
  442. }
  443. private Integer uploadFreespace(String num, String path, Map<String, String> map){
  444. String floor0pngPath = "/results/floorplan/floor_0.png";
  445. String plyPath = path + "/results/laserData/cover/final_freespace.ply";
  446. String pngPath = path + "/results/laserData/cover/final_freespace.png";
  447. String infoJsonPath = path + "/results/laserData/cover/info.json";
  448. Integer hasAi = CommonStatus.NO.code().intValue();
  449. if(FileUtil.exist(floor0pngPath) || FileUtil.exist(plyPath)){
  450. hasAi = CommonStatus.YES.code().intValue();
  451. map.put(plyPath, String.format(UploadFilePath.IMG_VIEW_PATH, num) + "cover/" + FileUtil.getName(plyPath));
  452. }
  453. if(FileUtil.exist(pngPath)){
  454. map.put(pngPath, String.format(UploadFilePath.IMG_VIEW_PATH, num) + "cover/" + FileUtil.getName(pngPath));
  455. }
  456. if(FileUtil.exist(infoJsonPath)){
  457. map.put(infoJsonPath, String.format(UploadFilePath.IMG_VIEW_PATH, num) + "cover/" + FileUtil.getName(infoJsonPath));
  458. }
  459. return hasAi;
  460. }
  461. private void sendMqForBcgn(String num){
  462. Map<String, String> map = new HashMap<>();
  463. map.put("num", num);
  464. mqProducer.sendByWorkQueue("detect-queue", map);
  465. }
  466. private void sendMqForAiPano(String num){
  467. Map<String, String> map = new HashMap<>();
  468. map.put("num", num);
  469. mqProducer.sendByWorkQueue("detect-queue-pano", map);
  470. }
  471. private Map<String, String> getUploadFiles(ScenePlus scenePlus,String path,Integer cameraType,JSONObject fdageData) throws Exception {
  472. if (ObjectUtils.isEmpty(scenePlus)) {
  473. throw new Exception("未找到场景信息:" + path);
  474. }
  475. String projectNum = scenePlus.getNum();
  476. String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, projectNum);
  477. String imagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, projectNum);
  478. String videoPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, projectNum);
  479. String resultsPath = path + File.separator + "results" + File.separator;
  480. String uploadData = FileUtils.readFile(resultsPath + "upload.json");
  481. JSONArray array = JSONObject.parseObject(uploadData).getJSONArray("upload");
  482. JSONObject fileJson = null;
  483. String fileName = "";
  484. Map<String, String> map = new HashMap();
  485. for (int i = 0; i < array.size(); ++i) {
  486. fileJson = array.getJSONObject(i);
  487. fileName = fileJson.getString("file");
  488. String filePath = resultsPath + fileName;
  489. if (!(new File(filePath)).exists()) {
  490. throw new Exception(filePath + "文件不存在");
  491. }
  492. if ("vision2.txt".equals(fileName)) {
  493. CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision2.txt", resultsPath + "vision2.modeldata");
  494. map.put(resultsPath + "vision2.modeldata", imagesPath + "vision2.modeldata");
  495. map.put(resultsPath + "vision2.txt", imagesPath + "vision2.txt");
  496. }
  497. if (fileJson.getIntValue("clazz") == 2) {
  498. map.put(filePath, imagesPath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
  499. } else if (fileJson.getIntValue("clazz") == 3) {
  500. map.put(filePath, imagesPath + "pan/high/" + fileName.replace("high/", ""));
  501. } else if (fileJson.getIntValue("clazz") == 4) {
  502. map.put(filePath, imagesPath + "pan/low/" + fileName.replace("low/", ""));
  503. } else if (fileJson.getIntValue("clazz") == 5) {
  504. map.put(filePath, imagesPath + fileName);
  505. } else if (fileJson.getIntValue("clazz") == 7) {
  506. map.put(filePath, imagesPath + fileName);
  507. } else if (fileJson.getIntValue("clazz") == 10) {
  508. String updown = FileUtils.readFile(filePath);
  509. JSONObject updownJson = JSONObject.parseObject(updown);
  510. String mappingOssPath = String.format("scene_edit_data/%s/data/", projectNum) + fileName.replace("updown", "mapping");
  511. map.put(filePath, mappingOssPath);
  512. } else {
  513. if (fileJson.getIntValue("clazz") == 11 || fileJson.getIntValue("clazz") == 12) {
  514. map.put(filePath, videoPath + fileName.replace("videos/", ""));
  515. if (fileName.contains(".mp4")) {
  516. map.put(resultsPath + fileName.replace("mp4", "flv"), videoPath + fileName.replace("videos/", "").replace("mp4", "flv"));
  517. }
  518. }
  519. if (fileJson.getIntValue("clazz") == 16) {
  520. map.put(filePath, dataViewPath + fileName);
  521. }
  522. if (fileJson.getIntValue("clazz") == 18) {
  523. map.put(filePath, imagesPath + fileName);
  524. }
  525. }
  526. }
  527. //exportMeshObj这个是字段由app写入的
  528. boolean genModel = true;//是否生成模型 默认生成,深时场景要根据 exportMeshObj判断是否生成
  529. if(!ObjectUtils.isEmpty(cameraType)
  530. && cameraType == 14
  531. && (!fdageData.containsKey("exportMeshObj") || fdageData.getIntValue("exportMeshObj") != 1)){
  532. genModel = false;
  533. }
  534. boolean gen3dTiles = true;//是否生成3dtiles模型 默认生成
  535. if(!ModelKind.THREE_D_TILE.code().equals(modelKind)
  536. || CollUtil.isEmpty(sdTilesSceneSourceList)
  537. || !sdTilesSceneSourceList.contains(scenePlus.getSceneSource())){
  538. gen3dTiles = false;
  539. }
  540. if(genModel){
  541. if (!gen3dTiles) {
  542. String damPath = path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam";
  543. CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", damPath);
  544. // FileUtil.writeBytes(ZipUtil.gzip(new File(damPath)), damPath);
  545. map.put(damPath, imagesPath + ConstantFileName.modelUUID + "_50k.dam");
  546. }else{
  547. List<String> list = FileUtils.list(new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
  548. if(CollUtil.isEmpty(list)){
  549. log.error("3dtiles目录异常,3dtiles地址:{}", new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
  550. throw new Exception("3dtiles目录异常");
  551. }
  552. list.stream().forEach(str->{
  553. map.put(str, str.replace(path + File.separator + "results" + File.separator, imagesPath));
  554. });
  555. }
  556. }
  557. CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision.txt", resultsPath + "vision.modeldata");
  558. map.put(resultsPath + "vision.txt", imagesPath + "vision.txt");
  559. map.put(resultsPath + "vision.modeldata", imagesPath + "vision.modeldata");
  560. log.info("数据转换完成:" + projectNum);
  561. if(!new File("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum).exists()){
  562. FileUtil.mkdir("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum);
  563. }
  564. // map.put(resultsPath + "floorplan.json", dataViewPath + "floor.json");
  565. map.put(resultsPath + "floorplan_cad.json", dataViewPath + "floorplan_cad.json");
  566. map.put(path + File.separator + "capture/stitch_params.txt", dataViewPath + "stitch_params.txt");
  567. map.put(path + File.separator + "capture/Up.xml", dataViewPath + "Up.xml");
  568. map.put(path + File.separator + "capture/Up2.xml", dataViewPath + "Up2.xml");
  569. map.put(path + File.separator + "capture/Up.txt", dataViewPath + "Up.txt");
  570. map.put(path + File.separator + "capture/Up2.txt", dataViewPath + "Up2.txt");
  571. return map;
  572. }
  573. private JSONObject getFdageData(String dataFdagePath) {
  574. log.info("dataFdagePath 文件路径 :{}", dataFdagePath);
  575. String data = FileUtils.readFile(dataFdagePath);
  576. //获取data.fdage的内容
  577. JSONObject dataJson = new JSONObject();
  578. if(data!=null){
  579. dataJson = JSONObject.parseObject(data);
  580. }
  581. return dataJson;
  582. }
  583. private void uploadFloorCad(String path, String num, Map<String, String> uploadFiles){
  584. //户型图上传
  585. String dataViewPath = UploadFilePath.DATA_VIEW_PATH + "floor-cad-%s.%s";
  586. String floorCadPath = path + "/results/floorplan_cad";
  587. List<String> floorCadList = FileUtils.getFileList(floorCadPath);
  588. if(CollUtil.isNotEmpty(floorCadList)){
  589. floorCadList.stream().forEach(str->{
  590. String substring = str.substring(str.lastIndexOf(File.separator) + 1);
  591. String[] arr = substring.split("floor");
  592. String[] arr2 = arr[1].split("\\.");
  593. uploadFiles.put(str, String.format(dataViewPath, num, arr2[0], arr2[1]));
  594. });
  595. }
  596. }
  597. private void uploadStatusJson(ScenePlus scenePlus, ScenePlusExt scenePlusExt){
  598. String num = scenePlus.getNum();
  599. String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
  600. Integer status = 1;
  601. if(scenePlus.getSceneSource() == 4 || scenePlus.getSceneSource() == 5){//如果是激光场景,需要激光系统那边完全处理好之后再发mq通知更新状态
  602. status = 0;
  603. }
  604. // 上传status JSON.
  605. JSONObject statusJson = new JSONObject();
  606. //临时将-2改成1,app还没完全更新
  607. statusJson.put("status", status);
  608. statusJson.put("webSite", scenePlusExt.getWebSite());
  609. statusJson.put("sceneNum", num);
  610. statusJson.put("thumb", scenePlusExt.getThumb());
  611. statusJson.put("payStatus", scenePlus.getPayStatus());
  612. statusJson.put("sceneScheme", scenePlusExt.getSceneScheme());
  613. FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json", statusJson.toString());
  614. Map<String,String> headers = new HashMap<>();
  615. headers.put(HttpHeaders.CONTENT_TYPE, ContentType.JSON.getValue());
  616. fYunFileService.uploadFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json", dataViewPath + "status.json", headers);
  617. }
  618. private void createQrCode(String num, ScenePlusExt scenePlusExt, String qrLogo) {
  619. String localLogoPath = null;
  620. if (!ObjectUtils.isEmpty(qrLogo)) {
  621. try {
  622. localLogoPath = ConstantFilePath.AGENT_PATH + qrLogo.substring(qrLogo.lastIndexOf("//") + 1);
  623. HttpUtil.downloadFile(qrLogo, localLogoPath);
  624. } catch (Exception e) {
  625. log.error("公司logo下载失败:{}", qrLogo);
  626. localLogoPath = null;
  627. }
  628. }
  629. //生成二维码
  630. String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +".png";
  631. String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +"_en.png";
  632. QrConfig qrConfig = QrConfig.create();
  633. qrConfig.setWidth(1024);
  634. qrConfig.setHeight(1024);
  635. if(StrUtil.isNotEmpty(localLogoPath)){
  636. qrConfig.setImg(localLogoPath);
  637. }
  638. QrCodeUtil.generate(scenePlusExt.getWebSite(), qrConfig, FileUtil.file(outPathZh));
  639. QrCodeUtil.generate(scenePlusExt.getWebSite() + "&lang=en", qrConfig, FileUtil.file(outPathEn));
  640. //上传二维码
  641. fYunFileService.uploadFile(outPathZh, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + ".png");
  642. fYunFileService.uploadFile(outPathEn, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + "_en.png");
  643. if(!ObjectUtils.isEmpty(localLogoPath)){
  644. FileUtils.deleteFile(localLogoPath);
  645. }
  646. }
  647. private void pushMsgToApp(Integer pushChannel, String pushToken, int cameraType, String sceneName, String webSite){
  648. log.info("推送消息,渠道是 {}, 手机token是 {}", pushChannel, pushToken);
  649. if(Objects.isNull(pushChannel) || StrUtil.isBlank(pushToken)){
  650. return;
  651. }
  652. String title = sceneName + "计算完成";
  653. String body = "您上传的" + sceneName + "计算完成,点击查看";
  654. try{
  655. if(FYunTypeEnum.AWS.code().equals(fYunFileService.getFyunType())){
  656. PushMsgUtil.googlePushMsg(ConstantFilePath.BASE_PATH + "/refreshToken.json", pushToken,
  657. title, body , webSite);
  658. return;
  659. }
  660. PushMessageConfig pushConfig = null;
  661. if(pushChannel == 0){
  662. if(cameraType == 10 || cameraType == 13){
  663. //ios
  664. pushConfig = new PushMessageConfig(PushMessageConfig.IOS_KEY_Z, PushMessageConfig.IOS_SECRET_Z);
  665. pushConfig.sendIOSUnicast(pushToken, "四维看看Minion",title, body, webSite);
  666. }else {
  667. //ios
  668. pushConfig = new PushMessageConfig(PushMessageConfig.IOS_KEY, PushMessageConfig.IOS_SECRET);
  669. pushConfig.sendIOSUnicast(pushToken, "四维看看Pro",title, body, webSite);
  670. }
  671. }else {
  672. if(cameraType == 10 || cameraType == 13){
  673. //ios
  674. //安卓
  675. pushConfig = new PushMessageConfig(PushMessageConfig.ANDROID_KEY_Z, PushMessageConfig.ANDROID_SECRET_Z);
  676. pushConfig.sendAndroidUnicast2(pushToken, "四维看看Minion",title, body, webSite);
  677. }else {
  678. //安卓
  679. pushConfig = new PushMessageConfig(PushMessageConfig.ANDROID_KEY, PushMessageConfig.ANDROID_SECRET);
  680. pushConfig.sendAndroidUnicast(pushToken, "四维看看Pro",title, body, webSite);
  681. }
  682. }
  683. log.info("消息推送结束!");
  684. }catch (Exception e){
  685. log.error("推送消息失败:", e);
  686. }
  687. }
  688. private void copyToEditDir(String num) throws IOException {
  689. String editImagesPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
  690. String viewImagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
  691. String editDataPath = String.format(UploadFilePath.DATA_EDIT_PATH, num);
  692. String viewDataPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
  693. Map<String, String> map = new HashMap<>();
  694. map.put(editImagesPath + "vision.modeldata", viewImagesPath + "vision.modeldata");
  695. map.put(editImagesPath + "vision2.modeldata", viewImagesPath + "vision2.modeldata");
  696. map.put(editDataPath + "floorplan_cad.json", viewDataPath + "floorplan_cad.json");
  697. for (Entry<String, String> entry : map.entrySet()) {
  698. fYunFileService.copyFileInBucket(entry.getValue(), entry.getKey());
  699. }
  700. }
  701. private JSONObject getVideosJson(String path, Integer videoVersion, String projectNum, int cameraType) throws Exception {
  702. //读取videos_hdr_param.json, 保存点位视频的value
  703. Map<String, Object> videoMap = new HashMap<>();
  704. String videosHdr = FileUtils.readFile(path + File.separator + "results/videos/videos_hdr_param.json");
  705. JSONArray videoArray = null;
  706. if(StringUtils.isNotEmpty(videosHdr)){
  707. videoArray = JSONObject.parseObject(videosHdr).getJSONArray("hdr_param");
  708. }
  709. if(videoArray != null){
  710. for(int i = 0, len = videoArray.size(); i < len; i++) {
  711. videoMap.put(videoArray.getJSONObject(i).getString("name"), videoArray.getJSONObject(i).getString("value"));
  712. if(videoArray.getJSONObject(i).containsKey("fov")){
  713. videoMap.put(videoArray.getJSONObject(i).getString("name") + "_fov", videoArray.getJSONObject(i).getString("fov"));
  714. }
  715. }
  716. }
  717. //获取upload中的video视频名称
  718. String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
  719. JSONObject uploadJson = null;
  720. JSONArray array = null;
  721. if(uploadData!=null) {
  722. uploadJson = JSONObject.parseObject(uploadData);
  723. array = uploadJson.getJSONArray("upload");
  724. }
  725. JSONObject fileJson = null;
  726. String fileName = "";
  727. //计算ts文件的大小,并拼接成json格式
  728. JSONArray jsonArray = new JSONArray();
  729. JSONObject videoJson = null;
  730. JSONObject videosJson = new JSONObject();
  731. long videoSize = 0L;
  732. for(int i = 0, len = array.size(); i < len; i++) {
  733. fileJson = array.getJSONObject(i);
  734. fileName = fileJson.getString("file");
  735. if(fileJson.getIntValue("clazz") == 11 && fileName.contains(".mp4") && !fileName.contains("-ios.mp4")){
  736. videoJson = new JSONObject();
  737. videoJson.put("id", fileName.substring(
  738. 0, fileName.lastIndexOf(".")).replace("videos/", ""));
  739. //如果ts文件存在,就计算ts大小
  740. if(new File(path + File.separator + "results" +File.separator+ fileName.replace(".mp4", ".ts")).exists()){
  741. videoSize = new File(path + File.separator + "results" +File.separator+ fileName.replace(".mp4", ".ts")).length();
  742. videoJson.put("tsSize", videoSize);
  743. }
  744. if(videoMap.containsKey(videoJson.get("id"))){
  745. videoJson.put("value", videoMap.get(videoJson.get("id")));
  746. }
  747. if(videoMap.containsKey(videoJson.get("id") + "_fov")){
  748. videoJson.put("blend_fov", videoMap.get(videoJson.get("id") + "_fov"));
  749. }else {
  750. videoJson.put("blend_fov", 7);
  751. }
  752. jsonArray.add(videoJson);
  753. }
  754. }
  755. videosJson.put("data", jsonArray);
  756. if(Objects.nonNull(videoVersion) && videoVersion >= 4){
  757. videosJson.put("version", 3);
  758. videosJson.put("upPath", String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "Up.xml");
  759. if(cameraType == 13 || cameraType == 14){
  760. //转台相机
  761. videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
  762. }
  763. }else {
  764. videosJson.put("version", 1);
  765. videosJson.put("upPath", String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "Up2.xml");
  766. if(cameraType == 13 || cameraType == 14){
  767. //转台相机
  768. videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
  769. }
  770. }
  771. if(cameraType == 5 || cameraType == 6){
  772. videosJson.put("version", 1);
  773. videosJson.put("upPath", String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "stitch_params.txt");
  774. }
  775. return videosJson;
  776. }
  777. private void updateDbPlus(int sceneSource,Long space,String videosJson, Long computeTime,boolean isObj,ScenePlusExt scenePlusExt){
  778. scenePlusExt.setSpace(space);
  779. scenePlusExt.setComputeTime(computeTime.toString());
  780. scenePlusExt.setAlgorithmTime(new Date());
  781. scenePlusExt.setVideos(videosJson);
  782. scenePlusExt.setIsObj(isObj ? 1 : 0);
  783. if(ModelTypeEnums.TILE_CODE.equals(modelType)){
  784. scenePlusExt.setSceneScheme(3);
  785. }
  786. switch (SceneSource.get(sceneSource)){
  787. case BM:
  788. scenePlusExt.setSceneResolution(SceneResolution.two_K.code());
  789. scenePlusExt.setSceneFrom(SceneFrom.PRO.code());
  790. break;
  791. case SM:
  792. scenePlusExt.setSceneResolution(SceneResolution.one_k.code());
  793. scenePlusExt.setSceneFrom(SceneFrom.LITE.code());
  794. break;
  795. case ZT:
  796. scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
  797. scenePlusExt.setSceneFrom(SceneFrom.MINION.code());
  798. break;
  799. case JG:
  800. scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
  801. scenePlusExt.setSceneFrom(SceneFrom.LASER.code());
  802. break;
  803. case SG:
  804. scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
  805. scenePlusExt.setSceneFrom(SceneFrom.LASER.code());
  806. break;
  807. }
  808. String sceneKind = scenePlusExt.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code();
  809. scenePlusExt.setSceneKind(sceneKind);
  810. // scenePlusExt.setModelKind(modelKind);
  811. //统计点位数量
  812. Map<String, Integer> result = this.getShootCount(scenePlusExt);
  813. Integer shootCount = result.get("shootCount");
  814. Integer mixture = result.get("mixture");
  815. scenePlusExt.setShootCount(shootCount);
  816. scenePlusExt.setMixture(mixture);
  817. scenePlusExtService.updateById(scenePlusExt);
  818. }
  819. private Map<String, Integer> getShootCount(ScenePlusExt scenePlusExt){
  820. Map<String, Integer> result = new HashMap<>();
  821. Integer shootCount = 0;
  822. Integer mixture = Objects.isNull(scenePlusExt.getMixture()) ? 0 : scenePlusExt.getMixture();
  823. String homePath = SceneUtil.getHomePath(scenePlusExt.getDataSource());
  824. JSONObject dataFdageObj = JSON.parseObject(fYunFileService.getFileContent(homePath.concat("data.fdage")));
  825. if(Objects.nonNull(dataFdageObj)){
  826. JSONArray points = dataFdageObj.getJSONArray("points");
  827. if(CollUtil.isNotEmpty(points)){
  828. shootCount = points.size();
  829. }
  830. }
  831. if(Objects.nonNull(shootCount) && shootCount > 0){
  832. if(Objects.nonNull(scenePlusExt.getLocation()) && scenePlusExt.getLocation() == 6){
  833. mixture = CommonStatus.YES.code().intValue();
  834. }
  835. }else{
  836. String slamDataStr = fYunFileService.getFileContent(homePath.concat("slam_data.json"));
  837. JSONObject slamDataObj = JSON.parseObject(slamDataStr);
  838. if(Objects.nonNull(slamDataObj)){
  839. JSONArray viewsInfo = slamDataObj.getJSONArray("views_info");
  840. if(CollUtil.isNotEmpty(viewsInfo)){
  841. shootCount = viewsInfo.stream().mapToInt(info -> {
  842. return ((JSONObject) info).getJSONArray("list_pose").size();
  843. }).sum();
  844. }
  845. }
  846. mixture = CommonStatus.NO.code().intValue();
  847. }
  848. result.put("shootCount", shootCount);
  849. result.put("mixture", mixture);
  850. return result;
  851. }
  852. public static void main(String[] args) {
  853. // JSONObject dataFdageObj = JSON.parseObject(null);
  854. // System.out.println(dataFdageObj);
  855. 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}";
  856. BuildSceneResultMqMessage message = JSONObject.parseObject(test, BuildSceneResultMqMessage.class);
  857. Map<String, Object> ext = message.getExt();
  858. JSONObject detFloorplanObj = (JSONObject)ext.get("detFloorplan");
  859. for (String s : detFloorplanObj.keySet()) {
  860. System.out.println(s + ":" + detFloorplanObj.getBoolean(s));
  861. }
  862. }
  863. public boolean uploadHouseTypeJson(String num, String dataSource) {
  864. String floorPlanCardFilePath = dataSource + File.separator + "results/floorplan_cad.json";
  865. if (!new File(floorPlanCardFilePath).exists()) {
  866. log.warn("floorplan_cad.json 文件不存在,文件路径:{}", floorPlanCardFilePath);
  867. return false;
  868. }
  869. JSONObject json = CreateHouseJsonUtil.createHouseTypeJsonByCad(floorPlanCardFilePath);
  870. if(Objects.isNull(json)){
  871. return false;
  872. }
  873. String hourseTypeJsonPath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "houseType.json";
  874. fYunFileService.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
  875. hourseTypeJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "houseType.json";
  876. fYunFileService.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
  877. return true;
  878. }
  879. private void sendFailToLaser(String num){
  880. ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  881. if(SceneSource.JG.code() != scenePlus.getSceneSource().intValue() && SceneSource.SG.code() != scenePlus.getSceneSource().intValue()){
  882. return;
  883. }
  884. Map<String, Object> params = new HashMap<>();
  885. params.put("sceneCode", num);
  886. params.put("status", 1);
  887. params.put("createTime", DateUtil.date2String(scenePlus.getCreateTime(), null));
  888. params.put("algorithmTime", DateUtil.date2String(Calendar.getInstance().getTime(), null));
  889. params.put("sceneSource", scenePlus.getSceneSource());
  890. fdkkLaserService.syncFailResult(params);
  891. }
  892. }