Преглед изворни кода

获取四维场景时, 过滤激光、点云、obj数据

wuweihao пре 2 година
родитељ
комит
5ec933e1fe

+ 2 - 3
720yun_fd_manage/gis_application/src/main/resources/application-locSit.properties

@@ -93,11 +93,10 @@ spring.rabbitmq.template.mandatory=true
 oss.point=http://oss-cn-shenzhen.aliyuncs.com
 oss.key=LTAIUrvuHqj8pvry
 oss.secrecy=JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4
-oss.bucket=4dkankan
+oss.bucket=oss-xiaoan
 oss.type=oss
 oss.file.path=${project.name}/
-# \u56DB\u7EF4\u770B\u770Boss cdn\u57DF\u540D
-oss.domain=https://4dkk.4dage.com/
+oss.domain=https://oss-xiaoan.oss-cn-shenzhen.aliyuncs.com/
 
 
 # swagger2 \u8BBE\u7F6E\u5168\u5C40\u5B57\u4F53\u683C\u5F0F\u4E3Autf-8

+ 2 - 2
720yun_fd_manage/gis_common/src/main/java/com/gis/common/util/EncryptUtils.java

@@ -146,10 +146,10 @@ public class EncryptUtils {
         // CBFA2F1815E8828F9E28D73B5D6A57836BFECEDEBEDA387F
 //        String str = "221.4.210.172:biguiyuan";
 
-        System.out.println(createAppId("4dkk_v4", "api"));
+//        System.out.println(createAppId("4dkk_v4", "api"));
 
 
 //        System.out.println(desEncrypt(str));
-        System.out.println(desDecrypt("CBFA2F1815E8828F9E28D73B5D6A57836BFECEDEBEDA387F"));
+        System.out.println(desDecrypt("2cd4167b1c627f11a6ce4ce7cadf1b18"));
     }
 }

+ 3 - 1
720yun_fd_manage/gis_service/src/main/java/com/gis/service/FodderService.java

@@ -22,7 +22,7 @@ public interface FodderService extends IBaseService<FodderEntity, Long> {
 
     Result search(FodderPageDto param);
 
-    Result selectFodderPano(PageDto param, String workId);
+//    Result selectFodderPano(PageDto param, String workId);
 
 
 
@@ -33,4 +33,6 @@ public interface FodderService extends IBaseService<FodderEntity, Long> {
 
     // 2022-09-15
     List<FodderEntity> batchBySceneCodes(List<String> sceneCodes);
+
+    List<FodderEntity> findByType(String type);
 }

+ 2 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/TestService.java

@@ -13,4 +13,6 @@ public interface TestService  {
     Result batchReplaceSomeData(String isBatch);
 
     Result getSceneCode(String ids);
+
+    Result updatePanoTourXml(String all);
 }

+ 1 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/WorkService.java

@@ -39,4 +39,5 @@ public interface WorkService extends IBaseService<WorkEntity, String> {
     WorkEntity findByIdForUpdate(String id);
 
 
+    List<WorkEntity> findByStatus(int i);
 }

+ 33 - 25
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -31,6 +31,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.multipart.MultipartFile;
+import tk.mybatis.mapper.entity.Condition;
 
 import javax.transaction.Transactional;
 import java.awt.image.BufferedImage;
@@ -268,31 +269,31 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
     }
 
 
