瀏覽代碼

720yun 恒大 首次提交

wuweihao 4 年之前
父節點
當前提交
41155215ac

+ 1 - 1
cms_pano_consumer/src/main/resources/application-uat.properties

@@ -57,7 +57,7 @@ oss.secrey=mqVRTWbWcn4sNMoWmnRq6eToWr9BIy
 oss.bucket=fcb-vrkanfang-uat
 oss.type=oss
 oss.file.path=cms_pano_fcb/
-oss.domain=http://vr-web02-uat.fcb.com.cn/
+oss.domain=https://vr-web02-uat.fcb.com.cn/
 
 
 #log

+ 0 - 1
cms_pano_fcb/gis_application/src/main/resources/application-dev.properties

@@ -89,7 +89,6 @@ logging.level.com.gis=debug
 # 上传文件保存路径
 # 本地保存路径
 file.path=F:\\test\\ngin\\${project.name}_data\\
-server.domain=192
 
 
 

+ 0 - 1
cms_pano_fcb/gis_application/src/main/resources/application-sit.properties

@@ -83,7 +83,6 @@ logging.level.com.gis=debug
 # 上传文件保存路径
 # 本地保存路径 nas目录
 file.path=/mnt/${project.name}_data/
-server.domain=192
 
 
 

+ 0 - 1
cms_pano_fcb/gis_application/src/main/resources/application-test.properties

@@ -100,7 +100,6 @@ logging.level.com.gis=debug
 # 上传文件保存路径
 # 本地保存路径 nas目录
 file.path=/mnt/${project.name}_data/
-server.domain=192
 
 
 

+ 7 - 2
cms_pano_fcb/gis_application/src/main/resources/application-uat.properties

@@ -66,7 +66,7 @@ oss.secrey=mqVRTWbWcn4sNMoWmnRq6eToWr9BIy
 oss.bucket=fcb-vrkanfang-uat
 oss.type=oss
 oss.file.path=${project.name}/
-oss.domain=http://vr-web02-uat.fcb.com.cn/
+oss.domain=https://vr-web02-uat.fcb.com.cn/
 
 
 #log
@@ -78,7 +78,12 @@ logging.level.com.gis=debug
 # 上传文件保存路径
 # 本地保存路径
 file.path=/mnt/${project.name}_data/
-server.domain=192
+
+# swagger login
+# 开启basic登录认证
+knife4j.basic.enable=true
+knife4j.basic.username=owen
+knife4j.basic.password=owen
 
 
 

+ 29 - 8
cms_pano_fcb/gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -372,6 +372,7 @@ public class FileUtils {
     }
 
     /**
+     * 使用opencv 生成缩略图
      * 压缩图片
      * 需要图片比例是2:1,否则图片压出来会变形
      */
@@ -405,6 +406,13 @@ public class FileUtils {
     }
 
 
+    /**
+     * 使用java 生成缩略图
+     * @param inputFilePath
+     * @param ossBasePath
+     * @param ossDomain
+     * @return
+     */
     public  String compressImgAndUploadOss2(String inputFilePath, String ossBasePath, String ossDomain){
         String serverBasePath = StringUtils.substringBeforeLast(inputFilePath, "/");
 
@@ -414,15 +422,28 @@ public class FileUtils {
 
         // 保存图片位置
         String saveCompressImgPath = serverBasePath + fileName;
-        Img.from(new File(inputFilePath)).scale(300, 150).write(new File(saveCompressImgPath));
-        log.info("图片压缩成功: " + saveCompressImgPath);
+        String ossUrl = null;
+        try {
+            Img.from(new File(inputFilePath)).scale(600, 300).write(new File(saveCompressImgPath));
+            log.info("图片压缩成功: " + saveCompressImgPath);
+
+            if (FileUtil.isFile(saveCompressImgPath)) {
+                // 上传oss
+                String ossPath = ossBasePath + "image" + fileName;
+                log.info("ossPath: " + ossPath);
+                asyncTask.uploadOss(saveCompressImgPath, ossPath);
+                ossUrl = ossDomain + ossPath;
+                log.info("图片上传成功: " + ossUrl);
+            } else {
+                log.error("缩略图不存在: " + saveCompressImgPath);
+            }
+
+        } catch (Exception e) {
+            log.error("图片格式有误,不支持此图片");
+            e.printStackTrace();
+        }
+
 
-        // 上传oss
-        String ossPath = ossBasePath + "image/" + fileName;
-        log.info("ossPath: " + ossPath);
-        asyncTask.uploadOss(saveCompressImgPath, ossPath);
-        String ossUrl = ossDomain + ossPath;
-        log.info("图片上传成功: " + ossUrl);
         return ossUrl;
     }
 

+ 3 - 0
cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/dto/SceneRroPageDto.java

@@ -18,4 +18,7 @@ public class SceneRroPageDto extends PageDto {
     @NotBlank(message = "楼盘id不能为空")
     @ApiModelProperty(value = "楼盘id")
     private String houseId;
+
+    @ApiModelProperty(value = "状态,0:计算完成的")
+    private String status;
 }

+ 7 - 0
cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/entity/SceneEntity.java

@@ -73,4 +73,11 @@ public class SceneEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "恒大Id")
     private String hengdaId;
 
