瀏覽代碼

Merge branch 'release-swsx' into test

dengsixing 3 天之前
父節點
當前提交
da32f0752a
共有 20 個文件被更改,包括 636 次插入33 次删除
  1. 51 0
      src/main/java/com/fdkankan/contro/entity/RelocationBatch.java
  2. 72 0
      src/main/java/com/fdkankan/contro/entity/RelocationBatchDetail.java
  3. 51 0
      src/main/java/com/fdkankan/contro/entity/RelocationInit.java
  4. 1 1
      src/main/java/com/fdkankan/contro/generate/AutoGenerate.java
  5. 18 0
      src/main/java/com/fdkankan/contro/mapper/IRelocationBatchDetailMapper.java
  6. 18 0
      src/main/java/com/fdkankan/contro/mapper/IRelocationBatchMapper.java
  7. 18 0
      src/main/java/com/fdkankan/contro/mapper/IRelocationInitMapper.java
  8. 70 10
      src/main/java/com/fdkankan/contro/mq/listener/BuildSxRelocationListener.java
  9. 17 1
      src/main/java/com/fdkankan/contro/mq/service/impl/BuildIntermitSceneServiceImpl.java
  10. 39 18
      src/main/java/com/fdkankan/contro/mq/service/impl/BuildSxRelocationServiceImpl.java
  11. 26 3
      src/main/java/com/fdkankan/contro/schedule/ScheduleJob.java
  12. 21 0
      src/main/java/com/fdkankan/contro/service/IRelocationBatchDetailService.java
  13. 19 0
      src/main/java/com/fdkankan/contro/service/IRelocationBatchService.java
  14. 19 0
      src/main/java/com/fdkankan/contro/service/IRelocationInitService.java
  15. 27 0
      src/main/java/com/fdkankan/contro/service/impl/RelocationBatchDetailServiceImpl.java
  16. 84 0
      src/main/java/com/fdkankan/contro/service/impl/RelocationBatchServiceImpl.java
  17. 70 0
      src/main/java/com/fdkankan/contro/service/impl/RelocationInitServiceImpl.java
  18. 5 0
      src/main/resources/mapper/contro/RelocationBatchDetailMapper.xml
  19. 5 0
      src/main/resources/mapper/contro/RelocationBatchMapper.xml
  20. 5 0
      src/main/resources/mapper/contro/RelocationInitMapper.xml

+ 51 - 0
src/main/java/com/fdkankan/contro/entity/RelocationBatch.java

@@ -0,0 +1,51 @@
+package com.fdkankan.contro.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 重定位批次表
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+@Getter
+@Setter
+@TableName("t_relocation_batch")
+public class RelocationBatch implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 重定位场景码
+     */
+    @TableField("num")
+    private String num;
+
+    /**
+     * 0-排队中,1-计算中,2-已完成
+     */
+    @TableField("status")
+    private Integer status;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+    @TableField("rec_status")
+    @TableLogic(value = "A", delval = "I")
+    private String recStatus;
+
+
+}

+ 72 - 0
src/main/java/com/fdkankan/contro/entity/RelocationBatchDetail.java

@@ -0,0 +1,72 @@
+package com.fdkankan.contro.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+@Getter
+@Setter
+@TableName("t_relocation_batch_detail")
+public class RelocationBatchDetail implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    @TableField("batch_id")
+    private Long batchId;
+
+    /**
+     * 重定位场景码
+     */
+    @TableField("num")
+    private String num;
+
+    /**
+     * 全景图场景码
+     */
+    @TableField("pan_num")
+    private String panNum;
+
+    /**
+     * 图片key
+     */
+    @TableField("img_key")
+    private String imgKey;
+
+    /**
+     * 图片本地存储名称
+     */
+    @TableField("file_name")
+    private String fileName;
+
+    /**
+     * 图片 bucket
+     */
+    @TableField("bucket")
+    private String bucket;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+    @TableField("rec_status")
+    @TableLogic(value = "A", delval = "I")
+    private String recStatus;
+
+
+}

