Browse Source

1.mq逻辑修改

dev-warehouse
zhenghaoyu 2 years ago
parent
commit
92dffaf5a3
  1. 22
      blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java
  2. 6
      blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/controller/PanFactoryDataController.java
  3. 2
      blade-service/logpm-factory/src/main/java/com/logpm/factory/snm/service/impl/PanFactoryDataServiceImpl.java

22
blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java

@ -1,12 +1,16 @@
package com.logpm.factory.config; package com.logpm.factory.config;
import com.alibaba.nacos.shaded.com.google.common.collect.Maps; 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 lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.RabbitConstant; import org.springblade.common.constant.RabbitConstant;
import org.springframework.amqp.core.*; import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate; 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -21,6 +25,9 @@ import java.util.Map;
@Configuration @Configuration
public class RabbitMqConfiguration { public class RabbitMqConfiguration {
@Autowired
private IPanOrderStatusLogService panOrderStatusLogService;
@Bean @Bean
public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory){ public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory){
RabbitTemplate template = new RabbitTemplate(); RabbitTemplate template = new RabbitTemplate();
@ -32,6 +39,13 @@ public class RabbitMqConfiguration {
System.out.println("确认回调-相关数据:"+correlationData); System.out.println("确认回调-相关数据:"+correlationData);
System.out.println("确认回调-确认情况:"+b); System.out.println("确认回调-确认情况:"+b);
System.out.println("确认回调-原因:"+s); System.out.println("确认回调-原因:"+s);
//修改处理日志为已处理
Long id = Long.parseLong(correlationData.getId());
UpdateWrapper<PanOrderStatusLog> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("status",0)
.eq("id",id);
panOrderStatusLogService.update(updateWrapper);
} }
}); });
@ -78,9 +92,9 @@ public class RabbitMqConfiguration {
} }
// @Bean @Bean
// DirectExchange lonelyDirectExchange() { DirectExchange lonelyDirectExchange() {
// return new DirectExchange("lonelyDirectExchange"); return new DirectExchange("lonelyDirectExchange");
// } }
} }

6
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.common.utils.CommonUtil;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -168,10 +169,7 @@ public class PanFactoryDataController extends BladeController {
map.put("messageData",orderInfoDTO); map.put("messageData",orderInfoDTO);
map.put("createTime",new Date().getTime()); map.put("createTime",new Date().getTime());
//将消息携带绑定键值:TestDirectRouting 发送到交换机TestDirectExchange //将消息携带绑定键值:TestDirectRouting 发送到交换机TestDirectExchange
rabbitTemplate.convertAndSend(RabbitConstant.ORDER_STATUS_EXCHANGE, RabbitConstant.ORDER_STATUS_ROUTING, map); rabbitTemplate.convertAndSend("lonelyDirectExchange", RabbitConstant.ORDER_STATUS_ROUTING, map,new CorrelationData(String.valueOf(panOrderStatusLog.getId())));
panOrderStatusLog.setStatus(0);
panOrderStatusLogService.saveOrUpdate(panOrderStatusLog);
// R r = factoryDataService.handleData(orderInfoDTO); // R r = factoryDataService.handleData(orderInfoDTO);
return R.success("调用成功"); return R.success("调用成功");

2
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); 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("Authorization","Bearer "+panToken)
.header("Content-Type","application/json") .header("Content-Type","application/json")
.body(s).timeout(5 * 1000) .body(s).timeout(5 * 1000)

Loading…
Cancel
Save