+    @ApiModelProperty(value = "排序(序号小排前面)")
+    private Integer sort;
+
+    @ApiModelProperty(value =  "初始视觉")
+    private String initVisual;
+
+
 }

+ 8 - 1
cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/SceneMapper.java

@@ -37,14 +37,21 @@ public interface SceneMapper extends IBaseMapper<SceneEntity, String> {
     @Select("select * from tb_scene where is_delete = 0 and vr_model_id = #{vrModelId}")
     SceneEntity findByVrModelId(String vrModelId);
 
+    @Select("select * from tb_scene where is_delete = 0 and vr_model_id = #{vrModelId}")
+    List<SceneEntity> findByVrModelId2(String vrModelId);
+
     @Select("select * from tb_scene where is_delete = 0 and vr_model_id = #{vrModelId} and house_id = #{houseId}")
     SceneEntity findByVrModelIdAndHouseId(String vrModelId, String houseId);
 
     @Select("select * from tb_scene where is_delete = 0 and is_index = 1 and house_id = #{houseId} ")
-    SceneEntity getIndex(String houseId);
+    List<SceneEntity> getIndex(String houseId);
 
     @Select("select * from tb_scene where is_delete = 0 and house_id = #{houseId}")
     List<SceneEntity> findByHouseId(String houseId);
 
+    @Update("UPDATE tb_scene SET sort=#{sort} where id = #{id}")
+    void setSortById(String id, String sort);
 
+    @Select("select scene_code from tb_scene where is_delete = 0 and status = #{status} and type = #{type} and house_id = #{houseId}")
+    List<String> getVrSceneCode(String houseId, String status, String type);
 }

+ 1 - 1
cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/provider/SceneProvider.java

@@ -33,7 +33,7 @@ public class SceneProvider {
             sql.append(" and ( status = '").append(status).append("' )");
         }
 
-        sql.append(" order by is_index, create_time desc");
+        sql.append(" order by sort asc, create_time asc");
 
         log.info("sql: {}", sql.toString());
         return sql.toString();

+ 2 - 1
cms_pano_fcb/gis_service/src/main/java/com/gis/feign/SceneProFeign.java

@@ -2,6 +2,7 @@ package com.gis.feign;
 
 import com.gis.common.util.Result;
 import com.gis.domain.dto.PageDto;
