From f95c7b63461c3c92ac20e6cd5c0e335702d51236 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" <123456> Date: Thu, 7 Sep 2023 21:58:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=B0=83=E8=AF=95=E6=AC=A7=E6=B4=BE=E5=B7=A5?= =?UTF-8?q?=E5=8E=82=E6=95=B0=E6=8D=AE=E5=AF=B9=E6=8E=A5=EF=BC=8C=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E9=98=9F=E5=88=97=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RabbitConstant.java | 7 ++++ .../oupai/entity/OpOrderStatusLogEntity.java | 2 +- .../oldproject/feign/IAdvanceClient.java | 2 +- .../service/impl/AsyncDataServiceImpl.java | 5 --- .../factory/config/RabbitMqConfiguration.java | 18 ++++++++ .../receiver/OpReceivingDataHandler.java | 18 ++++++-- .../service/impl/OuPaiFactoryServiceImpl.java | 42 ++++++++++--------- .../impl/PanFactoryDataServiceImpl.java | 13 ++++-- .../factory/receiver/ErrorQueueHandler.java | 2 + 9 files changed, 76 insertions(+), 33 deletions(-) diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java index 7ab6e3254..9cc654405 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/RabbitConstant.java +++ b/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"; + + } diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/OpOrderStatusLogEntity.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/OpOrderStatusLogEntity.java index ad2e7dca7..724b55950 100644 --- a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/OpOrderStatusLogEntity.java +++ b/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 { diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceClient.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceClient.java index bd99121c3..10af419cb 100644 --- a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IAdvanceClient.java +++ b/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") diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java index 7bac612f3..6fbb5327b 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java +++ b/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 list = factoryPackageService.lambdaQuery().eq(FactoryPackageEntity::getCarNumber, carNumber).list(); -// // 将这里数据加入到老的advance - - } /** 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 e6428d65c..aed756fd9 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 @@ -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 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(); + } + + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpReceivingDataHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpReceivingDataHandler.java index 43002c0e7..85f7b3928 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpReceivingDataHandler.java +++ b/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(); } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java index f6477ece7..23223e84f 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java +++ b/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=" + diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java index db2e95916..f90613d77 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java +++ b/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 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(); diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java index 7635fee43..1e4cfce36 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/ErrorQueueHandler.java +++ b/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");