Browse Source

新增dev-1.5 二手房分支

wuweihao 4 năm trước cách đây
mục cha
commit
1410e12d6c
32 tập tin đã thay đổi với 1862 bổ sung340 xóa
  1. 38 0
      cms_pano_consumer/src/main/java/com/gis/constant/RabbitConfig.java
  2. 100 0
      cms_pano_consumer/src/main/java/com/gis/entity/SecondHandEntity.java
  3. 0 31
      cms_pano_consumer/src/main/java/com/gis/listener/PanoConsumer.java
  4. 159 0
      cms_pano_consumer/src/main/java/com/gis/listener/SecondHandConsumer.java
  5. 20 0
      cms_pano_consumer/src/main/java/com/gis/mapper/SecondHandMapper.java
  6. 132 132
      cms_pano_consumer/src/main/java/com/gis/task/AsyncTask.java
  7. 0 45
      cms_pano_consumer/src/main/java/com/gis/task/TaskExecutePool.java
  8. 9 3
      cms_pano_consumer/src/main/resources/application-dev.properties
  9. 11 0
      cms_pano_consumer/src/main/resources/sh/shutdown.sh
  10. 11 0
      cms_pano_consumer/src/main/resources/sh/startup.sh
  11. 8 3
      cms_pano_fcb/gis_application/src/main/resources/application-dev.properties
  12. 2 1
      cms_pano_fcb/gis_application/src/main/resources/application-sit.properties
  13. 3 1
      cms_pano_fcb/gis_common/src/main/java/com/gis/common/constant/ConfigConstant.java
  14. 35 0
      cms_pano_fcb/gis_common/src/main/java/com/gis/common/constant/RabbitConfig.java
  15. 1 6
      cms_pano_fcb/gis_common/src/main/java/com/gis/common/util/FileUtils.java
  16. 15 0
      cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/dto/SecondHandPageDto.java
  17. 100 0
      cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/entity/SecondHandEntity.java
  18. 52 0
      cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/vo/SceneAndInitVo.java
  19. 4 12
      cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/SceneInitMapper.java
  20. 20 16
      cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/SceneMapper.java
  21. 67 0
      cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/SecondHandMapper.java
  22. 45 0
      cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/provider/SecondHandProvider.java
  23. 2 0
      cms_pano_fcb/gis_service/src/main/java/com/gis/service/HouseService.java
  24. 2 3
      cms_pano_fcb/gis_service/src/main/java/com/gis/service/SceneInitService.java
  25. 53 0
      cms_pano_fcb/gis_service/src/main/java/com/gis/service/SecondHandService.java
  26. 21 74
      cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/HouseServiceImpl.java
  27. 10 12
      cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/SceneInitServiceImpl.java
  28. 695 0
      cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/SecondHandServiceImpl.java
  29. 14 0
      cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/HouseController.java
  30. 194 0
      cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/SecondHandController.java
  31. 27 0
      cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/TestController.java
  32. 12 1
      cms_pano_fcb/remark.md

+ 38 - 0
cms_pano_consumer/src/main/java/com/gis/constant/RabbitConfig.java

@@ -42,6 +42,17 @@ public class RabbitConfig {
     public static final String PANO_QUEUE_ROUTING = "panoQueueRouting";
 
 
+    // 2021-09-08
+    /** 二手房队列*/
+    public static final String SECOND_HAND_QUEUE = "secondHandQueue";
+
+    /** 二手房交换机*/
+    public static final String SECOND_HAND_EXCHANGE = "secondHandExchange";
+
+    /** 二手房交换机路由*/
+    public static final String SECOND_HAND_QUEUE_ROUTING = "secondHandQueueRouting";
+
+
 
 
 
@@ -72,6 +83,33 @@ public class RabbitConfig {
     }
 
 
+
+    /**
+     * 二手房队列
+     */
+    @Bean
+    public Queue secondHandQueue() {
+        return new Queue(SECOND_HAND_QUEUE);
+    }
+
+    /**
+     * 二手房交换机
+     */
+    @Bean
+    public Exchange secondHandExchange(){
+        return new DirectExchange(SECOND_HAND_EXCHANGE, true, false);
+    }
+
+
+    /**
+     * 二手房队列绑定交换机
+     */
+    @Bean
+    public Binding secondHandRoutingExchange(Queue secondHandQueue, Exchange secondHandExchange){
+        return BindingBuilder.bind(secondHandQueue).to(secondHandExchange).with(SECOND_HAND_QUEUE_ROUTING).noargs();
+    }
+
+
     /**
      * 以下三个方法是配置集群
      * @return

+ 100 - 0
cms_pano_consumer/src/main/java/com/gis/entity/SecondHandEntity.java

@@ -0,0 +1,100 @@
+package com.gis.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.io.Serializable;
+
+/**
+ * 二手房场景实体类
+ */
+@Data
+@Entity
+@Table(name = "tb_second_hand")
+public class SecondHandEntity extends BaseEntity implements Serializable {
+
+
+    private static final long serialVersionUID = -1624241144090646200L;
+
+    @ApiModelProperty(value = "场景码")
+    private String sceneCode;
+
+    @ApiModelProperty(value = "存放地址")
+    private String path;
+
+//    @ApiModelProperty(value = "场景名称")
+//    private String sceneTitle;
+//
+//    @ApiModelProperty(value = "场景url")
+//    private String webSite;
+//
+//    @ApiModelProperty(value = "简介")
+//    private String description;
+//
+//    @ApiModelProperty(value = "oss存放地址")
+//    private String ossPath;
+
+    @ApiModelProperty(value = "状态 1:切图中, 2:失败, 3:完成(未审核), 4:审核通过")
+    private Integer status;
+
+//    @ApiModelProperty(value = "类型, 楼盘:building, 园林:garden, 户型:house")
+//    private String type;
+//
+//    @ApiModelProperty(value = "楼盘id")
+//    private String houseId;
+//
+//    @ApiModelProperty(value = "创建人")
+//    private String createUserId;
+//
+//    @ApiModelProperty(value = "封面图")
+//    private String icon;
+//
+//    @ApiModelProperty(value = "文件名")
+//    private String fileName;
+//
+//    @ApiModelProperty(value = "someData")
+//    private String someData;
+//
+//    @ApiModelProperty(value = "样版间名称")
+//    private String roomName;
+
+
+
+//    /**
+//     * 只可以存一次,不能重复,重复需要删除旧数据
+//     */
+//    @ApiModelProperty(value = "vrModelId(四维看看场景id), 只有在house类型才有此数据")
+//    private String vrModelId;
+//
+//    @ApiModelProperty(value = "恒大Id")
+//    private String hengdaId;
+//
+//    @ApiModelProperty(value = "排序(序号小排前面)")
+//    private Integer sort;
+//
+//    @ApiModelProperty(value =  "初始视觉")
+//    private String initVisual;
+//
+//    @ApiModelProperty(value =  "热点关联场景, 场景码,允许多个以逗号隔开")
+//    private String useHots;
+//
+//    @ApiModelProperty(value =  "模型在全景园林显示byType=garden")
+//    private String byType;
+//
+//    @Transient
+//    @ApiModelProperty(value = "初始场景是否已使用,0:否, 1:是")
+//    private Integer isUseIndex = 0;
+//
+//
+//    @ApiModelProperty(value = "恒大样本间id, 只有在house类型才有此数据")
+//    private String roomId;
+//
+//    @ApiModelProperty(value = "恒大经纪人id(讲房顾问), 只有在house类型才有此数据")
+//    private String agentId;
+
+
+
+}

+ 0 - 31
cms_pano_consumer/src/main/java/com/gis/listener/PanoConsumer.java

@@ -8,11 +8,9 @@ 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.AliyunOssUtil;
 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;
@@ -127,35 +125,6 @@ public class PanoConsumer {
         }
     }
 
