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. 42
      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();
}

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

@ -59,7 +59,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
// 对返回i的数据进行处理 按照 发车单-->订单-->包件 完成保存
handleData(code);
if(ObjectUtils.isNotNull(code)){
if (ObjectUtils.isNotNull(code)) {
asyncDataService.handlerOuPaiDataToHt(code);
}
return code;
@ -67,9 +67,9 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
}
@Override
public String saveOuPaiPackageStatusByCode(String orderCode,Integer event) {
public String saveOuPaiPackageStatusByCode(String orderCode, Integer event) {
//
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/ReceivingOrder?$filter=Code eq '"+orderCode+"'&select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber\n" +
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/ReceivingOrder?$filter=Code eq '" + orderCode + "'&select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber\n" +
"&$expand=" +
"Packages($select=Code,PdaNumber,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,SortingCenter,DistributionCenter,Length,Width,Height,Weight,OrderDetail,Order,PathIndex,PathDetail,DeliveryOrders,ReceivingOrders,LPN,LpnSerialNum,IsEntruck,ReservationOrder,OutGoingOrderDetail,SignBill,IsInventory,Inventories,InventoryInDetails,Freeze,OutGoingOrderDetailInventoryDetail,From,Creator,CreateTime,ShipTime,CarNumber,DeliveryMethod,DeliveryReceiver,DeliveryReceiverPhone,ReturnNumber,GroupType,CarrierCode,CarrierName,PackageDetailNames,ReceivingTime,SendTime,ExceptionSignRemark,Descript,SignTime,OutOrder,IsReceiveByHand,PackageStatus,PackageDetailNames;" +
"$expand=Order($select=" +
@ -80,7 +80,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
"&$expand=SendWarehouse($select=Name,Code)" +
")&$expand=FromWarehouse($select=Name,Code)&$expand=CurrentWarehouse($select=Name,Code)&$expand=EndWarehouse($select=Name,Code)";
handlePackageData(url,event);
handlePackageData(url, event);
return orderCode;
}
@ -108,23 +108,23 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
"$expand=ReservationOrderInventoryDetail($select=Qty;$expand=Inventory($select=SerialNumber,BatchCode," +
"Code,Name,Unit,Qty,HoldQty,SelectedQty,Location))))";
handleOutGoingOrderData(url,event);
handleOutGoingOrderData(url, event);
return orderCode;
}
@Override
public String savaOuPaiSignBillByCode(String orderCode, Integer event) {
//
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/SignBill?$filter=Code eq '"+orderCode+"'" +
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/SignBill?$filter=Code eq '" + orderCode + "'" +
"&$select=Code,Status,SignPerson,SignPhone,SignAddress,SignTime,Remark," +
"&$expand=OutGoingOrder($select=Code,Status&$expand=OutGoingOrderDetails($select=))&$expand=Packages($select=Code,FirstClassName,PackageStatus)&$expand=SignPictures($select=)";
handleSignBillData(url,event);
handleSignBillData(url, event);
return orderCode;
}
private void handleSignBillData(String url, Integer event) {
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url,event);
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event);
// 保存需要解析的数据
// 获取返回内容
@ -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);
}
@ -145,7 +144,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
}
private void handleOutGoingOrderData(String url, Integer event) {
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url,event);
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event);
// 保存需要解析的数据
// 获取返回内容
@ -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);
}
@ -167,9 +164,9 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
}
private void handlePackageData(String url,Integer event) {
private void handlePackageData(String url, Integer event) {
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url,event);
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event);
// 保存需要解析的数据
// 获取返回内容
@ -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: 数据处理结束");
}
@ -359,7 +363,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
}
JSONObject store = orderEntity.getJSONObject("Store");
if(!Objects.isNull(store)){
if (!Objects.isNull(store)) {
factoryOrderEntity.setStoreCode(store.getString("Code"));
factoryOrderEntity.setStoreName(store.getString("Name"));
}
@ -489,11 +493,11 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
factoryPackageEntity.setPushStatus(0);
factoryPackageEntity.setTurnStatus(0);
boolean save = factoryPackageService.save(factoryPackageEntity);
if(save){
if (save) {
Long packageId = factoryPackageEntity.getId();
//保存物料信息
JSONArray packageDetails = packageEntity.getJSONArray("PackageDetails");
if(!Objects.isNull(packageDetails)){
if (!Objects.isNull(packageDetails)) {
for (int k = 0; k < packageDetails.size(); k++) {
JSONObject packageDetailsJSONObject = packageDetails.getJSONObject(k);
FactoryPackageDetailEntity factoryPackageDetailEntity = new FactoryPackageDetailEntity();
@ -534,7 +538,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
*/
private OpOrderStatusLogEntity findOurPaiDataByCarNumber(String code) {
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/ReceivingOrder?$filter=Code eq '"+code+"'&select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber\n" +
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/ReceivingOrder?$filter=Code eq '" + code + "'&select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber\n" +
"&$expand=" +
"Packages($select=Code,PdaNumber,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,SortingCenter,DistributionCenter,Length,Width,Height,Weight,OrderDetail,Order,PathIndex,PathDetail,DeliveryOrders,ReceivingOrders,LPN,LpnSerialNum,IsEntruck,ReservationOrder,OutGoingOrderDetail,SignBill,IsInventory,Inventories,InventoryInDetails,Freeze,OutGoingOrderDetailInventoryDetail,From,Creator,CreateTime,ShipTime,CarNumber,DeliveryMethod,DeliveryReceiver,DeliveryReceiverPhone,ReturnNumber,GroupType,CarrierCode,CarrierName,PackageDetailNames,ReceivingTime,SendTime,ExceptionSignRemark,Descript,SignTime,OutOrder,IsReceiveByHand,PackageStatus,PackageDetailNames;" +
"$expand=Order($select=" +

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