|
@@ -1,23 +1,25 @@
|
|
|
package com.fdkankan.contro.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
|
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 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;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -27,6 +29,7 @@ import java.util.Map;
|
|
|
* @author
|
|
|
* @since 2025-09-09
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class RelocationInitServiceImpl extends ServiceImpl<IRelocationInitMapper, RelocationInit> implements IRelocationInitService {
|
|
|
|
|
@@ -39,22 +42,45 @@ public class RelocationInitServiceImpl extends ServiceImpl<IRelocationInitMapper
|
|
|
|
|
|
@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;
|
|
|
+ try {
|
|
|
+ ScenePlus sx = null;
|
|
|
+ if(StrUtil.isNotEmpty(relocationInit.getNum())){
|
|
|
+ sx = scenePlusService.getScenePlusByNum(relocationInit.getNum());
|
|
|
+ }else{
|
|
|
+ sx = scenePlusService.getByFileId(relocationInit.getUnicode());
|
|
|
+ }
|
|
|
+ if(Objects.isNull(sx) || (sx.getSceneStatus() != SceneStatus.NO_DISPLAY.code() && sx.getSceneStatus() != SceneStatus.SUCCESS.code())){
|
|
|
+ if(Objects.nonNull(sx)){
|
|
|
+ relocationInit.setNum(sx.getNum());
|
|
|
+ relocationInit.setUpdateTime(null);
|
|
|
+ this.updateById(relocationInit);
|
|
|
+ }
|
|
|
+ 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.setNum(sx.getNum());
|
|
|
+ relocationInit.setStatus(CommonSuccessStatus.SUCCESS.code());
|
|
|
+ relocationInit.setUpdateTime(null);
|
|
|
+ this.updateById(relocationInit);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("重定位初始化推送报错, relocationInit-id:{}", relocationInit.getId(), e);
|
|
|
+ }finally {
|
|
|
+ //如果等待状态持续一个星期,可以认为这个记录由于各种未知情况,推送不出去,置为失败
|
|
|
+ if(relocationInit.getStatus() == CommonSuccessStatus.WAITING.code() && relocationInit.getCreateTime().before(DateUtil.offsetDay(new Date(), -7))){
|
|
|
+ relocationInit.setStatus(CommonSuccessStatus.FAIL.code());
|
|
|
+ relocationInit.setUpdateTime(null);
|
|
|
+ this.updateById(relocationInit);
|
|
|
+ }
|
|
|
}
|
|
|
- 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
|