RelocationBatchServiceImpl.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package com.fdkankan.contro.service.impl;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.fdkankan.contro.entity.RelocationBatch;
  5. import com.fdkankan.contro.entity.ScenePlus;
  6. import com.fdkankan.contro.entity.ScenePlusExt;
  7. import com.fdkankan.contro.mapper.IRelocationBatchMapper;
  8. import com.fdkankan.contro.service.IRelocationBatchService;
  9. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  10. import com.fdkankan.contro.service.IScenePlusExtService;
  11. import com.fdkankan.contro.service.IScenePlusService;
  12. import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
  13. import com.fdkankan.rabbitmq.util.RabbitMqProducer;
  14. import lombok.extern.slf4j.Slf4j;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.beans.factory.annotation.Value;
  17. import org.springframework.stereotype.Service;
  18. import javax.annotation.Resource;
  19. import java.util.HashMap;
  20. import java.util.List;
  21. import java.util.Map;
  22. /**
  23. * <p>
  24. * 重定位批次表 服务实现类
  25. * </p>
  26. *
  27. * @author
  28. * @since 2025-09-09
  29. */
  30. @Slf4j
  31. @Service
  32. public class RelocationBatchServiceImpl extends ServiceImpl<IRelocationBatchMapper, RelocationBatch> implements IRelocationBatchService {
  33. @Value("${queue.modeling.relocation.relocation-pre:sx-relocation-pre}")
  34. private String queueModelingPre;
  35. @Autowired
  36. private IScenePlusService scenePlusService;
  37. @Autowired
  38. private IScenePlusExtService scenePlusExtService;
  39. @Resource
  40. private RabbitMqProducer mqProducer;
  41. @Override
  42. public void relocationControl() {
  43. List<RelocationBatch> list = this.list(new LambdaQueryWrapper<RelocationBatch>().eq(RelocationBatch::getStatus, 0));
  44. if(CollUtil.isEmpty(list)){
  45. return;
  46. }
  47. for (RelocationBatch relocationBatch : list) {
  48. try {
  49. List<RelocationBatch> buildingList= this.list(new LambdaQueryWrapper<RelocationBatch>().eq(RelocationBatch::getNum, relocationBatch.getNum()).eq(RelocationBatch::getStatus, 1));
  50. if(CollUtil.isNotEmpty(buildingList)){
  51. continue;
  52. }
  53. this.relocationControlHandler(relocationBatch);
  54. }catch (Exception e){
  55. log.error("重定位调度失败,num:{}, batchId:{}", relocationBatch.getNum(), relocationBatch.getId(), e);
  56. }
  57. }
  58. }
  59. @Override
  60. public void relocationControlHandler(RelocationBatch relocationBatch) {
  61. ScenePlus scenePlus = scenePlusService.getScenePlusByNum(relocationBatch.getNum());
  62. ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
  63. String path = scenePlusExt.getDataSource() + "_relocation";
  64. BuildSceneCallMessage buildSceneMessage = new BuildSceneCallMessage();
  65. buildSceneMessage.setSceneNum(relocationBatch.getNum());
  66. buildSceneMessage.setBizType("relocation");
  67. buildSceneMessage.setPath(path);
  68. buildSceneMessage.setCameraType("14");
  69. Map<String, Object> ext = new HashMap<>();
  70. ext.put("batchId", relocationBatch.getId());
  71. buildSceneMessage.setExt(ext);
  72. mqProducer.sendByWorkQueue(queueModelingPre, buildSceneMessage);
  73. relocationBatch.setStatus(1);
  74. relocationBatch.setUpdateTime(null);
  75. this.updateById(relocationBatch);
  76. }
  77. }