Browse Source

1.mq取消手动确认

dev-warehouse
zhenghaoyu 2 years ago
parent
commit
907da55445
  1. 4
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java
  2. 21
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OpenOrderHandler.java
  3. 22
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java
  4. 13
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java

4
blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/DealWithDataHandler.java

@ -55,7 +55,7 @@ public class DealWithDataHandler {
}else{ }else{
if(!currentWarehouseId.equals(destinationWarehouseId)){ if(!currentWarehouseId.equals(destinationWarehouseId)){
log.info("##############dealWithDataHandler: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}",currentWarehouseId,destinationWarehouseId); log.info("##############dealWithDataHandler: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}",currentWarehouseId,destinationWarehouseId);
channel.basicAck(deliveryTag,false); // channel.basicAck(deliveryTag,false);
}else{ }else{
//真正的处理需要的数据 //真正的处理需要的数据
panFactoryDataService.handleDataToPlatform(unitNo); panFactoryDataService.handleDataToPlatform(unitNo);
@ -64,7 +64,7 @@ public class DealWithDataHandler {
}else{ }else{
log.info("##############dealWithDataHandler: 不用处理的状态 status={}",status); log.info("##############dealWithDataHandler: 不用处理的状态 status={}",status);
channel.basicAck(deliveryTag,false); // channel.basicAck(deliveryTag,false);
} }
} }
} }

21
blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OpenOrderHandler.java

@ -17,7 +17,6 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -43,7 +42,7 @@ public class OpenOrderHandler {
private Integer retryCount = 1; private Integer retryCount = 1;
@RabbitHandler @RabbitHandler
public void openOrderStatusHandler(Map map, Message message, Channel channel) throws IOException { public void openOrderStatusHandler(Map map, Message message, Channel channel) {
// 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉 // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉
final long deliveryTag = message.getMessageProperties().getDeliveryTag(); final long deliveryTag = message.getMessageProperties().getDeliveryTag();
String msg = new String(message.getBody()); String msg = new String(message.getBody());
@ -54,7 +53,7 @@ public class OpenOrderHandler {
AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderNo); AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderNo);
if(Objects.isNull(advanceEntity)){ if(Objects.isNull(advanceEntity)){
log.info("##################openOrderStatusHandler: 未找到对应订单 orderNo={}",orderNo); log.info("##################openOrderStatusHandler: 未找到对应订单 orderNo={}",orderNo);
channel.basicAck(deliveryTag,true); // channel.basicAck(deliveryTag,true);
return; return;
} }
String type = advanceEntity.getType();//品牌 String type = advanceEntity.getType();//品牌
@ -63,20 +62,20 @@ public class OpenOrderHandler {
switch (type){ switch (type){
case FactoryConstant.PIANO: case FactoryConstant.PIANO:
r = panFactoryDataService.handleData(orderInfoDTO); r = panFactoryDataService.handleData(orderInfoDTO);
int code = r.getCode();
if(code == 400 || code == 200){
log.info("##################openOrderStatusHandler: 该条数据不用处理 orderNo={}",orderNo);
// channel.basicAck(deliveryTag,true);
}else{
throw new CustomerException(code,r.getMsg());
}
break; break;
// case FactoryConstant.MENGT: // case FactoryConstant.MENGT:
// r = mtFactoryDataService.handleData(orderInfoDTO); // r = mtFactoryDataService.handleData(orderInfoDTO);
// break; // break;
default: default:
log.info("##################openOrderStatusHandler: 未知品牌 type={}",type); log.info("##################openOrderStatusHandler: 未知品牌 type={}",type);
channel.basicAck(deliveryTag,true); // channel.basicAck(deliveryTag,true);
}
int code = r.getCode();
if(code == 400 || code == 200){
log.info("##################openOrderStatusHandler: 该条数据不用处理 orderNo={}",orderNo);
channel.basicAck(deliveryTag,true);
}else{
throw new CustomerException(code,r.getMsg());
} }
} }
} }

