|
@@ -0,0 +1,57 @@
|
|
|
+package com.fdkankan.ucenter.mq.consumer;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.fdkankan.ucenter.entity.ScenePlus;
|
|
|
+import com.fdkankan.ucenter.service.IScenePlusService;
|
|
|
+import com.fdkankan.ucenter.service.impl.SceneCommonService;
|
|
|
+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 UpdateSceneStatusConsumer {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IScenePlusService scenePlusService;
|
|
|
+ @RabbitListener(
|
|
|
+ queuesToDeclare = @Queue("${queue.scene.laser.title:update-scene-title}")
|
|
|
+ ,concurrency = "1"
|
|
|
+ )
|
|
|
+ public void consumerQueue(Channel channel, Message message) {
|
|
|
+ try {
|
|
|
+ String messageId = message.getMessageProperties().getMessageId();
|
|
|
+ String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
+ log.info("update-scene-status-ucent--messageId:{},msg:{}",messageId,msg);
|
|
|
+
|
|
|
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(msg);
|
|
|
+ String num = jsonObject.getString("sceneNum");
|
|
|
+ String title = jsonObject.getString("sceneNewTitle");
|
|
|
+ if(StringUtils.isNotBlank(num) && StringUtils.isNotBlank(title)){
|
|
|
+ LambdaUpdateWrapper<ScenePlus> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(ScenePlus::getNum,num);
|
|
|
+ wrapper.set(ScenePlus::getTitle,title);
|
|
|
+ scenePlusService.update(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("update-scene-title-ucent----消费失败",e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|