-//    public void cmdPano(String id) {
-//        log.info("start task cmdPano");
-//        SceneEntity entity = sceneService.findById(id);
-//        if (entity == null) {
-//            log.error("场景不存在: " + id);
-//            return;
-//        }
-//        try {
-//
-//            // 切图
-//            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);
-////            uploadOss(entity);
-//            uploadOssDir(entity);
-//
-//            entity.setStatus(3);
-//        }  catch (Exception e) {
-//            entity.setStatus(2);
-//            e.printStackTrace();
-//        } finally {
-//            sceneService.update(entity);
-//        }
-//
-//    }
 
 
     /**

+ 159 - 0
cms_pano_consumer/src/main/java/com/gis/listener/SecondHandConsumer.java

@@ -0,0 +1,159 @@
+package com.gis.listener;
+
+import cn.hutool.core.io.FileUtil;
+import com.gis.constant.CmdConstant;
+import com.gis.constant.ConfigConstant;
+import com.gis.constant.RabbitConfig;
+import com.gis.entity.SceneEntity;
+import com.gis.entity.SecondHandEntity;
+import com.gis.exception.BaseRuntimeException;
+import com.gis.mapper.SceneMapper;
+import com.gis.mapper.SecondHandMapper;
+import com.gis.server.SceneService;
+import com.gis.util.AliyunOssUtil;
+import com.gis.util.CmdUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.annotation.RabbitHandler;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.concurrent.*;
+
+
+/**
+ * Created by owen on 2021/9/8 0012 10:05
+ */
+@Slf4j
+@Component
+@RabbitListener(queues = RabbitConfig.SECOND_HAND_QUEUE) // 指定监听队列
+public class SecondHandConsumer {
+
+
+    @Autowired
+    ConfigConstant configConstant;
+
+
+    @Autowired
+    AliyunOssUtil aliyunOssUtil;
+
+    @Autowired
+    SecondHandMapper secondHandMapper;
+
+    @RabbitHandler
+    public void getMessage(String param)  {
+        log.warn("run Listener SecondHandConsumer: " + param);
+        try {
+            Thread.sleep(1000);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+        processPano(param);
+        log.warn("end Listener SecondHandConsumer: "+ param);
+    }
+
+
+    /**
+     * 切图会超时回调
+     * @param id
+     */
+    private void processPano(String id)  {
+
+        log.warn("run processPano : " + id);
+        long start = System.currentTimeMillis();
+//        SceneEntity entity = sceneService.findById(id);
+        SecondHandEntity entity = secondHandMapper.findById(id);
+        if (entity == null) {
+            log.error("场景不存在: " + id);
+            return;
+        }
+        // 切图
+        String panoPath = entity.getPath();
+        String cmd = CmdConstant.PANO_KRPANO + panoPath;
+
+
+        // 超时处理机制
+        final ExecutorService exec = Executors.newFixedThreadPool(1);
+        Callable<String> call = new Callable<String>() {
+            @Override
+            public String call() throws Exception {
+                CmdUtils.callLine(cmd, 200);
+                long end = System.currentTimeMillis();
+                log.info("切图完成耗时: {} s" ,(end-start)/1000);
+                log.warn("end processListener : "+ id);
+                return "执行完成";
+            }
+        };
+        // 超时回调
+        Future<String> future = exec.submit(call);
+        try {
+            //任务处理超时时间设为 3分钟
+            String obj = future.get(configConstant.queueTimeout, TimeUnit.MINUTES);
+            entity.setStatus(3);
+            // 上传切图
+            uploadOssDir(entity);
+            log.info("任务成功返回: " + obj);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+            log.error("其他异常");
+            StringWriter trace=new StringWriter();
+            log.error(trace.toString());
+            entity.setStatus(2);
+        } catch (ExecutionException e) {
+            e.printStackTrace();
+            StringWriter trace=new StringWriter();
+            e.printStackTrace(new PrintWriter(trace));
+            log.error("超时了 1");
+            // 异常日志要打印,不然不会出现在日志文件中,只会出现在控制台
+            log.error(trace.toString());
+            entity.setStatus(2);
+            future.cancel(true);
+        } catch (TimeoutException e) {
+            e.printStackTrace();
+            StringWriter trace=new StringWriter();
+            e.printStackTrace(new PrintWriter(trace));
+            log.error("超时了 2");
+            log.error(trace.toString());
+            entity.setStatus(2);
+            future.cancel(true);
+        } finally {
+            secondHandMapper.updateStatus(entity.getStatus(), id);
+        }
+    }
+
+
+
+    /**
+     * 2021-09-08
+     * 上传切图目录
+     */
+    public void uploadOssDir(SecondHandEntity entity){
+        log.info("run uploadOss, id: " + entity.getId());
+        long start = System.currentTimeMillis();
+//        String houseId = entity.getHouseId();
+        String sceneCode = entity.getSceneCode();
+//        String dirCode = houseId + "/" + sceneCode;
+        String uploadDir = configConstant.filePath + sceneCode;
+        log.info("uploadDir:" + uploadDir);
+        String ossDir = "oss://" + configConstant.ossBucket+"/"+configConstant.ossBasePath + sceneCode ;
+        log.info("ossDir:" + ossDir);
+
+        String cmd = CmdConstant.OSSUTIL_UPLOAD_DIR;
+        cmd = cmd.replaceAll("@input", uploadDir);
+        cmd = cmd.replaceAll("@output", ossDir);
+        CmdUtils.callshell(cmd);
+        long end = System.currentTimeMillis();
+        log.info("切图上传完成, 耗时:{} s" , (end-start)/1000 );
+    }
+
+
+
+
+
+
+
+}

+ 20 - 0
cms_pano_consumer/src/main/java/com/gis/mapper/SecondHandMapper.java

@@ -0,0 +1,20 @@
+package com.gis.mapper;
+
+
+import com.gis.entity.SecondHandEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@Mapper
+public interface SecondHandMapper extends IBaseMapper<SecondHandEntity, String> {
+
+    @Select("select id, path, scene_code from tb_second_hand where is_delete=0 and id=#{id}")
+    SecondHandEntity findById(String id);
+
+    @Update("update tb_second_hand set status=#{status}, update_time=NOW() where id=#{id}")
+    void updateStatus(Integer status, String id);
+}

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

@@ -1,132 +1,132 @@
-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;
-
-import java.io.IOException;
-
-
-/**
- * Created by owen on 2021/1/20 0020 20:38
- */
-@Slf4j
-@Component
-public class AsyncTask {
-
-    @Autowired
-    AliyunOssUtil aliyunOssUtil;
-
-    @Autowired
-    ConfigConstant configConstant;
-
-    @Async("taskExecutor")
-    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
-        String dirPath = basePath + "/vtour/panos";
-
-        long OssStart = System.currentTimeMillis();
-        log.info("dirPath: " + dirPath);
-        log.info("dirCode: " + dirCode);
-        log.info("ossBasePath: " + configConstant.ossBasePath);
-        try {
-            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: 完成
-            entity.setStatus(3);
-        } catch (IOException e) {
-            entity.setStatus(2);
-            log.error("上传oss有误");
-            e.printStackTrace();
-        }
-        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();
-        }
-    }
-}
+//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;
+//
+//import java.io.IOException;
+//
+//
+///**
+// * Created by owen on 2021/1/20 0020 20:38
+// */
+//@Slf4j
+//@Component
+//public class AsyncTask {
+//
+//    @Autowired
+//    AliyunOssUtil aliyunOssUtil;
+//
+//    @Autowired
+//    ConfigConstant configConstant;
+//
+//    @Async("taskExecutor")
+//    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
+//        String dirPath = basePath + "/vtour/panos";
+//
+//        long OssStart = System.currentTimeMillis();
+//        log.info("dirPath: " + dirPath);
+//        log.info("dirCode: " + dirCode);
+//        log.info("ossBasePath: " + configConstant.ossBasePath);
+//        try {
+//            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: 完成
+//            entity.setStatus(3);
+//        } catch (IOException e) {
+//            entity.setStatus(2);
+//            log.error("上传oss有误");
+//            e.printStackTrace();
+//        }
+//        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();
+//        }
+//    }
+//}

+ 0 - 45
cms_pano_consumer/src/main/java/com/gis/task/TaskExecutePool.java

@@ -1,45 +0,0 @@
-//package com.gis.task;
-//
-//import org.springframework.beans.factory.annotation.Value;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.scheduling.annotation.EnableAsync;
-//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-//import org.springframework.stereotype.Component;
-//
-//import java.util.concurrent.Executor;
-//import java.util.concurrent.ThreadPoolExecutor;
-//
-///**
-// * Created by owen on 2017/8/29.
-// * https://blog.csdn.net/h2453532874/article/details/108480673
-// */
-////@Configuration
-//@Component
-//@EnableAsync
-//public class TaskExecutePool {
-//
-//    @Value("${spring.task.pool.corePoolSize}")
-//    private int corePoolSize;
-//    @Value("${spring.task.pool.corePoolSize}")
-//    private int maxPoolSize;
-//    @Value("${spring.task.pool.keepAliveSeconds}")
-//    private int keepAliveSeconds;
-//    @Value("${spring.task.pool.queueCapacity}")
-//    private int queueCapacity;
-//
-//    @Bean
-//    public Executor taskExecutor() {
-//        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-//        executor.setCorePoolSize(corePoolSize);
-//        executor.setMaxPoolSize(maxPoolSize);
-//        executor.setQueueCapacity(queueCapacity);
-//        executor.setKeepAliveSeconds(keepAliveSeconds);
-//        executor.setThreadNamePrefix("MyExecutor-");
-//        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
-//        // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
-//        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
-//        executor.initialize();
-//        return executor;
-//    }
-//}

+ 9 - 3
cms_pano_consumer/src/main/resources/application-dev.properties

@@ -37,9 +37,15 @@ spring.datasource.druid.stat-view-servlet.enabled=true
 #spring.rabbitmq.password=guest
 
 # rabbitmq ¼¯ÈºÅäÖÃ
-spring.rabbitmq.address=127.0.0.1:5672
-spring.rabbitmq.username=guest
-spring.rabbitmq.password=guest
+#spring.rabbitmq.address=127.0.0.1:5672
+#spring.rabbitmq.username=guest
+#spring.rabbitmq.password=guest
+
+# ÏîÄ¿²âÊÔ·þÎñ
+spring.rabbitmq.address=8.135.106.227:5672
+spring.rabbitmq.username=admin
+spring.rabbitmq.password=admin123
+
 spring.rabbitmq.virtual-host=/
 spring.rabbitmq.connection-timeout=15000
 # confirmģʽ

+ 11 - 0
cms_pano_consumer/src/main/resources/sh/shutdown.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+RESOURCE_NAME=cms_pano_consumer.jar
+   Pid=`awk '{print $1}' tpid`
+
+if [ ${Pid} ]; then
+kill -9 $Pid
+echo 'Kill Process!'
+else
+echo 'Stop failed!'
+fi
+

+ 11 - 0
cms_pano_consumer/src/main/resources/sh/startup.sh

@@ -0,0 +1,11 @@
+#!/bin/sh
+RESOURCE_NAME=cms_pano_consumer.jar
+rm -f tpid
+nohup java -jar ./$RESOURCE_NAME --spring.profiles.active=sit & echo $! > tpid
+echo Start Success!
+echo
+
+
+
+
+

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

