Explorar o código

重定位绑定关系

dengsixing hai 1 mes
pai
achega
1214dc8785

+ 13 - 0
src/main/java/com/fdkankan/contro/schedule/ScheduleJob.java

@@ -1,6 +1,7 @@
 package com.fdkankan.contro.schedule;
 
 import com.fdkankan.contro.service.IRelocationBatchService;
+import com.fdkankan.contro.service.IRelocationBindService;
 import com.fdkankan.contro.service.IRelocationInitService;
 import com.fdkankan.contro.service.IScene3dNumService;
 import lombok.extern.log4j.Log4j2;
@@ -18,6 +19,8 @@ public class ScheduleJob {
     private IRelocationBatchService relocationBatchService;
     @Autowired
     private IRelocationInitService relocationInitService;
+    @Autowired
+    private IRelocationBindService relocationBindService;
 
 
     /**
@@ -47,4 +50,14 @@ public class ScheduleJob {
         relocationInitService.relocationInit();
         log.info("重定位初始化调度结束");
     }
+
+    /**
+     * 重定位绑定关系初始化
+     */
+    @Scheduled(fixedDelay = 5*60*1000, initialDelay = 1000)
+    public void relocationBind() {
+        log.info("重定位绑定关系开始");
+        relocationBindService.relocationBind();
+        log.info("重定位绑定关系结束");
+    }
 }

+ 1 - 0
src/main/java/com/fdkankan/contro/service/IRelocationBindService.java

@@ -15,4 +15,5 @@ public interface IRelocationBindService extends IService<RelocationBind> {
 
     RelocationBind getByPanNum(String panNum);
 
+    void relocationBind();
 }

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

@@ -1,11 +1,17 @@
 package com.fdkankan.contro.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.fdkankan.contro.entity.RelocationBind;
+import com.fdkankan.contro.entity.ScenePlus;
 import com.fdkankan.contro.mapper.IRelocationBindMapper;
 import com.fdkankan.contro.service.IRelocationBindService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.contro.service.IScenePlusService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 重定位场景绑定关系表 服务实现类
@@ -17,8 +23,29 @@ import org.springframework.stereotype.Service;
 @Service
 public class RelocationBindServiceImpl extends ServiceImpl<IRelocationBindMapper, RelocationBind> implements IRelocationBindService {
 
+    @Autowired
+    private IScenePlusService scenePlusService;
+
+
     @Override
     public RelocationBind getByPanNum(String panNum) {
         return lambdaQuery().eq(RelocationBind::getPanNum, panNum).one();
     }
+
+    @Override
+    public void relocationBind() {
+        List<RelocationBind> list = lambdaQuery().isNull(RelocationBind::getMainNum).list();
+        if(CollUtil.isEmpty(list)){
+            return;
+        }
+        list.stream().forEach(v->{
+            ScenePlus scenePlus = scenePlusService.getByFileId(v.getMainUuid());
+            if(scenePlus != null){
+                v.setMainNum(scenePlus.getNum());
+                v.setUpdateTime(null);
+                this.updateById(v);
+            }
+        });
+
+    }
 }