-    @Override
-    public Result selectFodderPano(PageDto param, String workId) {
-        startPage(param);
-
-        List<FodderEntity> list = entityMapper.searchPano(param, getUserNameForToken());
-        PageInfo<FodderEntity> pageInfo = new PageInfo<>(list);
-
-
-        // 作品场景查重
-        List<String> useScenes = sceneService.strFindByWorkId(workId, "pano");
-        // 存更新后的数据
-        List<FodderEntity> result = new ArrayList<>();
-
-        List<FodderEntity> fodderList = pageInfo.getList();
-        for (FodderEntity entity : fodderList) {
-            String sceneCode = entity.getSceneCode();
-            if (useScenes.contains(sceneCode)) {
-                entity.setIsUse(1);
-            }
-            result.add(entity);
-        }
-        pageInfo.setList(result);
-
-        return Result.success(pageInfo);
-    }
+//    @Override
+//    public Result selectFodderPano(PageDto param, String workId) {
+//        startPage(param);
+//
+//        List<FodderEntity> list = entityMapper.searchPano(param, getUserNameForToken());
+//        PageInfo<FodderEntity> pageInfo = new PageInfo<>(list);
+//
+//
+//        // 作品场景查重
+//        List<String> useScenes = sceneService.strFindByWorkId(workId, "pano");
+//        // 存更新后的数据
+//        List<FodderEntity> result = new ArrayList<>();
+//
+//        List<FodderEntity> fodderList = pageInfo.getList();
+//        for (FodderEntity entity : fodderList) {
+//            String sceneCode = entity.getSceneCode();
+//            if (useScenes.contains(sceneCode)) {
+//                entity.setIsUse(1);
+//            }
+//            result.add(entity);
+//        }
+//        pageInfo.setList(result);
+//
+//        return Result.success(pageInfo);
+//    }
 
     @Override
     public Result checkStatus(String ids) {
@@ -337,6 +338,13 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         return entityMapper.batchBySceneCodes(sqlStr);
     }
 