+ 51 - 0
src/main/java/com/fdkankan/contro/entity/RelocationInit.java

@@ -0,0 +1,51 @@
+package com.fdkankan.contro.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+@Getter
+@Setter
+@TableName("t_relocation_init")
+public class RelocationInit implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    @TableField("num")
+    private String num;
+
+    @TableField("pan_num")
+    private String panNum;
+
+    /**
+     * 0-等待推送,1-已推送
+     */
+    @TableField("status")
+    private Integer status;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+    @TableField("rec_status")
+    @TableLogic(value = "A", delval = "I")
+    private String recStatus;
+
+
+}

+ 1 - 1
src/main/java/com/fdkankan/contro/generate/AutoGenerate.java

@@ -17,7 +17,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir");
 
         generate(path,"contro", getTables(new String[]{
-                "t_app_camera_fail_log"
+                "t_relocation_init"
         }));
 
 //        generate(path,"goods", getTables(new String[]{

+ 18 - 0
src/main/java/com/fdkankan/contro/mapper/IRelocationBatchDetailMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.contro.mapper;
+
+import com.fdkankan.contro.entity.RelocationBatchDetail;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+@Mapper
+public interface IRelocationBatchDetailMapper extends BaseMapper<RelocationBatchDetail> {
+
+}

+ 18 - 0
src/main/java/com/fdkankan/contro/mapper/IRelocationBatchMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.contro.mapper;
+
+import com.fdkankan.contro.entity.RelocationBatch;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 重定位批次表 Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+@Mapper
+public interface IRelocationBatchMapper extends BaseMapper<RelocationBatch> {
+
+}

+ 18 - 0
src/main/java/com/fdkankan/contro/mapper/IRelocationInitMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.contro.mapper;
+
+import com.fdkankan.contro.entity.RelocationInit;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+@Mapper
+public interface IRelocationInitMapper extends BaseMapper<RelocationInit> {
+
+}

+ 70 - 10
src/main/java/com/fdkankan/contro/mq/listener/BuildSxRelocationListener.java

@@ -1,11 +1,18 @@
 package com.fdkankan.contro.mq.listener;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.exceptions.ExceptionUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.common.constant.CommonOperStatus;
+import com.fdkankan.contro.entity.RelocationBatch;
+import com.fdkankan.contro.entity.RelocationBatchDetail;
 import com.fdkankan.contro.mq.service.impl.BuildSxRelocationServiceImpl;
 import com.fdkankan.contro.service.ICommonService;
