|
@@ -1,5 +1,7 @@
|
|
|
package com.gis.listener;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.io.file.FileWriter;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
@@ -12,17 +14,13 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.filestorage.FileStorageTemplate;
|
|
|
import com.gis.constant.CmdConstant;
|
|
|
import com.gis.constant.ConfigConstant;
|
|
|
-import com.gis.entity.RelicsSceneInitQueueDTO;
|
|
|
-import com.gis.entity.ScenePanoEntity;
|
|
|
-import com.gis.entity.SceneQueueDTO;
|
|
|
-import com.gis.entity.WorkEntity;
|
|
|
+import com.gis.dto.*;
|
|
|
+import com.gis.entity.*;
|
|
|
import com.gis.exception.BaseRuntimeException;
|
|
|
import com.gis.mq.RabbitMqProducerUtil;
|
|
|
import com.gis.oss.util.FileAndOssUtil;
|
|
|
-import com.gis.service.ScenePanoService;
|
|
|
-import com.gis.service.WorkService;
|
|
|
+import com.gis.service.*;
|
|
|
import com.gis.util.CmdUtils;
|
|
|
-import com.gis.util.FileUtils;
|
|
|
import com.gis.util.QrCodeUtils;
|
|
|
import com.gis.util.RandomUtils;
|
|
|
import com.rabbitmq.client.Channel;
|
|
@@ -45,6 +43,7 @@ import java.nio.charset.StandardCharsets;
|
|
|
import java.nio.file.Files;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
@@ -81,6 +80,15 @@ public class SceneListener {
|
|
|
|
|
|
@Value("${domain.4dkk}")
|
|
|
public String domain4dKK;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkNavigationSettingService workNavigationSettingService;
|
|
|
+ @Autowired
|
|
|
+ private WorkNavigationService workNavigationService;
|
|
|
+ @Autowired
|
|
|
+ private WorkCustomMaskService workCustomMaskService;
|
|
|
+ @Autowired
|
|
|
+ private WorkCustomButtonService workCustomButtonService;
|
|
|
/**
|
|
|
* 全景场景初始化方法
|
|
|
*
|
|
@@ -126,7 +134,7 @@ public class SceneListener {
|
|
|
if (ObjectUtil.isNotEmpty(param.getPayStatus())){
|
|
|
workEntity.setPayStatus(param.getPayStatus());
|
|
|
}
|
|
|
- workService.update(workEntity);
|
|
|
+ workService.updateById(workEntity);
|
|
|
sendStartMq(param);
|
|
|
channel.basicAck(deliveryTag, false);
|
|
|
}else if (ObjectUtil.isNotEmpty(param.getSceneCode())&¶m.getStatus()==1) {
|
|
@@ -196,13 +204,13 @@ public class SceneListener {
|
|
|
workEntity.setPassword(param.getPwd());
|
|
|
workEntity.setIsPassword(1);
|
|
|
}
|
|
|
- workService.update(workEntity);
|
|
|
+ workService.updateById(workEntity);
|
|
|
//清理旧数据
|
|
|
List<ScenePanoEntity> list = scenePanoService.findByWorkId(workEntity.getId());
|
|
|
for (ScenePanoEntity scenePanoEntity : list) {
|
|
|
scenePanoEntity.setIsDelete(1);
|
|
|
scenePanoEntity.setUpdateTime(new Date());
|
|
|
- scenePanoService.update(scenePanoEntity);
|
|
|
+ scenePanoService.updateById(scenePanoEntity);
|
|
|
}
|
|
|
|
|
|
String visionUrl = "http://"+domain4dKK+"/oss/scene_view_data/"+param.getSceneCode()+"/images/vision.txt";
|
|
@@ -217,13 +225,14 @@ public class SceneListener {
|
|
|
}
|
|
|
|
|
|
//2,使用krpano工具生成全景图数据
|
|
|
- List<Map<String,Object>> scenes=new ArrayList<>();
|
|
|
+ List<InitWorkNavigationSceneDTO> scenes = new ArrayList<>();
|
|
|
+
|
|
|
for (int i = 0; i < sweepLocations.size(); i++) {
|
|
|
JSONObject jsonObject = sweepLocations.getJSONObject(i);
|
|
|
String uuid = jsonObject.getString("uuid");
|
|
|
String id = jsonObject.getString("id");
|
|
|
String ossKey="scene_view_data/"+param.getSceneCode()+"/images/panoramas/"+uuid+".jpg";
|
|
|
- Map<String,Object> scene=new HashMap<>();
|
|
|
+ InitWorkNavigationSceneDTO scene=new InitWorkNavigationSceneDTO();
|
|
|
ScenePanoEntity scenePanoEntity = this.doSlice(traceId ,ossKey, param.getSceneCode(), workEntity.getId(),uuid+".jpg",uuid,id);
|
|
|
// "icon": "https://ossxiaoan.4dage.com/720yun_fd_manage/fd720_8nRkFlzpp/vtour/panos/fd720_8nRkFlzpp.tiles/thumb.jpg",
|
|
|
// "sceneCode": "fd720_8nRkFlzpp",
|
|
@@ -231,32 +240,36 @@ public class SceneListener {
|
|
|
// "category": 1,
|
|
|
// "type": "pano",
|
|
|
// "id": "s_xId8vevp",
|
|
|
- scene.put("icon", scenePanoEntity.getIcon());
|
|
|
- scene.put("sceneCode", scenePanoEntity.getSceneCode());
|
|
|
- scene.put("sceneTitle", id);
|
|
|
- scene.put("category", 1);
|
|
|
- scene.put("type", "pano");
|
|
|
+ scene.setIcon(scenePanoEntity.getIcon());
|
|
|
+ scene.setType("pano");
|
|
|
+ scene.setName(id);
|
|
|
//id生成规则是 s_ 拼接,随机8位字符串,字母加数字组合,有大小写
|
|
|
- String customId = generateCustomId();
|
|
|
- scene.put("id", customId);
|
|
|
+ scene.setSceneCode(scenePanoEntity.getSceneCode());
|
|
|
scenes.add(scene);
|
|
|
if (i==0){
|
|
|
workEntity.setIcon(scenePanoEntity.getIcon());
|
|
|
- workService.update(workEntity);
|
|
|
+ workService.updateById(workEntity);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
log.info("场景切图完成组装json");
|
|
|
- //3,修改json文件,并创建work作品表数据,增加作品类型为相机拍摄全景图
|
|
|
- JSONObject someDataToJson= this.editSomeData(workEntity,scenes);
|
|
|
+ //修改为创建数据库
|
|
|
+ String shareUrl = configConstant.domain4dKK + "/panorama/showMobile.html?id=" + workEntity.getId();
|
|
|
+ String qrCode = qrCodeUtils.generateLogoQrCode(shareUrl, configConstant.serverBasePath, configConstant.ossBasePath, ossUtil.calculateUrl(""), workEntity.getId());
|
|
|
+ workEntity.setQrCode(qrCode);
|
|
|
+ workEntity.setShare(shareUrl);
|
|
|
+
|
|
|
+ //创建tour.xml
|
|
|
+ this.saveTour(workEntity.getId());
|
|
|
|
|
|
+ WorkAddDto workAddDto = new WorkAddDto();
|
|
|
+ workAddDto.setSceneDTOList(scenes);
|
|
|
|
|
|
- // 更新跟目录tour.xml 2022-09-15
|
|
|
- this.updateTour(someDataToJson, workEntity.getId());
|
|
|
+ this.initData(workAddDto, workEntity);
|
|
|
|
|
|
workEntity.setCalcStatus(1);
|
|
|
- workService.update(workEntity);
|
|
|
+ workService.updateById(workEntity);
|
|
|
sendEndMq(param);
|
|
|
updateOssStatusJson(param.getSceneCode(),1);
|
|
|
channel.basicAck(deliveryTag, false);
|
|
@@ -274,6 +287,65 @@ public class SceneListener {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ private void initData(WorkAddDto workAddDto, WorkEntity entity){
|
|
|
+ //添加默认分组
|
|
|
+ WorkNavigationDTO defaultGroup = WorkNavigationDTO.builder().parentId(0L).name("一级分组").sort(0).build();
|
|
|
+ defaultGroup.setWorkId(entity.getId());
|
|
|
+ WorkNavigationVo workNavigationVo = workNavigationSettingService.addGroup(defaultGroup);
|
|
|
+ List<WorkNavigationEntity> workNavigationEntities = BeanUtil.copyToList(workAddDto.getSceneDTOList(), WorkNavigationEntity.class);
|
|
|
+ AtomicInteger sort = new AtomicInteger(0);
|
|
|
+ workNavigationEntities.stream().forEach(v->{
|
|
|
+ v.setParentId(workNavigationVo.getId());
|
|
|
+ v.setWorkId(entity.getId());
|
|
|
+ v.setSort(sort.getAndAdd(1));
|
|
|
+ });
|
|
|
+ workNavigationService.saveBatch(workNavigationEntities);
|
|
|
+
|
|
|
+ //初始化遮罩数据
|
|
|
+ this.initMaskData(workNavigationEntities);
|
|
|
+
|
|
|
+ //初始化自定义按钮
|
|
|
+ this.initCustomButton(entity.getId());
|
|
|
+ }
|
|
|
+ private void initCustomButton(String workId){
|
|
|
+ WorkCustomButtonEntity phoneButton = new WorkCustomButtonEntity();
|
|
|
+ phoneButton.setWorkId(workId);
|
|
|
+ phoneButton.setIsShow(0);
|
|
|
+ phoneButton.setName("电话");
|
|
|
+ phoneButton.setType("phone");
|
|
|
+ phoneButton.setOpenMethod("_self");
|
|
|
+ phoneButton.setCreateTime(new Date());
|
|
|
+
|
|
|
+ WorkCustomButtonEntity linkButton = BeanUtil.toBean(phoneButton, WorkCustomButtonEntity.class);
|
|
|
+ linkButton.setName("链接");
|
|
|
+
|
|
|
+ workCustomButtonService.saveBatch(Arrays.asList(phoneButton, linkButton));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initMaskData(List<WorkNavigationEntity> workNavigations){
|
|
|
+ List<WorkCustomMaskEntity> list = new ArrayList<>();
|
|
|
+ workNavigations.stream().forEach(v->{
|
|
|
+ WorkCustomMaskEntity sky = new WorkCustomMaskEntity();
|
|
|
+ sky.setWorkId(v.getWorkId());
|
|
|
+ sky.setNavigationId(v.getId());
|
|
|
+ sky.setIsShow(true);
|
|
|
+ sky.setType("sky");
|
|
|
+ sky.setAntidistorted(true);
|
|
|
+ sky.setScale(1D);
|
|
|
+ list.add(sky);
|
|
|
+
|
|
|
+ WorkCustomMaskEntity earth = BeanUtil.toBean(sky, WorkCustomMaskEntity.class);
|
|
|
+ earth.setType("earth");
|
|
|
+ earth.setIsShow(false);
|
|
|
+ list.add(earth);
|
|
|
+ });
|
|
|
+ if(CollUtil.isNotEmpty(list)){
|
|
|
+ workCustomMaskService.saveBatch(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void updateOssStatusJson(String sceneCode, int status) throws IOException {
|
|
|
//修改OSS,status状态 scene_view_data/场景码/data/status.json
|
|
|
String statusJson = "scene_view_data/"+sceneCode+"/data/status.json";
|
|
@@ -393,7 +465,7 @@ public class SceneListener {
|
|
|
size = size / 1024;
|
|
|
log.info("fileSize: " + size);
|
|
|
entity.setFileSize(size + "");
|
|
|
- scenePanoService.update(entity);
|
|
|
+ scenePanoService.updateById(entity);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -452,7 +524,7 @@ public class SceneListener {
|
|
|
entity.setStatus(2);
|
|
|
future.cancel(true);
|
|
|
} finally {
|
|
|
- scenePanoService.update(entity);
|
|
|
+ scenePanoService.updateById(entity);
|
|
|
log.info("切图流程, 更新数据库完成 : ");
|
|
|
}
|
|
|
log.info("切图流程结束 : ");
|
|
@@ -461,15 +533,10 @@ public class SceneListener {
|
|
|
|
|
|
/**
|
|
|
* 更新 tour.xml
|
|
|
- * @param someDataToJson
|
|
|
* @param id
|
|
|
*/
|
|
|
- private void updateTour(JSONObject someDataToJson, String id) {
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
- String scenes = someDataToJson.getString("scenes");
|
|
|
- BaseRuntimeException.isBlank(scenes, null, "someData的场景码参数未空");
|
|
|
+ private void saveTour(String id) {
|
|
|
List<ScenePanoEntity> list = scenePanoService.findByWorkId(id);
|
|
|
-
|
|
|
// 读取tour.xml模板
|
|
|
String baseTour = getBaseTour();
|
|
|
StringBuilder builder = new StringBuilder();
|
|
@@ -538,73 +605,7 @@ public class SceneListener {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private JSONObject editSomeData(WorkEntity workEntity, List<Map<String, Object>> scenes){
|
|
|
- // 如基someData作出修改,记得把代码里的someData 跟服务器里的someData都修改
|
|
|
- String baseSomeDataPath = configConstant.serverBasePath + "baseData/someData.json";
|
|
|
- String baseSomeDataSceneDataPath = configConstant.serverBasePath + "baseData/someDataSceneData.json";
|
|
|
- log.info("服务器base someData.json path: {}", baseSomeDataPath);
|
|
|
- // someData.json 内容
|
|
|
- String content = null;
|
|
|
- if (FileUtil.isFile(baseSomeDataPath)) {
|
|
|
- log.info("使用服务器someData.json");
|
|
|
- content = FileUtil.readUtf8String(baseSomeDataPath);
|
|
|
- } else {
|
|
|
- // 获取文件内容
|
|
|
- log.info("创建someData.json");
|
|
|
- content = FileUtils.getResourceContent("data/someData.json");
|
|
|
- FileUtil.writeUtf8String(content, baseSomeDataPath);
|
|
|
- }
|
|
|
- String someDataSceneDatContent = null;
|
|
|
- if (FileUtil.isFile(baseSomeDataSceneDataPath)) {
|
|
|
- log.info("使用服务器SomeDataSceneData.json");
|
|
|
- someDataSceneDatContent = FileUtil.readUtf8String(baseSomeDataSceneDataPath);
|
|
|
- } else {
|
|
|
- // 获取文件内容
|
|
|
- log.info("创建SomeDataSceneData.json");
|
|
|
- someDataSceneDatContent = FileUtils.getResourceContent("data/someDataSceneData.json");
|
|
|
- FileUtil.writeUtf8String(someDataSceneDatContent, baseSomeDataSceneDataPath);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
- jsonObject.put("id", workEntity.getId() + "");
|
|
|
-
|
|
|
-
|
|
|
- // 创建二维码、二维码url
|
|
|
- String shareUrl = configConstant.domain4dKK + "/panorama/showMobile.html?id=" + workEntity.getId();
|
|
|
- String qrCode = qrCodeUtils.generateLogoQrCode(shareUrl, configConstant.serverBasePath, configConstant.ossBasePath, ossUtil.calculateUrl(""), workEntity.getId());
|
|
|
- jsonObject.put("share", shareUrl);
|
|
|
- jsonObject.put("qrCode", qrCode);
|
|
|
- jsonObject.put("icon",workEntity.getIcon());
|
|
|
- jsonObject.put("name",workEntity.getName());
|
|
|
- if (ObjectUtil.isNotEmpty(workEntity.getPassword())){
|
|
|
- jsonObject.put("password", workEntity.getPassword());
|
|
|
- }
|
|
|
|
|
|
- String ossKeyPath = configConstant.ossBasePath + workEntity.getId() + "/someData.json";
|
|
|
- workEntity.setQrCode(qrCode);
|
|
|
- workEntity.setShare(shareUrl);
|
|
|
- workService.update(workEntity);
|
|
|
-
|
|
|
- JSONArray scenesJson = new JSONArray();
|
|
|
- for (Map<String, Object> scene : scenes) {
|
|
|
- JSONObject SomeDataSceneDataJsonObject = JSONObject.parseObject(someDataSceneDatContent);
|
|
|
- SomeDataSceneDataJsonObject.putAll(scene);
|
|
|
- scenesJson.add(JSON.toJSON(SomeDataSceneDataJsonObject));
|
|
|
- }
|
|
|
- jsonObject.remove("scenes");
|
|
|
- jsonObject.put("scenes",JSON.toJSON(scenesJson));
|
|
|
-
|
|
|
- try {
|
|
|
- fileAndOssUtil.upload(jsonObject.toJSONString().getBytes(), ossKeyPath);
|
|
|
-
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- String ossUrl = ossUtil.calculateUrl("") + ossKeyPath;
|
|
|
- log.info("ossSomeData:{}", ossUrl);
|
|
|
- return jsonObject;
|
|
|
- }
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|