|
|
|
@ -6,7 +6,9 @@ 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; |
|
|
|
|
import com.logpm.distribution.dto.ReportQualityDeliverDTO; |
|
|
|
|
import com.logpm.distribution.entity.DistributionParcelListEntity; |
|
|
|
@ -23,6 +25,7 @@ import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
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.springframework.amqp.core.ExchangeTypes; |
|
|
|
|
import org.springframework.amqp.rabbit.annotation.Exchange; |
|
|
|
@ -64,6 +67,9 @@ public class QualityDeliverListener {
|
|
|
|
|
@Resource |
|
|
|
|
private IDistributionStockListService stockListService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private IBasicdataFactoryCategoryClient factoryCategoryClient; |
|
|
|
|
|
|
|
|
|
@RabbitListener(bindings = @QueueBinding( |
|
|
|
|
value = @Queue(name = ReportConstants.REPORT_QUALITY_DELIVER_QUEUE, durable = "true"), |
|
|
|
|
exchange = @Exchange(name = ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE, type = ExchangeTypes.TOPIC), |
|
|
|
@ -77,37 +83,39 @@ public class QualityDeliverListener {
|
|
|
|
|
ReportQualityDeliverDTO bean = JSONUtil.toBean(msg, ReportQualityDeliverDTO.class); |
|
|
|
|
String data = bean.getData(); |
|
|
|
|
QualityDeliverEntity qualityDeliverEntity = JSONUtil.toBean(data, QualityDeliverEntity.class); |
|
|
|
|
switch (bean.getOperation()) { |
|
|
|
|
case MODIFY: |
|
|
|
|
Integer conditions = qualityDeliverEntity.getConditions(); |
|
|
|
|
if (ObjectUtil.equals(PackageTypeEnums.CMP.getCode(), conditions)) { |
|
|
|
|
// 定制品
|
|
|
|
|
LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery() |
|
|
|
|
.eq(QualityDeliverEntity::getOrderPackageCode, qualityDeliverEntity.getOrderPackageCode()) |
|
|
|
|
.lt(QualityDeliverEntity::getBizStatus, 110); |
|
|
|
|
saveOrUpdate(wrapper, qualityDeliverEntity); |
|
|
|
|
} else if (ObjectUtil.equals(PackageTypeEnums.INV.getCode(), conditions)) { |
|
|
|
|
// 库存品
|
|
|
|
|
LambdaQueryWrapper<QualityDeliverEntity> wrapper = buildInvWrapper(qualityDeliverEntity); |
|
|
|
|
if (wrapper == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 查询不存在时更新,存在时修改
|
|
|
|
|
saveOrUpdate(wrapper, qualityDeliverEntity); |
|
|
|
|
} else if (ObjectUtil.equals(PackageTypeEnums.LTL.getCode(), conditions)) { |
|
|
|
|
// 零担
|
|
|
|
|
LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery() |
|
|
|
|
.eq(QualityDeliverEntity::getOrderCode, qualityDeliverEntity.getOrderCode()) |
|
|
|
|
.eq(QualityDeliverEntity::getCostCategory, qualityDeliverEntity.getCostCategory()) |
|
|
|
|
.lt(QualityDeliverEntity::getBizStatus, 110); |
|
|
|
|
if (StrUtil.isNotEmpty(qualityDeliverEntity.getPlanReservationCode())) { |
|
|
|
|
wrapper.eq(QualityDeliverEntity::getPlanReservationCode, qualityDeliverEntity.getPlanReservationCode()); |
|
|
|
|
} |
|
|
|
|
saveOrUpdate(wrapper, qualityDeliverEntity); |
|
|
|
|
Integer conditions = qualityDeliverEntity.getConditions(); |
|
|
|
|
if(ObjectUtil.equals(bean.getOperation(), BizOperationEnums.MODIFY)){ |
|
|
|
|
if (ObjectUtil.equals(PackageTypeEnums.CMP.getCode(), conditions)) { |
|
|
|
|
// 定制品
|
|
|
|
|
LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery() |
|
|
|
|
.eq(QualityDeliverEntity::getOrderPackageCode, qualityDeliverEntity.getOrderPackageCode()) |
|
|
|
|
.lt(QualityDeliverEntity::getBizStatus, 110); |
|
|
|
|
saveOrUpdate(wrapper, qualityDeliverEntity); |
|
|
|
|
} else if (ObjectUtil.equals(PackageTypeEnums.INV.getCode(), conditions)) { |
|
|
|
|
// 库存品
|
|
|
|
|
LambdaQueryWrapper<QualityDeliverEntity> wrapper = buildInvWrapper(qualityDeliverEntity); |
|
|
|
|
if (wrapper == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
return; |
|
|
|
|
// 查询不存在时更新,存在时修改
|
|
|
|
|
saveOrUpdate(wrapper, qualityDeliverEntity); |
|
|
|
|
} else if (ObjectUtil.equals(PackageTypeEnums.LTL.getCode(), conditions)) { |
|
|
|
|
// 零担
|
|
|
|
|
LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery() |
|
|
|
|
.eq(QualityDeliverEntity::getOrderCode, qualityDeliverEntity.getOrderCode()) |
|
|
|
|
.eq(QualityDeliverEntity::getCostCategory, qualityDeliverEntity.getCostCategory()) |
|
|
|
|
.lt(QualityDeliverEntity::getBizStatus, 110); |
|
|
|
|
if (StrUtil.isNotEmpty(qualityDeliverEntity.getPlanReservationCode())) { |
|
|
|
|
wrapper.eq(QualityDeliverEntity::getPlanReservationCode, qualityDeliverEntity.getPlanReservationCode()); |
|
|
|
|
} |
|
|
|
|
saveOrUpdate(wrapper, qualityDeliverEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(ObjectUtil.equals(bean.getOperation(), BizOperationEnums.ADD)){ |
|
|
|
|
if (ObjectUtil.equals(PackageTypeEnums.INV.getCode(), conditions)) { |
|
|
|
|
// 查询不存在时更新,存在时修改
|
|
|
|
|
saveOrUpdate(null, qualityDeliverEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -165,7 +173,10 @@ public class QualityDeliverListener {
|
|
|
|
|
* @Author zqb 2024/9/10 |
|
|
|
|
**/ |
|
|
|
|
private void saveOrUpdate(LambdaQueryWrapper<QualityDeliverEntity> wrapper, QualityDeliverEntity qualityDeliverEntity) { |
|
|
|
|
QualityDeliverEntity entity = qualityDeliverService.getOne(wrapper); |
|
|
|
|
QualityDeliverEntity entity = null; |
|
|
|
|
if (ObjectUtil.isNotEmpty(wrapper)) { |
|
|
|
|
entity = qualityDeliverService.getOne(wrapper); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(entity)) { |
|
|
|
|
// 修改
|
|
|
|
|
qualityDeliverService.update(qualityDeliverEntity, wrapper); |
|
|
|
@ -197,25 +208,41 @@ public class QualityDeliverListener {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void buildInvBasicInfo(QualityDeliverEntity qualityDeliverEntity) { |
|
|
|
|
String materielName = qualityDeliverEntity.getMaterielName(); |
|
|
|
|
DistributionStockListEntity stockListEntity = new DistributionStockListEntity(); |
|
|
|
|
stockListEntity.setIncomingBatch(qualityDeliverEntity.getIncomingBatch()); |
|
|
|
|
stockListEntity.setMallName(qualityDeliverEntity.getMallName()); |
|
|
|
|
stockListEntity.setCargoNumber((qualityDeliverEntity.getMaterielCode())); |
|
|
|
|
stockListEntity.setDescriptionGoods(qualityDeliverEntity.getMaterielName()); |
|
|
|
|
stockListEntity.setDescriptionGoods(materielName); |
|
|
|
|
stockListEntity.setWarehouseId(qualityDeliverEntity.getWarehouseId()); |
|
|
|
|
DistributionStockListEntity stockList = stockListService.findStockListByAttrAndWarehouseId(stockListEntity); |
|
|
|
|
if (ObjectUtil.isNotEmpty(stockList)) { |
|
|
|
|
String brandName = stockList.getBrandName(); |
|
|
|
|
String sourceType = stockList.getSourceType(); |
|
|
|
|
if (StrUtil.equals(sourceType, "1")) { |
|
|
|
|
buildCmpBasicInfo(qualityDeliverEntity); |
|
|
|
|
} else { |
|
|
|
|
qualityDeliverEntity.setBrandName(stockList.getBrandName()); |
|
|
|
|
qualityDeliverEntity.setBrandName(brandName); |
|
|
|
|
qualityDeliverEntity.setMallCode(stockList.getMarketCode()); |
|
|
|
|
qualityDeliverEntity.setStoreCode(stockList.getStoreCode()); |
|
|
|
|
qualityDeliverEntity.setStoreName(stockList.getStoreName()); |
|
|
|
|
qualityDeliverEntity.setEndWarehouseInTime(stockList.getWarehousingTime()); |
|
|
|
|
} |
|
|
|
|
// 品类
|
|
|
|
|
if(StrUtil.isNotEmpty(materielName) && StrUtil.isNotEmpty(brandName)){ |
|
|
|
|
BasicdataFactoryCategoryEntity factoryCategoryEntity = new BasicdataFactoryCategoryEntity(); |
|
|
|
|
factoryCategoryEntity.setMaterielName(materielName); |
|
|
|
|
factoryCategoryEntity.setBrand(brandName); |
|
|
|
|
BasicdataFactoryCategoryEntity categoryEntity = factoryCategoryClient.findEntityByMaterielName(factoryCategoryEntity); |
|
|
|
|
if(ObjectUtil.isNotEmpty(categoryEntity)){ |
|
|
|
|
// TODO 存id
|
|
|
|
|
qualityDeliverEntity.setCostCategory(categoryEntity.getCategory()); |
|
|
|
|
qualityDeliverEntity.setRevenueCategory(categoryEntity.getCategory()); |
|
|
|
|
} |
|
|
|
|
// TODO 从入库单上查询入库时间
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void buildCmpBasicInfo(QualityDeliverEntity qualityDeliverEntity) { |
|
|
|
@ -269,7 +296,7 @@ public class QualityDeliverListener {
|
|
|
|
|
qualityDeliverEntity.setCustomAddress(stockArticleEntity.getCustomerAddress()); |
|
|
|
|
// 商场信息
|
|
|
|
|
qualityDeliverEntity.setMallName(stockArticleEntity.getMallName()); |
|
|
|
|
qualityDeliverEntity.setMallCode(stockArticleEntity.getMallName()); |
|
|
|
|
qualityDeliverEntity.setMallCode(stockArticleEntity.getMallCode()); |
|
|
|
|
// 服务号
|
|
|
|
|
qualityDeliverEntity.setServiceNumber(stockArticleEntity.getServiceNumber()); |
|
|
|
|
// 经销商信息
|
|
|
|
|