+    @Override
+    public List<FodderEntity> findByType(String type) {
+        Condition condition = new Condition(FodderEntity.class);
+        condition.and().andEqualTo("type", type);
+        return this.findAll(condition);
+    }
+
 
     /**
      * 2022-05-31 by owen

+ 185 - 12
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/TestServiceImpl.java

@@ -1,15 +1,20 @@
 package com.gis.service.impl;
 
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.gis.common.constant.ConfigConstant;
+import com.gis.common.constant.ErrorEnum;
+import com.gis.common.exception.BaseRuntimeException;
 import com.gis.common.util.AliyunOssUtil;
 import com.gis.common.util.FileUtils;
 import com.gis.common.util.Result;
+import com.gis.domain.entity.FodderEntity;
 import com.gis.domain.entity.WorkEntity;
+import com.gis.service.FodderService;
 import com.gis.service.TestService;
 import com.gis.service.WorkService;
 import com.gis.util.ReplaceVo;
@@ -18,7 +23,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.util.*;
@@ -47,21 +51,12 @@ public class TestServiceImpl implements TestService {
     @Autowired
     WorkService workService;
 
+    @Autowired
+    FodderService fodderService;
 
 
 
 
-//    public Result upload(MultipartFile file) {
-//        Map<String, Object>  map = fileUtils.renameUploadOssBye(file, configConstant.ossBasePath, configConstant.ossDomain, "icon/");
-//        IconEntity entity = new IconEntity();
-//        entity.setFileName((String) map.get("fileName"));
-//        Object ossUrl = map.get("ossUrl");
-//        entity.setOssPath(ossUrl.toString());
-//
-//
-//        return Result.success(ossUrl);
-//    }
-
     @Override
     public Result batchReplaceSomeData(String isBatch) {
         String basePath = "F:\\work\\四维-全景看看\\data\\";
@@ -124,6 +119,184 @@ public class TestServiceImpl implements TestService {
         return Result.success();
     }
 
+    /**
+     * 2022-10-21
+     * @param isAll
+     * @return
+     */
+    @Override
+    public Result updatePanoTourXml(String isAll) {
+
+        // 更新素材表字段
+//        updateFodderTour(isAll);
+        // 作品创建tour.xml
+        createWorkTour(isAll);
+
+        return Result.success("更新完成");
+    }
+
+    /**
+     * 2022-10-21
+     * 作品创建tour.xml
+     * @param isAll
+     */
+    private void createWorkTour(String isAll) {
+
+        // 1. 获取作品表
+
+        List<WorkEntity> list = workService.findByStatus(1);
+        log.info("作品数量:{}", list.size());
+        // 2. 上传tour.xml
+        int n = 0;
+        for (WorkEntity workEntity : list) {
+            String id = workEntity.getId();
+            String sceneCodes = workEntity.getSceneCodes();
+            createTour(sceneCodes, id);
+            n ++;
+            log.info("更新完成第:{} 个, 作品码为:{}", n, id);
+            if (!"1".equals(isAll)){
+                break;
+            }
+
+        }
+    }
+
+    private void createTour(String sceneCodes, String id) {
+        List<String> scenes = filterSceneCodesByPano(sceneCodes);
+        List<FodderEntity> list = fodderService.batchBySceneCodes(scenes);
+
+        // 读取tour.xml模板
+        String baseTour = getBaseTour();
+        StringBuilder builder = new StringBuilder();
+        builder.append(baseTour).append("\r\n");
+        for (FodderEntity entity : list) {
+            String tour = entity.getTour();
+            builder.append(tour).append("\r\n");
+        }
+
+        // 添加结束标签
+        builder.append("</krpano>");
+
+
+        String tourPath = configConstant.serverBasePath + id + "/tour.xml";
+        FileUtil.writeUtf8String(builder.toString(), tourPath);
+        log.info("作品tour.xml写入完成");
+
+        // 上传oss
+        BaseRuntimeException.isTrue(!FileUtil.isFile(tourPath), ErrorEnum.FAILURE_CODE_3103.code(), "服务器tour.xml文件不存在");
+
+        String ossKeyPath = configConstant.ossBasePath + id + "/tour.xml";
+        aliyunOssUtil.upload(tourPath, ossKeyPath);
+        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;
+    }
+
+
+    /**
+     * 过滤720场景
+     * @param sceneCodes
+     * @return
+     */
+    private List<String> filterSceneCodesByPano(String sceneCodes){
+        if (StrUtil.isBlank(sceneCodes)){
+            return new ArrayList<>();
+        }
+        String[] split = sceneCodes.split(",");
+        List<String> list = new ArrayList<>();
+        for (String s : split) {
+            if (s.startsWith("fd720_")){
+                list.add(s);
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 2022-10-21
+     * 更新素材表字段
+     * @param isAll
+     */
+    private void updateFodderTour(String isAll) {
+
+        // 1.获取素材表,type=pano
+        List<FodderEntity> list = fodderService.findByType("pano");
+        log.info("场景数量:{}", list.size());
+        // 2.下载对应的tour.xml
+        String basePath = configConstant.serverBasePath;
+        int n = 0;
+        for (FodderEntity fodderEntity : list) {
+            n ++;
+            String tour = fodderEntity.getTour();
+            if (StrUtil.isNotBlank(tour)){
+                continue;
+            }
+            String ossPath = fodderEntity.getOssPath();
+            String tourPath = ossPath + "/vtour/tour.xml";
+            String sceneCode = fodderEntity.getSceneCode();
+            String locPath = basePath + sceneCode + "/vtour/tour.xml";
+            log.info("正在执行第:{} 个, 场景码:{}, oss路径:{}", n, sceneCode, tourPath);
+            try {
+                HttpUtil.downloadFile(tourPath, locPath);
+                String tourXmlScene = getTourXmlScene(sceneCode);
+
+                fodderEntity.setTour(tourXmlScene);
+                fodderEntity.setUpdateTime(new Date());
+                fodderService.update(fodderEntity);
+
+                log.info("更新完成第:{} 个, 场景码为:{}", n, sceneCode);
+
+
+            } catch (Exception e) {
+//                e.printStackTrace();
+                // 遇到oss没有tour.xml 直接跳过, 不用更新此场景
+                log.error("此场景不存在, 执行第:{} 个, 场景码:{}, oss路径:{}", n, sceneCode, tourPath);
+                continue;
+            }
+
+            // isAll != 1 只更新一个
+            if (!"1".equals(isAll)){
+                break;
+            }
+
+
+
+
+        }
+
+
+
+    }
+
+
+    // 获取切图后的tour.xml
+    private String getTourXmlScene(String code) {
+        log.info("处理tour.xml");
+        String tourPath = configConstant.serverBasePath + code + "/vtour/tour.xml";
+        log.info("tourPath: {}", tourPath);
+        BaseRuntimeException.isTrue(!FileUtil.isFile(tourPath), null, code + "_tour.xml文件不存在");
+
+        String tour = FileUtil.readString(tourPath, "utf-8");
+        tour = StrUtil.subAfter(tour, "</action>", true);
+        tour = StrUtil.subBefore(tour, "</krpano>", true);
+        String trim = StrUtil.trim(tour);
+        // log.info("trim: {}", trim);
+        BaseRuntimeException.isTrue(StrUtil.isAllBlank(trim), null, code + "_tour.xml文件不存在");
+
+        // 2022-09-15 加入相对路径
+        String basePath = "%CURRENTXML%../" + code + "/vtour/panos/";
+        trim = trim.replaceAll("panos/", basePath);
+
+        return trim;
+    }
+
     // 下载初始场景图片
     private void downloadThumb(Map<String, String> iconMap){
         String basePath = "F:\\work\\项目-科学城(广州)信科集团-3D合作\\thumb";

+ 13 - 2
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/WorkServiceImpl.java

@@ -28,6 +28,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
+import tk.mybatis.mapper.entity.Condition;
 
 import java.io.IOException;
 import java.time.LocalDate;
@@ -238,6 +239,14 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
     }
 
     @Override
+    public List<WorkEntity> findByStatus(int i) {
+        Condition condition = new Condition(WorkEntity.class);
+        condition.and().andEqualTo("status", i);
+
+        return this.findAll(condition);
+    }
+
+    @Override
     public Result edit(SomeDataDto param) {
 
 
@@ -324,7 +333,7 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
 
 
     private String getBaseTour(){
-        String baseTourPath = configConstant.serverBasePath + "tour.xml";
+        String baseTourPath = configConstant.serverBasePath + "baseData/tour.xml";
         String s = FileUtil.readString(baseTourPath, "utf-8");
         // 结束标签置空, 方便操作
         s = s.replace("</krpano>", "");
@@ -460,7 +469,9 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
         // type=11, 计算成功的场景
         reqParam.put("type", "11");
         // 2022-2-10 excludeSceneSource=4, 过滤激光场景数据
-        reqParam.put("excludeSceneSource", 4);
+        // reqParam.put("excludeSceneSource", 4);
+        // 2022-10-21 过滤激光场景数据 点云、obj
+        reqParam.put("sceneSource", "1,3");
 
         HashMap<String, String> headers = new HashMap<>();
         String token = getToken();

+ 13 - 12
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/TestController.java

@@ -52,8 +52,6 @@ public class TestController extends BaseController {
     @Autowired
     FileUtils fileUtils;
 
-//    @Autowired
-//    SceneService sceneService;
 
     @Autowired
     SceneMapper sceneMapper;
@@ -232,6 +230,19 @@ public class TestController extends BaseController {
     }
 
 
+    /**
+     * 2022-10-21
+     * @param
+     * @return
+     * 逻辑 1.20需求
+     * 1.将每个场景的tour里的值添加到对应表的数据库tour的字段里
+     * 2.查询作品表,再oss里找出对应的someData.json文件,查找出对应的场景, 把绑定场景的tour值封装好一个全局的tour.xml
+     */
+    @GetMapping("updatePanoTourXml")
+    @ApiOperation(value = "批量更新全景图Tour", notes = "isAll:不传为更新1个, 传1为更新全部")
+    public Result updatePanoTourXml(String isAll){
+        return testService.updatePanoTourXml(isAll);
+    }
 
 
 
@@ -248,14 +259,4 @@ public class TestController extends BaseController {
 
 
 
-    @Test
-    public void test2(){
-        String [] suffixCheck = {"dbf","shp","shx","prj"};
-        String fileName = "xxx.shp";
-
-
-
-    }
-
-
 }