CommonServiceImpl.java 23 KB

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