|
@@ -1,5 +1,7 @@
|
|
|
package com.gis.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
@@ -27,6 +29,8 @@ import com.gis.domain.entity.ScenePanoEntity;
|
|
|
import com.gis.domain.entity.WorkEntity;
|
|
|
import com.gis.domain.entity.WorkHotsFodderEntity;
|
|
|
import com.gis.domain.vo.ReportWorkVo;
|
|
|
+import com.gis.domain.vo.WorkNavigationVo;
|
|
|
+import com.gis.domain.vo.WorkVo;
|
|
|
import com.gis.mapper.*;
|
|
|
import com.gis.oss.util.FileAndOssUtil;
|
|
|
import com.gis.oss.util.FileUtils;
|
|
@@ -56,6 +60,7 @@ import java.io.IOException;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -116,9 +121,22 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper,WorkEntity> implemen
|
|
|
ScenePanoService scenePanoService;
|
|
|
@Autowired
|
|
|
RabbitMqProducerUtil rabbitMqProducer;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkNavigationSettingService workNavigationSettingService;
|
|
|
+
|
|
|
+ @Lazy
|
|
|
+ @Autowired
|
|
|
+ private WorkNavigationService workNavigationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KrpanoService krpanoService;
|
|
|
+
|
|
|
+
|
|
|
@Value("${queue.relics-update-name-queue:#{null}}")
|
|
|
String relicsUpdateNameQueue;
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public Result search(AgePageDto param, boolean isAdmin) {
|
|
|
PageHelper.startPage(param.getPageNum(), param.getPageSize(), true);
|
|
@@ -178,19 +196,23 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper,WorkEntity> implemen
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Result<WorkEntity> entityAdd() {
|
|
|
+ public Result<WorkEntity> entityAdd(String workId) {
|
|
|
+
|
|
|
+ WorkEntity entity = null;
|
|
|
+ if(StrUtil.isEmpty(workId)){
|
|
|
+ entity = new WorkEntity();
|
|
|
+ entity.setId(SnowFlakeUUidUtils.getUuid("WK"));
|
|
|
+ entity.setUserId(userRequest.getUserNameForToken());
|
|
|
+ entity.setStatus(0);
|
|
|
+ Date date = new Date();
|
|
|
+ entity.setCreateTime(date);
|
|
|
+ entity.setUpdateTime(date);
|
|
|
+ this.save(entity);
|
|
|
+ }else{
|
|
|
+ entity = this.getById(workId);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- WorkEntity entity = new WorkEntity();
|
|
|
- entity.setId(SnowFlakeUUidUtils.getUuid("WK"));
|
|
|
- entity.setUserId(userRequest.getUserNameForToken());
|
|
|
- entity.setStatus(0);
|
|
|
- Date date = new Date();
|
|
|
- entity.setCreateTime(date);
|
|
|
- entity.setUpdateTime(date);
|
|
|
-
|
|
|
- this.save(entity);
|
|
|
-
|
|
|
String id = entity.getId();
|
|
|
log.info("创建对象完成: {}", id);
|
|
|
|
|
@@ -278,7 +300,9 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper,WorkEntity> implemen
|
|
|
// 删除服务器器文件
|
|
|
fileUtils.del(entity.getId());
|
|
|
|
|
|
- this.updateById(entity);
|
|
|
+// this.updateById(entity);
|
|
|
+
|
|
|
+ this.removeById(id);
|
|
|
|
|
|
// 删除redis
|
|
|
redisUtil.delete(RedisConstant.WORK_ID + id);
|
|
@@ -504,7 +528,7 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper,WorkEntity> implemen
|
|
|
List<FodderEntity> list = fodderService.batchBySceneCodes(getSceneCodesList(scenes));
|
|
|
|
|
|
// 读取tour.xml模板
|
|
|
- String baseTour = getBaseTour();
|
|
|
+ String baseTour = krpanoService.getBaseTour();
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
builder.append(baseTour).append("\r\n");
|
|
|
for (FodderEntity entity : list) {
|
|
@@ -543,7 +567,7 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper,WorkEntity> implemen
|
|
|
List<FodderEntity> list = fodderService.batchBySceneCodes(getSceneCodesList(scenes));
|
|
|
|
|
|
// 读取tour.xml模板
|
|
|
- String baseTour = getBaseTour();
|
|
|
+ String baseTour = krpanoService.getBaseTour();
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
builder.append(baseTour).append("\r\n");
|
|
|
for (FodderEntity entity : list) {
|
|
@@ -567,13 +591,7 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper,WorkEntity> implemen
|
|
|
log.info("tour.xml上传完成 : {}", ossKeyPath);
|
|
|
}
|
|
|
|
|
|
- private String getBaseTour(){
|
|
|
- String baseTourPath = configConstant.serverBasePath + "baseData/tour.xml";
|
|
|
- String s = FileUtil.readString(baseTourPath, "utf-8");
|
|
|
- // 结束标签置空, 方便操作
|
|
|
- s = s.replace("</krpano>", "");
|
|
|
- return s;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -1235,7 +1253,7 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper,WorkEntity> implemen
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result addWork(WorkAddDto workAddDto) {
|
|
|
+ public Result<WorkVo> addWork(WorkAddDto workAddDto) {
|
|
|
|
|
|
WorkEntity entity = new WorkEntity();
|
|
|
entity.setId(SnowFlakeUUidUtils.getUuid("WK"));
|
|
@@ -1244,63 +1262,87 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper,WorkEntity> implemen
|
|
|
Date date = new Date();
|
|
|
entity.setCreateTime(date);
|
|
|
entity.setUpdateTime(date);
|
|
|
- entity.setIcon(workAddDto.getIcon());
|
|
|
-
|
|
|
+ entity.setName("无标题");
|
|
|
+ entity.setIcon(workAddDto.getSceneDTOList().get(0).getIcon());
|
|
|
String id = entity.getId();
|
|
|
log.info("创建对象完成: {}", id);
|
|
|
|
|
|
// 创建二维码、二维码url
|
|
|
- String shareUrlZH = configConstant.domain4dKK + "/panorama/showMobile.html?lang=zh&id=" + id;
|
|
|
- String shareUrlEN = configConstant.domain4dKK + "/panorama/showMobile.html?lang=en&id=" + id;
|
|
|
- String qrZHCode = qrCodeUtils.generateLogoQrCode(shareUrlZH, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain, id,"zh");
|
|
|
- String qrENCode = qrCodeUtils.generateLogoQrCode(shareUrlEN, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain, id,"en");
|
|
|
- entity.setQrCode(qrZHCode);
|
|
|
- entity.setQrENCode(qrENCode);
|
|
|
+// String shareUrlZH = configConstant.domain4dKK + "/panorama/showMobile.html?lang=zh&id=" + id;
|
|
|
+// String shareUrlEN = configConstant.domain4dKK + "/panorama/showMobile.html?lang=en&id=" + id;
|
|
|
+// String qrZHCode = qrCodeUtils.generateLogoQrCode(shareUrlZH, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain, id,"zh");
|
|
|
+// String qrENCode = qrCodeUtils.generateLogoQrCode(shareUrlEN, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain, id,"en");
|
|
|
+// entity.setQrCode(qrZHCode);
|
|
|
+// entity.setQrENCode(qrENCode);
|
|
|
this.save(entity);
|
|
|
|
|
|
- WorkOpeningTipEntity workOpeningTipEntity=new WorkOpeningTipEntity();
|
|
|
- workOpeningTipEntity.setWorkId(entity.getId());
|
|
|
- workOpeningTipEntity.setIsRemind(1);
|
|
|
- workOpeningTipEntity.setRemindTime(1);
|
|
|
- workOpeningTipService.save(workOpeningTipEntity);
|
|
|
-
|
|
|
- WorkOpeningAnimationEntity workOpeningAnimationEntity=new WorkOpeningAnimationEntity();
|
|
|
- workOpeningAnimationEntity.setIsShowOpeningAnimation(true);
|
|
|
- workOpeningAnimationEntity.setOpeningAnimationType(1);
|
|
|
- workOpeningAnimationEntity.setWorkId(entity.getId());
|
|
|
- workOpeningAnimationService.save(workOpeningAnimationEntity);
|
|
|
-
|
|
|
-
|
|
|
- WorkCoverTypeEntity workCoverTypeEntity=new WorkCoverTypeEntity();
|
|
|
- workCoverTypeEntity.setWorkId(entity.getId());
|
|
|
- workCoverTypeService.save(workCoverTypeEntity);
|
|
|
-
|
|
|
- WorkLogoEntity workLogoEntity=new WorkLogoEntity();
|
|
|
- workLogoEntity.setWorkId(entity.getId());
|
|
|
- workLogoService.save(workLogoEntity);
|
|
|
-
|
|
|
- WorkCustomMaskEntity earth=new WorkCustomMaskEntity();
|
|
|
- earth.setWorkId(entity.getId());
|
|
|
- earth.setType("earth");
|
|
|
- workCustomMaskService.save(earth);
|
|
|
- WorkCustomMaskEntity sky=new WorkCustomMaskEntity();
|
|
|
- sky.setWorkId(entity.getId());
|
|
|
- sky.setType("sky");
|
|
|
- workCustomMaskService.save(sky);
|
|
|
-
|
|
|
- WorkCustomButtonEntity phone=new WorkCustomButtonEntity();
|
|
|
- phone.setWorkId(entity.getId());
|
|
|
- phone.setName("电话");
|
|
|
- phone.setType("phone");
|
|
|
- workCustomButtonService.save(phone);
|
|
|
-
|
|
|
- WorkCustomButtonEntity link=new WorkCustomButtonEntity();
|
|
|
- link.setWorkId(entity.getId());
|
|
|
- link.setName("链接");
|
|
|
- link.setType("link");
|
|
|
- workCustomButtonService.save(link);
|
|
|
+ //创建tour.xml
|
|
|
+ krpanoService.saveTourXml(entity);
|
|
|
+
|
|
|
+ //初始化数据库
|
|
|
+ this.initData(workAddDto, entity);
|
|
|
+
|
|
|
+ return Result.success(BeanUtil.toBean(entity, WorkVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ 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.initCustomButtom(entity.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 initCustomButtom(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));
|
|
|
|
|
|
- return Result.success(entity);
|
|
|
}
|
|
|
|
|
|
@Override
|