+import com.gis.domain.dto.SceneRroPageDto;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -15,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
 public interface SceneProFeign {
 
     @PostMapping(value = "/api/scene/findSceneListPage", consumes = MediaType.APPLICATION_JSON_VALUE, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
-    Result findByList(@RequestBody PageDto param, @RequestHeader(value = "token", name = "token", required = true) String token);
+    Result findByList(@RequestBody SceneRroPageDto param, @RequestHeader(value = "token", name = "token", required = true) String token);
 
 
 }

+ 5 - 0
cms_pano_fcb/gis_service/src/main/java/com/gis/service/SceneService.java

@@ -7,6 +7,7 @@ import com.gis.domain.entity.SceneEntity;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -42,4 +43,8 @@ public interface SceneService extends IBaseService<SceneEntity, String> {
     Result getIndex(String houseId);
 
     Result findByHouseId(String houseId);
+
+    Result setSort(Map<String, String> param);
+
+    Result getVrSceneCode(String houseId, String status, String type);
 }

+ 68 - 38
cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -32,6 +32,7 @@ import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -107,8 +108,8 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
             log.info("equalsIgnoreCase1:" + type.equalsIgnoreCase("jpg"));
             log.info("equalsIgnoreCase2:" + type.equalsIgnoreCase("jpeg"));
 
-            // png 需要转 jpg
-            if (type.equalsIgnoreCase("png")) {
+            // 全景图只支持jpg图片格式
+            if (!type.equalsIgnoreCase("jpg")) {
                 log.error("图片格式错误,只支持jpg图片类型, type: " + type);
                 return Result.failure(7002, "只支持jpg图片类型");
             }
@@ -133,15 +134,18 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
 
             // 缩略图,使用切图那个thumb.jpg
             // 压缩图片并上传oss
-//            String iconPath = fileUtils.compressImgAndUploadOss2(panoPath, configConstant.ossBasePath, configConstant.ossDomain);
-            String iconPath = fileUtils.compressImgAndUploadOss(panoPath, configConstant.ossBasePath, configConstant.ossDomain);
+            String iconPath = fileUtils.compressImgAndUploadOss2(panoPath, configConstant.ossBasePath, configConstant.ossDomain);
+//            String iconPath = fileUtils.compressImgAndUploadOss(panoPath, configConstant.ossBasePath, configConstant.ossDomain);
 
             entity.setIcon(iconPath);
             entity.setStatus(1);
             entity.setHouseId(houseId);
             entity.setType(sceneType);
             entity.setHengdaId(hengdaId);
-            entity.setFileName(file.getOriginalFilename());
+            // 出来文件名不要后缀
+            String originalFilename = file.getOriginalFilename();
+            originalFilename = StringUtils.substringBeforeLast(originalFilename,".");
+            entity.setFileName(originalFilename);
             entity.setSceneTitle(entity.getFileName());
 
             // /hengda.html?m=场景码&prodId=房车宝楼盘ID&houseId=自己维护的楼盘ID
@@ -150,8 +154,9 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
             entity.setWebSite(webSite);
 
             // 设置初始场景
-            SceneEntity index = entityMapper.getIndex(houseId);
-            if (index == null) {
+//            SceneEntity index = entityMapper.getIndex(houseId);
+            List<SceneEntity> index = entityMapper.getIndex(houseId);
+            if (index.size() == 0) {
                 log.info("需要设置更新场景码到VR项目");
                 entity.setIsIndex(1);
 
@@ -181,40 +186,19 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
 
         } catch (IOException e) {
             e.printStackTrace();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
         }
 
         return Result.success(entity);
     }
 
 
-    public String compressImgAndUploadOss(String cmd) throws IOException, InterruptedException {
-        // openCV生成缩略图
-        CmdUtils.cmdThumb(cmd);
-
-
-
-        return null;
-    }
-
     @Test
     public void test2(){
-        String type = "jpg";
-        System.out.println(type.equalsIgnoreCase("jpg"));
+        String type = "aa.jpg";
+        System.out.println(StringUtils.substringBeforeLast(type, "."));
         System.out.println(type.equalsIgnoreCase("jpeg"));
 
-        if (!type.equalsIgnoreCase("jpg")) {
-            log.info("111111111");
-        }
 
-        if (!type.equalsIgnoreCase("jpeg")) {
-            log.info("2222222");
-        }
-
-        if (!type.equalsIgnoreCase("jpeg") || !type.equalsIgnoreCase("jpg")) {
-            log.info("33333");
-        }
     }
 
     @Override
@@ -302,7 +286,11 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
 
     @Override
     public Result getIndex(String houseId) {
-        return Result.success(entityMapper.getIndex(houseId));
+        List<SceneEntity> index = entityMapper.getIndex(houseId);
+        if (index.size() == 0) {
+            return Result.success();
+        }
+        return Result.success(index.get(0));
     }
 
     @Override
@@ -310,6 +298,25 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
         return Result.success(entityMapper.findByHouseId(houseId));
     }
 
+    @Override
+    public Result setSort(Map<String, String> param) {
+        log.info("sort size: " + param.size());
+        for (Map.Entry<String, String> m : param.entrySet()) {
+            String id = m.getKey();
+            String sort = m.getValue();
+            log.info("id: " + id);
+            log.info("sort: " + sort);
+            entityMapper.setSortById(id, sort);
+        }
+
+        return Result.success();
+    }
+
+    @Override
+    public Result getVrSceneCode(String houseId, String status, String type) {
+        return Result.success(entityMapper.getVrSceneCode(houseId, status, type));
+    }
+
     /**
      * 添加VR模型
      * @return
@@ -318,6 +325,8 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
     public Result findVrModel(SceneRroPageDto param) {
         // TODO: 2021/1/8 0008 查找4dkk场景数据,当前区域公司下的模型
         @NotBlank(message = "token不能为空") String token = param.getToken();
+        // 只获取计算成功的, 0:计算成功
+        param.setStatus("0");
         Result result = sceneProFeign.findByList(param, token);
 
         // 过滤已添加的数据
@@ -334,10 +343,10 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
             for (Object o : list) {
                 JSONObject scenePro = JSON.parseObject(o.toString());
                 String sceneProId = scenePro.getString("id");
-//                SceneEntity vrModelId = entityMapper.findByVrModelId(sceneProId);
-                SceneEntity vrModelId = entityMapper.findByVrModelIdAndHouseId(sceneProId, param.getHouseId());
+                List<SceneEntity> vrModelId = entityMapper.findByVrModelId2(sceneProId);
+//                SceneEntity vrModelId = entityMapper.findByVrModelIdAndHouseId(sceneProId, param.getHouseId());
                 String use = "0";
-                if (vrModelId != null) {
+                if (vrModelId.size() > 0) {
                     use = "1";
                 }
 
@@ -364,16 +373,21 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
         String id = param.getId();
         log.info("id: "+ id);
         SceneEntity entity = null;
+
+        List<SceneEntity> index = entityMapper.getIndex(param.getHouseId());
+
         if ( id == null) {
              entity = entityMapper.findByVrModelIdAndHouseId(param.getVrModelId(), param.getHouseId());
             if (entity != null){
                 log.error("VrModelId已存在");
                 return Result.failure(3001, "场景码已存在, 不能重复添加");
-
             }
 
             entity = new SceneEntity();
             BeanUtils.copyProperties(param, entity);
+            if (index.size() == 0) {
+                entity.setIsIndex(1);
+            }
             entity.setId(RandomUtils.getUuid());
             entity.setType("house");
             entity.setStatus(3);
@@ -382,6 +396,9 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
         } else {
             entity = this.findById(id);
             BeanUtils.copyProperties(param, entity);
+            if (index.size() == 0) {
+                entity.setIsIndex(1);
+            }
             entity.setUpdateTime(new Date());
             this.update(entity);
             log.info("更新VR模型完成");
@@ -440,6 +457,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
 
     @Override
     public Result editXml(XmlDataDto param) {
+        long start = System.currentTimeMillis();
         String id = param.getId();
         SceneEntity entity = findById(id);
         if (entity == null) {
@@ -459,13 +477,25 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
         // 编辑xml, 修改初始角度
         String inPath = localBasePath + "/tour2.xml";
         String outPath = localBasePath + "/tour.xml";
-        streamEditFile(inPath, outPath, param.getHlookat(), param.getVlookat());
+        String hlookat = param.getHlookat();
+        String vlookat = param.getVlookat();
+        streamEditFile(inPath, outPath, hlookat, vlookat);
         log.info("编辑xml, 修改初始角度完毕");
 
         String tourOssSavePath = configConstant.ossBasePath + entity.getHouseId() + "/" + entity.getSceneCode() + "/vtour/tour.xml";
         log.info("osspath: " + tourOssSavePath);
-        asyncTask.uploadOss(outPath, tourOssSavePath);
-        log.info("tour.xml 上传oss完成");
+        aliyunOssUtil.upload(outPath, tourOssSavePath);
+//        asyncTask.uploadOss(outPath, tourOssSavePath);
+        long end = System.currentTimeMillis();
+        log.info("tour.xml 上传oss完成, 共耗时: " + (end-start)/1000 + " s");
+
+        // 保存初始视觉
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("hlookat", hlookat);
+        jsonObject.put("vlookat", vlookat);
+        entity.setInitVisual(jsonObject.toJSONString());
+        this.update(entity);
+
 
 
         return Result.success(entity.getOssPath());

+ 24 - 8
cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -1,8 +1,6 @@
 package com.gis.web.controller;
 
 
-import cn.hutool.core.io.FileUtil;
-import com.gis.common.exception.JwtAuthenticationException;
 import com.gis.common.util.Result;
 import com.gis.domain.dto.*;
 import com.gis.domain.entity.SceneEntity;
@@ -23,6 +21,7 @@ import javax.validation.Valid;
 import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -79,6 +78,13 @@ public class SceneController extends BaseController {
         return sceneService.uploadPanoRabbitMq(file, houseId, type, hengdaId);
     }
 
+    @WebControllerLog(description = "场景管理-场景排序")
+    @ApiOperation(value = "场景排序")
+    @PostMapping(value = "setSort" )
+    public Result setSort(@RequestBody Map<String, String> param){
+        return sceneService.setSort(param);
+    }
+
 
     @ApiOperation(value = "上传-图标", position = 2)
     @PostMapping(value = "upload" )
@@ -112,12 +118,17 @@ public class SceneController extends BaseController {
         return sceneService.getIndex(houseId);
     }
 
-    @ApiOperation(value = "查找VR模型" , position = 3)
-    @PostMapping("findVrModel")
-    public Result findVrModel(@Valid @RequestBody SceneRroPageDto param) {
-        return sceneService.findVrModel(param);
-    }
 
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "houseId", value = "房源id", dataType = "String", required = true),
+            @ApiImplicitParam(name = "type", value = "场景类型, 楼盘:building, 园林:garden, 户型:house", dataType = "String",required = true),
+            @ApiImplicitParam(name = "status", value = "状态 3:成功", dataType = "String", required = true)
+    })
+    @ApiOperation(value = "获取场景码列表" , position = 3)
+    @GetMapping("getVrSceneCode/{houseId}/{status}/{type}")
+    public Result getVrSceneCode(@PathVariable String houseId, @PathVariable String status, @PathVariable String type) {
+        return sceneService.getVrSceneCode(houseId, status, type);
+    }
 
 
 
@@ -127,9 +138,14 @@ public class SceneController extends BaseController {
         return houseFeign.findByHouseId(houseId);
     }
 
+    @ApiOperation(value = "VR模型查找" , position = 3)
+    @PostMapping("findVrModel")
+    public Result findVrModel(@Valid @RequestBody SceneRroPageDto param) {
+        return sceneService.findVrModel(param);
+    }
 
     @WebControllerLog(description = "场景管理-保存VR模型")
-    @ApiOperation("保存VR模型")
+    @ApiOperation("VR模型保存")
     @PostMapping("saveVrModel")
     public Result saveVrModel(@Valid @RequestBody VrModelDto param) {
         return sceneService.saveVrModel(param);

+ 14 - 0
cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/TestController.java

@@ -31,6 +31,7 @@ import javax.validation.Valid;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -81,6 +82,19 @@ public class TestController extends BaseController {
 //        return sceneService.findVrModel(param);
 //    }
 
+    @ApiOperation(value = "场景排序")
+    @PostMapping(value = "setSort" )
+    public Result setSort(@RequestBody Map<String, String> param){
+        return sceneService.setSort(param);
+    }
+
+
+    @ApiOperation(value = "获取四维看看场景码" , position = 3)
+    @GetMapping("getVrSceneCode/{houseId}/{status}/{type}")
+    public Result getVrSceneCode(@PathVariable String houseId, @PathVariable String status, @PathVariable String type) {
+        return sceneService.getVrSceneCode(houseId, status, type);
+    }
+
 
     @GetMapping("testSendMq")
     @ApiOperation(value = "rabbitMQ发送", position = 1)

+ 11 - 0
cms_pano_fcb/remark.md

@@ -82,6 +82,17 @@ sit:
   krpano 切图命令       
     krpanotools makepano -config=templates/vtour-multires.config /root/user/owen_test/krpano/test.jpg      
     krpanotools makepano -config=templates/vtour-multires.config /root/user/owen_test/krpano/100m.jpg      
+    
+    
+   
+# uat 
+   数据库
+   
+   -   alter table tb_scene add sort int(11) DEFAULT 100; (已更新)
+   -   alter table tb_scene add init_visual varchar(255) ;
+   
+   测试切图工具命令
+   krpanotools makepano -config=templates/vtour-multires.config /mnt/cms_pano_fcb_data/test/test.jpg
    
 
 # 720yun 需求