+import com.fdkankan.contro.service.IRelocationBatchDetailService;
+import com.fdkankan.contro.service.IRelocationBatchService;
 import com.fdkankan.contro.service.ISceneBuildProcessLogService;
 import com.fdkankan.model.constants.SceneBuildProcessType;
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
@@ -20,7 +27,8 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
+import java.util.List;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Component
@@ -37,6 +45,65 @@ public class BuildSxRelocationListener {
     private ISceneBuildProcessLogService sceneBuildProcessLogService;
     @Autowired
     private ICommonService commonService;
+    @Autowired
+    private IRelocationBatchService relocationBatchService;
+    @Autowired
+    private IRelocationBatchDetailService relocationBatchDetailService;
+
+
+    /**
+     * 场景计算前置资源准备处理
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.sx-relocation-push:sx-relocation-push}"),
+            concurrency = "5"
+    )
+    public void push(Channel channel, Message message) throws Exception {
+        String messageId = message.getMessageProperties().getMessageId();
+        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
+        JSONObject jsonObject = JSON.parseObject(msg);
+        log.info("开始接受重定位请求,id:{},消息体:{}", messageId, jsonObject);
+        String sxNum = jsonObject.getString("sxNum");
+        RelocationBatch relocationBatch = new RelocationBatch();
+        relocationBatch.setNum(sxNum);
+        relocationBatchService.save(relocationBatch);
+        JSONArray imgs = jsonObject.getJSONArray("imgs");
+        List<RelocationBatchDetail> detailList = imgs.stream().map(v -> {
+            JSONObject img = (JSONObject) v;
+            RelocationBatchDetail detail = new RelocationBatchDetail();
+            detail.setBatchId(relocationBatch.getId());
+            detail.setNum(sxNum);
+            detail.setPanNum(img.getString("num"));
+            detail.setBucket(img.getString("bucket"));
+            detail.setImgKey(img.getString("key"));
+            detail.setFileName(img.getString("fileName"));
+            return detail;
+        }).collect(Collectors.toList());
+        relocationBatchDetailService.saveBatch(detailList);
+
+
+        List<RelocationBatch> list = relocationBatchService.list(new LambdaQueryWrapper<RelocationBatch>().eq(RelocationBatch::getNum, sxNum).in(RelocationBatch::getStatus, 0, 1).lt(RelocationBatch::getId, relocationBatch.getId()));
+        boolean canBuild = true;
+        if(CollUtil.isNotEmpty(list)){
+            for (RelocationBatch batch : list) {
+                if(batch.getStatus() == 1){//如果已经有进入计算的重定位记录,则这次提交需要进入定时任务等待
+                    canBuild = false;
+                }
+                if(batch.getStatus() == 0){//如果前面有等待的,则丢弃等待的记录,因为最后一次推送是最全的
+                    relocationBatchService.removeById(batch);
+                }
+            }
+        }
+        if(canBuild){
+            relocationBatchService.relocationControlHandler(relocationBatch);
+        }
+
+        log.info("结束接受重定位请求,id:{}", messageId);
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+    }
 
     /**
      * 场景计算前置资源准备处理
@@ -51,15 +118,8 @@ public class BuildSxRelocationListener {
     public void buildScenePreHandler(Channel channel, Message message) throws Exception {
         String messageId = message.getMessageProperties().getMessageId();
         String msg = new String(message.getBody(), StandardCharsets.UTF_8);
-        HashMap<String, Object> map = JSON.parseObject(msg, HashMap.class);
-        String num = (String) map.get("num");
-        String path = (String) map.get("path");
-
-        BuildSceneCallMessage buildSceneMessage = new BuildSceneCallMessage();
-        buildSceneMessage.setSceneNum(num);
-        buildSceneMessage.setBizType("relocation");
-        buildSceneMessage.setPath(path);
-        buildSceneMessage.setCameraType("14");
+        BuildSceneCallMessage buildSceneMessage = JSON.parseObject(msg, BuildSceneCallMessage.class);
+        String num = buildSceneMessage.getSceneNum();
 
         log.info("开始准备重定位计算资源,队列名:{},id:{},消息体:{}", queueModelingPre, messageId, msg);
         try {

+ 17 - 1
src/main/java/com/fdkankan/contro/mq/service/impl/BuildIntermitSceneServiceImpl.java

@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.common.constant.*;
 import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.contro.entity.RelocationInit;
 import com.fdkankan.contro.entity.ScenePlus;
 import com.fdkankan.contro.entity.ScenePlusExt;
 import com.fdkankan.contro.mq.service.IBuildSceneService;
@@ -23,7 +24,6 @@ import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
@@ -78,6 +78,8 @@ public class BuildIntermitSceneServiceImpl implements IBuildSceneService {
     private IntermitSceneService intermitSceneService;
     @Autowired
     private IBuildService buildService;
+    @Autowired
+    private IRelocationInitService relocationInitService;
 
     @Override
     public void buildScenePre(BuildSceneCallMessage message) throws Exception{
@@ -187,6 +189,11 @@ public class BuildIntermitSceneServiceImpl implements IBuildSceneService {
             ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
 
             log.info("开始上传场景计算结果数据,num:{}", sceneCode);
+            //上传结算结果之前需要删除oss上的结果数据
+            String panoramaKey = String.format(UploadFilePath.IMG_VIEW_PATH, sceneCode) + "panoramas";
+            if(fYunFileService.fileExist(panoramaKey)){
+                fYunFileService.deleteFolder(panoramaKey);
+            }
             //上传文件
             fYunFileService.uploadMulFiles(uploadFiles);
 
@@ -217,6 +224,15 @@ public class BuildIntermitSceneServiceImpl implements IBuildSceneService {
             //推送到全景看看
             intermitSceneService.sendMq(sceneCode, fdageData, CommonSuccessStatus.SUCCESS.code());
 
+            //判断是否有重定位关系,如果有,推送到激光系统去做初始化处理
+            String sxUuid = fdageData.getString("parentScene");
+            ScenePlus sxScenePlus = scenePlusService.getByFileId(sxUuid);
+            RelocationInit relocationInit = new RelocationInit();
+            relocationInit.setNum(sxScenePlus.getNum());
+            relocationInit.setPanNum(sceneCode);
+            relocationInitService.save(relocationInit);
+            relocationInitService.pushInit(relocationInit);
+
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
 
         }catch (Exception e){

+ 39 - 18
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSxRelocationServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fdkankan.contro.mq.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -32,6 +33,7 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.nio.charset.StandardCharsets;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
@@ -77,10 +79,15 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
     private IntermitSceneService intermitSceneService;
     @Autowired
     private IBuildService buildService;
+    @Autowired
+    private IRelocationBatchDetailService relocationBatchDetailService;
+    @Autowired
+    private IRelocationBatchService relocationBatchService;
 
     @Override
     public void buildScenePre(BuildSceneCallMessage message) throws Exception{
         String num = message.getSceneNum();
+        Long batchId = (Long) message.getExt().get("batchId");
         ScenePlus scenePlusByNum = scenePlusService.getScenePlusByNum(num);
         try {
             //重新计算时需要删除文件夹,否知使用缓存
@@ -92,8 +99,7 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
                 FileUtils.deleteDirectory(message.getPath() + File.separator + "caches");
             }
 
-            String extrasPath = message.getPath() + File.separator + "extras";
-            fYunFileService.downloadFileByCommand(extrasPath, String.format(UploadFilePath.scene_result_data_path, num) + "pose/");
+            this.downLoadSource(message, message.getPath());
 
             message.setResultReceiverMqName(queueModelingPost);
 
@@ -110,30 +116,43 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
         }catch (Exception e){
             scenePlusByNum.setSceneStatus(SceneStatus.FAILD.code());
             scenePlusService.updateById(scenePlusByNum);
+            //修改重定位记录为退出计算
+            relocationBatchService.update(new LambdaUpdateWrapper<RelocationBatch>().eq(RelocationBatch::getId, batchId).set(RelocationBatch::getStatus, 2));
             buildSceneDTService.handBaseFail("深巡场景重定位资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
             throw e;
         }
     }
 
-    private String getOssPath(String path) {
-        String ossPath = ConstantFilePath.OSS_PREFIX
-                + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
-                .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
-        if (!ossPath.endsWith("/")) {
-            ossPath = ossPath.concat("/");
-        }
-        return ossPath;
-    }
-
     @Override
     public void downLoadSource(BuildSceneCallMessage buildSceneMqMessage,String path){
-        String ossPath = getOssPath(path);
-        fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
+        String num = buildSceneMqMessage.getSceneNum();
+        Long batchId = (Long)buildSceneMqMessage.getExt().get("batchId");
+        //下载深巡缓存数据
+        String extrasPath = path + File.separator + "extras";
+        fYunFileService.downloadFileByCommand(extrasPath, String.format(UploadFilePath.scene_result_data_path, num) + "pose/");
+        String imagesPath = extrasPath + File.separator + "images";
+        //下载图片
+        String queryPath = imagesPath + File.separator + "query";
+        List<RelocationBatchDetail> detailList = relocationBatchDetailService.listByBatchId(batchId);
+        detailList.stream().forEach(v->{
+            fYunFileService.downloadFile(v.getBucket(), v.getImgKey(), queryPath + File.separator + v.getFileName());
+        });
+        //生成query.json
+        List<String> imgNameList = FileUtil.listFileNames(queryPath);
+        List<JSONObject> filenames = imgNameList.stream().map(v -> {
+            JSONObject a = new JSONObject();
+            a.put("filename", v);
+            return a;
+        }).collect(Collectors.toList());
+        JSONObject query = new JSONObject();
+        query.put("query", filenames);
+        FileUtil.writeUtf8String(query.toJSONString(), extrasPath + File.separator + "query.json");
     }
 
     @Override
     public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
         String sceneCode = message.getBuildContext().get("sceneNum").toString();
+        Long batchId = (Long) message.getExt().get("batchId");
         String path = message.getPath();
         Map<String, Object> downParams = new HashMap<>();
         downParams.put("sceneCode", sceneCode);
@@ -147,7 +166,7 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
             log.info("计算日志上传完成");
 
             if (!message.getBuildSuccess()) {
-                log.error("建模失败,修改状态为失败状态");
+                log.error("重定位计算报错,修改状态为失败状态");
                 scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
                         .set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
                         .eq(ScenePlus::getNum, sceneCode));
@@ -190,16 +209,18 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
 
             //发送消息到点云系统处理
             downParams.put("status", CommonSuccessStatus.SUCCESS.code());
-            log.info("场景计算结果处理结束,场景码:{}", sceneCode);
+            log.info("场景重定位计算结果处理结束,场景码:{}", sceneCode);
 
         }catch (Exception e){
-            log.error("场景计算结果处理出错,num"+sceneCode, e);
+            log.error("场景重定位计算结果处理出错,num"+sceneCode, e);
             downParams.put("status", CommonSuccessStatus.FAIL.code());
-            buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
+            buildSceneDTService.handBaseFail("场景重定位计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
             throw e;
         } finally {
             //发送消息到激光系统做处理
             mqProducer.sendByWorkQueue("sx-relocation-done", downParams);
+            //修改重定位记录为退出计算
+            relocationBatchService.update(new LambdaUpdateWrapper<RelocationBatch>().eq(RelocationBatch::getId, batchId).set(RelocationBatch::getStatus, 2));
         }
     }
 

+ 26 - 3
src/main/java/com/fdkankan/contro/schedule/ScheduleJob.java

@@ -1,11 +1,10 @@
 package com.fdkankan.contro.schedule;
 
+import com.fdkankan.contro.service.IRelocationBatchService;
+import com.fdkankan.contro.service.IRelocationInitService;
 import com.fdkankan.contro.service.IScene3dNumService;
-import com.fdkankan.rabbitmq.util.RabbitMqProducer;
-import com.fdkankan.rubbersheeting.ScalingService;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
@@ -15,6 +14,10 @@ public class ScheduleJob {
 
     @Autowired
     private IScene3dNumService scene3dNumService;
+    @Autowired
+    private IRelocationBatchService relocationBatchService;
+    @Autowired
+    private IRelocationInitService relocationInitService;
 
 
     /**
@@ -24,4 +27,24 @@ public class ScheduleJob {
     public void generateSceneNum() {
         scene3dNumService.generateSceneNumHandler();
     }
+
+    /**
+     * 重定位调度
+     */
+    @Scheduled(fixedDelay = 5*60*1000, initialDelay = 1000)
+    public void relocationControl() {
+        log.info("重定位调度开始");
+        relocationBatchService.relocationControl();
+        log.info("重定位调度结束");
+    }
+
+    /**
+     * 重定位调度
+     */
+    @Scheduled(fixedDelay = 5*60*1000, initialDelay = 1000)
+    public void relocationInit() {
+        log.info("重定位初始化调度开始");
+        relocationInitService.relocationInit();
+        log.info("重定位初始化调度结束");
+    }
 }

