CommonServiceImpl.java 24 KB

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