From 605e157f0e904f71ce4588311ad80b003537c878 Mon Sep 17 00:00:00 2001 From: zhaoqiaobo Date: Tue, 28 May 2024 16:42:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E5=A2=9E=E5=8A=A0=E6=88=91?= =?UTF-8?q?=E4=B9=90=E9=85=8D=E9=80=81=E8=8A=82=E7=82=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../factorydata/FactoryDataConstants.java | 2 + .../factory/mt/dto/MtReceiveContentDTO.java | 3 + .../factorydata/util/FactoryDataUtil.java | 1 + .../com/logpm/factorydata/vo/PushData.java | 20 ++- .../impl/DistributionAsyncServiceImpl.java | 148 ++++++++++++---- .../DistributionDeliveryListServiceImpl.java | 33 +++- .../DistrilbutionBillLadingServiceImpl.java | 10 +- .../src/main/resources/application-prod.yml | 2 +- .../olo/enums/FactoryNodeEnums.java | 29 ++++ .../olo/enums/NodeMappingEnums.java | 62 +++++++ .../factorydata/olo/enums/NodeNeedEnums.java | 34 ++++ .../olo/mq/FactoryOrderListener.java | 145 +--------------- .../olo/mq/NodeDataPushListener.java | 122 ++++++++++++++ .../olo/service/DeliveryNoteService.java | 1 + .../service/impl/DeliveryNoteServiceImpl.java | 159 +++++++++++++++++- .../zbom/controller/OrderController.java | 5 +- .../impl/TrunklineCarsLoadServiceImpl.java | 24 ++- 17 files changed, 603 insertions(+), 197 deletions(-) create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/FactoryNodeEnums.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/NodeMappingEnums.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/NodeNeedEnums.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/NodeDataPushListener.java diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java b/blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java index b75e6b5a9..c9540d3df 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java @@ -72,6 +72,7 @@ public abstract class FactoryDataConstants { /** * 我乐工厂订单 */ + String OLO_NODE_DATA_PUSH = "factory.data.queue.olo.nodeDataPush" + DEVAUTH; String OLO_FACTORY_ORDER = "factory.data.queue.olo.factoryOrder" + DEVAUTH; /** * 林氏工厂订单 @@ -120,6 +121,7 @@ public abstract class FactoryDataConstants { /** * 我乐工厂订单 */ + String OLO_NODE_DATA_PUSH = "olo.nodeDataPush" + DEVAUTH; String OLO_FACTORY_ORDER = "olo.factoryOrder" + DEVAUTH; /** * 林氏工厂订单 diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/mt/dto/MtReceiveContentDTO.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/mt/dto/MtReceiveContentDTO.java index 4a324c686..5d308b680 100644 --- a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/mt/dto/MtReceiveContentDTO.java +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/mt/dto/MtReceiveContentDTO.java @@ -24,4 +24,7 @@ public class MtReceiveContentDTO { @JsonProperty("发货单编号") private String invoiceOrderCode;//发货单编号 + @JsonProperty("运单号") + private String waybillNumber;//运单号 + } diff --git a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java index 3cec54208..8f93fe967 100644 --- a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java +++ b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java @@ -24,6 +24,7 @@ public class FactoryDataUtil { static { factorys.put(BrandEnums.ZB.getValue(), FactoryDataConstants.Mq.RoutingKeys.ZBOM_NODE_DATA_PUSH); factorys.put(BrandEnums.LINSY.getValue(), FactoryDataConstants.Mq.RoutingKeys.LINSY_NODE_DATA_PUSH); + factorys.put(BrandEnums.OLO.getValue(), FactoryDataConstants.Mq.RoutingKeys.OLO_NODE_DATA_PUSH); } diff --git a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/vo/PushData.java b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/vo/PushData.java index 280e55086..688462d48 100644 --- a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/vo/PushData.java +++ b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/vo/PushData.java @@ -1,17 +1,11 @@ package com.logpm.factorydata.vo; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.logpm.factorydata.enums.BrandEnums; -import com.logpm.factorydata.enums.SignForStatusEnums; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import org.springblade.common.constant.WorkNodeEnums; import java.io.Serializable; -import java.util.Date; -import java.util.List; /** * 提送数据 @@ -26,8 +20,20 @@ import java.util.List; public class PushData implements Serializable { /** - * 包件 + * 包件码 */ private String packageCode; + /** + * 订单号 + */ + private String orderCode; + /** + * 运单号 + */ + private String waybillNumber; + /** + * 当前仓库名称 + */ + private String warehouseName; } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java index 467295522..1e80737a2 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java @@ -18,10 +18,59 @@ import com.logpm.distribution.dto.DistributionStockArticleDTO; import com.logpm.distribution.dto.app.DistrilbutionloadingscanDTO; import com.logpm.distribution.dto.app.StockupDTO; import com.logpm.distribution.dto.app.StockupZeroDTO; -import com.logpm.distribution.entity.*; -import com.logpm.distribution.mapper.*; -import com.logpm.distribution.service.*; -import com.logpm.distribution.vo.*; +import com.logpm.distribution.entity.DisStockListDetailEntity; +import com.logpm.distribution.entity.DistributionBillLadingScanEntity; +import com.logpm.distribution.entity.DistributionDeliveryDetailsEntity; +import com.logpm.distribution.entity.DistributionDeliveryListEntity; +import com.logpm.distribution.entity.DistributionLoadscanEntity; +import com.logpm.distribution.entity.DistributionLoadscaninvnEntity; +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionParcelNumberEntity; +import com.logpm.distribution.entity.DistributionReservationEntity; +import com.logpm.distribution.entity.DistributionReservationPackageEntity; +import com.logpm.distribution.entity.DistributionReservationStockarticleEntity; +import com.logpm.distribution.entity.DistributionReservationStocklistEntity; +import com.logpm.distribution.entity.DistributionReservationZeroPackageEntity; +import com.logpm.distribution.entity.DistributionSignforEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; +import com.logpm.distribution.entity.DistributionStockEntity; +import com.logpm.distribution.entity.DistributionStockListEntity; +import com.logpm.distribution.entity.DistributionStockupEntity; +import com.logpm.distribution.entity.DistributionStockupInfoEntity; +import com.logpm.distribution.entity.DistrilbutionBillLadingEntity; +import com.logpm.distribution.entity.DistrilbutionBillPackageEntity; +import com.logpm.distribution.entity.DistrilbutionBillStockEntity; +import com.logpm.distribution.mapper.DistributionBillLadingScanMapper; +import com.logpm.distribution.mapper.DistributionDeliveryDetailsMapper; +import com.logpm.distribution.mapper.DistributionDeliveryListMapper; +import com.logpm.distribution.mapper.DistributionLoadscanMapper; +import com.logpm.distribution.mapper.DistributionLoadscaninvnMapper; +import com.logpm.distribution.mapper.DistributionParcelListMapper; +import com.logpm.distribution.mapper.DistributionReservationMapper; +import com.logpm.distribution.mapper.DistributionReservationPackageMapper; +import com.logpm.distribution.mapper.DistributionReservationStockarticleMapper; +import com.logpm.distribution.mapper.DistributionReservationStocklistMapper; +import com.logpm.distribution.mapper.DistributionSignforMapper; +import com.logpm.distribution.mapper.DistributionStockListMapper; +import com.logpm.distribution.mapper.DistributionStockMapper; +import com.logpm.distribution.mapper.DistributionStockupInfoMapper; +import com.logpm.distribution.mapper.DistributionStockupMapper; +import com.logpm.distribution.mapper.DistrilbutionBillLadingMapper; +import com.logpm.distribution.service.IDisStockListDetailService; +import com.logpm.distribution.service.IDistributionAsyncService; +import com.logpm.distribution.service.IDistributionDeliveryDetailsService; +import com.logpm.distribution.service.IDistributionParcelNumberService; +import com.logpm.distribution.service.IDistributionReservationStockarticleService; +import com.logpm.distribution.service.IDistributionReservationStocklistService; +import com.logpm.distribution.service.IDistributionReservationZeroPackageService; +import com.logpm.distribution.service.IDistributionStockArticleService; +import com.logpm.distribution.service.IDistrilbutionBillPackageService; +import com.logpm.distribution.service.IDistrilbutionBillStockService; +import com.logpm.distribution.vo.DistributionParcelNumberVO; +import com.logpm.distribution.vo.DistributionSignPrintVO; +import com.logpm.distribution.vo.DistributionStockPackageVO; +import com.logpm.distribution.vo.DistributionStockupSelfVO; +import com.logpm.distribution.vo.DistrilbutionBillStockVO; import com.logpm.factory.comfac.dto.OrderStatusDTO; import com.logpm.factory.mt.dto.MtReceiveContentDTO; import com.logpm.factory.mt.dto.MtReceiveDTO; @@ -31,12 +80,17 @@ import com.logpm.factory.oupai.feign.IOuPaiFactoryClinet; import com.logpm.factorydata.enums.BrandEnums; import com.logpm.factorydata.util.FactoryDataMessageSender; import com.logpm.factorydata.vo.NodePushMsg; +import com.logpm.factorydata.vo.PushData; import com.logpm.trunkline.dto.AddWaybillTrackDTO; import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import com.logpm.trunkline.entity.TrunklineWaybillOrderEntity; import com.logpm.trunkline.entity.TrunklineWaybillPackageEntity; -import com.logpm.trunkline.feign.*; +import com.logpm.trunkline.feign.ITrunklineAdvanceClient; +import com.logpm.trunkline.feign.ITrunklineAdvanceDetailClient; +import com.logpm.trunkline.feign.ITrunklineWaybillOrderClient; +import com.logpm.trunkline.feign.ITrunklineWaybillPackageClient; +import com.logpm.trunkline.feign.ITrunklineWaybillTrackClient; import com.logpm.trunkline.vo.TrunklineAdvanceDetailVO; import com.logpm.warehouse.entity.WarehouseWayBillDetail; import com.logpm.warehouse.entity.WarehouseWaybillEntity; @@ -64,7 +118,14 @@ import org.springblade.common.constant.orderpackage.OrderPackageLoadingStatusCon import org.springblade.common.constant.orderpackage.OrderPackageReservationStatusConstant; import org.springblade.common.constant.orderpackage.OrderPackageStatusConstant; import org.springblade.common.constant.orderpackage.OrderPackageStockupStatusConstant; -import org.springblade.common.constant.reservation.*; +import org.springblade.common.constant.reservation.ReservationInventoryLoadingStatusConstant; +import org.springblade.common.constant.reservation.ReservationInventorySigningStatusConstant; +import org.springblade.common.constant.reservation.ReservationInventoryStatusConstant; +import org.springblade.common.constant.reservation.ReservationLoadingStatusConstant; +import org.springblade.common.constant.reservation.ReservationOrderStatusConstant; +import org.springblade.common.constant.reservation.ReservationPackageStatusConstant; +import org.springblade.common.constant.reservation.ReservationSigningStatusConstant; +import org.springblade.common.constant.reservation.ReservationStockupStatusConstant; import org.springblade.common.constant.signing.SignforStatusConstant; import org.springblade.common.constant.stockup.StockupStatusConstant; import org.springblade.common.constant.stockup.StockupTypeConstant; @@ -82,7 +143,14 @@ import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -1471,7 +1539,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { @Transactional(rollbackFor = Exception.class) @LogpmAsync("asyncExecutor") public void sendReviewFactory(Long signingId, String warehouseName, Long warehouseId) { - String brands = "梦天,欧派,志邦,皮阿诺";//可追加 + String brands = "梦天,欧派,志邦,皮阿诺,我乐";//可追加 log.info(">>>>>>>>>>> 签收推送 对象 {}", "signingId:=" + signingId + "warehouseName:=" + warehouseName + "warehouseId:=" + warehouseId); //查询签收信息 DistributionSignforEntity distributionSignforEntity = distributionSignforMapper.selectById(signingId); @@ -1496,7 +1564,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { //存在订单 List orderIds = distributionReservationStockarticleEntities.stream().filter(f -> f.getIsZero().equals(IsOrNoConstant.no.getValue())).map(DistributionReservationStockarticleEntity::getStockArticleId).collect(Collectors.toList()); - if (ObjectUtils.isNotNull(orderIds) && !orderIds.isEmpty()){ + if (ObjectUtils.isNotNull(orderIds) && !orderIds.isEmpty()) { log.info(">>>brand 进入 orderIds {} ", orderIds); List distributionStockArticleEntities = distributionStockArticleService.listByIds(orderIds); @@ -1618,6 +1686,28 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { } } } + if (Func.isNotEmpty(brand.get("我乐"))) { + List zb = brand.get("我乐"); + List contents = new ArrayList<>(); + if (CollUtil.isNotEmpty(zb)) { + for (MtReceiveContentDTO mtReceiveContentDTO : zb) { + PushData pushData = PushData.builder() + .packageCode(mtReceiveContentDTO.getUnitNo()) + .orderCode(mtReceiveContentDTO.getOrderCode()) + .warehouseName(warehouseName) + .waybillNumber(mtReceiveContentDTO.getWaybillNumber()).build(); + contents.add(pushData); + } + } + NodePushMsg msg = new NodePushMsg(); + msg.setNode(WorkNodeEnums.CLERK_REVIEW); + msg.setBrand(BrandEnums.OLO); + msg.setOperator(distributionSignforEntity.getDeliveryDriverName()); + msg.setOperatorTime(new Date()); + msg.setContent(contents); + log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg)); + factoryDataMessageSender.sendNodeDataByBrand(msg); + } //....工厂 } catch (Exception e) { @@ -1764,7 +1854,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { //统计已装车数量 WarehouseWaybillEntity byWaybillNo = waybillClient.findByWaybillNo(k); AddWaybillTrackDTO addWaybillTrackDTO = new AddWaybillTrackDTO(); - if(ObjectUtils.isNotNull(byWaybillNo)){ + if (ObjectUtils.isNotNull(byWaybillNo)) { addWaybillTrackDTO.setWaybillId(byWaybillNo.getId()); addWaybillTrackDTO.setWaybillNo(byWaybillNo.getWaybillNo()); } @@ -2073,6 +2163,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { mtReceiveContentDTO.setUnitNo(distributionParcelListEntity.getOrderPackageCode());// mtReceiveContentDTO.setOperateDate(signingTime);//操作时间 mtReceiveContentDTO.setInvoiceOrderCode(deliveryCode);//发货编号 + mtReceiveContentDTO.setWaybillNumber(distributionParcelListEntity.getWaybillNumber()); mtReceiveContentDTOS.add(mtReceiveContentDTO); } } @@ -2829,6 +2920,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { } return null; } + @ChangeAsync() @Override public void saveOtherData(String tenantId, List waybillBilllByWaybillNos, List trunklineAdvanceDetailEntities, List trunklineAdvanceEntities, List trunklineWaybillPackageEntities, List trunklineWaybillOrderEntities, List warehouseWayBillDetails, List distributionParcelListEntities, String mallName) { @@ -2861,7 +2953,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { waybillBilllByWaybillNo.setDepartureWarehouseId(null); // 目的仓 - if(basicdataWarehouseEntity!=null){ + if (basicdataWarehouseEntity != null) { waybillBilllByWaybillNo.setDestinationWarehouseId(basicdataWarehouseEntity.getId()); waybillBilllByWaybillNo.setDestinationWarehouseName(basicdataWarehouseEntity.getName()); } @@ -2870,10 +2962,10 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { waybillBilllByWaybillNo.setTenantId(tenant.getTenantId()); WarehouseWaybillEntity byWaybillNo = warehouseWaybillClient.findByWaybillNo(waybillBilllByWaybillNo.getWaybillNo()); - if(byWaybillNo==null){ + if (byWaybillNo == null) { Long l = warehouseWaybillClient.addEnntity(waybillBilllByWaybillNo); waybillBilllByWaybillNo.setId(l); - }else{ + } else { waybillBilllByWaybillNo.setId(byWaybillNo.getId()); } @@ -2884,14 +2976,14 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { warehouseWayBillDetail.setId(null); for (WarehouseWayBillDetail wayBillDetail : byWaybillId) { - if(wayBillDetail.getProductName().equals(warehouseWayBillDetail.getProductName())){ + if (wayBillDetail.getProductName().equals(warehouseWayBillDetail.getProductName())) { // 不执行 warehouseWayBillDetail.setId(wayBillDetail.getId()); break; } } - if(warehouseWayBillDetail.getId()==null){ + if (warehouseWayBillDetail.getId() == null) { warehouseWayBillDetail.setWaybillId(waybillBilllByWaybillNo.getId()); warehouseWaybillDetailClient.addEntity(warehouseWayBillDetail); } @@ -2927,12 +3019,12 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { for (TrunklineWaybillOrderEntity waybillOrderEntity : listByWaybillNo) { - if(waybillOrderEntity.getOrderCode().equals(trunklineWaybillOrderEntity.getOrderCode())){ + if (waybillOrderEntity.getOrderCode().equals(trunklineWaybillOrderEntity.getOrderCode())) { trunklineWaybillOrderEntity.setId(waybillOrderEntity.getId()); } } - if(trunklineWaybillOrderEntity.getId()==null){ + if (trunklineWaybillOrderEntity.getId() == null) { Long l1 = trunklineWaybillOrderClient.addEntityReturnId(trunklineWaybillOrderEntity); @@ -2940,7 +3032,6 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { } - List ids = Arrays.asList(waybillBilllByWaybillNo.getId()); List listByWaybillIds = trunklineWaybillPackageClient.findListByWaybillIds(ids); @@ -2963,15 +3054,15 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { for (TrunklineWaybillPackageEntity listByWaybillId : listByWaybillIds) { - if(listByWaybillId.getWaybillId().equals(trunklineWaybillPackageEntity.getWaybillId())){ - if(listByWaybillId.getOrderPackageCode().equals(trunklineWaybillPackageEntity.getOrderPackageCode())){ + if (listByWaybillId.getWaybillId().equals(trunklineWaybillPackageEntity.getWaybillId())) { + if (listByWaybillId.getOrderPackageCode().equals(trunklineWaybillPackageEntity.getOrderPackageCode())) { trunklineWaybillPackageEntity.setId(listByWaybillId.getId()); break; } } } - if(trunklineWaybillPackageEntity.getId()==null){ + if (trunklineWaybillPackageEntity.getId() == null) { trunklineWaybillPackageClient.addEntity(trunklineWaybillPackageEntity); } @@ -2983,11 +3074,11 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { } private BasicdataWarehouseEntity getBasicdataWarehouseEntity(String mallName) { - String cacheName =mallName +"仓"; + String cacheName = mallName + "仓"; BasicdataWarehouseEntity basicdataWarehouseEntity = bladeRedis.get(cacheName); - if(basicdataWarehouseEntity==null){ - basicdataWarehouseEntity = warehouseClient.findByName(mallName +"仓"); - bladeRedis.setEx(cacheName,basicdataWarehouseEntity,60*60*24L); + if (basicdataWarehouseEntity == null) { + basicdataWarehouseEntity = warehouseClient.findByName(mallName + "仓"); + bladeRedis.setEx(cacheName, basicdataWarehouseEntity, 60 * 60 * 24L); } return basicdataWarehouseEntity; } @@ -2996,7 +3087,6 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { Tenant tenant = changeDataBase(mallName); - List ids = Arrays.asList(trunklineAdvanceEntity.getId()); List listByAdvanceIds = trunklineAdvanceDetailClient.findListByAdvanceIds(ids); @@ -3007,7 +3097,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { // 检测 保存的对象是否已经存在 for (TrunklineAdvanceDetailVO listByAdvanceId : listByAdvanceIds) { - if(listByAdvanceId.getOrderPackageCode().equals(trunklineAdvanceDetailEntity.getOrderPackageCode())){ + if (listByAdvanceId.getOrderPackageCode().equals(trunklineAdvanceDetailEntity.getOrderPackageCode())) { trunklineAdvanceDetailEntity.setId(listByAdvanceId.getId()); break; } @@ -3020,7 +3110,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { trunklineAdvanceDetailEntity.setIncomingWarehouseId(null); trunklineAdvanceDetailEntity.setIncomingWarehouseName(null); BasicdataWarehouseEntity basicdataWarehouseEntity = getBasicdataWarehouseEntity(mallName); - if(basicdataWarehouseEntity!=null){ + if (basicdataWarehouseEntity != null) { trunklineAdvanceDetailEntity.setWarehouseId(basicdataWarehouseEntity.getId()); trunklineAdvanceDetailEntity.setWarehouseName(basicdataWarehouseEntity.getName()); } @@ -3039,7 +3129,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { if (ObjectUtil.isEmpty(trunklineAdvanceEntity1)) { // 保存对象 - if(basicdataWarehouseEntity!=null){ + if (basicdataWarehouseEntity != null) { trunklineAdvanceEntity.setWarehouseId(basicdataWarehouseEntity.getId()); trunklineAdvanceEntity.setWarehouseName(basicdataWarehouseEntity.getName()); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java index 59deb1066..dc5742210 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java @@ -16,7 +16,9 @@ */ package com.logpm.distribution.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -47,6 +49,10 @@ import com.logpm.distribution.vo.app.DistributionAppParcelListVO; import com.logpm.distribution.vo.app.DistributionAppReservationVO; import com.logpm.distribution.vo.print.PrintPreviewVO; import com.logpm.distribution.wrapper.*; +import com.logpm.factorydata.enums.BrandEnums; +import com.logpm.factorydata.util.FactoryDataMessageSender; +import com.logpm.factorydata.vo.NodePushMsg; +import com.logpm.factorydata.vo.PushData; import com.logpm.warehouse.entity.WarehouseTrayGoodsEntity; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import com.logpm.warehouse.feign.*; @@ -61,6 +67,7 @@ import org.springblade.common.constant.Inventory.InventorySigningStatusConstant; import org.springblade.common.constant.Inventory.InventoryStockUpStatusConstant; import org.springblade.common.constant.ModuleNameConstant; import org.springblade.common.constant.RabbitConstant; +import org.springblade.common.constant.WorkNodeEnums; import org.springblade.common.constant.common.IsOrNoConstant; import org.springblade.common.constant.delivery.DeliveryLoadingStatusConstant; import org.springblade.common.constant.delivery.DeliveryStatusConstant; @@ -232,6 +239,9 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl pushList = new ArrayList<>(); if (distrilbutionloadingscanDTO.getType() == 1) { List list = disStockListDetailService.list(Wrappers.query().lambda() .eq(DisStockListDetailEntity::getStockPackageCode, distrilbutionloadingscanDTO.getBarcode()) @@ -755,7 +766,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl contents = new ArrayList<>(); + PushData pushData = PushData.builder() + .packageCode(parcelListEntity.getOrderPackageCode()) + .orderCode(parcelListEntity.getOrderCode()) + .warehouseName(myCurrentWarehouse.getName()) + .waybillNumber(parcelListEntity.getWaybillNumber()).build(); + contents.add(pushData); + NodePushMsg msg = new NodePushMsg(); + msg.setNode(WorkNodeEnums.DISTRIBUTION_LOADING); + msg.setBrand(BrandEnums.getByValue(parcelListEntity.getBrandName())); + msg.setOperator(AuthUtil.getNickName()); + msg.setOperatorTime(new Date()); + msg.setContent(contents); + log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg)); + factoryDataMessageSender.sendNodeDataByBrand(msg); + } + } //添加缓存 if (!packageLockIds.isEmpty()){ List a = bladeRedis.get("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + "orderPackageCode:"); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java index 9a5fcdfc5..03bc2a021 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java @@ -53,6 +53,7 @@ import com.logpm.distribution.wrapper.DistributionStockArticleWrapper; import com.logpm.factorydata.enums.BrandEnums; import com.logpm.factorydata.util.FactoryDataMessageSender; import com.logpm.factorydata.vo.NodePushMsg; +import com.logpm.factorydata.vo.PushData; import com.logpm.oldproject.dto.SignPushDataContactDTO; import com.logpm.oldproject.dto.SignPushDataDTO; import com.logpm.oldproject.dto.SignPushDataUnitDTO; @@ -3512,9 +3513,12 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl contents = new ArrayList<>(); if (CollUtil.isNotEmpty(value)) { for (DistributionParcelListEntity distributionParcelListEntity : value) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("packageCode", distributionParcelListEntity.getOrderPackageCode()); - contents.add(jsonObject); + PushData pushData = PushData.builder() + .packageCode(distributionParcelListEntity.getOrderPackageCode()) + .orderCode(distributionParcelListEntity.getOrderCode()) + .warehouseName(myCurrentWarehouse.getName()) + .waybillNumber(distributionParcelListEntity.getWaybillNumber()).build(); + contents.add(pushData); } } NodePushMsg msg = new NodePushMsg(); diff --git a/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/resources/application-prod.yml b/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/resources/application-prod.yml index 3bf1caa8b..924f6edba 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/resources/application-prod.yml +++ b/blade-service/logpm-factory-data/logpm-factory-data-base/src/main/resources/application-prod.yml @@ -1,6 +1,6 @@ #服务器端口 server: - port: 8900 + port: 18900 #数据源配置 #spring: diff --git a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/FactoryNodeEnums.java b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/FactoryNodeEnums.java new file mode 100644 index 000000000..a80f7bd95 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/FactoryNodeEnums.java @@ -0,0 +1,29 @@ +package com.logpm.factorydata.olo.enums; + +import lombok.Getter; +import org.springblade.common.model.IDict; + +/** + * 工厂节点枚举 + * + * @author zhaoqiaobo + * @create 2024-03-20 15:19 + */ +@Getter +public enum FactoryNodeEnums implements IDict { + + /** + * 配送装车 + */ + DISTRIBUTION_LOADING(270, "配送"), + /** + * 文员复核 + */ + CLERK_REVIEW(290, "签收"), + ; + + FactoryNodeEnums(Integer code, String text) { + init(code, text); + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/NodeMappingEnums.java b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/NodeMappingEnums.java new file mode 100644 index 000000000..5a7112254 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/NodeMappingEnums.java @@ -0,0 +1,62 @@ +package com.logpm.factorydata.olo.enums; + +import cn.hutool.core.util.ObjectUtil; +import lombok.Getter; +import org.springblade.common.constant.WorkNodeEnums; + +/** + * 系统和工厂节点映射枚举 + * + * @author zhaoqiaobo + * @create 2024-03-20 15:19 + */ +@Getter +public enum NodeMappingEnums { + + /** + * 已交接 + */ + DISTRIBUTION_LOADING(FactoryNodeEnums.DISTRIBUTION_LOADING, WorkNodeEnums.DISTRIBUTION_LOADING, 1), + /** + * 收货完成 + */ + CLERK_REVIEW(FactoryNodeEnums.CLERK_REVIEW, WorkNodeEnums.CLERK_REVIEW, 1); + + /** + * 系统作业节点 + */ + private WorkNodeEnums workNodeEnums; + /** + * 工厂作业节点 + */ + private FactoryNodeEnums factoryNodeEnums; + /** + * 状态码 + * 存在我们系统同一个作业节点对应工厂多个节点的情况,通过状态码区分 + */ + private Integer status; + + NodeMappingEnums(FactoryNodeEnums factoryNodeEnums, WorkNodeEnums workNodeEnums, Integer status) { + this.workNodeEnums = workNodeEnums; + this.factoryNodeEnums = factoryNodeEnums; + this.status = status; + } + + public static FactoryNodeEnums getFactoryByNodeAndStatus(WorkNodeEnums workNodeEnums) { + return getFactoryByNodeAndStatus(workNodeEnums, 1); + } + + public static FactoryNodeEnums getFactoryByNodeAndStatus(WorkNodeEnums workNodeEnums, Integer status) { + NodeMappingEnums[] values = values(); + for (NodeMappingEnums value : values) { + WorkNodeEnums workNodeEnums1 = value.getWorkNodeEnums(); + Integer status1 = value.getStatus(); + FactoryNodeEnums factoryNodeEnums = value.getFactoryNodeEnums(); + if (ObjectUtil.equal(workNodeEnums1, workNodeEnums) && ObjectUtil.equal(status1, status)) { + return factoryNodeEnums; + } + } + return null; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/NodeNeedEnums.java b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/NodeNeedEnums.java new file mode 100644 index 000000000..c795d0f2e --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/NodeNeedEnums.java @@ -0,0 +1,34 @@ +package com.logpm.factorydata.olo.enums; + +import lombok.Getter; + +import java.io.Serializable; + +/** + * 作业节点枚举 + * + * @author zhaoqiaobo + * @create 2024-03-20 15:19 + */ +@Getter +public enum NodeNeedEnums implements Serializable { + + /** + * 配送装车 + */ + DISTRIBUTION_LOADING(270, "配送装车"), + /** + * 文员复核 + */ + CLERK_REVIEW(290, "文员复核"), + ; + + private Integer code; + private String value; + + NodeNeedEnums(Integer code, String value) { + this.code = code; + this.value = value; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/FactoryOrderListener.java b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/FactoryOrderListener.java index 84a6d100f..6563cb5d5 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/FactoryOrderListener.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/FactoryOrderListener.java @@ -63,10 +63,6 @@ public class FactoryOrderListener { private final DeliveryNoteService deliveryNoteService; private final FactoryOrderLogService logService; - private final BladeRedis bladeRedis; - private final IFactoryDataBaseClient baseClient; - private final IFactoryDataClient factoryDataClient; - @RabbitListener(bindings = @QueueBinding( value = @Queue(name = FactoryDataConstants.Mq.Queues.OLO_FACTORY_ORDER), exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER, type = ExchangeTypes.TOPIC), @@ -164,7 +160,7 @@ public class FactoryOrderListener { if (CollUtil.isNotEmpty(entities)) { deliveryNoteService.saveBatch(entities); // 处理暂存单 - buildAdvance(entities); + deliveryNoteService.buildAdvance(entities); FactoryOrderLogEntity logEntity1 = new FactoryOrderLogEntity(); logEntity1.setSaxStatus(SaxStatusEnums.SUCCESS.getCode()); logEntity1.setId(logId); @@ -173,143 +169,4 @@ public class FactoryOrderListener { } } - @LogpmAsync("asyncExecutor") - public void buildAdvance(List vos) { - // 新起线程构建暂存单发送mq -// ThreadPoolUtil.getThreadPool().submit(() -> { - Long startWarehouseId = null; - String startWarehouseName = null; - String tenantId = null; - // 获取工厂基地绑定的始发仓信息 - R warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(BrandEnums.OLO.getValue(), BrandEnums.OLO.getValue()); - if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) { - FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData(); - if (ObjectUtil.isNotNull(data)) { - startWarehouseId = data.getWarehouseId(); - startWarehouseName = data.getWarehouseName(); - tenantId = data.getTenantId(); - } - } - Map> advanceMap = new HashMap<>(); - // 车次号 + 订单自编号 一个暂存单 - for (DeliveryNoteEntity detail : vos) { - String crmSo = detail.getCrmSo(); - String shipmentNumber = detail.getShipmentNo(); - String advanceKey = crmSo + shipmentNumber; - if (advanceMap.containsKey(advanceKey)) { - advanceMap.get(advanceKey).add(detail); - } else { - ArrayList orderPackageDTOS = new ArrayList<>(); - orderPackageDTOS.add(detail); - advanceMap.put(advanceKey, orderPackageDTOS); - } - } - // 组装暂存单数据 - List advances = new ArrayList<>(); - for (Map.Entry> stringListEntry : advanceMap.entrySet()) { - List value = stringListEntry.getValue(); - TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity(); - advanceEntity.setTenantId(tenantId); - advanceEntity.setStatus(0); - advanceEntity.setIsDeleted(0); - advanceEntity.setHasPackage(CollUtil.isNotEmpty(value) ? 1 : 0); - advanceEntity.setOrderType(""); - advanceEntity.setBrand(BrandEnums.OLO.getValue()); - advanceEntity.setSiteName(""); - advanceEntity.setArea(""); - advanceEntity.setTotalNum(CollUtil.isNotEmpty(value) ? value.size() : 0); - - advanceEntity.setPackCode(""); - advanceEntity.setWarehouseId(startWarehouseId); - advanceEntity.setWarehouseName(startWarehouseName); - - advanceEntity.setIsGcp(0); - advanceEntity.setSystemType("线上"); - advanceEntity.setMatingType("1"); - advanceEntity.setWaybillStatus("0"); - advanceEntity.setWaybillNo(""); - advanceEntity.setFreezeStatus("0"); - - List packageList = new ArrayList<>(); - for (DeliveryNoteEntity orderPackageDTO : value) { - advanceEntity.setPackName(orderPackageDTO.getSpace()); - advanceEntity.setCarrierName(orderPackageDTO.getCarrierName()); - advanceEntity.setSenderName(""); - advanceEntity.setSenderPhone(""); - advanceEntity.setSenderAddress(""); - advanceEntity.setTrainNumber(orderPackageDTO.getShipmentNo()); - advanceEntity.setSenderFactory(BrandEnums.OLO.getValue()); - advanceEntity.setOrderCode(orderPackageDTO.getCrmSo()); - advanceEntity.setDealerCode(orderPackageDTO.getCustomerCode()); - advanceEntity.setDealerName(orderPackageDTO.getCustomerName()); - advanceEntity.setStoreCode(orderPackageDTO.getCustomerCode()); - advanceEntity.setStoreName(orderPackageDTO.getCustomerName()); - advanceEntity.setServiceNum(orderPackageDTO.getShipmentSplitNo()); - advanceEntity.setCustomerName(orderPackageDTO.getEndingCustomer()); - advanceEntity.setCustomerPhone(orderPackageDTO.getEndingCustomerTel()); - advanceEntity.setCustomerAddress(orderPackageDTO.getZgkdz()); - - // 封装包件 - TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity(); - advanceDetailEntity.setWarehouseId(startWarehouseId); - advanceDetailEntity.setWarehouseName(startWarehouseName); -// advanceDetailEntity.setIncomingWarehouseId(0L); -// advanceDetailEntity.setIncomingWarehouseName(""); - // 根据志邦的一流单标识赋值 - advanceEntity.setLegacyStatus("0"); - if (StrUtil.contains(orderPackageDTO.getCrmSo(), "遗")) { - advanceEntity.setLegacyStatus("1"); - } - - advanceDetailEntity.setOrderCode(orderPackageDTO.getCrmSo()); - advanceDetailEntity.setBrand(BrandEnums.OLO.getValue()); - advanceDetailEntity.setSystemType("线上"); - advanceDetailEntity.setFirstPackName(orderPackageDTO.getMaterialCategory()); - // 获取映射志邦映射品类信息 - //二级品类名称 - advanceDetailEntity.setSecondPackName(orderPackageDTO.getMaterialCategory()); - //三级品类名称 - advanceDetailEntity.setThirdPackName(orderPackageDTO.getMaterialCategory()); - advanceDetailEntity.setMaterialName(orderPackageDTO.getMaterialCategory()); - - advanceDetailEntity.setSiteName(""); - advanceDetailEntity.setSiteCode(""); - advanceDetailEntity.setQuantity((StrUtil.isNotBlank(orderPackageDTO.getQty()) && NumberUtil.isNumber(orderPackageDTO.getQty())) ? Convert.toInt(orderPackageDTO.getQty()) : 0); - advanceDetailEntity.setOrderPackageCode(orderPackageDTO.getSn()); - advanceDetailEntity.setTrainNumber(orderPackageDTO.getShipmentNo()); - advanceDetailEntity.setServiceNum(orderPackageDTO.getShipmentSplitNo()); - advanceDetailEntity.setWaybillNo(""); - advanceDetailEntity.setPackageStatus("0"); - advanceDetailEntity.setWeight(StrUtil.isNotBlank(orderPackageDTO.getSnWeight()) ? new BigDecimal(orderPackageDTO.getSnWeight()) : BigDecimal.ZERO); - advanceDetailEntity.setVolume(StrUtil.isNotBlank(orderPackageDTO.getSnVolume()) ? new BigDecimal(orderPackageDTO.getSnVolume()) : BigDecimal.ZERO); -// advanceDetailEntity.setChargeType(0); - advanceDetailEntity.setSupple(""); - advanceDetailEntity.setManifest(""); - advanceDetailEntity.setReturnNum(""); - advanceDetailEntity.setSendDateStr(DateUtil.formatLocalDateTime(LocalDateTime.now())); - advanceDetailEntity.setCarNumber(""); - advanceDetailEntity.setGoodsMan(""); - advanceDetailEntity.setTenantId(tenantId); - advanceDetailEntity.setStatus(0); - advanceDetailEntity.setIsDeleted(0); - JSONObject entries = JSONUtil.parseObj(advanceDetailEntity); - packageList.add(entries); - } - // 转成json对象,然后将包件明细放到detail中 - JSONObject entries = JSONUtil.parseObj(advanceEntity); - entries.set("details", JSONUtil.toJsonStr(packageList)); - advances.add(entries); - } - // 将组装好的暂存单发送到 MQ ,由暂存单服务统一消费SendMsg. - if (CollUtil.isNotEmpty(advances)) { - for (JSONObject advance : advances) { - SendMsg sendMsg = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.ADVANCE_ORDER) - .routingKey(FactoryDataConstants.Mq.RoutingKeys.ADVANCE_ORDER).message(JSONUtil.toJsonStr(advance)).build(); - factoryDataClient.sendMessage(sendMsg); - } - } -// }); - } - - } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/NodeDataPushListener.java b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/NodeDataPushListener.java new file mode 100644 index 000000000..7495af8ed --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/mq/NodeDataPushListener.java @@ -0,0 +1,122 @@ +package com.logpm.factorydata.olo.mq; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.logpm.factorydata.feign.IFactoryDataClient; +import com.logpm.factorydata.olo.enums.FactoryNodeEnums; +import com.logpm.factorydata.olo.enums.NodeMappingEnums; +import com.logpm.factorydata.olo.enums.NodeNeedEnums; +import com.logpm.factorydata.vo.PushData; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.WorkNodeEnums; +import org.springblade.common.constant.factorydata.FactoryDataConstants; +import org.springframework.amqp.core.ExchangeTypes; +import org.springframework.amqp.rabbit.annotation.Exchange; +import org.springframework.amqp.rabbit.annotation.Queue; +import org.springframework.amqp.rabbit.annotation.QueueBinding; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 监听业务系统推送给节点数据 + * + * @author zhaoqiaobo + * @create 2024-03-18 0:02 + */ +@Slf4j +@Component +@AllArgsConstructor +public class NodeDataPushListener { + + private final IFactoryDataClient factoryDataClient; + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FactoryDataConstants.Mq.Queues.OLO_NODE_DATA_PUSH, durable = "true"), + exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH, type = ExchangeTypes.TOPIC), + key = FactoryDataConstants.Mq.RoutingKeys.OLO_NODE_DATA_PUSH + )) + public void nodeDataPush(String msg) { + log.info("zb接收到节点数据推送:{}", msg); + if (checkData(msg)) { + return; + } + JSONObject entries = JSONUtil.parseObj(msg); + // 节点 + String node = entries.getStr("node"); + WorkNodeEnums workNodeEnums = EnumUtil.fromString(WorkNodeEnums.class, node); + FactoryNodeEnums factoryNode = NodeMappingEnums.getFactoryByNodeAndStatus(workNodeEnums); + // 2 获取业务数据 + List content = entries.getBeanList("content", PushData.class); + // 按订单号和运单号进行分组 + if (CollUtil.isNotEmpty(content)) { + Map> sendMap = content.stream() + .collect(Collectors.groupingBy(data -> data.getOrderCode() + data.getWaybillNumber())); + for (Map.Entry> entry : sendMap.entrySet()) { + List pushDatas = entry.getValue(); + PushData pushData = pushDatas.get(0); + JSONObject js = new JSONObject(); + js.set("status", factoryNode.getText()); + js.set("opTime", DateUtil.now()); + js.set("content", factoryNode.getText()); + js.set("orderNo", pushData.getOrderCode()); + js.set("deliveryNo", pushData.getWaybillNumber()); + js.set("siteLevel", 3); + js.set("nodeName", pushData.getWarehouseName()); + js.set("receiveOrSend", 1); + js.set("shipmentSplitNo", ""); + js.set("receivable", 0); + js.set("receipts", 0); + js.set("shipmentNo", ""); + JSONArray snArray = new JSONArray(pushDatas.size()); + for (PushData data : pushDatas) { + JSONObject jsonObject = new JSONObject(); + jsonObject.set("sn", data.getPackageCode()); + jsonObject.set("qty", 1); + snArray.add(jsonObject); + } + js.set("snList", snArray); + log.info("推送节点数据:{}", js.toString()); +// HttpUtil.post("", js.toString()); + } + } + } + + private boolean checkData(String msg) { + if (StrUtil.isEmpty(msg)) { + return true; + } + if (!msg.contains("brand") || !msg.contains("content") || !msg.contains("node")) { + return true; + } + JSONObject entries = JSONUtil.parseObj(msg); + String node = entries.getStr("node"); + if (StrUtil.isEmpty(node)) { + return true; + } + // 不是志邦需要的节点数据直接不处理 + if (!EnumUtil.contains(NodeNeedEnums.class, node)) { + return true; + } + WorkNodeEnums workNodeEnums = EnumUtil.fromString(WorkNodeEnums.class, node); + if (ObjectUtil.isEmpty(workNodeEnums)) { + return true; + } + List content = entries.getBeanList("content", JSONObject.class); + if (CollUtil.isEmpty(content)) { + return true; + } + return false; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/service/DeliveryNoteService.java b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/service/DeliveryNoteService.java index c9417cefa..20f2177cc 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/service/DeliveryNoteService.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/service/DeliveryNoteService.java @@ -16,4 +16,5 @@ public interface DeliveryNoteService extends BaseService { String order(List vo); + void buildAdvance(List entities); } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/service/impl/DeliveryNoteServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/service/impl/DeliveryNoteServiceImpl.java index 1d72b9cdf..a79715f20 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/service/impl/DeliveryNoteServiceImpl.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/service/impl/DeliveryNoteServiceImpl.java @@ -1,7 +1,17 @@ package com.logpm.factorydata.olo.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.logpm.factorydata.base.feign.IFactoryDataBaseClient; +import com.logpm.factorydata.base.vo.FactoryWarehouseBindVO; +import com.logpm.factorydata.enums.BrandEnums; import com.logpm.factorydata.enums.SaxStatusEnums; import com.logpm.factorydata.feign.IFactoryDataClient; import com.logpm.factorydata.olo.entity.DeliveryNoteEntity; @@ -11,16 +21,21 @@ import com.logpm.factorydata.olo.service.DeliveryNoteService; import com.logpm.factorydata.olo.service.FactoryOrderLogService; import com.logpm.factorydata.olo.vo.DeliveryNoteVO; import com.logpm.factorydata.vo.SendMsg; +import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; +import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.io.IOUtils; import org.jetbrains.annotations.NotNull; +import org.springblade.common.annotations.LogpmAsync; +import org.springblade.common.constant.HttpConstants; import org.springblade.common.constant.factorydata.FactoryDataConstants; import org.springblade.common.utils.FileLogsUtil; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.oss.model.BladeFile; +import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.tool.api.R; import org.springblade.resource.feign.IOssClient; import org.springframework.amqp.rabbit.core.RabbitTemplate; @@ -32,8 +47,13 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile; import java.io.File; import java.io.InputStream; import java.io.OutputStream; +import java.math.BigDecimal; import java.nio.file.Files; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 发货单 业务实现类 @@ -49,7 +69,7 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl vo) { @@ -71,6 +91,143 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl vos) { + // 新起线程构建暂存单发送mq + Long startWarehouseId = null; + String startWarehouseName = null; + String tenantId = null; + // 获取工厂基地绑定的始发仓信息 + R warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(BrandEnums.OLO.getValue(), BrandEnums.OLO.getValue()); + if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) { + FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData(); + if (ObjectUtil.isNotNull(data)) { + startWarehouseId = data.getWarehouseId(); + startWarehouseName = data.getWarehouseName(); + tenantId = data.getTenantId(); + } + } + Map> advanceMap = new HashMap<>(); + // 车次号 + 订单自编号 一个暂存单 + for (DeliveryNoteEntity detail : vos) { + String crmSo = detail.getCrmSo(); + String shipmentNumber = detail.getShipmentNo(); + String advanceKey = crmSo + shipmentNumber; + if (advanceMap.containsKey(advanceKey)) { + advanceMap.get(advanceKey).add(detail); + } else { + ArrayList orderPackageDTOS = new ArrayList<>(); + orderPackageDTOS.add(detail); + advanceMap.put(advanceKey, orderPackageDTOS); + } + } + // 组装暂存单数据 + List advances = new ArrayList<>(); + for (Map.Entry> stringListEntry : advanceMap.entrySet()) { + List value = stringListEntry.getValue(); + TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity(); + advanceEntity.setTenantId(tenantId); + advanceEntity.setStatus(0); + advanceEntity.setIsDeleted(0); + advanceEntity.setHasPackage(CollUtil.isNotEmpty(value) ? 1 : 0); + advanceEntity.setOrderType(""); + advanceEntity.setBrand(BrandEnums.OLO.getValue()); + advanceEntity.setSiteName(""); + advanceEntity.setArea(""); + advanceEntity.setTotalNum(CollUtil.isNotEmpty(value) ? value.size() : 0); + + advanceEntity.setPackCode(""); + advanceEntity.setWarehouseId(startWarehouseId); + advanceEntity.setWarehouseName(startWarehouseName); + + advanceEntity.setIsGcp(0); + advanceEntity.setSystemType("线上"); + advanceEntity.setMatingType("1"); + advanceEntity.setWaybillStatus("0"); + advanceEntity.setWaybillNo(""); + advanceEntity.setFreezeStatus("0"); + + List packageList = new ArrayList<>(); + for (DeliveryNoteEntity orderPackageDTO : value) { + advanceEntity.setPackName(orderPackageDTO.getSpace()); + advanceEntity.setCarrierName(orderPackageDTO.getCarrierName()); + advanceEntity.setSenderName(""); + advanceEntity.setSenderPhone(""); + advanceEntity.setSenderAddress(""); + advanceEntity.setTrainNumber(orderPackageDTO.getShipmentNo()); + advanceEntity.setSenderFactory(BrandEnums.OLO.getValue()); + advanceEntity.setOrderCode(orderPackageDTO.getCrmSo()); + advanceEntity.setDealerCode(orderPackageDTO.getCustomerCode()); + advanceEntity.setDealerName(orderPackageDTO.getCustomerName()); + advanceEntity.setStoreCode(orderPackageDTO.getCustomerCode()); + advanceEntity.setStoreName(orderPackageDTO.getCustomerName()); + advanceEntity.setServiceNum(orderPackageDTO.getShipmentSplitNo()); + advanceEntity.setCustomerName(orderPackageDTO.getEndingCustomer()); + advanceEntity.setCustomerPhone(orderPackageDTO.getEndingCustomerTel()); + advanceEntity.setCustomerAddress(orderPackageDTO.getZgkdz()); + + // 封装包件 + TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity(); + advanceDetailEntity.setWarehouseId(startWarehouseId); + advanceDetailEntity.setWarehouseName(startWarehouseName); +// advanceDetailEntity.setIncomingWarehouseId(0L); +// advanceDetailEntity.setIncomingWarehouseName(""); + // 根据志邦的一流单标识赋值 + advanceEntity.setLegacyStatus("0"); + if (StrUtil.contains(orderPackageDTO.getCrmSo(), "遗")) { + advanceEntity.setLegacyStatus("1"); + } + + advanceDetailEntity.setOrderCode(orderPackageDTO.getCrmSo()); + advanceDetailEntity.setBrand(BrandEnums.OLO.getValue()); + advanceDetailEntity.setSystemType("线上"); + advanceDetailEntity.setFirstPackName(orderPackageDTO.getMaterialCategory()); + // 获取映射志邦映射品类信息 + //二级品类名称 + advanceDetailEntity.setSecondPackName(orderPackageDTO.getMaterialCategory()); + //三级品类名称 + advanceDetailEntity.setThirdPackName(orderPackageDTO.getMaterialCategory()); + advanceDetailEntity.setMaterialName(orderPackageDTO.getMaterialCategory()); + + advanceDetailEntity.setSiteName(""); + advanceDetailEntity.setSiteCode(""); + advanceDetailEntity.setQuantity((StrUtil.isNotBlank(orderPackageDTO.getQty()) && NumberUtil.isNumber(orderPackageDTO.getQty())) ? Convert.toInt(orderPackageDTO.getQty()) : 0); + advanceDetailEntity.setOrderPackageCode(orderPackageDTO.getSn()); + advanceDetailEntity.setTrainNumber(orderPackageDTO.getShipmentNo()); + advanceDetailEntity.setServiceNum(orderPackageDTO.getShipmentSplitNo()); + advanceDetailEntity.setWaybillNo(""); + advanceDetailEntity.setPackageStatus("0"); + advanceDetailEntity.setWeight(StrUtil.isNotBlank(orderPackageDTO.getSnWeight()) ? new BigDecimal(orderPackageDTO.getSnWeight()) : BigDecimal.ZERO); + advanceDetailEntity.setVolume(StrUtil.isNotBlank(orderPackageDTO.getSnVolume()) ? new BigDecimal(orderPackageDTO.getSnVolume()) : BigDecimal.ZERO); +// advanceDetailEntity.setChargeType(0); + advanceDetailEntity.setSupple(""); + advanceDetailEntity.setManifest(""); + advanceDetailEntity.setReturnNum(""); + advanceDetailEntity.setSendDateStr(DateUtil.formatLocalDateTime(LocalDateTime.now())); + advanceDetailEntity.setCarNumber(""); + advanceDetailEntity.setGoodsMan(""); + advanceDetailEntity.setTenantId(tenantId); + advanceDetailEntity.setStatus(0); + advanceDetailEntity.setIsDeleted(0); + JSONObject entries = JSONUtil.parseObj(advanceDetailEntity); + packageList.add(entries); + } + // 转成json对象,然后将包件明细放到detail中 + JSONObject entries = JSONUtil.parseObj(advanceEntity); + entries.set("details", JSONUtil.toJsonStr(packageList)); + advances.add(entries); + } + // 将组装好的暂存单发送到 MQ ,由暂存单服务统一消费SendMsg. + if (CollUtil.isNotEmpty(advances)) { + for (JSONObject advance : advances) { + SendMsg sendMsg = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.ADVANCE_ORDER) + .routingKey(FactoryDataConstants.Mq.RoutingKeys.ADVANCE_ORDER).message(JSONUtil.toJsonStr(advance)).build(); + factoryDataClient.sendMessage(sendMsg); + } + } + } + private String uploadFile(String body) { //文本内容和保存为本地文件 并上传 String logPath = FileLogsUtil.saveFileLogs(body); diff --git a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/controller/OrderController.java b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/controller/OrderController.java index c9047b0cb..61c59d625 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/controller/OrderController.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/controller/OrderController.java @@ -3,10 +3,12 @@ package com.logpm.factorydata.zbom.controller; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.factorydata.enums.SaxStatusEnums; import com.logpm.factorydata.feign.IFactoryDataClient; +import com.logpm.factorydata.vo.NodePushMsg; import com.logpm.factorydata.vo.SendMsg; import com.logpm.factorydata.zbom.constants.ZbomConstants; import com.logpm.factorydata.zbom.entity.FactoryLogEntity; @@ -94,7 +96,4 @@ public class OrderController { return ZbResp.success("成功"); } - - - } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 1ea2ef978..2ef432b89 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -30,6 +30,7 @@ import com.logpm.factorydata.enums.BrandEnums; import com.logpm.factorydata.feign.IFactoryDataClient; import com.logpm.factorydata.util.FactoryDataMessageSender; import com.logpm.factorydata.vo.NodePushMsg; +import com.logpm.factorydata.vo.PushData; import com.logpm.trunkline.bean.Resp; import com.logpm.trunkline.dto.*; import com.logpm.trunkline.entity.*; @@ -4194,9 +4195,13 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl contents = new ArrayList<>(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("packageCode", orderPackageCode); - contents.add(jsonObject); + PushData pushData = PushData.builder() + .packageCode(parcelListEntity.getOrderPackageCode()) + .waybillNumber(parcelListEntity.getWaybillNumber()) + .warehouseName(warehouseEntity.getName()) + .orderCode(parcelListEntity.getOrderCode()) + .build(); + contents.add(pushData); NodePushMsg msg = new NodePushMsg(); msg.setNode(WorkNodeEnums.CLERK_REVIEW); msg.setBrand(BrandEnums.getByValue(parcelListEntity.getBrandName())); @@ -4382,9 +4387,12 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl { if (ObjectUtil.isNotEmpty(parcelListEntity)) { List contents = new ArrayList<>(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("packageCode", parcelListEntity.getOrderPackageCode()); - contents.add(jsonObject); + PushData pushData = PushData.builder() + .packageCode(parcelListEntity.getOrderPackageCode()) + .orderCode(parcelListEntity.getOrderCode()) + .warehouseName(warehouseName) + .waybillNumber(parcelListEntity.getWaybillNumber()).build(); + contents.add(pushData); NodePushMsg msg = new NodePushMsg(); msg.setNode(WorkNodeEnums.CLERK_REVIEW); msg.setBrand(BrandEnums.getByValue(parcelListEntity.getBrandName())); @@ -5881,8 +5889,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl