|
@@ -0,0 +1,86 @@
|
|
|
|
|
+package com.fdkankan.download.listener;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.fdkankan.common.constant.CommonStatus;
|
|
|
|
|
+import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
|
|
|
+import com.fdkankan.common.constant.SceneSource;
|
|
|
|
|
+import com.fdkankan.download.entity.DownloadLog;
|
|
|
|
|
+import com.fdkankan.download.entity.ScenePlus;
|
|
|
|
|
+import com.fdkankan.download.entity.ScenePlusExt;
|
|
|
|
|
+import com.fdkankan.download.service.*;
|
|
|
|
|
+import com.fdkankan.scene.entity.DownloadTourVideo;
|
|
|
|
|
+import com.fdkankan.scene.service.IDownloadTourVideoService;
|
|
|
|
|
+import com.fdkankan.scene.service.IRemovePortraitService;
|
|
|
|
|
+import com.fdkankan.scene.service.ISceneService;
|
|
|
|
|
+import com.rabbitmq.client.Channel;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+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.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * TODO
|
|
|
|
|
+ * </p>
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author dengsixing
|
|
|
|
|
+ * @since 2022/4/19
|
|
|
|
|
+ **/
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Component
|
|
|
|
|
+public class RabbitMqListener {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IDownloadService downloadService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IDownloadLogService downloadLogService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @RabbitListener(
|
|
|
|
|
+ queuesToDeclare = @Queue("batch-download-scene"),
|
|
|
|
|
+ concurrency = "5"
|
|
|
|
|
+ )
|
|
|
|
|
+ public void downloadScene(Channel channel, Message message) throws Exception {
|
|
|
|
|
+ String messageId = message.getMessageProperties().getMessageId();
|
|
|
|
|
+ String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
|
|
+ log.info("开始消费消息,id:{},queue:{},content:{}", messageId, "batch-download-scene", msg);
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(msg);
|
|
|
|
|
+ String num = jsonObject.getString("num");
|
|
|
|
|
+
|
|
|
|
|
+ DownloadLog downloadLog = new DownloadLog();
|
|
|
|
|
+ downloadLog.setNum(num);
|
|
|
|
|
+ ScenePlusExt scenePlusExt = null;
|
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
|
|
+ if(scenePlus == null){
|
|
|
|
|
+ downloadLog.setStatus(CommonSuccessStatus.FAIL.code());
|
|
|
|
|
+ downloadLog.setReason("场景不存在或已被删除");
|
|
|
|
|
+ downloadLogService.save(downloadLog);
|
|
|
|
|
+ }
|
|
|
|
|
+ scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
|
|
+ if(scenePlus.getSceneSource() == SceneSource.JG.code()
|
|
|
|
|
+ || scenePlus.getSceneSource() == SceneSource.SG.code()
|
|
|
|
|
+ || scenePlus.getSceneSource() == SceneSource.SX.code()){
|
|
|
|
|
+ downloadService.downloadLaserScene(num);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(scenePlus.getSceneSource() == SceneSource.BM.code()
|
|
|
|
|
+ || scenePlus.getSceneSource() == SceneSource.ZT.code()
|
|
|
|
|
+ || scenePlusExt.getIsObj() == 1){
|
|
|
|
|
+ downloadService.downloadMeshScene(num);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
|
|
+ log.info("结束消费消息,id:{}", messageId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|