+ 21 - 0
src/main/java/com/fdkankan/contro/service/IRelocationBatchDetailService.java

@@ -0,0 +1,21 @@
+package com.fdkankan.contro.service;
+
+import com.fdkankan.contro.entity.RelocationBatchDetail;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+public interface IRelocationBatchDetailService extends IService<RelocationBatchDetail> {
+
+    List<RelocationBatchDetail> listByBatchId(Long batchId);
+
+
+}

+ 19 - 0
src/main/java/com/fdkankan/contro/service/IRelocationBatchService.java

@@ -0,0 +1,19 @@
+package com.fdkankan.contro.service;
+
+import com.fdkankan.contro.entity.RelocationBatch;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 重定位批次表 服务类
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+public interface IRelocationBatchService extends IService<RelocationBatch> {
+
+    void relocationControl();
+
+    void relocationControlHandler(RelocationBatch relocationBatch);
+}

+ 19 - 0
src/main/java/com/fdkankan/contro/service/IRelocationInitService.java

@@ -0,0 +1,19 @@
+package com.fdkankan.contro.service;
+
+import com.fdkankan.contro.entity.RelocationInit;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+public interface IRelocationInitService extends IService<RelocationInit> {
+
+    void pushInit(RelocationInit relocationInit);
+
+    void relocationInit();
+}

