From ac9e8811c7a57fe9ff87b5ed64acbdfdc780241f Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 4 Jun 2024 17:20:45 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9B=B4=E6=96=B0=E6=89=98=E7=9B=98=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E5=BA=93=E4=BD=8D=E6=95=B0=E6=8D=AE=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IDistributionStockArticleClient.java | 5 + .../feign/DistributionStockArticleClient.java | 20 +++ .../mapper/DistributionParcelListMapper.java | 2 + .../mapper/DistributionParcelListMapper.xml | 10 ++ .../DistributionStockArticleMapper.java | 3 + .../mapper/DistributionStockArticleMapper.xml | 11 ++ .../IDistributionParcelListService.java | 2 + .../IDistributionStockArticleService.java | 5 +- .../DistributionParcelListServiceImpl.java | 19 +-- .../DistributionStockArticleServiceImpl.java | 12 ++ .../DistrilbutionBillLadingServiceImpl.java | 8 +- .../mapper/WarehouseTrayTypeMapper.java | 2 + .../mapper/WarehouseTrayTypeMapper.xml | 8 ++ .../impl/WarehouseTrayTypeServiceImpl.java | 4 +- .../impl/WarehouseUpdownTypeServiceImpl.java | 120 ++++++++---------- 15 files changed, 149 insertions(+), 82 deletions(-) diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java index fd7ec1c6f..2d1721a6f 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java @@ -183,4 +183,9 @@ public interface IDistributionStockArticleClient { @PostMapping(value = API_PREFIX + "/addReturnList",consumes = MediaType.APPLICATION_JSON_VALUE) List addReturnList(@RequestBody List addStockArticleEntities); + @PostMapping(value = API_PREFIX + "/findOrderTotalNumByOrderCodes",consumes = MediaType.APPLICATION_JSON_VALUE) + Integer findOrderTotalNumByOrderCodes(@RequestBody JSONObject jsonObject); + + @PostMapping(value = API_PREFIX + "/findOrderTotalNumByOrderPackageCodes",consumes = MediaType.APPLICATION_JSON_VALUE) + Integer findOrderTotalNumByOrderPackageCodes(@RequestBody JSONObject jsonObject); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java index 9a8347a70..b2a919421 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java @@ -16,6 +16,7 @@ */ package com.logpm.distribution.feign; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -350,4 +351,23 @@ public class DistributionStockArticleClient implements IDistributionStockArticle return addStockArticleEntities; } + @Override + public Integer findOrderTotalNumByOrderCodes(JSONObject jsonObject) { + JSONArray jsonArray = jsonObject.getJSONArray("orderCodes"); + List orderCodes = jsonArray.toJavaList(String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + + return distributionStockArticleService.findOrderTotalNumByOrderCodes(orderCodes,warehouseId); + } + + @Override + public Integer findOrderTotalNumByOrderPackageCodes(JSONObject jsonObject) { + JSONArray jsonArray = jsonObject.getJSONArray("orderPackageCodes"); + List orderPackageCodes = jsonArray.toJavaList(String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + + + return distributionStockArticleService.findOrderTotalNumByOrderPackageCodes(orderPackageCodes,warehouseId); + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java index df28d3560..8a7ad57de 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java @@ -279,4 +279,6 @@ public interface DistributionParcelListMapper extends BaseMapper> findPackageCodeByCodes(@Param("keySet") Set keySet); List findALLNoUpShelfPackageByOrderCodeList(@Param("orderCodeList") List orderCodeList, @Param("warehouseId") Long warehouseId); + + List findOrderCodesByOrderPackageCodes(@Param("orderPackageCodes") List orderPackageCodes, @Param("warehouseId") Long warehouseId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml index ca5ed687a..1648b6219 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml @@ -1783,5 +1783,15 @@ and lwug.id is null + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java index eb551af1c..adff2343c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java @@ -199,4 +199,7 @@ public interface DistributionStockArticleMapper extends BaseMapper orderCodes,@Param("warehouseId") Long warehouseId); + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml index e240d4576..2015edc33 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml @@ -1428,4 +1428,15 @@ + + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java index 5d834e357..facf16eed 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java @@ -244,4 +244,6 @@ public interface IDistributionParcelListService extends BaseService> findPackageCodeByCodes(Set keySet); List findALLNoUpShelfPackageByOrderCodeList(List orderCodeList, Long warehouseId); + + List findOrderCodesByOrderPackageCodes(List orderPackageCodes, Long warehouseId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java index c935b13c8..8ed82bd3e 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java @@ -28,7 +28,6 @@ import com.logpm.distribution.vo.app.queryOrderVO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; -import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -288,4 +287,8 @@ public interface IDistributionStockArticleService extends BaseService orderCodes,Long warehouseId); + + Integer findOrderTotalNumByOrderPackageCodes(List orderPackageCodes, Long warehouseId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java index 3fa109637..8c553e927 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java @@ -43,13 +43,7 @@ import com.logpm.distribution.entity.DistrilbutionBillPackageEntity; import com.logpm.distribution.excel.DistributionParcelListExcel; import com.logpm.distribution.mapper.DistributionParcelListMapper; import com.logpm.distribution.mapper.DistributionStockArticleMapper; -import com.logpm.distribution.service.IDistributionParcelDetailsService; -import com.logpm.distribution.service.IDistributionParcelListService; -import com.logpm.distribution.service.IDistributionParcelNumberService; -import com.logpm.distribution.service.IDistributionReservationZeroPackageService; -import com.logpm.distribution.service.IDistributionStockListInfoService; -import com.logpm.distribution.service.IDistributionStockListService; -import com.logpm.distribution.service.IDistrilbutionBillPackageService; +import com.logpm.distribution.service.*; import com.logpm.distribution.vo.DistributionParcelListBaseVO; import com.logpm.distribution.vo.DistributionParcelListNodeVO; import com.logpm.distribution.vo.DistributionParcelListVO; @@ -82,6 +76,7 @@ import org.springblade.system.feign.IUserClient; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -132,6 +127,9 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl findOrderCodesByOrderPackageCodes(List orderPackageCodes, Long warehouseId) { + return baseMapper.findOrderCodesByOrderPackageCodes(orderPackageCodes,warehouseId); + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java index 12c95a71c..db116ef98 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java @@ -2698,6 +2698,18 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl orderCodes,Long warehouseId) { + return baseMapper.findOrderTotalNumByOrderCodes(orderCodes,warehouseId); + } + + @Override + public Integer findOrderTotalNumByOrderPackageCodes(List orderPackageCodes, Long warehouseId) { + List orderCodes = distributionParcelListService.findOrderCodesByOrderPackageCodes(orderPackageCodes,warehouseId); + + return baseMapper.findOrderTotalNumByOrderCodes(orderCodes,warehouseId); + } + @Override public R findEditCustomerLog(Long orderId) { 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 0916a99f2..d94e0bbe9 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 @@ -3157,10 +3157,10 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl - List distributionStockArticleEntityList = distributionStockArticleService.list(Wrappers.query().lambda() - .in(DistributionStockArticleEntity::getId, ls) - .ne(DistributionStockArticleEntity::getIsZero, "1") - ); + List distributionStockArticleEntityList = distributionStockArticleService.list(Wrappers.query().lambda() + .in(DistributionStockArticleEntity::getId, ls) + .ne(DistributionStockArticleEntity::getIsZero, "1") + ); List list1 = distributionParcelListService.list(Wrappers.query().lambda() .in(DistributionParcelListEntity::getStockArticleId, ls) diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayTypeMapper.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayTypeMapper.java index 14c791fab..36c9f5c62 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayTypeMapper.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayTypeMapper.java @@ -43,4 +43,6 @@ public interface WarehouseTrayTypeMapper extends BaseMapper + + update logpm_warehouse_tray_type + set total_num = #{enterNum}, + order_total_num = #{orderTotalNum}, + stock_num = #{enterNum}, + stock_total_num = #{orderTotalNum} + where id = #{trayTypeId} + diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java index 256356b4e..3be4ea2a1 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java @@ -1155,14 +1155,14 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("updown_type_id", updownTypeId); List list = warehouseUpdownGoodsService.list(queryWrapper); - Set set = new TreeSet<>(); - Integer totalNum = 0; - Integer orderTotalNum = 0; - Integer stockNum = 0; - Integer stockTotalNum = 0; - for (WarehouseUpdownGoodsEntity updownGoodsEntity : list) { - String associationType = updownGoodsEntity.getAssociationType(); - Long associationId = updownGoodsEntity.getAssociationId(); - String associationValue = updownGoodsEntity.getAssociationValue(); - Long marketId = updownGoodsEntity.getMarketId(); - Integer num = updownGoodsEntity.getNum(); - String incomingBatch = updownGoodsEntity.getIncomingBatch(); - if ("1".equals(associationType)) { - //零担订单数据 - String orderCode = associationValue; - DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); - Integer totalNumber = stockArticleEntity.getTotalNumber(); - if (!set.contains(associationValue)) { - set.add(orderCode); - orderTotalNum = orderTotalNum + totalNumber; - } - totalNum = totalNum + num; - } else if ("3".equals(associationType)) { - DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(associationValue, warehouseId); - String orderCode = parcelListEntity.getOrderCode(); - DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); - Integer totalNumber = stockArticleEntity.getTotalNumber(); - if (!set.contains(orderCode)) { - set.add(orderCode); - orderTotalNum = orderTotalNum + totalNumber; - } - totalNum = totalNum + num; - } else if ("4".equals(associationType)) { - DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(marketId, associationValue, incomingBatch, warehouseId); - Integer quantityStock = stockListEntity.getQuantityStock(); - stockNum = stockNum + num; - stockTotalNum = stockTotalNum + quantityStock; - } - } - baseMapper.updateNumByUpdownTypeId(orderTotalNum, totalNum, stockNum, stockTotalNum, updownTypeId); + AtomicReference totalNum = new AtomicReference<>(0); + AtomicReference orderTotalNum = new AtomicReference<>(0); + AtomicReference stockNum = new AtomicReference<>(0); + AtomicReference stockTotalNum = new AtomicReference<>(0); -// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCode(orderCode); -// if(Objects.isNull(stockArticleEntity)){ -// log.warn("##############updateUpdownTypeNumPackage: 订单信息不存在 orderCode={}",orderCode); -// throw new CustomerException(403,"订单信息不存在"); -// } -// Integer orderTotalNumber = stockArticleEntity.getTotalNumber(); -// //查询该订单在该上架方式下的包件还有几条数据 -// List ls = warehouseUpdownGoodsService.findListByUpdownTypeIdAndOrderCode(updownTypeId,orderCode); -// int size = ls.size(); -// if("1".equals(addStatus)){ -// if(size==0){ -// baseMapper.updateOrderTotalNumAndTotalNum(updownTypeId,orderTotalNumber,quantity); -// }else{ -// baseMapper.updateTotalNum(updownTypeId,quantity); -// } -// }else if("2".equals(addStatus)){ -// if(size==0){ -// log.warn("##############updateUpdownTypeNumPackage: 数据格式问题 updownTypeId={} orderCode={}",updownTypeId,orderCode); -// throw new CustomerException(403,"数据格式问题"); -// }else if(size > 1){ -// //如果库中有至少2条数据,那么去掉一条也不会影响改订单的总数变化,所以只减去包件的数量 -// baseMapper.updateTotalNum(updownTypeId,-quantity); -// }else{ -// //如果库中有至少2条数据,那么去掉一条也不会影响改订单的总数变化,所以只减去包件的数量 -// baseMapper.updateOrderTotalNumAndTotalNum(updownTypeId,-orderTotalNumber,-quantity); -// } -// } + // 使用Java Stream对list按associationType字段进行分组 + Map> groupedByAssociationType = list.stream() + .collect(Collectors.groupingBy(WarehouseUpdownGoodsEntity::getAssociationType)); + + groupedByAssociationType.keySet().forEach(associationType -> { + List updownGoodsEntities = groupedByAssociationType.get(associationType); + + //统计updownGoodsEntities中所有元素的num之和 + Integer total = updownGoodsEntities.stream() + .mapToInt(WarehouseUpdownGoodsEntity::getNum) + .sum(); + //把updownGoodsEntities中所有元素的associationValue放入一个List中 + List associationValues = updownGoodsEntities.stream() + .map(WarehouseUpdownGoodsEntity::getAssociationValue) + .collect(Collectors.toList()); + + if ("1".equals(associationType)) { + //零担 + //获取所有 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("orderCodes",associationValues); + jsonObject.put("warehouseId",warehouseId); + Integer orderTotal = distributionStockArticleClient.findOrderTotalNumByOrderCodes(jsonObject); + + totalNum.set(totalNum.get()+total); + orderTotalNum.set(orderTotalNum.get()+orderTotal); + + }else if ("3".equals(associationType)){ + //订制品 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("orderPackageCodes",associationValues); + jsonObject.put("warehouseId",warehouseId); + Integer orderTotal = distributionStockArticleClient.findOrderTotalNumByOrderPackageCodes(jsonObject); + + totalNum.set(totalNum.get()+total); + orderTotalNum.set(orderTotalNum.get()+orderTotal); + + }else if ("4".equals(associationType)){ + //无数据库存品 + updownGoodsEntities.forEach(updownGoodsEntity -> { + DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(updownGoodsEntity.getMarketId(), updownGoodsEntity.getAssociationValue(), updownGoodsEntity.getIncomingBatch(), warehouseId); + Integer quantityStock = stockListEntity.getQuantityStock(); + stockTotalNum.set(stockTotalNum.get() + quantityStock); + }); + stockNum.set(stockNum.get() + total); + } + }); + baseMapper.updateNumByUpdownTypeId(orderTotalNum.get(), totalNum.get(), stockNum.get(), stockTotalNum.get(), updownTypeId); } /**