From 92dffaf5a38a6506065ef4f6cabf11a01a523095 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Mon, 19 Jun 2023 15:35:41 +0800 Subject: [PATCH] =?UTF-8?q?1.mq=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../factory/config/RabbitMqConfiguration.java | 22 +++++++++++++++---- .../controller/PanFactoryDataController.java | 6 ++--- .../impl/PanFactoryDataServiceImpl.java | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java index a2cc7b1f3..0d9cb8945 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java @@ -1,12 +1,16 @@ package com.logpm.factory.config; import com.alibaba.nacos.shaded.com.google.common.collect.Maps; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.logpm.factory.snm.entity.PanOrderStatusLog; +import com.logpm.factory.snm.service.IPanOrderStatusLogService; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.RabbitConstant; import org.springframework.amqp.core.*; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -21,6 +25,9 @@ import java.util.Map; @Configuration public class RabbitMqConfiguration { + @Autowired + private IPanOrderStatusLogService panOrderStatusLogService; + @Bean public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory){ RabbitTemplate template = new RabbitTemplate(); @@ -32,6 +39,13 @@ public class RabbitMqConfiguration { System.out.println("确认回调-相关数据:"+correlationData); System.out.println("确认回调-确认情况:"+b); System.out.println("确认回调-原因:"+s); + //修改处理日志为已处理 + Long id = Long.parseLong(correlationData.getId()); + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("status",0) + .eq("id",id); + panOrderStatusLogService.update(updateWrapper); + } }); @@ -78,9 +92,9 @@ public class RabbitMqConfiguration { } -// @Bean -// DirectExchange lonelyDirectExchange() { -// return new DirectExchange("lonelyDirectExchange"); -// } + @Bean + DirectExchange lonelyDirectExchange() { + return new DirectExchange("lonelyDirectExchange"); + } } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java index 433f91757..f1cce3197 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java @@ -35,6 +35,7 @@ import org.springblade.common.exception.CustomerException; import org.springblade.common.utils.CommonUtil; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; +import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -168,10 +169,7 @@ public class PanFactoryDataController extends BladeController { map.put("messageData",orderInfoDTO); map.put("createTime",new Date().getTime()); //将消息携带绑定键值:TestDirectRouting 发送到交换机TestDirectExchange - rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map); - - panOrderStatusLog.setStatus(0); - panOrderStatusLogService.saveOrUpdate(panOrderStatusLog); + rabbitTemplate.convertAndSend("lonelyDirectExchange", RabbitConstant.ORDER_STATUS_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId()))); // R r = factoryDataService.handleData(orderInfoDTO); return R.success("调用成功"); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java index d1422e92e..6ab85b8cd 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java @@ -131,7 +131,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { //请求参数 logger.info("##############handleData: 推送包件状态请求参数 {}",s); //处理逻辑 - String result = HttpRequest.post(panFactoryProperties.getUrl()+"/hitf/v1/rest/invoke?namespace=HZERO&serverCode=HUITONG_MID_RECEIVE") + String result = HttpRequest.post(panFactoryProperties.getUrl()+"/hitf/v1/rest/invoke?namespace=HZERO&serverCode=OPEN&interfaceCode=HUITONG_MID_RECEIVE") .header("Authorization","Bearer "+panToken) .header("Content-Type","application/json") .body(s).timeout(5 * 1000)