|
@@ -0,0 +1,475 @@
|
|
|
+package com.fdkankan.repair.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.exceptions.ExceptionUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.common.constant.CommonStatus;
|
|
|
+import com.fdkankan.common.constant.ConstantFilePath;
|
|
|
+import com.fdkankan.common.constant.SceneFrom;
|
|
|
+import com.fdkankan.common.constant.SceneResolution;
|
|
|
+import com.fdkankan.common.constant.SceneSource;
|
|
|
+import com.fdkankan.common.constant.UploadFilePath;
|
|
|
+import com.fdkankan.common.util.FileUtil;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.common.util.MatrixToImageWriterUtil;
|
|
|
+import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import com.fdkankan.repair.bean.SceneEditControlsBean;
|
|
|
+import com.fdkankan.repair.bean.SceneJsonBean;
|
|
|
+import com.fdkankan.repair.entity.SceneEditControls;
|
|
|
+import com.fdkankan.repair.entity.SceneEditInfo;
|
|
|
+import com.fdkankan.repair.entity.SceneEditInfoExt;
|
|
|
+import com.fdkankan.repair.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.repair.entity.ScenePro;
|
|
|
+import com.fdkankan.repair.entity.SceneProEdit;
|
|
|
+import com.fdkankan.repair.entity.SceneProEditExt;
|
|
|
+import com.fdkankan.repair.entity.SceneProExt;
|
|
|
+import com.fdkankan.repair.entity.SceneRepairLog;
|
|
|
+import com.fdkankan.repair.service.ISceneEditControlsService;
|
|
|
+import com.fdkankan.repair.service.ISceneEditInfoExtService;
|
|
|
+import com.fdkankan.repair.service.ISceneEditInfoService;
|
|
|
+import com.fdkankan.repair.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.repair.service.ISceneProEditExtService;
|
|
|
+import com.fdkankan.repair.service.ISceneProEditService;
|
|
|
+import com.fdkankan.repair.service.ISceneProExtService;
|
|
|
+import com.fdkankan.repair.service.ISceneProService;
|
|
|
+import com.fdkankan.repair.service.ISceneRepairLogService;
|
|
|
+import java.io.File;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Map.Entry;
|
|
|
+import java.util.Set;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import sun.rmi.runtime.Log;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * TODO
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author dengsixing
|
|
|
+ * @since 2022/3/23
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class SceneRepairService {
|
|
|
+
|
|
|
+ @Value("${main.url}")
|
|
|
+ private String mainUrl;
|
|
|
+
|
|
|
+ @Value("${scene.pro.new.url}")
|
|
|
+ private String sceneProNewUrl;
|
|
|
+
|
|
|
+ @Value("${oss.prefix.url}")
|
|
|
+ private String ossUrlPrefix;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISceneProExtService sceneProExtService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneEditInfoService sceneEditInfoService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneEditInfoExtService sceneEditInfoExtService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneProEditService sceneProEditService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneProEditExtService sceneProEditExtService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneEditControlsService sceneEditControlsService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneRepairLogService sceneRepairLogService;
|
|
|
+ @Value("${oss.bucket:4dkankan}")
|
|
|
+ private String bucket;
|
|
|
+ @Autowired
|
|
|
+ private ISceneProService sceneProService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 当前正在执行的线程数
|
|
|
+ */
|
|
|
+ private int currentThreadCnt = 0;
|
|
|
+ @Autowired
|
|
|
+ private UploadToOssUtil uploadToOssUtil;
|
|
|
+ @Value("${upload.type:oss}")
|
|
|
+ private String uploadType;
|
|
|
+
|
|
|
+ private static final String[] prefixArr = new String[]{
|
|
|
+ "data/data%s/",
|
|
|
+ "voice/voice%s/",
|
|
|
+ "video/video%s/",
|
|
|
+ "images/images%s/"
|
|
|
+ };
|
|
|
+
|
|
|
+ @Async("sceneDownLoadExecutror")
|
|
|
+ public void repair(ScenePro scenePro) throws Exception {
|
|
|
+ //线程开始,正在执行线程数+1
|
|
|
+ this.addCurrentThreadCnt();
|
|
|
+ String num = scenePro.getNum();
|
|
|
+ long consumTime = 0;
|
|
|
+ long startTime = Calendar.getInstance().getTimeInMillis();
|
|
|
+ SceneRepairLog sceneRepairLog = null;
|
|
|
+ try {
|
|
|
+
|
|
|
+ sceneRepairLog = sceneRepairLogService.getOne(new LambdaQueryWrapper<SceneRepairLog>().eq(SceneRepairLog::getNum, num));
|
|
|
+ if(sceneRepairLog == null){
|
|
|
+ sceneRepairLog = SceneRepairLog.builder()
|
|
|
+ .num(scenePro.getNum())
|
|
|
+ .reason("")
|
|
|
+ .state(0).build();
|
|
|
+ }else{
|
|
|
+ sceneRepairLog.setReason("");
|
|
|
+ sceneRepairLog.setState(0);
|
|
|
+ }
|
|
|
+ //写入日志
|
|
|
+ sceneRepairLogService.saveOrUpdate(sceneRepairLog);
|
|
|
+
|
|
|
+ SceneProExt sceneProExt = sceneProExtService.getOne(
|
|
|
+ new LambdaQueryWrapper<SceneProExt>()
|
|
|
+ .eq(SceneProExt::getSceneProId, scenePro.getId()));
|
|
|
+ SceneProEdit sceneProEdit = sceneProEditService.getOne(
|
|
|
+ new LambdaQueryWrapper<SceneProEdit>()
|
|
|
+ .eq(SceneProEdit::getProId, scenePro.getId()));
|
|
|
+ SceneProEditExt sceneProEditExt = sceneProEditExtService
|
|
|
+ .getOne(new LambdaQueryWrapper<SceneProEditExt>()
|
|
|
+ .eq(SceneProEditExt::getProEditId, sceneProEdit.getId()));
|
|
|
+
|
|
|
+ String path = sceneProExt.getDataSource();
|
|
|
+
|
|
|
+ System.out.println("开始处理场景:" + num);
|
|
|
+
|
|
|
+ //oss文件拷贝
|
|
|
+ String dataPath = String.format("data/data%s/", num);
|
|
|
+ String imagePath = String.format("images/images%s/", num);
|
|
|
+ String videoPath = String.format("video/video%s/", num);
|
|
|
+ String voicePath = String.format("voice/voice%s/", num);
|
|
|
+ String dataViewPath = String.format("scene_view_data/%s/data/", num);
|
|
|
+ String imageViewPath = String.format("scene_view_data/%s/images/", num);
|
|
|
+ String videoViewPath = String.format("scene_view_data/%s/video/", num);
|
|
|
+ String voiceViewPath = String.format("scene_view_data/%s/voice/", num);
|
|
|
+ uploadToOssUtil.copyFiles(dataPath, dataViewPath);
|
|
|
+ uploadToOssUtil.copyFiles(imagePath, imageViewPath);
|
|
|
+ uploadToOssUtil.copyFiles(videoPath, videoViewPath);
|
|
|
+ uploadToOssUtil.copyFiles(voicePath, voiceViewPath);
|
|
|
+
|
|
|
+ //全景图上传、球幕视频
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ String sceneNumPAth = String.format("scene/%s", num);
|
|
|
+ List<String> imagesList = FileUtil.getFileList(path + "/caches/images");
|
|
|
+ if(CollUtil.isNotEmpty(imagesList)){
|
|
|
+ imagesList.stream().forEach(str -> map.put(str, str.replace(path, sceneNumPAth)));
|
|
|
+ }
|
|
|
+ List<String> videosList = FileUtil.getFileList(path + "/caches/videos");
|
|
|
+ if(CollUtil.isNotEmpty(videosList)){
|
|
|
+ videosList.stream().forEach(str -> map.put(str, str.replace(path, sceneNumPAth)));
|
|
|
+ }
|
|
|
+ uploadToOssUtil.uploadMulFiles(map);
|
|
|
+
|
|
|
+ //拷贝模型文件到用户编辑目录
|
|
|
+ String editImagesPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
|
+ String viewImagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
+ String editDataPath = String.format(UploadFilePath.DATA_EDIT_PATH, num);
|
|
|
+ String viewDataPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
|
|
|
+ Map<String, String> map2 = new HashMap<>();
|
|
|
+ map2.put(editImagesPath + "vision.modeldata", viewImagesPath + "vision.modeldata");
|
|
|
+ map2.put(editImagesPath + "vision2.modeldata", viewImagesPath + "vision2.modeldata");
|
|
|
+ map2.put(editDataPath + "floorplan_cad.json", viewDataPath + "floorplan_cad.json");
|
|
|
+ for (Entry<String, String> entry : map2.entrySet()) {
|
|
|
+ uploadToOssUtil.copyFiles(entry.getValue(), entry.getKey());
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成二维码
|
|
|
+ String sceneUrl = mainUrl + "/" + sceneProNewUrl;
|
|
|
+ String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/" + num + ".png";
|
|
|
+ String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/" + num + "_en.png";
|
|
|
+ MatrixToImageWriterUtil.createQRCode(sceneUrl + num, outPathZh, false,null);
|
|
|
+ MatrixToImageWriterUtil.createQRCode(sceneUrl + num + "&lang=en", outPathEn, false, null);
|
|
|
+ uploadToOssUtil.upload(outPathZh, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + ".png");
|
|
|
+ uploadToOssUtil.upload(outPathEn, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + "_en.png");
|
|
|
+
|
|
|
+ //生成热点json文件
|
|
|
+ Integer tags = Integer.parseInt(CommonStatus.NO.code().toString());
|
|
|
+ Set<String> icons = new HashSet<>();
|
|
|
+ String hotJson = uploadToOssUtil.getObjectContent("4dkankan", dataPath + "hot.json");
|
|
|
+ JSONArray newHotArr = new JSONArray();
|
|
|
+ if(StrUtil.isNotBlank(hotJson)){
|
|
|
+ JSONArray hotArr = JSON.parseArray(hotJson);
|
|
|
+ if(hotArr.size() > 0){
|
|
|
+ tags = Integer.parseInt(CommonStatus.YES.code().toString());
|
|
|
+ for(int i=0; i < hotArr.size(); i++){
|
|
|
+ JSONObject oldHot = (JSONObject)hotArr.get(i);
|
|
|
+ String styleId = oldHot.getString("styleId");
|
|
|
+
|
|
|
+ JSONObject newHot = new JSONObject();
|
|
|
+ newHot.put("createTime", Calendar.getInstance().getTimeInMillis() + i);
|
|
|
+ newHot.put("icon", styleId);
|
|
|
+
|
|
|
+ newHot.put("position", oldHot.getJSONObject("position"));
|
|
|
+
|
|
|
+ JSONObject media = new JSONObject();
|
|
|
+ newHot.put("media", media);
|
|
|
+ JSONObject fileName = oldHot.getJSONObject("fileName");
|
|
|
+ Set<Entry<String, Object>> entries = null;
|
|
|
+ if(fileName != null){
|
|
|
+ entries = fileName.entrySet();
|
|
|
+ }
|
|
|
+ if(CollUtil.isNotEmpty(entries)){
|
|
|
+ for (Entry<String, Object> entry : entries) {
|
|
|
+ JSONArray arr = new JSONArray();
|
|
|
+ media.put(entry.getKey(), arr);
|
|
|
+ JSONObject o = new JSONObject();
|
|
|
+ arr.add(o);
|
|
|
+ String fileSrc = ((String) entry.getValue());
|
|
|
+ o.put("src", oldHot.getString("sid") + fileSrc.substring(fileSrc.lastIndexOf(".")));
|
|
|
+ o.put("name", fileSrc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newHot.put("type", oldHot.getString("mediaType"));
|
|
|
+ newHot.put("title", oldHot.getString("label"));
|
|
|
+ newHot.put("content", oldHot.getString("description"));
|
|
|
+ newHot.put("sid", oldHot.getString("sid"));
|
|
|
+
|
|
|
+ if(StrUtil.isNotBlank(styleId)){
|
|
|
+ icons.add(styleId);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String hotJsonEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "hot.json";
|
|
|
+ String hotJsonViewPath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "hot.json";
|
|
|
+ uploadToOssUtil.upload(hotJson.getBytes(), hotJsonEditPath);
|
|
|
+ uploadToOssUtil.upload(hotJson.getBytes(), hotJsonViewPath);
|
|
|
+
|
|
|
+ //写到本地文件
|
|
|
+ JSONObject localObject = new JSONObject();
|
|
|
+ localObject.put("tags", newHotArr);
|
|
|
+ localObject.put("icons", icons);
|
|
|
+ String hotJsonPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, num) + "hot.json";
|
|
|
+ FileUtils.writeFile(hotJsonPath, localObject.toJSONString());
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean existLoadingLogo = false;
|
|
|
+ //生成编辑表
|
|
|
+ SceneEditInfo sceneEditInfo = sceneEditInfoService.getOne(
|
|
|
+ new LambdaQueryWrapper<SceneEditInfo>()
|
|
|
+ .eq(SceneEditInfo::getSceneProId, scenePro.getId()));
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = null;
|
|
|
+ SceneEditControls sceneEditControls = null;
|
|
|
+ if(sceneEditInfo == null){
|
|
|
+
|
|
|
+ List<String> loadingLogoFile = uploadToOssUtil.listKeys(imagePath + "logo-main.png");
|
|
|
+ if(CollUtil.isNotEmpty(loadingLogoFile)){
|
|
|
+ existLoadingLogo = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ sceneEditInfo = new SceneEditInfo();
|
|
|
+ sceneEditInfo.setSceneProId(scenePro.getId());
|
|
|
+ sceneEditInfo.setScenePlusId(scenePro.getId());
|
|
|
+ sceneEditInfo.setFloorLogo(sceneProEdit.getFloorLogo());
|
|
|
+ sceneEditInfo.setFloorLogoSize(sceneProEdit.getFloorLogoSize());
|
|
|
+ sceneEditInfo.setFloorLogoFile("user".equals(sceneProEdit.getFloorLogo()) ? "floorLogo-user.png" : null); //floorLogoImg.png -> floorLogo-user.png
|
|
|
+ sceneEditInfo.setMusic(sceneProEdit.getBgMusic());
|
|
|
+ //如果bgmusicname 不为空 ,MusicFile = BgMusicName
|
|
|
+ if(StrUtil.isNotEmpty(sceneProEditExt.getBgMusicName())){
|
|
|
+ sceneEditInfo.setMusicFile(sceneProEditExt.getBgMusicName());
|
|
|
+ }
|
|
|
+ //bgmusic=user, music=musicfile
|
|
|
+ if("user".equals(sceneProEdit.getBgMusic())){
|
|
|
+ sceneEditInfo.setMusic(sceneEditInfo.getMusicFile());
|
|
|
+ }
|
|
|
+ sceneEditInfo.setScenePassword(sceneProEdit.getSceneKey());
|
|
|
+ sceneEditInfo.setTitle(scenePro.getSceneName());
|
|
|
+ sceneEditInfo.setDescription(scenePro.getSceneDec());
|
|
|
+ sceneEditInfo.setFloorPlanUser(sceneProEdit.getFloorLogo() == null ? 0 : Integer.parseInt(sceneProEdit.getFloorLogo()));
|
|
|
+ sceneEditInfo.setCadInfo(sceneProEditExt.getCadInfo());
|
|
|
+ sceneEditInfo.setTags(tags);
|
|
|
+ sceneEditInfo.setVersion(sceneProEdit.getVersion());
|
|
|
+ sceneEditInfo.setIsUploadObj(Integer.parseInt(CommonStatus.NO.code().toString()));
|
|
|
+ sceneEditInfo.setFloorEditVer(sceneProEdit.getFloorEditVer());
|
|
|
+ sceneEditInfo.setFloorPublishVer(sceneProEdit.getFloorPublishVer());
|
|
|
+ sceneEditInfo.setBoxVideos(sceneProEditExt.getOverlay());
|
|
|
+ sceneEditInfo.setEntry(sceneProEdit.getEntry());
|
|
|
+ sceneEditInfo.setLoadingLogo(existLoadingLogo ? "user" : null);
|
|
|
+ sceneEditInfo.setLoadingLogoFile(existLoadingLogo ? "loadingLogo-user.png" : null);
|
|
|
+ sceneEditInfo.setCreateTime(sceneProEdit.getCreateTime());
|
|
|
+ sceneEditInfo.setUpdateTime(sceneProEdit.getUpdateTime());
|
|
|
+ sceneEditInfo.setTbStatus(sceneProEdit.getTbStatus());
|
|
|
+ sceneEditInfoService.save(sceneEditInfo);
|
|
|
+
|
|
|
+ sceneEditInfoExt = new SceneEditInfoExt();
|
|
|
+ sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
|
|
|
+ sceneEditInfoExt.setSceneProId(scenePro.getId());
|
|
|
+ sceneEditInfoExt.setScenePlusId(scenePro.getId());
|
|
|
+ sceneEditInfoExt.setFloorPlanAngle(sceneProEditExt.getFloorPlanAngle() == null ? 0f : Float.parseFloat(sceneProEditExt.getFloorPlanAngle()));
|
|
|
+ sceneEditInfoExt.setFloorPlanCompass(this.getFloorPlanCompass(num));
|
|
|
+ sceneEditInfoExt.setVrNum(sceneProEditExt.getVrNum());
|
|
|
+ sceneEditInfoExt.setCreateTime(sceneEditInfo.getCreateTime());
|
|
|
+ sceneEditInfoExt.setUpdateTime(sceneEditInfo.getUpdateTime());
|
|
|
+ sceneEditInfoExt.setTbStatus(sceneEditInfo.getTbStatus());
|
|
|
+ sceneEditInfoExtService.save(sceneEditInfoExt);
|
|
|
+
|
|
|
+ sceneEditControls = new SceneEditControls();
|
|
|
+ sceneEditControls.setEditInfoId(sceneEditInfo.getId());
|
|
|
+ sceneEditControls.setShowMap(sceneProEditExt.getMapVisi());
|
|
|
+ sceneEditControls.setShowLock(sceneProEdit.getNeedKey());
|
|
|
+ sceneEditControls.setShowTitle(Integer.valueOf(CommonStatus.YES.code()));
|
|
|
+ sceneEditControls.setShowPanorama(sceneProEditExt.getPanoVisi());
|
|
|
+ sceneEditControls.setShowDollhouse(sceneProEditExt.getM3dVisi());
|
|
|
+ sceneEditControls.setShowFloorplan(sceneProEditExt.getM2dVisi());
|
|
|
+ sceneEditControls.setShowVr(sceneProEditExt.getVrVisi());
|
|
|
+ sceneEditControls.setShowTour(sceneProEditExt.getTourVisi());
|
|
|
+ sceneEditControls.setShowRule(sceneProEditExt.getRulerVisi());
|
|
|
+ sceneEditControls.setCreateTime(sceneEditInfo.getCreateTime());
|
|
|
+ sceneEditControls.setUpdateTime(sceneEditInfo.getUpdateTime());
|
|
|
+ sceneEditControls.setTbStatus(sceneEditInfo.getTbStatus());
|
|
|
+ sceneEditControlsService.save(sceneEditControls);
|
|
|
+ }else{
|
|
|
+ sceneEditInfoExt = sceneEditInfoExtService.getOne(
|
|
|
+ new LambdaQueryWrapper<SceneEditInfoExt>()
|
|
|
+ .eq(SceneEditInfoExt::getEditInfoId, sceneEditInfo.getId()));
|
|
|
+ sceneEditControls = sceneEditControlsService.getOne(
|
|
|
+ new LambdaQueryWrapper<SceneEditControls>()
|
|
|
+ .eq(SceneEditControls::getEditInfoId, sceneEditInfo.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据编辑表 上传用户目录 包括编辑目录 查看目录
|
|
|
+ String editUsersPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
|
|
|
+ String viewUsersPath = String.format(UploadFilePath.USER_VIEW_PATH, num);
|
|
|
+ if("user".equals(sceneProEdit.getFloorLogo())){
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "floorLogoImg.png", editUsersPath + "floorLogo-user.png");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "floorLogoImg.png", viewUsersPath + "floorLogo-user.png");
|
|
|
+ }
|
|
|
+ if("user".equals(sceneProEdit.getBgMusic())){
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + sceneProEditExt.getBgMusicName(), editUsersPath + "music-user.mp3");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + sceneProEditExt.getBgMusicName(), viewUsersPath + "music-user.mp3");
|
|
|
+ }
|
|
|
+ if(existLoadingLogo){
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "logo-main.png", editUsersPath + "loadingLogo-user.png");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "logo-main.png", viewUsersPath + "loadingLogo-user.png");
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(scenePro.getThumb())
|
|
|
+ && scenePro.getThumb().contains(imagePath)){
|
|
|
+ String thumbUrl = null;
|
|
|
+ if(scenePro.getThumb().contains("thumbSmallImg.jpg")){
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "thumbBigImg.jpg", editUsersPath + "thumb-1k.jpg");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "thumbBigImg.jpg", viewUsersPath + "thumb-1k.jpg");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "thumbBigImg.jpg", editUsersPath + "thumb-2k.jpg");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "thumbBigImg.jpg", viewUsersPath + "thumb-2k.jpg");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "thumbSmallImg.jpg", editUsersPath + "thumb-128.jpg");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "thumbSmallImg.jpg", viewUsersPath + "thumb-128.jpg");
|
|
|
+ thumbUrl = this.ossUrlPrefix + String.format(UploadFilePath.USER_VIEW_PATH, num) + "thumb-128.jpg";
|
|
|
+ }else{
|
|
|
+ thumbUrl = scenePro.getThumb().replace(imagePath, viewImagesPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ scenePro.setThumb(thumbUrl);
|
|
|
+ sceneProService.updateById(scenePro);
|
|
|
+
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getOne(
|
|
|
+ new LambdaQueryWrapper<ScenePlusExt>()
|
|
|
+ .eq(ScenePlusExt::getPlusId, scenePro.getId()));
|
|
|
+ scenePlusExt.setThumb(thumbUrl);
|
|
|
+ scenePlusExtService.updateById(scenePlusExt);
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(sceneEditInfo.getBoxVideos())){
|
|
|
+ JSONArray boxVideoArr = JSON.parseArray(sceneEditInfo.getBoxVideos());
|
|
|
+ for(int i = 0; i < boxVideoArr.size(); i++){
|
|
|
+ JSONObject boxVideo = boxVideoArr.getJSONObject(i);
|
|
|
+ String sid = boxVideo.getString("sid");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "overlay" + sid + ".mp4", editUsersPath + sid + ".mp4");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "overlay" + sid + ".mp4", viewUsersPath + sid + ".mp4");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "overlay" + sid + ".flv", editUsersPath + sid + ".flv");
|
|
|
+ uploadToOssUtil.copyFiles(imagePath + "overlay" + sid + ".flv", viewUsersPath + sid + ".flv");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //生成scene.json
|
|
|
+// 生成新的scene.json,上传至scene_view_data/<num>/data
|
|
|
+ SceneJsonBean sceneJson = new SceneJsonBean();
|
|
|
+ BeanUtil.copyProperties(sceneEditInfoExt, sceneJson);
|
|
|
+ BeanUtil.copyProperties(sceneEditInfo, sceneJson);
|
|
|
+ SceneEditControlsBean sceneEditControlsBean = BeanUtil.copyProperties(sceneEditControls, SceneEditControlsBean.class);
|
|
|
+ sceneJson.setControls(sceneEditControlsBean);
|
|
|
+ sceneJson.setNum(num);
|
|
|
+ sceneJson.setCreateTime(scenePro.getCreateTime());
|
|
|
+ sceneJson.setSceneResolution(sceneProExt.getSceneResolution());
|
|
|
+ sceneJson.setSceneFrom(sceneProExt.getSceneFrom());
|
|
|
+ if(StrUtil.isNotEmpty(scenePro.getVideos())){
|
|
|
+ sceneJson.setVideos(JSON.parseObject(scenePro.getVideos()));
|
|
|
+ }
|
|
|
+ //本地写sceneJson文件
|
|
|
+ String localSceneJsonPath = String.format(ConstantFilePath.SCENE_PATH_FORMAT, num);
|
|
|
+ FileUtils.writeFile(localSceneJsonPath, JSON.toJSONString(sceneJson));
|
|
|
+ //上传sceneJson文件
|
|
|
+ String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH+"scene.json", num);
|
|
|
+ uploadToOssUtil.upload(JSON.toJSONBytes(sceneJson), sceneJsonPath);
|
|
|
+
|
|
|
+ //迁移耗时
|
|
|
+ consumTime = Calendar.getInstance().getTimeInMillis() - startTime;
|
|
|
+
|
|
|
+ //记录日志
|
|
|
+ sceneRepairLog.setState(1);
|
|
|
+ sceneRepairLog.setConsumTime(consumTime);
|
|
|
+ sceneRepairLogService.updateById(sceneRepairLog);
|
|
|
+
|
|
|
+ System.out.println(Thread.currentThread().getName());
|
|
|
+ Thread.sleep(20000);
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println("处理场景结束:" + num);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ //记录日志
|
|
|
+ consumTime = Calendar.getInstance().getTimeInMillis() - startTime;
|
|
|
+ sceneRepairLog.setState(2);
|
|
|
+ sceneRepairLog.setReason(ExceptionUtil.stacktraceToString(e));
|
|
|
+ sceneRepairLog.setConsumTime(consumTime);
|
|
|
+ sceneRepairLogService.updateById(sceneRepairLog);
|
|
|
+ }finally {
|
|
|
+ //线程结束,正在执行线程数-1
|
|
|
+ this.decCurrentThreadCnt();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Float getFloorPlanCompass(String num){
|
|
|
+ String objectContent =
|
|
|
+ uploadToOssUtil.getObjectContent(bucket, "data/data" + num + "/houst_floor.json");
|
|
|
+ if(StrUtil.isEmpty(objectContent)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSON.parseObject(objectContent);
|
|
|
+ JSONArray floors = jsonObject.getJSONArray("floors");
|
|
|
+ if(CollUtil.isEmpty(floors)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Object o = floors.get(0);
|
|
|
+ JSONObject object = (JSONObject)o;
|
|
|
+ return object.getFloat("dire");
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getCurrentThreadCnt(){
|
|
|
+ return this.currentThreadCnt;
|
|
|
+ }
|
|
|
+
|
|
|
+ public synchronized void addCurrentThreadCnt(){
|
|
|
+ ++this.currentThreadCnt;
|
|
|
+ }
|
|
|
+
|
|
|
+ public synchronized void decCurrentThreadCnt(){
|
|
|
+ --this.currentThreadCnt;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|