CommonServiceImpl.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. package com.fdkankan.contro.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.http.HttpUtil;
  6. import com.alibaba.fastjson.JSON;
  7. import com.alibaba.fastjson.JSONObject;
  8. import com.fdkankan.common.util.FileUtils;
  9. import cn.hutool.core.util.StrUtil;
  10. import com.alibaba.fastjson.JSONObject;
  11. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  12. import com.fdkankan.common.constant.CommonStatus;
  13. import com.fdkankan.common.constant.PayStatus;
  14. import com.fdkankan.common.constant.SceneStatus;
  15. import com.fdkankan.common.constant.SpaceType;
  16. import com.fdkankan.common.util.FileUtils;
  17. import com.fdkankan.contro.bean.SceneJsonBean;
  18. import com.fdkankan.contro.entity.*;
  19. import com.fdkankan.contro.factory.UserEditData.UserEditDataHandler;
  20. import com.fdkankan.contro.factory.UserEditData.UserEditDataHandlerFactory;
  21. import com.fdkankan.contro.service.ICommonService;
  22. import com.fdkankan.contro.service.*;
  23. import com.fdkankan.contro.vo.SceneEditControlsVO;
  24. import com.fdkankan.contro.vo.ScenePlusVO;
  25. import com.fdkankan.fyun.config.FYunFileConfig;
  26. import com.fdkankan.fyun.face.FYunFileServiceInterface;
  27. import com.fdkankan.model.constants.ConstantFilePath;
  28. import com.fdkankan.model.constants.UploadFilePath;
  29. import com.fdkankan.model.utils.FloorPlanUserUtil;
  30. import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
  31. import com.fdkankan.rabbitmq.util.RabbitMqProducer;
  32. import com.fdkankan.redis.constant.RedisKey;
  33. import com.fdkankan.redis.util.RedisUtil;
  34. import com.fdkankan.sms.SendMailAcceUtils;
  35. import lombok.extern.slf4j.Slf4j;
  36. import org.apache.commons.lang3.ObjectUtils;
  37. import org.springframework.beans.factory.annotation.Autowired;
  38. import org.springframework.beans.factory.annotation.Value;
  39. import org.springframework.cloud.context.config.annotation.RefreshScope;
  40. import org.springframework.stereotype.Service;
  41. import javax.annotation.Resource;
  42. import java.io.File;
  43. import java.io.IOException;
  44. import java.util.HashMap;
  45. import java.util.List;
  46. import java.util.Map;
  47. import java.util.Objects;
  48. import java.util.Set;
  49. import java.util.Objects;
  50. import java.util.*;
  51. import java.util.stream.Collectors;
  52. @Slf4j
  53. @Service
  54. @RefreshScope
  55. public class CommonServiceImpl implements ICommonService {
  56. @Value("${main.url}")
  57. private String mainUrl;
  58. @Value("${env:gn}")
  59. private String env;
  60. @Value("${helpLink.zh-cn:https://docs.4dkankan.com/#/product/4dkk/zh-cn/README}")
  61. private String helpLinkZh;
  62. @Value("${helpLink.en-us:https://docs.4dkankan.com/#/product/4dkk/en-us/README}")
  63. private String helpLinkEn;
  64. @Value("#{'${camType.laser:}'.split(',')}")
  65. private List<Integer> laserCamTypeList;
  66. @Autowired
  67. private ISceneAsynOperLogService sceneAsynOperLogService;
  68. @Resource
  69. private FYunFileServiceInterface fYunFileServiceInterface;
  70. @Autowired
  71. private IScenePlusService scenePlusService;
  72. @Autowired
  73. private IScenePlusExtService scenePlusExtService;
  74. @Autowired
  75. private IMailTemplateService mailTemplateService;
  76. @Autowired
  77. private IUserService userService;
  78. @Autowired
  79. private ISceneProService sceneProService;
  80. @Autowired
  81. private ICameraDetailService cameraDetailService;
  82. @Autowired
  83. private IUserIncrementService userIncrementService;
  84. @Autowired
  85. private IIncrementTypeService incrementTypeService;
  86. @Autowired
  87. private ICameraService cameraService;
  88. @Autowired
  89. private FYunFileConfig fYunFileConfig;
  90. @Autowired
  91. private ISceneEditInfoService sceneEditInfoService;
  92. @Autowired
  93. private ISceneEditControlsService sceneEditControlsService;
  94. @Autowired
  95. private ISceneEditInfoExtService sceneEditInfoExtService;
  96. @Autowired
  97. private RedisUtil redisUtil;
  98. @Autowired
  99. private IMqSendLogService mqSendLogService;
  100. @Autowired
  101. private RabbitMqProducer rabbitMqProducer;
  102. @Autowired
  103. private ISceneInfoSyncMqConfigService sceneInfoSyncMqConfigService;
  104. @Override
  105. public void uploadBuildResultData(String num, String dataSource, String version) {
  106. Map<String, String> uploadMap = new HashMap<>();
  107. String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
  108. //删除旧的文件目录
  109. fYunFileServiceInterface.deleteFolder(ossResultPath);
  110. //上传caches/images
  111. String localCachesImagePath = dataSource + "/caches/images/";
  112. String ossCachesImagePath = ossResultPath + "caches/images/";
  113. //先清除旧的全景图
  114. if(FileUtil.exist(localCachesImagePath)){
  115. fYunFileServiceInterface.uploadFileByCommand(localCachesImagePath, ossCachesImagePath);
  116. }
  117. //上传project.json
  118. String localProjectJsonPath = dataSource + "/project.json";
  119. String ossProjectJsonPath = ossResultPath + "project.json";
  120. if(FileUtil.exist(localProjectJsonPath)){
  121. uploadMap.put(localProjectJsonPath, ossProjectJsonPath);
  122. }
  123. //上传data.json
  124. String localDataJsonPath = dataSource + "/data.json";
  125. String ossDataJsonPath = ossResultPath + "data.json";
  126. if(FileUtil.exist(localDataJsonPath)){
  127. uploadMap.put(localDataJsonPath, ossDataJsonPath);
  128. }
  129. //户型图上传
  130. String floorplanCadPath = ossResultPath + "floorplan_cad";
  131. String cadPicPathFormat = floorplanCadPath + "/floor-cad-%s.%s";
  132. String floorCadPath = dataSource + "/results/floorplan_cad";
  133. //清除原有旧的cad图
  134. fYunFileServiceInterface.deleteFolder(floorplanCadPath);
  135. List<String> floorCadList = FileUtils.getFileList(floorCadPath);
  136. if(CollUtil.isNotEmpty(floorCadList)){
  137. floorCadList.stream().forEach(str->{
  138. String substring = str.substring(str.lastIndexOf(File.separator) + 1);
  139. String[] arr = substring.split("floor");
  140. String[] arr2 = arr[1].split("\\.");
  141. //上传到用户编辑目录
  142. uploadMap.put(str, String.format(cadPicPathFormat, arr2[0], arr2[1]));
  143. });
  144. }
  145. //上传深时场景生成obj需要的文件
  146. String localReconstruction = dataSource + "/caches/reconstruction/";
  147. String ossReconstruction = ossResultPath + "caches/reconstruction/";
  148. if(FileUtil.exist(localReconstruction)){
  149. fYunFileServiceInterface.uploadFileByCommand(localReconstruction, ossReconstruction);
  150. }
  151. String localDepthmap = dataSource + "/caches/depthmap/";
  152. String ossDepthmap = ossResultPath + "caches/depthmap/";
  153. if(FileUtil.exist(localDepthmap)){
  154. fYunFileServiceInterface.uploadFileByCommand(localDepthmap, ossDepthmap);
  155. }
  156. String localDepthmapAsc = dataSource + "/caches/depthmap_csc/";
  157. String ossDepthmapAsc = ossResultPath + "caches/depthmap_csc/";
  158. if(FileUtil.exist(localDepthmapAsc)){
  159. fYunFileServiceInterface.uploadFileByCommand(localDepthmapAsc, ossDepthmapAsc);
  160. }
  161. String localPanoramaJson = dataSource + "/caches/panorama.json";
  162. String ossPanoramaJson = ossResultPath + "caches/panorama.json";
  163. if(FileUtil.exist(localPanoramaJson)){
  164. fYunFileServiceInterface.uploadFile(localPanoramaJson, ossPanoramaJson);
  165. }
  166. // String localLaserPly = dataSource + "/results/laserData/laser.ply";
  167. // String ossLaserPly = ossResultPath + "results/laserData/laser.ply";
  168. // if(FileUtil.exist(localLaserPly)){
  169. // fYunFileServiceInterface.uploadFile(localLaserPly, ossLaserPly);
  170. // }
  171. String localFloorGroupFixJson = dataSource + "/caches/floor_group_fix.json";
  172. String ossFloorGroupFixJson = ossResultPath + "caches/floor_group_fix.json";
  173. if(FileUtil.exist(localFloorGroupFixJson)){
  174. fYunFileServiceInterface.uploadFile(localFloorGroupFixJson, ossFloorGroupFixJson);
  175. }
  176. String localDepthmapVis = dataSource + "/caches/depthmap_vis";
  177. String ossDepthmapVis = ossResultPath + "caches/depthmap_vis";
  178. if(FileUtil.exist(localDepthmapVis)){
  179. fYunFileServiceInterface.uploadFileByCommand(localDepthmapVis, ossDepthmapVis);
  180. }
  181. String localIntensity = dataSource + "/caches/intensity";
  182. String ossIntensity = ossResultPath + "caches/intensity";
  183. if(FileUtil.exist(localIntensity)){
  184. fYunFileServiceInterface.uploadFileByCommand(localIntensity, ossIntensity);
  185. }
  186. //上传点位校准相关文件
  187. String localExtras = dataSource + "/extras";
  188. String ossExtras = ossResultPath + "extras";
  189. if(FileUtil.exist(localExtras)){
  190. fYunFileServiceInterface.uploadFileByCommand(localExtras, ossExtras);
  191. }
  192. //开始上传
  193. fYunFileServiceInterface.uploadMulFiles(uploadMap);
  194. }
  195. @Override
  196. public void uploadFloorplanJson(String num, String dataSource) throws Exception{
  197. String floorPlanCardFilePath = dataSource + File.separator + "results/floorplan_cad.json";
  198. if (!new File(floorPlanCardFilePath).exists()) {
  199. log.warn("floorplan_cad.json 文件不存在,文件路径:{}", floorPlanCardFilePath);
  200. return;
  201. }
  202. JSONObject json = FloorPlanUserUtil.createFloorPlanUserJson(floorPlanCardFilePath);
  203. if(Objects.isNull(json)){
  204. log.warn("生成floorplan.json失败,cadPath:{}", floorPlanCardFilePath);
  205. return;
  206. }
  207. String floorplanJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan.json";
  208. fYunFileServiceInterface.uploadFile(json.toJSONString().getBytes(), floorplanJsonPath);
  209. }
  210. @Override
  211. public void initUserEditData(String num, Set<String> bizs, Map<String, Map<String ,Object>> params) throws Exception {
  212. if(StrUtil.isEmpty(num) || CollUtil.isEmpty(bizs)){
  213. return;
  214. }
  215. for (String biz : bizs) {
  216. UserEditDataHandler handler = UserEditDataHandlerFactory.getHandler(biz);
  217. handler.init(num, CollUtil.isEmpty(params) ? null : params.get(biz));
  218. }
  219. }
  220. @Override
  221. public void sendEmail(String num) {
  222. try {
  223. Long userId = null;
  224. String websize = "";
  225. String title = "";
  226. ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  227. if(Objects.isNull(scenePlus)){
  228. ScenePro scenePro = sceneProService.getByNum(num);
  229. if(Objects.isNull(scenePro)){
  230. return;
  231. }
  232. userId = scenePro.getUserId();
  233. websize = scenePro.getWebSite();
  234. title = scenePro.getSceneName();
  235. }else{
  236. userId = scenePlus.getUserId();
  237. ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  238. websize = scenePlusExt.getWebSite();
  239. title = scenePlus.getTitle();
  240. }
  241. if(Objects.isNull(userId)){
  242. return;
  243. }
  244. User user = userService.getById(userId);
  245. if(Objects.isNull(user) || StrUtil.isEmpty(user.getUserName())){
  246. return;
  247. }
  248. String toEmail = user.getUserName();
  249. String helpLink = helpLinkEn;
  250. String lang = "en";
  251. if("gn".equals(env)){
  252. lang = "zh";
  253. helpLink = helpLinkZh;
  254. }
  255. websize += "&lang=" + lang;
  256. MailTemplate mailTemplate = mailTemplateService.getOne(new LambdaQueryWrapper<MailTemplate>().eq(MailTemplate::getRemark, "计算完成").eq(MailTemplate::getLang, lang));
  257. String content = mailTemplate.getMsg().replaceAll("scene_name", title).replaceAll("scene_link", websize).replaceAll("help_link", helpLink);
  258. SendMailAcceUtils.sendMail(mailTemplate.getSendMail(), mailTemplate.getSendPassword(), mailTemplate.getSendHost(), toEmail, mailTemplate.getSubject(), content, null);
  259. }catch (Exception e){
  260. log.error("发送邮件失败,num:" + num, e);
  261. }
  262. }
  263. public String getOssOrignPath(String path) {
  264. String ossPath = ConstantFilePath.OSS_PREFIX
  265. + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
  266. .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
  267. if (!ossPath.endsWith("/")) {
  268. ossPath = ossPath.concat("/");
  269. }
  270. return ossPath;
  271. }
  272. @Override
  273. public int getPayStatus(Long cameraId, Long space){
  274. //查询权益统计容量的方式
  275. String unit = SpaceType.GB.code();
  276. CameraDetail cameraDetail = cameraDetailService.getByCameraId(cameraId);
  277. if(StrUtil.isNotEmpty(cameraDetail.getUnit())){
  278. unit = cameraDetail.getUnit();
  279. }
  280. Long limit = this.getSpaceLimit(cameraDetail);
  281. if(SpaceType.SP.code().equals(unit)){//如果按空间方式统计,则space置为1
  282. space = 1L;
  283. }
  284. //更新相机使用用量,非激光相机或者是空间个数计算方式的,需要叠加相机容量
  285. cameraDetailService.updateCameraDetailByCameraIdAndSpace(cameraId, space);
  286. //无限容量或者激光相机,直接返回已支付
  287. if(limit == -1 || ("gn".equals(env) && CollUtil.isNotEmpty(laserCamTypeList) && laserCamTypeList.contains(cameraDetail.getType()))){
  288. return PayStatus.PAY.code();
  289. }
  290. Long usedSpace = cameraService.getUsedSpace(cameraId, unit);
  291. if(usedSpace + space > limit){
  292. return PayStatus.NO_CAPACITY.code();
  293. }
  294. return PayStatus.PAY.code();
  295. }
  296. @Override
  297. public void uploadStatusJson(String num, Integer sceneStatus, String webSite, String thumb, Integer payStatus, String uploadPath) {
  298. String localDataPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, num);
  299. JSONObject statusJson = new JSONObject();
  300. statusJson.put("status", sceneStatus);
  301. statusJson.put("webSite", webSite);
  302. statusJson.put("sceneNum", num);
  303. statusJson.put("thumb", thumb);
  304. statusJson.put("payStatus", PayStatus.NOT_PAY.code());
  305. statusJson.put("recStatus", 'A');
  306. FileUtils.writeFile(localDataPath + "status.json", statusJson.toString());
  307. fYunFileServiceInterface.uploadFile(localDataPath + "status.json", uploadPath + "status.json");
  308. }
  309. @Override
  310. public Long getSpaceLimit(CameraDetail cameraDetail){
  311. Long limit = cameraDetail.getTotalSpace();
  312. UserIncrement userIncrement = userIncrementService.getByCameraId(cameraDetail.getCameraId());
  313. if(Objects.nonNull(userIncrement) && userIncrement.getIsExpired() == CommonStatus.NO.code().intValue()){
  314. IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
  315. switch (SpaceType.get(cameraDetail.getUnit())){
  316. case GB:
  317. limit = incrementType.getCameraCapacity();
  318. if(limit != -1){
  319. limit = limit * 1024 * 1024 * 1024;
  320. }
  321. break;
  322. case SP:
  323. limit = incrementType.getCameraSpace();
  324. break;
  325. }
  326. }
  327. return limit;
  328. }
  329. @Override
  330. public Long getSpace(String num){
  331. Long space = fYunFileServiceInterface.getSpace(fYunFileConfig.getBucket(), String.format(UploadFilePath.DATA_VIEW_PATH, num));
  332. space += fYunFileServiceInterface.getSpace(fYunFileConfig.getBucket(), String.format(UploadFilePath.IMG_VIEW_PATH, num));
  333. space += fYunFileServiceInterface.getSpace(fYunFileConfig.getBucket(), String.format(UploadFilePath.VIDEOS_VIEW_PATH, num));
  334. space += fYunFileServiceInterface.getSpace(fYunFileConfig.getBucket(), String.format(UploadFilePath.VOICE_VIEW_PATH, num));
  335. space += fYunFileServiceInterface.getSpace(fYunFileConfig.getBucket(), String.format(UploadFilePath.scene_result_data_path, num).concat("caches"));
  336. return space;
  337. }
  338. public Object[] updateEditInfo(ScenePlus scenePlus){
  339. SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
  340. SceneEditControls sceneEditControls = null;
  341. SceneEditInfoExt sceneEditInfoExt = null;
  342. if(sceneEditInfo == null){
  343. sceneEditInfo = new SceneEditInfo();
  344. sceneEditInfo.setScenePlusId(scenePlus.getId());
  345. sceneEditInfo.setDescription(scenePlus.getDescription());
  346. sceneEditInfo.setTitle(scenePlus.getTitle());
  347. sceneEditInfoService.save(sceneEditInfo);
  348. }else{
  349. int version = 0;
  350. int imgVersion = 0;
  351. int linkVersion = 0;
  352. //获取展示页的版本号
  353. String sceneJsonStr = fYunFileServiceInterface.getFileContent(String.format(UploadFilePath.DATA_VIEW_PATH, scenePlus.getNum()) + "scene.json");
  354. if(StrUtil.isNotEmpty(sceneJsonStr)){
  355. JSONObject sceneJson = JSON.parseObject(sceneJsonStr);
  356. version = sceneJson.getIntValue("version");
  357. imgVersion = sceneJson.getIntValue("imgVersion");
  358. linkVersion = sceneJson.getIntValue("linkVersion");
  359. }
  360. if(version < sceneEditInfo.getVersion()){
  361. version = sceneEditInfo.getVersion();
  362. }
  363. if(imgVersion < sceneEditInfo.getImgVersion()){
  364. imgVersion = sceneEditInfo.getImgVersion();
  365. }
  366. if(linkVersion < sceneEditInfo.getLinkVersion()){
  367. linkVersion = sceneEditInfo.getLinkVersion();
  368. }
  369. sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
  370. sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
  371. sceneEditInfo.setVersion(version + 1);
  372. sceneEditInfo.setImgVersion(imgVersion + 1);
  373. sceneEditInfo.setLinkVersion(linkVersion + 1);
  374. sceneEditInfo.setIsUploadObj(CommonStatus.NO.code());
  375. sceneEditInfoService.updateById(sceneEditInfo);
  376. }
  377. if(sceneEditControls == null){
  378. sceneEditControls = new SceneEditControls();
  379. sceneEditControls.setEditInfoId(sceneEditInfo.getId());
  380. sceneEditControlsService.save(sceneEditControls);
  381. }
  382. if(sceneEditInfoExt == null){
  383. sceneEditInfoExt = new SceneEditInfoExt();
  384. sceneEditInfoExt.setScenePlusId(scenePlus.getId());
  385. sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
  386. sceneEditInfoExtService.save(sceneEditInfoExt);
  387. }
  388. return new Object[]{sceneEditInfo, sceneEditInfoExt, sceneEditControls};
  389. }
  390. public void writeSceneJson(String num, JSONObject videosJson, SceneEditInfo sceneEditInfo, SceneEditInfoExt sceneEditInfoExt,
  391. SceneEditControls sceneEditControls, ScenePlus scenePlus, ScenePlusExt scenePlusExt,Company company){
  392. String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
  393. String oldSceneJson = fYunFileServiceInterface.getFileContent(dataViewPath + "scene.json");
  394. SceneJsonBean sceneJson = new SceneJsonBean();
  395. BeanUtil.copyProperties(sceneEditInfoExt, sceneJson, "started");
  396. BeanUtil.copyProperties(sceneEditInfo, sceneJson);
  397. SceneEditControlsVO sceneEditControlsVO = BeanUtil.copyProperties(sceneEditControls, SceneEditControlsVO.class);
  398. sceneJson.setControls(sceneEditControlsVO);
  399. sceneJson.setNum(num);
  400. sceneJson.setCreateTime(scenePlus.getCreateTime());
  401. sceneJson.setSceneResolution(scenePlusExt.getSceneResolution());
  402. sceneJson.setVersion(sceneEditInfo.getVersion());
  403. sceneJson.setImgVersion(sceneEditInfo.getImgVersion());
  404. sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
  405. sceneJson.setSceneKind(scenePlusExt.getSceneKind());
  406. sceneJson.setModelKind(scenePlusExt.getModelKind());
  407. sceneJson.setVideos(JSON.toJSONString(videosJson));
  408. sceneJson.setPayStatus(scenePlus.getPayStatus());
  409. if(StrUtil.isNotEmpty(oldSceneJson)){
  410. SceneJsonBean oldSceneJsonBean = JSON.parseObject(oldSceneJson, SceneJsonBean.class);
  411. List<JSONObject> mosaicList = JSON.parseObject(oldSceneJson, SceneJsonBean.class).getMosaicList();
  412. sceneJson.setMosaicList(mosaicList);
  413. sceneJson.setFloorLogo(oldSceneJsonBean.getFloorLogo());
  414. sceneJson.setFloorLogoFile(oldSceneJsonBean.getFloorLogoFile());
  415. sceneJson.setBoxModels(oldSceneJsonBean.getBoxModels());
  416. sceneJson.setBoxVideos(oldSceneJsonBean.getBoxVideos());
  417. sceneJson.setBoxPhotos(oldSceneJsonBean.getBoxPhotos());
  418. }
  419. if(StrUtil.isNotEmpty(sceneEditInfoExt.getStarted())){
  420. log.info("开始转换started:{}", sceneEditInfoExt.getStarted());
  421. sceneJson.setStarted(JSON.parseObject(sceneEditInfoExt.getStarted()));
  422. log.info("结束转换started:{}", sceneEditInfoExt.getStarted());
  423. }
  424. if(!ObjectUtils.isEmpty(company)){
  425. String userViewPath = String.format(UploadFilePath.USER_VIEW_PATH, num);
  426. String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
  427. String localLogoPath = null;
  428. if (StrUtil.isNotEmpty(company.getTopLogo())) {
  429. localLogoPath = ConstantFilePath.AGENT_PATH + company.getTopLogo().substring(company.getTopLogo().lastIndexOf("//") + 1);
  430. if(company.getTopLogo().startsWith("http")){
  431. HttpUtil.downloadFile(company.getTopLogo(), localLogoPath);
  432. }else{
  433. fYunFileServiceInterface.downloadFile(company.getTopLogo().substring(1), localLogoPath);
  434. }
  435. fYunFileServiceInterface.uploadFile(localLogoPath, userViewPath + "loadingLogo-user.png");
  436. fYunFileServiceInterface.uploadFile(localLogoPath, userEditPath + "loadingLogo-user.png");
  437. sceneJson.setLoadingLogo("user");
  438. sceneJson.setLoadingLogoFile("loadingLogo-user.png");
  439. sceneEditInfo.setLoadingLogo("user");
  440. sceneEditInfo.setLoadingLogoFile("loadingLogo-user.png");
  441. }
  442. if (StrUtil.isNotEmpty(company.getFloorLogo())) {
  443. if(company.getFloorLogo().startsWith("http")){
  444. HttpUtil.downloadFile(company.getFloorLogo(), localLogoPath);
  445. }else{
  446. fYunFileServiceInterface.downloadFile(company.getFloorLogo().substring(1), localLogoPath);
  447. }
  448. localLogoPath = ConstantFilePath.AGENT_PATH + company.getFloorLogo().substring(company.getFloorLogo().lastIndexOf("//") + 1);
  449. fYunFileServiceInterface.uploadFile(localLogoPath, userViewPath + "floorLogo-user.png");
  450. fYunFileServiceInterface.uploadFile(localLogoPath, userEditPath + "floorLogo-user.png");
  451. sceneJson.setFloorLogo("user");
  452. sceneJson.setFloorLogoFile("floorLogo-user.png");
  453. sceneEditInfo.setFloorLogo("user");
  454. sceneEditInfo.setFloorLogoFile("floorLogo-user.png");
  455. }
  456. if(!ObjectUtils.isEmpty(localLogoPath)){
  457. sceneEditInfoService.updateById(sceneEditInfo);
  458. FileUtils.deleteFile(localLogoPath);
  459. }
  460. }
  461. String sceneJsonStr = JSON.toJSONString(sceneJson);
  462. //上传sceneJson文件
  463. fYunFileServiceInterface.uploadFile(sceneJsonStr.getBytes(), dataViewPath + "scene.json");
  464. //scenejson写入缓存
  465. redisUtil.set(String.format(RedisKey.SCENE_JSON, num), sceneJsonStr);
  466. }
  467. @Override
  468. public void saveMqSendLog(String num, BuildSceneCallMessage message) {
  469. MqSendLog mqSendLog = new MqSendLog();
  470. mqSendLog.setNum(num);
  471. mqSendLog.setContent(JSON.toJSONString(message));
  472. mqSendLogService.save(mqSendLog);
  473. }
  474. @Override
  475. public void sendUpdateSceneStatusMqToQueues(Map<String, Object> content) {
  476. List<SceneInfoSyncMqConfig> configs = sceneInfoSyncMqConfigService.listByInfoType("update_scene_status");
  477. if(CollUtil.isEmpty(configs)){
  478. return;
  479. }
  480. for (SceneInfoSyncMqConfig config : configs) {
  481. rabbitMqProducer.sendByWorkQueue(config.getQueueName(), content);
  482. }
  483. }
  484. @Override
  485. public void removeSceneAsynOperLog(String num) {
  486. List<SceneAsynOperLog> list = sceneAsynOperLogService.list(new LambdaQueryWrapper<SceneAsynOperLog>().eq(SceneAsynOperLog::getNum, num));
  487. if(CollUtil.isEmpty(list)){
  488. return;
  489. }
  490. //删除数据库记录
  491. List<Long> deleteIdList = list.parallelStream().map(item -> item.getId()).collect(Collectors.toList());
  492. sceneAsynOperLogService.removeByIds(deleteIdList);
  493. list.parallelStream().forEach(item -> {
  494. if(StrUtil.isNotEmpty(item.getUrl())){
  495. try {
  496. fYunFileServiceInterface.deleteFile(item.getUrl());
  497. } catch (IOException e) {
  498. log.warn("删除oss全景图下载压缩包失败,key:{}", item.getUrl());
  499. }
  500. }
  501. });
  502. }
  503. }