@@ -61,9 +61,14 @@ spring.redis.jedis.pool.max-wait=-1ms
 #spring.rabbitmq.password=guest
 
 # rabbitmq ¼¯ÈºÅäÖÃ
-spring.rabbitmq.address=localhost:5672
-spring.rabbitmq.username=guest
-spring.rabbitmq.password=guest
+#spring.rabbitmq.address=localhost:5672
+#spring.rabbitmq.username=guest
+#spring.rabbitmq.password=guest
+
+# ÏîÄ¿²âÊÔ·þÎñ
+spring.rabbitmq.address=8.135.106.227:5672
+spring.rabbitmq.username=admin
+spring.rabbitmq.password=admin123
 spring.rabbitmq.virtual-host=/
 spring.rabbitmq.connection-timeout=15000
 # confirmģʽ

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

@@ -33,7 +33,8 @@ spring.datasource.druid.stat-view-servlet.enabled=true
 
 
 # redis ·Ö²¼Ê½µÄ
-spring.redis.cluster.nodes=10.1.152.54:6379
+#spring.redis.cluster.nodes=10.1.152.54:6379
+spring.redis.cluster.nodes=127.0.0.1:6379
 spring.redis.database=0
 spring.redis.password=
 spring.redis.timeout=3000ms

+ 3 - 1
cms_pano_fcb/gis_common/src/main/java/com/gis/common/constant/ConfigConstant.java

