Browse Source

Merge branch 'dev' into pre-production

visual
zhaoqiaobo 3 months ago
parent
commit
63ca51284a
  1. 129
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java
  2. 2
      blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportPackageBasicServiceImpl.java
  3. 2
      blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportPackageTrunklineServiceImpl.java

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

@ -3,11 +3,11 @@ 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;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.basicdata.entity.BasicdataFactoryCategoryEntity;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataFactoryCategoryClient;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
@ -20,7 +20,6 @@ import com.logpm.distribution.service.IDistributionParcelListService;
import com.logpm.distribution.service.IDistributionStockArticleService;
import com.logpm.distribution.service.IDistributionStockListService;
import com.logpm.distribution.service.IQualityDeliverService;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.feign.ITrunklineAdvanceDetailClient;
import com.logpm.warehouse.entity.WarehouseWayBillDetail;
import com.logpm.warehouse.entity.WarehouseWaybillEntity;
@ -32,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;
@ -81,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),
@ -99,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);
@ -117,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());
}
@ -194,11 +197,13 @@ public class QualityDeliverListener {
private void saveOrUpdate(LambdaQueryWrapper<QualityDeliverEntity> wrapper, QualityDeliverEntity qualityDeliverEntity) {
QualityDeliverEntity entity = null;
if (ObjectUtil.isNotEmpty(wrapper)) {
wrapper.select(QualityDeliverEntity::getId);
entity = qualityDeliverService.getOne(wrapper);
}
if (ObjectUtil.isNotEmpty(entity)) {
// 修改
qualityDeliverService.update(qualityDeliverEntity, wrapper);
qualityDeliverEntity.setId(entity.getId());
qualityDeliverService.updateById(qualityDeliverEntity);
} else {
// 新增
// 初始化基础数据
@ -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);
@ -262,24 +272,24 @@ public class QualityDeliverListener {
qualityDeliverEntity.setEndWarehouseInTime(stockList.getWarehousingTime());
}
// 品类
if (StrUtil.isNotEmpty(materielName) && StrUtil.isNotEmpty(brandName)) {
BasicdataFactoryCategoryEntity factoryCategoryEntity = new BasicdataFactoryCategoryEntity();
factoryCategoryEntity.setMaterielName(materielName);
factoryCategoryEntity.setBrand(brandName);
factoryCategoryEntity.setType(2);
BasicdataFactoryCategoryEntity categoryEntity = factoryCategoryClient.findEntityByBrandAndMaterielName(factoryCategoryEntity);
factoryCategoryEntity.setType(1);
BasicdataFactoryCategoryEntity categoryEntity1 = factoryCategoryClient.findEntityByBrandAndMaterielName(factoryCategoryEntity);
if (ObjectUtil.isNotEmpty(categoryEntity)) {
qualityDeliverEntity.setCostCategoryId(categoryEntity.getCategoryId());
qualityDeliverEntity.setCostCategory(categoryEntity.getCategory());
}
if (ObjectUtil.isNotEmpty(categoryEntity1)) {
qualityDeliverEntity.setRevenueCategory(categoryEntity.getCategory());
qualityDeliverEntity.setRevenueCategoryId(categoryEntity1.getCategoryId());
}
// TODO 从入库单上查询入库时间
}
// if (StrUtil.isNotEmpty(materielName) && StrUtil.isNotEmpty(brandName)) {
// BasicdataFactoryCategoryEntity factoryCategoryEntity = new BasicdataFactoryCategoryEntity();
// factoryCategoryEntity.setMaterielName(materielName);
// factoryCategoryEntity.setBrand(brandName);
// factoryCategoryEntity.setType(2);
// BasicdataFactoryCategoryEntity categoryEntity = factoryCategoryClient.findEntityByBrandAndMaterielName(factoryCategoryEntity);
// factoryCategoryEntity.setType(1);
// BasicdataFactoryCategoryEntity categoryEntity1 = factoryCategoryClient.findEntityByBrandAndMaterielName(factoryCategoryEntity);
// if (ObjectUtil.isNotEmpty(categoryEntity)) {
// qualityDeliverEntity.setCostCategoryId(categoryEntity.getCategoryId());
// qualityDeliverEntity.setCostCategory(categoryEntity.getCategory());
// }
// if (ObjectUtil.isNotEmpty(categoryEntity1)) {
// qualityDeliverEntity.setRevenueCategory(categoryEntity.getCategory());
// qualityDeliverEntity.setRevenueCategoryId(categoryEntity1.getCategoryId());
// }
// TODO 从入库单上查询入库时间
// }
}
}
@ -322,19 +332,19 @@ public class QualityDeliverListener {
buildWaybillInfo(qualityDeliverEntity, waybillNumber);
}
// 暂存单查询结算品类
TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailClient.findEntityByOrderPackageCode(qualityDeliverEntity.getOrderPackageCode());
if (ObjectUtil.isNotEmpty(advanceDetailEntity)) {
qualityDeliverEntity.setCostCategoryId(advanceDetailEntity.getCostCategoryId());
qualityDeliverEntity.setCostCategory(advanceDetailEntity.getCostCategoryName());
qualityDeliverEntity.setRevenueCategoryId(advanceDetailEntity.getIncomeCategoryId());
qualityDeliverEntity.setRevenueCategory(advanceDetailEntity.getIncomeCategoryName());
}
// TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailClient.findEntityByOrderPackageCode(qualityDeliverEntity.getOrderPackageCode());
// if (ObjectUtil.isNotEmpty(advanceDetailEntity)) {
// qualityDeliverEntity.setCostCategoryId(advanceDetailEntity.getCostCategoryId());
// qualityDeliverEntity.setCostCategory(advanceDetailEntity.getCostCategoryName());
// qualityDeliverEntity.setRevenueCategoryId(advanceDetailEntity.getIncomeCategoryId());
// qualityDeliverEntity.setRevenueCategory(advanceDetailEntity.getIncomeCategoryName());
// }
// 构建订单相关信息
buildOrderInfo(qualityDeliverEntity, qualityDeliverEntity.getWarehouseId(), qualityDeliverEntity.getOrderCode());
}
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;
}
}

2
blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportPackageBasicServiceImpl.java

@ -3,8 +3,8 @@ package com.logpm.report.service.impl;
import com.logpm.report.entity.ReportPackageBasicEntity;
import com.logpm.report.mapper.ReportPackageBasicMapper;
import com.logpm.report.service.IReportPackageBasicService;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

2
blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportPackageTrunklineServiceImpl.java

@ -3,8 +3,8 @@ package com.logpm.report.service.impl;
import com.logpm.report.entity.ReportPackageTrunklineEntity;
import com.logpm.report.mapper.ReportPackageTrunklineMapper;
import com.logpm.report.service.IReportPackageTrunklineService;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

Loading…
Cancel
Save