Browse Source

feat(all): 优化配送明细报表消费

1 增加公共的仓库,运单,订单查询缓存,提高消费效率
visual
zhaoqiaobo 3 months ago
parent
commit
985ab508f0
  1. 73
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java

73
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java

@ -3,6 +3,7 @@ package com.logpm.distribution.receiver.report;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -30,6 +31,7 @@ import org.jetbrains.annotations.Nullable;
import org.springblade.common.constant.report.ReportConstants;
import org.springblade.common.enums.BizOperationEnums;
import org.springblade.common.enums.PackageTypeEnums;
import org.springblade.core.redis.cache.BladeRedis;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
@ -79,6 +81,9 @@ public class QualityDeliverListener {
@Resource
private IWarehouseWaybillDetailClient waybillDetailClient;
@Resource
private BladeRedis redisCache;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = ReportConstants.REPORT_QUALITY_DELIVER_QUEUE, durable = "true"),
exchange = @Exchange(name = ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE, type = ExchangeTypes.TOPIC),
@ -97,9 +102,9 @@ public class QualityDeliverListener {
if (ObjectUtil.equals(PackageTypeEnums.CMP.getCode(), conditions)) {
// 定制品
LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery();
if(ObjectUtil.isNotEmpty(qualityDeliverEntity.getId())){
if (ObjectUtil.isNotEmpty(qualityDeliverEntity.getId())) {
wrapper.eq(QualityDeliverEntity::getId, qualityDeliverEntity.getId());
}else{
} else {
wrapper.eq(QualityDeliverEntity::getOrderPackageCode, qualityDeliverEntity.getOrderPackageCode());
}
wrapper.lt(QualityDeliverEntity::getBizStatus, 110);
@ -115,9 +120,9 @@ public class QualityDeliverListener {
} else if (ObjectUtil.equals(PackageTypeEnums.LTL.getCode(), conditions)) {
// 零担
LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery();
if(ObjectUtil.isNotEmpty(qualityDeliverEntity.getId())){
if (ObjectUtil.isNotEmpty(qualityDeliverEntity.getId())) {
wrapper.eq(QualityDeliverEntity::getId, qualityDeliverEntity.getId());
}else{
} else {
wrapper.eq(QualityDeliverEntity::getOrderCode, qualityDeliverEntity.getOrderCode())
.eq(QualityDeliverEntity::getCategory, qualityDeliverEntity.getCategory());
}
@ -214,7 +219,7 @@ public class QualityDeliverListener {
if (ObjectUtil.equals(PackageTypeEnums.CMP.getCode(), conditions)) {
// 订制品
// 构建订制品基础信息
DistributionParcelListEntity parcelListEntity = parcelListService.selectByOrderPackageCode(qualityDeliverEntity.getOrderPackageCode(), qualityDeliverEntity.getWarehouseId());
DistributionParcelListEntity parcelListEntity = getDistributionParcelListEntity(qualityDeliverEntity.getOrderPackageCode(), qualityDeliverEntity.getWarehouseId());
buildCmpBasicInfo(qualityDeliverEntity, parcelListEntity);
}
if (ObjectUtil.equals(PackageTypeEnums.INV.getCode(), conditions)) {
@ -236,6 +241,11 @@ public class QualityDeliverListener {
}
}
private DistributionParcelListEntity getDistributionParcelListEntity(String orderPackageCode, Long warehouseId) {
DistributionParcelListEntity parcelListEntity = parcelListService.selectByOrderPackageCode(orderPackageCode, warehouseId);
return parcelListEntity;
}
private void buildInvBasicInfo(QualityDeliverEntity qualityDeliverEntity) {
String materielName = qualityDeliverEntity.getMaterielName();
DistributionStockListEntity stockListEntity = new DistributionStockListEntity();
@ -249,7 +259,7 @@ public class QualityDeliverListener {
String brandName = stockList.getBrandName();
String sourceType = stockList.getSourceType();
if (StrUtil.equals(sourceType, "1")) {
DistributionParcelListEntity parcelListEntity = parcelListService.selectByOrderPackageCode(qualityDeliverEntity.getOrderPackageCode(), qualityDeliverEntity.getWarehouseId());
DistributionParcelListEntity parcelListEntity = getDistributionParcelListEntity(qualityDeliverEntity.getOrderPackageCode(), qualityDeliverEntity.getWarehouseId());
buildCmpBasicInfo(qualityDeliverEntity, parcelListEntity);
} else {
qualityDeliverEntity.setBrandName(brandName);
@ -334,7 +344,7 @@ public class QualityDeliverListener {
}
private void buildOrderInfo(QualityDeliverEntity qualityDeliverEntity, Long warehouseId, String orderCode) {
DistributionStockArticleEntity stockArticleEntity = stockArticleService.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
DistributionStockArticleEntity stockArticleEntity = getDistributionStockArticleEntity(warehouseId, orderCode);
if (ObjectUtil.isNotEmpty(stockArticleEntity)) {
// 客户信息
qualityDeliverEntity.setCustomName(stockArticleEntity.getCustomerName());
@ -356,9 +366,23 @@ public class QualityDeliverListener {
}
}
private DistributionStockArticleEntity getDistributionStockArticleEntity(Long warehouseId, String orderCode) {
String key = "report:qualityDeliver:stockArticle:" + warehouseId + "_" + orderCode;
String obj = redisCache.get(key);
if (StrUtil.isNotEmpty(obj)) {
return JSONUtil.toBean(obj, DistributionStockArticleEntity.class);
}
DistributionStockArticleEntity stockArticleEntity = stockArticleService.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
if (ObjectUtil.isNotEmpty(stockArticleEntity)) {
redisCache.setEx(key, JSONUtil.toJsonStr(stockArticleEntity), 60 * 60L + RandomUtil.randomInt(600));
return stockArticleEntity;
}
return null;
}
private void buildWaybillInfo(QualityDeliverEntity qualityDeliverEntity, String waybillNumber) {
if (StrUtil.isNotEmpty(waybillNumber)) {
WarehouseWaybillEntity byWaybillNo = warehouseWaybillClient.findByWaybillNo(waybillNumber);
WarehouseWaybillEntity byWaybillNo = getWarehouseWaybillEntity(waybillNumber);
if (ObjectUtil.isNotEmpty(byWaybillNo)) {
// 运单发货信息
qualityDeliverEntity.setShipperUnitId(byWaybillNo.getShipperId());
@ -380,14 +404,41 @@ public class QualityDeliverListener {
}
}
private WarehouseWaybillEntity getWarehouseWaybillEntity(String waybillNumber) {
String key = "report:qualityDeliver:waybill:" + waybillNumber;
String obj = redisCache.get(key);
if (StrUtil.isNotEmpty(obj)) {
return JSONUtil.toBean(obj, WarehouseWaybillEntity.class);
}
WarehouseWaybillEntity byWaybillNo = warehouseWaybillClient.findByWaybillNo(waybillNumber);
if (ObjectUtil.isNotEmpty(byWaybillNo)) {
redisCache.setEx(key, JSONUtil.toJsonStr(byWaybillNo), 60 * 60L + RandomUtil.randomInt(600));
return byWaybillNo;
}
return null;
}
private void warehouseInfo(QualityDeliverEntity qualityDeliverEntity) {
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.findWarehousesByIds(Arrays.asList(qualityDeliverEntity.getWarehouseId()));
if (CollUtil.isNotEmpty(warehouseEntities)) {
BasicdataWarehouseEntity warehouseEntity = warehouseEntities.get(0);
BasicdataWarehouseEntity warehouseEntity = getBasicdataWarehouseEntities(qualityDeliverEntity.getWarehouseId());
if (ObjectUtil.isNotEmpty(warehouseEntity)) {
// 事业线
qualityDeliverEntity.setBusinessUnit(warehouseEntity.getBusinessLine());
qualityDeliverEntity.setWarehousePosition(StrUtil.concat(true, Convert.toStr(warehouseEntity.getLongitude()), ",", Convert.toStr(warehouseEntity.getLatitude())));
}
}
public BasicdataWarehouseEntity getBasicdataWarehouseEntities(Long warehouseId) {
String key = "report:qualityDeliver:warehouse:" + warehouseId;
String obj = redisCache.get(key);
if (StrUtil.isNotEmpty(obj)) {
return JSONUtil.toBean(obj, BasicdataWarehouseEntity.class);
}
List<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.findWarehousesByIds(Arrays.asList(warehouseId));
if (CollUtil.isNotEmpty(warehouseEntities)) {
redisCache.setEx(key, JSONUtil.toJsonStr(warehouseEntities.get(0)), 60 * 60L + RandomUtil.randomInt(600));
return warehouseEntities.get(0);
}
return null;
}
}

Loading…
Cancel
Save