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; /** *

* 重定位批次表 服务实现类 *

* * @author * @since 2025-09-09 */ @Slf4j @Service public class RelocationBatchServiceImpl extends ServiceImpl implements IRelocationBatchService { @Value("${queue.modeling.relocation.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 list = this.list(new LambdaQueryWrapper().eq(RelocationBatch::getStatus, 0)); if(CollUtil.isEmpty(list)){ return; } for (RelocationBatch relocationBatch : list) { try { List buildingList= this.list(new LambdaQueryWrapper().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 ext = new HashMap<>(); ext.put("batchId", relocationBatch.getId()); buildSceneMessage.setExt(ext); mqProducer.sendByWorkQueue(queueModelingPre, buildSceneMessage); relocationBatch.setStatus(1); relocationBatch.setUpdateTime(null); this.updateById(relocationBatch); } }