BuildSceneServiceImpl.java 44 KB

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