BuildSceneServiceImpl.java 45 KB

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