+ 27 - 0
src/main/java/com/fdkankan/contro/service/impl/RelocationBatchDetailServiceImpl.java

@@ -0,0 +1,27 @@
+package com.fdkankan.contro.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.contro.entity.RelocationBatchDetail;
+import com.fdkankan.contro.mapper.IRelocationBatchDetailMapper;
+import com.fdkankan.contro.service.IRelocationBatchDetailService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+@Service
+public class RelocationBatchDetailServiceImpl extends ServiceImpl<IRelocationBatchDetailMapper, RelocationBatchDetail> implements IRelocationBatchDetailService {
+
+    @Override
+    public List<RelocationBatchDetail> listByBatchId(Long batchId) {
+        return this.list(new LambdaQueryWrapper<RelocationBatchDetail>().eq(RelocationBatchDetail::getBatchId, batchId));
+    }
+}

+ 84 - 0
src/main/java/com/fdkankan/contro/service/impl/RelocationBatchServiceImpl.java

@@ -0,0 +1,84 @@
+package com.fdkankan.contro.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.contro.entity.RelocationBatch;
+import com.fdkankan.contro.entity.ScenePlus;
+import com.fdkankan.contro.entity.ScenePlusExt;
+import com.fdkankan.contro.mapper.IRelocationBatchMapper;
+import com.fdkankan.contro.service.IRelocationBatchService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.contro.service.IScenePlusExtService;
+import com.fdkankan.contro.service.IScenePlusService;
+import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * 重定位批次表 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+@Slf4j
+@Service
+public class RelocationBatchServiceImpl extends ServiceImpl<IRelocationBatchMapper, RelocationBatch> implements IRelocationBatchService {
+
+    @Value("${queue.modeling.sx-relocation-pre:sx-relocation-pre}")
+    private String queueModelingPre;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
+    @Resource
+    private RabbitMqProducer mqProducer;
+
+    @Override
+    public void relocationControl() {
+        List<RelocationBatch> list = this.list(new LambdaQueryWrapper<RelocationBatch>().eq(RelocationBatch::getStatus, 0));
+        if(CollUtil.isNotEmpty(list)){
+            return;
+        }
+        for (RelocationBatch relocationBatch : list) {
+            try {
+                List<RelocationBatch> buildingList= this.list(new LambdaQueryWrapper<RelocationBatch>().eq(RelocationBatch::getNum, relocationBatch.getNum()).eq(RelocationBatch::getStatus, 1));
+                if(CollUtil.isNotEmpty(buildingList)){
+                    continue;
+                }
+                this.relocationControlHandler(relocationBatch);
+            }catch (Exception e){
+                log.error("重定位调度失败,num:{}, batchId:{}", relocationBatch.getNum(), relocationBatch.getId(), e);
+            }
+        }
+
+    }
+
+    @Override
+    public void relocationControlHandler(RelocationBatch relocationBatch) {
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(relocationBatch.getNum());
+        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+        String path = scenePlusExt.getDataSource() + "_relocation";
+        BuildSceneCallMessage buildSceneMessage = new BuildSceneCallMessage();
+        buildSceneMessage.setSceneNum(relocationBatch.getNum());
+        buildSceneMessage.setBizType("relocation");
+        buildSceneMessage.setPath(path);
+        buildSceneMessage.setCameraType("14");
+        Map<String, Object> ext = new HashMap<>();
+        ext.put("batchId", relocationBatch.getId());
+        buildSceneMessage.setExt(ext);
+        mqProducer.sendByWorkQueue(queueModelingPre, buildSceneMessage);
+        relocationBatch.setStatus(1);
+        relocationBatch.setUpdateTime(null);
+        this.updateById(relocationBatch);
+    }
+}

