1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package com.fdkankan.manage_jp.mq.consumer;
- import com.alibaba.fastjson.JSONObject;
- import com.fdkankan.manage_jp.mq.vo.LaserSceneGpsVo;
- import com.fdkankan.manage_jp.mq.vo.LaserSceneTitleVo;
- import com.fdkankan.manage_jp.service.IProjectSceneGpsService;
- import com.rabbitmq.client.Channel;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.amqp.core.Message;
- import org.springframework.amqp.rabbit.annotation.Queue;
- import org.springframework.amqp.rabbit.annotation.RabbitListener;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import java.nio.charset.StandardCharsets;
- /**
- * 场景封存解封 mq
- */
- @Slf4j
- @Component
- public class LaserSceneGpsConsumer {
- @Autowired
- IProjectSceneGpsService projectSceneGpsService;
- @RabbitListener(
- queuesToDeclare = @Queue("${queue.laser.update-scene.location:save-scene-location}")
- )
- public void consumerQueue(Channel channel, Message message) {
- try {
- String messageId = message.getMessageProperties().getMessageId();
- String msg = new String(message.getBody(), StandardCharsets.UTF_8);
- log.info("laser-update-save-scene-location-mq--messageId:{},msg:{}",messageId,msg);
- channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
- LaserSceneGpsVo vo = JSONObject.parseObject(msg, LaserSceneGpsVo.class);
- if(vo != null && StringUtils.isNotBlank(vo.getNum()) && vo.getLocation() != null && vo.getLocation().length >0){
- String lat = String.valueOf(vo.getLocation()[1]);
- String lon = String.valueOf(vo.getLocation()[0]);
- projectSceneGpsService.updateGps(vo.getNum(),lat,lon,2);
- }
- }catch (Exception e){
- log.info("laser-save-scene-location------消费失败",e);
- }finally {
- }
- }
- }
|