BuildSceneServiceImpl.java 44 KB

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