|
@@ -0,0 +1,56 @@
|
|
|
+package com.gis.listener.container;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.gis.common.annotation.LogAnnotation;
|
|
|
+import com.gis.domain.dto.DeleteSceneDTO;
|
|
|
+import com.gis.domain.dto.DoSliceDTO;
|
|
|
+import com.gis.domain.entity.WorkEntity;
|
|
|
+import com.gis.service.FodderService;
|
|
|
+import com.gis.service.WorkService;
|
|
|
+import com.rabbitmq.client.Channel;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.amqp.core.Message;
|
|
|
+import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Xiewj
|
|
|
+ * @date 2025/3/19
|
|
|
+ */
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class DeleteQueueListener implements ChannelAwareMessageListener {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WorkService workService;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @LogAnnotation
|
|
|
+ public void onMessage(Message message, Channel channel) throws Exception {
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(message.getBody())) {
|
|
|
+ log.error("消息内容为空,退出构建,当前服务器id:{}" );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
|
|
+ try {
|
|
|
+ String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
+ String messageId = message.getMessageProperties().getMessageId();
|
|
|
+ log.info("场景doSliceQueue开始,id:{},deliveryTag:{},消息体:{}", messageId,deliveryTag,msg);
|
|
|
+ DeleteSceneDTO dto = JSONObject.parseObject(msg, DeleteSceneDTO.class);
|
|
|
+ if (dto != null && dto.getNumList() != null) {
|
|
|
+ workService.removeByNums(dto.getNumList());
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("场景doSliceQueue报错{}",e.getMessage());
|
|
|
+ }finally {
|
|
|
+ channel.basicAck(deliveryTag, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|