22
blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java

@ -54,7 +54,7 @@ public class OrderStatusHandler {
AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderNo); AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderNo);
if(Objects.isNull(advanceEntity)){ if(Objects.isNull(advanceEntity)){
log.info("##################orderStatusHandler: 未找到对应订单 orderNo={}",orderNo); log.info("##################orderStatusHandler: 未找到对应订单 orderNo={}",orderNo);
channel.basicAck(deliveryTag,true); // channel.basicAck(deliveryTag,true);
return; return;
} }
String type = advanceEntity.getType();//品牌 String type = advanceEntity.getType();//品牌
@ -63,19 +63,27 @@ public class OrderStatusHandler {
switch (type){ switch (type){
case FactoryConstant.PIANO: case FactoryConstant.PIANO:
r = panFactoryDataService.handleStatusData(orderStatusDTO); r = panFactoryDataService.handleStatusData(orderStatusDTO);
int code = r.getCode();
if(code == 400 || code == 200){
log.info("##################orderStatusHandler: 该条数据不用处理 orderNo={}",orderNo);
// channel.basicAck(deliveryTag,true);
}else{
throw new CustomerException(code,r.getMsg());
}
break; break;
case FactoryConstant.MENGT: case FactoryConstant.MENGT:
r = mtFactoryDataService.handleStatusData(orderStatusDTO); r = mtFactoryDataService.handleStatusData(orderStatusDTO);
break; code = r.getCode();
default:
log.info("##################orderStatusHandler: 未知品牌 type={}",type);
}
int code = r.getCode();
if(code == 400 || code == 200){ if(code == 400 || code == 200){
log.info("##################orderStatusHandler: 该条数据不用处理 orderNo={}",orderNo); log.info("##################orderStatusHandler: 该条数据不用处理 orderNo={}",orderNo);
channel.basicAck(deliveryTag,true); // channel.basicAck(deliveryTag,true);
}else{ }else{
throw new CustomerException(code,r.getMsg()); throw new CustomerException(code,r.getMsg());
} }
break;
default:
log.info("##################orderStatusHandler: 未知品牌 type={}",type);
}
} }
} }

13
blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ReceiveInfoHandler.java

@ -58,7 +58,7 @@ public class ReceiveInfoHandler {
AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderCode); AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderCode);
if(Objects.isNull(advanceEntity)){ if(Objects.isNull(advanceEntity)){
log.info("##################receiveInfoHandler: 未找到对应订单 orderCode={}",orderCode); log.info("##################receiveInfoHandler: 未找到对应订单 orderCode={}",orderCode);
channel.basicAck(deliveryTag,true); // channel.basicAck(deliveryTag,true);
return; return;
} }
String type = advanceEntity.getType();//品牌 String type = advanceEntity.getType();//品牌
@ -70,11 +70,6 @@ public class ReceiveInfoHandler {
// break; // break;
case FactoryConstant.MENGT: case FactoryConstant.MENGT:
r = mtFactoryDataService.sendReceiveInfo(receiveInfoDTO); r = mtFactoryDataService.sendReceiveInfo(receiveInfoDTO);
break;
default:
log.info("##################receiveInfoHandler: 未知品牌 type={}",type);
channel.basicAck(deliveryTag,true);
}
int code = r.getCode(); int code = r.getCode();
if(code == 400 || code == 200){ if(code == 400 || code == 200){
log.info("##################receiveInfoHandler: 该条数据不用处理 orderNo={}",orderCode); log.info("##################receiveInfoHandler: 该条数据不用处理 orderNo={}",orderCode);
@ -82,5 +77,11 @@ public class ReceiveInfoHandler {
}else{ }else{
throw new CustomerException(code,r.getMsg()); throw new CustomerException(code,r.getMsg());
} }
break;
default:
log.info("##################receiveInfoHandler: 未知品牌 type={}",type);
// channel.basicAck(deliveryTag,true);
}
} }
} }

Loading…
Cancel
Save