SceneEditInfoServiceImpl.java 127 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891
  1. package com.fdkankan.scene.service.impl;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import cn.hutool.core.collection.CollUtil;
  4. import cn.hutool.core.util.StrUtil;
  5. import com.alibaba.fastjson.JSON;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  8. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  9. import com.fdkankan.common.constant.CommonStatus;
  10. import com.fdkankan.common.constant.ErrorCode;
  11. import com.fdkankan.common.constant.SceneInfoReqType;
  12. import com.fdkankan.common.exception.BusinessException;
  13. import com.fdkankan.redis.constant.RedisKey;
  14. import com.fdkankan.redis.util.RedisClient;
  15. import com.fdkankan.scene.entity.*;
  16. import com.fdkankan.scene.mapper.SceneEditInfoMapper;
  17. import com.fdkankan.scene.service.*;
  18. import com.fdkankan.scene.vo.*;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.stereotype.Service;
  21. import org.springframework.transaction.annotation.Transactional;
  22. import javax.annotation.Resource;
  23. import java.util.*;
  24. import java.util.stream.Collectors;
  25. /**
  26. * <p>
  27. * 服务实现类
  28. * </p>
  29. *
  30. * @author
  31. * @since 2024-10-09
  32. */
  33. @Service
  34. public class SceneEditInfoServiceImpl extends ServiceImpl<SceneEditInfoMapper, SceneEditInfo> implements SceneEditInfoService {
  35. // @Value("${fyun.host}")
  36. // private String ossUrlPrefix;
  37. // @Value("${fyun.type}")
  38. // private String fyunType;
  39. // @Value("${ecs.checkFile.maxTimes:20}")
  40. // private int maxCheckTimes;
  41. // @Value("${ecs.checkFile.waitTime:1000}")
  42. // private int waitTime;
  43. //
  44. @Autowired
  45. private SceneEditControlsService sceneEditControlsService;
  46. // @Autowired
  47. // private ISceneProService sceneProService;
  48. // @Resource
  49. // private FYunFileServiceInterface fYunFileService;
  50. @Resource
  51. private RedisClient redisClient;
  52. // @Autowired
  53. // private RedisLockUtil redisLockUtil;
  54. // @Autowired
  55. // ISceneDataDownloadService sceneDataDownloadService;
  56. @Autowired
  57. private SceneEditInfoExtService sceneEditInfoExtService;
  58. @Autowired
  59. private SceneService sceneService;
  60. @Autowired
  61. private SceneFileMappingService sceneFileMappingService;
  62. // @Autowired
  63. // IScenePlusExtService scenePlusExtService;
  64. // @Autowired
  65. // private ISceneUploadService sceneUploadService;
  66. // @Autowired
  67. // private ICameraDetailService cameraDetailService;
  68. // @Autowired
  69. // private ICompanyService companyService;
  70. // @Autowired
  71. // private ISurveillanceService surveillanceService;
  72. // @Autowired
  73. // private ISceneAsynOperLogService sceneAsynOperLogService;
  74. // @Autowired
  75. // private ICutModelService cutModelService;
  76. // @Autowired
  77. // private ICommonService commonService;
  78. // @Autowired
  79. // private FYunFileConfig fYunFileConfig;
  80. // @Autowired
  81. // private ISceneDrawService sceneDrawService;
  82. // @Autowired
  83. // private ISceneDynamicPanelService sceneDynamicPanelService;
  84. @Transactional
  85. @Override
  86. public SceneEditInfoVO saveScene(SceneEditInfoParamVO param) {
  87. Scene scenePlus = sceneService.getByNum(param.getNum());
  88. if(Objects.isNull(scenePlus)){
  89. throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  90. }
  91. SceneEditInfo sceneEditInfoDb = this.getByScenePlusId(scenePlus.getId());
  92. SceneEditControls sceneEditControlsDb = null;
  93. if(Objects.nonNull(sceneEditInfoDb)){
  94. sceneEditControlsDb = sceneEditControlsService.getBySceneEditId(sceneEditInfoDb.getId());
  95. }
  96. //用户上传的文件后缀名转小写
  97. this.lowercaseExtName(param);
  98. SceneEditInfo sceneEditInfo = BeanUtil.copyProperties(param, SceneEditInfo.class);
  99. sceneEditInfo.setScenePlusId(scenePlus.getId());
  100. if(Objects.isNull(sceneEditInfoDb)){
  101. this.save(sceneEditInfo);
  102. }else{
  103. sceneEditInfo.setId(sceneEditInfoDb.getId());
  104. sceneEditInfo.setVersion(sceneEditInfoDb.getVersion() + 1);
  105. this.updateById(sceneEditInfo);
  106. }
  107. SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
  108. if(Objects.isNull(sceneEditInfoExt)){
  109. sceneEditInfoExt = new SceneEditInfoExt();
  110. sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
  111. sceneEditInfoExt.setScenePlusId(scenePlus.getId());
  112. }
  113. if(Objects.nonNull(param.getSns())){
  114. sceneEditInfoExt.setSnsInfo(JSON.toJSONString(param.getSns()));
  115. }
  116. if(Objects.nonNull(param.getStarted())){
  117. sceneEditInfoExt.setStarted(JSON.toJSONString(param.getStarted()));
  118. }
  119. // else{
  120. // sceneEditInfoExt.setStarted("");
  121. // }
  122. sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
  123. if(Objects.nonNull(param.getControls())){
  124. SceneEditControls sceneEditControls = BeanUtil.copyProperties(param.getControls(), SceneEditControls.class);
  125. sceneEditControls.setEditInfoId(sceneEditInfo.getId());
  126. if(Objects.isNull(sceneEditControlsDb)){
  127. sceneEditControlsService.save(sceneEditControls);
  128. }else{
  129. sceneEditControls.setId(sceneEditControlsDb.getId());
  130. sceneEditControlsService.updateById(sceneEditControls);
  131. }
  132. }
  133. scenePlus.setTitle(param.getTitle());
  134. scenePlus.setDescription(param.getDescription());
  135. sceneService.updateById(scenePlus);
  136. SceneEditInfoVO result = BeanUtil.copyProperties(param, SceneEditInfoVO.class);
  137. result.setCreateTime(sceneEditInfo.getCreateTime());
  138. return result;
  139. }
  140. private void lowercaseExtName(SceneEditInfoParamVO sceneEditInfo){
  141. if(StrUtil.isNotEmpty(sceneEditInfo.getMusic())){
  142. String extName = cn.hutool.core.io.FileUtil.extName(sceneEditInfo.getMusic());
  143. if(StrUtil.isNotEmpty(extName)){
  144. sceneEditInfo.setMusic(sceneEditInfo.getMusic().replace(extName, extName.toLowerCase()));
  145. }
  146. }
  147. if(StrUtil.isNotEmpty(sceneEditInfo.getMusicFile())){
  148. String extName = cn.hutool.core.io.FileUtil.extName(sceneEditInfo.getMusicFile());
  149. if(StrUtil.isNotEmpty(extName)){
  150. sceneEditInfo.setMusicFile(sceneEditInfo.getMusicFile().replace(extName, extName.toLowerCase()));
  151. }
  152. }
  153. }
  154. // @Override
  155. // public SceneEditInfo getBySceneProId(long sceneProId) {
  156. // return this.getOne(new LambdaQueryWrapper<SceneEditInfo>()
  157. // .eq(SceneEditInfo::getSceneProId, sceneProId));
  158. // }
  159. @Override
  160. public SceneEditInfo getByScenePlusId(long scenePlusId) {
  161. return this.getOne(new LambdaQueryWrapper<SceneEditInfo>()
  162. .eq(SceneEditInfo::getScenePlusId, scenePlusId));
  163. }
  164. // @Transactional
  165. // @Override
  166. // public ResultData publicScene(SceneEditInfoParamVO param) throws Exception{
  167. // String num = param.getNum();
  168. //
  169. // //根据场景码查询数据库
  170. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  171. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  172. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  173. // SceneEditInfoExt sceneEditInfoExt = null;
  174. // SceneEditControls sceneEditControls = null;
  175. // if(sceneEditInfo == null){
  176. // sceneEditInfo = new SceneEditInfo();
  177. // sceneEditInfo.setSceneProId(scenePlus.getId());
  178. // }else{
  179. // sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
  180. // sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
  181. // }
  182. // if(sceneEditInfoExt == null){
  183. // sceneEditInfoExt = new SceneEditInfoExt();
  184. // sceneEditInfoExt.setFloorPlanAngle(0f);
  185. // sceneEditInfoExt.setFloorPlanCompass(0f);
  186. // }
  187. // String bucket = scenePlusExt.getYunFileBucket();
  188. //
  189. // //生成sceneJson
  190. // SceneJsonBean sceneJson = new SceneJsonBean();
  191. // BeanUtil.copyProperties(sceneEditInfoExt, sceneJson, "started");
  192. // BeanUtil.copyProperties(sceneEditInfo, sceneJson);
  193. // sceneJson.setFloorPlanUpload(JSON.parseArray(sceneEditInfo.getFloorPlanUpload()));
  194. // SceneEditControlsVO sceneEditControlsVO = BeanUtil.copyProperties(sceneEditControls, SceneEditControlsVO.class);
  195. // sceneJson.setControls(sceneEditControlsVO);
  196. // sceneJson.setNum(num);
  197. // sceneJson.setCreateTime(scenePlus.getCreateTime());
  198. //
  199. // sceneJson.setSceneResolution(scenePlusExt.getSceneResolution());
  200. // sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
  201. // sceneJson.setSceneKind(scenePlusExt.getSceneKind());
  202. // sceneJson.setModelKind(scenePlusExt.getModelKind());
  203. // if(StrUtil.isNotEmpty(scenePlusExt.getVideos())){
  204. // sceneJson.setVideos(scenePlusExt.getVideos());
  205. // }
  206. //
  207. // //发布马赛克列表
  208. // sceneJson.setMosaicList(this.getMosaicList(num));
  209. //
  210. // //发布分享配置
  211. // sceneJson.setSns(JSON.parseObject(sceneEditInfoExt.getSnsInfo()));
  212. //
  213. // //发布启动页配置
  214. // sceneJson.setStarted(JSON.parseObject(sceneEditInfoExt.getStarted()));
  215. //
  216. // //处理热点数据,生成hot.json
  217. // this.publicHotData(num, bucket);
  218. //
  219. // //发布场景关联相关数据
  220. // this.publicLinkSceneData(num, bucket);
  221. //
  222. // //发布滤镜数据
  223. // this.publicFilterData(num, sceneEditInfoExt.getFilters(), bucket);
  224. //
  225. // //发布摄像头数据
  226. // this.publicSurveillance(num, sceneEditInfoExt.getSurveillances(), bucket);
  227. //
  228. // //发布指示牌数据
  229. // this.publicBillboardData(num, bucket);
  230. //
  231. // //发布模型裁剪
  232. // cutModelService.publicCutModel(num, bucket);
  233. //
  234. // //发布场景绘制
  235. // sceneDrawService.publicSceneDraw(num, bucket);
  236. //
  237. // sceneJson.setDynamicPanel(sceneDynamicPanelService.checkDynamicPanel(num));
  238. //
  239. // //本地写sceneJson文件
  240. // String localSceneJsonPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "scene.json";
  241. // FileUtils.writeFile(localSceneJsonPath, JSON.toJSONString(sceneJson));
  242. // //上传sceneJson文件
  243. // String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH+"scene.json", num);
  244. // fYunFileService.uploadFile(bucket, JSON.toJSONBytes(sceneJson), sceneJsonPath);
  245. //
  246. // //删除发布数据中的user目录
  247. // String publicUserPath = String.format(UploadFilePath.USER_VIEW_PATH, num);
  248. // List<String> userViewFileList = fYunFileService.listRemoteFiles(bucket, publicUserPath);
  249. // if(CollUtil.isNotEmpty(userViewFileList)){
  250. // fYunFileService.deleteFolder(bucket, publicUserPath);
  251. // }
  252. //
  253. // //复制编辑目录到发布目录
  254. // String editPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum());
  255. // String viewPath = String.format(UploadFilePath.USER_VIEW_PATH, param.getNum());
  256. // fYunFileService.copyFileBetweenBucket(bucket, editPath, bucket, viewPath);
  257. //
  258. // //sceneJson放入缓存
  259. // String key = String.format(RedisKey.SCENE_JSON, num);
  260. // redisUtil.set(key, JSON.toJSONString(sceneJson));
  261. //
  262. // //入库
  263. // if(sceneEditInfo.getId() == null){
  264. // this.save(sceneEditInfo);
  265. // }else{
  266. // this.updateById(sceneEditInfo);
  267. // }
  268. // sceneEditInfoExt.setScenePlusId(scenePlus.getId());
  269. // sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
  270. // sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
  271. //
  272. // scenePlus.setTitle(sceneEditInfo.getTitle());
  273. // scenePlus.setDescription(sceneEditInfo.getDescription());
  274. // scenePlus.setHouseType(this.existsHouseType(bucket, num));
  275. // scenePlusService.updateById(scenePlus);
  276. //
  277. // return ResultData.ok();
  278. // }
  279. //
  280. // private int existsHouseType(String bucket, String num){
  281. // String houseTypePath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "houseType.json";
  282. // boolean exist = fYunFileService.fileExist(bucket, houseTypePath);
  283. // return exist ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue();
  284. // }
  285. //
  286. // private void publicSurveillance(String num, Integer surveillances, String bucket) throws IOException {
  287. // String surveillanceJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "surveillance.json";
  288. // if(surveillances == CommonStatus.NO.code().intValue()){
  289. // fYunFileService.deleteFile(bucket, surveillanceJsonPath);
  290. // return;
  291. // }
  292. // List<SurveillanceVO> surveillanceList = surveillanceService.listSurveillance(num);
  293. // fYunFileService.uploadFile(bucket, JSON.toJSONString(surveillanceList).getBytes(StandardCharsets.UTF_8), surveillanceJsonPath);
  294. // }
  295. //
  296. // private void publicFilterData(String num, int filters, String bucket) throws IOException {
  297. //
  298. // String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
  299. // if(filters == CommonStatus.NO.code()){
  300. // fYunFileService.deleteFile(bucket, userEditPath + "filter.json");
  301. // return;
  302. // }
  303. // String key = String.format(RedisKey.SCENE_filter_DATA, num);
  304. // List<String> list = redisUtil.lGet(key, 0, -1);
  305. // JSONArray jsonArray = new JSONArray();
  306. // list.stream().forEach(str->jsonArray.add(JSON.parseObject(str)));
  307. // fYunFileService.uploadFile(bucket, JSON.toJSONBytes(jsonArray), userEditPath + "filter.json");
  308. // }
  309. //
  310. // public void publicLinkSceneData(String num, String bucket) throws IOException {
  311. //
  312. // String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
  313. // String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
  314. // String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
  315. //
  316. // //清除发布目录中的场景关联图片
  317. // if(fYunFileService.fileExist(bucket,imgViewPath + "panorama")){
  318. // fYunFileService.deleteFolder(bucket,imgViewPath + "panorama");
  319. // }
  320. //
  321. // //生成links.json并上传到发布目录
  322. // String linkPanKey = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
  323. // Map<String, String> linkPanMap = redisUtil.hmget(linkPanKey);
  324. // if(CollUtil.isEmpty(linkPanMap)){
  325. // return;
  326. // }
  327. // List<JSONObject> tags = Lists.newArrayList();
  328. // List<TagBean> tagBeanList = new ArrayList<>();
  329. // if(CollUtil.isNotEmpty(linkPanMap)){
  330. // linkPanMap.entrySet().stream().forEach(entry -> {
  331. // JSONObject jsonObject = JSON.parseObject(entry.getValue());
  332. // tagBeanList.add(
  333. // TagBean.builder()
  334. // .createTime(jsonObject.getLong("createTime"))
  335. // .tag(jsonObject).build());
  336. // });
  337. // //按创建时间倒叙排序
  338. // tagBeanList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
  339. //
  340. // //移除createTime字段
  341. // tags = tagBeanList.stream().map(tagBean -> {
  342. // JSONObject tag = tagBean.getTag();
  343. // tag.remove("createTime");
  344. // return tag;
  345. // }).collect(Collectors.toList());
  346. // }
  347. // String linkScenePath = userEditPath + "links.json";
  348. // fYunFileService.uploadFile(bucket, JSON.toJSONString(tags).getBytes(StandardCharsets.UTF_8), linkScenePath);
  349. //
  350. // //拷贝编辑目录到发布目录
  351. // fYunFileService.copyFileBetweenBucket(bucket, imgEditPath + "panorama", bucket, imgViewPath + "panorama");
  352. //
  353. // }
  354. //
  355. // private void publicHotData(String sceneNum, String bucket) throws IOException {
  356. // String hotDataKey = String.format(RedisKey.SCENE_HOT_DATA, sceneNum);
  357. // Map<String, String> hotMap = redisUtil.hmget(hotDataKey);
  358. //
  359. // JSONArray tags = new JSONArray();
  360. // if(CollUtil.isNotEmpty(hotMap)){
  361. // List<TagBean> tagBeanList = hotMap.entrySet().stream().map(entry -> {
  362. // JSONObject jsonObject = JSON.parseObject(entry.getValue());
  363. // return TagBean.builder()
  364. // .createTime(jsonObject.getLong("createTime"))
  365. // .tag(jsonObject).build();
  366. // }).collect(Collectors.toList());
  367. // //按创建时间倒叙排序
  368. // tagBeanList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
  369. //
  370. // //移除createTime字段
  371. // tagBeanList.stream().forEach(tagBean -> {
  372. // tags.add(tagBean.getTag());
  373. // });
  374. // }
  375. //
  376. // String hotJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, sceneNum) + "hot.json";
  377. // fYunFileService.uploadFile(bucket, tags.toString().getBytes(), hotJsonPath);
  378. //// this.saveTagsToSceneEditInfo(sceneNum, sceneEditInfo);
  379. //
  380. // }
  381. //
  382. // private void publicBillboardData(String sceneNum, String bucket) throws IOException {
  383. // String Key = String.format(RedisKey.SCENE_BILLBOARDS, sceneNum);
  384. // String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, sceneNum) + "billboards.json";
  385. // List<String> list = redisUtil.hgetValues(Key);
  386. // if(CollUtil.isEmpty(list)){
  387. // fYunFileService.deleteFile(bucket, userEditPath);
  388. // return;
  389. // }
  390. // List<JSONObject> collect = list.stream().map(str -> JSON.parseObject(str)).collect(Collectors.toList());
  391. // fYunFileService.uploadFile(bucket, JSON.toJSONString(collect).getBytes(), userEditPath);
  392. // }
  393. //
  394. @Override
  395. public SceneInfoVO getSceneInfo(SceneInfoParamVO param) throws Exception{
  396. SceneInfoReqType sceneInfoReqType = SceneInfoReqType.get(param.getReqType());
  397. switch (sceneInfoReqType){
  398. //如果是编辑页面请求,查数据库
  399. case EDIT:
  400. return this.getSceneInfo4Edit(param.getNum());
  401. //如果是查看页面请求,查redis
  402. case VIEW:
  403. return this.getSceneInfo4Edit(param.getNum());
  404. }
  405. return null;
  406. }
  407. /**
  408. * <p>
  409. 编辑页面获取场景详情信息
  410. * </p>
  411. * @author dengsixing
  412. * @date 2022/1/21
  413. * @param num
  414. * @return com.fdkankan.scene.vo.SceneInfoVO
  415. **/
  416. private SceneInfoVO getSceneInfo4Edit(String num) throws Exception{
  417. Scene scenePlus = sceneService.getByNum(num);
  418. if(Objects.isNull(scenePlus)){
  419. throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  420. }
  421. SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  422. if(Objects.isNull(sceneEditInfo)){
  423. throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  424. }
  425. SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
  426. SceneEditControls sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
  427. SceneInfoVO sceneInfoVO = new SceneInfoVO();
  428. BeanUtil.copyProperties(sceneEditInfoExt, sceneInfoVO, "started");
  429. BeanUtil.copyProperties(sceneEditInfo, sceneInfoVO);
  430. sceneInfoVO.setFloorPlanUpload(JSON.parseArray(sceneEditInfo.getFloorPlanUpload()));
  431. if(Objects.isNull(sceneInfoVO.getFloorPlanAngle())){
  432. sceneInfoVO.setFloorPlanAngle(0f);
  433. }
  434. if(Objects.isNull(sceneInfoVO.getFloorPlanCompass())){
  435. sceneInfoVO.setFloorPlanCompass(0f);
  436. }
  437. sceneInfoVO.setControls(BeanUtil.copyProperties(sceneEditControls, SceneEditControlsVO.class));
  438. sceneInfoVO.setNum(num);
  439. sceneInfoVO.setSceneResolution(scenePlus.getSceneresolution());
  440. sceneInfoVO.setSceneFrom(scenePlus.getScenefrom());
  441. sceneInfoVO.setSceneKind(scenePlus.getScenekind());
  442. sceneInfoVO.setModelKind(scenePlus.getModelkind());
  443. if(CommonStatus.YES.code().intValue() == sceneEditInfoExt.getMosaic()){
  444. sceneInfoVO.setMosaicList(this.getMosaicList(num));
  445. }
  446. sceneInfoVO.setSns(JSON.parseObject(sceneEditInfoExt.getSnsInfo()));
  447. sceneInfoVO.setStarted(JSON.parseObject(sceneEditInfoExt.getStarted()));
  448. // this.SortBoxVideos(sceneInfoVO);
  449. Set<String> keySet = new HashSet<>();
  450. Set<Long> deleteIds = new HashSet<>();
  451. List<SceneFileMapping> mappings = new ArrayList<>();
  452. List<SceneFileMapping> mappingList = sceneFileMappingService.list(new LambdaQueryWrapper<SceneFileMapping>().eq(SceneFileMapping::getNum, num).orderByDesc(SceneFileMapping::getId));
  453. for (SceneFileMapping mapping : mappingList) {
  454. if(keySet.contains(mapping.getKey())){
  455. deleteIds.add(mapping.getId());
  456. }else{
  457. keySet.add(mapping.getKey());
  458. mappings.add(mapping);
  459. }
  460. }
  461. if(CollUtil.isNotEmpty(deleteIds)){
  462. sceneFileMappingService.removeByIds(deleteIds);
  463. }
  464. Map<String, String> keyMap = new HashMap<>();
  465. for (SceneFileMapping sceneFileMapping : mappings) {
  466. keyMap.put(sceneFileMapping.getKey(), "service/scene/file?key=" + sceneFileMapping.getKey());
  467. }
  468. sceneInfoVO.setMapping(keyMap);
  469. return sceneInfoVO;
  470. }
  471. // public static void main(String[] args) {
  472. // String test = "";
  473. //// JSONObject jsonObject = JSON.parseObject(test);
  474. // System.out.println(JSON.toJSONString(test));
  475. // }
  476. //
  477. // private void SortBoxVideos(SceneInfoVO sceneInfoVO){
  478. // String boxVideos = sceneInfoVO.getBoxVideos();
  479. // if(StrUtil.isEmpty(boxVideos)){
  480. // return;
  481. // }
  482. // JSONArray boxVideoArr = JSON.parseArray(boxVideos);
  483. // if(CollUtil.isEmpty(boxVideoArr)){
  484. // return;
  485. // }
  486. // List<TagBean> tagBeanList = boxVideoArr.stream().map(o -> {
  487. // JSONObject item = (JSONObject) o;
  488. // return TagBean.builder()
  489. // .createTime(item.getLong("createTime"))
  490. // .tag(item).build();
  491. // }).collect(Collectors.toList());
  492. //
  493. // //按创建时间倒叙排序
  494. // tagBeanList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
  495. //
  496. // //移除createTime字段
  497. // List<JSONObject> boxVideoList = tagBeanList.stream().map(tagBean -> {
  498. // JSONObject tag = tagBean.getTag();
  499. // tag.remove("createTime");
  500. // return tag;
  501. // }).collect(Collectors.toList());
  502. //
  503. // sceneInfoVO.setBoxVideos(JSON.toJSONString(boxVideoList));
  504. // }
  505. //
  506. // /**
  507. // * <p>
  508. // getInfo接口返回字段扩展
  509. // * </p>
  510. // * @author dengsixing
  511. // * @date 2022/3/9
  512. // **/
  513. // private void setExtData(SceneInfoVO sceneInfoVO, Long cameraId) throws Exception{
  514. //
  515. // if(Objects.isNull(cameraId)){
  516. // return;
  517. // }
  518. //
  519. // CameraDetail cameraDetail = cameraDetailService.findByCameraId(cameraId);
  520. // if(Objects.isNull(cameraDetail)){
  521. // throw new BusinessException(ErrorCode.FAILURE_CODE_7010);
  522. // }
  523. // if(Objects.isNull(cameraDetail.getCompanyId())){
  524. // return;
  525. // }
  526. // Company company = companyService.getById(cameraDetail.getCompanyId());
  527. // if(Objects.isNull(company)){
  528. // return;
  529. // }
  530. // sceneInfoVO.setDataSync(company.getDataSync());
  531. // }
  532. //
  533. // /**
  534. // * <p>
  535. // 查看页面获取场景详情信息
  536. // * </p>
  537. // * @author dengsixing
  538. // * @date 2022/1/21
  539. // * @param num
  540. // * @return com.fdkankan.scene.vo.SceneInfoVO
  541. // **/
  542. // private SceneInfoVO getSceneInfo4View(String num) throws Exception{
  543. //
  544. // //校验场景是否为空、封存、计算中
  545. // ScenePlus scenePlus = scenePlusService.checkSceneAvail(num);
  546. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  547. //
  548. // //访问量+1
  549. // scenePlusService.updateViewCount(num);
  550. //
  551. // String key = String.format(RedisKey.SCENE_JSON, num);
  552. // String sceneJson = redisUtil.get(key);
  553. // SceneInfoVO sceneInfoVO = null;
  554. // //先查询redis
  555. // if(StrUtil.isEmpty(sceneJson)) {
  556. // String objectName = String.format(ConstantFilePath.SCENE_VIEW_DATA_DATA_SCENEJSON, num);
  557. // sceneJson = fYunFileService.getFileContent(scenePlusExt.getYunFileBucket(), objectName);
  558. // redisUtil.set(key, sceneJson);
  559. // }
  560. // sceneInfoVO = JSON.parseObject(sceneJson, SceneInfoVO.class);
  561. // sceneInfoVO.setScenePassword(null);
  562. // if(Objects.isNull(sceneInfoVO.getFloorPlanAngle())){
  563. // sceneInfoVO.setFloorPlanAngle(0f);
  564. // }
  565. // if(Objects.isNull(sceneInfoVO.getFloorPlanCompass())){
  566. // sceneInfoVO.setFloorPlanCompass(0f);
  567. // }
  568. // SceneEditControlsVO controls = sceneInfoVO.getControls();
  569. // if(Objects.isNull(controls.getShowShare())){
  570. // controls.setShowShare(CommonStatus.YES.code().intValue());
  571. // }
  572. // if(Objects.isNull(controls.getShowCapture())){
  573. // controls.setShowCapture(CommonStatus.YES.code().intValue());
  574. // }
  575. // if(Objects.isNull(controls.getShowBillboardTitle())){
  576. // controls.setShowBillboardTitle(CommonStatus.YES.code().intValue());
  577. // }
  578. // if(Objects.isNull(controls.getShowDrawTitle())){
  579. // controls.setShowDrawTitle(CommonStatus.YES.code().intValue());
  580. // }
  581. //
  582. // sceneInfoVO.setPayStatus(scenePlus.getPayStatus());
  583. //
  584. // return sceneInfoVO;
  585. // }
  586. //
  587. // @Override
  588. // public ResultData saveCad(BaseDataParamVO param) throws Exception {
  589. //
  590. // String num = param.getNum();
  591. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  592. // if(Objects.isNull(scenePlus))
  593. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  594. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  595. //
  596. // String bucket = scenePlusExt.getYunFileBucket();
  597. // String editUserPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
  598. // String localDataPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
  599. //
  600. // JSONObject fileInfoJson = JSON.parseObject(param.getData());
  601. // Float angel = null;
  602. // Float compass = null;
  603. // String floorJsonData = fileInfoJson.getString("floorJsonData");
  604. // if(StrUtil.isNotBlank(floorJsonData)){
  605. // JSONObject jsonObject = JSON.parseObject(floorJsonData);
  606. // angel = jsonObject.getFloat("angle");
  607. // compass = jsonObject.getFloat("compass");
  608. // }
  609. //
  610. // //处理户型图数据
  611. // //上传floorplan_user.json文件
  612. // FileUtils.writeFile(localDataPath + "floorplan_user.json", floorJsonData);
  613. // fYunFileService.uploadFile(bucket, localDataPath + "floorplan_user.json", editUserPath + "floorplan.json");
  614. //
  615. // //写入数据库
  616. // Byte floorPlanUser = null;
  617. // if(StrUtil.isNotEmpty(floorJsonData)){
  618. // JSONObject houseTypeJson = CreateHouseJsonUtil
  619. // .createHouseTypeJsonByUser(localDataPath + "floorplan_user.json");
  620. // if(Objects.nonNull(houseTypeJson)) {
  621. // fYunFileService.uploadFile(bucket, houseTypeJson.toJSONString().getBytes(), editUserPath + "houseType.json");
  622. // }
  623. //
  624. // floorPlanUser = CommonStatus.YES.code();
  625. // }
  626. // SceneEditInfo sceneEditInfoDb = this.getByScenePlusId(scenePlus.getId());
  627. // if(Objects.nonNull(sceneEditInfoDb)){
  628. // LambdaUpdateWrapper<SceneEditInfo> updateWrapper = new LambdaUpdateWrapper<SceneEditInfo>()
  629. // .setSql("version=version+" + 1)
  630. // .eq(SceneEditInfo::getId, sceneEditInfoDb.getId());
  631. // if(floorPlanUser != null){
  632. // updateWrapper.set(SceneEditInfo::getFloorPlanUser, floorPlanUser);
  633. // }
  634. // this.update(updateWrapper);
  635. // }else{
  636. // sceneEditInfoDb = new SceneEditInfo();
  637. // sceneEditInfoDb.setScenePlusId(scenePlus.getId());
  638. // sceneEditInfoDb.setFloorPlanUser(floorPlanUser);
  639. // this.save(sceneEditInfoDb);
  640. // }
  641. //
  642. // SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfoDb.getId());
  643. // if(Objects.isNull(sceneEditInfoExt)){
  644. // sceneEditInfoExt = new SceneEditInfoExt();
  645. // sceneEditInfoExt.setEditInfoId(sceneEditInfoDb.getId());
  646. // }
  647. // if(Objects.nonNull(angel)){
  648. // sceneEditInfoExt.setFloorPlanAngle(angel);
  649. // }
  650. // if(Objects.nonNull(compass)){
  651. // sceneEditInfoExt.setFloorPlanCompass(compass);
  652. // }
  653. // sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
  654. //
  655. //
  656. // return ResultData.ok();
  657. //
  658. // }
  659. //
  660. // @Override
  661. // public ResultData uploadDxf(MultipartFile file, String num) throws Exception {
  662. //
  663. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  664. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  665. //
  666. // String extName = FileUtil.extName(file.getOriginalFilename());
  667. // if(!"dxf".equals(extName)){
  668. // throw new BusinessException(ErrorCode.FAILURE_CODE_7007.code(), ErrorCode.FAILURE_CODE_7007.formatMessage("dxf"));
  669. // }
  670. // String dfxPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + UUID.randomUUID() + "." + extName;
  671. // String floorplanUserPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + UUID.randomUUID() + ".json";
  672. // file.transferTo(new File(dfxPath));
  673. // try {
  674. // String editUserPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
  675. // FdJsonToDxfUtil.dxfToFdJson(dfxPath, floorplanUserPath);
  676. // fYunFileService.uploadFile(scenePlusExt.getYunFileBucket(), floorplanUserPath, editUserPath + "floorplan.json");
  677. // JSONObject houseTypeJson = CreateHouseJsonUtil
  678. // .createHouseTypeJsonByUser(floorplanUserPath);
  679. // if(Objects.nonNull(houseTypeJson)) {
  680. // fYunFileService.uploadFile(scenePlusExt.getYunFileBucket(), houseTypeJson.toJSONString().getBytes(), editUserPath + "houseType.json");
  681. // }
  682. //
  683. // SceneEditInfo sceneEditInfoDb = this.getByScenePlusId(scenePlus.getId());
  684. // this.update(new LambdaUpdateWrapper<SceneEditInfo>()
  685. // .setSql("version=version+" + 1)
  686. // .set(SceneEditInfo::getFloorPlanUser, 1)
  687. // .eq(SceneEditInfo::getId, sceneEditInfoDb.getId()));
  688. //
  689. // SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfoDb.getId());
  690. // sceneEditInfoExt.setFloorPlanAngle(0f);
  691. // sceneEditInfoExt.setFloorPlanCompass(0f);
  692. // sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
  693. // }catch (Exception e){
  694. // log.error("cad文件转换失败");
  695. // ResultData.error(ErrorCode.FAILURE_CODE_7013);
  696. // }finally {
  697. // FileUtil.del(dfxPath);
  698. // FileUtil.del(floorplanUserPath);
  699. // }
  700. //
  701. // return ResultData.ok();
  702. // }
  703. //
  704. // @Override
  705. // public ResultData downloadDxf(String num) throws Exception {
  706. //
  707. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  708. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  709. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  710. // if(Objects.isNull(sceneEditInfo.getFloorPlanUser()) || sceneEditInfo.getFloorPlanUser() == CommonStatus.NO.code()){
  711. // return ResultData.ok();
  712. // }
  713. //
  714. // String localFloorplan = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + UUID.randomUUID() + ".json";
  715. // fYunFileService.downloadFile(scenePlusExt.getYunFileBucket(),
  716. // String.format(UploadFilePath.USER_EDIT_PATH, num) + "floorplan.json", localFloorplan);
  717. // String localDxf = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + UUID.randomUUID() + ".dxf";
  718. // FdJsonToDxfUtil.fdJsonToDxf(localFloorplan, localDxf);
  719. // String key = OssFileUtil.getUploadTempFileKey(null, "dxf");
  720. // fYunFileService.uploadFile(scenePlusExt.getYunFileBucket(), localDxf, key);
  721. // String url = fYunFileConfig.getHost() + key;
  722. //
  723. // return ResultData.ok(url);
  724. // }
  725. //
  726. // @Override
  727. // public ResultData resetCad(String num) throws IOException {
  728. //
  729. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  730. // if(Objects.isNull(scenePlus))
  731. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  732. // ScenePlusExt scenePlusExt = scenePlusExtService
  733. // .getScenePlusExtByPlusId(scenePlus.getId());
  734. // String bucket = scenePlusExt.getYunFileBucket();
  735. // String path = scenePlusExt.getDataSource();
  736. //
  737. // //户型图上传 恢复默认并发布同时点击刷新查看页面,平面图会变形,所以这里先注释掉 bug-36281 2023-05-04
  738. //// String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
  739. //// String floorplanCadPath = ossResultPath + "floorplan_cad/";
  740. //// fYunFileService.copyFileBetweenBucket(bucket, floorplanCadPath, bucket, String.format(UploadFilePath.USER_EDIT_PATH, num));
  741. //
  742. //// String userEditPath = UploadFilePath.USER_EDIT_PATH + "floor-cad-%s.%s";
  743. //// String floorCadPath = path + "/results/floorplan_cad";
  744. //// List<String> floorCadList = FileUtils.getFileList(floorCadPath);
  745. //// if(CollUtil.isNotEmpty(floorCadList)){
  746. //// floorCadList.stream().forEach(str->{
  747. //// String substring = str.substring(str.lastIndexOf(File.separator) + 1);
  748. //// String[] arr = substring.split("floor");
  749. //// String[] arr2 = arr[1].split("\\.");
  750. //// fYunFileService.uploadFile(bucket, str, String.format(userEditPath, num, arr2[0], arr2[1]));
  751. //// });
  752. //// }
  753. //
  754. // //根据floorplan_cad.json生成houseType.json
  755. // this.uploadHouseTypeJson(num, bucket);
  756. //
  757. // SceneEditInfo sceneEditInfoDb = this.getByScenePlusId(scenePlus.getId());
  758. // SceneEditInfoExt sceneEditInfoExt = null;
  759. // if(Objects.nonNull(sceneEditInfoDb)){
  760. // LambdaUpdateWrapper<SceneEditInfo> updateWrapper = new LambdaUpdateWrapper<SceneEditInfo>()
  761. // .setSql("version=version+" + 1)
  762. // .set(SceneEditInfo::getFloorPlanUser, CommonStatus.NO.code())
  763. // .eq(SceneEditInfo::getId, sceneEditInfoDb.getId());
  764. // this.update(updateWrapper);
  765. //
  766. // sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfoDb.getId());
  767. // }else{
  768. // sceneEditInfoDb = new SceneEditInfo();
  769. // sceneEditInfoDb.setScenePlusId(scenePlus.getId());
  770. // sceneEditInfoDb.setFloorPlanUser(CommonStatus.NO.code());
  771. // this.save(sceneEditInfoDb);
  772. // }
  773. // if(Objects.isNull(sceneEditInfoExt)){
  774. // sceneEditInfoExt = new SceneEditInfoExt();
  775. // sceneEditInfoDb.setScenePlusId(scenePlus.getId());
  776. // sceneEditInfoExt.setEditInfoId(sceneEditInfoDb.getId());
  777. // }
  778. // sceneEditInfoExt.setFloorPlanAngle(0f);
  779. // sceneEditInfoExt.setFloorPlanCompass(0f);
  780. // sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
  781. //
  782. // return ResultData.ok();
  783. //
  784. // }
  785. //
  786. // private void uploadHouseTypeJson(String num, String bucket) throws IOException {
  787. //
  788. // JSONObject result = new JSONObject();
  789. // result.put("name", "houseType.json");
  790. // result.put("version", "2.1");
  791. //
  792. // String floorplanCadPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan_cad.json";
  793. // if(!fYunFileService.fileExist(bucket, floorplanCadPath)){
  794. // log.warn("生成houseType.json失败,原因:floorplan_cad.json文件不存在,num:{}", num);
  795. // return;
  796. // }
  797. // String floorcadStr = fYunFileService.getFileContent(bucket, floorplanCadPath);
  798. //
  799. // JSONObject floorcadObj = JSON.parseObject(floorcadStr);
  800. // JSONArray floors = floorcadObj.getJSONArray("floors");
  801. //
  802. // JSONArray targetFloors = new JSONArray();
  803. // result.put("floors", targetFloors);
  804. // for(int i = 0; i < floors.size(); i++){
  805. // JSONObject floor = (JSONObject)floors.get(i);
  806. // JSONArray[] pointsAndWalls = this.createHouseTypeJsonHandler(floor);
  807. // JSONArray points = pointsAndWalls[0];
  808. // JSONArray walls = pointsAndWalls[1];
  809. // JSONObject targetFloor = new JSONObject();
  810. // targetFloor.put("points", points);
  811. // targetFloor.put("walls", walls);
  812. // targetFloors.add(targetFloor);
  813. // }
  814. //
  815. // String hourseTypeJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "houseType.json";
  816. // fYunFileService.uploadFile(bucket, result.toJSONString().getBytes(), hourseTypeJsonPath);
  817. // }
  818. //
  819. // private JSONArray[] createHouseTypeJsonHandler(JSONObject floor){
  820. //
  821. // JSONArray[] result = new JSONArray[2];
  822. //
  823. // //处理点
  824. // Map<Integer, VertexBean> vertexMap = new HashMap<>();
  825. // Map<String, PointBean> pointMap = new HashMap<>();
  826. // Map<Integer, String> vpMap = new HashMap<>();
  827. // JSONArray vertexArr = floor.getJSONArray("vertex-xy");
  828. // for(int i = 0; i < vertexArr.size(); i++){
  829. // Object o = vertexArr.get(i);
  830. //
  831. // VertexBean vertexBean = JSON.parseObject(JSON.toJSONString(o), VertexBean.class);
  832. // Integer vertexId = vertexBean.getId();
  833. // vertexMap.put(vertexId, vertexBean);
  834. //
  835. // String pointId = "Point" + i;
  836. // pointMap.put(pointId, PointBean.builder().vectorId(pointId).x(vertexBean.getX()).y(vertexBean.getY()).build());
  837. //
  838. // vpMap.put(vertexId, pointId);
  839. // }
  840. //
  841. // //处理墙
  842. // Map<Integer, SegmentBean> segmentMap = new HashMap<>();
  843. // Map<String, WallBean> wallMap = new HashMap<>();
  844. // Map<Integer, String> swMap = new HashMap<>();
  845. // JSONArray segmentArr = floor.getJSONArray("segment");
  846. // Map<String, String> startMap = new HashMap<>();
  847. // Map<String, String> endMap = new HashMap<>();
  848. // for(int i = 0; i < segmentArr.size(); i++){
  849. // Object o = segmentArr.get(i);
  850. //
  851. // SegmentBean segmentBean = JSON.parseObject(JSON.toJSONString(o), SegmentBean.class);
  852. // String startPointId = vpMap.get(segmentBean.getA());
  853. // String endPointId = vpMap.get(segmentBean.getB());
  854. // segmentBean.setStartPointId(startPointId);
  855. // segmentBean.setEndPointId(endPointId);
  856. //
  857. // Integer segmentId = segmentBean.getId();
  858. // segmentMap.put(segmentId, segmentBean);
  859. //
  860. // String wallId = "Wall" + i;
  861. // WallBean wallBean = WallBean.builder()
  862. // .vectorId(wallId)
  863. // .start(segmentBean.getStartPointId())
  864. // .end(segmentBean.getEndPointId())
  865. // .children(new String[]{})
  866. // .width(0.2d)
  867. // .build();
  868. // wallMap.put(wallId, wallBean);
  869. //
  870. // startMap.put(wallBean.getStart(), wallBean.getVectorId());
  871. // endMap.put(wallBean.getEnd(), wallBean.getVectorId());
  872. //
  873. // swMap.put(segmentId, wallId);
  874. // }
  875. //
  876. // Collection<PointBean> pointBeans = pointMap.values();
  877. // for (PointBean pointBean : pointBeans) {
  878. // Map<String, String> parent = new HashMap<>();
  879. // String startParent = startMap.get(pointBean.getVectorId());
  880. // String endParent = endMap.get(pointBean.getVectorId());
  881. // parent.put(startParent, "start");
  882. // parent.put(endParent, "end");
  883. // pointBean.setParent(parent);
  884. // }
  885. // JSONArray pointArr = JSON.parseArray(JSON.toJSONString(pointBeans));
  886. // result[0] = pointArr;
  887. //
  888. // Collection<WallBean> wallBeans = wallMap.values();
  889. // JSONArray wallArr = JSON.parseArray(JSON.toJSONString(wallBeans));
  890. // result[1] = wallArr;
  891. //
  892. // return result;
  893. //
  894. // }
  895. //
  896. // @Override
  897. // public ResultData renameCad(RenameCadParamVO param) throws IOException {
  898. //
  899. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  900. // if(Objects.isNull(scenePlus)){
  901. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  902. // }
  903. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  904. // String bucket = scenePlusExt.getYunFileBucket();
  905. //
  906. // String key = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + "floorplan.json";
  907. // String floorplanJson = fYunFileService.getFileContent(bucket, key);
  908. // if(StrUtil.isEmpty(floorplanJson)){
  909. // return ResultData.ok();
  910. // }
  911. // Map<Integer, String> renameMap = new HashMap<>();
  912. // param.getFloors().stream().forEach(floor->{
  913. // renameMap.put(floor.getSubgroup(), floor.getName());
  914. // });
  915. // JSONObject jsonObject = JSON.parseObject(floorplanJson);
  916. // if(Objects.isNull(jsonObject)){
  917. // return ResultData.ok();
  918. // }
  919. // JSONArray floorArr = jsonObject.getJSONArray("floors");
  920. // if(CollUtil.isEmpty(floorArr)){
  921. // return ResultData.ok();
  922. // }
  923. // for (Object o : floorArr) {
  924. // JSONObject item = (JSONObject)o;
  925. // int subgroup = item.getIntValue("subgroup");
  926. // String name = renameMap.get(subgroup);
  927. // if(StrUtil.isEmpty(name)){
  928. // continue;
  929. // }
  930. // item.put("name", name);
  931. // }
  932. // fYunFileService.uploadFile(bucket, jsonObject.toJSONString().getBytes(), key);
  933. // return ResultData.ok();
  934. // }
  935. //
  936. // private JSONObject updateFloorName(String sourceFloors, String targeFloors){
  937. // JSONArray sourceFloorsJson = JSON.parseArray(sourceFloors);
  938. // JSONObject targeFloorsJson = JSONObject.parseObject(targeFloors);
  939. // JSONArray array = targeFloorsJson.getJSONArray("floors");
  940. // for (int i = 0; i < array.size(); ++i) {
  941. // JSONObject targetFloor = array.getJSONObject(i);
  942. // int targetId = targetFloor.getIntValue("id");
  943. // for (int j = 0; j < sourceFloorsJson.size(); ++j) {
  944. // JSONObject floor = sourceFloorsJson.getJSONObject(j);
  945. // int id = floor.getIntValue("id");
  946. // String name = floor.getString("name");
  947. // if (targetId != id)
  948. // continue;
  949. //
  950. // targetFloor.put("name", name);
  951. // }
  952. // }
  953. // return targeFloorsJson;
  954. // }
  955. //
  956. // @Override
  957. // public void upgradeVersionById(Long id) {
  958. // this.update(new LambdaUpdateWrapper<SceneEditInfo>()
  959. // .setSql("version=version+" + 1)
  960. // .eq(SceneEditInfo::getId, id));
  961. // }
  962. //
  963. // @Override
  964. // public void upgradeVersionAndImgVersionById(Long id) {
  965. // this.update(new LambdaUpdateWrapper<SceneEditInfo>()
  966. // .setSql("version=version + " + 1)
  967. // .setSql("img_version=img_version + " + 1)
  968. // .eq(SceneEditInfo::getId, id));
  969. // }
  970. //
  971. // @Override
  972. // public void upgradeSceneJsonVersion(String num, int version, Integer imgVersion, String bucket) throws IOException {
  973. //
  974. // //更新redis缓存版本号
  975. // String key = String.format(RedisKey.SCENE_JSON, num);
  976. // String sceneJson = redisUtil.get(key);
  977. // if(StrUtil.isNotEmpty(sceneJson)){
  978. // SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
  979. // if(Objects.nonNull(version)){
  980. // sceneJsonBean.setVersion(version);
  981. // }
  982. // if(Objects.nonNull(imgVersion)){
  983. // sceneJsonBean.setImgVersion(imgVersion);
  984. // }
  985. // redisUtil.set(key, JSON.toJSONString(sceneJsonBean));
  986. // }
  987. //
  988. // //更新oss scene.json版本号
  989. // String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
  990. // sceneJson= fYunFileService.getFileContent(bucket, sceneJsonPath);
  991. // if(StrUtil.isNotEmpty(sceneJson)){
  992. // SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
  993. // if(Objects.nonNull(version)){
  994. // sceneJsonBean.setVersion(version);
  995. // }
  996. // if(Objects.nonNull(imgVersion)){
  997. // sceneJsonBean.setImgVersion(imgVersion);
  998. // }
  999. // fYunFileService.uploadFile(bucket, JSON.toJSONString(sceneJsonBean).getBytes(StandardCharsets.UTF_8), sceneJsonPath);
  1000. // }
  1001. //
  1002. // }
  1003. //
  1004. // @Override
  1005. // public ResultData uploadPanorama(String num, MultipartFile file) throws Exception {
  1006. //
  1007. // if(!file.getOriginalFilename().endsWith(".zip") && !file.getOriginalFilename().endsWith(".jpg")){
  1008. // throw new BusinessException(ErrorCode.FAILURE_CODE_7007, "jpg或者zip");
  1009. // }
  1010. //
  1011. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  1012. // if(scenePlus == null){
  1013. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1014. // }
  1015. //
  1016. // //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
  1017. // sceneAsynOperLogService.checkSceneAsynOper(num, null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
  1018. //
  1019. // //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
  1020. // sceneAsynOperLogService.cleanLog(num, SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code());
  1021. //
  1022. //
  1023. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  1024. // String bucket = scenePlusExt.getYunFileBucket();
  1025. //
  1026. // //原始计算根目录
  1027. //// String path = "F:\\test";
  1028. // String path = scenePlusExt.getDataSource();
  1029. // //全景图计算根目录
  1030. // String target = path + "_images";
  1031. // //解压缩文件存放目录
  1032. // String targetImagesPath = target + "/extras/images/";
  1033. // //压缩文件保存目录
  1034. // String zipTargetFilePath = targetImagesPath + file.getOriginalFilename();
  1035. //
  1036. // //判断全景图缓存是否存在,如果不存在,从计算目录中拷贝到缓存目录
  1037. //// this.cachePanorama(path, num);
  1038. //
  1039. // //先删除本地文件
  1040. // FileUtils.deleteDirectory(targetImagesPath);
  1041. // File targetFile = new File(zipTargetFilePath);
  1042. // if(!targetFile.getParentFile().exists()){
  1043. // targetFile.getParentFile().mkdirs();
  1044. // }
  1045. // file.transferTo(targetFile);
  1046. //
  1047. // //如果是压缩包上传,需要解压缩
  1048. // int async = CommonStatus.NO.code();
  1049. // if(file.getOriginalFilename().endsWith(".zip")){
  1050. //
  1051. // //标记为异步处理
  1052. // async = CommonStatus.YES.code();
  1053. //
  1054. // //解压zip包
  1055. // cn.hutool.core.util.ZipUtil.unzip(zipTargetFilePath,targetImagesPath, CharsetUtil.CHARSET_GBK);
  1056. // //删除压缩包
  1057. // FileUtils.delFile(zipTargetFilePath);
  1058. // }
  1059. //
  1060. // //判断文件夹目录结构,图片必须放在压缩包根目录下,不支持空文件夹或其他格式文件上传
  1061. // File[] files = new File(targetImagesPath).listFiles();
  1062. // Arrays.stream(files).forEach(item->{
  1063. // if(item.isDirectory()){
  1064. // throw new BusinessException(ErrorCode.FAILURE_CODE_7018);
  1065. // }
  1066. // });
  1067. //
  1068. // //获取解压后的文件列表
  1069. // List<String> uploadFileList = FileUtils.getFileList(targetImagesPath);
  1070. // if(CollUtil.isEmpty(uploadFileList)){
  1071. // throw new BusinessException(ErrorCode.FAILURE_CODE_5062);
  1072. // }
  1073. //
  1074. // //判断是否有可用的jpg文件
  1075. // boolean existJpg = false;
  1076. // if(CollUtil.isNotEmpty(uploadFileList)){
  1077. // existJpg = uploadFileList.stream().anyMatch(str -> {
  1078. // if(str.endsWith(".jpg")){
  1079. // return true;
  1080. // }
  1081. // return false;
  1082. // });
  1083. // }
  1084. // if(!existJpg){
  1085. // throw new BusinessException(ErrorCode.FAILURE_CODE_5062);
  1086. // }
  1087. //
  1088. // //比对图片列表,不存在的要返回名称集合
  1089. // String ossVisionPath = String.format(UploadFilePath.IMG_VIEW_PATH, num) + "vision.txt";
  1090. // String visionPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "vision.txt";
  1091. // fYunFileService.downloadFile(ossVisionPath, visionPath);
  1092. // List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
  1093. // List<String> notExistFileList = uploadFileList.stream().filter(filePath -> {
  1094. // filePath = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
  1095. // if(CollUtil.isEmpty(panoramaImageList) || panoramaImageList.contains(filePath)){
  1096. // return false;
  1097. // }
  1098. // return true;
  1099. // }).collect(Collectors.toList());
  1100. //
  1101. // if(CollUtil.isNotEmpty(notExistFileList)){
  1102. // //删除错误文件
  1103. // notExistFileList.parallelStream().forEach(filePath->{
  1104. // FileUtils.deleteFile(filePath);
  1105. // });
  1106. // }
  1107. //
  1108. // //判断成功的图片,如果成功图片为0,就直接返回,不需要执行算法
  1109. // uploadFileList = FileUtils.getFileList(targetImagesPath);
  1110. // if(CollUtil.isEmpty(uploadFileList)){
  1111. // if(CollUtil.isNotEmpty(notExistFileList)){
  1112. // notExistFileList = notExistFileList.stream().map(filePath -> {
  1113. // return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
  1114. // }).collect(Collectors.toList());
  1115. // }
  1116. // return ResultData.ok(new UploadPanoramaVO(0,0, notExistFileList));
  1117. // }
  1118. //
  1119. // //上传
  1120. // Map<String, String> map = new HashMap<>();
  1121. //
  1122. // String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
  1123. // fYunFileService.downloadFile(bucket, imgViewPath + "vision.modeldata", target + File.separator + "extras" + File.separator + "vision.modeldata");
  1124. // CreateObjUtil.convertVisionmodeldataToTxt(target + File.separator + "extras" + File.separator + "vision.modeldata",
  1125. // target + File.separator + "extras" + File.separator + "vision.txt");
  1126. //
  1127. // String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
  1128. // fYunFileService.downloadFile(bucket, ossResultPath + "data.json", target + File.separator+"data.json");
  1129. // fYunFileService.downloadFile(bucket, ossResultPath + "project.json", target + File.separator+"project.json");
  1130. //
  1131. // //data.json增加extras为执行重建算法
  1132. // String data = FileUtils.readFile(target + File.separator+"data.json");
  1133. // if(data != null){
  1134. // JSONObject floorplanJson = new JSONObject();
  1135. // floorplanJson.put("has_source_images", true);
  1136. // floorplanJson.put("has_vision_txt", true);
  1137. //
  1138. // JSONObject dataJson = JSONObject.parseObject(data);
  1139. // dataJson.put("extras", floorplanJson);
  1140. // dataJson.put("split_type", "SPLIT_V8");
  1141. // //V5表示不需要生成high,low文件
  1142. // String skyboxType = "SKYBOX_V6";
  1143. // if(scenePlusExt.getSceneScheme() == 11){
  1144. // skyboxType = "SKYBOX_V7";
  1145. // }
  1146. // //sceneScheme为3切成瓦片图
  1147. // if(scenePlusExt.getSceneScheme() == 3){
  1148. // if("4k".equals(scenePlusExt.getSceneResolution())){
  1149. // skyboxType = "SKYBOX_V14";
  1150. // }else{
  1151. // skyboxType = "SKYBOX_V13";
  1152. // }
  1153. // }
  1154. // dataJson.put("skybox_type", skyboxType);
  1155. // FileUtils.writeFile(target + File.separator+"data.json", new String(dataJson.toString().getBytes(), "UTF-8"));
  1156. // }
  1157. // if(new File(target + File.separator + "capture").exists()){
  1158. // new File(target + File.separator + "capture").delete();
  1159. // }
  1160. // if(new File(target + File.separator + "results").exists()){
  1161. // FileUtils.delAllFile(target + File.separator + "results");
  1162. // }
  1163. //
  1164. // fYunFileService.downloadFile(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", target + File.separator + "capture/data.fdage");
  1165. //
  1166. // //如果部分成功,则需要返回成功数量和失败列表
  1167. // if(CollUtil.isNotEmpty(notExistFileList)){
  1168. // notExistFileList = notExistFileList.stream().map(filePath -> {
  1169. // return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
  1170. // }).collect(Collectors.toList());
  1171. // }
  1172. //
  1173. // UploadPanoramaVO uploadPanoramaVO = new UploadPanoramaVO();
  1174. // uploadPanoramaVO.setAsyn(async);
  1175. // if(async == CommonStatus.YES.code().intValue()){
  1176. // List<String> finalUploadFileList = uploadFileList;
  1177. // List<String> finalNotExistFileList = notExistFileList;
  1178. // CompletableFuture.runAsync(() -> {
  1179. // SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
  1180. // sceneAsynOperLog.setNum(num);
  1181. // sceneAsynOperLog.setOperType(SceneAsynOperType.UPLOAD.code());
  1182. // sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
  1183. // sceneAsynOperLog.setFunc(SceneAsynFuncType.PANORAMIC_IMAGE.code());
  1184. // if(CollUtil.isNotEmpty(finalNotExistFileList)){
  1185. // Map<String, Object> extData = new HashMap<>();
  1186. // extData.put("successCnt", finalUploadFileList.size());
  1187. // extData.put("failList", finalNotExistFileList);
  1188. // sceneAsynOperLog.setExtData(JSON.toJSONString(extData));
  1189. // }
  1190. // sceneAsynOperLogService.save(sceneAsynOperLog);
  1191. // try {
  1192. // this.uploadPanoramaHandler(num,bucket,target,imgViewPath, finalUploadFileList,targetImagesPath);
  1193. // sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
  1194. // } catch (Exception e) {
  1195. // log.error("上传全景图报错,num:" + num, e);
  1196. // sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
  1197. // }
  1198. // sceneAsynOperLogService.updateById(sceneAsynOperLog);
  1199. // });
  1200. // }else{
  1201. // this.uploadPanoramaHandler(num,bucket,target,imgViewPath,uploadFileList,targetImagesPath);
  1202. // if(CollUtil.isNotEmpty(notExistFileList)){
  1203. // uploadPanoramaVO.setSuccessCnt(uploadFileList.size());
  1204. // uploadPanoramaVO.setFailList(notExistFileList);
  1205. // }
  1206. // }
  1207. // return ResultData.ok(uploadPanoramaVO);
  1208. // }
  1209. //
  1210. // public void uploadPanoramaHandler(String num, String bucket, String target, String imgViewPath, List<String> uploadFileList, String targetImagesPath) throws Exception {
  1211. // CreateObjUtil.build3dModel(target , "1");
  1212. //
  1213. // String uploadJsonPath= target + File.separator + "results" +File.separator+"upload.json";
  1214. // Thread.sleep(2000);
  1215. // boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, maxCheckTimes, waitTime);
  1216. // if(!exist){
  1217. // throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
  1218. // }
  1219. // String uploadData = FileUtils.readFile(uploadJsonPath);
  1220. // JSONObject uploadJson = null;
  1221. // JSONArray array = null;
  1222. // if(uploadData!=null) {
  1223. // uploadJson = JSONObject.parseObject(uploadData);
  1224. // array = uploadJson.getJSONArray("upload");
  1225. // }
  1226. // if(array == null){
  1227. // throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
  1228. // }
  1229. // Map<String, String> map = new HashMap<>();
  1230. // JSONObject fileJson = null;
  1231. // String fileName = "";
  1232. // for(int i = 0, len = array.size(); i < len; i++) {
  1233. // fileJson = array.getJSONObject(i);
  1234. // fileName = fileJson.getString("file");
  1235. // //文件不存在抛出异常
  1236. // if (!new File(target + File.separator + "results" + File.separator + fileName)
  1237. // .exists()) {
  1238. // throw new Exception(
  1239. // target + File.separator + "results" + File.separator + fileName + "文件不存在");
  1240. // }
  1241. //
  1242. // //high文件夹
  1243. // if (fileJson.getIntValue("clazz") == 3) {
  1244. // map.put(target + File.separator + "results" + File.separator + fileName,
  1245. // imgViewPath + "pan/high/" + fileName.replace("high/", ""));
  1246. // continue;
  1247. // }
  1248. // //low文件夹
  1249. // if (fileJson.getIntValue("clazz") == 4) {
  1250. // map.put(target + File.separator + "results" + File.separator + fileName,
  1251. // imgViewPath + "pan/low/" + fileName.replace("low/", ""));
  1252. // continue;
  1253. // }
  1254. //
  1255. // //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
  1256. // if (fileJson.getIntValue("clazz") == 5) {
  1257. // map.put(target + File.separator + "results" + File.separator + fileName,
  1258. // imgViewPath + fileName);
  1259. // continue;
  1260. // }
  1261. //
  1262. // //tiles文件夹,亚马逊瓦片图
  1263. // if (fileJson.getIntValue("clazz") == 7) {
  1264. // map.put(target + File.separator + "results" + File.separator + fileName,
  1265. // imgViewPath + fileName);
  1266. // continue;
  1267. // }
  1268. // }
  1269. //
  1270. // //用户上传的全景图上传到ossresult目录
  1271. // String ossCachesImagesPath = String.format(UploadFilePath.scene_result_data_path, num) + "caches/images/";
  1272. // uploadFileList.stream().forEach(srcPath->{
  1273. // map.put(srcPath, srcPath.replace(targetImagesPath, ossCachesImagesPath));
  1274. // });
  1275. //
  1276. // if(map.size()>0) {
  1277. // fYunFileService.uploadMulFiles(bucket, map);
  1278. // }
  1279. //
  1280. // //更新数据库版本号
  1281. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  1282. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  1283. // this.upgradeVersionAndImgVersionById(sceneEditInfo.getId());
  1284. // //更新scenejson缓存和oss文件版本号
  1285. // this.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1, bucket);
  1286. // }
  1287. //
  1288. //
  1289. //
  1290. // @Override
  1291. // public ResultData downloadPanorama(FileParamVO param) throws Exception {
  1292. //
  1293. // String num = param.getNum();
  1294. // String fileName = param.getFileName();
  1295. //
  1296. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  1297. // if(Objects.isNull(scenePlus)){
  1298. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1299. // }
  1300. //
  1301. // //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
  1302. // sceneAsynOperLogService.checkSceneAsynOper(num,null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
  1303. //
  1304. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  1305. // String bucket = scenePlusExt.getYunFileBucket();
  1306. // String path = scenePlusExt.getDataSource();
  1307. //
  1308. // String cachePath = String.format(ConstantFilePath.SCENE_CACHE, num);
  1309. // String imgCachePath = String.format(UploadFilePath.IMG_CACHES_PATH, num);
  1310. // String localImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
  1311. //
  1312. // String cacheFormat = "downloads/scene/%s/caches/";
  1313. // String cacheImageFormat = "downloads/scene/%s/caches/images/";
  1314. //
  1315. // //判断全景图缓存是否存在,如果不存在,从计算目录中拷贝到缓存目录
  1316. //// this.cachePanorama(scenePlusExt.getDataSource(), num);
  1317. //
  1318. // //根据vision.txt获取到有效的全景图名称
  1319. // String ossVisionPath = String.format(UploadFilePath.IMG_VIEW_PATH, num) + "vision.txt";
  1320. // String visionPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "vision.txt";
  1321. // fYunFileService.downloadFile(ossVisionPath, visionPath);
  1322. // List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
  1323. // if(CollUtil.isEmpty(panoramaImageList)){
  1324. // throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
  1325. // }
  1326. //
  1327. // Map<String, Object> map = new HashMap<>();
  1328. //
  1329. // //标记是否是异步操作,默认是同步操作
  1330. // //如果入参文件名不为空,则是单个文件下载,不需要打包
  1331. // String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num) + "caches/images/";
  1332. // if(StrUtil.isNotEmpty(fileName)){
  1333. // //如果是单张图片,直接提供oss url
  1334. //// if(!fYunFileService.fileExist(bucket, ossResultPath + fileName)){
  1335. //// throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
  1336. //// }
  1337. // if(!panoramaImageList.contains(fileName)){
  1338. // throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
  1339. // }
  1340. // String url = ossResultPath + fileName;
  1341. // String downloadName = fileName;
  1342. // map.put("asyn", CommonStatus.NO.code());
  1343. // map.put("fileUrl", url + "?t=" + System.currentTimeMillis());
  1344. // map.put("fileName", downloadName);
  1345. // return ResultData.ok(map);
  1346. // }else{
  1347. // //清除旧的下载记录
  1348. // sceneAsynOperLogService.cleanLog(num, SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code(), SceneAsynOperType.DOWNLOAD.code());
  1349. //
  1350. // //开始异步执行下载全景图压缩包操作
  1351. // CompletableFuture.runAsync(() -> {
  1352. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  1353. // SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
  1354. // sceneAsynOperLog.setNum(num);
  1355. // sceneAsynOperLog.setOperType(SceneAsynOperType.DOWNLOAD.code());
  1356. // sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
  1357. // sceneAsynOperLog.setFunc(SceneAsynFuncType.PANORAMIC_IMAGE.code());
  1358. // sceneAsynOperLog.setVersion(sceneEditInfo.getImgVersion());
  1359. // sceneAsynOperLogService.save(sceneAsynOperLog);
  1360. // try {
  1361. //
  1362. // //下载到本地目录
  1363. // FileUtil.del(localImagesPath);
  1364. // fYunFileService.downloadFileByCommand(bucket, localImagesPath, ossResultPath);
  1365. // //移除非必须文件
  1366. // List<String> fileNames = FileUtil.listFileNames(localImagesPath);
  1367. // fileNames.stream().forEach(name->{
  1368. // if(!panoramaImageList.contains(name)){
  1369. // FileUtil.del(localImagesPath + name);
  1370. // }
  1371. // });
  1372. //
  1373. // String downloadName = num + "_images.zip";
  1374. // long start = Calendar.getInstance().getTimeInMillis();
  1375. // //打包
  1376. // String zipPath = cachePath + downloadName;
  1377. // ZipUtil.zip(localImagesPath, zipPath);
  1378. // long end1 = Calendar.getInstance().getTimeInMillis();
  1379. // log.info("打包耗时:" + (end1 - start));
  1380. // //上传压缩包
  1381. // fYunFileService.uploadFileByCommand(bucket, zipPath, String.format(cacheFormat, num) + downloadName);
  1382. // String url = String.format(cacheFormat, num) + downloadName;
  1383. // long end2 = Calendar.getInstance().getTimeInMillis();
  1384. // log.info("上传耗时:" + (end2 - end1));
  1385. // //删除本地压缩包
  1386. // FileUtils.deleteFile(zipPath);
  1387. // //删除本地目录
  1388. // FileUtils.deleteDirectory(localImagesPath);
  1389. // sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
  1390. // sceneAsynOperLog.setUrl(url);
  1391. // }catch (Exception e){
  1392. // sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
  1393. // log.error("下载全景图压缩包失败,num:" + num, e);
  1394. // }
  1395. // sceneAsynOperLogService.saveOrUpdate(sceneAsynOperLog);
  1396. // });
  1397. //
  1398. // map.put("asyn", CommonStatus.YES.code());
  1399. // return ResultData.ok(map);
  1400. // }
  1401. // }
  1402. //
  1403. // private void cachePanorama(String dataSource, String num){
  1404. // String cachedImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
  1405. // if(FileUtil.exist(cachedImagesPath) && CollUtil.isNotEmpty(FileUtil.listFileNames(cachedImagesPath))){
  1406. // return;
  1407. // }
  1408. // //将全景图缓存到缓存目录
  1409. // List<String> imagesList = FileUtil.listFileNames(dataSource + "/caches/images");
  1410. // //先清除旧的全景图
  1411. // cn.hutool.core.io.FileUtil.del(cachedImagesPath);
  1412. // String visionPath = dataSource + "/results/vision.txt";
  1413. // List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
  1414. // imagesList.stream().forEach(fileName -> {
  1415. // if (panoramaImageList.contains(fileName)) {
  1416. // String srcPath = dataSource + "/caches/images/" + fileName;
  1417. // String targetPath = cachedImagesPath + fileName;
  1418. // log.info("源文件:{}, 目标文件:{}", srcPath, targetPath);
  1419. // cn.hutool.core.io.FileUtil.copy(srcPath, targetPath, true);
  1420. // }
  1421. // });
  1422. // }
  1423. @Override
  1424. public void saveTagsToSceneEditInfo(String num, SceneEditInfo sceneEditInfo){
  1425. //查询缓存是否包含热点数据
  1426. String key = String.format(RedisKey.SCENE_HOT_DATA, num);
  1427. Map<String, String> allTagsMap = redisClient.hmget(key);
  1428. boolean hashTags = false;
  1429. for (Map.Entry<String, String> tagMap : allTagsMap.entrySet()) {
  1430. if(StrUtil.isEmpty(tagMap.getValue())){
  1431. continue;
  1432. }
  1433. hashTags = true;
  1434. break;
  1435. }
  1436. //更改热点状态
  1437. sceneEditInfo.setTags(hashTags ? CommonStatus.YES.code() : CommonStatus.NO.code());
  1438. //version 是空的代表 sceneEditInfo记录集不存在
  1439. if(sceneEditInfo.getVersion() != null){
  1440. sceneEditInfo.setVersion(sceneEditInfo.getVersion() + 1);
  1441. }
  1442. }
  1443. //
  1444. // @Override
  1445. // public ResultData saveVideoBox(FileNameAndDataParamVO param) throws Exception {
  1446. //
  1447. // JSONObject boxVideo = JSONObject.parseObject(param.getData());
  1448. // String sid = boxVideo.getString("sid");
  1449. // if(StrUtil.isEmpty(sid)){
  1450. // throw new BusinessException(ErrorCode.PARAM_REQUIRED);
  1451. // }
  1452. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  1453. // if(Objects.isNull(scenePlus))
  1454. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1455. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  1456. // String bucket = scenePlusExt.getYunFileBucket();
  1457. //
  1458. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  1459. //
  1460. // //转换视频格式
  1461. // commonService.transferToFlv(param.getNum(), param.getFileName(), bucket);
  1462. //
  1463. // //生成boxVideos数据
  1464. // String boxVideos = this.createBoxVideos(param.getNum(), sid, boxVideo, sceneEditInfo, OperationType.ADDORUPDATE.code());
  1465. //
  1466. // //更新数据库
  1467. // this.updateBoxVideos(sceneEditInfo, scenePlus.getId(), boxVideos);
  1468. //
  1469. // return ResultData.ok();
  1470. // }
  1471. //
  1472. // @Override
  1473. // public ResultData deleteVideoBox(DeleteSidParamVO param) throws Exception {
  1474. //
  1475. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  1476. // if(Objects.isNull(scenePlus))
  1477. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1478. //
  1479. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  1480. //
  1481. // //根据sid移除json
  1482. // String boxVideos = this.createBoxVideos(param.getNum(), param.getSid(), null, sceneEditInfo, OperationType.DELETE.code());
  1483. //
  1484. // //写数据库
  1485. // this.updateBoxVideos(sceneEditInfo,scenePlus.getId(),boxVideos);
  1486. //
  1487. // return ResultData.ok();
  1488. // }
  1489. //
  1490. // @Override
  1491. // public ResultData saveBoxPhoto(BaseDataParamVO param) throws Exception {
  1492. //
  1493. // JSONObject boxPhoto = JSONObject.parseObject(param.getData());
  1494. // String sid = boxPhoto.getString("sid");
  1495. // if(StrUtil.isEmpty(sid)){
  1496. // throw new BusinessException(ServerCode.PARAM_REQUIRED, sid);
  1497. // }
  1498. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  1499. // if(Objects.isNull(scenePlus))
  1500. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1501. //
  1502. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  1503. //
  1504. // //生成boxVideos数据
  1505. // String boxPhotos = this.createBoxPhotos(param.getNum(), sid, boxPhoto, sceneEditInfo, OperationType.ADDORUPDATE.code());
  1506. //
  1507. // //更新数据库
  1508. // this.updateBoxPhotos(sceneEditInfo, boxPhotos);
  1509. //
  1510. // return ResultData.ok();
  1511. // }
  1512. //
  1513. // @Override
  1514. // public ResultData deleteBoxPhoto(DeleteSidParamVO param) throws Exception {
  1515. //
  1516. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  1517. // if(Objects.isNull(scenePlus))
  1518. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1519. //
  1520. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  1521. //
  1522. // //根据sid移除json
  1523. // String boxPhotos = this.createBoxPhotos(param.getNum(), param.getSid(), null, sceneEditInfo, OperationType.DELETE.code());
  1524. //
  1525. // //写数据库
  1526. // this.updateBoxPhotos(sceneEditInfo, boxPhotos);
  1527. //
  1528. // return ResultData.ok();
  1529. // }
  1530. //
  1531. // @Override
  1532. // public DownloadVO downloadBallScreenVideo(BallScreenVideoParamVO param) {
  1533. // String videoPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, param.getNum()) + param.getFileName();
  1534. // String url = ossUrlPrefix + videoPath + "?t=" + System.currentTimeMillis();
  1535. // return DownloadVO.builder()
  1536. // .fileName(param.getFileName())
  1537. // .url(url)
  1538. // .build();
  1539. // }
  1540. //
  1541. // @Override
  1542. // public ResultData uploadBallScreenVideo(String num, String fileName, MultipartFile file) throws Exception {
  1543. //
  1544. // //校验格式
  1545. // if(!fileName.endsWith(".mp4")){
  1546. // throw new BusinessException(ErrorCode.FAILURE_CODE_7016);
  1547. // }
  1548. // String videosViewPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, num);
  1549. //
  1550. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  1551. // if(scenePlus == null){
  1552. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1553. // }
  1554. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  1555. // String bucket = scenePlusExt.getYunFileBucket();
  1556. //
  1557. // String path = scenePlusExt.getDataSource();
  1558. // //校验文件名
  1559. // String videos = scenePlusExt.getVideos();
  1560. // if(StrUtil.isEmpty(videos)){
  1561. // throw new BusinessException(ErrorCode.FAILURE_CODE_7012);
  1562. // }
  1563. // JSONObject videosJson = JSON.parseObject(videos);
  1564. // JSONArray dataArr = videosJson.getJSONArray("data");
  1565. // boolean exists = false;
  1566. // for (Object o : dataArr) {
  1567. // JSONObject jsonObject = (JSONObject)o;
  1568. // if(jsonObject.getString("id").equals(fileName.replace(".mp4", ""))){
  1569. // exists = true;
  1570. // break;
  1571. // }
  1572. // }
  1573. // if(!exists){
  1574. // throw new BusinessException(ErrorCode.FAILURE_CODE_7012);
  1575. // }
  1576. //
  1577. // if(path != null && !"".equals(path) && path.startsWith("http")){
  1578. // path = ConstantFilePath.BUILD_MODEL_PATH + File.separator + path.split("/")[path.split("/").length - 2];
  1579. // }
  1580. //
  1581. // String target = path + "_images";
  1582. //
  1583. // String filePath = target + File.separator + "extras/video" + File.separator + fileName;
  1584. //
  1585. // File targetFile = new File(filePath);
  1586. // if(!targetFile.getParentFile().exists()){
  1587. // targetFile.getParentFile().mkdirs();
  1588. // }
  1589. //
  1590. // //保存视频到本地
  1591. // file.transferTo(targetFile);
  1592. //
  1593. // File video = new File(target + File.separator + "extras/video");
  1594. // //如果文件夹或者文件不存在,跳出
  1595. // if(!video.exists() || video.listFiles() == null || video.listFiles().length == 0){
  1596. // throw new BusinessException(ErrorCode.FAILURE_CODE_7009);
  1597. // }
  1598. //
  1599. // for(String videoName : video.list()){
  1600. // log.info("球幕视频名称:{}", videoName);
  1601. // fYunFileService.uploadFile(bucket, target + File.separator + "extras/video/" + videoName,videosViewPath + videoName);
  1602. //
  1603. // CreateObjUtil.mp4ToFlv(target + File.separator + "extras/video/" + videoName,
  1604. // target + File.separator + "extras/video/" + videoName.replace("mp4", "flv"));
  1605. //
  1606. // fYunFileService.uploadFile(bucket, target + File.separator + "extras/video/" + videoName.replace("mp4", "flv"),videosViewPath + videoName.replace("mp4", "flv"));
  1607. //
  1608. // //覆盖原始视频资源
  1609. //// FileUtils.copyFile(target + File.separator + "extras/video/" + videoName,
  1610. //// path + File.separator + "caches/videos/" + videoName, true);
  1611. //
  1612. // }
  1613. // FileUtils.deleteDirectory(target + File.separator + "extras/video/");
  1614. //
  1615. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  1616. // this.upgradeVersionById(sceneEditInfo.getId());
  1617. //
  1618. // //更新scenejson缓存和oss文件版本号
  1619. // this.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, null, bucket);
  1620. //
  1621. // return ResultData.ok();
  1622. // }
  1623. //
  1624. // @Override
  1625. // public void upgradeVersionToSceneJson(String num, String bucket) throws Exception{
  1626. // String key = String.format(RedisKey.SCENE_JSON, num);
  1627. // String objectName = String.format(ConstantFilePath.SCENE_VIEW_DATA_DATA_SCENEJSON, num);
  1628. // String objectContent = fYunFileService.getFileContent(bucket, objectName);
  1629. // SceneJsonBean sceneJsonBean = JSON.parseObject(objectContent, SceneJsonBean.class);
  1630. // sceneJsonBean.setVersion(sceneJsonBean.getVersion() +1);
  1631. // fYunFileService.uploadFile(bucket, JSON.toJSONString(sceneJsonBean).getBytes(), objectName);
  1632. // redisUtil.set(key, JSON.toJSONString(sceneJsonBean));
  1633. // }
  1634. //
  1635. // @Override
  1636. // public ResultData sceneSync(String num, String type, String floorPlanJson, String ajkJson, String cameraJson,
  1637. // MultipartFile[] files) throws Exception {
  1638. //
  1639. // String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
  1640. // String lockKey = String.format(RedisLockKey.LOCK_SCENE_SYNC, num);
  1641. // Boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_2_HOUR);
  1642. // if(!lock){
  1643. // throw new BusinessException(ErrorCode.SYSTEM_BUSY);
  1644. // }
  1645. // try {
  1646. //
  1647. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  1648. // if(scenePlus == null){
  1649. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1650. // }
  1651. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  1652. // String bucket = scenePlusExt.getYunFileBucket();
  1653. //
  1654. // //更新scene.json文件
  1655. // String strsceneInfos = FileUtils.readFile(ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + num + File.separator + "scene.json");
  1656. // if(strsceneInfos == null)
  1657. // new File(ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + num + File.separator + "scene.json").createNewFile();
  1658. //
  1659. // String path = scenePlusExt.getDataSource();// /mnt/data/0662c5389/831989883441512448/4898cab04f8c_202104141602356060/
  1660. // if(path != null && !"".equals(path) && path.startsWith("http")){
  1661. // path = ConstantFilePath.BUILD_MODEL_PATH + File.separator + path.split("/")[path.split("/").length - 2];
  1662. // }
  1663. // String target = path + "_ajk"; // /mnt/data/0662c5389/831989883441512448/4898cab04f8c_202104141602356060_ajk
  1664. // File editPath = new File(target);
  1665. // if(!editPath.exists()){
  1666. // editPath.mkdirs();
  1667. // }
  1668. //
  1669. // //创建文件夹软连接并且复制data.json和project.json
  1670. // if(new File(target + File.separator + "capture").exists()){
  1671. // new File(target + File.separator + "capture").delete();
  1672. // }
  1673. // if(new File(target + File.separator + "caches").exists()){
  1674. // //删除link
  1675. // new File(target + File.separator + "caches" + File.separator + "images").delete();
  1676. // //删除所有文件
  1677. // FileUtils.delAllFile(target + File.separator + "caches");
  1678. // }
  1679. // if(new File(target + File.separator + "results").exists()){
  1680. // FileUtils.delAllFile(target + File.separator + "results");
  1681. // }
  1682. //
  1683. // //创建文件夹,并link文件夹
  1684. // new File(target + File.separator + "caches").mkdirs();
  1685. // fYunFileService.downloadFileByCommand(target + File.separator + "capture", SceneUtil.getHomePath(path));
  1686. //// CreateObjUtil.createSoftConnection(path + File.separator + "capture", target + File.separator + "capture");
  1687. // if(new File(path + File.separator + "caches" + File.separator + "images").exists()){
  1688. // CreateObjUtil.createSoftConnection(path + File.separator + "caches" + File.separator + "images", target + File.separator + "caches" + File.separator + "images");
  1689. // }
  1690. //
  1691. // String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
  1692. // fYunFileService.downloadFile(bucket, ossResultPath + "data.json", target + File.separator+"data.json");
  1693. // fYunFileService.downloadFile(bucket, ossResultPath + "project.json", target + File.separator+"project.json");
  1694. //// FileUtils.copyFile(path + File.separator + "data.json", target + File.separator+"data.json", true);
  1695. //// FileUtils.copyFile(path + File.separator + "project.json", target + File.separator+"project.json", true);
  1696. //
  1697. // //data.json增加extras为执行重建算法
  1698. // String project = FileUtils.readFile(target + File.separator+"project.json");
  1699. // if(project != null){
  1700. // JSONObject projectJson = JSONObject.parseObject(project);
  1701. // projectJson.put("parent", projectJson.get("uuid"));
  1702. // projectJson.put("uuid", UUID.randomUUID().toString());
  1703. // projectJson.put("time", System.currentTimeMillis());
  1704. // FileUtils.writeFile(path + File.separator + "project.json", projectJson.toString());
  1705. // }
  1706. //
  1707. // String data = FileUtils.readFile(target + File.separator+"data.json");
  1708. // if(data != null){
  1709. // JSONObject floorplanJson = new JSONObject();
  1710. // floorplanJson.put("has_floor_ajk_json", true);
  1711. // floorplanJson.put("has_vision_txt", true);
  1712. // floorplanJson.put("has_floorplan_json", true);
  1713. //
  1714. // JSONObject dataJson = JSONObject.parseObject(data);
  1715. // dataJson.put("extras", floorplanJson);
  1716. // //V5表示不需要生成high,low文件
  1717. // dataJson.put("skybox_type", "SKYBOX_V8");
  1718. // dataJson.put("split_type", "SPLIT_V10");
  1719. // FileUtils.writeFile(target + File.separator+"data.json", new String(dataJson.toString().getBytes(), "UTF-8"));
  1720. // }
  1721. //
  1722. // //文件上传的位置可以自定义
  1723. // log.info("画墙重建模型开始");
  1724. // File targetFile = new File(target + File.separator + "extras" + File.separator + "floor_ajk.json");
  1725. // if(!targetFile.getParentFile().exists()){
  1726. // targetFile.getParentFile().mkdirs();
  1727. // }
  1728. // if(targetFile.exists()){
  1729. // FileUtils.deleteFile(target + File.separator + "extras" + File.separator + "floor_ajk.json");
  1730. // }
  1731. // // 保存
  1732. // FileUtils.writeFile(target + File.separator + "extras" + File.separator + "floorplan.json", new String(floorPlanJson.getBytes(), "UTF-8"));
  1733. //
  1734. // FileUtils.writeFile(target + File.separator + "extras" + File.separator + "floor_ajk.json", new String(ajkJson.getBytes(), "UTF-8"));
  1735. // FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+num + File.separator + "floor_ajk.json", new String(ajkJson.getBytes(), "UTF-8"));
  1736. //
  1737. // FileUtils.writeFile(target + File.separator + "extras" + File.separator + "vision.txt", new String(cameraJson.getBytes(), "UTF-8"));
  1738. // FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+num + File.separator + "camera.json", new String(cameraJson.getBytes(), "UTF-8"));
  1739. //
  1740. // for(int i = 0; i < files.length; i ++){
  1741. //
  1742. // File cadImg = new File(target + File.separator + "extras" + File.separator + "Floorplans/" + files[i].getOriginalFilename());
  1743. // if(!cadImg.getParentFile().exists()){
  1744. // cadImg.getParentFile().mkdirs();
  1745. // }
  1746. // if(cadImg.exists())
  1747. // {
  1748. // cadImg.delete();
  1749. // }
  1750. //
  1751. // files[i].transferTo(cadImg);
  1752. // }
  1753. // //下载封面图
  1754. // FileUtils.downLoadFromUrl(scenePlusExt.getThumb() + "?t=" + System.currentTimeMillis(),
  1755. // "Cover.png", target + File.separator + "extras" + File.separator + "CoverImage");
  1756. // //转换成jpg
  1757. // FileUtils.pngToJpg(target + File.separator + "extras" + File.separator + "CoverImage/Cover.png",
  1758. // target + File.separator + "extras" + File.separator + "CoverImage/Cover.jpg");
  1759. //
  1760. // //安居客算法运行
  1761. // log.info("安居客算法:开始建模——"+num);
  1762. // CreateObjUtil.build3dModelOld(target , "1");
  1763. // String uploadJsonPath = target + File.separator + "results" + File.separator + "upload.json";
  1764. // log.info("uploadJsonPath=" + uploadJsonPath);
  1765. // //因为共享目录有延迟,这里循环检测算法是否计算完毕3次,每次隔五秒
  1766. // boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, maxCheckTimes, waitTime);
  1767. // if(!exist){
  1768. // throw new BusinessException(ErrorCode.FAILURE_CODE_7017);
  1769. // }
  1770. //
  1771. // String zipPath = target + File.separator + "results/" + num + ".zip";
  1772. // new File(zipPath).delete();
  1773. // ZipUtil.zip(target + File.separator + "results/ajk/", zipPath);
  1774. //// String command = "bash /opt/ossutil/gzip.sh " + zipPath.replace(".zip", "") + " " + target + File.separator + "results/ajk/";
  1775. //// log.info("压缩文件:" + command);
  1776. //// CreateObjUtil.callshell(command);
  1777. //
  1778. // if(!new File(zipPath).exists()){
  1779. // return ResultData.error(ErrorCode.FAILURE_CODE_5043);
  1780. // }
  1781. // String fileMD5 = FileMd5Util.getFileMD5(new File(zipPath));
  1782. //
  1783. // fYunFileService.uploadFileByCommand(bucket, zipPath, "data_download/" + num + ".zip");
  1784. //
  1785. // SceneDataDownload sceneDataDownload = sceneDataDownloadService.findBySceneNum(num);
  1786. // if(sceneDataDownload == null){
  1787. // sceneDataDownload = new SceneDataDownload();
  1788. // sceneDataDownload.setSceneNum(num);
  1789. // sceneDataDownload.setDownloadPath(ossUrlPrefix + "data_download/" + num + ".zip");
  1790. // sceneDataDownload.setFileMd5(fileMD5);
  1791. // sceneDataDownloadService.save(sceneDataDownload);
  1792. // return ResultData.ok();
  1793. // }
  1794. //
  1795. // sceneDataDownload.setFileMd5(fileMD5);
  1796. // sceneDataDownload.setUpdateTime(Calendar.getInstance().getTime());
  1797. // sceneDataDownloadService.updateById(sceneDataDownload);
  1798. // }catch (Exception e){
  1799. // log.error("画墙重建模型失败...", e);
  1800. // throw new BusinessException(ErrorCode.FAILURE_CODE_5039);
  1801. // }finally {
  1802. // redisLockUtil.unlockLua(lockKey, lockVal);
  1803. // }
  1804. //
  1805. // return ResultData.ok();
  1806. // }
  1807. //
  1808. // @Override
  1809. // public ResultData checkKey(SceneCheckKeyParamVO param) throws Exception {
  1810. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  1811. // if(Objects.isNull(scenePlus)){
  1812. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1813. // }
  1814. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  1815. // String bucket = scenePlusExt.getYunFileBucket();
  1816. // SceneJsonBean sceneJsonBean = null;
  1817. // String sceneJson = redisUtil.get(String.format(RedisKey.SCENE_JSON, param.getNum()));
  1818. // if(StrUtil.isEmpty(sceneJson)){
  1819. // sceneJson = fYunFileService.getFileContent(bucket,
  1820. // String.format(UploadFilePath.DATA_VIEW_PATH, param.getNum()) + "scene.json");
  1821. // }
  1822. // sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
  1823. //
  1824. // if(!param.getPassword().equals(sceneJsonBean.getScenePassword())){
  1825. // throw new BusinessException(ErrorCode.FAILURE_CODE_5021);
  1826. // }
  1827. //
  1828. // return ResultData.ok();
  1829. // }
  1830. //
  1831. // @Override
  1832. // public ResultData addMosaics(BaseDataParamVO param) throws Exception {
  1833. //
  1834. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  1835. // if(Objects.isNull(scenePlus)){
  1836. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1837. // }
  1838. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  1839. //
  1840. // //如果redis数据丢失,从本地文件中同步马赛克数据到redis
  1841. // this.syncMosaicFromFileToRedis(param.getNum());
  1842. //
  1843. // Map<String, String> map = new HashMap<>();
  1844. // JSONArray jsonArray = JSON.parseArray(param.getData());
  1845. // for (Object o : jsonArray) {
  1846. // JSONObject mosaic = (JSONObject) o;
  1847. // String panoId = mosaic.getString("panoId");
  1848. // if(StrUtil.isEmpty(panoId)){
  1849. // throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
  1850. // }
  1851. // map.put(panoId, JSON.toJSONString(mosaic));
  1852. // }
  1853. // String key = String.format(RedisKey.SCENE_MOSAIC_DATA, param.getNum());
  1854. // redisUtil.hmset(key, map);
  1855. //
  1856. // //写入本地文件,作为备份
  1857. // this.writeMosaic(param.getNum());
  1858. //
  1859. // //更新数据库
  1860. // this.updateMosaicFlag(param.getNum());
  1861. //
  1862. // //更新版本号
  1863. // this.upgradeVersionById(sceneEditInfo.getId());
  1864. //
  1865. // return ResultData.ok();
  1866. // }
  1867. //
  1868. // private void updateMosaicFlag(String num){
  1869. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  1870. // SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByScenePlusId(scenePlus.getId());
  1871. //
  1872. // String key = String.format(RedisKey.SCENE_MOSAIC_DATA, num);
  1873. // boolean flag = redisUtil.hasKey(key);
  1874. // if(flag){
  1875. // sceneEditInfoExt.setMosaic(Integer.valueOf(CommonStatus.YES.code()));
  1876. // }else{
  1877. // sceneEditInfoExt.setMosaic(Integer.valueOf(CommonStatus.NO.code()));
  1878. // }
  1879. // sceneEditInfoExtService.updateById(sceneEditInfoExt);
  1880. // }
  1881. //
  1882. // /**
  1883. // * <p>
  1884. // 保证马赛克数据安全性,当redis宕机导致热点数据丢失时,可以从文件中读取,恢复到redis
  1885. // **/
  1886. // private void syncMosaicFromFileToRedis(String num) throws Exception{
  1887. //
  1888. // String key = String.format(RedisKey.SCENE_MOSAIC_DATA, num);
  1889. // boolean exist = redisUtil.hasKey(key);
  1890. // if(exist){
  1891. // return;
  1892. // }
  1893. //// String uuid = cn.hutool.core.lang.UUID.randomUUID().toString();
  1894. // String lockKey = String.format(RedisLockKey.LOCK_MOSAIC_DATA_SYNC, num);
  1895. // boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_1_MINUTE);
  1896. // if(!lock){
  1897. // throw new BusinessException(ErrorCode.SYSTEM_BUSY);
  1898. // }
  1899. // try{
  1900. // exist = redisUtil.hasKey(key);
  1901. // if(exist){
  1902. // return;
  1903. // }
  1904. // String filePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "mosaic.json";
  1905. // String mosaicData = FileUtils.readUtf8String(filePath);
  1906. // if(StrUtil.isEmpty(mosaicData)){
  1907. // return;
  1908. // }
  1909. // JSONArray jsonArray = JSON.parseArray(mosaicData);
  1910. // if(CollUtil.isEmpty(jsonArray)){
  1911. // return;
  1912. // }
  1913. // Map<String, String> map = new HashMap<>();
  1914. // for (Object o : jsonArray) {
  1915. // JSONObject jo = (JSONObject)o;
  1916. // map.put(jo.getString("panoId"), jo.toJSONString());
  1917. // }
  1918. // redisUtil.hmset(key, map);
  1919. // }finally {
  1920. // redisLockUtil.unlockLua(lockKey);
  1921. // }
  1922. // }
  1923. //
  1924. // /**
  1925. // * <p>
  1926. // 保证马赛克数据安全性,当redis宕机导致热点数据丢失时,可以从文件中读取,恢复到redis
  1927. // **/
  1928. // private void writeMosaic(String num) throws Exception{
  1929. //
  1930. // String mosaicPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "mosaic.json";
  1931. //
  1932. // String key = String.format(RedisKey.SCENE_MOSAIC_DATA, num);
  1933. // Map<String, String> mosaicMap = redisUtil.hmget(key);
  1934. // if(CollUtil.isEmpty(mosaicMap)){
  1935. // FileUtils.deleteFile(mosaicPath);
  1936. // return;
  1937. // }
  1938. // List<String> mosaicList = Lists.newArrayList(mosaicMap.values());
  1939. // JSONArray jsonArr = new JSONArray();
  1940. // mosaicList.stream().forEach(mosaic->{
  1941. // jsonArr.add(JSONObject.parseObject(mosaic));
  1942. // });
  1943. //
  1944. // String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
  1945. // String lockKey = String.format(RedisLockKey.LOCK_MOSAIC_JSON, num);
  1946. // boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
  1947. // if(!lock){
  1948. // return;
  1949. // }
  1950. // try{
  1951. // FileUtils.writeFile(mosaicPath, jsonArr.toJSONString());
  1952. // }finally {
  1953. // redisLockUtil.unlockLua(lockKey, lockVal);
  1954. // }
  1955. // }
  1956. //
  1957. // @Override
  1958. // public ResultData uploadLinkPan(String num, String sid, String fileName, MultipartFile file) throws Exception {
  1959. //
  1960. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
  1961. // if(scenePlus == null){
  1962. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  1963. // }
  1964. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  1965. // String bucket = scenePlusExt.getYunFileBucket();
  1966. //
  1967. // String localImagesPath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, num);
  1968. // String path = scenePlusExt.getDataSource();
  1969. // String target = localImagesPath + "panorama/" + sid;
  1970. // FileUtils.deleteDirectory(target);
  1971. //
  1972. // //文件写如本地磁盘
  1973. // String filePath = target + File.separator + "extras/images" + File.separator + fileName;
  1974. // File targetFile = new File(filePath);
  1975. // if(!targetFile.getParentFile().exists()){
  1976. // targetFile.getParentFile().mkdirs();
  1977. // }
  1978. // file.transferTo(targetFile);
  1979. //
  1980. // //调用算法切全景图
  1981. // String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
  1982. // fYunFileService.downloadFile(bucket, ossResultPath + "data.json", target + File.separator+"data.json");
  1983. // fYunFileService.downloadFile(bucket, ossResultPath + "project.json", target + File.separator+"project.json");
  1984. // JSONObject visionJson = new JSONObject();
  1985. // JSONArray visionArray = new JSONArray();
  1986. // visionJson.put("uuid", sid);
  1987. // visionJson.put("group", 1);
  1988. // visionJson.put("subgroup", 0);
  1989. // visionArray.add(visionJson);
  1990. // JSONObject vision = new JSONObject();
  1991. // vision.put("sweepLocations", visionArray);
  1992. // cn.hutool.core.io.FileUtil.writeString(vision.toString(), target + "/extras" + File.separator + "vision.txt", StandardCharsets.UTF_8);
  1993. //
  1994. // //data.json增加extras为执行重建算法
  1995. // String type = "4k";
  1996. // String data = FileUtils.readFile(target + File.separator + "data.json");
  1997. // if(data != null){
  1998. // JSONObject floorplanJson = new JSONObject();
  1999. // floorplanJson.put("has_source_images", true);
  2000. // floorplanJson.put("has_vision_txt", true);
  2001. //
  2002. // JSONObject dataJson = JSONObject.parseObject(data);
  2003. // dataJson.put("extras", floorplanJson);
  2004. // dataJson.put("split_type", "SPLIT_V8");//替换全景图算法
  2005. //
  2006. // String skyboxType = "SKYBOX_V6";//默认4k minion
  2007. // if(SceneFrom.PRO.code().equals(scenePlusExt.getSceneFrom())){
  2008. // skyboxType = "SKYBOX_V7";
  2009. // type = "2k";
  2010. // }
  2011. // if(scenePlusExt.getSceneScheme() == 3){
  2012. // if("4k".equals(scenePlusExt.getSceneResolution())){
  2013. // skyboxType = "SKYBOX_V14";
  2014. // }else{
  2015. // skyboxType = "SKYBOX_V13";
  2016. // }
  2017. // }
  2018. // dataJson.put("skybox_type", skyboxType);
  2019. //
  2020. // cn.hutool.core.io.FileUtil.writeString(dataJson.toString(), target + File.separator+"data.json", StandardCharsets.UTF_8);
  2021. // }
  2022. //
  2023. // //创建文件夹软连接并且复制data.json和project.json
  2024. // String capturePath = target + File.separator + "capture";
  2025. // String resultPath = target + File.separator + "results";
  2026. // log.info("场景关联上传全景图:capturePath={}", capturePath);
  2027. // log.info("场景关联上传全景图:resultPath={}", resultPath);
  2028. // if(cn.hutool.core.io.FileUtil.exist(capturePath)){
  2029. // cn.hutool.core.io.FileUtil.del(capturePath);
  2030. // }
  2031. // if(cn.hutool.core.io.FileUtil.exist(resultPath)){
  2032. // cn.hutool.core.io.FileUtil.del(resultPath);
  2033. // }
  2034. // //下载data.fdage
  2035. // fYunFileService.downloadFile(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", capturePath + "/data.fdage");
  2036. // CreateObjUtil.build3dModel(target , "1");
  2037. //
  2038. // //读取upload文件,获取需要上传的文件
  2039. // JSONArray array = ComputerUtil.getUploadArray(resultPath + "/upload.json", this.maxCheckTimes, this.waitTime);
  2040. // Map<String, String> map = new HashMap<>();
  2041. // JSONObject fileJson;
  2042. // String uploadFile, uploadFilePath;
  2043. // String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
  2044. // for(int i = 0, len = array.size(); i < len; i++){
  2045. // fileJson = array.getJSONObject(i);
  2046. // uploadFile = fileJson.getString("file");
  2047. // uploadFilePath = resultPath +File.separator + uploadFile;
  2048. // //文件不存在抛出异常
  2049. //
  2050. // if(!cn.hutool.core.io.FileUtil.exist(uploadFilePath)){
  2051. // throw new Exception(uploadFilePath + "文件不存在");
  2052. // }
  2053. //
  2054. // Integer clazz = fileJson.getIntValue("clazz");
  2055. // if(Objects.isNull(clazz)){
  2056. // continue;
  2057. // }
  2058. // if(clazz == 4 || clazz == 5 || clazz == 7){
  2059. // map.put(uploadFilePath, imgEditPath + "panorama/" + sid + File.separator + uploadFile);
  2060. // }
  2061. // }
  2062. //
  2063. // //上传全景图
  2064. // map.put(filePath, imgEditPath + "panorama/" + sid + "/high/" + fileName);
  2065. //
  2066. // fYunFileService.uploadMulFiles(bucket, map);
  2067. //
  2068. // Map<String, String> result = new HashMap<>();
  2069. // result.put("type", type);
  2070. // return ResultData.ok(result);
  2071. // }
  2072. //
  2073. // @Override
  2074. // public ResultData saveLinkPan(SaveLinkPanParamVO param) throws Exception {
  2075. //
  2076. // String num = param.getNum();
  2077. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  2078. // if(Objects.isNull(scenePlus)){
  2079. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  2080. // }
  2081. //
  2082. // //添加场景关联数据
  2083. // this.addOrUpdateLinPan(num, param.getLinkPans());
  2084. //
  2085. // //添加场景关联图标
  2086. // this.addOrUpdateLinkPanStyles(num, param.getStyles());
  2087. //
  2088. // //场景关联数据备份到本地
  2089. // this.writeLinkScene(num);
  2090. //
  2091. // //更新场景关联标识、升级版本号
  2092. // this.setLinkScenesAndUpgradeVersion(scenePlus.getId(), num);
  2093. //
  2094. // return ResultData.ok();
  2095. // }
  2096. //
  2097. // @Override
  2098. // public ResultData deleteStyles(DeleteStylesParamVO param) throws Exception {
  2099. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  2100. // if (scenePlus == null)
  2101. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  2102. //
  2103. // List<String> sidList = param.getSidList();
  2104. //
  2105. // this.syncLinkPanStylesFromFileToRedis(param.getNum());
  2106. //
  2107. // String key = String.format(RedisKey.SCENE_LINKPAN_STYLES, param.getNum());
  2108. // List<String> deleteList = redisUtil.hMultiGet(key, sidList);
  2109. // redisUtil.hdel(key, sidList.toArray());
  2110. //
  2111. // //写入本地文件,作为备份
  2112. // this.writeLinkScene(param.getNum());
  2113. //
  2114. // //删除oss文件
  2115. // List<String> deleteFileList = deleteList.stream().map(str -> {
  2116. // JSONObject parse = JSON.parseObject(str);
  2117. // return parse.getString("url");
  2118. // }).collect(Collectors.toList());
  2119. // sceneUploadService.delete(
  2120. // DeleteFileParamVO.builder()
  2121. // .num(param.getNum())
  2122. // .fileNames(deleteFileList)
  2123. // .bizType(FileBizType.LINK_STYLE.code()).build());
  2124. //
  2125. // return ResultData.ok();
  2126. // }
  2127. //
  2128. // @Override
  2129. // public ResultData deleteLinkPan(DeleteLinkPanParamVO param) throws Exception {
  2130. //
  2131. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  2132. // if (scenePlus == null)
  2133. // return ResultData.error(ErrorCode.FAILURE_CODE_5005);
  2134. // ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  2135. // String bucket = scenePlusExt.getYunFileBucket();
  2136. //
  2137. // List<String> deleteSidList = param.getSidList();
  2138. //
  2139. // //处理删除状态数据
  2140. // this.deletelinkPanData(param.getNum(), deleteSidList, bucket);
  2141. //
  2142. // //写入本地文件,作为备份
  2143. // this.writeLinkScene(param.getNum());
  2144. //
  2145. // //更新场景关联标识、升级版本号
  2146. // this.setLinkScenesAndUpgradeVersion(scenePlus.getId(), param.getNum());
  2147. //
  2148. // return ResultData.ok();
  2149. // }
  2150. //
  2151. // private void deletelinkPanData(String num, List<String> deleteSidList, String bucket) throws Exception {
  2152. //
  2153. // if(CollUtil.isEmpty(deleteSidList)){
  2154. // return;
  2155. // }
  2156. //
  2157. // this.syncLinPanFromFileToRedis(num);
  2158. //
  2159. // //从redis中加载热点数据
  2160. // String key = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
  2161. // List<String> deletDataList = redisUtil.hMultiGet(key, deleteSidList);
  2162. // if(CollUtil.isEmpty(deletDataList))
  2163. // return;
  2164. // List<String> thumbNameList = deleteSidList.stream().map(sid -> {
  2165. // String linkPan = redisUtil.hget(key, sid);
  2166. // JSONObject linkPanObj = JSON.parseObject(linkPan);
  2167. // return FileUtil.getPrefix(linkPanObj.getString("thumb"));
  2168. // }).collect(Collectors.toList());
  2169. //
  2170. // //从redis中移除热点数据
  2171. // redisUtil.hdel(key, deleteSidList.toArray());
  2172. //
  2173. // //删除oss文件
  2174. // String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
  2175. // thumbNameList.stream().forEach(thumbName->{
  2176. // fYunFileService.deleteFolder(bucket, imgEditPath + "panorama/" + thumbName);
  2177. // });
  2178. //
  2179. // }
  2180. //
  2181. // @Override
  2182. // public ResultData listLinkPan(String num) throws Exception {
  2183. //
  2184. // this.syncLinPanFromFileToRedis(num);
  2185. //
  2186. // this.syncLinkPanStylesFromFileToRedis(num);
  2187. //
  2188. // JSONObject result = new JSONObject();
  2189. //
  2190. // //查询场景关联数据
  2191. // String key = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
  2192. // Map<String, String> allTagsMap = redisUtil.hmget(key);
  2193. // List<JSONObject> tags = Lists.newArrayList();
  2194. // List<TagBean> tagBeanList = new ArrayList<>();
  2195. // if(CollUtil.isNotEmpty(allTagsMap)){
  2196. // allTagsMap.entrySet().stream().forEach(entry -> {
  2197. // JSONObject jsonObject = JSON.parseObject(entry.getValue());
  2198. // tagBeanList.add(
  2199. // TagBean.builder()
  2200. // .createTime(jsonObject.getLong("createTime"))
  2201. // .tag(jsonObject).build());
  2202. // });
  2203. // //按创建时间倒叙排序
  2204. // tagBeanList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
  2205. //
  2206. // //移除createTime字段
  2207. // tags = tagBeanList.stream().map(tagBean -> {
  2208. // JSONObject tag = tagBean.getTag();
  2209. // tag.remove("createTime");
  2210. // return tag;
  2211. // }).collect(Collectors.toList());
  2212. // }
  2213. // result.put("tags", tags);
  2214. //
  2215. // //封装styles数据
  2216. // List<JSONObject> styles = Lists.newArrayList();
  2217. // key = String.format(RedisKey.SCENE_LINKPAN_STYLES, num);
  2218. // Map<String, String> styleMap = redisUtil.hmget(key);
  2219. // if(CollUtil.isNotEmpty(styleMap)) {
  2220. // for (String style : styleMap.values()) {
  2221. // styles.add(JSON.parseObject(style));
  2222. // }
  2223. // }
  2224. //
  2225. //
  2226. // //图标按写入时间排序
  2227. // styles = this.sortStyles(styles);
  2228. //
  2229. // result.put("styles", styles);
  2230. //
  2231. // return ResultData.ok(result);
  2232. // }
  2233. //
  2234. // private List<JSONObject> sortStyles(List<JSONObject> styles){
  2235. //
  2236. // if(CollUtil.isEmpty(styles)){
  2237. // return null;
  2238. // }
  2239. //
  2240. // //统计使用频次
  2241. // List<StyleBean> styleBeans = Lists.newArrayList();
  2242. // for (JSONObject style : styles) {
  2243. // Long createTime = style.getLong("createTime");
  2244. // createTime = Objects.isNull(createTime) ? Calendar.getInstance().getTimeInMillis() : createTime;
  2245. // style.remove("createTime");
  2246. // styleBeans.add(
  2247. // StyleBean.builder().style(style)
  2248. // .createTime(createTime).build());
  2249. // }
  2250. //
  2251. // //排序
  2252. // List<JSONObject> styleList = Lists.newArrayList();
  2253. // if(CollUtil.isNotEmpty(styleBeans)){
  2254. // styleList = styleBeans.stream().sorted(Comparator.comparing(StyleBean::getCreateTime).reversed())
  2255. // .map(item -> {
  2256. // return item.getStyle();
  2257. // }).collect(Collectors.toList());
  2258. // }
  2259. //
  2260. // return styleList;
  2261. // }
  2262. //
  2263. // private void setLinkScenesAndUpgradeVersion(Long scenePlusId, String num){
  2264. //
  2265. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlusId);
  2266. //
  2267. // //查询缓存是否有场景关联数据
  2268. // String key = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
  2269. // Map<String, String> allTagsMap = redisUtil.hmget(key);
  2270. // boolean hashTags = false;
  2271. // for (Entry<String, String> tagMap : allTagsMap.entrySet()) {
  2272. // if(StrUtil.isEmpty(tagMap.getValue())){
  2273. // continue;
  2274. // }
  2275. // hashTags = true;
  2276. // break;
  2277. // }
  2278. //
  2279. // //更新linkscenes字段
  2280. // sceneEditInfoExtService.update(
  2281. // new LambdaUpdateWrapper<SceneEditInfoExt>()
  2282. // .set(SceneEditInfoExt::getLinks, hashTags ? CommonStatus.YES.code() : CommonStatus.NO.code())
  2283. // .eq(SceneEditInfoExt::getEditInfoId, sceneEditInfo.getId()));
  2284. //
  2285. // //更新场景版本
  2286. // this.update(new LambdaUpdateWrapper<SceneEditInfo>()
  2287. // .setSql("version=version+" + 1)
  2288. // .setSql("link_version=link_version+" + 1)
  2289. // .eq(SceneEditInfo::getId, sceneEditInfo.getId()));
  2290. // }
  2291. //
  2292. // /**
  2293. // * <p>
  2294. // 热点数据保存
  2295. //
  2296. // * </p>
  2297. // * @author dengsixing
  2298. // * @date 2022/3/3
  2299. // **/
  2300. // private void writeLinkScene(String num) throws Exception{
  2301. //
  2302. // String dataKey = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
  2303. // Map<String, String> tagMap = redisUtil.hmget(dataKey);
  2304. // List<String> tagList = Lists.newArrayList();
  2305. // tagMap.entrySet().stream().forEach(entry->{
  2306. // if(StrUtil.isNotEmpty(entry.getValue())){
  2307. // tagList.add(entry.getValue());
  2308. // }
  2309. // });
  2310. // JSONObject jsonObject = new JSONObject();
  2311. // JSONArray tagJsonArr = new JSONArray();
  2312. // if(CollUtil.isNotEmpty(tagList)){
  2313. // tagList.stream().forEach(linkPan->{
  2314. // tagJsonArr.add(JSONObject.parseObject(linkPan));
  2315. // });
  2316. // }
  2317. // jsonObject.put("tags", tagJsonArr);
  2318. //
  2319. // String stylesKey = String.format(RedisKey.SCENE_LINKPAN_STYLES, num);
  2320. // Map<String, String> styleMap = redisUtil.hmget(stylesKey);
  2321. // List<JSONObject> styleList = Lists.newArrayList();
  2322. // if(CollUtil.isNotEmpty(styleMap)){
  2323. // styleMap.values().stream().forEach(style->{
  2324. // styleList.add(JSONObject.parseObject(style));
  2325. // });
  2326. // }
  2327. // jsonObject.put("styles", styleList);
  2328. //
  2329. // String linkScenePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "links.json";
  2330. // String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
  2331. // String lockKey = String.format(RedisLockKey.LOCK_LINK_SCENE_JSON, num);
  2332. // boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
  2333. // if(!lock){
  2334. // return;
  2335. // }
  2336. // try{
  2337. // cn.hutool.core.io.FileUtil.writeUtf8String(jsonObject.toJSONString(), linkScenePath);
  2338. // }finally {
  2339. // redisLockUtil.unlockLua(lockKey, lockVal);
  2340. // }
  2341. // }
  2342. //
  2343. //
  2344. // private void addOrUpdateLinkPanStyles(String num, List<JSONObject> styles) throws Exception{
  2345. //
  2346. // this.syncLinkPanStylesFromFileToRedis(num);
  2347. //
  2348. // if(CollUtil.isEmpty(styles)){
  2349. // return;
  2350. // }
  2351. //
  2352. // long time = Calendar.getInstance().getTimeInMillis();
  2353. // Map<String, String> styleMap = new HashMap<>();
  2354. // AtomicInteger index = new AtomicInteger();
  2355. // styles.stream().forEach(style->{
  2356. // String id = style.getString("sid");
  2357. // style.put("createTime", time + index.getAndIncrement());
  2358. // styleMap.put(id, style.toJSONString());
  2359. // });
  2360. //
  2361. // String key = String.format(RedisKey.SCENE_LINKPAN_STYLES, num);
  2362. // redisUtil.hmset(key, styleMap);
  2363. // }
  2364. //
  2365. // /**
  2366. // * <p>
  2367. // 保证icons数据安全性,当redis宕机导致icons数据丢失时,可以从文件中读取,恢复到redis
  2368. // * </p>
  2369. // * @author dengsixing
  2370. // * @date 2022/3/3
  2371. // **/
  2372. // private void syncLinkPanStylesFromFileToRedis(String num) throws Exception{
  2373. //
  2374. // String key = String.format(RedisKey.SCENE_LINKPAN_STYLES, num);
  2375. // boolean exist = redisUtil.hasKey(key);
  2376. // if(exist){
  2377. // return;
  2378. // }
  2379. // String lockKey = String.format(RedisLockKey.LOCK_LINKPAN_STYLES_SYNC, num);
  2380. // String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
  2381. // boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
  2382. // if(!lock){
  2383. // throw new BusinessException(ErrorCode.SYSTEM_BUSY);
  2384. // }
  2385. // try{
  2386. // exist = redisUtil.hasKey(key);
  2387. // if(exist){
  2388. // return;
  2389. // }
  2390. // String linkSceneFilePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
  2391. // String linkSceneData = FileUtils.readUtf8String(linkSceneFilePath + "links.json");
  2392. // if(StrUtil.isEmpty(linkSceneData)){
  2393. // return;
  2394. // }
  2395. // JSONObject jsonObject = JSON.parseObject(linkSceneData);
  2396. // JSONArray stylesArr = jsonObject.getJSONArray("styles");
  2397. // if(CollUtil.isEmpty(stylesArr)){
  2398. // return;
  2399. // }
  2400. // Map<String, String> styleMap = new HashMap<>();
  2401. // for (Object style : stylesArr) {
  2402. // JSONObject styleObj = (JSONObject)style;
  2403. // String id = styleObj.getString("sid");
  2404. // styleMap.put(id, styleObj.toJSONString());
  2405. // }
  2406. // redisUtil.hmset(key, styleMap);
  2407. // }finally {
  2408. // redisLockUtil.unlockLua(lockKey, lockVal);
  2409. // }
  2410. //
  2411. // }
  2412. //
  2413. // private void addOrUpdateLinPan(String num, List<JSONObject> linkPanList) throws Exception{
  2414. // Map<String, String> addOrUpdateMap = new HashMap<>();
  2415. // int i = 0;
  2416. // for (JSONObject jsonObject : linkPanList) {
  2417. // jsonObject.put("createTime", Calendar.getInstance().getTimeInMillis() + i++);
  2418. // addOrUpdateMap.put(jsonObject.getString("sid"), jsonObject.toJSONString());
  2419. // }
  2420. //
  2421. // this.syncLinPanFromFileToRedis(num);
  2422. //
  2423. // //处理新增和修改数据
  2424. // this.addOrUpdateLinkPanHandler(num, addOrUpdateMap);
  2425. // }
  2426. //
  2427. // /**
  2428. // * <p>
  2429. // 保证热点数据安全性,当redis宕机导致热点数据丢失时,可以从文件中读取,恢复到redis
  2430. // * </p>
  2431. // * @author dengsixing
  2432. // * @date 2022/3/3
  2433. // **/
  2434. // private void syncLinPanFromFileToRedis(String num) throws Exception{
  2435. //
  2436. // String key = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
  2437. // boolean exist = redisUtil.hasKey(key);
  2438. // if(exist){
  2439. // return;
  2440. // }
  2441. // String lockKey = String.format(RedisLockKey.LOCK_LINKPAN_DATA_SYNC, num);
  2442. // String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
  2443. // boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
  2444. // if(!lock){
  2445. // throw new BusinessException(ErrorCode.SYSTEM_BUSY);
  2446. // }
  2447. // try{
  2448. // exist = redisUtil.hasKey(key);
  2449. // if(exist){
  2450. // return;
  2451. // }
  2452. // String linkSceneFilePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
  2453. // String linkSceneData = FileUtils.readUtf8String(linkSceneFilePath + "links.json");
  2454. // if(StrUtil.isEmpty(linkSceneData)){
  2455. // return;
  2456. // }
  2457. // JSONObject jsonObject = JSON.parseObject(linkSceneData);
  2458. // JSONArray tagsArr = jsonObject.getJSONArray("tags");
  2459. // if(CollUtil.isEmpty(tagsArr)){
  2460. // return;
  2461. // }
  2462. // Map<String, String> map = new HashMap<>();
  2463. // for (Object o : tagsArr) {
  2464. // JSONObject jo = (JSONObject)o;
  2465. // map.put(jo.getString("sid"), jo.toJSONString());
  2466. // }
  2467. // redisUtil.hmset(key, map);
  2468. // }finally {
  2469. // redisLockUtil.unlockLua(lockKey, lockVal);
  2470. // }
  2471. // }
  2472. //
  2473. // private void addOrUpdateLinkPanHandler(String num, Map<String, String> addOrUpdateMap){
  2474. // if(CollUtil.isEmpty(addOrUpdateMap))
  2475. // return;
  2476. //
  2477. // //数据验证,新增、修改状态,linkPan不能为空
  2478. // for (String sid : addOrUpdateMap.keySet()) {
  2479. // String linkPan = addOrUpdateMap.get(sid);
  2480. // if(StrUtil.isEmpty(linkPan)){
  2481. // throw new BusinessException(ErrorCode.FAILURE_CODE_7022);
  2482. // }
  2483. // }
  2484. //
  2485. // //批量写入缓存
  2486. // String key = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
  2487. // redisUtil.hmset(key, addOrUpdateMap);
  2488. // }
  2489. //
  2490. // private void updateBoxVideos(SceneEditInfo sceneEditInfo, Long scenePlusId, String boxVideos){
  2491. // if(Objects.isNull(sceneEditInfo)){
  2492. // sceneEditInfo = new SceneEditInfo();
  2493. // sceneEditInfo.setScenePlusId(scenePlusId);
  2494. // sceneEditInfo.setBoxVideos(boxVideos);
  2495. // this.save(sceneEditInfo);
  2496. // }else{
  2497. // this.update(new UpdateWrapper<SceneEditInfo>()
  2498. // .setSql("version = version + 1")
  2499. // .set("box_videos", boxVideos)
  2500. // .eq("id", sceneEditInfo.getId()));
  2501. // }
  2502. // }
  2503. //
  2504. // private void updateBoxPhotos(SceneEditInfo sceneEditInfo, String boxPhotos){
  2505. // this.update(new LambdaUpdateWrapper<SceneEditInfo>()
  2506. // .set(SceneEditInfo::getBoxPhotos, boxPhotos)
  2507. // .setSql("version = version + 1")
  2508. // .eq(SceneEditInfo::getId, sceneEditInfo.getId()));
  2509. // }
  2510. //
  2511. // private String createBoxVideos(
  2512. // String num, String sid, JSONObject boxVideo,
  2513. // SceneEditInfo sceneEditInfo, int type) throws Exception{
  2514. //
  2515. // String boxVideos = null;
  2516. // if(sceneEditInfo != null){
  2517. // boxVideos = sceneEditInfo.getBoxVideos();
  2518. // }
  2519. // JSONArray boxVideosJson = null;
  2520. // if (StrUtil.isNotEmpty(boxVideos)) {
  2521. // boxVideosJson = JSONArray.parseArray(boxVideos);
  2522. // }else {
  2523. // boxVideosJson = new JSONArray();
  2524. // }
  2525. // if(boxVideosJson.size() > 0){
  2526. // int i = 1;
  2527. // long timeInMillis = Calendar.getInstance().getTimeInMillis();
  2528. // for (Object o : boxVideosJson) {
  2529. // JSONObject item = (JSONObject)o;
  2530. // if(Objects.nonNull(item.getLong("createTime"))){
  2531. // continue;
  2532. // }
  2533. // item.put("createTime", timeInMillis - (i++));
  2534. // }
  2535. // }
  2536. //
  2537. // String result = null;
  2538. // //删除
  2539. // if(type == OperationType.DELETE.code()){
  2540. // Set<String> deleteVidoeFile = new HashSet<>();
  2541. // Set<String> deletePicFile = new HashSet<>();
  2542. // if(boxVideosJson.size() == 0)
  2543. // return null;
  2544. // for(int i=0;i<boxVideosJson.size();++i){
  2545. // JSONObject ele = boxVideosJson.getJSONObject(i);
  2546. // if(ele.getString("sid").equals(sid)){
  2547. //
  2548. // String poster = ele.getString("poster");
  2549. // if(StrUtil.isNotEmpty(poster))
  2550. // deletePicFile.add(poster);
  2551. // String url = ele.getString("url");
  2552. // if(StrUtil.isNotEmpty(url)){
  2553. // deleteVidoeFile.add(url);
  2554. // deleteVidoeFile.add(url.replace(".mp4",".flv"));
  2555. // }
  2556. //
  2557. // boxVideosJson.remove(i);
  2558. // }
  2559. // }
  2560. //
  2561. // //删除资源文件
  2562. // if(CollUtil.isNotEmpty(deleteVidoeFile))
  2563. // sceneUploadService.delete(
  2564. // DeleteFileParamVO.builder().num(num)
  2565. // .bizType(FileBizType.BOX_VIDEO.code())
  2566. // .fileNames(new ArrayList<>(deleteVidoeFile)).build());
  2567. // //删除资源文件
  2568. // if(CollUtil.isNotEmpty(deleteVidoeFile))
  2569. // sceneUploadService.delete(
  2570. // DeleteFileParamVO.builder().num(num)
  2571. // .bizType(FileBizType.BOX_POSTER.code())
  2572. // .fileNames(new ArrayList<>(deletePicFile)).build());
  2573. // }else{
  2574. //
  2575. // boxVideo.put("createTime", Calendar.getInstance().getTimeInMillis());
  2576. //
  2577. // //更新
  2578. // boolean exist = false;
  2579. // for(int i=0;i<boxVideosJson.size();++i){
  2580. // JSONObject ele = boxVideosJson.getJSONObject(i);
  2581. // if(ele.getString("sid").equals(sid)){
  2582. // boxVideosJson.set(i, boxVideo);
  2583. // exist = true;
  2584. // }
  2585. // }
  2586. // //新增
  2587. // if(!exist){
  2588. // boxVideosJson.add(boxVideo);
  2589. // }
  2590. //
  2591. // boxVideosJson.clear();
  2592. // boxVideosJson.add(boxVideo);
  2593. //
  2594. // }
  2595. // if(boxVideosJson.size() != 0){
  2596. // result = boxVideosJson.toJSONString();
  2597. // }
  2598. //
  2599. // return result;
  2600. // }
  2601. //
  2602. // private String createBoxPhotos(String num, String sid, JSONObject boxPhoto, SceneEditInfo sceneEditInfo, int type) throws Exception{
  2603. //
  2604. // String boxPhotos = null;
  2605. // if(sceneEditInfo != null){
  2606. // boxPhotos = sceneEditInfo.getBoxPhotos();
  2607. // }
  2608. // JSONArray boxPhotosJson = null;
  2609. // if (StrUtil.isNotEmpty(boxPhotos)) {
  2610. // boxPhotosJson = JSONArray.parseArray(boxPhotos);
  2611. // }else {
  2612. // boxPhotosJson = new JSONArray();
  2613. // }
  2614. //
  2615. // String result = null;
  2616. // //删除
  2617. // if(type == OperationType.DELETE.code()){
  2618. // Set<String> deleteFile = new HashSet<>();
  2619. // if(boxPhotosJson.size() == 0)
  2620. // return null;
  2621. // for(int i=0;i<boxPhotosJson.size();++i){
  2622. // JSONObject ele = boxPhotosJson.getJSONObject(i);
  2623. // if(ele.getString("sid").equals(sid)){
  2624. //
  2625. // String poster = ele.getString("poster");
  2626. // if(StrUtil.isNotEmpty(poster))
  2627. // deleteFile.add(poster);
  2628. // String url = ele.getString("url");
  2629. // if(StrUtil.isNotEmpty(url))
  2630. // deleteFile.add(url);
  2631. //
  2632. // boxPhotosJson.remove(i);
  2633. // }
  2634. // }
  2635. // //删除资源文件
  2636. // if(CollUtil.isNotEmpty(deleteFile))
  2637. // sceneUploadService.delete(
  2638. // DeleteFileParamVO.builder().num(num)
  2639. // .bizType(FileBizType.BOX_VIDEO.code())
  2640. // .fileNames(new ArrayList<>(deleteFile)).build());
  2641. // }else{
  2642. // //更新
  2643. // boolean exist = false;
  2644. // for(int i=0;i<boxPhotosJson.size();++i){
  2645. // JSONObject ele = boxPhotosJson.getJSONObject(i);
  2646. // if(ele.getString("sid").equals(sid)){
  2647. // boxPhoto.put("createTime", ele.getLong("createTime"));
  2648. // boxPhotosJson.set(i, boxPhoto);
  2649. // exist = true;
  2650. // }
  2651. // }
  2652. // //新增
  2653. // if(!exist){
  2654. // boxPhoto.put("createTime", Calendar.getInstance().getTimeInMillis());
  2655. // boxPhotosJson.add(boxPhoto);
  2656. // }
  2657. //
  2658. // }
  2659. // if(boxPhotosJson.size() != 0){
  2660. //
  2661. // List<BoxPhotoBean> list = Lists.newArrayList();
  2662. // for (Object o : boxPhotosJson) {
  2663. // JSONObject jsonObject = (JSONObject)o;
  2664. // list.add(BoxPhotoBean.builder().createTime(jsonObject.getLong("createTime")).boxPhoto(jsonObject).build());
  2665. // }
  2666. // //按创建时间倒叙排序
  2667. // list.sort(Comparator.comparingLong(BoxPhotoBean::getCreateTime).reversed());
  2668. //
  2669. // // list转JSONArray
  2670. // JSONArray array = new JSONArray();
  2671. // list.stream().forEach(bean->{
  2672. // array.add(bean.getBoxPhoto());
  2673. // });
  2674. //
  2675. // result = array.toJSONString();
  2676. // }
  2677. //
  2678. // return result;
  2679. // }
  2680. //
  2681. // @Override
  2682. // public ResultData deleteMosaics(DeleteMosaicParamVO param) throws Exception {
  2683. //
  2684. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  2685. // if(Objects.isNull(scenePlus)){
  2686. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  2687. // }
  2688. // SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
  2689. //
  2690. // //如果redis数据丢失,从本地文件中同步马赛克数据到redis
  2691. // this.syncMosaicFromFileToRedis(param.getNum());
  2692. //
  2693. // String key = String.format(RedisKey.SCENE_MOSAIC_DATA, param.getNum());
  2694. // redisUtil.hdel(key, param.getPanoIdList().toArray());
  2695. //
  2696. // //写入本地文件,作为备份
  2697. // this.writeMosaic(param.getNum());
  2698. //
  2699. // //更新数据库
  2700. // this.updateMosaicFlag(param.getNum());
  2701. //
  2702. // //更新版本号
  2703. // this.upgradeVersionById(sceneEditInfo.getId());
  2704. //
  2705. // return ResultData.ok();
  2706. // }
  2707. //
  2708. @Override
  2709. public List<JSONObject> getMosaicList(String num) throws Exception {
  2710. // String key = String.format(RedisKey.SCENE_MOSAIC_DATA, num);
  2711. // Map<String, String> map = redisUtil.hmget(key);
  2712. // if(CollUtil.isEmpty(map)){
  2713. // ResultData.ok(new String[0]);
  2714. // }
  2715. // return map.values().stream()
  2716. // .map(mosaic-> JSON.parseObject(mosaic))
  2717. // .collect(Collectors.toList());
  2718. return null;
  2719. }
  2720. // @Override
  2721. // public ResultData addWaterMark(BaseFileParamVO param) throws Exception {
  2722. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  2723. // if(Objects.isNull(scenePlus)){
  2724. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  2725. // }
  2726. // SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService
  2727. // .getByScenePlusId(scenePlus.getId());
  2728. // sceneEditInfoExt.setWaterMark(param.getFileName());
  2729. // sceneEditInfoExtService.updateById(sceneEditInfoExt);
  2730. // return ResultData.ok();
  2731. // }
  2732. //
  2733. // @Override
  2734. // public ResultData deleteWaterMark(BaseFileParamVO param) throws Exception {
  2735. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  2736. // if(Objects.isNull(scenePlus)){
  2737. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  2738. // }
  2739. // sceneUploadService.delete(
  2740. // DeleteFileParamVO.builder()
  2741. // .num(param.getNum())
  2742. // .fileNames(Lists.newArrayList(param.getFileName()))
  2743. // .bizType(FileBizType.WATERMARK.code()).build());
  2744. //
  2745. // SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByScenePlusId(scenePlus.getId());
  2746. // sceneEditInfoExt.setWaterMark("");
  2747. // sceneEditInfoExtService.updateById(sceneEditInfoExt);
  2748. //
  2749. // return ResultData.ok();
  2750. // }
  2751. //
  2752. // @Override
  2753. // public ResultData saveFilter(SaveFiltersParamVO param) throws Exception {
  2754. //
  2755. // ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
  2756. // if(Objects.isNull(scenePlus)){
  2757. // throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  2758. // }
  2759. //
  2760. // String key = String.format(RedisKey.SCENE_filter_DATA, param.getNum());
  2761. // redisUtil.del(key);//前端将全量数据传过来,所以这里先清空历史数据,然后保存前端数据即可
  2762. // JSONArray filterArr = JSON.parseArray(param.getData());
  2763. // int filters = CommonStatus.YES.code();
  2764. // //如果页面选择恢复默认,filters字段值为否
  2765. // if(Objects.nonNull(param.getReset()) && param.getReset() == CommonStatus.YES.code().intValue()){
  2766. // filters = CommonStatus.NO.code();
  2767. // }else{
  2768. // if(CollUtil.isNotEmpty(filterArr)){
  2769. // List<String> filterList = filterArr.stream().map(item->JSON.toJSONString(item)).collect(Collectors.toList());
  2770. // redisUtil.lRightPushAll(key, filterList);
  2771. // }else{
  2772. // filters = CommonStatus.NO.code();
  2773. // }
  2774. // }
  2775. //
  2776. // //写本地文件,作为备份
  2777. // this.writeFilter(param.getNum());
  2778. //
  2779. //
  2780. // //更新数据库
  2781. // SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByScenePlusId(scenePlus.getId());
  2782. // sceneEditInfoExt.setFilters(filters);
  2783. // sceneEditInfoExtService.updateById(sceneEditInfoExt);
  2784. //
  2785. // //更新版本号
  2786. // this.upgradeVersionById(sceneEditInfoExt.getEditInfoId());
  2787. //
  2788. // return ResultData.ok();
  2789. //
  2790. // }
  2791. //
  2792. // private void writeFilter(String num) throws Exception{
  2793. //
  2794. // String filterPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "filter.json";
  2795. //
  2796. // String key = String.format(RedisKey.SCENE_filter_DATA, num);
  2797. // List<String> filters = redisUtil.lGet(key, 0, -1);
  2798. // if(CollUtil.isEmpty(filters)){
  2799. // FileUtils.deleteFile(filterPath);
  2800. // return;
  2801. // }
  2802. //
  2803. // String lockKey = String.format(RedisLockKey.LOCK_filter_JSON, num);
  2804. // String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
  2805. // boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
  2806. // if(!lock){
  2807. // return;
  2808. // }
  2809. // try{
  2810. // FileUtils.writeFile(filterPath, JSON.toJSONString(filters));
  2811. // }finally {
  2812. // redisLockUtil.unlockLua(lockKey, lockVal);
  2813. // }
  2814. // }
  2815. //
  2816. // private void syncFiltersFromFileToRedis(String num) throws Exception{
  2817. //
  2818. // String key = String.format(RedisKey.SCENE_filter_DATA, num);
  2819. // boolean exist = redisUtil.hasKey(key);
  2820. // if(exist){
  2821. // return;
  2822. // }
  2823. // String lockKey = String.format(RedisLockKey.LOCK_FILTER_DATA_SYNC, num);
  2824. // String lockVal = cn.hutool.core.lang.UUID.randomUUID().toString();
  2825. // boolean lock = redisLockUtil.lock(lockKey, lockVal, RedisKey.EXPIRE_TIME_1_MINUTE);
  2826. // if(!lock){
  2827. // throw new BusinessException(ErrorCode.SYSTEM_BUSY);
  2828. // }
  2829. // try{
  2830. // exist = redisUtil.hasKey(key);
  2831. // if(exist){
  2832. // return;
  2833. // }
  2834. // String filePath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num);
  2835. // String filterData = FileUtils.readUtf8String(filePath + "filter.json");
  2836. // if(StrUtil.isEmpty(filterData)){
  2837. // return;
  2838. // }
  2839. // JSONArray jsonArray = JSON.parseArray(filterData);
  2840. // if(CollUtil.isEmpty(jsonArray)){
  2841. // return;
  2842. // }
  2843. // redisUtil.lRightPushAll(key, jsonArray.stream().collect(Collectors.toList()));
  2844. // }finally {
  2845. // redisLockUtil.unlockLua(lockKey, lockVal);
  2846. // }
  2847. // }
  2848. //
  2849. // @Override
  2850. // public ResultData listFilter(BaseSceneParamVO param) throws Exception {
  2851. //
  2852. // //同步数据
  2853. // this.syncFiltersFromFileToRedis(param.getNum());
  2854. //
  2855. // //查询redis
  2856. // String key = String.format(RedisKey.SCENE_filter_DATA, param.getNum());
  2857. // List<String> list = redisUtil.lGet(key, 0, -1);
  2858. // List<JSONObject> collect =
  2859. // list.stream().map(str -> JSON.parseObject(str)).collect(Collectors.toList());
  2860. // return ResultData.ok(collect);
  2861. // }
  2862. }