@@ -20,7 +20,9 @@ public class ConfigConstant {
 //    @Value("${server.domain}")
 //    public  String serverDomain;
 
-
+    /**配置环境*/
+    @Value("${spring.profiles.active}")
+    public String active;
 
     @Value("${project.name}")
     public String projectName;

+ 35 - 0
cms_pano_fcb/gis_common/src/main/java/com/gis/common/constant/RabbitConfig.java

@@ -49,6 +49,16 @@ public class RabbitConfig {
     /** 全景图交换机路由*/
     public static final String TEST_QUEUE_ROUTING = "testOwenQueueRouting";
 
+     // 2021-09-08
+    /** 二手房队列*/
+    public static final String SECOND_HAND_QUEUE = "secondHandQueue";
+
+    /** 二手房交换机*/
+    public static final String SECOND_HAND_EXCHANGE = "secondHandExchange";
+
+    /** 二手房交换机路由*/
+    public static final String SECOND_HAND_QUEUE_ROUTING = "secondHandQueueRouting";
+
 
 
 
@@ -105,6 +115,31 @@ public class RabbitConfig {
         return BindingBuilder.bind(testQueue).to(testExchange).with(TEST_QUEUE_ROUTING).noargs();
     }
 
+    /**
+     * 二手房队列
+     */
+    @Bean
+    public Queue secondHandQueue() {
+        return new Queue(SECOND_HAND_QUEUE);
+    }
+
+    /**
+     * 二手房交换机
+     */
+    @Bean
+    public Exchange secondHandExchange(){
+        return new DirectExchange(SECOND_HAND_EXCHANGE, true, false);
+    }
+
+
+    /**
+     * 二手房队列绑定交换机
+     */
+    @Bean
+    public Binding secondHandRoutingExchange(Queue secondHandQueue, Exchange secondHandExchange){
+        return BindingBuilder.bind(secondHandQueue).to(secondHandExchange).with(SECOND_HAND_QUEUE_ROUTING).noargs();
+    }
+
 
     /**
      * 以下三个方法是配置集群

+ 1 - 6
cms_pano_fcb/gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -161,8 +161,6 @@ public class FileUtils {
 
         log.info("savePath: {}", savePath);
 
-
-
         try {
             FileUtil.writeFromStream(file.getInputStream(), savePath);
         } catch (IOException e) {
@@ -172,13 +170,10 @@ public class FileUtils {
         // 上传oss
         String ossPath = ossBasePath + dirType + newName;
         aliyunOssUtil.upload(savePath, ossPath);
-//        asyncTask.uploadOss(savePath, ossPath);
 
         String ossUrl = ossDomain + ossPath + "?d=" + System.currentTimeMillis();
         log.info("ossUrl: {}", ossUrl);
 
-
-
         return ossUrl;
 
     }
@@ -296,7 +291,7 @@ public class FileUtils {
      */
     public static String getCode(){
         String sceneCode = RandomUtils.randowString(9);
-        return  "fcb_" +sceneCode;
+        return  "SH_" +sceneCode;
     }
 
 

+ 15 - 0
cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/dto/SecondHandPageDto.java

@@ -0,0 +1,15 @@
+package com.gis.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2021/9/9 0008 16:31
+ */
+@Data
+public class SecondHandPageDto extends PageDto {
+
+    @ApiModelProperty(value = "houseId", required = true)
+    private String houseId;
+
+}

+ 100 - 0
cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/entity/SecondHandEntity.java

@@ -0,0 +1,100 @@
+package com.gis.domain.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.io.Serializable;
+
+/**
+ * 二手房场景实体类
+ */
+@Data
+@Entity
+@Table(name = "tb_second_hand")
+public class SecondHandEntity extends BaseEntity implements Serializable {
+
+
+    private static final long serialVersionUID = -1624241144090646200L;
+
+    @ApiModelProperty(value = "场景码")
+    private String sceneCode;
+
+    @ApiModelProperty(value = "存放地址")
+    private String path;
+
+    @ApiModelProperty(value = "场景名称")
+    private String sceneTitle;
+
+    @ApiModelProperty(value = "场景url")
+    private String webSite;
+
+    @ApiModelProperty(value = "简介")
+    private String description;
+
+    @ApiModelProperty(value = "oss存放地址")
+    private String ossPath;
+
+    @ApiModelProperty(value = "状态 1:切图中, 2:失败, 3:完成(未审核), 4:审核通过")
+    private Integer status;
+
+    @ApiModelProperty(value = "类型, 楼盘:building, 园林:garden, 户型:house")
+    private String type;
+
+    @ApiModelProperty(value = "楼盘id")
+    private String houseId;
+
+    @ApiModelProperty(value = "创建人")
+    private String createUserId;
+
+    @ApiModelProperty(value = "封面图")
+    private String icon;
+
+    @ApiModelProperty(value = "文件名")
+    private String fileName;
+
+    @ApiModelProperty(value = "someData")
+    private String someData;
+
+    @ApiModelProperty(value = "样版间名称")
+    private String roomName;
+
+
+
+    /**
+     * 只可以存一次,不能重复,重复需要删除旧数据
+     */
+    @ApiModelProperty(value = "vrModelId(四维看看场景id), 只有在house类型才有此数据")
+    private String vrModelId;
+
+    @ApiModelProperty(value = "恒大Id")
+    private String hengdaId;
+
+    @ApiModelProperty(value = "排序(序号小排前面)")
+    private Integer sort;
+
+    @ApiModelProperty(value =  "初始视觉")
+    private String initVisual;
+
+    @ApiModelProperty(value =  "热点关联场景, 场景码,允许多个以逗号隔开")
+    private String useHots;
+
+    @ApiModelProperty(value =  "模型在全景园林显示byType=garden")
+    private String byType;
+
+    @Transient
+    @ApiModelProperty(value = "初始场景是否已使用,0:否, 1:是")
+    private Integer isUseIndex = 0;
+
+
+    @ApiModelProperty(value = "恒大样本间id, 只有在house类型才有此数据")
+    private String roomId;
+
+    @ApiModelProperty(value = "恒大经纪人id(讲房顾问), 只有在house类型才有此数据")
+    private String agentId;
+
+
+
+}

+ 52 - 0
cms_pano_fcb/gis_domain/src/main/java/com/gis/domain/vo/SceneAndInitVo.java

@@ -0,0 +1,52 @@
+package com.gis.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * Created by owen on 2021-09-08 新增
+ * 场景码并标记初始场景
+ */
+@Data
+public class SceneAndInitVo {
+
+    @ApiModelProperty(value = "id, 修改时必须传,新增忽略", name = "id")
+    private String id;
+
+    @ApiModelProperty(value = "场景码")
+    private String sceneCode;
+
+    @ApiModelProperty(value = "楼盘id")
+    private String houseId;
+
+    @ApiModelProperty(value = "缩略图(管理后台用)")
+    private String icon;
+
+    @ApiModelProperty(value = "类型, 楼盘:building, 园林:garden, 户型:house")
+    private String type;
+
+    @ApiModelProperty(value = "场景名称")
+    private String sceneTitle;
+
+//    @ApiModelProperty(value = "样版间名称")
+//    private String roomName;
+
+    @ApiModelProperty(value = "场景url")
+    private String webSite;
+
+    @ApiModelProperty(value =  "模型在全景园林显示byType=garden")
+    private String byType;
+
+    @ApiModelProperty(value =  "是否初始场景, 0:否, 1:是")
+    private Integer isInit;
+
+//    @ApiModelProperty(value = "场景id")
+//    private String sceneId;
+//
+//    @ApiModelProperty(value = "样版间id")
+//    private String roomId;
+
+
+}

+ 4 - 12
cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/SceneInitMapper.java

@@ -22,15 +22,6 @@ public interface SceneInitMapper extends IBaseMapper<SceneInitEntity, String> {
     @Update("UPDATE tb_scene_init SET is_delete = 1, update_time = NOW() where is_delete = 0 AND house_id = #{houseId}")
     void removeByHouseId(String houseId);
 
-//    @Update("UPDATE tb_scene_init SET is_delete = 1 where is_delete = 0 AND house_id = #{houseId} AND scene_code = #{sceneCode}")
-//    void removeByHouseIdAndSceneCode(String houseId, String sceneCode);
-
-    // 按创建日期前三条信息
-//    @Select("select a.id, a.house_id, a.scene_code, b.icon as icon, b.type as type, b.scene_title as sceneTitle, " +
-//            "b.web_site as webSite, b.room_name as roomName, b.by_type as byType " +
-//            " from tb_scene_init a left join tb_scene b on a.scene_code = b.scene_code AND a.house_id = b.house_id " +
-//            " where a.is_delete = 0 and a.house_id = #{houseId} and b.is_delete = 0 order by a.create_time asc limit 3")
-//    List<SceneInitDto> voFindByHouseId(String houseId);
 
     // 按创建日期前三条信息
     @Select("select a.id, a.house_id, b.scene_code, b.icon as icon, b.type as type, b.scene_title as sceneTitle, " +
@@ -40,12 +31,13 @@ public interface SceneInitMapper extends IBaseMapper<SceneInitEntity, String> {
     List<SceneInitVo> voFindByHouseId(String houseId);
 
 
-//    @Select("select * from tb_scene_init where is_delete = 0 and house_id = #{houseId} AND scene_code = #{sceneCode}")
-//    List<SceneInitEntity> findByHouseIdAndSceneCode(String houseId, String sceneCode);
-
     @Select("select * from tb_scene_init where is_delete = 0 and house_id = #{houseId} AND scene_id = #{sceneId}")
     List<SceneInitEntity> findByHouseIdAndSceneId(String houseId, String sceneId);
 
     @Update("UPDATE tb_scene_init SET is_delete = 1, update_time = NOW() where is_delete = 0 AND house_id = #{houseId} AND scene_id = #{sceneId}")
     void removeByHouseIdAndSceneId(String houseId, String sceneId);
+
+    // 获取场景id
+    @Select("select scene_id from tb_scene_init where is_delete = 0 and house_id = #{houseId}")
+    List<String> getSceneIdByHouseId(String houseId);
 }

+ 20 - 16
cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/SceneMapper.java

@@ -3,6 +3,7 @@ package com.gis.mapper;
 
 import com.gis.domain.dto.ScenePageDto;
 import com.gis.domain.entity.SceneEntity;
+import com.gis.domain.vo.SceneAndInitVo;
 import com.gis.mapper.provider.SceneProvider;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
@@ -23,14 +24,14 @@ public interface SceneMapper extends IBaseMapper<SceneEntity, String> {
     @SelectProvider(type = SceneProvider.class, method = "searchUnion")
     List<SceneEntity> searchUnion(ScenePageDto param);
 
-    @Update("UPDATE tb_scene SET is_index=#{index}")
-    void setIndex(Integer index);
-
-    @Update("UPDATE tb_scene SET is_index=#{index} where house_id = #{houseId}")
-    void setIndexByHouseId(Integer index, String houseId);
-
-    @Update("UPDATE tb_scene SET is_index=#{index} where id = #{id}")
-    void setIndexById(String id, Integer index);
+//    @Update("UPDATE tb_scene SET is_index=#{index}")
+//    void setIndex(Integer index);
+//
+//    @Update("UPDATE tb_scene SET is_index=#{index} where house_id = #{houseId}")
+//    void setIndexByHouseId(Integer index, String houseId);
+//
+//    @Update("UPDATE tb_scene SET is_index=#{index} where id = #{id}")
+//    void setIndexById(String id, Integer index);
 
     @Select("select * from tb_scene where is_delete = 0 and scene_code = #{sceneCode}")
     SceneEntity findBySceneCode(String sceneCode);
@@ -38,8 +39,8 @@ public interface SceneMapper extends IBaseMapper<SceneEntity, String> {
     @Select("select * from tb_scene where is_delete = 0 and scene_code = #{sceneCode}")
     List<SceneEntity> listFindBySceneCode(String sceneCode);
 
-    @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}")
+//    SceneEntity findByVrModelId(String vrModelId);
 
     @Select("select * from tb_scene where is_delete = 0 and vr_model_id = #{vrModelId}")
     List<SceneEntity> findByVrModelId2(String vrModelId);
@@ -53,8 +54,8 @@ 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);
+//    @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} , update_time = NOW() where id = #{id}")
     void setSortById(String id, String sort);
@@ -87,8 +88,8 @@ public interface SceneMapper extends IBaseMapper<SceneEntity, String> {
     @Update("UPDATE tb_scene SET icon = #{icon} , update_time = NOW() where is_delete = 0 AND scene_code = #{sceneCode}")
     void updateIcon(String sceneCode, String icon);
 
-    @Select("select house_id, scene_title, is_index, scene_code, is_delete from tb_scene where is_delete = 0 and is_index=1")
-    List<SceneEntity> findAllByIndex();
+//    @Select("select house_id, scene_title, is_index, scene_code, is_delete from tb_scene where is_delete = 0 and is_index=1")
+//    List<SceneEntity> findAllByIndex();
 
     @Select("select * from tb_scene where is_delete = 0 and house_id = #{houseId} and room_id = #{roomId}")
     List<SceneEntity> findByHouseIdAndRoomId(String houseId, String roomId);
@@ -99,9 +100,12 @@ public interface SceneMapper extends IBaseMapper<SceneEntity, String> {
     @SelectProvider(type = SceneProvider.class, method = "countByType")
     Integer countByType(String houseId, String type);
 
-    @Select("select id, house_id, scene_code,hengda_id,room_id, type, is_delete,status,create_time,update_time  from tb_scene where is_delete = 0 and status >= 3 and type = 'house'")
-    List<SceneEntity> findByRoodData();
+//    @Select("select id, house_id, scene_code,hengda_id,room_id, type, is_delete,status,create_time,update_time  from tb_scene where is_delete = 0 and status >= 3 and type = 'house'")
+//    List<SceneEntity> findByRoodData();
 
     @Select("select scene_code, by_type from tb_scene where is_delete = 0 and type = #{type} and house_id = #{houseId}")
     List<SceneEntity> getVrSceneCodeAndType(String houseId, String type);
+
+    @Select("select * from tb_scene where is_delete = 0 and (status=3 or status=4) and house_id = #{houseId}")
+    List<SceneAndInitVo> voFindByHouseId(String houseId);
 }

+ 67 - 0
cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/SecondHandMapper.java

@@ -0,0 +1,67 @@
+package com.gis.mapper;
+
+
+
+import com.gis.domain.dto.SecondHandPageDto;
+import com.gis.domain.entity.SceneEntity;
+import com.gis.domain.entity.SecondHandEntity;
+import com.gis.mapper.provider.SceneProvider;
+import com.gis.mapper.provider.SecondHandProvider;
+import org.apache.ibatis.annotations.Mapper;
+
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.apache.ibatis.annotations.Update;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+
+@Component
+@Mapper
+public interface SecondHandMapper extends IBaseMapper<SecondHandEntity, String> {
+
+    /**
+     * for update 锁表更新完,才能进行更新,需要开启事务
+     * 并发量大作会出现脏数据
+     *
+     * @param id
+     * @return
+     */
+    @Select("select * from tb_second_hand where is_delete = 0 and id = #{id} for update")
+    SecondHandEntity findByIdForUpdate(String id);
+
+
+    @Select("select * from tb_second_hand where is_delete = 0 and scene_code = #{sceneCode}")
+    SecondHandEntity findBySceneCode(String sceneCode);
+
+    @Update("UPDATE tb_second_hand SET sort=#{sort} , update_time = NOW() where id = #{id}")
+    void setSortById(String id, String sort);
+
+    @Select("select * from tb_second_hand where is_delete = 0 and status = #{status} and house_id = #{houseId}")
+    List<SecondHandEntity> findByHouseIdAndStatus(String houseId, String status);
+
+    @SelectProvider(type = SecondHandProvider.class, method = "search")
+    List<SecondHandEntity> search(SecondHandPageDto param);
+
+    @Select("select * from tb_second_hand where is_delete = 0 and house_id = #{houseId} and use_hots like #{sceneCode}")
+    List<SecondHandEntity> searchUseHots(String houseId, String sceneCode);
+
+    @Update("UPDATE tb_second_hand SET is_delete = 1, update_time = NOW() where is_delete = 0 AND house_id = #{houseId}")
+    void houseRemove(String houseId);
+
+    @Update("UPDATE tb_second_hand SET status = #{status}, update_time = NOW() where is_delete = 0 AND house_id = #{houseId}")
+    void houseAudit(String houseId, String status);
+
+    @Select("select * from tb_second_hand where is_delete = 0 and scene_code = #{sceneCode}")
+    List<SecondHandEntity> listFindBySceneCode(String sceneCode);
+
+    @Select("select * from tb_second_hand where is_delete = 0 and vr_model_id = #{vrModelId}")
+    List<SecondHandEntity> findByVrModelId2(String vrModelId);
+
+    @Select("select * from tb_second_hand where is_delete = 0 and house_id = #{houseId} and room_id = #{roomId}")
+    List<SecondHandEntity> findByHouseIdAndRoomId(String houseId, String roomId);
+
+    @Select("select * from tb_second_hand where is_delete = 0 and vr_model_id = #{vrModelId} and house_id = #{houseId}")
+    SecondHandEntity findByVrModelIdAndHouseId(String vrModelId, String houseId);
+}

+ 45 - 0
cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/provider/SecondHandProvider.java

@@ -0,0 +1,45 @@
+package com.gis.mapper.provider;
+
+import com.gis.domain.dto.SecondHandPageDto;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Created by owen on 2021/1/8 0008 16:50
+ */
+@Log4j2
+public class SecondHandProvider {
+
+    public String search(SecondHandPageDto param){
+        StringBuffer sql = new StringBuffer("select * from tb_second_hand where is_delete = 0");
+
+        String houseId = param.getHouseId();
+        if(!StringUtils.isAllBlank(houseId)){
+            sql.append(" and ( house_id = '").append(houseId).append("' )");
+        }
+
+        String searchKey = param.getSearchKey();
+        if(!StringUtils.isAllBlank(searchKey)){
+            sql.append(" and (");
+            sql.append(" scene_title like '%").append(searchKey).append("%'");
+            sql.append( ")");
+        }
+
+
+        String status = "3";
+        // 传3 过来,会把审核:4、未审核:3的都传给前端
+        if(StringUtils.isNotBlank(status)){
+            sql.append(" and ( status >= '").append(status).append("' )");
+        }
+
+        sql.append(" order by sort asc, create_time asc");
+
+        log.info("sql: {}", sql.toString());
+        return sql.toString();
+    }
+
+
+
+
+
+}

+ 2 - 0
cms_pano_fcb/gis_service/src/main/java/com/gis/service/HouseService.java

@@ -16,4 +16,6 @@ public interface HouseService  {
     Result statistics(String houseId);
 
     Result getVrSceneCodeAndType(String houseId);
+
+    Result getVrAndIndex(String houseId);
 }

+ 2 - 3
cms_pano_fcb/gis_service/src/main/java/com/gis/service/SceneInitService.java

@@ -18,18 +18,17 @@ public interface SceneInitService extends IBaseService<SceneInitEntity, String>
 
     Result saveEntity(SceneInitDto param);
 
-//    void removeByHouseIdAndSceneCode(String houseId, String sceneCode);
 
     Result uploadFixedName(MultipartFile file, String sceneCode);
 
-//    List<SceneInitDto> voFindByHouseId(String houseId);
     List<SceneInitVo> voFindByHouseId(String houseId);
 
     List<SceneInitEntity> findByHouseId(String houseId);
 
-//    List<SceneInitEntity> findByHouseIdAndSceneCode(String houseId, String sceneCode);
 
     List<SceneInitEntity> findByHouseIdAndSceneId(String houseId, String id);
 
     void removeByHouseIdAndSceneId(String houseId, String id);
+
+    List<String> getSceneIdByHouseId(String houseId);
 }

+ 53 - 0
cms_pano_fcb/gis_service/src/main/java/com/gis/service/SecondHandService.java

@@ -0,0 +1,53 @@
+package com.gis.service;
+
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.gis.common.util.Result;
+import com.gis.domain.dto.*;
+import com.gis.domain.entity.SecondHandEntity;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * Created by owen on 2021/9/8 0011 16:14
+ */
+public interface SecondHandService extends IBaseService<SecondHandEntity, String> {
+
+    Result uploadPanoRabbitMq(MultipartFile file, String houseId, String hengDaId);
+
+    Result testQueueSecondHand();
+
+    Result editXml(XmlDataDto param);
+
+    Result findBySceneCode(String sceneCode);
+
+    Result updateInitIcon(String id, String icon);
+
+    Result setSort(Map<String, String> param);
+
+    Result upload(MultipartFile file);
+
+    JSONObject jsonSearch(SecondHandPageDto param);
+
+    Result editSomeData(EditSomeDataDto param);
+
+    Result remove(String id);
+
+    List<SecondHandEntity> searchUseHots(String houseId, String sceneCode);
+
+    Result saveUseHots(UseHotsDto param);
+
+    Result houseRemove(String houseId);
+
+    Result houseAudit(String houseId, String status);
+
+    Result vrFindBySceneCode(String sceneCode);
+
+    Result findVrModel(SceneRroPageDto param);
+
+    Result saveVrModel(VrModelDto param);
+}

+ 21 - 74
cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/HouseServiceImpl.java

@@ -7,9 +7,12 @@ import com.gis.common.util.Result;
 import com.gis.domain.dto.EditHouseDto;
 import com.gis.domain.dto.HouseDto;
 import com.gis.domain.entity.SceneEntity;
+import com.gis.domain.entity.SceneInitEntity;
+import com.gis.domain.vo.SceneAndInitVo;
 import com.gis.feign.HouseFeign;
 import com.gis.mapper.SceneMapper;
 import com.gis.service.HouseService;
+import com.gis.service.SceneInitService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -34,6 +37,9 @@ public class HouseServiceImpl implements HouseService {
     @Autowired
     HouseFeign houseFeign;
 
+    @Autowired
+    SceneInitService sceneInitService;
+
 
     @Override
     public Result checkStatus(String houseId, String status) {
@@ -57,10 +63,6 @@ public class HouseServiceImpl implements HouseService {
 
         // 检查VR项目状态
         String houseId = param.getHouseId();
-//        Result resStatus =  canEdit(houseId);
-//        if (resStatus != null) {
-//            return resStatus;
-//        }
         if (!canEdit(houseId)) {
             log.error("VR项目不可编辑");
             return Result.failure(7005, "VR项目不可编辑");
@@ -138,78 +140,25 @@ public class HouseServiceImpl implements HouseService {
     }
 
     /**
-     * 查询VR项目状态
+     * 返回改房源下的所有场景,并标记那些是初始场景
      * @param houseId
      * @return
      */
-//    private Result getHouseStatus(String houseId){
-//        Result result = null;
-//        try {
-//            result = houseFeign.findByHouseId(houseId);
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        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);
-//            log.warn("可以正常编辑");
-//            if (status.equals("1")) {
-//                log.warn("审核中不能编辑");
-//                return Result.failure(7005, "审核中不能编辑");
-//            }
-//            if (status.equals("2")) {
-//                log.warn("已审核中不能编辑");
-//                return Result.failure(7006, "已审核中不能编辑");
-//            }
-//
-//
-//        }
-//
-//        if (result.getCode() == -1){
-//            log.error("VR项目接口查询失败:" + result.getMsg() );
-//            return Result.failure(7007, "VR项目接口查询失败");
-//        }
-//
-//        return null;
-//    }
-
+    @Override
+    public Result getVrAndIndex(String houseId) {
+        // 查询status大于等于3的场景
+        List<SceneAndInitVo> sceneList = entityMapper.voFindByHouseId(houseId);
+        List<String> sceneIds = sceneInitService.getSceneIdByHouseId(houseId);
+        for (SceneAndInitVo vo : sceneList) {
+            vo.setIsInit(0);
+            if (sceneIds.contains(vo.getId())){
+                // 初始场景
+             vo.setIsInit(1);
+            }
+        }
+        return Result.success(sceneList);
+    }
 
-    /**
-     * 查询VR项目是否可编辑
-     * true: 可编辑
-     * false: 不可编辑
-     * @param houseId
-     * @return
-     */
-//    private Result canEdit(String houseId){
-////        Result result = null;
-////        try {
-////            result = houseFeign.canEdit(houseId);
-////            log.info("房车宝返回数据:{}", result);
-////        } catch (Exception e) {
-////            e.printStackTrace();
-////            log.error("调用房车宝接口失败");
-////            throw new BaseRuntimeException("调用房车宝接口失败");
-////        }
-////        if (result.getCode() == 0) {
-////            boolean data = (boolean) result.getData();
-////            if (data) {
-////                log.info("vr项目可编辑");
-////                return Result.success();
-////            } else {
-////                log.info("vr项目不可编辑");
-////                return Result.failure(7005, "VR项目不可编辑");
-////            }
-////
-////        } else {
-////            log.error("VR项目接口查询失败:" + result.getMsg() );
-////            return Result.failure(7007, "VR项目接口查询失败");
-////        }
-////
-////    }
 
     private boolean canEdit(String houseId){
         Result result = null;
@@ -223,14 +172,12 @@ public class HouseServiceImpl implements HouseService {
                     return true;
                 } else {
                     log.info("vr项目不可编辑");
-//                    throw new BaseRuntimeException(7005, "VR项目不可编辑");
                     return false;
                 }
 
             } else {
                 log.error("VR项目接口查询失败:" + result.getMsg() );
                 throw new BaseRuntimeException(7007, "VR项目接口查询失败");
-//                return Result.failure(7007, "VR项目接口查询失败");
             }
         } catch (Exception e) {
             e.printStackTrace();

+ 10 - 12
cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/SceneInitServiceImpl.java

@@ -95,25 +95,23 @@ public class SceneInitServiceImpl extends IBaseServiceImpl<SceneInitEntity, Stri
         entityMapper.removeByHouseIdAndSceneId(houseId, sceneId);
     }
 
-//    @Override
-//    public List<SceneInitEntity> findByHouseIdAndSceneCode(String houseId, String sceneCode) {
-//        return entityMapper.findByHouseIdAndSceneCode(houseId, sceneCode);
-//    }
+    /**
+     * 2021-09-08
+     * @param houseId
+     * @return 获取场景id
+     */
+    @Override
+    public List<String> getSceneIdByHouseId(String houseId) {
+        return entityMapper.getSceneIdByHouseId(houseId);
+    }
 
-//    @Override
-//    public List<SceneInitDto> voFindByHouseId(String houseId) {
-//        return entityMapper.voFindByHouseId(houseId);
-//    }
 
     @Override
     public List<SceneInitVo> voFindByHouseId(String houseId) {
         return entityMapper.voFindByHouseId(houseId);
     }
 
-//    @Override
-//    public void removeByHouseIdAndSceneCode(String houseId, String sceneCode) {
-//        entityMapper.removeByHouseIdAndSceneCode(houseId, sceneCode);
-//    }
+
 
     @Override
     public Result uploadFixedName(MultipartFile file, String sceneCode) {

+ 695 - 0
cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/SecondHandServiceImpl.java

@@ -0,0 +1,695 @@
+package com.gis.service.impl;
+
+import cn.hutool.core.io.FileTypeUtil;
+import cn.hutool.core.io.FileUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.gis.common.constant.CmdConstant;
+import com.gis.common.constant.ConfigConstant;
+import com.gis.common.constant.MsgCode;
+import com.gis.common.constant.RabbitConfig;
+import com.gis.common.exception.BaseRuntimeException;
+import com.gis.common.task.AsyncTask;
+import com.gis.common.util.*;
+import com.gis.domain.dto.*;
+import com.gis.domain.entity.SceneEntity;
+import com.gis.domain.entity.SceneInitEntity;
+import com.gis.domain.entity.SecondHandEntity;
+import com.gis.feign.HouseFeign;
+import com.gis.feign.SceneProFeign;
+import com.gis.mapper.IBaseMapper;
+import com.gis.mapper.SceneInitMapper;
+import com.gis.mapper.SceneMapper;
+import com.gis.mapper.SecondHandMapper;
+import com.gis.service.SceneInitService;
+import com.gis.service.SceneService;
+import com.gis.service.SecondHandService;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.transaction.Transactional;
+import javax.validation.constraints.NotBlank;
+import java.util.*;
+
+
+/**
+ * Created by owen on 2021/9/8 0011 16:16
+ */
+@Slf4j
+@Service
+@Transactional
+public class SecondHandServiceImpl extends IBaseServiceImpl<SecondHandEntity, String> implements SecondHandService {
+
+    @Autowired
+    private SecondHandMapper entityMapper;
+
+    @Autowired
+    SceneInitMapper sceneInitMapper;
+
+    @Autowired
+    SceneInitService sceneInitService;
+
+    @Autowired
+    private RabbitTemplate rabbitTemplate;
+
+    @Autowired
+    HouseFeign houseFeign;
+
+    @Autowired
+    SceneProFeign sceneProFeign;
+
+    @Autowired
+    ConfigConstant configConstant;
+
+    @Autowired
+    FileUtils fileUtils;
+
+    @Autowired
+    AliyunOssUtil aliyunOssUtil;
+
+    @Autowired
+    AsyncTask asyncTask;
+
+    @Override
+    public IBaseMapper<SecondHandEntity, String> getBaseMapper() {
+        return this.entityMapper;
+    }
+
+
+    /**
+     *
+     * @param file
+     * @param houseId 房源id
+     * @param groupId 小区id
+     * @return
+     */
+    @Override
+    public Result uploadPanoRabbitMq(MultipartFile file, String houseId, String hengDaId) {
+
+        // 检查非法文件上传
+        boolean checkFile = FileUtils.checkFile(file);
+        if (!checkFile) {
+            return Result.failure("上传文件格式有误, 请重新上传");
+        }
+
+        // 文件名不能为空
+        String originalFilename = file.getOriginalFilename();
+        originalFilename = StringUtils.substringBeforeLast(originalFilename, ".");
+        if (StringUtils.isAllBlank(originalFilename)) {
+            return Result.failure("文件名不能为空");
+        }
+
+
+        if (StringUtils.isBlank(houseId) || houseId.equals("null")) {
+            log.error("houseId不能为空");
+            return Result.failure("houseId不能为空");
+        }
+
+        if (!canEdit(houseId)) {
+            log.error("VR项目不可编辑");
+            return Result.failure(7005, "VR项目不可编辑");
+        }
+
+
+        String basePath = null;
+        String sceneCode = FileUtils.getCode();
+        SecondHandEntity entity = new SecondHandEntity();
+        try {
+
+            // 此方法可以读取到图片内部结构
+            String type = FileTypeUtil.getType(file.getInputStream());
+            if (!FileUtils.getType(type).equals("image")) {
+                log.error("非图片类型");
+                return Result.failure(7001, "非图片类型");
+            }
+
+            // todo 下次发版,建议前端判断图片大小比例,后端耗性能,不处理
+            if (!FileUtils.checkScale(file.getInputStream())) {
+                log.error("图片比例非2:1");
+                return Result.failure(7007, "图片比例非2:1");
+            }
+
+            log.info("type: " + type);
+
+
+            // 全景图只支持jpg图片格式
+            if (!type.equalsIgnoreCase("jpg")) {
+                log.error("图片格式错误,只支持jpg图片类型, type: " + type);
+                return Result.failure(7002, "只支持jpg图片类型");
+            }
+
+            // 写入文件
+            basePath = configConstant.filePath  + sceneCode;
+            String panoPath = basePath + "/" + sceneCode + "." + type;
+            log.info("panoPath: {}", panoPath);
+            FileUtil.writeFromStream(file.getInputStream(), panoPath);
+            log.info("文件写入服务器完成");
+
+            if (!FileUtil.isFile(panoPath)) {
+                log.error("全景图不存在");
+                return Result.failure("全景图不存在");
+            }
+
+
+
+            String uuid = RandomUtils.getUuid("SH");
+            entity.setId(uuid);
+            entity.setSceneCode(sceneCode);
+            entity.setPath(panoPath);
+            entity.setOssPath(configConstant.ossDomain + configConstant.projectName  + "/" + sceneCode);
+
+            // 压缩图片并上传oss
+            // 全景图缩略图统一命名规则: http:// oss/cms_pano_fcb/image/thumb_sceneCode.jpg
+            String iconPath = convertAndUploadOss(
+                    panoPath, configConstant.filePath, configConstant.ossBasePath, configConstant.ossDomain, 600, 300, "image/thumb_" + sceneCode + ".jpg");
+            log.info("iconPath:" + iconPath);
+            entity.setIcon(iconPath);
+            entity.setStatus(1);
+            entity.setHouseId(houseId);
+//            entity.setType(sceneType);
+            entity.setHengdaId(hengDaId);
+
+            // 出来文件名不要后缀
+            entity.setFileName(originalFilename);
+            entity.setSceneTitle(entity.getFileName());
+
+            // todo webSite待定
+            // /hengda.html?m=场景码&prodId=房车宝楼盘ID&houseId=自己维护的楼盘ID
+            String webSite = "/hengda.html?m=" + sceneCode + "&prodId=" + hengDaId + "&houseId=" + houseId;
+            log.info("webSite: " + webSite);
+            entity.setWebSite(webSite);
+
+            this.save(entity);
+
+            //发消息到mq
+            rabbitTemplate.convertAndSend(RabbitConfig.SECOND_HAND_EXCHANGE, RabbitConfig.SECOND_HAND_QUEUE_ROUTING, entity.getId());
+            log.info("二手房全景图入队成功: 场景码:{},场景id:{} ", sceneCode, entity.getId());
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        log.info("二手房全景图上传完成:{}", sceneCode);
+        return Result.success(entity);
+    }
+
+    @Override
+    public Result testQueueSecondHand() {
+        String msg = "cms_pano_fcb/image/thumb_sceneCode.jpg_" + System.currentTimeMillis();
+        rabbitTemplate.convertAndSend(RabbitConfig.SECOND_HAND_EXCHANGE, RabbitConfig.SECOND_HAND_QUEUE_ROUTING, msg);
+        log.info("msg: " + msg);
+        return Result.success(msg);
+    }
+
+    @Override
+    public Result editXml(XmlDataDto param) {
+        String id = param.getId();
+        SecondHandEntity entity = entityMapper.findByIdForUpdate(id);
+        if (entity == null) {
+            log.error("对象不存在,id : " + id);
+            return Result.failure("场景码不存在");
+        }
+
+
+        // 检查VR项目状态
+        String houseId = entity.getHouseId();
+        if (!canEdit(houseId)) {
+            log.error("VR项目不可编辑");
+            return Result.failure(7005, "VR项目不可编辑");
+        }
+
+
+        // 保存初始视觉
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("hlookat", param.getHlookat());
+        jsonObject.put("vlookat", param.getVlookat());
+        entity.setInitVisual(jsonObject.toJSONString());
+
+        this.update(entity);
+
+        return Result.success(entity.getOssPath());
+    }
+
+    @Override
+    public Result editSomeData(EditSomeDataDto param) {
+        String id = param.getId();
+        SecondHandEntity entity = this.findById(id);
+        if (entity == null) {
+            log.error("场景不存在, id: " + id);
+            return Result.failure("场景不存在");
+        }
+
+        // 检查VR项目状态
+        String houseId = entity.getHouseId();
+        if (!canEdit(houseId)) {
+            log.error("VR项目不可编辑");
+            return Result.failure(7005, "VR项目不可编辑");
+        }
+
+        BeanUtils.copyProperties(param, entity);
+        entity.setUpdateTime(new Date());
+        this.update(entity);
+        log.info("更新场景完成");
+        return Result.success();
+    }
+
+    @Override
+    public Result findBySceneCode(String sceneCode) {
+        SecondHandEntity entity = entityMapper.findBySceneCode(sceneCode);
+        if (entity == null) {
+            log.error("对象不存在, 场景码:{}", sceneCode);
+            return Result.failure("对象不存在");
+        }
+        return Result.success(entity);
+    }
+
+    @Override
+    public Result updateInitIcon(String id, String icon) {
+        // forUpdate:数据一致新问题
+        SecondHandEntity entity = entityMapper.findByIdForUpdate(id);
+        if (entity == null) {
+            log.error("对象不存在: {}", id);
+            return Result.failure("对象不存在");
+        }
+
+        entity.setIcon(icon);
+        entity.setUpdateTime(new Date());
+        this.update(entity);
+        log.info("更新初始画面成功");
+        return Result.success();
+    }
+
+    @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) {
+                SecondHandEntity entity = this.findById(id);
+                String houseId = entity.getHouseId();
+                if (!canEdit(houseId)) {
+                    log.error("VR项目不可编辑");
+                    return Result.failure(7005, "VR项目不可编辑");
+                }
+            }
+
+            String sort = m.getValue();
+            log.info("id: " + id);
+            log.info("sort: " + sort);
+            entityMapper.setSortById(id, sort);
+            n++;
+        }
+
+        return Result.success();
+    }
+
+    @Override
+    public Result upload(MultipartFile file) {
+
+        // 检查非法文件上传
+        boolean checkFile = FileUtils.checkFile(file);
+        if (!checkFile) {
+            return Result.failure("上传文件格式有误, 请重新上传");
+        }
+        // 直接上传oss
+        return Result.success(fileUtils.renameUploadOssBye(file, configConstant.ossBasePath + "secondHand/", configConstant.ossDomain));
+    }
+
+    @Override
+    public JSONObject jsonSearch(SecondHandPageDto param) {
+        startPage(param);
+        List<SecondHandEntity> search = entityMapper.search(param);
+        PageInfo<SecondHandEntity> page = new PageInfo<>(search);
+
+        JSONObject result = new JSONObject();
+        result.put("code", 0);
+        result.put("data", page);
+        result.put("msg", "操作成功");
+        // 是否存在计算中的场景, true: 需要轮询, false:不轮询
+        result.put("isCheck", checkStatus(param.getHouseId(), "1"));
+        return result;
+    }
+
+
+    @Override
+    public Result remove(String id) {
+        SecondHandEntity entity = this.findById(id);
+        if (entity.getStatus() == 1) {
+            return Result.failure(7004, "执行中的任务不能删除");
+
+        }
+        String sceneCode = entity.getSceneCode();
+        String houseId = entity.getHouseId();
+
+        // 检查VR项目状态
+        if (!canEdit(houseId)) {
+            log.error("VR项目不可编辑");
+            return Result.failure(7005, "VR项目不可编辑");
+        }
+
+        // 查询热点关联场景
+        List<SecondHandEntity> list = this.searchUseHots(houseId, sceneCode);
+        log.info("关联热点场景数量: " + list.size());
+        if (list.size() > 0) {
+            return Result.failure(7008, "有关联热点场景使用此场景,不能删除");
+        }
+
+        entity.setIsDelete(1);
+        entity.setUpdateTime(new Date());
+        this.update(entity);
+
+
+        return Result.success();
+    }
+
+    @Override
+    public List<SecondHandEntity> searchUseHots(String houseId, String sceneCode) {
+        sceneCode = "%" + sceneCode + "%";
+        return entityMapper.searchUseHots(houseId, sceneCode);
+    }
+
+    @Override
+    public Result saveUseHots(UseHotsDto param) {
+        String id = param.getId();
+        SecondHandEntity entity = this.findById(id);
+        if (entity == null) {
+            log.info("对象不存在:" + id);
+            return Result.failure("对象不存在");
+
+        }
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("data", param.getSceneCodes());
+        entity.setUseHots(jsonObject.toJSONString());
+        entity.setUpdateTime(new Date());
+        this.update(entity);
+        return Result.success();
+    }
+
+
+    @Override
+    public Result houseRemove(String houseId) {
+
+        entityMapper.houseRemove(houseId);
+        log.info("管理后台-vr项目删除成功, id: {}", houseId);
+        return Result.success();
+    }
+
+    @Override
+    public Result houseAudit(String houseId, String status) {
+        if ("3".equals(status)) {
+            log.info("vr项目下线,状态:{},  房源id:{}", status, houseId);
+        } else {
+            log.info("vr项目上线,状态:{},  房源id:{}", status, houseId);
+        }
+        entityMapper.houseAudit(houseId, status);
+        return Result.success();
+    }
+
+    @Override
+    public Result vrFindBySceneCode(String sceneCode) {
+        log.info("VR模模型-根据场景码查询: " + sceneCode);
+        // 此方法建议把返回值改回list值会更安全
+        List<SecondHandEntity> list = entityMapper.listFindBySceneCode(sceneCode);
+        log.info("使用中的VR模型数量:" + list.size());
+        boolean flag = true;
+        if (list.isEmpty()) {
+            flag = false;
+        }
+        log.info("查询结果: " + flag);
+        return Result.success(flag);
+    }
+
+
+    /**
+     * 添加VR模型
+     *
+     * @return
+     */
+    @Override
+    public Result findVrModel(SceneRroPageDto param) {
+        // TODO: 2021/1/8 0008 查找4dkk场景数据,当前区域公司下的模型
+        @NotBlank(message = "token不能为空") String token = param.getToken();
+        // 只获取计算成功的, 0:计算成功
+        param.setStatus("0");
+        String searchKey = param.getSearchKey();
+        if (StringUtils.isNotBlank(searchKey)) {
+            param.setSceneName(searchKey);
+        }
+
+        Result result = null;
+        try {
+            result = sceneProFeign.findByList(param, token);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        // 过滤已添加的数据
+        if (result.getCode() == 0) {
+            log.info("调用四维看看查找场景列表数据成功");
+            Object data = result.getData();
+            PageInfo page = JSON.parseObject(data.toString(), PageInfo.class);
+
+            List<Object> list = page.getList();
+            log.info("list size: " + list.size());
+
+            List<Object> newList = new ArrayList<>();
+
+            for (Object o : list) {
+                JSONObject scenePro = JSON.parseObject(o.toString());
+                String sceneProId = scenePro.getString("id");
+                List<SecondHandEntity> vrModelId = entityMapper.findByVrModelId2(sceneProId);
+                // 0:未使用
+                String use = "0";
+                if (vrModelId.size() > 0) {
+                    // 1: 已使用
+                    use = "1";
+                }
+
+                scenePro.put("isUse", use);
+                newList.add(scenePro);
+            }
+
+            page.setList(newList);
+            log.info("newList size: " + newList.size());
+
+            return Result.success(page);
+        } else {
+            log.error("异常了");
+            return Result.failure(result.getMsg());
+        }
+
+
+    }
+
+
+    @Override
+    public Result saveVrModel(VrModelDto param) {
+        String id = param.getId();
+        log.info("id: " + id);
+
+        // 检查VR项目状态
+        String houseId = param.getHouseId();
+        String roomId = param.getRoomId();
+
+        if (!canEdit(houseId)) {
+            log.error("VR项目不可编辑");
+            return Result.failure(7005, "VR项目不可编辑");
+        }
+
+        SecondHandEntity entity = null;
+        @NotBlank(message = "场景码不能为空") String sceneCode = param.getSceneCode();
+        @NotBlank(message = "恒大id不能为空") String hengdaId = param.getHengdaId();
+        String webSite = "/hengda.html?m=" + sceneCode + "&prodId=" + hengdaId + "&houseId=" + houseId;
+
+
+        if (id == null) {
+
+            // 一个VR项目不能有相同的户型
+            List<SecondHandEntity> sceneEntities = entityMapper.findByHouseIdAndRoomId(houseId, roomId);
+            if (sceneEntities.size() > 0) {
+                return Result.failure(MsgCode.e3002, "户型已存在,不能重复添加");
+            }
+
+            // 一个VR项目不能有相同的模型
+            entity = entityMapper.findByVrModelIdAndHouseId(param.getVrModelId(), houseId);
+            if (entity != null) {
+                log.error("VrModelId已存在");
+                return Result.failure(MsgCode.e3001, "场景码已存在, 不能重复添加");
+            }
+
+            entity = new SecondHandEntity();
+
+            BeanUtils.copyProperties(param, entity);
+
+            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);
+            entity.setWebSite(webSite);
+            entity.setUpdateTime(new Date());
+            this.update(entity);
+            log.info("更新VR模型完成");
+        }
+        return Result.success();
+    }
+
+
+    /**
+     * 检查是否有计算中的场景
+     *
+     * @param houseId
+     * @param status
+     * @return true: 有, false:没有
+     */
+    public Boolean checkStatus(String houseId, String status) {
+        List<SecondHandEntity> entities = entityMapper.findByHouseIdAndStatus(houseId, status);
+        boolean flag = false;
+        if (entities.size() > 0) {
+            flag = true;
+        }
+        return flag;
+    }
+
+    /**
+     * 2021-04-27
+     * 使用convert 生成缩略图
+     *
+     * @param inputFilePath
+     * @param ossBasePath
+     * @param ossDomain
+     * @return
+     */
+    public String convertAndUploadOss(
+            String inputFilePath, String serverBasePath, String ossBasePath, String ossDomain, Integer width, Integer height, String fileName) {
+
+        // 保存图片位置
+        String saveCompressImgPath = serverBasePath + fileName;
+        log.info("saveCompressImgPath: " + saveCompressImgPath);
+        String ossUrl = null;
+        try {
+            // 使用convert压缩图片
+            String cmd = CmdConstant.CONVERT;
+            String size = width + "x" + height;
+            cmd = cmd.replace("@size", size);
+            cmd = cmd.replace("@input", inputFilePath);
+            cmd = cmd.replace("@output", saveCompressImgPath);
+            CmdUtils.callShell(cmd);
+            log.info("图片压缩成功: " + saveCompressImgPath);
+
+            if (FileUtil.isFile(saveCompressImgPath)) {
+                // 上传oss
+                String ossPath = ossBasePath + 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();
+        }
+        return ossUrl;
+    }
+
+
+    /**
+     * 查询VR项目是否可编辑
+     * true: 可编辑
+     * false: 不可编辑
+     *
+     * @param houseId
+     * @return
+     */
+    private boolean canEdit(String houseId) {
+        Result result = null;
+        // 方便测试用, 可以删除
+        if ("dev".equals(configConstant.active) || "sit".equals(configConstant.active)) {
+            return true;
+        }
+        try {
+            result = houseFeign.canEdit(houseId);
+            log.info("房车宝返回数据:{}", result);
+            if (result.getCode() == 0) {
+                boolean data = (boolean) result.getData();
+                if (data) {
+                    log.info("vr项目可编辑");
+                    return true;
+                } else {
+                    log.info("vr项目不可编辑");
+                    return false;
+                }
+
+            } else {
+                log.error("VR项目接口查询失败:" + result.getMsg());
+                throw new BaseRuntimeException(7007, "VR项目接口查询失败");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("调用房车宝接口失败");
+            throw new BaseRuntimeException("调用房车宝接口失败");
+        }
+
+
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    @Override
+    public void startPage(PageDto param) {
+        super.startPage(param);
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+}

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

@@ -101,6 +101,20 @@ public class HouseController extends BaseController {
     }
 
 
+    /**
+     * 2021-09-08 新增
+     * 管理后台调用全景
+     * @param houseId
+     * @return
+     */
+    @WebControllerLog(description = "VR项目-根据房源ID查询场景,需要返回初始场景标记")
+    @ApiOperation(value = "根据房源ID查询场景,需要返回初始场景标记", position = 3, notes = "需要返回初始场景标记")
+    @GetMapping("getVrAndIndex/{houseId}")
+    public Result getVrAndIndex(@PathVariable String houseId) {
+        return houseService.getVrAndIndex(houseId);
+    }
+
+
 
 
 

+ 194 - 0
cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/SecondHandController.java

@@ -0,0 +1,194 @@
+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;
+import com.gis.service.SecondHandService;
+import com.gis.web.aop.WebControllerLog;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.validation.Valid;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by owen on 2021/9/8 0008 11:21
+ *
+ */
+@Api(tags = "二手房管理")
+@RestController
+@RequestMapping("fcb/pano/secondHand")
+public class SecondHandController {
+
+    @Autowired
+    SecondHandService secondHandService;
+
+    /**
+     * 创建场景
+     *
+     * @param file
+     * @param houseId
+     */
+    @ApiOperation(value = "上传全景图(创建场景)")
+    @PostMapping("uploadPano/{houseId}/{hengDaId}")
+    public Result uploadPano(MultipartFile file, @PathVariable String houseId, @PathVariable String hengDaId) {
+        return secondHandService.uploadPanoRabbitMq(file, houseId, hengDaId);
+    }
+
+
+    /**
+     * 改VR项目有计算中的模型,允许轮询,否则停止轮询
+     * 30s 轮询一次
+     * VR项目有计算中的模型,(true)允许轮询,(false)否则停止轮询
+     */
+    @ApiOperation(value = "场景列表", position = 1, notes = "30s轮询一次,VR项目有计算中的模型,(true)允许轮询,(false)否则停止轮询")
+    @PostMapping("list")
+    public JSONObject list(@RequestBody SecondHandPageDto param) {
+        return secondHandService.jsonSearch(param);
+    }
+
+    @WebControllerLog(description = "二手房管理-更新初始画面")
+    @ApiOperation("更新初始画面")
+    @PostMapping("updateInitIcon")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "场景id", dataType = "String", required = true),
+            @ApiImplicitParam(name = "icon", value = "iconURL", dataType = "String", required = true)
+    })
+    public Result updateInitIcon(@RequestParam String id, @RequestParam String icon) {
+        return secondHandService.updateInitIcon(id, icon);
+    }
+
+    @WebControllerLog(description = "二手房管理-编辑xml设置初始角度")
+    @ApiOperation(value = "编辑xml", notes = "设置初始角度")
+    @PostMapping("editXml")
+    public Result editXml(@Valid @RequestBody XmlDataDto param) {
+
+        return secondHandService.editXml(param);
+    }
+
+    @WebControllerLog(description = "二手房管理-编辑someData,(重命名)")
+    @ApiOperation(value = "编辑someData,(重命名)", position = 3)
+    @PostMapping("editSomeData")
+    public Result editSomeData(@Valid @RequestBody EditSomeDataDto param) {
+        return secondHandService.editSomeData(param);
+    }
+
+
+    @ApiOperation("场景详情")
+    @GetMapping("detail/{sceneCode}")
+    public Result detail(@PathVariable String sceneCode) {
+        return secondHandService.findBySceneCode(sceneCode);
+    }
+
+    @WebControllerLog(description = "二手房管理-场景排序")
+    @ApiOperation(value = "场景排序")
+    @PostMapping(value = "setSort")
+    public Result setSort(@RequestBody Map<String, String> param) {
+        return secondHandService.setSort(param);
+    }
+
+    @WebControllerLog(description = "二手房管理-上传图标")
+    @ApiOperation(value = "上传-图标", position = 2)
+    @PostMapping(value = "upload")
+    public Result upload(@RequestParam("file") MultipartFile file) {
+        return secondHandService.upload(file);
+    }
+
+
+    @WebControllerLog(description = "二手房管理-场景删除")
+    @ApiOperation(value = "场景删除", notes = "判断VR项目关联场景、关联热点等判断")
+    @GetMapping("remove/{id}")
+    public Result remove(@PathVariable String id) {
+        return secondHandService.remove(id);
+    }
+
+    @WebControllerLog(description = "二手房管理-保存关联场景热点")
+    @ApiOperation(value = "保存关联场景热点", position = 1, notes = "sceneCodes:场景关联的场景码")
+    @PostMapping("save/useHots")
+    public Result saveUseHots(@Valid @RequestBody UseHotsDto param) {
+        return secondHandService.saveUseHots(param);
+    }
+
+
+    /**
+     * 四维看看VR模型保存
+     * 会添加一条场景记录
+     * @param param
+     * @return
+     */
+    @WebControllerLog(description = "二手房管理-四维看看VR模型保存")
+    @ApiOperation("四维看看VR模型保存")
+    @PostMapping("saveVrModel")
+    public Result saveVrModel(@Valid @RequestBody VrModelDto param) {
+        return secondHandService.saveVrModel(param);
+    }
+
+
+    /**
+     * 会调用四维看看接口
+     * @param param
+     * @return
+     */
+    @WebControllerLog(description = "二手房管理-调用四维看看VR模型查找")
+    @ApiOperation(value = "VR模型查找", position = 3, notes = "获取四维看看计算成功的场景信息")
+    @PostMapping("findVrModel")
+    public Result findVrModel(@Valid @RequestBody SceneRroPageDto param) {
+        return secondHandService.findVrModel(param);
+    }
+
+
+    /**
+     * 提供管理后台使用
+     * @param houseId
+     * @return
+     */
+    @WebControllerLog(description = "二手房管理-VR项目删除")
+    @ApiOperation(value = "VR项目删除", position = 3, notes = "管理后台删除VR项目时,把相应场景设置为删除状态")
+    @GetMapping("house/remove/{houseId}")
+    public Result houseRemove(@PathVariable String houseId) {
+        return secondHandService.houseRemove(houseId);
+    }
+
+
+    /**
+     * 提供恒大管理后台使用
+     * 更新数据状态
+     * @param houseId
+     * @param status
+     * @return
+     */
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "houseId", value = "房源id", dataType = "String", required = true),
+            @ApiImplicitParam(name = "status", value = "状态, 审核通过/上线:4, 下线:3", dataType = "String"),
+    })
+    @WebControllerLog(description = "二手房管理-VR项目审核通过/下线")
+    @ApiOperation(value = "VR项目审核通过/下线", position = 3)
+    @GetMapping("house/audit/{houseId}/{status}")
+    public Result houseAudit(@PathVariable String houseId, @PathVariable String status) {
+        return secondHandService.houseAudit(houseId, status);
+    }
+
+
+    /**
+     * 提供四维看看使用
+     * @param sceneCode
+     * @return
+     */
+    @WebControllerLog(description = "二手房管理-VR模模型, 根据场景码查询(判断删除作用)")
+    @ApiOperation(value = "VR模模型-根据场景码查询", notes = "提供给四维看看,判断是否在720yun中使用此场景,true:有,四维看看不能删除此场景; false:可以删除")
+    @GetMapping(value = "fdkk/findBySceneCode")
+    public Result vrFindBySceneCode(String sceneCode) {
+
+        return secondHandService.vrFindBySceneCode(sceneCode);
+    }
+
+}

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

@@ -0,0 +1,27 @@
+package com.gis.web.controller;
+
+import com.gis.common.util.Result;
+import com.gis.service.SecondHandService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * Created by owen on 2021/9/9 0009 8:59
+ */
+@Api(tags = "测试")
+@RestController
+@RequestMapping("fcb/pano/test")
+public class TestController {
+
+    @Autowired
+    SecondHandService secondHandService;
+
+    @ApiOperation(value = "二手房队列测试")
+    @GetMapping("queueSecondHand")
+    public Result queueSecondHand() {
+        return secondHandService.testQueueSecondHand();
+    }
+}

+ 12 - 1
cms_pano_fcb/remark.md

@@ -382,5 +382,16 @@ sit:
     
     
 ====================== 2021-09-07   1.5新需求开发 ======================
- master现在是最新的代码, dev版本可以删除   
+ master现在是最新的代码, dev其他版本可以删除
+ 
+ 开发二手房功能
+ 
+ #需求疑问:
+ 1. 管理后台删除VR模型, 二手房全景已添加该场景作为热点,如何处理?
+ 2. 
+ 
+ 已确认:
+ 1. 审核中/已上线 -> 编辑操作需要检查该二手房是否可操作
+ 
+