123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- 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.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<RelocationBatch> list = this.list(new LambdaQueryWrapper<RelocationBatch>().eq(RelocationBatch::getStatus, 0));
- if(CollUtil.isEmpty(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);
- }
- }
|