CommonServiceImpl.java 25 KB

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