SceneProServiceImpl.java 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359
  1. package com.fdkankan.ucenter.service.impl;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.io.FileUtil;
  4. import cn.hutool.core.thread.ThreadUtil;
  5. import cn.hutool.json.JSONUtil;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  8. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  9. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  10. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  11. import com.fdkankan.common.constant.SceneConstant;
  12. import com.fdkankan.common.constant.SceneKind;
  13. import com.fdkankan.common.constant.SceneVersionType;
  14. import com.fdkankan.common.exception.BusinessException;
  15. import com.fdkankan.common.util.*;
  16. import com.fdkankan.model.constants.UploadFilePath;
  17. import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
  18. import com.fdkankan.rabbitmq.util.RabbitMqProducer;
  19. import com.fdkankan.redis.constant.RedisKey;
  20. import com.fdkankan.ucenter.common.OssPath;
  21. import com.fdkankan.ucenter.common.PageInfo;
  22. import com.fdkankan.fyun.face.FYunFileServiceInterface;
  23. import com.fdkankan.image.MatrixToImageWriterUtil;
  24. import com.fdkankan.ucenter.common.constants.ConstantFilePath;
  25. import com.fdkankan.redis.util.RedisUtil;
  26. import com.fdkankan.ucenter.common.constants.NacosProperty;
  27. import com.fdkankan.ucenter.common.utils.ShellUtil;
  28. import com.fdkankan.ucenter.constant.CameraConstant;
  29. import com.fdkankan.ucenter.constant.LoginConstant;
  30. import com.fdkankan.ucenter.entity.*;
  31. import com.fdkankan.ucenter.httpClient.service.LaserService;
  32. import com.fdkankan.ucenter.mapper.ISceneProMapper;
  33. import com.fdkankan.ucenter.mapper.ISceneUpgradeMapper;
  34. import com.fdkankan.ucenter.service.*;
  35. import com.fdkankan.ucenter.util.DateUserUtil;
  36. import com.fdkankan.ucenter.vo.ResponseScene;
  37. import com.fdkankan.ucenter.vo.request.RequestScene;
  38. import com.fdkankan.ucenter.vo.request.SceneParam;
  39. import com.fdkankan.ucenter.vo.response.GroupByCount;
  40. import com.fdkankan.ucenter.vo.response.SceneInfoVo;
  41. import com.fdkankan.ucenter.vo.response.SceneNumVo;
  42. import com.fdkankan.ucenter.vo.response.SceneVo;
  43. import java.io.File;
  44. import java.net.InetAddress;
  45. import java.net.UnknownHostException;
  46. import java.util.ArrayList;
  47. import java.util.Arrays;
  48. import java.util.Collections;
  49. import java.util.Date;
  50. import java.util.HashMap;
  51. import java.util.List;
  52. import java.util.Map;
  53. import java.util.Objects;
  54. import java.util.concurrent.CompletableFuture;
  55. import java.util.concurrent.ExecutorService;
  56. import java.util.concurrent.locks.Condition;
  57. import java.util.stream.Collectors;
  58. import javax.annotation.Resource;
  59. import lombok.extern.slf4j.Slf4j;
  60. import org.apache.commons.lang3.StringUtils;
  61. import org.joda.time.DateTime;
  62. import org.springframework.beans.BeanUtils;
  63. import org.springframework.beans.factory.annotation.Autowired;
  64. import org.springframework.beans.factory.annotation.Value;
  65. import org.springframework.stereotype.Service;
  66. import org.springframework.util.ObjectUtils;
  67. /**
  68. * <p>
  69. * pro场景表 服务实现类
  70. * </p>
  71. *
  72. * @author
  73. * @since 2022-07-04
  74. */
  75. @Service
  76. @Slf4j
  77. public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro> implements ISceneProService {
  78. @Autowired
  79. private IUserService userService;
  80. @Autowired
  81. private ISceneCooperationService sceneCooperationService;
  82. @Autowired
  83. private IScenePlusService scenePlusService;
  84. @Autowired
  85. private ISceneService sceneService;
  86. @Autowired
  87. private LaserService fdkkLaserService;
  88. @Autowired
  89. private FYunFileServiceInterface fYunFileService;
  90. @Autowired
  91. private IUserIncrementService userIncrementService;
  92. @Autowired
  93. private IIncrementTypeService incrementTypeService;
  94. @Autowired
  95. private IScenePlusExtService scenePlusExtService;
  96. @Autowired
  97. private ISceneEditInfoService sceneEditInfoService;
  98. @Autowired
  99. private ICameraDetailService cameraDetailService;
  100. @Autowired
  101. ICameraService cameraService;
  102. @Autowired
  103. private IFolderService folderService;
  104. @Autowired
  105. private IFolderSceneService folderSceneService;
  106. @Autowired
  107. private ISceneCopyLogService sceneCopyLogService;
  108. @Autowired
  109. private IScene3dNumService scene3dNumService;
  110. @Autowired
  111. private ISceneProEditService sceneProEditService;
  112. @Autowired
  113. private RedisUtil redisUtil;
  114. @Autowired
  115. private ISceneUpgradeMapper sceneUpgradeMapper;
  116. @Autowired
  117. private IInnerService innerService;
  118. @Autowired
  119. LaserService laserService;
  120. @Value("${scene.pro.url}")
  121. private String sceneProUrl;
  122. @Value("${scene.pro.new.url}")
  123. private String sceneProNewUrl;
  124. @Value("${queue.modeling.obj.modeling-pre}")
  125. private String queueObjModelingPre;
  126. @Autowired
  127. private RabbitMqProducer mqProducer;
  128. @Override
  129. public HashMap<String, SceneNumVo> findSceneNumber(String token) {
  130. User user = userService.getByUserName(JwtUtil.getUsername(token));
  131. SceneNumVo sceneNumVoKk = getSceneNumVoByType(Arrays.asList(1,2,12,13,14), user.getId());
  132. Integer oldNum = sceneService.getCountByUserId(user.getId());
  133. sceneNumVoKk.setSceneNum( oldNum + sceneNumVoKk.getSceneNum());
  134. sceneNumVoKk.setTotalNum(oldNum + sceneNumVoKk.getTotalNum());
  135. SceneNumVo sceneNumVoKj = getSceneNumVoByType(Collections.singletonList(3), user.getId());
  136. SceneNumVo sceneNumVoSS = fdkkLaserService.getLaserSceneNumByUser(token);
  137. SceneNumVo sceneNumVoSSObj = getSceneNumVoByObjType(Arrays.asList(4), user.getId());
  138. HashMap<String, SceneNumVo> hashMap = new HashMap<>();
  139. hashMap.put("kk",sceneNumVoKk);
  140. hashMap.put("kJ",sceneNumVoKj);
  141. hashMap.put("SS",sceneNumVoSS);
  142. hashMap.put("SS_OBJ",sceneNumVoSSObj);
  143. return hashMap;
  144. }
  145. private SceneNumVo getSceneNumVoByType(List<Integer> sceneSourceList, Long userId){
  146. SceneNumVo sceneNumVo = new SceneNumVo();
  147. LambdaQueryWrapper<ScenePro> queryWrapper = new LambdaQueryWrapper<>();
  148. queryWrapper.eq(ScenePro::getUserId, userId);
  149. queryWrapper.in(ScenePro::getSceneSource, sceneSourceList);
  150. queryWrapper.eq(ScenePro::getIsUpgrade, 0);
  151. Integer sceneNum = Math.toIntExact(this.count(queryWrapper));
  152. Long count = scenePlusService.getCountByUserId(userId,sceneSourceList);
  153. sceneNumVo.setCooperationSceneNum(sceneCooperationService.getCooperationSceneNum(userId,sceneSourceList));
  154. sceneNumVo.setSceneNum(sceneNum + count);
  155. sceneNumVo.setTotalNum(sceneNumVo.getSceneNum() + sceneNumVo.getCooperationSceneNum());
  156. return sceneNumVo;
  157. }
  158. private SceneNumVo getSceneNumVoByObjType(List<Integer> sceneSourceList, Long userId){
  159. SceneNumVo sceneNumVo = new SceneNumVo();
  160. LambdaQueryWrapper<ScenePro> queryWrapper = new LambdaQueryWrapper<>();
  161. queryWrapper.eq(ScenePro::getUserId, userId);
  162. queryWrapper.in(ScenePro::getSceneSource, sceneSourceList);
  163. queryWrapper.eq(ScenePro::getIsUpgrade, 0);
  164. queryWrapper.eq(ScenePro::getIsObj,1);
  165. Integer sceneNum = Math.toIntExact(this.count(queryWrapper));
  166. LambdaQueryWrapper<ScenePlusExt> wrapper = new LambdaQueryWrapper<>();
  167. wrapper.eq(ScenePlusExt::getIsObj,1);
  168. List<ScenePlusExt> list = scenePlusExtService.list(wrapper);
  169. List<Long> plusIds = list.stream().map(ScenePlusExt::getPlusId).collect(Collectors.toList());
  170. long plusCount = 0L;
  171. long cooperNum = 0L;
  172. if(plusIds.size() >0){
  173. LambdaQueryWrapper<ScenePlus> plusWr = new LambdaQueryWrapper<>();
  174. plusWr.in(ScenePlus::getId,plusIds);
  175. plusWr.in(ScenePlus::getSceneSource,sceneSourceList);
  176. List<ScenePlus> plusList = scenePlusService.list(plusWr);
  177. if(plusList.size() >0){
  178. List<ScenePlus> userList = plusList.stream().filter(entity -> userId.equals(entity.getUserId())).collect(Collectors.toList());
  179. plusCount = userList.size();
  180. List<String> numList = plusList.stream().map(ScenePlus::getNum).collect(Collectors.toList());
  181. HashMap<String, User> cooNumList = sceneCooperationService.getByNumList(numList);
  182. for (String num : cooNumList.keySet()) {
  183. if(userId.equals(cooNumList.get(num).getId())){
  184. cooperNum ++;
  185. }
  186. }
  187. }
  188. }
  189. sceneNumVo.setCooperationSceneNum(cooperNum);
  190. sceneNumVo.setSceneNum(sceneNum + plusCount);
  191. sceneNumVo.setTotalNum(sceneNumVo.getSceneNum() + sceneNumVo.getCooperationSceneNum());
  192. return sceneNumVo;
  193. }
  194. @Override
  195. public HashMap<Long,GroupByCount> findSceneNumByCameraIds(List<Long> cameraIdList) {
  196. HashMap<Long,GroupByCount> map = new HashMap<>();
  197. List<GroupByCount> result = this.getBaseMapper().findSceneProNumByCameraIds(cameraIdList);
  198. List<GroupByCount> result2 = this.getBaseMapper().findScenePlusNumByCameraIds(cameraIdList);
  199. result.forEach(entity ->map.put(entity.getId(),entity));
  200. for (GroupByCount groupByCount : result2) {
  201. if (map.get(groupByCount.getId()) != null) {
  202. Long totalCount = map.get(groupByCount.getId()).getCount() + groupByCount.getCount();
  203. String lastTime = DateUserUtil.getLastTime(map.get(groupByCount.getId()).getLastTime(), groupByCount.getLastTime());
  204. groupByCount.setCount(totalCount);
  205. groupByCount.setLastTime(lastTime);
  206. }
  207. map.put(groupByCount.getId(),groupByCount);
  208. }
  209. return map;
  210. }
  211. /**
  212. * @param payStatus -2 封存,为 1 解封
  213. */
  214. @Override
  215. public void lockOrUnLockBySpace(CameraDetail cameraDetail, Long cameraId, Integer payStatus) {
  216. LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  217. LambdaQueryWrapper<ScenePlus> plusWr = new LambdaQueryWrapper<>();
  218. Long totalSpace = cameraDetail.getTotalSpace();
  219. UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
  220. if(userIncrement!=null){
  221. IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
  222. if(incrementType!=null){
  223. if(incrementType.getCameraCapacity() == -1){
  224. totalSpace = -1L;
  225. }else {
  226. totalSpace = incrementType.getCameraCapacity() * 1024* 1024 * 1024L;
  227. }
  228. }
  229. }
  230. log.info("lockOrUnLockBySpace---cameraId:{},payStatus:{},totalSpace:{},useSpace{}",
  231. cameraId,payStatus,totalSpace,cameraDetail.getUsedSpace());
  232. if(payStatus == 1){ //解封,判断用户权益,用户会员权益无限容量
  233. wrapper.orderByAsc(ScenePro::getCreateTime);
  234. plusWr.orderByAsc(ScenePlus::getCreateTime);
  235. wrapper.eq(ScenePro::getPayStatus,-2);
  236. plusWr.eq(ScenePlus::getPayStatus,-2);
  237. }else {
  238. if (totalSpace == -1 || totalSpace >= cameraDetail.getUsedSpace()) {
  239. // 总容量大于已使用容量,不予封存
  240. return;
  241. }
  242. wrapper.orderByDesc(ScenePro::getCreateTime);
  243. plusWr.orderByDesc(ScenePlus::getCreateTime);
  244. wrapper.eq(ScenePro::getPayStatus,1);
  245. plusWr.eq(ScenePlus::getPayStatus,1);
  246. }
  247. wrapper.eq(ScenePro::getCameraId,cameraId)
  248. .eq(ScenePro::getIsUpgrade,0);
  249. plusWr.eq(ScenePlus::getCameraId,cameraId);
  250. List<ScenePro> list = this.list(wrapper);
  251. List<ScenePlus> plusList = scenePlusService.list(plusWr);
  252. List<Long> lockedIds = new ArrayList<>();
  253. if(totalSpace == -1 && payStatus == 1){
  254. List<Long> collect = list.stream().map(ScenePro::getId).collect(Collectors.toList());
  255. List<Long> collect2 = plusList.stream().map(ScenePlus::getId).collect(Collectors.toList());
  256. lockedIds.addAll(collect);
  257. lockedIds.addAll(collect2);
  258. lockOrUnLockScenes(lockedIds,payStatus); // 无限容量 全部解封
  259. return;
  260. }
  261. Long beyondSpace = 0L;
  262. Long accumulateSpace = 0L;
  263. if(payStatus == 1){
  264. beyondSpace = totalSpace - cameraDetail.getTotalSpace();
  265. getScenePlusLockedIds(lockedIds, plusList, beyondSpace, accumulateSpace);
  266. getSceneLockedIds(lockedIds,list,beyondSpace,accumulateSpace);
  267. }else {
  268. beyondSpace = cameraDetail.getUsedSpace() - totalSpace;
  269. getSceneLockedIds(lockedIds, list, beyondSpace, accumulateSpace);
  270. getScenePlusLockedIds(lockedIds,plusList,beyondSpace,accumulateSpace);
  271. }
  272. lockOrUnLockScenes(lockedIds,payStatus);
  273. }
  274. private void getSceneLockedIds(List<Long> lockedIds ,List<ScenePro> list,Long beyondSpace,Long accumulateSpace){
  275. if (list != null && list.size() > 0){
  276. for (ScenePro scenePro : list){
  277. accumulateSpace += scenePro.getSpace();
  278. if (accumulateSpace.compareTo(beyondSpace) > 0){
  279. break;
  280. }
  281. lockedIds.add(scenePro.getId());
  282. }
  283. }
  284. }
  285. private void getScenePlusLockedIds(List<Long> lockedIds , List<ScenePlus> list, Long beyondSpace, Long accumulateSpace){
  286. if (list != null && list.size() > 0){
  287. List<Long> plusIds = list.parallelStream().map(ScenePlus::getId).collect(Collectors.toList());
  288. HashMap<Long, ScenePlusExt> byPlusIds = scenePlusExtService.getByPlusIds(plusIds);
  289. for (ScenePlus scenePlus : list){
  290. ScenePlusExt scenePlusExt = byPlusIds.get(scenePlus.getId());
  291. accumulateSpace += scenePlusExt.getSpace();
  292. if (accumulateSpace.compareTo(beyondSpace) > 0){
  293. break;
  294. }
  295. lockedIds.add(scenePlus.getId());
  296. }
  297. }
  298. }
  299. // payStatus 为 -2 封存,为 1 解封
  300. private void lockOrUnLockScenes(List<Long> lockedIds,Integer payStatus) {
  301. if (lockedIds == null || lockedIds.size() == 0){
  302. return;
  303. }
  304. LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<>();
  305. updateWrapper.set(ScenePro::getPayStatus,payStatus)
  306. .eq(ScenePro::getIsUpgrade,0)
  307. .in(ScenePro::getId,lockedIds);
  308. this.update(updateWrapper);
  309. LambdaUpdateWrapper<ScenePlus> updatePlusWrapper = new LambdaUpdateWrapper<>();
  310. updatePlusWrapper.set(ScenePlus::getPayStatus,payStatus)
  311. .in(ScenePlus::getId,lockedIds);
  312. scenePlusService.update(updatePlusWrapper);
  313. this.updateOssStatus(lockedIds,payStatus);
  314. }
  315. /**
  316. * 修改oss status.json中 payStatus
  317. */
  318. private void updateOssStatus(List<Long> lockedIds, Integer payStatus) {
  319. LambdaQueryWrapper<ScenePro> proWr = new LambdaQueryWrapper<>();
  320. proWr.eq(ScenePro::getIsUpgrade,0);
  321. proWr.in(ScenePro::getId,lockedIds);
  322. List<ScenePro> proList = this.list(proWr);
  323. LambdaQueryWrapper<ScenePlus> pluWr = new LambdaQueryWrapper<>();
  324. pluWr.in(ScenePlus::getId,lockedIds);
  325. List<ScenePlus> plusList = scenePlusService.list(pluWr);
  326. for (ScenePro scenePro : proList) {
  327. this.updateOssStatus(String.format(OssPath.v3_statusPath,scenePro.getNum()),payStatus);
  328. }
  329. for (ScenePlus scenePlus : plusList) {
  330. this.updateOssStatus(String.format(OssPath.v4_statusPath,scenePlus.getNum()),payStatus);
  331. }
  332. }
  333. /**
  334. * 从oss中获取文件,并重写,上传替换
  335. */
  336. @Override
  337. public void updateOssStatus(String path,Integer payStatus) {
  338. try {
  339. if(!fYunFileService.fileExist(path)){
  340. return;
  341. }
  342. String data = fYunFileService.getFileContent(path);
  343. if(StringUtils.isBlank(data)){
  344. return;
  345. }
  346. JSONObject jsonObject = JSONObject.parseObject(data);
  347. jsonObject.put("payStatus",payStatus);
  348. String json = JSONUtil.toJsonStr(jsonObject);
  349. FileUtils.writeFile(OssPath.localStatusPath ,json);
  350. log.info("updateOssStatus--localPath:{},ossPath:{},payStatus:{}",OssPath.localStatusPath,path,payStatus);
  351. fYunFileService.uploadFile(OssPath.localStatusPath,path);
  352. }catch (Exception e){
  353. e.printStackTrace();
  354. }finally {
  355. FileUtil.del(OssPath.localStatusPath);
  356. }
  357. }
  358. @Override
  359. public List<ScenePro> getListByCameraId(Long cameraId) {
  360. LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  361. wrapper.eq(ScenePro::getCameraId,cameraId)
  362. .eq(ScenePro::getIsUpgrade,0);
  363. return this.list(wrapper);
  364. }
  365. @Override
  366. public void bindOrUnCamera(List<Long> cameraIds, Long userId) {
  367. if(cameraIds.size() >0){
  368. LambdaUpdateWrapper<ScenePro> wrapper = new LambdaUpdateWrapper<>();
  369. wrapper.in(ScenePro::getCameraId,cameraIds)
  370. .eq(ScenePro::getIsUpgrade,0)
  371. .set(ScenePro::getUserId,userId);
  372. this.update(wrapper);
  373. }
  374. }
  375. @Override
  376. public List<ScenePro> getListByCameraIds(List<Long> cameraIds) {
  377. if(cameraIds.size() >0){
  378. LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  379. wrapper.in(ScenePro::getCameraId,cameraIds)
  380. .eq(ScenePro::getIsUpgrade,0);
  381. return this.list(wrapper);
  382. }
  383. return new ArrayList<>();
  384. }
  385. @Override
  386. public List<ScenePro> getListByNums(List<String> numList) {
  387. if(numList.size() >0){
  388. LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  389. wrapper.in(ScenePro::getNum,numList)
  390. .eq(ScenePro::getIsUpgrade,0);
  391. return this.list(wrapper);
  392. }
  393. return new ArrayList<>();
  394. }
  395. @Override
  396. public Long getCountByUserId(Long userId, List<?> resourceList) {
  397. if(resourceList.size() >0){
  398. LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  399. wrapper.eq(ScenePro::getUserId,userId);
  400. wrapper.eq(ScenePro::getIsUpgrade,0);
  401. wrapper.in(ScenePro::getSceneSource,resourceList);
  402. return this.count(wrapper);
  403. }
  404. return 0L;
  405. }
  406. @Override
  407. public Long getCountByUserId(Long id, Integer cameraType) {
  408. return this.getBaseMapper().getCountByUserId(id,cameraType);
  409. }
  410. @Override
  411. public void deleteByIds(List<Long> sceneIds) {
  412. if(sceneIds.size() >0){
  413. LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  414. wrapper.in(ScenePro::getId,sceneIds)
  415. .eq(ScenePro::getIsUpgrade,0);
  416. List<ScenePro> proList = this.list(wrapper);
  417. LambdaQueryWrapper<ScenePlus> plusWr = new LambdaQueryWrapper<>();
  418. plusWr.in(ScenePlus::getId,sceneIds);
  419. List<ScenePlus> plusList = scenePlusService.list(plusWr);
  420. this.deleteByList(proList,plusList);
  421. }
  422. }
  423. @Override
  424. public Page<SceneVo> pageListAndFolder(Page<Object> page, SceneParam param) {
  425. return getBaseMapper().pageListAndFolder(new Page<>(param.getPageNum(),param.getPageSize()),param);
  426. }
  427. @Override
  428. public Object getScenes(String username, RequestScene param) {
  429. User user = userService.getByUserName(username);
  430. log.info("搜索条件是:"+ param.getSearchKey());
  431. //type为12表示一键换装的请求,不查询相机数据
  432. if(StringUtils.isNotEmpty(param.getSearchKey()) && !"11".equals(param.getType())){
  433. List<Long> userIds = userService.getLikeUserName(param.getSearchKey());
  434. if(userIds.size() > 0){
  435. List<String> cooperationList = sceneCooperationService.getNumByUserIds(userIds);
  436. param.setNumList(cooperationList);
  437. }
  438. }
  439. param.setUserId(user.getId());
  440. Page<SceneVo> sceneList = sceneService.getSceneList(param);
  441. for (SceneVo record : sceneList.getRecords()) {
  442. record.setUserName(username);
  443. SceneCooperation sceneCooperationEntity = sceneCooperationService.getByNum(record.getNum());
  444. if(sceneCooperationEntity != null && sceneCooperationEntity.getUserId()!= null){
  445. User user1 = userService.getById(sceneCooperationEntity.getUserId());
  446. if(user1 != null){
  447. record.setCooperationUserId(String.valueOf(sceneCooperationEntity.getUserId()));
  448. record.setCooperationUserName(user1.getUserName());
  449. }
  450. }
  451. }
  452. return PageInfo.PageInfo(sceneList);
  453. }
  454. @Override
  455. public JSONObject newList(SceneParam param, String username) {
  456. param.setSourceList(getSceneSource(param.getSceneSource()));
  457. if(StringUtils.isNotBlank(username)){
  458. User user = userService.getByUserName(username);
  459. param.setUserId(user.getId());
  460. }
  461. Page<SceneVo> sceneVoPage = getBaseMapper().pageListAndFolder(new Page<>(param.getPageNum(),param.getPageSize()),param);
  462. List<SceneVo> folderList = sceneVoPage.getRecords().parallelStream().filter(entity -> entity.getIsFolder() == 1).collect(Collectors.toList());
  463. Long totalSceneNum = sceneVoPage.getTotal();
  464. if(folderList.size() >0){
  465. List<Long> folderIds = folderList.parallelStream().map(SceneVo::getId).collect(Collectors.toList());
  466. List<Folder> allFolderIds = folderService.getAllFolderIds(folderIds);
  467. HashMap<Long,Long> map = folderSceneService.getGroupByFolderIds(allFolderIds);
  468. for (SceneVo vo : sceneVoPage.getRecords()) {
  469. if(vo.getIsFolder() == 1 && vo.getType()!= null && vo.getType()!= 3){
  470. Long sceneNum = map.get(vo.getId()) == null ? 0L : map.get(vo.getId());
  471. vo.setSceneNum(sceneNum);
  472. vo.setCreateTimeStr(vo.getCreateTime());
  473. }else if(vo.getIsFolder() == 1 && vo.getType()!= null && vo.getType() == 3){
  474. if(param.getUserId()!= null){
  475. Integer count = sceneService.getCountByUserId(param.getUserId());
  476. vo.setSceneNum(Long.valueOf(count));
  477. }
  478. }
  479. }
  480. }
  481. //设置协作者信息
  482. if(sceneVoPage.getRecords().size() >0){
  483. List<String> numList = sceneVoPage.getRecords().parallelStream().map(SceneVo::getNum).collect(Collectors.toList());
  484. HashMap<String,User> cooMap = sceneCooperationService.getByNumList(numList);
  485. for (SceneVo vo : sceneVoPage.getRecords()) {
  486. if (StringUtils.isNotBlank(vo.getNum())) {
  487. User userVo = cooMap.get(vo.getNum());
  488. if (userVo != null) {
  489. vo.setCooperationUserId(userVo.getId().toString());
  490. vo.setCooperationUserName(userVo.getUserName());
  491. }
  492. }
  493. }
  494. }
  495. List<SceneVo> sceneList = sceneVoPage.getRecords().parallelStream().filter(entity -> entity.getIsFolder() == 0)
  496. .peek(vo->{
  497. if (ObjectUtils.isEmpty(vo.getStatus())) {
  498. return;
  499. }
  500. if (vo.getStatus().equals(500)) { //500状态为数据库中手动修改值,当场景本身异常,算法,算不了
  501. vo.setStatus(-1);
  502. }
  503. if (vo.getStatus().equals(-1)) { //计算失败,钉钉通知之后,判定是否重算,还是修改为 500
  504. vo.setStatus(0);
  505. }
  506. }).collect(Collectors.toList());
  507. if(sceneList.size() >0){
  508. folderList.addAll(sceneList);
  509. }
  510. sceneVoPage.setRecords(folderList);
  511. if(param.getFolderId() == null && param.getIsObj() == null ){
  512. List<String> sourceList = param.getSourceList();
  513. if(param.getUserId()!= null){
  514. totalSceneNum = this.getCountByUserId(param.getUserId(),sourceList);
  515. totalSceneNum += scenePlusService.getCountByUserId(param.getUserId(),sourceList);
  516. totalSceneNum += sceneService.getCountByUserId(param.getUserId());
  517. }
  518. }else if(param.getFolderId() != null ){
  519. totalSceneNum = folderSceneService.getCountByFolderAndSon(param.getFolderId());
  520. }else if(param.getIsObj() != null && param.getIsObj() ==1){
  521. if(param.getUserId()!= null){
  522. totalSceneNum = this.getCountByLaserAndIsObj(param.getUserId());
  523. }
  524. }
  525. JSONObject jsonObject = new JSONObject();
  526. jsonObject.put("pageInfo",PageInfo.PageInfo(sceneVoPage));
  527. jsonObject.put("sceneNum",totalSceneNum);
  528. return jsonObject;
  529. }
  530. private Long getCountByLaserAndIsObj(Long userId) {
  531. Long proCount = 0L;
  532. Long plusCount = 0L;
  533. LambdaQueryWrapper<ScenePro> proWr = new LambdaQueryWrapper<>();
  534. proWr.eq(ScenePro::getUserId,userId);
  535. proWr.eq(ScenePro::getSceneSource,4);
  536. proWr.eq(ScenePro::getIsObj,1);
  537. proWr.eq(ScenePro::getIsUpgrade,0);
  538. proCount = this.count(proWr);
  539. LambdaQueryWrapper<ScenePlus> plusWr = new LambdaQueryWrapper<>();
  540. plusWr.eq(ScenePlus::getUserId,userId);
  541. plusWr.eq(ScenePlus::getSceneSource,4);
  542. List<ScenePlus> list = scenePlusService.list(plusWr);
  543. if(list.size() >0){
  544. List<Long> plusIds = list.stream().map(ScenePlus::getId).collect(Collectors.toList());
  545. LambdaQueryWrapper<ScenePlusExt> extWr = new LambdaQueryWrapper<>();
  546. extWr.in(ScenePlusExt::getPlusId,plusIds);
  547. extWr.eq(ScenePlusExt::getIsObj,1);
  548. plusCount = scenePlusExtService.count(extWr);
  549. }
  550. return proCount +plusCount;
  551. }
  552. public List<String> getSceneSource(String sceneSource){
  553. List<String> sceneSourceList ;
  554. if(StringUtils.isNotBlank(sceneSource)){
  555. switch (sceneSource){
  556. case "1" : sceneSourceList = Arrays.asList("1","2","12","13","14"); break; //四维看看
  557. case "3" : sceneSourceList = Collections.singletonList("3"); break;//四维看见
  558. case "4" : sceneSourceList = Collections.singletonList("4"); break;//深时场景
  559. default:
  560. if(sceneSource.contains(",")){
  561. sceneSource = sceneSource + ",12,13,14";
  562. sceneSourceList = Arrays.asList(sceneSource.split(","));
  563. break;
  564. }
  565. sceneSourceList = Collections.singletonList(sceneSource);break;
  566. }
  567. return sceneSourceList;
  568. }
  569. return Arrays.asList("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15");
  570. }
  571. @Override
  572. public void copyScene(String sceneNum,String userName) throws Exception {
  573. if(StringUtils.isEmpty(sceneNum)){
  574. throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
  575. }
  576. ScenePro scenePro = this.getByNum(sceneNum);
  577. ScenePlus scenePlus = scenePlusService.getByNum(sceneNum);
  578. if((scenePro == null || scenePro.getCameraId() == null ) && (scenePlus== null || scenePlus.getCameraId() == null)){
  579. throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
  580. }
  581. Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
  582. Long userId = scenePro == null ? scenePlus.getUserId() :scenePro.getUserId();
  583. // 判断是否有绑定会员权益
  584. Long count = userIncrementService.getValidCountByCameraId(cameraId);
  585. if(count <= 0){
  586. throw new BusinessException(LoginConstant.FAILURE_CODE_3030, LoginConstant.FAILURE_MSG_3030);
  587. }
  588. if(userId == null){
  589. throw new BusinessException(SceneConstant.FAILURE_CODE_5013, SceneConstant.FAILURE_MSG_5013);
  590. }
  591. //只能复制自己的场景
  592. User user = userService.getByUserName(userName);
  593. if(user == null || !user.getId().equals(userId) ){
  594. throw new BusinessException(SceneConstant.FAILURE_CODE_5013, SceneConstant.FAILURE_MSG_5013);
  595. }
  596. CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraId);
  597. if(detailEntity == null){
  598. throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
  599. }
  600. UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
  601. if(userIncrement == null){
  602. throw new BusinessException(LoginConstant.FAILURE_CODE_3030, LoginConstant.FAILURE_MSG_3030);
  603. }
  604. IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
  605. if(incrementType == null){
  606. throw new BusinessException(LoginConstant.FAILURE_CODE_3030, LoginConstant.FAILURE_MSG_3030);
  607. }
  608. if(incrementType.getCameraCapacity() != -1){
  609. Long usedSpace = detailEntity.getUsedSpace();
  610. if( scenePro != null && scenePro.getSpace() + usedSpace > incrementType.getCameraCapacity() * 1024 * 1024 * 1024L){
  611. throw new BusinessException(CameraConstant.FAILURE_CODE_6008, CameraConstant.FAILURE_MSG_6008);
  612. }
  613. if( scenePlus != null ){
  614. ScenePlusExt ext = scenePlusExtService.getByPlusId(scenePlus.getId());
  615. if(ext.getSpace() + usedSpace > incrementType.getCameraCapacity() * 1024 * 1024 * 1024L){
  616. throw new BusinessException(CameraConstant.FAILURE_CODE_6008, CameraConstant.FAILURE_MSG_6008);
  617. }
  618. }
  619. }
  620. this.copySceneNoCheck(sceneNum);
  621. }
  622. @Override
  623. public void copySceneNoCheck(String sceneNum) throws Exception {
  624. ScenePro scenePro = this.getByNum(sceneNum);
  625. ScenePlus scenePlus = scenePlusService.getByNum(sceneNum);
  626. Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
  627. CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraId);
  628. if(detailEntity == null){
  629. throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
  630. }
  631. String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
  632. String title = scenePro == null ? scenePlus.getTitle() : scenePro.getSceneName();
  633. String newTitle = title.concat("(copy)");
  634. Long sceneId = scenePro == null ? scenePlus.getId() :scenePro.getId();
  635. Long newSceneId = null;
  636. FolderScene folderScene = folderSceneService.getByType(sceneId, null);
  637. String time = DateUtil.date2String(new Date(),DateUtil.YYYYMMDDHHMMSSSSS_DATA_FORMAT);
  638. if(scenePro !=null){ //v3场景复制
  639. log.info("场景复制--V3--OldNum:{},oldTitle:{},newNum:{},newTitle:{}",
  640. scenePro.getNum(),scenePro.getSceneName(),newNum,newTitle);
  641. scenePro.setSceneName(newTitle);
  642. newSceneId = this.copyV3Scene(scenePro, newNum, detailEntity,time);
  643. }
  644. if(scenePlus != null){ //v4场景复制
  645. log.info("场景复制--V4--OldNum:{},oldTitle:{},newNum:{},newTitle:{}",
  646. scenePlus.getNum(),scenePlus.getTitle(),newNum,newTitle);
  647. scenePlus.setTitle(newTitle);
  648. newSceneId = scenePlusService.copyV4Scene(scenePlus,newNum,detailEntity,time);
  649. }
  650. log.info("场景复制--完成--sceneId:{}",newSceneId);
  651. if(newSceneId != null && folderScene!= null){
  652. folderScene.setId(null);
  653. folderScene.setSceneId(newSceneId);
  654. folderSceneService.save(folderScene);
  655. }
  656. }
  657. @Override
  658. public ScenePro getByNum(String sceneNum) {
  659. LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  660. wrapper.eq(ScenePro::getNum,sceneNum);
  661. wrapper.eq(ScenePro::getIsUpgrade,0);
  662. List<ScenePro> list = this.list(wrapper);
  663. if(list!= null && list.size() >0){
  664. return list.get(0);
  665. }
  666. return null;
  667. }
  668. @Override
  669. public Long copyV3Scene(ScenePro oldScene,String newNum,CameraDetail cameraDetail,String time) throws Exception {
  670. SceneProEdit oldEditScene = sceneProEditService.getByProId(oldScene.getId());
  671. String oldNum = oldScene.getNum();
  672. //复制数据库数据
  673. oldScene.setId(null);
  674. oldScene.setStatus(0);
  675. oldScene.setNum(newNum);
  676. oldScene.setWebSite(oldScene.getWebSite().replace(oldNum, newNum));
  677. oldScene.setThumb(oldScene.getThumb().replace(oldNum, newNum));
  678. oldScene.setVideos(this.setVideos(oldScene.getVideos(),oldNum,newNum));
  679. oldScene.setViewCount(0);
  680. String preDataSource = oldScene.getDataSource();
  681. String newDataSource = this.setDataSource(preDataSource,time);
  682. oldScene.setDataSource(newDataSource);
  683. this.save(oldScene);
  684. if(oldScene.getSceneSource() == 4){ //深时复制
  685. laserService.copy(oldNum,oldScene.getCameraId(),oldScene.getCreateTime(),newNum,0,null,
  686. oldEditScene.getSceneKey(),oldScene.getSceneName(),oldScene.getUserId(),"V3",oldScene.getIsObj());
  687. }
  688. //更新video
  689. Map map = new HashMap();
  690. JSONObject object = new JSONObject();
  691. if(StringUtils.isNotEmpty(oldScene.getVideos())){
  692. object = JSONObject.parseObject(oldScene.getVideos());
  693. if(object.containsKey("upPath")){
  694. String upPath = object.getString("upPath");
  695. upPath = upPath.replace(oldNum,newNum);
  696. object.put("upPath",upPath);
  697. }
  698. oldScene.setVideos(object.toJSONString());
  699. log.info("更新 scene.json");
  700. map.put("videos",oldScene.getVideos());
  701. }
  702. map.put("sceneName",oldScene.getSceneName());
  703. map.put("webSite",oldScene.getWebSite());
  704. map.put("thumb",oldScene.getThumb());
  705. map.put("num",oldScene.getNum());
  706. map.put("id",oldScene.getId());
  707. map.put("dataSource",oldScene.getDataSource());
  708. //复制完成更新相机容量
  709. oldEditScene.setId(null);
  710. oldEditScene.setProId(oldScene.getId());
  711. oldEditScene.setScreencapVoiceSrc(oldEditScene.getScreencapVoiceSrc() == null ? null : oldEditScene.getScreencapVoiceSrc().replace(oldNum, newNum));
  712. oldEditScene.setScreencapVoiceSound(oldEditScene.getScreencapVoiceSound() == null ? null : oldEditScene.getScreencapVoiceSound().replace(oldNum, newNum));
  713. oldEditScene.setScreencapVoiceSoundsync(oldEditScene.getScreencapVoiceSoundsync() == null ? null : oldEditScene.getScreencapVoiceSoundsync().replace(oldNum, newNum));
  714. oldEditScene.setPlayData(oldEditScene.getPlayData() == null ? null : oldEditScene.getPlayData().replace(oldNum, newNum));
  715. oldEditScene.setScreencapThumb(oldEditScene.getScreencapThumb() == null ? null : oldEditScene.getScreencapThumb().replace(oldNum, newNum));
  716. oldEditScene.setFloorPlanPng(oldEditScene.getFloorPlanPng() == null ? null : oldEditScene.getFloorPlanPng().replace(oldNum, newNum));
  717. sceneProEditService.save(oldEditScene);
  718. this.setQrCode(oldScene.getBuildType(), oldScene.getNum(), oldScene.getCameraId(), oldEditScene.getShareLogo());
  719. ExecutorService executor = ThreadUtil.newSingleExecutor();
  720. try {
  721. CompletableFuture.runAsync(() -> {
  722. try {
  723. log.info("开始复制场景-{}", new Date());
  724. String buildModelPath = ConstantFilePath.BUILD_MODEL_PATH;
  725. if(oldScene.getSceneSource().equals(4)){
  726. buildModelPath = ConstantFilePath.BUILD_MODEL_LASER_PATH;
  727. }
  728. this.copyFdage(preDataSource,newDataSource,buildModelPath,time);
  729. //oss复制计算结果资源
  730. downloadFromOldNumFromOss(oldNum, newNum);
  731. // 复制本地secen.json
  732. copyOldSceneLocalToNew(oldNum, newNum);
  733. FileUtils.writeJsonFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + File.separator + "scene.json", map);
  734. //上传资源到oss
  735. uploadNewSceneToOss(newNum);
  736. FileUtils.delFolder(ConstantFilePath.SCENE_PATH + "images/images" + newNum);
  737. FileUtils.delFolder(ConstantFilePath.SCENE_PATH + "data/data" + newNum);
  738. FileUtils.delFolder(ConstantFilePath.SCENE_PATH + "voice/voice" + newNum);
  739. FileUtils.delFolder(ConstantFilePath.SCENE_PATH + "video/video" + newNum);
  740. FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"images/images" + oldNum,ConstantFilePath.SCENE_PATH +"images/images" + newNum);
  741. FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"data/data" + oldNum,ConstantFilePath.SCENE_PATH +"data/data" + newNum);
  742. FileUtils.writeJsonFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + File.separator + "scene.json", map);
  743. reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/link-scene.json",oldNum, newNum);
  744. reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/hot.json",oldNum, newNum);
  745. FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"voice/voice" + oldNum,ConstantFilePath.SCENE_PATH +"voice/voice" + newNum);
  746. FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"video/video" + oldNum,ConstantFilePath.SCENE_PATH +"video/video" + newNum);
  747. oldScene.setStatus(-2);
  748. this.updateById(oldScene);
  749. cameraDetail.setUsedSpace(cameraDetail.getUsedSpace() + oldScene.getSpace());
  750. cameraDetailService.updateById(cameraDetail);
  751. if(oldScene.getPayStatus() == -2){
  752. this.updateOssStatus(String.format(OssPath.v3_statusPath,oldScene.getNum()),-2);
  753. }
  754. if(oldScene.getSceneSource() == 4){ //深时复制
  755. String laserPath = laserService.copyDataSource(preDataSource,oldScene.getDataSource());
  756. laserService.copy(oldNum,oldScene.getCameraId(),oldScene.getCreateTime(),newNum,2,laserPath,
  757. oldEditScene.getSceneKey(),oldScene.getSceneName(),oldScene.getUserId(),"V3",oldScene.getIsObj());
  758. }
  759. sceneCopyLogService.saveByNum(oldNum,newNum,oldScene.getUserId());
  760. } catch (Exception e) {
  761. this.removeById(oldScene.getId());
  762. log.error("复制场景异常", e);
  763. }
  764. }, executor).whenComplete((reslut, e) -> {
  765. log.info("复制场景oldNum:{},newNum:{}结束-{}",oldNum,newNum, new Date());
  766. });
  767. }catch (Exception e){
  768. log.error("线程错误:{}",e);
  769. }finally {
  770. executor.shutdown();
  771. }
  772. return oldScene.getId();
  773. }
  774. /**
  775. * 从旧场景下载资源
  776. * @param sceneNum
  777. * @param newNum
  778. * @throws Exception
  779. */
  780. private void downloadFromOldNumFromOss(String sceneNum, String newNum) {
  781. ShellUtil.yunDownload("images/images" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "images/images" + newNum);
  782. ShellUtil.yunDownload("data/data" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "data/data" + newNum);
  783. ShellUtil.yunDownload("voice/voice" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "voice/voice" + newNum);
  784. ShellUtil.yunDownload("video/video" + sceneNum + "/", ConstantFilePath.SCENE_PATH + "video/video" + newNum);
  785. }
  786. /**
  787. * 从本地旧场景拷贝资源到新场景
  788. * @param sceneNum
  789. * @param newNum
  790. */
  791. private void copyOldSceneLocalToNew(String sceneNum, String newNum) throws Exception {
  792. FileUtils.copyFolderAllFiles(ConstantFilePath.SCENE_PATH + "data/data" + sceneNum + "/",
  793. ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/", true);
  794. reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/link-scene.json",sceneNum, newNum);
  795. reloadFile(ConstantFilePath.SCENE_PATH + "data/data" + newNum + "/hot.json",sceneNum, newNum);
  796. }
  797. public void copyFdage(String oldDataSource,String newDataSource,String buildModelPath,String time) throws Exception {
  798. ShellUtil.yunDownload(ConstantFilePath.OSS_PREFIX + oldDataSource.replace(buildModelPath, "")+"/", newDataSource);
  799. // 修改data.fdage
  800. String data = FileUtils.readFile(newDataSource + "/data.fdage");
  801. JSONObject jsonObject = JSONObject.parseObject(data);
  802. if(ObjectUtils.isEmpty(jsonObject)){
  803. log.error("data.fdage文件不存在");
  804. throw new BusinessException(-1,"拷贝场景出错,data.fdage文件不存在");
  805. }
  806. jsonObject.put("uuidtime",time);
  807. FileUtils.writeFile(newDataSource + "/data.fdage", jsonObject.toJSONString());
  808. ShellUtil.yunUpload(newDataSource, ConstantFilePath.OSS_PREFIX + newDataSource.replace(buildModelPath, ""));
  809. // 复制计算结果
  810. ShellUtil.yunDownload(ConstantFilePath.OSS_PREFIX + oldDataSource.concat("_results/").replace(buildModelPath, ""), newDataSource.concat("_results"));
  811. if(new File(newDataSource.concat("_results")).exists()){
  812. ShellUtil.yunUpload(newDataSource.concat("_results"), ConstantFilePath.OSS_PREFIX + newDataSource.concat("_results").replace(buildModelPath, ""));
  813. FileUtils.delAllFile(newDataSource.concat("_results"));
  814. }
  815. FileUtils.delAllFile(newDataSource);
  816. try {
  817. FileUtils.copyFolderAllFiles(oldDataSource+"/",newDataSource+"/", true);
  818. }catch (Exception e){
  819. log.error("dataSource复制失败,{}不存在",oldDataSource);
  820. }
  821. }
  822. @Override
  823. public String setDataSource(String preDataSource,String time) throws Exception {
  824. SnowflakeIdGenerator snowflakeIdGenerator = new SnowflakeIdGenerator(0,1);
  825. String[] datasource = preDataSource.split("/");
  826. datasource[4] = snowflakeIdGenerator.nextId()+"";
  827. datasource[5] = datasource[5].split("_")[0] + "_" + time;
  828. return Arrays.stream(datasource).collect(Collectors.joining("/"));
  829. }
  830. @Override
  831. public String setVideos(String videos,String oldNum,String newNum) {
  832. JSONObject object = new JSONObject();
  833. if(StringUtils.isNotEmpty(videos)){
  834. object = JSONObject.parseObject(videos);
  835. if(object.containsKey("upPath")){
  836. String upPath = object.getString("upPath");
  837. upPath = upPath.replace(oldNum,newNum);
  838. object.put("upPath",upPath);
  839. }
  840. log.info("更新 scene.json");
  841. }
  842. return object.toJSONString();
  843. }
  844. private void reloadFile(String filePath,String sceneNum, String newNum) throws Exception {
  845. // 修改link-scene.json
  846. String content = FileUtils.readFile(filePath);
  847. if (!ObjectUtils.isEmpty(content)) {
  848. content = content.replaceAll(sceneNum, newNum);
  849. FileUtils.writeFile(filePath,content);
  850. }
  851. }
  852. /**
  853. * 上传新场景资源到oss
  854. * @param newNum
  855. */
  856. private void uploadNewSceneToOss(String newNum) {
  857. ShellUtil.yunUpload("/mnt/4Dkankan/scene/images/images" + newNum, "images/images" + newNum);
  858. ShellUtil.yunUpload("/mnt/4Dkankan/scene/data/data" + newNum, "data/data" + newNum);
  859. ShellUtil.yunUpload("/mnt/4Dkankan/scene/voice/voice" + newNum, "voice/voice" + newNum);
  860. ShellUtil.yunUpload("/mnt/4Dkankan/scene/video/video" + newNum, "video/video" + newNum);
  861. }
  862. @Override
  863. public void delete(String sceneNum) {
  864. if(StringUtils.isEmpty(sceneNum)){
  865. throw new BusinessException(LoginConstant.FAILURE_CODE_3001,LoginConstant.FAILURE_MSG_3001);
  866. }
  867. String[] nums = sceneNum.split(",");
  868. List<String> numList = Arrays.asList(nums);
  869. List<ScenePro> proList = this.getListByNums(numList);
  870. List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
  871. this.deleteByList(proList,plusList);
  872. }
  873. @Override
  874. public void deleteByList(List<ScenePro> proList,List<ScenePlus> plusList) {
  875. HashMap<Long ,Long >cameraMap = new HashMap<>();
  876. if(proList.size() >0){
  877. for (ScenePro scenePro : proList) {
  878. cameraMap.merge(scenePro.getCameraId(), scenePro.getSpace(), Long::sum);
  879. }
  880. List<Long> proIds = proList.parallelStream().map(ScenePro::getId).collect(Collectors.toList());
  881. this.removeByIds(proIds);
  882. folderSceneService.delBySceneId(proIds);
  883. }
  884. if(plusList.size() >0){
  885. List<Long> plusIds = plusList.parallelStream().map(ScenePlus::getId).collect(Collectors.toList());
  886. HashMap<Long, ScenePlusExt> plusMap = scenePlusExtService.getByPlusIds(plusIds);
  887. for (ScenePlus scenePlus : plusList) {
  888. if(scenePlus.getCameraId()!= null && plusMap.get(scenePlus.getId())!=null){
  889. cameraMap.merge(scenePlus.getCameraId(), plusMap.get(scenePlus.getId()).getSpace(), Long::sum);
  890. }
  891. }
  892. scenePlusService.removeByIds(plusIds);
  893. scenePlusExtService.removeByPlusIds(plusIds);
  894. folderSceneService.delBySceneId(plusIds);
  895. }
  896. //恢复相机使用容量
  897. if(cameraMap.size() >0){
  898. cameraDetailService.addUsedSpace(cameraMap);
  899. }
  900. }
  901. @Override
  902. public ScenePro getByUnicode(String unicode) {
  903. LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  904. wrapper.like(ScenePro::getDataSource,unicode);
  905. wrapper.eq(ScenePro::getIsUpgrade,0);
  906. wrapper.orderByDesc(ScenePro::getCreateTime);
  907. List<ScenePro> list = this.list(wrapper);
  908. if(list !=null && list.size() >0){
  909. return list.get(0);
  910. }
  911. return null;
  912. }
  913. @Override
  914. public SceneInfoVo getInfo(String num) {
  915. if(StringUtils.isEmpty(num)){
  916. throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
  917. }
  918. ScenePro scenePro = this.getByNum(num);
  919. ScenePlus scenePlus = scenePlusService.getByNum(num);
  920. if(scenePro == null && scenePlus == null){
  921. throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
  922. }
  923. if(scenePro!=null && scenePro.getStatus() != 1 && scenePro.getStatus() != -2){
  924. throw new BusinessException(SceneConstant.FAILURE_CODE_5033, SceneConstant.FAILURE_MSG_5033);
  925. }
  926. if(scenePlus!=null && scenePlus.getSceneStatus() != 1 && scenePlus.getSceneStatus() != -2){
  927. throw new BusinessException(SceneConstant.FAILURE_CODE_5033, SceneConstant.FAILURE_MSG_5033);
  928. }
  929. if(scenePro!=null && scenePro.getPayStatus() != 1){
  930. throw new BusinessException(SceneConstant.FAILURE_CODE_5034, SceneConstant.FAILURE_MSG_5034);
  931. }
  932. if(scenePlus!=null && scenePlus.getPayStatus() != 1){
  933. throw new BusinessException(SceneConstant.FAILURE_CODE_5034, SceneConstant.FAILURE_MSG_5034);
  934. }
  935. SceneInfoVo infoVo = new SceneInfoVo();
  936. if(scenePro!=null){
  937. SceneProEdit sceneProEdit = sceneProEditService.getByProId(scenePro.getId());
  938. if(sceneProEdit !=null){
  939. BeanUtils.copyProperties(sceneProEdit, infoVo);
  940. }
  941. BeanUtils.copyProperties(scenePro,infoVo);
  942. if(StringUtils.isNotEmpty(scenePro.getGps())){
  943. infoVo.setGps(JSONObject.parseObject(scenePro.getGps()).toJSONString());
  944. }
  945. infoVo.setSceneKey("");
  946. infoVo.setCreateDate(DateUserUtil.getDate(scenePro.getCreateTime()).getTime());
  947. }else {
  948. SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
  949. ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
  950. if(sceneEditInfo != null){
  951. BeanUtils.copyProperties(sceneEditInfo,infoVo);
  952. }
  953. if(scenePlusExt !=null){
  954. BeanUtils.copyProperties(scenePlusExt,infoVo);
  955. }
  956. BeanUtils.copyProperties(scenePlus,infoVo);
  957. infoVo.setSceneName(scenePlus.getTitle());
  958. infoVo.setStatus(scenePlus.getSceneStatus());
  959. }
  960. if(StringUtils.isNotEmpty(infoVo.getEntry())){
  961. infoVo.setEntry(JSONObject.parseObject(infoVo.getEntry()).toJSONString());
  962. }
  963. if(StringUtils.isEmpty(infoVo.getSceneKey())){
  964. infoVo.setIsPublic(0);
  965. }else {
  966. infoVo.setIsPublic(1);
  967. }
  968. //查询是否有随心装场景
  969. if(num.contains("vr-")){
  970. infoVo.setVrNum(null);
  971. infoVo.setVideosUser(null);
  972. infoVo.setBgMusicName(null);
  973. infoVo.setBgMusic(null);
  974. }
  975. infoVo.setSceneVer(innerService.getSceneNumVersion(num));
  976. infoVo.setVersion(infoVo.getSceneVer());
  977. this.updateViewCount(num);
  978. return infoVo;
  979. }
  980. @Override
  981. public void updateViewCount(String num) {
  982. String redisKey = RedisKey.SCENE_VISIT_CNT;
  983. if(!redisUtil.hHasKey(redisKey,num)){
  984. Integer count = 0;
  985. ScenePro pro = this.getByNum(num);
  986. if(pro !=null){
  987. count = pro.getViewCount() == null ? 0 : pro.getViewCount();
  988. }else {
  989. ScenePlus plus = scenePlusService.getByNum(num);
  990. if(plus !=null){
  991. ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(plus.getId());
  992. if(scenePlusExt != null){
  993. count = scenePlusExt.getViewCount() == null ? 0 :scenePlusExt.getViewCount();
  994. }
  995. }
  996. }
  997. redisUtil.hset(redisKey,num,String.valueOf(count));
  998. }
  999. redisUtil.hincr(redisKey,num,1);
  1000. }
  1001. @Override
  1002. public void updateDbViewCount(String num, String count) {
  1003. LambdaUpdateWrapper<ScenePro> wrapper = new LambdaUpdateWrapper<>();
  1004. wrapper.eq(ScenePro::getNum,num);
  1005. wrapper.set(ScenePro::getViewCount,count);
  1006. this.update(wrapper);
  1007. ScenePlus plus = scenePlusService.getByNum(num);
  1008. if(plus !=null){
  1009. LambdaUpdateWrapper<ScenePlusExt> exWr = new LambdaUpdateWrapper<>();
  1010. exWr.eq(ScenePlusExt::getPlusId,plus.getId())
  1011. .set(ScenePlusExt::getViewCount,count);
  1012. scenePlusExtService.update(exWr);
  1013. }
  1014. }
  1015. @Override
  1016. public ScenePro findByFileId(String fileId) {
  1017. LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  1018. wrapper.like(ScenePro::getDataSource,fileId);
  1019. List<ScenePro> list = this.list(wrapper);
  1020. if(list !=null && list.size() >0){
  1021. return list.get(0);
  1022. }
  1023. return null;
  1024. }
  1025. @Override
  1026. public Integer getSceneSourceByNum(String sceneNum) {
  1027. Integer sceneSource = null;
  1028. ScenePro scenePro = this.getByNum(sceneNum);
  1029. if(scenePro != null){
  1030. sceneSource = scenePro.getSceneSource();
  1031. }
  1032. if(scenePro == null){
  1033. ScenePlus scenePlus = scenePlusService.getByNum(sceneNum);
  1034. if(scenePlus != null){
  1035. sceneSource = scenePlus.getSceneSource();
  1036. }
  1037. }
  1038. return sceneSource;
  1039. }
  1040. @Override
  1041. public void setQrCode(String buildType,String num, Long cameraId, String shareLogoImg) throws Exception {
  1042. String basePath = NacosProperty.getMainUrl();
  1043. if("V2".equals(buildType)){
  1044. basePath += sceneProUrl;
  1045. }
  1046. if("V3".equals(buildType)){
  1047. basePath += sceneProNewUrl;
  1048. }
  1049. // 生成二维码
  1050. scenePlusService.createQrCode(num, cameraId, basePath + num, shareLogoImg, SceneVersionType.V3.code());
  1051. }
  1052. @Override
  1053. public void generateObjFile(String num) {
  1054. // LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
  1055. // wrapper.eq(ScenePro::getNum,num).eq(ScenePro::getRecStatus,"A");
  1056. // ScenePro sceneProEntity = this.getOne(wrapper);
  1057. ScenePro sceneProEntity = this.getByNum(num);
  1058. if(ObjectUtils.isEmpty(sceneProEntity)){
  1059. generatePlusObjFile(num);
  1060. return;
  1061. }
  1062. if(sceneProEntity.getSceneSource() != 4){
  1063. throw new BusinessException(LoginConstant.FAILURE_CODE_3003, "只能操作激光场景");
  1064. }
  1065. // 拷贝文件
  1066. String path = sceneProEntity.getDataSource();
  1067. if (!new File(path + "/caches/reconstruction/final.bin").exists()
  1068. || !new File(path + "/caches/reconstruction/chunk.json").exists()
  1069. || !new File(path + "/caches/images").exists()
  1070. || !new File(path + "/caches/depthmap").exists()
  1071. || !new File(path + "/caches/depthmap_csc").exists()
  1072. || !new File(path + "/caches/floor_group_fix.json").exists()
  1073. || !new File(path + "/caches/panorama.json").exists()
  1074. || !new File(path + "/results/laserData/laser.ply").exists()) {
  1075. log.error("生成obj缺少必要文件,生成失败!");
  1076. throw new BusinessException(SceneConstant.FAILURE_CODE_5038, SceneConstant.FAILURE_MSG_5038);
  1077. }
  1078. // 获取最新的场景名称
  1079. JSONObject sceneInfo = fdkkLaserService.getSceneByNum(sceneProEntity.getNum());
  1080. LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<>();
  1081. updateWrapper
  1082. .set(ScenePro::getStatus, 0)
  1083. .set(ScenePro::getIsObj, 1)
  1084. .set(ScenePro::getIsUpgrade, 2) // 升级中
  1085. .set(ScenePro::getSceneName, sceneInfo.getString("title"))
  1086. .eq(ScenePro::getNum, sceneProEntity.getNum());
  1087. this.update(updateWrapper);
  1088. //同步到scenePlus、scenePlus
  1089. //同步到scenePlus、scenePlus
  1090. ScenePlus scenePlus = scenePlusService.getByNum(num);
  1091. if(Objects.nonNull(scenePlus)){
  1092. sceneUpgradeMapper.deleteScenePlus(num);
  1093. sceneUpgradeMapper.deleteScenePlusExt(scenePlus.getId());
  1094. }
  1095. sceneUpgradeMapper.transferScenePlus(num);
  1096. scenePlus = scenePlusService.getByNum(num);
  1097. String sceneKind = sceneProEntity.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code();
  1098. sceneUpgradeMapper.transferScenePlusExt(num, scenePlus.getId(), sceneKind);
  1099. log.info("开始发送激光场景生成obj mq消息");
  1100. // 发送MQ
  1101. BuildSceneCallMessage mqMsg = new BuildSceneCallMessage();
  1102. mqMsg.setSceneNum(sceneProEntity.getNum());
  1103. mqMsg.setAlgorithm(sceneProEntity.getAlgorithm());
  1104. mqMsg.setBuildType(sceneProEntity.getBuildType());
  1105. mqMsg.setPath(sceneProEntity.getDataSource());
  1106. mqProducer.sendByWorkQueue(queueObjModelingPre,mqMsg);
  1107. }
  1108. public void generatePlusObjFile(String num) {
  1109. ScenePlus scenePlus = scenePlusService.getByNum(num);
  1110. if(ObjectUtils.isEmpty(scenePlus)){
  1111. throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
  1112. }
  1113. if(scenePlus.getSceneSource() != 4){
  1114. throw new BusinessException(LoginConstant.FAILURE_CODE_3003, "只能操作激光场景");
  1115. }
  1116. ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
  1117. // 拷贝文件
  1118. String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
  1119. String ossReconstruction = ossResultPath + "caches/reconstruction/";
  1120. if(!fYunFileService.fileExist(ossReconstruction + "final.bin")
  1121. || !fYunFileService.fileExist(ossReconstruction + "chunk.json")
  1122. || CollUtil.isEmpty(fYunFileService.listRemoteFiles(ossResultPath + "caches/images"))
  1123. || CollUtil.isEmpty(fYunFileService.listRemoteFiles(ossResultPath + "caches/depthmap"))
  1124. || CollUtil.isEmpty(fYunFileService.listRemoteFiles(ossResultPath + "caches/depthmap_csc"))
  1125. || !fYunFileService.fileExist(ossResultPath + "caches/panorama.json")
  1126. || !fYunFileService.fileExist(ossResultPath + "results/laserData/laser.ply")
  1127. || !fYunFileService.fileExist(ossResultPath + "caches/floor_group_fix.json")){
  1128. throw new BusinessException(SceneConstant.FAILURE_CODE_5038, SceneConstant.FAILURE_MSG_5038);
  1129. }
  1130. // String path = scenePlusExt.getDataSource();
  1131. // if (!new File(path + "/caches/reconstruction/final.bin").exists()
  1132. // || !new File(path + "/caches/reconstruction/chunk.json").exists()
  1133. // || !new File(path + "/caches/images").exists()
  1134. // || !new File(path + "/caches/depthmap").exists()
  1135. // || !new File(path + "/caches/depthmap_csc").exists()
  1136. // || !new File(path + "/caches/panorama.json").exists()
  1137. // || !new File(path + "/results/laserData/laser.ply").exists()) {
  1138. // log.error("生成obj缺少必要文件,生成失败!");
  1139. // throw new BusinessException(SceneConstant.FAILURE_CODE_5038, SceneConstant.FAILURE_MSG_5038);
  1140. // }
  1141. // 获取最新的场景名称
  1142. JSONObject sceneInfo = fdkkLaserService.getSceneByNum(num);
  1143. LambdaUpdateWrapper<ScenePlus> updateWrapper = new LambdaUpdateWrapper<>();
  1144. updateWrapper
  1145. .set(ScenePlus::getSceneStatus, 0)
  1146. .set(ScenePlus::getTitle, sceneInfo.getString("title"))
  1147. .eq(ScenePlus::getNum, num);
  1148. scenePlusService.update(updateWrapper);
  1149. LambdaUpdateWrapper<ScenePlusExt> plusExtUpdateWrapper = new LambdaUpdateWrapper<>();
  1150. plusExtUpdateWrapper
  1151. .set(ScenePlusExt::getIsObj, 1)
  1152. .eq(ScenePlusExt::getPlusId, scenePlus.getId());
  1153. scenePlusExtService.update(plusExtUpdateWrapper);
  1154. log.info("开始发送激光场景生成obj mq消息");
  1155. // 发送MQ
  1156. BuildSceneCallMessage mqMsg = new BuildSceneCallMessage();
  1157. mqMsg.setSceneNum(num);
  1158. mqMsg.setAlgorithm(scenePlusExt.getAlgorithm());
  1159. mqMsg.setBuildType(scenePlusExt.getBuildType());
  1160. mqMsg.setPath(scenePlusExt.getDataSource());
  1161. mqProducer.sendByWorkQueue(queueObjModelingPre,mqMsg);
  1162. }
  1163. @Override
  1164. public ResponseScene getSceneDetail(String sceneNum) {
  1165. if(StringUtils.isBlank(sceneNum)){
  1166. return null;
  1167. }
  1168. ResponseScene vo = new ResponseScene();
  1169. Scene sceneEntity = sceneService.getByNum(sceneNum);
  1170. if(sceneEntity != null){
  1171. return getResponseScene(vo, sceneEntity);
  1172. }
  1173. ScenePro sceneProEntity = this.getByNum(sceneNum);
  1174. if(sceneProEntity != null){
  1175. SceneProEdit sceneProEditEntity = sceneProEditService.getByProId(sceneProEntity.getId());
  1176. return getResponseProScene(vo, sceneProEntity, sceneProEditEntity);
  1177. }
  1178. ScenePlus scenePlus = scenePlusService.getByNum(sceneNum);
  1179. if(scenePlus != null){
  1180. ScenePlusExt ext = scenePlusExtService.getByPlusId(scenePlus.getId());
  1181. SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
  1182. return getResponseProScene(vo, scenePlus, ext,sceneEditInfo);
  1183. }
  1184. return vo;
  1185. }
  1186. private ResponseScene getResponseScene(ResponseScene vo, Scene sceneEntity) {
  1187. if (sceneEntity != null){
  1188. BeanUtils.copyProperties(sceneEntity, vo);
  1189. vo.setThumbImg(sceneEntity.getThumbStatus());
  1190. vo.setCreateTime(new DateTime(sceneEntity.getCreateTime()).toString("yyyy-MM-dd HH:mm"));
  1191. vo.setSceneIndex(sceneEntity.getStyle());
  1192. vo.setHasBGM(sceneEntity.getBgMusic());
  1193. vo.setCameraType(sceneEntity.getSceneScheme());
  1194. vo.setIsPublic(StringUtils.isEmpty(sceneEntity.getSceneKey()) ? 0 : 1);
  1195. }
  1196. return vo;
  1197. }
  1198. private ResponseScene getResponseProScene(ResponseScene vo, ScenePro sceneProEntity, SceneProEdit sceneProEditEntity) {
  1199. if (sceneProEntity != null){
  1200. BeanUtils.copyProperties(sceneProEditEntity, vo);
  1201. BeanUtils.copyProperties(sceneProEntity, vo);
  1202. vo.setCreateTime(DateUserUtil.getMDate(vo.getCreateTime()));
  1203. vo.setCameraType(sceneProEntity.getSceneScheme());
  1204. vo.setThumbImg(sceneProEditEntity.getThumbStatus());
  1205. vo.setHasBGM(sceneProEditEntity.getBgMusic());
  1206. vo.setIsPublic(StringUtils.isEmpty(sceneProEditEntity.getSceneKey()) ? 0 : 1);
  1207. }
  1208. return vo;
  1209. }
  1210. private ResponseScene getResponseProScene(ResponseScene vo, ScenePlus plus, ScenePlusExt ext,SceneEditInfo editInfo) {
  1211. if (plus != null){
  1212. BeanUtils.copyProperties(plus, vo);
  1213. BeanUtils.copyProperties(ext, vo);
  1214. BeanUtils.copyProperties(editInfo, vo);
  1215. vo.setNum(plus.getNum());
  1216. vo.setSceneName(plus.getTitle());
  1217. vo.setCreateTime(DateUserUtil.getMDate(vo.getCreateTime()));
  1218. vo.setCameraType(ext.getSceneScheme());
  1219. vo.setThumbImg(1);
  1220. vo.setHasBGM(editInfo.getMusic());
  1221. vo.setIsPublic(StringUtils.isEmpty(editInfo.getScenePassword()) ? 0 : 1);
  1222. }
  1223. return vo;
  1224. }
  1225. }