BuildSceneServiceImpl.java 45 KB

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