wuweihao 4 سال پیش
والد
کامیت
4adc937b7a

+ 19 - 27
cms_pano_consumer/src/main/java/com/gis/listener/PanoConsumer.java

@@ -4,11 +4,13 @@ import com.gis.constant.CmdConstant;
 import com.gis.constant.ConfigConstant;
 import com.gis.constant.RabbitConfig;
 import com.gis.entity.SceneEntity;
+import com.gis.exception.BaseRuntimeException;
 import com.gis.mapper.SceneMapper;
 import com.gis.server.SceneService;
 import com.gis.task.AsyncTask;
 import com.gis.util.CmdUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.amqp.rabbit.annotation.RabbitHandler;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,39 +48,29 @@ public class PanoConsumer {
 
     public void cmdPano(String id) {
         log.info("start task cmdPano");
-        SceneEntity entity = null;
-        log.info("task 1");
+        SceneEntity entity = sceneService.findById(id);
+        if (entity == null) {
+            log.error("场景不存在: " + id);
+            throw new BaseRuntimeException("场景不存在: " + id);
+        }
         try {
-            entity = sceneService.findById(id);
-            log.info("task 2");
-            log.info("entity: "+entity.toString());
-
-            if (entity == null) {
-                log.error("对象为空: " + id);
-                entity.setStatus(2);
-                return;
-            } else {
-                // 切图
-                long start = System.currentTimeMillis();
-                log.info("1111111");
-                String panoPath = entity.getPath();
-                String cmd = CmdConstant.PANO_KRPANO + panoPath;
-                log.info("cmd: " + cmd);
-                CmdUtils.cmdPano(cmd);
-                long end = System.currentTimeMillis();
-                log.info("切图完成耗时: {} s" ,(end-start)/1000);
-                asyncTask.uploadOss(entity, sceneService);
-            }
 
+            // 切图
+            long start = System.currentTimeMillis();
+            String panoPath = entity.getPath();
+            String cmd = CmdConstant.PANO_KRPANO + panoPath;
+            log.info("cmd: " + cmd);
+            CmdUtils.cmdPano(cmd);
+            long end = System.currentTimeMillis();
+            log.info("切图完成耗时: {} s" ,(end-start)/1000);
+            asyncTask.uploadOss(entity);
+
+            entity.setStatus(3);
         }  catch (Exception e) {
             entity.setStatus(2);
             e.printStackTrace();
         } finally {
-            if (entity != null) {
-                sceneService.update(entity);
-            }
-
-
+            sceneService.update(entity);
         }
 
     }

+ 75 - 6
cms_pano_consumer/src/main/java/com/gis/task/AsyncTask.java

@@ -1,10 +1,13 @@
 package com.gis.task;
 
+import cn.hutool.core.io.FileUtil;
 import com.gis.constant.ConfigConstant;
 import com.gis.entity.SceneEntity;
+import com.gis.exception.BaseRuntimeException;
 import com.gis.server.SceneService;
 import com.gis.util.AliyunOssUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
@@ -26,11 +29,50 @@ public class AsyncTask {
     ConfigConstant configConstant;
 
     @Async("taskExecutor")
-    public void uploadOss(SceneEntity entity, SceneService sceneService){
+    public void uploadOss(SceneEntity entity) throws IOException {
+
+        log.info("run uploadOss, id: " + entity.getId());
+        String houseId = entity.getHouseId();
+        String sceneCode = entity.getSceneCode();
+        log.info("sceneCode: " + sceneCode);
+        String dirCode = houseId + "/" + sceneCode;
+        String basePath = configConstant.filePath + dirCode;
+        // 上传oss: vtour/panos  vtour/tour.xml
+        String dirPath = basePath + "/vtour/panos";
+
+        long OssStart = System.currentTimeMillis();
+        log.info("dirPath: " + dirPath);
+        log.info("dirCode: " + dirCode);
+        log.info("ossBasePath: " + configConstant.ossBasePath);
+
+            String tourPath = basePath + "/vtour/tour.xml";
+            log.info("tourPath: " + tourPath);
+            if (!FileUtil.isFile(tourPath)) {
+                String msg = "服务器tour.xml不存在";
+                log.error(msg);
+                throw new BaseRuntimeException(msg);
+            }
+            String tourOssPath = configConstant.ossBasePath + dirCode + "/vtour/tour.xml";
+            log.info("tourOssPath: " + tourOssPath);
+            aliyunOssUtil.upload(tourPath, tourOssPath);
+            log.info("tour.xml上传oss完成");
+            aliyunOssUtil.uploadDir(dirPath, sceneCode, configConstant.ossBasePath, houseId);
+            log.info("全局切图目录上传oss完成");
+            long OssEnd = System.currentTimeMillis();
+            log.info("uploadOss耗时: {} s" ,(OssEnd-OssStart)/1000);
+            // 2: 完成
+
+        log.info("end uploadOss, sceneId: " + entity.getId());
+    }
+
+
+    @Async("taskExecutor")
+    public void uploadOss2(SceneEntity entity, SceneService sceneService){
 
         log.info("run uploadOss, sceneId: " + entity.getId());
         String houseId = entity.getHouseId();
         String sceneCode = entity.getSceneCode();
+        log.info("sceneCode: " + sceneCode);
         String dirCode = houseId + "/" + sceneCode;
         String basePath = configConstant.filePath + dirCode;
         // 上传oss: vtour/panos  vtour/tour.xml
@@ -41,9 +83,19 @@ public class AsyncTask {
         log.info("dirCode: " + dirCode);
         log.info("ossBasePath: " + configConstant.ossBasePath);
         try {
-            aliyunOssUtil.uploadDir(dirPath, sceneCode, configConstant.ossBasePath, houseId);
+            String tourPath = basePath + "/vtour/tour.xml";
+            log.info("tourPath: " + tourPath);
+            if (!FileUtil.isFile(tourPath)) {
+                String msg = "服务器tour.xml不存在";
+                log.error(msg);
+                throw new BaseRuntimeException(msg);
+            }
             String tourOssPath = configConstant.ossBasePath + dirCode + "/vtour/tour.xml";
-            aliyunOssUtil.upload(basePath + "/vtour/tour.xml", tourOssPath);
+            log.info("tourOssPath: " + tourOssPath);
+            aliyunOssUtil.upload(tourPath, tourOssPath);
+            log.info("tour.xml上传oss完成");
+            aliyunOssUtil.uploadDir(dirPath, sceneCode, configConstant.ossBasePath, houseId);
+            log.info("全局切图目录上传oss完成");
             long OssEnd = System.currentTimeMillis();
             log.info("uploadOss耗时: {} s" ,(OssEnd-OssStart)/1000);
             // 2: 完成
@@ -52,12 +104,29 @@ public class AsyncTask {
             entity.setStatus(2);
             log.error("上传oss有误");
             e.printStackTrace();
-        } finally {
-
+        }
+        finally {
             sceneService.update(entity);
-
         }
 
         log.info("end uploadOss, sceneId: " + entity.getId());
     }
+
+
+
+    @Test
+    public void test(){
+        try {
+            String tourPath = "11111";
+            if (!FileUtil.isFile(tourPath)) {
+                log.error("服务器tour.xml不存在");
+                throw new  BaseRuntimeException("服务器tour.xml不存在");
+            }
+
+            log.info("11111111111111");
+        } catch (Exception e) {
+            log.error("异常了");
+            e.printStackTrace();
+        }
+    }
 }

+ 3 - 2
cms_pano_fcb/gis_application/src/main/resources/application-dev.properties

@@ -1,5 +1,6 @@
-#×¢²áÖÐÐÄ
-#spring.cloud.nacos.discovery.server-addr=192.168.0.98:8848
+#Ó¦ÓÃÃû
+spring.application.name=pano-service
+spring.cloud.nacos.discovery.server-addr=192.168.0.98:8848
 
 #DB
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

+ 58 - 0
cms_pano_fcb/gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -2,6 +2,7 @@ package com.gis.common.util;
 
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.img.Img;
+import cn.hutool.core.img.ImgUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.URLUtil;
 import com.gis.common.task.AsyncTask;
@@ -13,6 +14,8 @@ import org.springframework.stereotype.Component;
 import org.springframework.util.ResourceUtils;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.HttpURLConnection;
 import java.net.URL;
@@ -596,9 +599,64 @@ public class FileUtils {
     }
 
 
+    /**
+     * 检查出图比较是否2:1
+     * @return
+     * @throws IOException
+     */
+    public Boolean checkScale(String path) throws IOException {
+        BufferedImage image = ImageIO.read(new File(path));
+        int srcWidth = image .getWidth();      // 源图宽度
+        int srcHeight = image .getHeight();    // 源图高度
+
+        boolean flag = false;
+        if (srcWidth % srcHeight == 0 ) {
+            flag = true;
+        }
+        log.info("srcWidth = " + srcWidth);
+        log.info("srcHeight = " + srcHeight);
+        return flag;
+
+    }
+
+    /**
+     * 检查出图比较是否2:1
+     * @return
+     * @throws IOException
+     */
+    public static Boolean checkScale(InputStream input) throws IOException {
+        BufferedImage image = ImageIO.read(input);
+        int srcWidth = image .getWidth();      // 源图宽度
+        int srcHeight = image .getHeight();    // 源图高度
+
+        boolean flag = false;
+        if (srcWidth % srcHeight == 0 ) {
+            flag = true;
+        }
+        log.info("srcWidth = " + srcWidth);
+        log.info("srcHeight = " + srcHeight);
+        return flag;
+
+    }
 
 
+    @Test
+    public void testScale() throws IOException {
+        String path = "C:\\Users\\Administrator\\Desktop\\33\\28\\2.jpg";
+        BufferedImage image = ImageIO.read(new File(path));
+        int srcWidth = image .getWidth();      // 源图宽度
+        int srcHeight = image .getHeight();    // 源图高度
+
+        if (srcWidth % srcHeight == 0 ) {
+            System.out.println("图片比例正确");
+        } else {
+            System.out.println("图片比例有误");
 
+        }
+
+        System.out.println("srcWidth = " + srcWidth);
+        System.out.println("srcHeight = " + srcHeight);
+}
 
 
 }

+ 1 - 1
cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/dto/ScenePageDto.java

@@ -15,6 +15,6 @@ public class ScenePageDto extends PageDto {
     @ApiModelProperty(value = "houseId", required = true)
     private String houseId;
 
-    @ApiModelProperty(value = "状态 1:切图中, 2:失败, 3:完成")
+    @ApiModelProperty(value = "状态 1:切图中, 2:失败, 3:完成(未审核), 4:审核通过")
     private String status;
 }

+ 8 - 3
cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/dto/VrModelDto.java

@@ -36,14 +36,19 @@ public class VrModelDto {
     @ApiModelProperty(value = "场景名称")
     private String sceneTitle;
 
-    @NotBlank(message = "场景链接不能为空")
-    @ApiModelProperty(value = "场景链接", required = true)
-    private String webSite;
+//    @NotBlank(message = "场景链接不能为空")
+//    @ApiModelProperty(value = "场景链接", required = true)
+//    private String webSite;
 
     @NotBlank(message = "场景码不能为空")
     @ApiModelProperty(value = "场景码(四维看看)", required = true)
     private String sceneCode;
 
+    @NotBlank(message = "恒大id不能为空")
+    @ApiModelProperty(value = "恒大id", required = true)
+    private String hengdaId;
+
+
 
 
 

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

@@ -34,7 +34,7 @@ public class SceneEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "oss存放地址")
     private String ossPath;
 
-    @ApiModelProperty(value = "状态 1:切图中, 2:失败, 3:完成")
+    @ApiModelProperty(value = "状态 1:切图中, 2:失败, 3:完成(未审核), 4:审核通过")
     private Integer status;
 
     @ApiModelProperty(value = "类型, 楼盘:building, 园林:garden, 户型:house")

+ 9 - 0
cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/SceneMapper.java

@@ -49,9 +49,18 @@ public interface SceneMapper extends IBaseMapper<SceneEntity, String> {
     @Select("select * from tb_scene where is_delete = 0 and house_id = #{houseId}")
     List<SceneEntity> findByHouseId(String houseId);
 
+    @Select("select * from tb_scene where is_delete = 0 and house_id = #{houseId} and type = #{type} order by sort asc, create_time asc ")
+    List<SceneEntity> findByHouseIdAndType(String houseId, String type);
+
     @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);
+
+    @Update("UPDATE tb_scene SET is_delete = 1 where is_delete = 0 AND house_id = #{houseId}")
+    void houseRemove(String houseId);
+
+    @Update("UPDATE tb_scene SET status = #{status} where is_delete = 0 AND house_id = #{houseId}")
+    void houseAudit(String houseId, String status);
 }

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

@@ -29,8 +29,9 @@ public class SceneProvider {
         }
 
         String status = param.getStatus();
-        if(!StringUtils.isAllBlank(status)){
-            sql.append(" and ( status = '").append(status).append("' )");
+        // 传3 过来,会把审核:4、未审核:3的都传给前端
+        if(StringUtils.isNotBlank(status)){
+            sql.append(" and ( status >= '").append(status).append("' )");
         }
 
         sql.append(" order by sort asc, create_time asc");

+ 6 - 0
cms_pano_fcb/gis_service/src/main/java/com/gis/feign/HouseFeign.java

@@ -35,6 +35,12 @@ public interface HouseFeign {
     @PostMapping(value = "/fcb/project/operation/addNew", consumes = MediaType.APPLICATION_JSON_VALUE, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
     Result addLog(@RequestBody LogInfoDto param);
 
+
+    /**
+     * 已测试,用json是可以的
+     * @param param
+     * @return
+     */
     @PostMapping(value = "/fcb/project/house/updateHouse", consumes = MediaType.APPLICATION_JSON_VALUE, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
     Result updateHouseJson(@RequestBody JSONObject param);
 

+ 4 - 1
cms_pano_fcb/gis_service/src/main/java/com/gis/service/SceneService.java

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

+ 157 - 11
cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -1,6 +1,5 @@
 package com.gis.service.impl;
 
-import cn.hutool.core.img.ImgUtil;
 import cn.hutool.core.io.FileTypeUtil;
 import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSON;
@@ -75,6 +74,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
     @Override
     public Result uploadPanoRabbitMq(MultipartFile file, String houseId, String sceneType, String hengdaId) {
 
+
         if (StringUtils.isBlank(hengdaId) || hengdaId.equals("null")) {
             log.error("hengdaId不能为空");
             return Result.failure("hengdaId不能为空");
@@ -85,6 +85,11 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
             return Result.failure("houseId不能为空");
         }
 
+        Result resStatus =  getHouseStatus(houseId);
+        if (resStatus != null) {
+            return resStatus;
+        }
+
         // 判断图片类型
         SceneEntity entity = new SceneEntity();
 
@@ -95,18 +100,23 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
         try {
             inputStream = file.getInputStream();
 
+
             String type = FileTypeUtil.getType(inputStream);
             if (!FileUtils.getType(type).equals("image")) {
                 log.error("非图片类型");
                 return Result.failure(7001, "非图片类型");
             }
+
+            // inputStream = file.getInputStream(); 出来后用会拿不到流
+            if (!FileUtils.checkScale(file.getInputStream())) {
+                log.error("图片比例非2:1");
+                return Result.failure(7007, "图片比例非2:1");
+            }
             String uuid = RandomUtils.getUuid();
 
             String sceneCode = FileUtils.getCode();
             log.info("type: " + type);
 
-            log.info("equalsIgnoreCase1:" + type.equalsIgnoreCase("jpg"));
-            log.info("equalsIgnoreCase2:" + type.equalsIgnoreCase("jpeg"));
 
             // 全景图只支持jpg图片格式
             if (!type.equalsIgnoreCase("jpg")) {
@@ -136,7 +146,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
             // 压缩图片并上传oss
             String iconPath = fileUtils.compressImgAndUploadOss2(panoPath, configConstant.ossBasePath, configConstant.ossDomain);
 //            String iconPath = fileUtils.compressImgAndUploadOss(panoPath, configConstant.ossBasePath, configConstant.ossDomain);
-
+            log.info("iconPath:" + iconPath);
             entity.setIcon(iconPath);
             entity.setStatus(1);
             entity.setHouseId(houseId);
@@ -166,7 +176,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
                 houseSceneIndexDto.setSceneNum(entity.getSceneCode());
                 houseSceneIndexDto.setUpdateTime(LocalDateTime.now());
                 houseSceneIndexDto.setFcbHouseId(hengdaId);
-                log.info("111111");
                 Result result = houseFeign.updateHouseSceneIndex(houseSceneIndexDto);
                 if (result.getCode() == 0) {
                     log.info("新场景码到VR项目完成");
@@ -192,6 +201,41 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
     }
 
 
+
+    /**
+     * 查询VR项目状态
+     * @param houseId
+     * @return
+     */
+    private Result getHouseStatus(String houseId){
+        Result result = houseFeign.findByHouseId(houseId);
+        String status = null;
+        if (result.getCode() == 0) {
+            Object data = result.getData();
+            JSONObject jsonObject = JSON.parseObject(data.toString());
+            status = jsonObject.getString("status");
+            log.info("house status: " + status);
+
+            if (status.equals("1")) {
+                log.warn("审核中不能编辑");
+                return Result.failure(7005, "审核中不能编辑");
+            }
+            if (status.equals("2")) {
+                log.warn("已审核中不能编辑");
+                return Result.failure(7006, "已审核中不能编辑");
+            }
+
+
+        }
+
+        if (result.getCode() == -1){
+            return Result.failure("查询失败");
+        }
+
+        return null;
+    }
+
+
     @Test
     public void test2(){
         String type = "aa.jpg";
@@ -221,9 +265,15 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
     @Override
     public Result editHouse(EditHouseDto param) {
 
+        // 检查VR项目状态
+        String houseId = param.getHouseId();
+        Result resStatus =  getHouseStatus(houseId);
+        if (resStatus != null) {
+            return resStatus;
+        }
+
         // TODO: 2021/1/8 0008 更新伟玉房源表单接口
         HouseDto houseDto = new HouseDto();
-        String houseId = param.getHouseId();
         houseDto.setId(houseId);
         houseDto.setCoverImagUrl(param.getHouseIcon());
         houseDto.setHouseTitle(param.getHouseTitle());
@@ -250,14 +300,26 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
 
     @Override
     public Result setIndex(String id) {
+
+
+
         SceneEntity entity = findById(id);
         if (entity == null) {
             log.error("场景不存在,id:  {}", id);
             return Result.failure("场景不存在");
         }
+
+
+        // 检查VR项目状态
+        String houseId = entity.getHouseId();
+        Result resStatus =  getHouseStatus(houseId);
+        if (resStatus != null) {
+            return resStatus;
+        }
+
+
         // 设置初始场景
             // step:1先全部设置为0
-//            entityMapper.setIndex(0);
             entityMapper.setIndexByHouseId(0, entity.getHouseId());
             // step:1先全部设置为1
             entityMapper.setIndexById(id, 1);
@@ -266,7 +328,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
 
         // TODO: 2021/1/8 0008 更新伟玉房源表单接口
         HouseSceneIndexDto houseSceneIndexDto = new HouseSceneIndexDto();
-        String houseId = entity.getHouseId();
         houseSceneIndexDto.setId(houseId);
 
         // 初始场景
@@ -301,12 +362,23 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
     @Override
     public Result setSort(Map<String, String> param) {
         log.info("sort size: " + param.size());
+        int n = 1;
         for (Map.Entry<String, String> m : param.entrySet()) {
             String id = m.getKey();
+            if (n == 1) {
+                SceneEntity entity = this.findById(id);
+                String houseId = entity.getHouseId();
+                Result resStatus =  getHouseStatus(houseId);
+                if (resStatus != null) {
+                    return resStatus;
+                }
+            }
+
             String sort = m.getValue();
             log.info("id: " + id);
             log.info("sort: " + sort);
             entityMapper.setSortById(id, sort);
+            n ++;
         }
 
         return Result.success();
@@ -317,6 +389,18 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
         return Result.success(entityMapper.getVrSceneCode(houseId, status, type));
     }
 
+    @Override
+    public Result houseRemove(String houseId) {
+        entityMapper.houseRemove(houseId);
+        return Result.success();
+    }
+
+    @Override
+    public Result houseAudit(String houseId, String status) {
+        entityMapper.houseAudit(houseId, status);
+        return Result.success();
+    }
+
     /**
      * 添加VR模型
      * @return
@@ -372,6 +456,15 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
     public Result saveVrModel(VrModelDto param) {
         String id = param.getId();
         log.info("id: "+ id);
+
+        // 检查VR项目状态
+        String houseId = param.getHouseId();
+        Result resStatus =  getHouseStatus(houseId);
+        if (resStatus != null) {
+            return resStatus;
+        }
+
+
         SceneEntity entity = null;
 
         List<SceneEntity> index = entityMapper.getIndex(param.getHouseId());
@@ -384,21 +477,56 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
             }
 
             entity = new SceneEntity();
+
+            @NotBlank(message = "场景码不能为空") String sceneCode = param.getSceneCode();
+            @NotBlank(message = "恒大id不能为空") String hengdaId = param.getHengdaId();
+            String webSite = "/hengda.html?m="+ sceneCode + "&prodId=" + hengdaId + "&houseId=" + houseId;
+
+
             BeanUtils.copyProperties(param, entity);
             if (index.size() == 0) {
                 entity.setIsIndex(1);
+
+                HouseSceneIndexDto indexDto = new HouseSceneIndexDto();
+                indexDto.setId(entity.getHouseId());
+                indexDto.setSceneNum(entity.getSceneCode());
+                indexDto.setUpdateTime(LocalDateTime.now());
+                indexDto.setFcbHouseId(entity.getHengdaId());
+                Result result = houseFeign.updateHouseSceneIndex(indexDto);
+
+                if (result.getCode() == 0) {
+                    log.info("更新了初始场景到VR项目完成");
+                } else {
+                    log.error("更新了初始场景到VR项目异常");
+                    return Result.failure(result.getMsg());
+                }
             }
             entity.setId(RandomUtils.getUuid());
             entity.setType("house");
             entity.setStatus(3);
+            entity.setWebSite(webSite);
             this.save(entity);
             log.info("保存VR模型完成");
         } else {
             entity = this.findById(id);
             BeanUtils.copyProperties(param, entity);
-            if (index.size() == 0) {
-                entity.setIsIndex(1);
-            }
+//            if (index.size() == 0) {
+//                entity.setIsIndex(1);
+//
+//                HouseSceneIndexDto indexDto = new HouseSceneIndexDto();
+//                indexDto.setId(entity.getHouseId());
+//                indexDto.setSceneNum(entity.getSceneCode());
+//                indexDto.setUpdateTime(LocalDateTime.now());
+//                indexDto.setFcbHouseId(entity.getHengdaId());
+//                Result result = houseFeign.updateHouseSceneIndex(indexDto);
+//
+//                if (result.getCode() == 0) {
+//                    log.info("更新了初始场景到VR项目完成");
+//                } else {
+//                    log.error("更新了初始场景到VR项目异常");
+//                    return Result.failure(result.getMsg());
+//                }
+//            }
             entity.setUpdateTime(new Date());
             this.update(entity);
             log.info("更新VR模型完成");
@@ -464,6 +592,16 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
             log.error("对象不存在,id : " + id);
             return Result.failure("场景码不存在");
         }
+
+
+        // 检查VR项目状态
+        String houseId = entity.getHouseId();
+        Result resStatus =  getHouseStatus(houseId);
+        if (resStatus != null) {
+            return resStatus;
+        }
+
+
         // 注意网络下载会有缓存,必须加时间戳
         // http://ossxiaoan.4dage.com/cms_pano_fcb/p19/fcb_px2rJW96F/vtour/tour.xml
         String tourOssUrl = entity.getOssPath() + "/vtour/tour.xml?m=" + System.currentTimeMillis();
@@ -643,6 +781,14 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
     public Result editSomeData(EditSomeDataDto param) {
         String id = param.getId();
         SceneEntity entity = this.findById(id);
+
+        // 检查VR项目状态
+        String houseId = entity.getHouseId();
+        Result resStatus =  getHouseStatus(houseId);
+        if (resStatus != null) {
+            return resStatus;
+        }
+
         if (entity == null) {
             log.error("场景不存在, id: " + id);
             return Result.failure("场景不存在");

+ 161 - 59
cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -1,6 +1,7 @@
 package com.gis.web.controller;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.gis.common.util.Result;
 import com.gis.domain.dto.*;
 import com.gis.domain.entity.SceneEntity;
@@ -43,7 +44,6 @@ public class SceneController extends BaseController {
     private SceneMapper sceneMapper;
 
 
-
     @WebControllerLog(description = "场景管理-场景列表")
     @ApiOperation(value = "场景列表", position = 1)
     @PostMapping("list")
@@ -53,12 +53,11 @@ public class SceneController extends BaseController {
 
     /**
      * 创建场景
+     *
      * @param file
      * @param houseId
      * @param type
-     * @return
-     *
-     * 恒大id 唯一入口
+     * @return 恒大id 唯一入口
      */
     @WebControllerLog(description = "场景管理-创建场景")
     @ApiImplicitParams({
@@ -68,7 +67,7 @@ public class SceneController extends BaseController {
     })
     @ApiOperation(value = "上传-全景图(创建场景)", position = 2)
     @PostMapping("uploadPano/{houseId}/{type}/{hengdaId}")
-    public Result uploadPano(MultipartFile file, @PathVariable String houseId, @PathVariable String type, @PathVariable String hengdaId){
+    public Result uploadPano(MultipartFile file, @PathVariable String houseId, @PathVariable String type, @PathVariable String hengdaId) {
 
         if (file == null) {
             log.error("文件不能为空");
@@ -80,25 +79,43 @@ public class SceneController extends BaseController {
 
     @WebControllerLog(description = "场景管理-场景排序")
     @ApiOperation(value = "场景排序")
-    @PostMapping(value = "setSort" )
-    public Result setSort(@RequestBody Map<String, String> param){
+    @PostMapping(value = "setSort")
+    public Result setSort(@RequestBody Map<String, String> param) {
         return sceneService.setSort(param);
     }
 
 
     @ApiOperation(value = "上传-图标", position = 2)
-    @PostMapping(value = "upload" )
-    public Result upload(@RequestParam("file")MultipartFile file){
+    @PostMapping(value = "upload")
+    public Result upload(@RequestParam("file") MultipartFile file) {
         return sceneService.upload(file);
     }
 
     @WebControllerLog(description = "场景管理-编辑场景")
-    @ApiOperation(value = "修改VR项目", position = 3)
+    @ApiOperation(value = "VR项目修改", position = 3)
     @PostMapping("house/edit")
     public Result editHouse(@Valid @RequestBody EditHouseDto param) {
         return sceneService.editHouse(param);
     }
 
+    @WebControllerLog(description = "场景管理-VR项目审核通过/下线")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "houseId", value = "房源id", dataType = "String", required = true),
+            @ApiImplicitParam(name = "status", value = "状态, 审核通过/上线:4, 下线:3", dataType = "String"),
+    })
+    @ApiOperation(value = "VR项目审核通过/下线/上线", position = 3)
+    @GetMapping("house/audit/{houseId}/{status}")
+    public Result houseAudit(@PathVariable String houseId, @PathVariable String status) {
+        return sceneService.houseAudit(houseId, status);
+    }
+
+    @WebControllerLog(description = "场景管理-VR项目删除")
+    @ApiOperation(value = "VR项目删除", position = 3)
+    @GetMapping("house/remove/{houseId}")
+    public Result houseRemove(@PathVariable String houseId) {
+        return sceneService.houseRemove(houseId);
+    }
+
     @WebControllerLog(description = "场景管理-编辑场景")
     @ApiOperation(value = "编辑someData,(重命名)", position = 3)
     @PostMapping("editSomeData")
@@ -106,13 +123,13 @@ public class SceneController extends BaseController {
         return sceneService.editSomeData(param);
     }
 
-    @ApiOperation(value = "首页设置" , position = 3)
+    @ApiOperation(value = "首页设置", position = 3)
     @PostMapping("setIndex/{id}")
     public Result setIndex(@PathVariable String id) {
         return sceneService.setIndex(id);
     }
 
-    @ApiOperation(value = "首页获取" , position = 3)
+    @ApiOperation(value = "首页获取", position = 3)
     @GetMapping("getIndex/{houseId}")
     public Result getIndex(@PathVariable String houseId) {
         return sceneService.getIndex(houseId);
@@ -121,29 +138,40 @@ public class SceneController extends BaseController {
 
     @ApiImplicitParams({
             @ApiImplicitParam(name = "houseId", value = "房源id", dataType = "String", required = true),
-            @ApiImplicitParam(name = "type", value = "场景类型, 楼盘:building, 园林:garden, 户型:house", 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)
+    @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);
     }
 
 
-
-    @ApiOperation(value = "房源详情" , position = 3)
+    @ApiOperation(value = "房源详情", position = 3)
     @GetMapping("house/detail/{houseId}")
     public Result houseDetail(@PathVariable String houseId) {
         return houseFeign.findByHouseId(houseId);
     }
 
-    @ApiOperation(value = "VR模型查找" , position = 3)
+
+    @ApiOperation(value = "VR模型查找", position = 3)
     @PostMapping("findVrModel")
     public Result findVrModel(@Valid @RequestBody SceneRroPageDto param) {
         return sceneService.findVrModel(param);
     }
 
+    @ApiOperation(value = "VR模模型-根据场景码查询")
+    @GetMapping(value = "fdkk/findBySceneCode")
+    public Result vrFindBySceneCode(String sceneCode) {
+        SceneEntity entity = sceneService.findBySceneCode(sceneCode);
+        boolean flag = true;
+        if (entity == null) {
+            flag = false;
+        }
+        return Result.success(flag);
+    }
+
     @WebControllerLog(description = "场景管理-保存VR模型")
     @ApiOperation("VR模型保存")
     @PostMapping("saveVrModel")
@@ -192,59 +220,133 @@ public class SceneController extends BaseController {
         return Result.success(entity);
     }
 
+
     @WebControllerLog(description = "场景管理-删除场景")
     @ApiOperation("删除")
-    @GetMapping("removes/{ids}")
-    public Result removes(@PathVariable String ids) {
-        String[] split = ids.split(",");
-        SceneEntity entity = null;
+    @GetMapping("removes/{id}")
+    public Result remove(@PathVariable String id) {
+
+        SceneEntity entity = sceneService.findById(id);
+        if (entity.getStatus() == 1) {
+            return Result.failure(7004, "执行中的任务不能删除");
+
+        }
+        entity.setIsDelete(1);
+        // 设置场景为0
+        entity.setIsIndex(0);
+        entity.setUpdateTime(new Date());
+        String houseId = entity.getHouseId();
+        sceneService.update(entity);
+
         boolean flag = false;
-        for (String id: split) {
-            entity = sceneService.findById(id);
-            if (entity.getStatus() == 1) {
-                return  Result.failure(7004, "执行中的任务不能删除");
-//                flag = true;
-//                break;
-            }
-            entity.setIsDelete(1);
-            // 设置场景为0
-            entity.setIsIndex(0);
-            entity.setUpdateTime(new Date());
-            String houseId = entity.getHouseId();
-            sceneService.update(entity);
-
-            // 更新首页
-               List<SceneEntity> entityList = sceneMapper.findByHouseId(houseId);
-               if (entityList.size() > 0) {
-                   SceneEntity sceneEntity = entityList.get(0);
-                   if (sceneEntity != null) {
-                       sceneEntity.setIsIndex(1);
-                       sceneService.update(sceneEntity);
-                       // 更新首页场景到VR项目
-                       HouseSceneIndexDto indexDto = new HouseSceneIndexDto();
-                       indexDto.setId(sceneEntity.getHouseId());
-                       indexDto.setSceneNum(entity.getSceneCode());
-                       indexDto.setUpdateTime(LocalDateTime.now());
-                       indexDto.setFcbHouseId(sceneEntity.getHengdaId());
-                       Result result = houseFeign.updateHouseSceneIndex(indexDto);
-                       if (result.getCode() == 0) {
-                           log.info("更新了初始场景到VR项目完成");
-                       } else {
-                           log.error("更新了初始场景到VR项目异常");
-                           return Result.failure(result.getMsg());
-                       }
-                       log.info("result: "+ result);
-                       log.info("更新了初始场景到VR项目");
-                   }
-               }
+
+        // 更新首页
+        List<SceneEntity> buildingList = sceneMapper.findByHouseIdAndType(houseId, "building");
+        List<SceneEntity> gardenList = sceneMapper.findByHouseIdAndType(houseId, "garden");
+        List<SceneEntity> houseList = sceneMapper.findByHouseIdAndType(houseId, "house");
+
+        // 顺序不能变
+        SceneEntity IndexEntity = null;
+        if (buildingList.size() > 0) {
+            IndexEntity = setInitIndex(buildingList);
+            flag = true;
+        } else if (gardenList.size() > 0) {
+            IndexEntity = setInitIndex(gardenList);
+            flag = true;
+        } else if (houseList.size() > 0) {
+            flag = true;
+            IndexEntity = setInitIndex(houseList);
         }
 
 
+        // todo 测试一下是否要更新初始场景到伟玉那边
+        // 更新首页场景到VR项目
+        if (flag) {
+            HouseSceneIndexDto indexDto = new HouseSceneIndexDto();
+            indexDto.setId(IndexEntity.getHouseId());
+            indexDto.setSceneNum(IndexEntity.getSceneCode());
+            indexDto.setUpdateTime(LocalDateTime.now());
+            indexDto.setFcbHouseId(IndexEntity.getHengdaId());
+            Result result = houseFeign.updateHouseSceneIndex(indexDto);
+
+
+            if (result.getCode() == 0) {
+                log.info("更新了初始场景到VR项目完成");
+            } else {
+                log.error("更新了初始场景到VR项目异常");
+                return Result.failure(result.getMsg());
+            }
+            log.info("result: " + result);
+            log.info("更新了初始场景到VR项目");
+        }
+
         return Result.success();
     }
 
+//    @WebControllerLog(description = "场景管理-删除场景")
+//    @ApiOperation("删除")
+//    @GetMapping("removes/{ids}")
+//    public Result removes(@PathVariable String ids) {
+//        String[] split = ids.split(",");
+//        SceneEntity entity = null;
+//
+//        for (String id: split) {
+//            entity = sceneService.findById(id);
+//            if (entity.getStatus() == 1) {
+//                return  Result.failure(7004, "执行中的任务不能删除");
+//
+//            }
+//            entity.setIsDelete(1);
+//            // 设置场景为0
+//            entity.setIsIndex(0);
+//            entity.setUpdateTime(new Date());
+//            String houseId = entity.getHouseId();
+//            sceneService.update(entity);
+//
+//            // 更新首页
+//               List<SceneEntity> entityList = sceneMapper.findByHouseId(houseId);
+//               if (entityList.size() > 0) {
+//                   SceneEntity sceneEntity = entityList.get(0);
+//                   if (sceneEntity != null) {
+//                       sceneEntity.setIsIndex(1);
+//                       sceneService.update(sceneEntity);
+//                       // 更新首页场景到VR项目
+//                       HouseSceneIndexDto indexDto = new HouseSceneIndexDto();
+//                       indexDto.setId(sceneEntity.getHouseId());
+//                       indexDto.setSceneNum(entity.getSceneCode());
+//                       indexDto.setUpdateTime(LocalDateTime.now());
+//                       indexDto.setFcbHouseId(sceneEntity.getHengdaId());
+//                       Result result = houseFeign.updateHouseSceneIndex(indexDto);
+//                       if (result.getCode() == 0) {
+//                           log.info("更新了初始场景到VR项目完成");
+//                       } else {
+//                           log.error("更新了初始场景到VR项目异常");
+//                           return Result.failure(result.getMsg());
+//                       }
+//                       log.info("result: "+ result);
+//                       log.info("更新了初始场景到VR项目");
+//                   }
+//               }
+//        }
+//
+//
+//        return Result.success();
+//    }
+
+
+    private SceneEntity setInitIndex(List<SceneEntity> entityList) {
+
+        SceneEntity sceneEntity = entityList.get(0);
+        if (sceneEntity != null) {
+            sceneEntity.setIsIndex(1);
+            sceneService.update(sceneEntity);
+        }
+        return sceneEntity;
+    }
+
     /**
      * 这个接口,好像是没用的
+     *
      * @param houseId
      * @return
      */

+ 115 - 7
cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/TestController.java

@@ -5,10 +5,10 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.gis.common.constant.ConfigConstant;
 import com.gis.common.constant.RabbitConfig;
+import com.gis.common.exception.BaseRuntimeException;
 import com.gis.common.util.FileUtils;
 import com.gis.common.util.Result;
 import com.gis.domain.dto.HouseSceneIndexDto;
-import com.gis.domain.dto.SceneRroPageDto;
 import com.gis.domain.dto.UserDto;
 import com.gis.domain.dto.VrModelDto;
 import com.gis.domain.entity.SceneEntity;
@@ -27,7 +27,6 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.validation.Valid;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -73,14 +72,99 @@ public class TestController extends BaseController {
         return Result.success(new Date());
     }
 
+    @ApiOperation(value = "VR模模型-根据场景码查询")
+    @GetMapping(value = "vr/findBySceneCode/{sceneCode}" )
+    public Result vrFindBySceneCode(@PathVariable String sceneCode){
+        SceneEntity entity = sceneService.findBySceneCode(sceneCode);
+        boolean flag = true;
+        if (entity == null) {
+            flag = false;
+        }
+        return Result.success(flag);
+    }
 
 
+    @ApiOperation(value = "测试异常" )
+    @PostMapping("ex/{id}")
+    public Result ex(@PathVariable String id) {
+
+
+            log.info("start task cmdPano");
+            SceneEntity entity = sceneService.findById(id);
+            if (entity == null) {
+                throw new BaseRuntimeException("场景不存在: " + id);
+            }
+            log.info("task 1");
+            try {
+                log.info("task 2");
+
+                log.info("1111111");
+
+            }  catch (Exception e) {
+                entity.setStatus(6);
+                e.printStackTrace();
+            } finally {
+                log.info("5555");
+                sceneService.update(entity);
+                log.info("66666");
+            }
+
+
+        return Result.success();
+    }
+
+    @ApiOperation(value = "VR项目状态查询" )
+    @PostMapping("findHouseStatus/{id}")
+    public Result findHouseStatus(@PathVariable String id) {
+
+        log.info("status: " + 1111);
+        // 检查VR项目状态
+        Result status =  getHouseStatus(id);
+       log.info("777777");
+       if (status != null) {
+           log.info("8888");
+           return status;
+       }
+        log.info("9999");
+
+        return Result.success();
+
+    }
+
+
+    /**
+     * 查询VR项目状态
+     * @param houseId
+     * @return
+     */
+    private Result getHouseStatus(String houseId){
+        Result result = houseFeign.findByHouseId(houseId);
+//        log.info("result: " + result);
+        String status = null;
+        if (result.getCode() == 0) {
+            Object data = result.getData();
+            JSONObject jsonObject = JSON.parseObject(data.toString());
+            status = jsonObject.getString("status");
+            log.info("house status: " + status);
+
+            if (status.equals("2")) {
+                log.warn("审核中不能编辑");
+                return Result.failure(7005, "审核中不能编辑");
+            }
+            if (status.equals("3")) {
+                log.warn("已审核中不能编辑");
+                return Result.failure(7006, "已审核中不能编辑");
+            }
 
-//    @ApiOperation(value = "查找VR模型" , position = 3)
-//    @PostMapping("findVrModel")
-//    public Result findVrModel(@RequestBody SceneRroPageDto param) {
-//        return sceneService.findVrModel(param);
-//    }
+
+        }
+
+        if (result.getCode() == -1){
+                return Result.failure("查询失败");
+            }
+
+        return null;
+    }
 
     @ApiOperation(value = "场景排序")
     @PostMapping(value = "setSort" )
@@ -96,6 +180,18 @@ public class TestController extends BaseController {
     }
 
 
+    @ApiOperation(value = "VR项目删除" , position = 3)
+    @GetMapping("house/remove/{houseId}")
+    public Result houseRemove(@PathVariable String houseId) {
+        return sceneService.houseRemove(houseId);
+    }
+
+//    @ApiOperation(value = "VR项目审核通过" , position = 3)
+//    @GetMapping("house/audit/{houseId}")
+//    public Result houseAudit(@PathVariable String houseId) {
+//        return sceneService.houseAudit(houseId, status);
+//    }
+
     @GetMapping("testSendMq")
     @ApiOperation(value = "rabbitMQ发送", position = 1)
     public Result testSendMq(){
@@ -127,6 +223,18 @@ public class TestController extends BaseController {
         return Result.success(key);
     }
 
+    @ApiOperation(value = "上传-全景图(创建场景)", position = 2)
+    @PostMapping("uploadPano/{houseId}/{type}/{hengdaId}")
+    public Result uploadPano(MultipartFile file, @PathVariable String houseId, @PathVariable String type, @PathVariable String hengdaId) {
+
+        if (file == null) {
+            log.error("文件不能为空");
+            return Result.failure("文件不能为空");
+        }
+
+        return sceneService.uploadPanoRabbitMq(file, houseId, type, hengdaId);
+    }
+
 
 
 

+ 7 - 1
cms_pano_fcb/remark.md

@@ -71,6 +71,7 @@ sit:
   
   恒大管理后台入口:
   url: https://fcb.test.4dkankan.com/evergrande/
+  https://fcb.test.4dkankan.com/vrscene/edit.html?m=HUS000011353902369549783040&h=7692531395896335655#/information
   
     88888888888  88888888
   
@@ -89,11 +90,16 @@ sit:
    数据库
    
    -   alter table tb_scene add sort int(11) DEFAULT 100; (已更新)
-   -   alter table tb_scene add init_visual varchar(255) ;
+   -   alter table tb_scene add init_visual varchar(255) ; (已更新)
    
    测试切图工具命令
    krpanotools makepano -config=templates/vtour-multires.config /mnt/cms_pano_fcb_data/test/test.jpg
    
+   更新代码工具
+   ex_031306460
+   4Dade_hy01
+   
+   /tmp/a/
 
 # 720yun 需求
  1. 先上传全景图