瀏覽代碼

laser-mq update gps

lyhzzz 1 年之前
父節點
當前提交
71da639aa9

+ 53 - 0
src/main/java/com/fdkankan/manage_jp/mq/consumer/LaserSceneGpsConsumer.java

@@ -0,0 +1,53 @@
+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 {
+
+        }
+
+    }
+
+}

+ 9 - 0
src/main/java/com/fdkankan/manage_jp/mq/vo/LaserSceneGpsVo.java

@@ -0,0 +1,9 @@
+package com.fdkankan.manage_jp.mq.vo;
+
+import lombok.Data;
+
+@Data
+public class LaserSceneGpsVo {
+    private String num;
+    private Double[] location;
+ }

+ 1 - 1
src/main/resources/mapper/manage_jp/ProjectSceneGpsMapper.xml

@@ -6,6 +6,6 @@
         SELECT s.num,s.scene_source,e.web_site,e.gps,e.data_source FROM t_scene_plus s
                               LEFT JOIN t_scene_plus_ext e on s.id = e.plus_id
                               LEFT JOIN t_project_scene_gps gps on s.num = gps.num
-        WHERE s.rec_status = 'A' and e.gps is not null and s.scene_status = -2 and gps.num is null
+        WHERE s.rec_status = 'A' and e.gps is not null and s.scene_status = -2 and gps.num is null  limit 100
     </select>
 </mapper>