Browse Source

1.调试欧派工厂数据对接,消息队列重复问题

training
pref_mail@163.com 2 years ago
parent
commit
f95c7b6346
  1. 7
      blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java
  2. 2
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/OpOrderStatusLogEntity.java
  3. 2
      blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceClient.java
  4. 5
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java
  5. 18
      blade-service/logpm-factory/src/main/java/com/logpm/factory/config/RabbitMqConfiguration.java
  6. 18
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpReceivingDataHandler.java
  7. 12
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java
  8. 13
      blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java
  9. 2
      blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java

7
blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java

@ -66,4 +66,11 @@ public interface RabbitConstant {
String STOCKUP_SCAN_EXCHANGE = "stockup_scan_exchange";
String STOCKUP_SCAN_ROUTING = "stockup_scan_routing";
/****************test队列******************/
String TEST_RECEIVE_INFO_QUEUE = "test_receive_info_queue";
String TEST_RECEIVE_INFO_EXCHANGE = "test_receive_info_exchange";
String TEST_RECEIVE_INFO_ROUTING = "test_receive_info_routing";
}

2
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/OpOrderStatusLogEntity.java

@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
@Data
@TableName("order_status_log")
@TableName("op_order_status_log")
@ApiModel(value = "OrderStatusLog对象", description = "欧派的数据")
@EqualsAndHashCode(callSuper = true)
public class OpOrderStatusLogEntity extends BaseEntity {

2
blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceClient.java

@ -78,7 +78,7 @@ public interface IAdvanceClient {
*/
@GetMapping(API_PREFIX + "/queryDataOne")
AdvanceEntity getQueryDataOne(@RequestParam String orderSelfNum);
@GetMapping(API_PREFIX + "/queryDataOne")
@GetMapping(API_PREFIX + "/getEntityByMctsTruck")
AdvanceEntity getEntityByMctsTruck(@RequestParam String orderSelfNum,@RequestParam String mctsTruck);
@GetMapping(API_PREFIX + "/fingById")

5
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java

@ -387,11 +387,6 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
addAdvanceEntityBtOuPai(receivingOrderEntity, factoryOrderEntities);
}
// // 需要将需要处理的数据进行查询 查询包件
// List<FactoryPackageEntity> list = factoryPackageService.lambdaQuery().eq(FactoryPackageEntity::getCarNumber, carNumber).list();
// // 将这里数据加入到老的advance
}
/**

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

@ -212,6 +212,24 @@ public class RabbitMqConfiguration {
return BindingBuilder.bind(oupaiReceivingQueue).to(oupaiReceivingExchange).with(RabbitConstant.OUPAI_RECEIVING_ROUTING).noargs();
}
@Bean
public Queue oupaiTestReceivingQueue() {
return new Queue(RabbitConstant.TEST_RECEIVE_INFO_QUEUE, true);
}
@Bean
public CustomExchange oupaiTestReceivingExchange() {
Map<String, Object> args = Maps.newHashMap();
args.put("x-delayed-type", "direct");
return new CustomExchange(RabbitConstant.TEST_RECEIVE_INFO_EXCHANGE, "x-delayed-message", true, false, args);
}
@Bean
public Binding oupaiTestReceivingBinding(Queue oupaiTestReceivingQueue, CustomExchange oupaiTestReceivingExchange) {
return BindingBuilder.bind(oupaiTestReceivingQueue).to(oupaiTestReceivingExchange).with(RabbitConstant.TEST_RECEIVE_INFO_ROUTING).noargs();
}
}

18
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpReceivingDataHandler.java

@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.time.LocalTime;
import java.util.Date;
import java.util.Map;
@ -25,7 +26,7 @@ import java.util.Map;
* @author yangkai.shen
*/
@Slf4j
@RabbitListener(queues = RabbitConstant.OUPAI_RECEIVING_QUEUE)
@RabbitListener(queues = RabbitConstant.RECEIVE_INFO_QUEUE)
@Component
public class OpReceivingDataHandler {
@ -47,11 +48,20 @@ public class OpReceivingDataHandler {
JSONObject packageJSON = packages.getJSONObject(j);
String packageStatus = packageJSON.getString("PackageStatus");
String orderPackageCode = packageJSON.getString("Code");
Date receivingTime = packageJSON.getDate("ReceivingTime");
if("已在库".equals(packageStatus)){
String receivingTime=null;
try{
receivingTime = packageJSON.getString("CreateTime");
}catch (Exception e){
log.error(e.getMessage());
}
log.info("##################opReceivingDataHandler: 处理欧派收货数据到新系统,packageStatus:{},orderPackageCode:{},receivingTime{}",
packageStatus,orderPackageCode,receivingTime);
//判断是否是已入库
if("已入库".equals(packageStatus)){
//真正的处理需要的数据
try {
panFactoryDataService.handleDataToPlatform(orderPackageCode, CommonUtil.dateToStringGeneral(receivingTime));
panFactoryDataService.handleDataToPlatform(orderPackageCode, receivingTime);
} catch (Exception e) {
e.printStackTrace();
}

12
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java

@ -137,7 +137,6 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
opOrderStatusLogEntity.setDataStatus(1);
} catch (Exception e) {
e.printStackTrace();
log.error("############handlePackageData: {}", e.getMessage());
opOrderStatusLogEntity.setDataStatus(2);
}
@ -156,10 +155,8 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
//TODO 这里需要添加处理配送发运单的逻辑
opOrderStatusLogEntity.setDataStatus(1);
} catch (Exception e) {
e.printStackTrace();
log.error("############handlePackageData: {}", e.getMessage());
opOrderStatusLogEntity.setDataStatus(2);
}
@ -179,7 +176,14 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
map.put("type", "Push");
map.put("messageData", opOrderStatusLogEntity);
map.put("createTime", new Date().getTime());
rabbitTemplate.convertAndSend(RabbitConstant.OUPAI_RECEIVING_EXCHANGE, RabbitConstant.OUPAI_RECEIVING_ROUTING, map);
try {
rabbitTemplate.convertAndSend(RabbitConstant.RECEIVE_INFO_EXCHANGE, RabbitConstant.RECEIVE_INFO_ROUTING, map);
} catch (Exception e) {
log.error("############handlePackageData: {}", e.getMessage());
}
log.info("############handlePackageData: 数据处理结束");
}

13
blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java

@ -362,9 +362,13 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
Integer total = advanceEntity.getTotal();//发货总数量
Map<String, String> supplyData = advanceDetailClient.getSupplyData(unitNo);
String destinationWarehouse = supplyData.get("destinationWarehouse");//目的仓名称
String destinationWarehouse= "";
String takeCompany= "";
if(ObjectUtil.isNotEmpty(supplyData)){
destinationWarehouse = supplyData.get("destinationWarehouse");//目的仓名称
takeCompany = supplyData.get("takeCompany");
}
String takeCompany = supplyData.get("takeCompany");
// 查询数据对应的仓库名称
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.findByName(destinationWarehouse);
@ -375,7 +379,10 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
String waybillNoNum = advanceEntity.getWaybillNo();
if (Objects.isNull(distributionStockArticleEntity)) {
Date date = CommonUtil.StringToDate(operationTime);
Date date = new Date();
if(StringUtil.isNoneBlank(operationTime)){
date = CommonUtil.StringToDate(operationTime);
}
logger.info("#################handleDataToPlatform.waybillNoNum: {}", waybillNoNum);
distributionStockArticleEntity = new DistributionStockArticleEntity();

2
blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java

@ -32,6 +32,8 @@ public class ErrorQueueHandler {
@RabbitHandler
public void orderStatusHandlerManualAck(Map map, Message message, Channel channel) {
// 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉
log.error(message.toString());
final long deliveryTag = message.getMessageProperties().getDeliveryTag();
try {
Long logId = (Long) map.get("logId");

Loading…
Cancel
Save