BuildSceneServiceImpl.java 44 KB

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