+ 70 - 0
src/main/java/com/fdkankan/contro/service/impl/RelocationInitServiceImpl.java

@@ -0,0 +1,70 @@
+package com.fdkankan.contro.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.common.constant.SceneStatus;
+import com.fdkankan.contro.entity.RelocationInit;
+import com.fdkankan.contro.entity.ScenePlus;
+import com.fdkankan.contro.mapper.IRelocationInitMapper;
+import com.fdkankan.contro.service.IRelocationInitService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.contro.service.IScenePlusService;
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2025-09-09
+ */
+@Service
+public class RelocationInitServiceImpl extends ServiceImpl<IRelocationInitMapper, RelocationInit> implements IRelocationInitService {
+
+    @Value("${queue.modeling.relocation.relocation-scene-init:relocation-scene-init}")
+    private String queueRelocationSceneInit;
+    @Resource
+    private RabbitMqProducer mqProducer;
+    @Autowired
+    private IScenePlusService scenePlusService;
+
+    @Override
+    public void pushInit(RelocationInit relocationInit) {
+        ScenePlus sx = scenePlusService.getScenePlusByNum(relocationInit.getNum());
+        if(sx.getSceneStatus() != SceneStatus.NO_DISPLAY.code() && sx.getSceneStatus() != SceneStatus.SUCCESS.code()){
+            return;
+        }
+        ScenePlus panNum = scenePlusService.getScenePlusByNum(relocationInit.getPanNum());
+        if(panNum.getSceneStatus() != SceneStatus.NO_DISPLAY.code() && panNum.getSceneStatus() != SceneStatus.SUCCESS.code()){
+            return;
+        }
+        Map<String, String> map = new HashMap<>();
+        map.put("sxNum", relocationInit.getNum());
+        map.put("qjkkNum",relocationInit.getPanNum());
+        mqProducer.sendByWorkQueue(queueRelocationSceneInit, map);
+
+        relocationInit.setStatus(1);
+        relocationInit.setUpdateTime(null);
+        this.updateById(relocationInit);
+    }
+
+    @Override
+    public void relocationInit() {
+        List<RelocationInit> list = this.list(new LambdaQueryWrapper<RelocationInit>().eq(RelocationInit::getStatus, 0));
+        if(CollUtil.isNotEmpty(list)){
+            return;
+        }
+        for (RelocationInit relocationInit : list) {
+            this.pushInit(relocationInit);
+        }
+    }
+}

+ 5 - 0
src/main/resources/mapper/contro/RelocationBatchDetailMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.contro.mapper.IRelocationBatchDetailMapper">
+
+</mapper>

+ 5 - 0
src/main/resources/mapper/contro/RelocationBatchMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.contro.mapper.IRelocationBatchMapper">
+
+</mapper>

+ 5 - 0
src/main/resources/mapper/contro/RelocationInitMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.contro.mapper.IRelocationInitMapper">
+
+</mapper>