From 217cca747fcebc9febe06aec4fb2c45fdfbd1b21 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Mon, 24 Jun 2024 09:12:36 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E9=A6=96=E9=A1=B5=E5=BA=93?= =?UTF-8?q?=E5=86=85=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3=202.=E5=BA=93?= =?UTF-8?q?=E5=86=85=E6=95=B0=E6=8D=AE=E4=BD=9C=E4=B8=9A=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=8C=85=E4=BB=B6=E4=B8=8A=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/broadcast/FanoutConstants.java | 98 ++ .../springblade/common/utils/CommonUtil.java | 28 + .../feign/IDistributionParcelListClient.java | 1 + .../config/RabbitMqConfiguration.java | 10 +- .../mapper/DistributionParcelListMapper.java | 8 + .../mapper/DistributionParcelListMapper.xml | 45 + .../DistributionStockArticleMapper.java | 5 + .../mapper/DistributionStockArticleMapper.xml | 18 + .../DistributionStockListInfoMapper.java | 4 + .../DistributionStockListInfoMapper.xml | 30 + .../mapper/DistributionStockListMapper.java | 4 + .../mapper/DistributionStockListMapper.xml | 18 + .../WarehouseTrayAllocationListener.java | 1275 +++++++++++++++++ .../IDistributionParcelListService.java | 8 + .../IDistributionStockArticleService.java | 4 + .../IDistributionStockListInfoService.java | 4 + .../IDistributionStockListService.java | 5 + .../DistributionParcelListServiceImpl.java | 20 + .../DistributionStockArticleServiceImpl.java | 10 + .../DistributionStockListInfoServiceImpl.java | 11 +- .../DistributionStockListServiceImpl.java | 10 + .../controller/WarehouseIndexController.java | 272 ++++ .../java/com/logpm/report/dto/IndexDTO.java | 16 + .../report/mapper/WarehouseIndexMapper.java | 42 + .../report/mapper/WarehouseIndexMapper.xml | 204 +++ .../service/IWarehouseIndexService.java | 21 + .../impl/WarehouseIndexServiceImpl.java | 239 +++ .../report/vo/IndexAllocationDataVO.java | 16 + .../logpm/report/vo/IndexHandOrderDataVO.java | 18 + .../logpm/report/vo/IndexOpenOrderDataVO.java | 15 + .../report/vo/IndexOpenOrderIncomeVO.java | 26 + .../report/vo/IndexTrunklineCarsDataVO.java | 16 + .../vo/IndexTrunklineHandOrderDataVO.java | 16 + .../report/vo/IndexUnloadAbnormalDataVO.java | 21 + .../impl/TrunklineCarsLoadLogServiceImpl.java | 47 +- .../impl/TrunklineCarsLoadServiceImpl.java | 4 + .../mapper/WarehouseWaybillMapper.java | 1 + .../warehouse/service/ISendFanoutService.java | 7 + .../service/IWarehouseWaybillService.java | 1 + .../service/impl/SendFanoutServiceImpl.java | 27 + .../impl/WarehouseTrayTypeServiceImpl.java | 778 +++++++++- .../impl/WarehouseUpdownGoodsServiceImpl.java | 2 +- .../impl/WarehouseUpdownTypeServiceImpl.java | 715 ++++++++- .../impl/WarehouseWaybillServiceImpl.java | 6 +- 44 files changed, 3977 insertions(+), 149 deletions(-) create mode 100644 blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/WarehouseTrayAllocationListener.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/controller/WarehouseIndexController.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/dto/IndexDTO.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/WarehouseIndexServiceImpl.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexAllocationDataVO.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexHandOrderDataVO.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexOpenOrderDataVO.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexOpenOrderIncomeVO.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexTrunklineCarsDataVO.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexTrunklineHandOrderDataVO.java create mode 100644 blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexUnloadAbnormalDataVO.java create mode 100644 blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/ISendFanoutService.java create mode 100644 blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/SendFanoutServiceImpl.java diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java b/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java index 49789924d..5b55e50c2 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java @@ -55,4 +55,102 @@ public abstract class FanoutConstants { } + + //仓库 + public interface warehouse { + + + //打托 + interface TRAYTYPE{ + + //交换机 + String EXCHANGE = "fanout.warehouse.traytype" + ModuleNameConstant.DEVAUTH; + + interface QUEUE { + + String TRAYTYPE_MESSAGE = "fanout.warehouse.traytype.distribution.traytypemessage" + ModuleNameConstant.DEVAUTH; + + } + + } + + +// //解托 +// interface UNBINDTRAY{ +// +// //交换机 +// String EXCHANGE = "fanout.warehouse.unbindtray" + ModuleNameConstant.DEVAUTH; +// +// interface QUEUE { +// +// String UNBINDTRAY_INFO = "fanout.warehouse.unbindtray.distribution.unbindtrayINFO" + ModuleNameConstant.DEVAUTH; +// +// } +// +// } +// +// +// //移托 +// interface MOVETRAY{ +// +// //交换机 +// String EXCHANGE = "fanout.warehouse.movetray" + ModuleNameConstant.DEVAUTH; +// +// interface QUEUE { +// +// String MOVETRAY_INFO = "fanout.warehouse.movetray.distribution.movetrayInfo" + ModuleNameConstant.DEVAUTH; +// +// } +// +// } + + + + //上架 + interface ALLOCATION{ + + //交换机 + String EXCHANGE = "fanout.warehouse.upshelf" + ModuleNameConstant.DEVAUTH; + + interface QUEUE { + + String ALLOCATION_MESSAGE = "fanout.warehouse.upshelf.distribution.allocationmessage" + ModuleNameConstant.DEVAUTH; + + } + + } + + +// //下架 +// interface DOWNSHELF{ +// +// //交换机 +// String EXCHANGE = "fanout.warehouse.downshelf" + ModuleNameConstant.DEVAUTH; +// +// interface QUEUE { +// +// String DOWNSHELF_INFO = "fanout.warehouse.downshelf.distribution.downshelfInfo" + ModuleNameConstant.DEVAUTH; +// +// } +// +// } +// +// +// //移库 +// interface MOVEALLOCATION{ +// +// //交换机 +// String EXCHANGE = "fanout.warehouse.moveallocation" + ModuleNameConstant.DEVAUTH; +// +// interface QUEUE { +// +// String MOVEALLOCATION_INFO = "fanout.warehouse.moveallocation.distribution.moveallocationInfo" + ModuleNameConstant.DEVAUTH; +// +// } +// +// } + + + } + } diff --git a/blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java b/blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java index 0d61ecfc8..ca8a9aca4 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java +++ b/blade-biz-common/src/main/java/org/springblade/common/utils/CommonUtil.java @@ -172,6 +172,17 @@ public class CommonUtil { return null; } + public static Date getDayStart(){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + // 将时分秒,毫秒域清零 + calendar.set(Calendar.HOUR_OF_DAY, 23); + calendar.set(Calendar.MINUTE, 59); + calendar.set(Calendar.SECOND, 59); + calendar.set(Calendar.MILLISECOND, 999); + return calendar.getTime(); + } + public static Date getDayEnd(){ Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); @@ -183,6 +194,23 @@ public class CommonUtil { return calendar.getTime(); } + public static Date getMonthDayStart(){ + //获取一个Calendar对象 + Calendar cal = Calendar.getInstance(); + //获取当前时间 + cal.setTime(new Date()); + //获取当前月 + cal.add(Calendar.MONTH, 0); + //获取当前月的最后一天 + cal.set(Calendar.DAY_OF_MONTH, 1); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + //得到当前月的最后一天 + Date preMonth=cal.getTime(); + return preMonth; + } public static Date getMonthDayEnd(){ //获取一个Calendar对象 Calendar cal = Calendar.getInstance(); diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java index 47f8b030e..6447f73b6 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java @@ -198,4 +198,5 @@ public interface IDistributionParcelListClient { @PostMapping(API_PREFIX + "/findALLNoUpShelfPackageByOrderCodeList") List findALLNoUpShelfPackageByOrderCodeList(@RequestBody FindParamterDTO findParamterDTO); + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/RabbitMqConfiguration.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/RabbitMqConfiguration.java index 9190efc26..ca6870abe 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/RabbitMqConfiguration.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/config/RabbitMqConfiguration.java @@ -7,8 +7,6 @@ import org.springframework.amqp.core.*; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.amqp.rabbit.retry.MessageRecoverer; -import org.springframework.amqp.rabbit.retry.RepublishMessageRecoverer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -69,10 +67,10 @@ public class RabbitMqConfiguration { * @param rabbitTemplate * @return */ - @Bean - public MessageRecoverer republishMessageRecoverer(RabbitTemplate rabbitTemplate){ - return new RepublishMessageRecoverer(rabbitTemplate, RabbitConstant.DISTRIBUTION_ERROR_EXCHANGE, RabbitConstant.DISTRIBUTION_ERROR_ROUTING); - } +// @Bean +// public MessageRecoverer republishMessageRecoverer(RabbitTemplate rabbitTemplate){ +// return new RepublishMessageRecoverer(rabbitTemplate, RabbitConstant.DISTRIBUTION_ERROR_EXCHANGE, RabbitConstant.DISTRIBUTION_ERROR_ROUTING); +// } /** 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 360bf8ce9..a0bff054b 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 @@ -288,4 +288,12 @@ public interface DistributionParcelListMapper extends BaseMapper findALLNoUpShelfPackageByOrderCodeList(@Param("orderCodeList") List orderCodeList, @Param("warehouseId") Long warehouseId); List findOrderCodesByOrderPackageCodes(@Param("orderPackageCodes") List orderPackageCodes, @Param("warehouseId") Long warehouseId); + + String findAllTraysByNoParcelListIds(@Param("parcelListIdList") List parcelListIdList,@Param("orderCode") String orderCode); + + void clearPalletByIds(@Param("clearTrayList") List clearTrayList); + + String findAllAllocationByNoParcelListIds(@Param("parcelListIdList") List parcelListIdList, @Param("orderCode") String orderCode); + + void clearAllocationByIds(@Param("clearTrayList") List clearTrayList); } 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 51a2f17be..aa202a059 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 @@ -1794,4 +1794,49 @@ group by ldpl.order_code + + + + update logpm_distribution_parcel_list + set pallet = null + where id in + + #{item} + + + + + + + update logpm_distribution_parcel_list + set goods_allocation = null, + order_package_grounding_status = '10' + where id in + + #{item} + + + 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 4c3b791e4..25112912e 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 @@ -208,4 +208,9 @@ public interface DistributionStockArticleMapper extends BaseMapper signforListDetail(@Param("orderId") Long id); + + void clearTraysByIds(@Param("ids") List clearTraysStockArticleIdList); + + void clearAllocationByIds(@Param("ids") List clearAllocationStockArticleIdList); + } 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 b4e8ba0fa..b90436f9e 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 @@ -1515,5 +1515,23 @@ ldrs.reservation_id + + update logpm_distribution_stock_article + set trays = null + where id in + + #{item} + + + + + update logpm_distribution_stock_article + set allocation = null, + grounding_status = '10' + where id in + + #{item} + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListInfoMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListInfoMapper.java index c13502730..00126736b 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListInfoMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListInfoMapper.java @@ -57,4 +57,8 @@ public interface DistributionStockListInfoMapper extends BaseMapper getStockListInfo(IPage page,@Param("par") Map distributionStockListInfo); List getAllOrderPackageCodes(@Param("incomingBatch") String incomingBatch, @Param("sku") String sku, @Param("mallId") Long mallId, @Param("warehouseId") Long warehouseId); + + String findAllTraysByNoParcelListIdsAndStockListId(@Param("parcelListIds") List parcelListIds, @Param("stockListId") Long stockListId); + + String findAllAllocationByNoParcelListIdsAndStockListId(@Param("parcelListIds") List parcelListIds, @Param("stockListId") Long stockListId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListInfoMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListInfoMapper.xml index 522a917f6..22ef7cd55 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListInfoMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListInfoMapper.xml @@ -116,4 +116,34 @@ AND is_deleted = 0 + + + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.java index 514488ca4..01512907a 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.java @@ -156,4 +156,8 @@ public interface DistributionStockListMapper extends BaseMapper listAllocationOrder(IPage page, @Param("param") DistributionStockListEntity distributionStockListEntity); List getListByMarketIdAndSku(@Param("mallId")Long mallId, @Param("sku")String sku, @Param("warehouseId")Long warehouseId); + + void clearTraysByIds(@Param("stockListIds") List clearTrayStockListIds); + + void clearAllocationByIds(@Param("stockListIds") List clearAllocationStockListIds); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml index e5187fbaf..2aa1ddd9e 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml @@ -616,4 +616,22 @@ and ldsl.warehouse_id = #{warehouseId} + + update logpm_distribution_stock_list + set tray_name = null + where id in + + #{stockListId} + + + + + update logpm_distribution_stock_list + set storage_location = null + where id in + + #{stockListId} + + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/WarehouseTrayAllocationListener.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/WarehouseTrayAllocationListener.java new file mode 100644 index 000000000..784eabaa3 --- /dev/null +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/WarehouseTrayAllocationListener.java @@ -0,0 +1,1275 @@ +package com.logpm.distribution.receiver; + +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; +import com.logpm.distribution.entity.DistributionStockListEntity; +import com.logpm.distribution.entity.DistributionStockListInfoEntity; +import com.logpm.distribution.service.IDistributionParcelListService; +import com.logpm.distribution.service.IDistributionStockArticleService; +import com.logpm.distribution.service.IDistributionStockListInfoService; +import com.logpm.distribution.service.IDistributionStockListService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.broadcast.FanoutConstants; +import org.springblade.core.tool.utils.StringUtil; +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 org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@Component +@AllArgsConstructor +public class WarehouseTrayAllocationListener { + + private final IDistributionParcelListService parcelListService; + private final IDistributionStockArticleService stockArticleService; + private final IDistributionStockListInfoService stockListInfoService; + private final IDistributionStockListService stockListService; + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FanoutConstants.warehouse.TRAYTYPE.QUEUE.TRAYTYPE_MESSAGE), + exchange = @Exchange(name = FanoutConstants.warehouse.TRAYTYPE.EXCHANGE, type = ExchangeTypes.FANOUT) + )) + @Transactional(rollbackFor = Exception.class) + public void trayTypeMessage(String msg) { + log.info("##########trayTypeMessage: 配送消费托盘广播 开始 msg={}",msg); + if(StringUtil.isNotBlank(msg)){ + JSONObject jsonObject = JSONUtil.parseObj(msg); + Integer operation = jsonObject.getInt("operation"); + if(operation.equals(1)){ + //打托 + trayTypeInfo(msg); + }else if(operation.equals(2)){ + //解托 + unbindTrayInfo(msg); + }else{ + log.info("##########trayTypeMessage: 配送消费托盘广播 操作类型错误 operation={}",operation); + } + } + log.info("##########trayTypeMessage: 配送消费托盘广播 结束 msg={}",msg); + } + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FanoutConstants.warehouse.ALLOCATION.QUEUE.ALLOCATION_MESSAGE), + exchange = @Exchange(name = FanoutConstants.warehouse.ALLOCATION.EXCHANGE, type = ExchangeTypes.FANOUT) + )) + @Transactional(rollbackFor = Exception.class) + public void allocationMessage(String msg) { + log.info("##########allocationMessage: 配送消费库位广播 开始 msg={}", msg); + if(StringUtil.isNotBlank(msg)){ + JSONObject jsonObject = JSONUtil.parseObj(msg); + Integer operation = jsonObject.getInt("operation"); + if(operation.equals(3)){ + //上架 + upshelfInfo(msg); + }else if(operation.equals(4)){ + //下架 + downshelfInfo(msg); + }else{ + log.info("##########allocationMessage: 配送消费库位广播 操作类型错误 operation={}",operation); + } + } + log.info("##########allocationMessage: 配送消费库位广播 结束 msg={}", msg); + } + + private void trayTypeInfo(String msg) { + log.info("##########trayTypeInfo: 配送消费打托广播 开始 msg={}",msg); + + if(StringUtil.isNotBlank(msg)){ + JSONObject jsonObject = JSONUtil.parseObj(msg); + Integer dataType = jsonObject.getInt("dataType"); + if(dataType.equals(1)){ + //订制品 + Integer conditions = jsonObject.getInt("conditions"); + JSONArray orderPackageCodeArray = jsonObject.getJSONArray("orderPackageCodes"); + List orderPackageCodes = JSONUtil.toList(orderPackageCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String trayName = jsonObject.getStr("trayName"); + + if(conditions.equals(1)){ + //订制品 + updatePackageTrayInfo(orderPackageCodes, trayName, warehouseId); + }else if(conditions.equals(2)){ + //有数据库存品 + updatePackageStockTrayInfo(orderPackageCodes, trayName, warehouseId); + } + }else if(dataType.equals(2)){ + //零担 + JSONArray orderCodeArray = jsonObject.getJSONArray("orderCodes"); + List orderCodes = JSONUtil.toList(orderCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String trayName = jsonObject.getStr("trayName"); + + updateZeroTrayInfo(orderCodes, trayName, warehouseId); + }else if (dataType.equals(3)){ + //无数据库存品 + JSONArray stockListIdArray = jsonObject.getJSONArray("stockListIds"); + List stockListIds = JSONUtil.toList(stockListIdArray, Long.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String trayName = jsonObject.getStr("trayName"); + + updateStockListTrayInfo(stockListIds,warehouseId,trayName); + } + } + + log.info("##########trayTypeInfo: 配送消费打托广播 结束 msg={}",msg); + } + + private void updateStockListTrayInfo(List stockListIds, Long warehouseId, String trayName) { + + List stockListEntities = stockListService.listByIds(stockListIds); + + List updateStockListList = new ArrayList<>(); + stockListEntities.forEach(stockListEntity -> { + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListEntity.getId()); + String trays = stockListEntity.getTrayName(); + if(StringUtil.isBlank(trays)){ + updateStockListEntity.setTrayName(trayName); + updateStockListList.add(updateStockListEntity); + }else{ + if(!trays.contains(trayName)){ + trays = trays + "," + trayName; + updateStockListEntity.setTrayName(trays); + updateStockListList.add(updateStockListEntity); + } + } + }); + if(!updateStockListList.isEmpty()){ + stockListService.updateBatchById(updateStockListList); + } + } + + private void updateZeroTrayInfo(List orderCodes, String trayName, Long warehouseId) { + QueryWrapper stockArticleEntityQueryWrapper = new QueryWrapper<>(); + stockArticleEntityQueryWrapper.in("order_code", orderCodes) + .eq("warehouse_id", warehouseId); + List stockArticleEntityList = stockArticleService.list(stockArticleEntityQueryWrapper); + + List updateStockArticleList = new ArrayList<>(); + stockArticleEntityList.forEach(stockArticleEntity -> { + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + String trays = stockArticleEntity.getTrays(); + if(StringUtil.isBlank(trays)){ + updateStockArticleEntity.setTrays(trayName); + updateStockArticleList.add(updateStockArticleEntity); + }else{ + if(!trays.contains(trayName)){ + trays = trays + "," + trayName; + updateStockArticleEntity.setTrays(trays); + updateStockArticleList.add(updateStockArticleEntity); + } + } + }); + if(!updateStockArticleList.isEmpty()){ + stockArticleService.updateBatchById(updateStockArticleList); + } + } + + private void updatePackageStockTrayInfo(List orderPackageCodes, String trayName, Long warehouseId) { + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + + List updateStockListList = new ArrayList<>(); + List updateParcelListList = new ArrayList<>(); + + //把parcelListEntityList的id存入一个list + List parcelListIdList = parcelListEntityList.stream() + .map(DistributionParcelListEntity::getId) + .collect(Collectors.toList()); + + QueryWrapper stockListInfoEntityQueryWrapper = new QueryWrapper<>(); + stockListInfoEntityQueryWrapper.in("parcel_list_id", parcelListIdList); + List stockListInfoEntities = stockListInfoService.list(stockListInfoEntityQueryWrapper); + //把stockListInfoEntities通过stockListId进行分组 + Map> groupedByStockListId = + stockListInfoEntities.stream() + .collect(Collectors.groupingBy(DistributionStockListInfoEntity::getStockListId)); + Set stockListIds = groupedByStockListId.keySet(); + + List stockListEntityList = stockListService.listByIds(stockListIds); + //把stockListEntityList转化成以id为key的Map + Map stockListEntityMap = stockListEntityList.stream() + .collect(Collectors.toMap(DistributionStockListEntity::getId, stockListEntity -> stockListEntity)); + + parcelListIdList.forEach(parcelListId -> { + DistributionParcelListEntity updateParcelListEntity = new DistributionParcelListEntity(); + updateParcelListEntity.setId(parcelListId); + updateParcelListEntity.setPallet(trayName); + updateParcelListList.add(updateParcelListEntity); + }); + + + stockListEntityMap.keySet().forEach(stockListId -> { + DistributionStockListEntity stockListEntity = stockListEntityMap.get(stockListId); + if(!Objects.isNull(stockListEntity)){ + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListId); + String trays = stockListEntity.getTrayName(); + if(StringUtil.isBlank(trays)){ + updateStockListEntity.setTrayName(trayName); + updateStockListList.add(updateStockListEntity); + }else{ + if(!trays.contains(trayName)){ + trays = trays + "," + trayName; + updateStockListEntity.setTrayName(trays); + updateStockListList.add(updateStockListEntity); + } + } + } + }); + if(!updateParcelListList.isEmpty()){ + parcelListService.updateBatchById(updateParcelListList); + } + if(!updateStockListList.isEmpty()){ + stockListService.updateBatchById(updateStockListList); + } + } + } + + private void updatePackageTrayInfo(List orderPackageCodes, String trayName, Long warehouseId) { + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + //把parcelListEntityList通过orderCode作为key进行分组 + Map> groupedByOrderCode = + parcelListEntityList.stream() + .collect(Collectors.groupingBy(DistributionParcelListEntity::getOrderCode)); + + Set orderCodeSet = groupedByOrderCode.keySet(); + QueryWrapper stockArticleEntityQueryWrapper = new QueryWrapper<>(); + stockArticleEntityQueryWrapper.in("order_code", orderCodeSet) + .eq("warehouse_id",warehouseId); + + List stockArticleEntities = stockArticleService.list(stockArticleEntityQueryWrapper); + //把stockArticleEntities转化成以orderCOde为key的Map + Map stockArticleEntityMap = stockArticleEntities.stream() + .collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, stockArticleEntity -> stockArticleEntity)); + + List updateStockArticleList = new ArrayList<>(); + List updateParcelListList = new ArrayList<>(); + groupedByOrderCode.keySet().forEach(orderCode -> { + List parcelListEntityListByOrderCode = groupedByOrderCode.get(orderCode); + if(!parcelListEntityListByOrderCode.isEmpty()){ + parcelListEntityListByOrderCode.forEach(parcelListEntity -> { + DistributionParcelListEntity updateParcelListEntity = new DistributionParcelListEntity(); + updateParcelListEntity.setId(parcelListEntity.getId()); + updateParcelListEntity.setPallet(trayName); + updateParcelListList.add(updateParcelListEntity); + }); + } + + DistributionStockArticleEntity stockArticleEntity = stockArticleEntityMap.get(orderCode); + if (!Objects.isNull(stockArticleEntity)){ + String trays = stockArticleEntity.getTrays(); + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + if(StringUtil.isBlank(trays)){ + updateStockArticleEntity.setTrays(trayName); + updateStockArticleList.add(updateStockArticleEntity); + }else{ + if(!trays.contains(trayName)){ + trays = trays + "," + trayName; + updateStockArticleEntity.setTrays(trays); + updateStockArticleList.add(updateStockArticleEntity); + } + } + } + }); + if(!updateParcelListList.isEmpty()){ + parcelListService.updateBatchById(updateParcelListList); + } + if(!updateStockArticleList.isEmpty()){ + stockArticleService.updateBatchById(updateStockArticleList); + } + + } + } + + + private void unbindTrayInfo(String msg) { + log.info("##########unbindTrayInfo: 配送消费解托广播 开始 msg={}", msg); + if(StringUtil.isNotBlank(msg)){ + JSONObject jsonObject = JSONUtil.parseObj(msg); + Integer dataType = jsonObject.getInt("dataType"); + if(dataType.equals(1)){ + //订制品 + Integer conditions = jsonObject.getInt("conditions"); + JSONArray orderPackageCodeArray = jsonObject.getJSONArray("orderPackageCodes"); + List orderPackageCodes = JSONUtil.toList(orderPackageCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + + if(conditions.equals(1)){ + //订制品 + updatePackageUnbindTrayInfo(orderPackageCodes, warehouseId); + }else if(conditions.equals(2)){ + //有数据库存品 + updatePackageStockUnbindTrayInfo(orderPackageCodes, warehouseId); + } + }else if(dataType.equals(2)){ + //零担 + JSONArray orderCodeArray = jsonObject.getJSONArray("orderCodes"); + List orderCodes = JSONUtil.toList(orderCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String trayName = jsonObject.getStr("trayName"); + + updateZeroUnbindTrayInfo(orderCodes, trayName, warehouseId); + }else if (dataType.equals(3)){ + //无数据库存品 + JSONArray stockListIdArray = jsonObject.getJSONArray("stockListIds"); + List stockListIds = JSONUtil.toList(stockListIdArray, Long.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String trayName = jsonObject.getStr("trayName"); + + updateStockListUnbindTrayInfo(stockListIds,warehouseId,trayName); + } + } + + log.info("##########unbindTrayInfo: 配送消费解托广播 结束后msg={}", msg); + } + + private void updateStockListUnbindTrayInfo(List stockListIds, Long warehouseId, String trayName) { + List stockListEntityList = stockListService.listByIds(stockListIds); + + List clearTrayStockListIds = new ArrayList<>(); + List updateTrayList = new ArrayList<>(); + stockListEntityList.forEach(stockListEntity -> { + if(StringUtil.isNotBlank(stockListEntity.getTrayName())){ + String[] split = stockListEntity.getTrayName().split(","); + List trayList = new ArrayList<>(Arrays.asList(split)); + if(trayList.contains(trayName)){ + trayList.remove(trayName); + if(trayList.isEmpty()){ + clearTrayStockListIds.add(stockListEntity.getId()); + }else{ + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListEntity.getId()); + updateStockListEntity.setTrayName(String.join(",", trayList)); + updateTrayList.add(updateStockListEntity); + } + + } + } + }); + if(!clearTrayStockListIds.isEmpty()){ + stockListService.clearTraysByIds(clearTrayStockListIds); + } + if(!updateTrayList.isEmpty()){ + stockListService.updateBatchById(updateTrayList); + } + + } + + private void updateZeroUnbindTrayInfo(List orderCodes, String trayName, Long warehouseId) { + QueryWrapper stockArticleEntityQueryWrapper = new QueryWrapper<>(); + stockArticleEntityQueryWrapper.in("order_code", orderCodes) + .eq("warehouse_id", warehouseId); + List stockArticleEntityList = stockArticleService.list(stockArticleEntityQueryWrapper); + + List clearTrayStockArticleIds = new ArrayList<>(); + List updateTrayList = new ArrayList<>(); + stockArticleEntityList.forEach(stockArticleEntity -> { + String trays = stockArticleEntity.getTrays(); + if(trays.contains(trayName)){ + String[] split = trays.split(","); + List trayList = new ArrayList<>(Arrays.asList(split)); + trayList.remove(trayName); + if(trayList.isEmpty()){ + clearTrayStockArticleIds.add(stockArticleEntity.getId()); + }else{ + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + updateStockArticleEntity.setTrays(String.join(",", trayList)); + updateTrayList.add(updateStockArticleEntity); + } + + } + }); + if(!clearTrayStockArticleIds.isEmpty()){ + stockArticleService.clearTraysByIds(clearTrayStockArticleIds); + } + if(!updateTrayList.isEmpty()){ + stockArticleService.updateBatchById(updateTrayList); + } + } + + private void updatePackageStockUnbindTrayInfo(List orderPackageCodes, Long warehouseId) { + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + //把parcelListEntityList中所有元素放入一个List + List parcelListIdList = parcelListEntityList.stream() + .map(DistributionParcelListEntity::getId) + .collect(Collectors.toList()); + + QueryWrapper stockListInfoEntityQueryWrapper = new QueryWrapper<>(); + stockListInfoEntityQueryWrapper.in("parcel_list_id", parcelListIdList); + List stockListInfoEntities = stockListInfoService.list(stockListInfoEntityQueryWrapper); + //把stockListInfoEntities通过stockListId进行分组 + Map> groupedByStockListId = + stockListInfoEntities.stream() + .collect(Collectors.groupingBy(DistributionStockListInfoEntity::getStockListId)); + + List clearTrayStockListIds = new ArrayList<>(); + List updateTraysStockListList = new ArrayList<>(); + groupedByStockListId.keySet().forEach(stockListId -> { + List stockListInfoEntityList = groupedByStockListId.get(stockListId); + //把stockListInfoEntityList中所有元素的parcelListId放入一个List + List parcelListIds = stockListInfoEntityList.stream() + .map(DistributionStockListInfoEntity::getParcelListId) + .collect(Collectors.toList()); + + String trayName = stockListInfoService.findAllTraysByNoParcelListIdsAndStockListId(parcelListIds, stockListId); + if(StringUtil.isBlank(trayName)){ + clearTrayStockListIds.add(stockListId); + }else{ + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListId); + updateStockListEntity.setTrayName(trayName); + updateTraysStockListList.add(updateStockListEntity); + } + }); + + if(!parcelListIdList.isEmpty()){ + parcelListService.clearPalletByIds(parcelListIdList); + } + if(!clearTrayStockListIds.isEmpty()){ + stockListService.clearTraysByIds(clearTrayStockListIds); + } + if(!updateTraysStockListList.isEmpty()){ + stockListService.updateBatchById(updateTraysStockListList); + } + } + } + + private void updatePackageUnbindTrayInfo(List orderPackageCodes, Long warehouseId) { + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + //把parcelListEntityList通过orderCode作为key进行分组 + Map> groupedByOrderCode = + parcelListEntityList.stream() + .collect(Collectors.groupingBy(DistributionParcelListEntity::getOrderCode)); + + Set orderCodeSet = groupedByOrderCode.keySet(); + QueryWrapper stockArticleEntityQueryWrapper = new QueryWrapper<>(); + stockArticleEntityQueryWrapper.in("order_code", orderCodeSet) + .eq("warehouse_id",warehouseId); + + List stockArticleEntities = stockArticleService.list(stockArticleEntityQueryWrapper); + //把stockArticleEntities转化成以orderCOde为key的Map + Map stockArticleEntityMap = stockArticleEntities.stream() + .collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, stockArticleEntity -> stockArticleEntity)); + + List updateTraysStockArticleIdList = new ArrayList<>(); + List clearTraysStockArticleIdList = new ArrayList<>(); + List clearTrayList = new ArrayList<>(); + groupedByOrderCode.keySet().forEach(orderCode -> { + List parcelListEntityListByOrderCode = groupedByOrderCode.get(orderCode); + if(!parcelListEntityListByOrderCode.isEmpty()){ + //把parcelListEntityListByOrderCode中所有元素的id放入一个List集合 + List parcelListIdList = parcelListEntityListByOrderCode.stream() + .map(DistributionParcelListEntity::getId) + .collect(Collectors.toList()); + + clearTrayList.addAll(parcelListIdList); + + String trays = parcelListService.findAllTraysByNoParcelListIds(parcelListIdList,orderCode); + DistributionStockArticleEntity stockArticleEntity = stockArticleEntityMap.get(orderCode); + if(StringUtil.isBlank(trays)){ + clearTraysStockArticleIdList.add(stockArticleEntity.getId()); + }else{ + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + updateStockArticleEntity.setTrays(trays); + updateTraysStockArticleIdList.add(updateStockArticleEntity); + } + } + }); + if(!clearTrayList.isEmpty()){ + parcelListService.clearPalletByIds(clearTrayList); + } + if(!clearTraysStockArticleIdList.isEmpty()){ + stockArticleService.clearTraysByIds(clearTraysStockArticleIdList); + } + if(!updateTraysStockArticleIdList.isEmpty()){ + stockArticleService.updateBatchById(updateTraysStockArticleIdList); + } + } + } + + + /** + * 移托方法 + * @param msg + */ + private void moveTrayInfo(String msg) { + log.info("##########unbindTrayInfo: 配送消费移托广播 开始 msg={}", msg); + if(StringUtil.isNotBlank(msg)){ + JSONObject jsonObject = JSONUtil.parseObj(msg); + Integer dataType = jsonObject.getInt("dataType"); + if(dataType.equals(1)){ + //订制品 + Integer conditions = jsonObject.getInt("conditions"); + JSONArray orderPackageCodeArray = jsonObject.getJSONArray("orderPackageCodes"); + List orderPackageCodes = JSONUtil.toList(orderPackageCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String sourceTrayName = jsonObject.getStr("sourceTrayName"); + String targetTrayName = jsonObject.getStr("targetTrayName"); + + if(conditions.equals(1)){ + //订制品 + updatePackageMoveTrayInfo(orderPackageCodes, warehouseId, sourceTrayName, targetTrayName); + }else if(conditions.equals(2)){ + //有数据库存品 + updatePackageStockMoveTrayInfo(orderPackageCodes, warehouseId, sourceTrayName, targetTrayName); + } + }else if(dataType.equals(2)){ + //零担 + JSONArray orderCodeArray = jsonObject.getJSONArray("orderCodes"); + List orderCodes = JSONUtil.toList(orderCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String sourceTrayName = jsonObject.getStr("sourceTrayName"); + String targetTrayName = jsonObject.getStr("targetTrayName"); + + updateZeroMoveTrayInfo(orderCodes, warehouseId, sourceTrayName, targetTrayName); + }else if (dataType.equals(3)){ + //无数据库存品 + JSONArray stockListIdArray = jsonObject.getJSONArray("stockListIds"); + List stockListIds = JSONUtil.toList(stockListIdArray, Long.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String sourceTrayName = jsonObject.getStr("sourceTrayName"); + String targetTrayName = jsonObject.getStr("targetTrayName"); + + updateStockListMoveTrayInfo(stockListIds,warehouseId,sourceTrayName,targetTrayName); + } + } + + log.info("##########unbindTrayInfo: 配送消费移托广播 结束 msg={}", msg); + } + + private void updateStockListMoveTrayInfo(List stockListIds, Long warehouseId, String sourceTrayName, String targetTrayName) { + List stockListEntityList = stockListService.listByIds(stockListIds); + + List updateTrayList = new ArrayList<>(); + stockListEntityList.forEach(stockListEntity -> { + String trayName = stockListEntity.getTrayName(); + if(StringUtil.isBlank(trayName)){ + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListEntity.getId()); + updateStockListEntity.setTrayName(trayName); + updateTrayList.add(updateStockListEntity); + }else{ + String[] split = trayName.split(","); + List trayNameList = new ArrayList<>(Arrays.asList(split)); + trayNameList.remove(sourceTrayName); + trayNameList.add(targetTrayName); + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListEntity.getId()); + updateStockListEntity.setTrayName(String.join(",", trayNameList)); + updateTrayList.add(updateStockListEntity); + } + + }); + if(!updateTrayList.isEmpty()){ + stockListService.updateBatchById(updateTrayList); + } + } + + private void updateZeroMoveTrayInfo(List orderCodes, Long warehouseId, String sourceTrayName, String targetTrayName) { + QueryWrapper stockArticleEntityQueryWrapper = new QueryWrapper<>(); + stockArticleEntityQueryWrapper.in("order_code", orderCodes) + .eq("warehouse_id", warehouseId); + List stockArticleEntityList = stockArticleService.list(stockArticleEntityQueryWrapper); + + List updateTrayList = new ArrayList<>(); + stockArticleEntityList.forEach(stockArticleEntity -> { + String trays = stockArticleEntity.getTrays(); + if(StringUtil.isBlank(trays)){ + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + updateStockArticleEntity.setTrays(targetTrayName); + updateTrayList.add(updateStockArticleEntity); + }else{ + String[] split = trays.split(","); + List trayNameList = new ArrayList<>(Arrays.asList(split)); + trayNameList.remove(sourceTrayName); + trayNameList.add(targetTrayName); + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + updateStockArticleEntity.setTrays(String.join(",", trayNameList)); + updateTrayList.add(updateStockArticleEntity); + } + }); + if(!updateTrayList.isEmpty()){ + stockArticleService.updateBatchById(updateTrayList); + } + } + + private void updatePackageStockMoveTrayInfo(List orderPackageCodes, Long warehouseId, String sourceTrayName, String targetTrayName) { + //先查询出对应的所有包件信息 + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + //把parcelListEntityList中所有元素放入一个List 便于查询所有包件对应的库存品有哪些 + List parcelListIdList = parcelListEntityList.stream() + .map(DistributionParcelListEntity::getId) + .collect(Collectors.toList()); + + QueryWrapper stockListInfoEntityQueryWrapper = new QueryWrapper<>(); + stockListInfoEntityQueryWrapper.in("parcel_list_id", parcelListIdList); + List stockListInfoEntities = stockListInfoService.list(stockListInfoEntityQueryWrapper); + //把stockListInfoEntities通过stockListId进行分组,就能知道所有库存品对应的包件有哪些 + Map> groupedByStockListId = + stockListInfoEntities.stream() + .collect(Collectors.groupingBy(DistributionStockListInfoEntity::getStockListId)); + + List updateTraysParcelListList = new ArrayList<>(); + List updateTraysStockListList = new ArrayList<>(); + groupedByStockListId.keySet().forEach(stockListId -> { + List stockListInfoEntityList = groupedByStockListId.get(stockListId); + //把stockListInfoEntityList中所有元素的parcelListId放入一个List + List parcelListIds = stockListInfoEntityList.stream() + .map(DistributionStockListInfoEntity::getParcelListId) + .collect(Collectors.toList()); + + String trayName = stockListInfoService.findAllTraysByNoParcelListIdsAndStockListId(parcelListIds, stockListId); + if(StringUtil.isBlank(trayName)){ + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListId); + updateStockListEntity.setTrayName(targetTrayName); + updateTraysStockListList.add(updateStockListEntity); + }else{ + if(!trayName.contains(targetTrayName)){ + trayName = trayName + "," + targetTrayName; + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListId); + updateStockListEntity.setTrayName(trayName); + updateTraysStockListList.add(updateStockListEntity); + } + } + }); + + parcelListIdList.forEach(parcelListId -> { + DistributionParcelListEntity updateParcelListEntity = new DistributionParcelListEntity(); + updateParcelListEntity.setId(parcelListId); + updateParcelListEntity.setPallet(targetTrayName); + updateTraysParcelListList.add(updateParcelListEntity); + }); + + + if(!updateTraysParcelListList.isEmpty()){ + parcelListService.updateBatchById(updateTraysParcelListList); + } + if(!updateTraysStockListList.isEmpty()){ + stockListService.updateBatchById(updateTraysStockListList); + } + } + + } + + private void updatePackageMoveTrayInfo(List orderPackageCodes, Long warehouseId, String sourceTrayName, String targetTrayName) { + //先查询出对应的所有包件信息 + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + //分组获得有哪些订单对应哪些包件 + //把parcelListEntityList中所有元素的orderCode作为key进行分组 + Map> groupedByOrderCode = parcelListEntityList.stream() + .collect(Collectors.groupingBy(DistributionParcelListEntity::getOrderCode)); + + //把所有对应订单的信息查出来 + List stockArticleEntities = stockArticleService.list(new QueryWrapper().in("order_code", groupedByOrderCode.keySet())); + //把stockArticleEntities转化成orderCodeweikey的map + Map stockArticleEntityMap = stockArticleEntities.stream() + .collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, stockArticleEntity -> stockArticleEntity)); + + List updateParcelListEntityList = new ArrayList<>(); + List updateStockArticleEntityList = new ArrayList<>(); + + //循环groupedByOrderCode,处理数据 + groupedByOrderCode.keySet().forEach(orderCode -> { + List parcelListEntityListByOrderCode = groupedByOrderCode.get(orderCode); + DistributionStockArticleEntity stockArticleEntity = stockArticleEntityMap.get(orderCode); + //把parcelListEntityListByOrderCode所有元素的id放入一个List,可以进行批量查询 + List parcelListIdList = parcelListEntityListByOrderCode.stream() + .map(DistributionParcelListEntity::getId) + .collect(Collectors.toList()); + + //处理包件更新信息 + parcelListEntityListByOrderCode.forEach(parcelListEntity -> { + DistributionParcelListEntity updateParcelListEntity = new DistributionParcelListEntity(); + updateParcelListEntity.setId(parcelListEntity.getId()); + updateParcelListEntity.setPallet(targetTrayName); + updateParcelListEntityList.add(updateParcelListEntity); + }); + + String trays = parcelListService.findAllTraysByNoParcelListIds(parcelListIdList, orderCode); + if(StringUtil.isBlank(trays)){ + trays = targetTrayName; + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + updateStockArticleEntity.setTrays(trays); + updateStockArticleEntityList.add(updateStockArticleEntity); + }else { + if(!trays.contains(targetTrayName)){ + trays = trays + "," + targetTrayName; + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + updateStockArticleEntity.setTrays(trays); + updateStockArticleEntityList.add(updateStockArticleEntity); + } + } + }); + if(!updateParcelListEntityList.isEmpty()){ + parcelListService.updateBatchById(updateParcelListEntityList); + } + if(!updateStockArticleEntityList.isEmpty()){ + stockArticleService.updateBatchById(updateStockArticleEntityList); + } + } + } + + + private void upshelfInfo(String msg) { + log.info("##########upshelfInfo: 配送消费上架广播 开始 msg={}",msg); + + if(StringUtil.isNotBlank(msg)){ + JSONObject jsonObject = JSONUtil.parseObj(msg); + Integer dataType = jsonObject.getInt("dataType"); + if(dataType.equals(1)){ + //订制品 + Integer conditions = jsonObject.getInt("conditions"); + JSONArray orderPackageCodeArray = jsonObject.getJSONArray("orderPackageCodes"); + List orderPackageCodes = JSONUtil.toList(orderPackageCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String allocationName = jsonObject.getStr("allocationName"); + + if(conditions.equals(1)){ + //订制品 + updatePackageAllocationInfo(orderPackageCodes, allocationName, warehouseId); + }else if(conditions.equals(2)){ + //有数据库存品 + updatePackageStockAllocationInfo(orderPackageCodes, allocationName, warehouseId); + } + }else if(dataType.equals(2)){ + //零担 + JSONArray orderCodeArray = jsonObject.getJSONArray("orderCodes"); + List orderCodes = JSONUtil.toList(orderCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String allocationName = jsonObject.getStr("allocationName"); + + updateZeroAllocationInfo(orderCodes, allocationName, warehouseId); + }else if (dataType.equals(3)){ + //无数据库存品 + JSONArray stockListIdArray = jsonObject.getJSONArray("stockListIds"); + List stockListIds = JSONUtil.toList(stockListIdArray, Long.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String allocationName = jsonObject.getStr("allocationName"); + + updateStockListAllocationInfo(stockListIds,warehouseId,allocationName); + } + } + + log.info("##########trayTypeInfo: 配送消费上架广播 结束 msg={}",msg); + } + + private void updateStockListAllocationInfo(List stockListIds, Long warehouseId, String allocationName) { + List stockListEntities = stockListService.listByIds(stockListIds); + + List updateStockListList = new ArrayList<>(); + stockListEntities.forEach(stockListEntity -> { + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListEntity.getId()); + String storageLocation = stockListEntity.getStorageLocation(); + if(StringUtil.isBlank(storageLocation)){ + updateStockListEntity.setStorageLocation(allocationName); + updateStockListList.add(updateStockListEntity); + }else{ + if(!storageLocation.contains(allocationName)){ + String[] split = storageLocation.split(","); + List allocationList = new ArrayList<>(Arrays.asList(split)); + allocationList.add(allocationName); + updateStockListEntity.setTrayName(StringUtil.join(allocationList,",")); + updateStockListList.add(updateStockListEntity); + } + } + }); + if(!updateStockListList.isEmpty()){ + stockListService.updateBatchById(updateStockListList); + } + + } + + private void updateZeroAllocationInfo(List orderCodes, String allocationName, Long warehouseId) { + QueryWrapper stockArticleEntityQueryWrapper = new QueryWrapper<>(); + stockArticleEntityQueryWrapper.in("order_code", orderCodes) + .eq("warehouse_id", warehouseId); + List stockArticleEntityList = stockArticleService.list(stockArticleEntityQueryWrapper); + + List updateStockArticleList = new ArrayList<>(); + stockArticleEntityList.forEach(stockArticleEntity -> { + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + String allocation = stockArticleEntity.getAllocation(); + if(StringUtil.isBlank(allocation)){ + updateStockArticleEntity.setAllocation(allocationName); + updateStockArticleEntity.setGroundingStatus("30"); + updateStockArticleList.add(updateStockArticleEntity); + }else{ + if(!allocation.contains(allocationName)){ + String[] split = allocation.split(","); + List allocationList = new ArrayList<>(Arrays.asList(split)); + allocationList.add(allocationName); + updateStockArticleEntity.setAllocation(StringUtil.join(allocationList,",")); + updateStockArticleEntity.setGroundingStatus("30"); + updateStockArticleList.add(updateStockArticleEntity); + } + } + }); + if(!updateStockArticleList.isEmpty()){ + stockArticleService.updateBatchById(updateStockArticleList); + } + } + + private void updatePackageStockAllocationInfo(List orderPackageCodes, String allocationName, Long warehouseId) { + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + + List updateStockListList = new ArrayList<>(); + List updateParcelListList = new ArrayList<>(); + + //把parcelListEntityList的id存入一个list + List parcelListIdList = parcelListEntityList.stream() + .map(DistributionParcelListEntity::getId) + .collect(Collectors.toList()); + + QueryWrapper stockListInfoEntityQueryWrapper = new QueryWrapper<>(); + stockListInfoEntityQueryWrapper.in("parcel_list_id", parcelListIdList); + List stockListInfoEntities = stockListInfoService.list(stockListInfoEntityQueryWrapper); + //把stockListInfoEntities通过stockListId进行分组 + Map> groupedByStockListId = + stockListInfoEntities.stream() + .collect(Collectors.groupingBy(DistributionStockListInfoEntity::getStockListId)); + Set stockListIds = groupedByStockListId.keySet(); + + List stockListEntityList = stockListService.listByIds(stockListIds); + //把stockListEntityList转化成以id为key的Map + Map stockListEntityMap = stockListEntityList.stream() + .collect(Collectors.toMap(DistributionStockListEntity::getId, stockListEntity -> stockListEntity)); + + parcelListIdList.forEach(parcelListId -> { + DistributionParcelListEntity updateParcelListEntity = new DistributionParcelListEntity(); + updateParcelListEntity.setId(parcelListId); + updateParcelListEntity.setGoodsAllocation(allocationName); + updateParcelListEntity.setOrderPackageGroundingStatus("20"); + updateParcelListList.add(updateParcelListEntity); + }); + + + stockListEntityMap.keySet().forEach(stockListId -> { + DistributionStockListEntity stockListEntity = stockListEntityMap.get(stockListId); + if(!Objects.isNull(stockListEntity)){ + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListId); + String storageLocation = stockListEntity.getStorageLocation(); + if(StringUtil.isBlank(storageLocation)){ + updateStockListEntity.setStorageLocation(allocationName); + updateStockListList.add(updateStockListEntity); + }else{ + if(!storageLocation.contains(allocationName)){ + String[] split = storageLocation.split(","); + List allocationList = new ArrayList<>(Arrays.asList(split)); + allocationList.add(allocationName); + updateStockListEntity.setStorageLocation(StringUtil.join(allocationList, ",")); + updateStockListList.add(updateStockListEntity); + } + } + } + }); + if(!updateParcelListList.isEmpty()){ + parcelListService.updateBatchById(updateParcelListList); + } + if(!updateStockListList.isEmpty()){ + stockListService.updateBatchById(updateStockListList); + } + } + } + + private void updatePackageAllocationInfo(List orderPackageCodes, String allocationName, Long warehouseId) { + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + //把parcelListEntityList通过orderCode作为key进行分组 + Map> groupedByOrderCode = + parcelListEntityList.stream() + .collect(Collectors.groupingBy(DistributionParcelListEntity::getOrderCode)); + + Set orderCodeSet = groupedByOrderCode.keySet(); + QueryWrapper stockArticleEntityQueryWrapper = new QueryWrapper<>(); + stockArticleEntityQueryWrapper.in("order_code", orderCodeSet) + .eq("warehouse_id",warehouseId); + + List stockArticleEntities = stockArticleService.list(stockArticleEntityQueryWrapper); + //把stockArticleEntities转化成以orderCOde为key的Map + Map stockArticleEntityMap = stockArticleEntities.stream() + .collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, stockArticleEntity -> stockArticleEntity)); + + List updateStockArticleList = new ArrayList<>(); + List updateParcelListList = new ArrayList<>(); + groupedByOrderCode.keySet().forEach(orderCode -> { + List parcelListEntityListByOrderCode = groupedByOrderCode.get(orderCode); + if(!parcelListEntityListByOrderCode.isEmpty()){ + parcelListEntityListByOrderCode.forEach(parcelListEntity -> { + DistributionParcelListEntity updateParcelListEntity = new DistributionParcelListEntity(); + updateParcelListEntity.setId(parcelListEntity.getId()); + updateParcelListEntity.setGoodsAllocation(allocationName); + updateParcelListEntity.setOrderPackageGroundingStatus("20"); + updateParcelListList.add(updateParcelListEntity); + }); + } + + DistributionStockArticleEntity stockArticleEntity = stockArticleEntityMap.get(orderCode); + if (!Objects.isNull(stockArticleEntity)){ + String allocation = stockArticleEntity.getAllocation(); + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + updateStockArticleEntity.setOrderCode(orderCode); + if(StringUtil.isBlank(allocation)){ + updateStockArticleEntity.setAllocation(allocationName); + updateStockArticleList.add(updateStockArticleEntity); + }else{ + if(!allocation.contains(allocationName)){ + String[] split = allocation.split(","); + List allocaationList = new ArrayList<>(Arrays.asList(split)); + allocaationList.add(allocationName); + updateStockArticleEntity.setAllocation(String.join(",",allocaationList)); + updateStockArticleList.add(updateStockArticleEntity); + } + } + } + }); + if(!updateParcelListList.isEmpty()){ + parcelListService.updateBatchById(updateParcelListList); + } + if(!updateStockArticleList.isEmpty()){ + stockArticleService.updateBatchById(updateStockArticleList); + updateStockArticleList.forEach(stockArticleEntity -> { + stockArticleService.updateOrderInfo(stockArticleEntity.getOrderCode(),warehouseId); + }); + } + } + } + + private void downshelfInfo(String msg) { + log.info("##########downshelfInfo: 配送消费下架广播 开始 msg={}",msg); + + if(StringUtil.isNotBlank(msg)){ + JSONObject jsonObject = JSONUtil.parseObj(msg); + Integer dataType = jsonObject.getInt("dataType"); + if(dataType.equals(1)){ + //订制品 + Integer conditions = jsonObject.getInt("conditions"); + JSONArray orderPackageCodeArray = jsonObject.getJSONArray("orderPackageCodes"); + List orderPackageCodes = JSONUtil.toList(orderPackageCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + + if(conditions.equals(1)){ + //订制品 + updatePackageDownInfo(orderPackageCodes, warehouseId); + }else if(conditions.equals(2)){ + //有数据库存品 + updatePackageStockDownInfo(orderPackageCodes, warehouseId); + } + }else if(dataType.equals(2)){ + //零担 + JSONArray orderCodeArray = jsonObject.getJSONArray("orderCodes"); + List orderCodes = JSONUtil.toList(orderCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String allocationName = jsonObject.getStr("allocationName"); + + updateZeroDownInfo(orderCodes, allocationName, warehouseId); + }else if (dataType.equals(3)){ + //无数据库存品 + JSONArray stockListIdArray = jsonObject.getJSONArray("stockListIds"); + List stockListIds = JSONUtil.toList(stockListIdArray, Long.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String allocationName = jsonObject.getStr("allocationName"); + + updateStockListDownInfo(stockListIds,warehouseId,allocationName); + } + } + + log.info("##########downshelfInfo: 配送消费下架广播 结束 msg={}",msg); + } + + private void updateStockListDownInfo(List stockListIds, Long warehouseId, String allocationName) { + List stockListEntityList = stockListService.listByIds(stockListIds); + + List clearAllocationStockListIds = new ArrayList<>(); + List updateAllocationList = new ArrayList<>(); + stockListEntityList.forEach(stockListEntity -> { + String storageLocation = stockListEntity.getStorageLocation(); + if(StringUtil.isNotBlank(storageLocation)){ + String[] split = storageLocation.split(","); + List allocationList = new ArrayList<>(Arrays.asList(split)); + allocationList.remove(allocationName); + if(allocationList.isEmpty()){ + clearAllocationStockListIds.add(stockListEntity.getId()); + }else{ + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListEntity.getId()); + updateStockListEntity.setStorageLocation(String.join(",", allocationList)); + updateAllocationList.add(updateStockListEntity); + } + + } + }); + if(!clearAllocationStockListIds.isEmpty()){ + stockListService.clearAllocationByIds(clearAllocationStockListIds); + } + if(!updateAllocationList.isEmpty()){ + stockListService.updateBatchById(updateAllocationList); + } + + } + + private void updateZeroDownInfo(List orderCodes, String allocationName, Long warehouseId) { + QueryWrapper stockArticleEntityQueryWrapper = new QueryWrapper<>(); + stockArticleEntityQueryWrapper.in("order_code", orderCodes) + .eq("warehouse_id", warehouseId); + List stockArticleEntityList = stockArticleService.list(stockArticleEntityQueryWrapper); + + List updateAllocationList = new ArrayList<>(); + List clearAllocationStockArticleIds = new ArrayList<>(); + stockArticleEntityList.forEach(stockArticleEntity -> { + String allocation = stockArticleEntity.getAllocation(); + if(allocation.contains(allocationName)){ + String[] split = allocation.split(","); + List allocationList = new ArrayList<>(Arrays.asList(split)); + allocationList.remove(allocationName); + if(allocationList.isEmpty()){ + clearAllocationStockArticleIds.add(stockArticleEntity.getId()); + }else{ + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + updateStockArticleEntity.setAllocation(String.join(",", allocationList)); + updateAllocationList.add(updateStockArticleEntity); + } + + } + }); + if(!clearAllocationStockArticleIds.isEmpty()){ + stockArticleService.clearAllocationByIds(clearAllocationStockArticleIds); + } + if(!updateAllocationList.isEmpty()){ + stockArticleService.updateBatchById(updateAllocationList); + } + + } + + private void updatePackageStockDownInfo(List orderPackageCodes, Long warehouseId) { + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + //把parcelListEntityList中所有元素放入一个List + List parcelListIdList = parcelListEntityList.stream() + .map(DistributionParcelListEntity::getId) + .collect(Collectors.toList()); + + QueryWrapper stockListInfoEntityQueryWrapper = new QueryWrapper<>(); + stockListInfoEntityQueryWrapper.in("parcel_list_id", parcelListIdList); + List stockListInfoEntities = stockListInfoService.list(stockListInfoEntityQueryWrapper); + //把stockListInfoEntities通过stockListId进行分组 + Map> groupedByStockListId = + stockListInfoEntities.stream() + .collect(Collectors.groupingBy(DistributionStockListInfoEntity::getStockListId)); + + List clearAllocationStockListIds = new ArrayList<>(); + List updateAllocationStockListList = new ArrayList<>(); + groupedByStockListId.keySet().forEach(stockListId -> { + List stockListInfoEntityList = groupedByStockListId.get(stockListId); + //把stockListInfoEntityList中所有元素的parcelListId放入一个List + List parcelListIds = stockListInfoEntityList.stream() + .map(DistributionStockListInfoEntity::getParcelListId) + .collect(Collectors.toList()); + + String allocations = stockListInfoService.findAllAllocationByNoParcelListIdsAndStockListId(parcelListIds, stockListId); + if(StringUtil.isBlank(allocations)){ + clearAllocationStockListIds.add(stockListId); + }else{ + DistributionStockListEntity updateStockListEntity = new DistributionStockListEntity(); + updateStockListEntity.setId(stockListId); + updateStockListEntity.setStorageLocation(allocations); + updateAllocationStockListList.add(updateStockListEntity); + } + }); + + if(!parcelListIdList.isEmpty()){ + parcelListService.clearAllocationByIds(parcelListIdList); + } + if(!clearAllocationStockListIds.isEmpty()){ + stockListService.clearAllocationByIds(clearAllocationStockListIds); + } + if(!updateAllocationStockListList.isEmpty()){ + stockListService.updateBatchById(updateAllocationStockListList); + } + } + } + + private void updatePackageDownInfo(List orderPackageCodes, Long warehouseId) { + QueryWrapper parcelListEntityQueryWrapper = new QueryWrapper<>(); + parcelListEntityQueryWrapper.in("order_package_code", orderPackageCodes) + .eq("warehouse_id", warehouseId); + List parcelListEntityList = parcelListService.list(parcelListEntityQueryWrapper); + + if(!parcelListEntityList.isEmpty()){ + //把parcelListEntityList通过orderCode作为key进行分组 + Map> groupedByOrderCode = + parcelListEntityList.stream() + .collect(Collectors.groupingBy(DistributionParcelListEntity::getOrderCode)); + + Set orderCodeSet = groupedByOrderCode.keySet(); + QueryWrapper stockArticleEntityQueryWrapper = new QueryWrapper<>(); + stockArticleEntityQueryWrapper.in("order_code", orderCodeSet) + .eq("warehouse_id",warehouseId); + + List stockArticleEntities = stockArticleService.list(stockArticleEntityQueryWrapper); + //把stockArticleEntities转化成以orderCOde为key的Map + Map stockArticleEntityMap = stockArticleEntities.stream() + .collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, stockArticleEntity -> stockArticleEntity)); + + List updateAllocationStockArticleList = new ArrayList<>(); + List clearAllocationStockArticleIdList = new ArrayList<>(); + List clearAllocationPraceListIdList = new ArrayList<>(); + Set updateOrderInfoSet = new HashSet<>(); + groupedByOrderCode.keySet().forEach(orderCode -> { + List parcelListEntityListByOrderCode = groupedByOrderCode.get(orderCode); + if(!parcelListEntityListByOrderCode.isEmpty()){ + //把parcelListEntityListByOrderCode中所有元素的id放入一个List集合 + List parcelListIdList = parcelListEntityListByOrderCode.stream() + .map(DistributionParcelListEntity::getId) + .collect(Collectors.toList()); + + clearAllocationPraceListIdList.addAll(parcelListIdList); + + String allocations = parcelListService.findAllAllocationByNoParcelListIds(parcelListIdList,orderCode); + DistributionStockArticleEntity stockArticleEntity = stockArticleEntityMap.get(orderCode); + if(StringUtil.isBlank(allocations)){ + clearAllocationStockArticleIdList.add(stockArticleEntity.getId()); + }else{ + DistributionStockArticleEntity updateStockArticleEntity = new DistributionStockArticleEntity(); + updateStockArticleEntity.setId(stockArticleEntity.getId()); + updateStockArticleEntity.setAllocation(allocations); + updateAllocationStockArticleList.add(updateStockArticleEntity); + } + updateOrderInfoSet.add(orderCode); + } + }); + if(!clearAllocationPraceListIdList.isEmpty()){ + parcelListService.clearAllocationByIds(clearAllocationPraceListIdList); + } + if(!clearAllocationStockArticleIdList.isEmpty()){ + stockArticleService.clearAllocationByIds(clearAllocationStockArticleIdList); + } + if(!updateAllocationStockArticleList.isEmpty()){ + stockArticleService.updateBatchById(updateAllocationStockArticleList); + } + + if(!updateOrderInfoSet.isEmpty()){ + updateOrderInfoSet.forEach(orderCode -> { + stockArticleService.updateOrderInfo(orderCode,warehouseId); + }); + } + } + } + + + /** + * 移库操作(逻辑有问题不正确) + * @param msg + */ + private void moveAllocaitonInfo(String msg) { + log.info("##########downshelfInfo: 配送消费移库广播 开始 msg={}",msg); + + if(StringUtil.isNotBlank(msg)){ + JSONObject jsonObject = JSONUtil.parseObj(msg); + Integer dataType = jsonObject.getInt("dataType"); + if(dataType.equals(1)){ + //订制品 + Integer conditions = jsonObject.getInt("conditions"); + JSONArray orderPackageCodeArray = jsonObject.getJSONArray("orderPackageCodes"); + List orderPackageCodes = JSONUtil.toList(orderPackageCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + + if(conditions.equals(1)){ + //订制品 + updatePackageDownInfo(orderPackageCodes, warehouseId); + }else if(conditions.equals(2)){ + //有数据库存品 + updatePackageStockDownInfo(orderPackageCodes, warehouseId); + } + }else if(dataType.equals(2)){ + //零担 + JSONArray orderCodeArray = jsonObject.getJSONArray("orderCodes"); + List orderCodes = JSONUtil.toList(orderCodeArray, String.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String allocationName = jsonObject.getStr("allocationName"); + + updateZeroDownInfo(orderCodes, allocationName, warehouseId); + }else if (dataType.equals(3)){ + //无数据库存品 + JSONArray stockListIdArray = jsonObject.getJSONArray("stockListIds"); + List stockListIds = JSONUtil.toList(stockListIdArray, Long.class); + Long warehouseId = jsonObject.getLong("warehouseId"); + String allocationName = jsonObject.getStr("allocationName"); + + updateStockListDownInfo(stockListIds,warehouseId,allocationName); + } + } + + log.info("##########downshelfInfo: 配送消费移库广播 结束 msg={}",msg); + } + +} 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 facf16eed..ea2c3d3c5 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 @@ -246,4 +246,12 @@ public interface IDistributionParcelListService extends BaseService findALLNoUpShelfPackageByOrderCodeList(List orderCodeList, Long warehouseId); List findOrderCodesByOrderPackageCodes(List orderPackageCodes, Long warehouseId); + + String findAllTraysByNoParcelListIds(List parcelListIdList,String orderCode); + + void clearPalletByIds(List clearTrayList); + + String findAllAllocationByNoParcelListIds(List parcelListIdList, String orderCode); + + void clearAllocationByIds(List clearTrayList); } 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 f54f83f2f..4b59beeef 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 @@ -299,4 +299,8 @@ public interface IDistributionStockArticleService extends BaseService signforListDetail(Long id); + void clearTraysByIds(List clearTraysStockArticleIdList); + + void clearAllocationByIds(List clearAllocationStockArticleIdList); + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockListInfoService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockListInfoService.java index ccfe25231..a175dd4cf 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockListInfoService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockListInfoService.java @@ -60,4 +60,8 @@ public interface IDistributionStockListInfoService extends BaseService getAllOrderPackageCodes(String incomingBatch, String sku, Long mallId, Long warehouseId); + String findAllTraysByNoParcelListIdsAndStockListId(List parcelListIds, Long stockListId); + + String findAllAllocationByNoParcelListIdsAndStockListId(List parcelListIds, Long stockListId); + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockListService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockListService.java index b9650dab5..5951d9fab 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockListService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockListService.java @@ -214,6 +214,11 @@ public interface IDistributionStockListService extends BaseService clearTrayStockListIds); + + void clearAllocationByIds(List clearAllocationStockListIds); + + // /** // * 查询库存品详情 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 b09821dea..9c7a5acba 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 @@ -1297,6 +1297,26 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl parcelListIdList,String orderCode) { + return baseMapper.findAllTraysByNoParcelListIds(parcelListIdList,orderCode); + } + + @Override + public void clearPalletByIds(List clearTrayList) { + baseMapper.clearPalletByIds(clearTrayList); + } + + @Override + public String findAllAllocationByNoParcelListIds(List parcelListIdList, String orderCode) { + return baseMapper.findAllAllocationByNoParcelListIds(parcelListIdList,orderCode); + } + + @Override + public void clearAllocationByIds(List clearTrayList) { + baseMapper.clearAllocationByIds(clearTrayList); + } + private JSONObject handleLogJSONObject(BasicdataWarehouseEntity warehouse, BladeUser user, String orderPackageCode, String content, Integer node) { JSONObject trunklinePackageTrackLog = new JSONObject(); 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 af92914c2..8979bc0f4 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 @@ -2723,6 +2723,16 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl clearTraysStockArticleIdList) { + baseMapper.clearTraysByIds(clearTraysStockArticleIdList); + } + + @Override + public void clearAllocationByIds(List clearAllocationStockArticleIdList) { + baseMapper.clearAllocationByIds(clearAllocationStockArticleIdList); + } + @Override public R findEditCustomerLog(Long orderId) { diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListInfoServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListInfoServiceImpl.java index 62dfb2586..83f08f0e1 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListInfoServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListInfoServiceImpl.java @@ -16,7 +16,6 @@ */ package com.logpm.distribution.service.impl; -import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.distribution.entity.DistributionStockListInfoEntity; @@ -89,4 +88,14 @@ public class DistributionStockListInfoServiceImpl extends BaseServiceImpl parcelListIds, Long stockListId) { + return baseMapper.findAllTraysByNoParcelListIdsAndStockListId(parcelListIds,stockListId); + } + + @Override + public String findAllAllocationByNoParcelListIdsAndStockListId(List parcelListIds, Long stockListId) { + return baseMapper.findAllAllocationByNoParcelListIdsAndStockListId(parcelListIds,stockListId); + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListServiceImpl.java index e15621a69..0cb196dda 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListServiceImpl.java @@ -918,6 +918,16 @@ public class DistributionStockListServiceImpl extends BaseServiceImpl clearTrayStockListIds) { + baseMapper.clearTraysByIds(clearTrayStockListIds); + } + + @Override + public void clearAllocationByIds(List clearAllocationStockListIds) { + baseMapper.clearAllocationByIds(clearAllocationStockListIds); + } + @Override public OrderPackgeCodeDataVO showInventorySourcePackageCode(String incomingBatch, Long packageIds) throws Exception { diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/controller/WarehouseIndexController.java b/blade-service/logpm-report/src/main/java/com/logpm/report/controller/WarehouseIndexController.java new file mode 100644 index 000000000..331596a45 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/controller/WarehouseIndexController.java @@ -0,0 +1,272 @@ +package com.logpm.report.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.report.dto.IndexDTO; +import com.logpm.report.service.IWarehouseIndexService; +import com.logpm.report.vo.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springblade.common.exception.CustomerException; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Log4j2 +@RestController +@AllArgsConstructor +@RequestMapping("/warehouseIndex") +@Api(value = "仓库首页控制类", tags = "仓库首页数据") +public class WarehouseIndexController { + + private IBasicdataWarehouseClient warehouseClient; + private IWarehouseIndexService warehouseIndexService; + + @ResponseBody + @PostMapping("/openOrderData") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "开单数据", notes = "传入indexDTO") + public R openOrderData(@RequestBody IndexDTO indexDTO) { + String method = "###########openOrderData: "; + log.info(method+"indexDTO={}",indexDTO); + + try{ + List warehouseIds = new ArrayList<>(); + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + List myWatchWarehouse = warehouseClient.getMyWatchWarehouse(); + myWatchWarehouse.forEach(warehouseEntity -> { + warehouseIds.add(warehouseEntity.getId()); + }); + }else{ + warehouseIds.add(myCurrentWarehouse.getId()); + } + indexDTO.setWarehouseIds(warehouseIds); + + //查询订制品打托列表 + IndexOpenOrderDataVO indexOpenOrderDataVO = warehouseIndexService.openOrderData(indexDTO); + return R.data(indexOpenOrderDataVO); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + + @ResponseBody + @PostMapping("/openOrderIncome") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "开单收入数据", notes = "传入indexDTO") + public R openOrderIncome(@RequestBody IndexDTO indexDTO) { + String method = "###########openOrderIncome: "; + log.info(method+"indexDTO={}",indexDTO); + + try{ + List warehouseIds = new ArrayList<>(); + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + List myWatchWarehouse = warehouseClient.getMyWatchWarehouse(); + myWatchWarehouse.forEach(warehouseEntity -> { + warehouseIds.add(warehouseEntity.getId()); + }); + }else{ + warehouseIds.add(myCurrentWarehouse.getId()); + } + indexDTO.setWarehouseIds(warehouseIds); + + //查询订制品打托列表 + IndexOpenOrderIncomeVO indexOpenOrderIncomeVO = warehouseIndexService.openOrderIncome(indexDTO); + return R.data(indexOpenOrderIncomeVO); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + + @ResponseBody + @PostMapping("/handOrderData") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "当前在库数据", notes = "传入indexDTO") + public R handOrderData(@RequestBody IndexDTO indexDTO) { + String method = "###########handOrderData: "; + log.info(method+"indexDTO={}",indexDTO); + + try{ + List warehouseIds = new ArrayList<>(); + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + List myWatchWarehouse = warehouseClient.getMyWatchWarehouse(); + myWatchWarehouse.forEach(warehouseEntity -> { + warehouseIds.add(warehouseEntity.getId()); + }); + }else{ + warehouseIds.add(myCurrentWarehouse.getId()); + } + indexDTO.setWarehouseIds(warehouseIds); + + //查询订制品打托列表 + IndexHandOrderDataVO indexHandOrderDataVO = warehouseIndexService.handOrderData(indexDTO); + return R.data(indexHandOrderDataVO); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + @ResponseBody + @PostMapping("/allocationData") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "库位数据", notes = "传入indexDTO") + public R allocationData(@RequestBody IndexDTO indexDTO) { + String method = "###########allocationData: "; + log.info(method+"indexDTO={}",indexDTO); + + try{ + List warehouseIds = new ArrayList<>(); + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + List myWatchWarehouse = warehouseClient.getMyWatchWarehouse(); + myWatchWarehouse.forEach(warehouseEntity -> { + warehouseIds.add(warehouseEntity.getId()); + }); + }else{ + warehouseIds.add(myCurrentWarehouse.getId()); + } + indexDTO.setWarehouseIds(warehouseIds); + + //查询订制品打托列表 + IndexAllocationDataVO indexAllocationDataVO = warehouseIndexService.allocationData(indexDTO); + return R.data(indexAllocationDataVO); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + @ResponseBody + @PostMapping("/trunklineHandOrderData") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "干线待发运数据", notes = "传入indexDTO") + public R trunklineHandOrderData(@RequestBody IndexDTO indexDTO) { + String method = "###########trunklineHandOrderData: "; + log.info(method+"indexDTO={}",indexDTO); + + try{ + List warehouseIds = new ArrayList<>(); + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + List myWatchWarehouse = warehouseClient.getMyWatchWarehouse(); + myWatchWarehouse.forEach(warehouseEntity -> { + warehouseIds.add(warehouseEntity.getId()); + }); + }else{ + warehouseIds.add(myCurrentWarehouse.getId()); + } + indexDTO.setWarehouseIds(warehouseIds); + + //查询订制品打托列表 + IndexTrunklineHandOrderDataVO indexTrunklineHandOrderDataVO = warehouseIndexService.trunklineHandOrderData(indexDTO); + return R.data(indexTrunklineHandOrderDataVO); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + @ResponseBody + @PostMapping("/trunklineCarsData") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "干线车次数据", notes = "传入indexDTO") + public R trunklineCarsData(@RequestBody IndexDTO indexDTO) { + String method = "###########trunklineCarsData: "; + log.info(method+"indexDTO={}",indexDTO); + + try{ + List warehouseIds = new ArrayList<>(); + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + List myWatchWarehouse = warehouseClient.getMyWatchWarehouse(); + myWatchWarehouse.forEach(warehouseEntity -> { + warehouseIds.add(warehouseEntity.getId()); + }); + }else{ + warehouseIds.add(myCurrentWarehouse.getId()); + } + indexDTO.setWarehouseIds(warehouseIds); + + //查询订制品打托列表 + IndexTrunklineCarsDataVO indexTrunklineCarsDataVO = warehouseIndexService.trunklineCarsData(indexDTO); + return R.data(indexTrunklineCarsDataVO); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + @ResponseBody + @PostMapping("/unloadAbnormalData") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "卸车异常数据", notes = "传入indexDTO") + public R unloadAbnormalData(@RequestBody IndexDTO indexDTO) { + String method = "###########unloadAbnormalData: "; + log.info(method+"indexDTO={}",indexDTO); + + try{ + List warehouseIds = new ArrayList<>(); + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + List myWatchWarehouse = warehouseClient.getMyWatchWarehouse(); + myWatchWarehouse.forEach(warehouseEntity -> { + warehouseIds.add(warehouseEntity.getId()); + }); + }else{ + warehouseIds.add(myCurrentWarehouse.getId()); + } + indexDTO.setWarehouseIds(warehouseIds); + + //查询订制品打托列表 + IndexUnloadAbnormalDataVO indexUnloadAbnormalDataVO = warehouseIndexService.unloadAbnormalData(indexDTO); + return R.data(indexUnloadAbnormalDataVO); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/dto/IndexDTO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/dto/IndexDTO.java new file mode 100644 index 000000000..44eeb8159 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/dto/IndexDTO.java @@ -0,0 +1,16 @@ +package com.logpm.report.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +@Data +public class IndexDTO implements Serializable { + + private List warehouseIds; + private Date startDate; + private Date endDate; + +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.java b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.java new file mode 100644 index 000000000..c545ce4b5 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.java @@ -0,0 +1,42 @@ +package com.logpm.report.mapper; + +import com.alibaba.fastjson.JSONObject; +import com.logpm.report.dto.IndexDTO; +import com.logpm.report.vo.IndexHandOrderDataVO; +import com.logpm.report.vo.IndexTrunklineCarsDataVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; + +@Mapper +public interface WarehouseIndexMapper { + + int findTotalNum(@Param("param") IndexDTO indexDTO); + + BigDecimal findTotalFee(@Param("param") IndexDTO indexDTO); + + JSONObject findFeeByDate(@Param("param") IndexDTO indexDTO); + + IndexHandOrderDataVO handOrderData(@Param("param") IndexDTO indexDTO); + + Integer findHandStockListNum(@Param("param") IndexDTO indexDTO); + + Integer findTrayNum(@Param("param") IndexDTO indexDTO); + + Integer findTotalAllocationNum(@Param("param") IndexDTO indexDTO); + + Integer findUseAllocationNum(@Param("param") IndexDTO indexDTO); + + Integer findUpshelfNum(@Param("param") IndexDTO indexDTO); + + JSONObject findPackageTrunklineHandOrderData(@Param("param") IndexDTO indexDTO); + + JSONObject findZeroTrunklineHandOrderData(@Param("param") IndexDTO indexDTO); + + IndexTrunklineCarsDataVO trunklineCarsData(@Param("param") IndexDTO indexDTO); + + JSONObject findAbnormalData(@Param("param") IndexDTO indexDTO); + + Integer findUnloadNum(@Param("param") IndexDTO indexDTO); +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml new file mode 100644 index 000000000..48588e078 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/WarehouseIndexMapper.xml @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java b/blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java new file mode 100644 index 000000000..775bc2128 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/service/IWarehouseIndexService.java @@ -0,0 +1,21 @@ +package com.logpm.report.service; + +import com.logpm.report.dto.IndexDTO; +import com.logpm.report.vo.*; + +public interface IWarehouseIndexService { + IndexOpenOrderDataVO openOrderData(IndexDTO indexDTO); + + IndexOpenOrderIncomeVO openOrderIncome(IndexDTO indexDTO); + + IndexHandOrderDataVO handOrderData(IndexDTO indexDTO); + + IndexAllocationDataVO allocationData(IndexDTO indexDTO); + + IndexTrunklineHandOrderDataVO trunklineHandOrderData(IndexDTO indexDTO); + + IndexTrunklineCarsDataVO trunklineCarsData(IndexDTO indexDTO); + + IndexUnloadAbnormalDataVO unloadAbnormalData(IndexDTO indexDTO); + +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/WarehouseIndexServiceImpl.java b/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/WarehouseIndexServiceImpl.java new file mode 100644 index 000000000..a245ffb37 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/WarehouseIndexServiceImpl.java @@ -0,0 +1,239 @@ +package com.logpm.report.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.logpm.report.dto.IndexDTO; +import com.logpm.report.mapper.WarehouseIndexMapper; +import com.logpm.report.service.IWarehouseIndexService; +import com.logpm.report.vo.*; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.utils.CommonUtil; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +@Slf4j +@Service +@AllArgsConstructor +public class WarehouseIndexServiceImpl implements IWarehouseIndexService { + + private WarehouseIndexMapper warehouseIndexMapper; + + @Override + public IndexOpenOrderDataVO openOrderData(IndexDTO indexDTO) { + List warehouseIds = indexDTO.getWarehouseIds(); + IndexOpenOrderDataVO indexOpenOrderDataVO = new IndexOpenOrderDataVO(); + if(warehouseIds.isEmpty()){ + return indexOpenOrderDataVO; + } + + indexOpenOrderDataVO.setTotalNum(warehouseIndexMapper.findTotalNum(indexDTO)); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + Date dayStart = calendar.getTime(); + calendar.set(Calendar.HOUR_OF_DAY, 23); + calendar.set(Calendar.MINUTE, 59); + calendar.set(Calendar.SECOND, 59); + calendar.set(Calendar.MILLISECOND, 999); + Date dayEnd = calendar.getTime(); + indexDTO.setStartDate(dayStart); + indexDTO.setEndDate(dayEnd); + indexOpenOrderDataVO.setDayNum(warehouseIndexMapper.findTotalNum(indexDTO)); + // 设置日为1,以获取当前月的第一天 + calendar.set(Calendar.DAY_OF_MONTH, 1); + // 将小时、分钟、秒和毫秒设置为0,确保获取的是完整的第一天 + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + Date firstDayOfMonth = calendar.getTime(); // 获取第一天 + + // 获取下个月的第一天 + calendar.add(Calendar.MONTH, 1); + // 再将日减1,以得到当前月的最后一天 + calendar.set(Calendar.DAY_OF_MONTH, 1); + calendar.add(Calendar.DATE, -1); + // 同样确保时间部分为0 + calendar.set(Calendar.HOUR_OF_DAY, 23); + calendar.set(Calendar.MINUTE, 59); + calendar.set(Calendar.SECOND, 59); + calendar.set(Calendar.MILLISECOND, 999); + Date lastDayOfMonth = calendar.getTime(); // 获取最后一天 + indexDTO.setStartDate(firstDayOfMonth); + indexDTO.setEndDate(lastDayOfMonth); + indexOpenOrderDataVO.setMonthNum(warehouseIndexMapper.findTotalNum(indexDTO)); + + return indexOpenOrderDataVO; + } + + @Override + public IndexOpenOrderIncomeVO openOrderIncome(IndexDTO indexDTO) { + List warehouseIds = indexDTO.getWarehouseIds(); + IndexOpenOrderIncomeVO indexOpenOrderIncomeVO = new IndexOpenOrderIncomeVO(); + if(warehouseIds.isEmpty()){ + return indexOpenOrderIncomeVO; + } + //总收入 + indexOpenOrderIncomeVO.setTotalFee(warehouseIndexMapper.findTotalFee(indexDTO)); + //获取当天的开始时间 + indexDTO.setStartDate(CommonUtil.getDayStart()); + indexDTO.setEndDate(CommonUtil.getDayEnd()); + JSONObject incomeDay = warehouseIndexMapper.findFeeByDate(indexDTO); + indexOpenOrderIncomeVO.setDayFee(incomeDay.getBigDecimal("fee")); + indexOpenOrderIncomeVO.setDayBillladingFee(incomeDay.getBigDecimal("billladingFee")); + indexOpenOrderIncomeVO.setDayInstallFee(incomeDay.getBigDecimal("installFee")); + indexOpenOrderIncomeVO.setDayTrunklineFee(incomeDay.getBigDecimal("trunklineFee")); + indexOpenOrderIncomeVO.setDayWarehouseFee(incomeDay.getBigDecimal("warehouseFee")); + indexOpenOrderIncomeVO.setDayDistributionFee(incomeDay.getBigDecimal("distributionFee")); + //获取当月的开始时间 + indexDTO.setStartDate(CommonUtil.getMonthDayStart()); + indexDTO.setEndDate(CommonUtil.getMonthDayEnd()); + JSONObject incomeMonth = warehouseIndexMapper.findFeeByDate(indexDTO); + indexOpenOrderIncomeVO.setMonthFee(incomeMonth.getBigDecimal("fee")); + indexOpenOrderIncomeVO.setMonthBillladingFee(incomeMonth.getBigDecimal("billladingFee")); + indexOpenOrderIncomeVO.setMonthInstallFee(incomeMonth.getBigDecimal("installFee")); + indexOpenOrderIncomeVO.setMonthTrunklineFee(incomeMonth.getBigDecimal("trunklineFee")); + indexOpenOrderIncomeVO.setMonthWarehouseFee(incomeMonth.getBigDecimal("warehouseFee")); + indexOpenOrderIncomeVO.setMonthDistributionFee(incomeMonth.getBigDecimal("distributionFee")); + + return indexOpenOrderIncomeVO; + } + + @Override + public IndexHandOrderDataVO handOrderData(IndexDTO indexDTO) { + List warehouseIds = indexDTO.getWarehouseIds(); + IndexHandOrderDataVO indexHandOrderDataVO = new IndexHandOrderDataVO(); + if(warehouseIds.isEmpty()){ + return indexHandOrderDataVO; + } + //当前在库的数据 订制品 零担 + indexHandOrderDataVO = warehouseIndexMapper.handOrderData(indexDTO); + //当前在库的库存品 + Integer stockListNum = warehouseIndexMapper.findHandStockListNum(indexDTO); + indexHandOrderDataVO.setTotalNum(indexHandOrderDataVO.getTotalNum() + stockListNum); + + //已打托数量 + Integer trayNum = warehouseIndexMapper.findTrayNum(indexDTO); + indexHandOrderDataVO.setTrayNum(trayNum); + + return indexHandOrderDataVO; + } + + @Override + public IndexAllocationDataVO allocationData(IndexDTO indexDTO) { + List warehouseIds = indexDTO.getWarehouseIds(); + IndexAllocationDataVO indexAllocationDataVO = new IndexAllocationDataVO(); + if(warehouseIds.isEmpty()){ + return indexAllocationDataVO; + } + //当前在库的数据 订制品 零担 + IndexHandOrderDataVO indexHandOrderDataVO = warehouseIndexMapper.handOrderData(indexDTO); + //当前在库的库存品 + Integer stockListNum = warehouseIndexMapper.findHandStockListNum(indexDTO); + Integer totalNum = indexHandOrderDataVO.getTotalNum() + stockListNum; + + //查询库位总数 + Integer totalAllocationNum = warehouseIndexMapper.findTotalAllocationNum(indexDTO); + //已使用库位数 + Integer useAllocationNum = warehouseIndexMapper.findUseAllocationNum(indexDTO); + //已上架件数 + Integer upshelfNum = warehouseIndexMapper.findUpshelfNum(indexDTO); + + indexAllocationDataVO.setTotalNum(totalAllocationNum); + indexAllocationDataVO.setUseNum(useAllocationNum); + indexAllocationDataVO.setNullNum(totalAllocationNum - useAllocationNum); + indexAllocationDataVO.setUpshelfNum(upshelfNum); + indexAllocationDataVO.setNoUpshelfNum(totalNum-upshelfNum); + + return indexAllocationDataVO; + } + + @Override + public IndexTrunklineHandOrderDataVO trunklineHandOrderData(IndexDTO indexDTO) { + List warehouseIds = indexDTO.getWarehouseIds(); + IndexTrunklineHandOrderDataVO indexTrunklineHandOrderDataVO = new IndexTrunklineHandOrderDataVO(); + if(warehouseIds.isEmpty()){ + return indexTrunklineHandOrderDataVO; + } + + //订制品 + JSONObject packageJson = warehouseIndexMapper.findPackageTrunklineHandOrderData(indexDTO); + Integer packageWaybillNum = packageJson.getInteger("waybillNum"); + Integer packageHandleNum = packageJson.getInteger("handleNum"); + BigDecimal packageHandleWeight = packageJson.getBigDecimal("handleWeight"); + BigDecimal packageHandleVolume = packageJson.getBigDecimal("handleVolume"); + //零担 + JSONObject zeroJson = warehouseIndexMapper.findZeroTrunklineHandOrderData(indexDTO); + Integer zeroWaybillNum = zeroJson.getInteger("waybillNum"); + Integer zeroHandleNum = zeroJson.getInteger("handleNum"); + BigDecimal zeroHandleWeight = zeroJson.getBigDecimal("handleWeight"); + BigDecimal zeroHandleVolume = zeroJson.getBigDecimal("handleVolume"); + + indexTrunklineHandOrderDataVO.setWaybillNum(packageWaybillNum + zeroWaybillNum); + indexTrunklineHandOrderDataVO.setHandleNum(packageHandleNum + zeroHandleNum); + indexTrunklineHandOrderDataVO.setHandleWeight(packageHandleWeight.add(zeroHandleWeight)); + indexTrunklineHandOrderDataVO.setHandleVolume(packageHandleVolume.add(zeroHandleVolume)); + + return indexTrunklineHandOrderDataVO; + } + + @Override + public IndexTrunklineCarsDataVO trunklineCarsData(IndexDTO indexDTO) { + List warehouseIds = indexDTO.getWarehouseIds(); + IndexTrunklineCarsDataVO indexTrunklineCarsDataVO = new IndexTrunklineCarsDataVO(); + if(warehouseIds.isEmpty()){ + return indexTrunklineCarsDataVO; + } + + indexTrunklineCarsDataVO = warehouseIndexMapper.trunklineCarsData(indexDTO); + + return indexTrunklineCarsDataVO; + } + + @Override + public IndexUnloadAbnormalDataVO unloadAbnormalData(IndexDTO indexDTO) { + List warehouseIds = indexDTO.getWarehouseIds(); + IndexUnloadAbnormalDataVO indexUnloadAbnormalDataVO = new IndexUnloadAbnormalDataVO(); + if(warehouseIds.isEmpty()){ + return indexUnloadAbnormalDataVO; + } + + indexDTO.setStartDate(CommonUtil.getDayStart()); + indexDTO.setEndDate(CommonUtil.getDayEnd()); + JSONObject dayJson = warehouseIndexMapper.findAbnormalData(indexDTO); + Integer sendDayNum = dayJson.getInteger("sendNum"); + Integer dealDayNum = dayJson.getInteger("dealNum"); + Integer unloadDayNum = warehouseIndexMapper.findUnloadNum(indexDTO); + indexUnloadAbnormalDataVO.setSendDayNum(sendDayNum); + indexUnloadAbnormalDataVO.setNoDealDayNum(sendDayNum - dealDayNum); + indexUnloadAbnormalDataVO.setUnloadDayNum(unloadDayNum); + BigDecimal dayRate = BigDecimal.ZERO; + if(!unloadDayNum.equals(0)){ + dayRate = new BigDecimal(sendDayNum).divide(new BigDecimal(unloadDayNum), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)); + } + indexUnloadAbnormalDataVO.setAbnormalDayRate(dayRate); + + indexDTO.setStartDate(CommonUtil.getMonthDayStart()); + indexDTO.setEndDate(CommonUtil.getMonthDayEnd()); + JSONObject monthJson = warehouseIndexMapper.findAbnormalData(indexDTO); + Integer sendMonthNum = monthJson.getInteger("sendNum"); + Integer dealMonthNum = monthJson.getInteger("dealNum"); + Integer unloadMonthNum = warehouseIndexMapper.findUnloadNum(indexDTO); + indexUnloadAbnormalDataVO.setSendMonthNum(sendMonthNum); + indexUnloadAbnormalDataVO.setNoDealMonthNum(sendMonthNum - dealMonthNum); + indexUnloadAbnormalDataVO.setUnloadMonthNum(unloadMonthNum); + BigDecimal monthRate = BigDecimal.ZERO; + if(!unloadMonthNum.equals(0)){ + monthRate = new BigDecimal(sendMonthNum).divide(new BigDecimal(unloadMonthNum),4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)); + } + indexUnloadAbnormalDataVO.setAbnormalMonthRate(monthRate); + + return indexUnloadAbnormalDataVO; + } +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexAllocationDataVO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexAllocationDataVO.java new file mode 100644 index 000000000..12f3870a6 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexAllocationDataVO.java @@ -0,0 +1,16 @@ +package com.logpm.report.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class IndexAllocationDataVO implements Serializable { + + private Integer totalNum = 0; + private Integer useNum = 0; + private Integer nullNum = 0; + private Integer upshelfNum = 0; + private Integer noUpshelfNum = 0; + +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexHandOrderDataVO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexHandOrderDataVO.java new file mode 100644 index 000000000..8d59c291c --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexHandOrderDataVO.java @@ -0,0 +1,18 @@ +package com.logpm.report.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class IndexHandOrderDataVO implements Serializable { + + private Integer totalNum = 0; + private Integer zeroNum = 0; + private Integer thirdTransferNum = 0; + private Integer mallNum = 0; + private Integer cityNum = 0; + private Integer billNum = 0; + private Integer trayNum = 0; + +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexOpenOrderDataVO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexOpenOrderDataVO.java new file mode 100644 index 000000000..15ea76511 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexOpenOrderDataVO.java @@ -0,0 +1,15 @@ +package com.logpm.report.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class IndexOpenOrderDataVO implements Serializable { + + + private int totalNum = 0; + private int monthNum = 0; + private int dayNum = 0; + +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexOpenOrderIncomeVO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexOpenOrderIncomeVO.java new file mode 100644 index 000000000..d81dcf4c0 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexOpenOrderIncomeVO.java @@ -0,0 +1,26 @@ +package com.logpm.report.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class IndexOpenOrderIncomeVO implements Serializable { + + private BigDecimal totalFee = BigDecimal.ZERO; + private BigDecimal monthFee = BigDecimal.ZERO; + private BigDecimal monthTrunklineFee = BigDecimal.ZERO; + private BigDecimal monthWarehouseFee = BigDecimal.ZERO; + private BigDecimal monthDistributionFee = BigDecimal.ZERO; + private BigDecimal monthBillladingFee = BigDecimal.ZERO; + private BigDecimal monthInstallFee = BigDecimal.ZERO; + private BigDecimal dayFee = BigDecimal.ZERO; + private BigDecimal dayTrunklineFee = BigDecimal.ZERO; + private BigDecimal dayWarehouseFee = BigDecimal.ZERO; + private BigDecimal dayDistributionFee = BigDecimal.ZERO; + private BigDecimal dayBillladingFee = BigDecimal.ZERO; + private BigDecimal dayInstallFee = BigDecimal.ZERO; + + +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexTrunklineCarsDataVO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexTrunklineCarsDataVO.java new file mode 100644 index 000000000..a03935af9 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexTrunklineCarsDataVO.java @@ -0,0 +1,16 @@ +package com.logpm.report.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class IndexTrunklineCarsDataVO implements Serializable { + + private Integer totalNum = 0; + private Integer inTransitNum = 0; + private Integer workNum = 0; + private Integer unloadNum = 0; + + +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexTrunklineHandOrderDataVO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexTrunklineHandOrderDataVO.java new file mode 100644 index 000000000..480f3e58a --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexTrunklineHandOrderDataVO.java @@ -0,0 +1,16 @@ +package com.logpm.report.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class IndexTrunklineHandOrderDataVO implements Serializable { + + private Integer waybillNum = 0; + private Integer handleNum = 0; + private BigDecimal handleWeight = BigDecimal.ZERO; + private BigDecimal handleVolume = BigDecimal.ZERO; + +} diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexUnloadAbnormalDataVO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexUnloadAbnormalDataVO.java new file mode 100644 index 000000000..66fc26049 --- /dev/null +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/vo/IndexUnloadAbnormalDataVO.java @@ -0,0 +1,21 @@ +package com.logpm.report.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class IndexUnloadAbnormalDataVO implements Serializable { + + private Integer sendDayNum = 0; + private Integer noDealDayNum = 0; + private Integer unloadDayNum = 0; + private BigDecimal abnormalDayRate = BigDecimal.ZERO; + + private Integer sendMonthNum = 0; + private Integer noDealMonthNum = 0; + private Integer unloadMonthNum = 0; + private BigDecimal abnormalMonthRate = BigDecimal.ZERO; + +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadLogServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadLogServiceImpl.java index a1e27f869..2145fb518 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadLogServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadLogServiceImpl.java @@ -1,10 +1,13 @@ package com.logpm.trunkline.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.logpm.trunkline.entity.TrunklineCarsLoadEntity; import com.logpm.trunkline.entity.TrunklineCarsLoadLineEntity; import com.logpm.trunkline.entity.TrunklineCarsLoadLogEntity; +import com.logpm.trunkline.entity.TrunklineCarsLoadScanEntity; import com.logpm.trunkline.mapper.TrunklineCarsLoadLogMapper; import com.logpm.trunkline.service.ITrunklineCarsLoadLogService; +import com.logpm.trunkline.service.ITrunklineCarsLoadScanService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.carsload.CarsLoadLogTypeConstant; @@ -14,12 +17,16 @@ import org.springblade.core.secure.utils.AuthUtil; import org.springframework.stereotype.Service; import java.util.Date; +import java.util.List; import java.util.Objects; @Slf4j @Service @AllArgsConstructor public class TrunklineCarsLoadLogServiceImpl extends BaseServiceImpl implements ITrunklineCarsLoadLogService { + + private final ITrunklineCarsLoadScanService carsLoadScanService; + @Override public void saveLog(TrunklineCarsLoadEntity carsLoadEntity, TrunklineCarsLoadLineEntity carsLoadLineEntity, int cardLoadType) { String nodeName = null; @@ -34,6 +41,7 @@ public class TrunklineCarsLoadLogServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("load_id",loadId) + .eq("scan_status","3"); + List list = carsLoadScanService.list(queryWrapper); + Integer signNum = 0; + if(!list.isEmpty()){ + signNum = list.size(); + } + content = "【"+nodeName+"】三方中转签收,车次号:"+carsNo+",车牌号:"+carNumber+",司机姓名:"+driverName+ + ",司机手机号:"+driverMobile+",签收件数:"+ signNum + "/" + realLoadingNumber + "件"; + break; + case 17: + content = "【"+nodeName+"】三方中转结算,车次号:"+carsNo+",车牌号:"+carNumber+",司机姓名:"+driverName+ + ",司机手机号:"+driverMobile+",结算时间:"+ now; + break; + case 18: + content = "【"+nodeName+"】直发商家签收,车次号:"+carsNo+",车牌号:"+carNumber+",司机姓名:"+driverName+ + ",司机手机号:"+driverMobile+",签收时间:"+ now; + break; default: content = "【"+nodeName+"】其他日志,车次号:"+carsNo+",车牌号:"+carNumber+",司机姓名:"+driverName+ ",司机手机号:"+driverMobile; @@ -124,6 +152,21 @@ public class TrunklineCarsLoadLogServiceImpl extends BaseServiceImpl qw = new QueryWrapper<>(); + qw.eq("node_id",nodeId) + .eq("load_id",loadId) + .eq("type",cardLoadType); + TrunklineCarsLoadLogEntity carsLoadLogEntity1 = baseMapper.selectOne(qw); + if(Objects.isNull(carsLoadLogEntity1)){ + save(carsLoadLogEntity); + }else{ + carsLoadLogEntity1.setContent(content); + updateById(carsLoadLogEntity1); + } + }else{ + save(carsLoadLogEntity); + } } } 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 a092d6819..f769793cc 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 @@ -2028,6 +2028,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl orderPackageCodes = trunklineCarsLoadScanService.findSignListOrderPackageCodes(loadId); String content = "包件在" + warehouseEntity.getName() + "被三方中转整车签收"; @@ -2065,6 +2067,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl findWaybillBilllByWaybillNos(@Param("waybillNos") List waybillNos); List exportWaybillList(@Param("param") WarehouseWaybillDTO waybillDTO); + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/ISendFanoutService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/ISendFanoutService.java new file mode 100644 index 000000000..b0ee5b3ff --- /dev/null +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/ISendFanoutService.java @@ -0,0 +1,7 @@ +package com.logpm.warehouse.service; + +import org.springblade.common.model.FanoutMsg; + +public interface ISendFanoutService { + void sendFanoutMsg(FanoutMsg fanoutMsg); +} diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWaybillService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWaybillService.java index 41f1fe4c3..913652622 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWaybillService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseWaybillService.java @@ -80,4 +80,5 @@ public interface IWarehouseWaybillService extends BaseService findWaybillBilllByWaybillNos(List waybillNos); List exportWaybillList(WarehouseWaybillDTO waybillDTO); + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/SendFanoutServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/SendFanoutServiceImpl.java new file mode 100644 index 000000000..7e42c6b3a --- /dev/null +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/SendFanoutServiceImpl.java @@ -0,0 +1,27 @@ +package com.logpm.warehouse.service.impl; + +import com.logpm.warehouse.service.ISendFanoutService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.model.FanoutMsg; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.stereotype.Service; + +@Service +@AllArgsConstructor +@Slf4j +public class SendFanoutServiceImpl implements ISendFanoutService { + + private final RabbitTemplate rabbitTemplate; + +// @Retryable(value = Exception.class, maxAttempts = 3, backoff = @Backoff(value = 3000, multiplier = 1.5)) + @Override + public void sendFanoutMsg(FanoutMsg fanoutMsg) { + + rabbitTemplate.convertAndSend(fanoutMsg.getExchange(),null, fanoutMsg.getMsg(), message -> { + message.getMessageProperties().setHeader("x-delay", 1000); + return message; + }); + + } +} 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 0d304e75e..94fc2c747 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 @@ -39,12 +39,14 @@ import lombok.extern.log4j.Log4j2; import org.springblade.common.constant.DictBizConstant; import org.springblade.common.constant.TenantNum; import org.springblade.common.constant.apiwarehouse.PalletProductTypeConstant; +import org.springblade.common.constant.broadcast.FanoutConstants; import org.springblade.common.constant.order.OrderFreezeStatusConstant; import org.springblade.common.constant.order.OrderGroundingStatusConstant; import org.springblade.common.constant.order.OrderReservationStatusConstant; import org.springblade.common.constant.order.OrderStockupStatusConstant; import org.springblade.common.constant.orderpackage.*; import org.springblade.common.exception.CustomerException; +import org.springblade.common.model.FanoutMsg; import org.springblade.common.utils.CommonUtil; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.redis.cache.BladeRedis; @@ -63,6 +65,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; import java.util.stream.Collectors; @@ -127,6 +130,8 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl orderPackageCodes = new ArrayList<>(); + orderPackageCodes.add(orderPackageCode); + jsonObject.put("orderPackageCodes",orderPackageCodes); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + if(chuanFlag){ log.warn("#########orderScanOrderPackageCode: 不属于同一个"+msg+" 串货 filterValue={} orderPackageCode={}",filterValue,orderPackageCode); return Resp.scanFail(2001,"不属于同一个"+msg,"窜货,扫描当前托盘"+msg+",窜货1件"); @@ -875,6 +900,37 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl> parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + parcelListEntityMap.keySet().forEach(conditions -> { + List ls = parcelListEntityMap.get(conditions); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("conditions",conditions); + jsonObject.put("operation",1); + //把ls中所有元素的orderPackageCode装入一个Set中 + Set orderPackageCodeSet = ls.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toSet()); + + jsonObject.put("orderPackageCodes",new ArrayList<>(orderPackageCodeSet)); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }); + + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + } @@ -1124,6 +1180,24 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl orderPackageCodes = new ArrayList<>(); + orderPackageCodes.add(orderPackageCode); + jsonObject.put("orderPackageCodes",orderPackageCodes); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",basicdataTrayEntity.getPalletName()); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + if(chuanFlag){ log.warn("#########orderScanOrderPackageCode: 不属于同一个"+msg+" 串货 filterValue={} orderPackageCode={}",filterValue,orderPackageCode); return R.success("扫描成功"); @@ -1185,6 +1259,7 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl parcelListEntityList = new ArrayList<>(); for (String orderPackageCode:orderPackageCodes){ WarehouseTrayGoodsEntity trayGoodsEntity = warehouseTrayGoodsService.findByTrayTypeIdAndAssociationValue(trayTypeId,orderPackageCode); if(Objects.isNull(trayGoodsEntity)){ @@ -1197,6 +1272,7 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl> parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + Long finalWarehouseId = warehouseId; + parcelListEntityMap.keySet().forEach(conditions -> { + List ls = parcelListEntityMap.get(conditions); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("conditions",conditions); + jsonObject.put("operation",2); + //把ls中所有元素的orderPackageCode装入一个Set中 + List orderPackageCodeList = ls.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toList()); + + jsonObject.put("orderPackageCodes",orderPackageCodeList); + jsonObject.put("warehouseId", finalWarehouseId); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }); + + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + return R.success("删除成功"); } @@ -1466,8 +1574,10 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl orderCodes = new ArrayList<>(); for(ZeroOrderVO zeroOrderVO:zeroList){ String orderCode = zeroOrderVO.getOrderCode();//订单自编码 + orderCodes.add(orderCode); Long orderId = zeroOrderVO.getOrderId(); Integer num = zeroOrderVO.getNum(); if(num == 0){ @@ -1516,6 +1626,24 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl orderCodes = new ArrayList<>(); for(ZeroOrderVO zeroOrderVO:zeroList){ String orderCode = zeroOrderVO.getOrderCode();//订单自编码 + orderCodes.add(orderCode); Long orderId = zeroOrderVO.getOrderId(); Integer num = zeroOrderVO.getNum(); if(num == 0 || Objects.isNull(num)){ @@ -1625,6 +1755,24 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl orderCodes = new ArrayList<>(); + orderCodes.add(orderCode); + jsonObject.put("orderCodes",orderCodes); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayEntity.getPalletName()); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + return R.success("删除成功"); } @@ -2023,6 +2191,7 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl stockListIds = new ArrayList<>(); + stockListIds.add(stockListId); + jsonObject.put("stockListIds",stockListIds); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + return R.success("删除成功"); } @@ -2199,12 +2389,14 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl stockListIds = new ArrayList<>(); + stockListIds.add(stockListId); + jsonObject.put("stockListIds",stockListIds); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + return Resp.scanSuccess("录入成功","成功录入"+num+"件"); } @@ -2322,6 +2502,11 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl orderPackageCodes = new ArrayList<>(); + orderPackageCodes.add(orderPackageCode); + jsonObject.put("orderPackageCodes",orderPackageCodes); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } }else { stringBuffer.append(orderPackageCode); } @@ -2346,6 +2549,49 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl trayGoodsQueryWrapper = new QueryWrapper<>(); + DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode,warehouseId); + trayGoodsQueryWrapper.eq("association_type","3") + .eq("association_value",orderPackageCode); + WarehouseTrayGoodsEntity trayGoodsEntity = warehouseTrayGoodsService.getOne(trayGoodsQueryWrapper); + StringBuffer stringBuffer = new StringBuffer(); + if (!Objects.isNull(trayGoodsEntity)){ + Long trayGoodsId = trayGoodsEntity.getId(); + Long trayTypeId = trayGoodsEntity.getTrayTypeId(); + Long trayId = trayGoodsEntity.getTrayId(); + String trayCode = trayGoodsEntity.getTrayCode(); + + BasicdataTrayEntity trayEntity = basicdataTrayClient.getTrayByTrayCode(trayCode); + String trayName = trayEntity.getPalletName(); + + WarehouseTrayTypeEntity trayTypeEntity = baseMapper.selectById(trayTypeId); + //解除绑定 + Integer residueNum = warehouseTrayGoodsService.deleteByTrayGoodsId(trayGoodsId,warehouseId); + + if(residueNum == 0){ + //空置托盘 + removeById(trayTypeId); + //更新托盘状态 + basicdataTrayClient.updateTrayStatus(trayId,1); + } + + //添加下托日志 + warehouseTrayGoodsLogService.saveLogPackage(parcelListEntity,trayTypeEntity,"0",remark,"1"); + + updateNumByTrayTypeId(trayTypeEntity); + }else { + stringBuffer.append(orderPackageCode); + } + if (Func.isNotEmpty(stringBuffer)){ + log.error("托盘商品不存在,trayId:{}",stringBuffer.toString()); + } + } + + + + @Transactional(rollbackFor = Exception.class) @Override public void downPackageByOrderPackageCodeList(List orderPackageCodeList,String remark,Long warehouseId) { @@ -2380,6 +2626,7 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl { WarehouseTrayGoodsLogEntity trayGoodsLogEntity = new WarehouseTrayGoodsLogEntity(); @@ -2408,6 +2655,51 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl orderPackageCodes = warehouseTrayGoodsEntities.stream() + .map(WarehouseTrayGoodsEntity::getAssociationValue) + .collect(Collectors.toList()); + + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(orderPackageCodes); + findParamterDTO.setWarehouseId(warehouseId); + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + //把parcelListEntityList通过conditions进行分组 + Map> conditionsToParcelListMap = parcelListEntityList.stream() + .collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + conditionsToParcelListMap.keySet().forEach(conditions -> { + List listEntityList = conditionsToParcelListMap.get(conditions); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("conditions",conditions); + jsonObject.put("operation",2); + //把listEntityList中所有元素的orderPackageCode放入一个List + List packageCodes = listEntityList.stream() + .map(DistributionParcelListEntity::getOrderPackageCode) + .collect(Collectors.toList()); + + jsonObject.put("orderPackageCodes",packageCodes); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }); + + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + } }); @@ -2427,6 +2719,7 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl trayGoodsEntityQueryWrapper = new QueryWrapper<>(); trayGoodsEntityQueryWrapper.eq("tray_type_id",trayTypeId); List trayGoodsList = warehouseTrayGoodsService.list(trayGoodsEntityQueryWrapper); @@ -2502,6 +2797,92 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl> map = trayGoodsList.stream() + .collect(Collectors.groupingBy(WarehouseTrayGoodsEntity::getAssociationType)); + + map.keySet().forEach(associationType -> { + List trayGoodsEntities = map.get(associationType); + if("1".equals(associationType)){ + List orderCodes = trayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toList()); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",2); + jsonObject.put("operation",2); + jsonObject.put("orderCodes",orderCodes); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayEntity.getPalletName()); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + }else if("3".equals(associationType)){ + //获取trayGoodsEntities所有元素的associationValue放入一个List集合 + List orderPackageCodes = trayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toList()); + + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(orderPackageCodes); + findParamterDTO.setWarehouseId(warehouseId); + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + + //把parcelListEntityList中的conditions进行分组 + Map> parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + Long finalWarehouseId = warehouseId; + parcelListEntityMap.keySet().forEach(conditions -> { + List ls = parcelListEntityMap.get(conditions); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("conditions",conditions); + jsonObject.put("operation",2); + + //把ls中所有元素的orderPackageCode装入一个Set中 + List orderPackageCodeList = ls.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toList()); + + jsonObject.put("orderPackageCodes",orderPackageCodeList); + jsonObject.put("warehouseId", finalWarehouseId); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }); + }else if("4".equals(associationType)){ + List stockListIds = new ArrayList<>(); + trayGoodsEntities.forEach(trayGoodsEntity -> { + String materialCode = trayGoodsEntity.getAssociationValue(); + String incomingBatch = trayGoodsEntity.getIncomingBatch(); + Long marketId = trayGoodsEntity.getMarketId(); + DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(marketId, materialCode, incomingBatch, warehouseId); + if(!Objects.isNull(stockListEntity)){ + stockListIds.add(stockListEntity.getId()); + } + }); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",3); + jsonObject.put("operation",2); + jsonObject.put("stockListIds",stockListIds); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + } + }); + + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + + } @Override @@ -2653,6 +3034,11 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("tray_type_id",sourceTrayTypeId); + List sourceTrayGoodsList = warehouseTrayGoodsService.list(queryWrapper); + if(Objects.isNull(targetTrayTypeEntity)){ targetTrayTypeEntity = new WarehouseTrayTypeEntity(); BeanUtil.copy(sourceTrayTypeEntity,targetTrayTypeEntity); @@ -2660,10 +3046,13 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl> map = sourceTrayGoodsList.stream().collect(Collectors.groupingBy(WarehouseTrayGoodsEntity::getAssociationType)); +// +// map.keySet().forEach(associationType -> { +// List trayGoodsEntities = map.get(associationType); +// if("1".equals(associationType)){ +// List orderCodes = trayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toList()); +// +// JSONObject jsonObject = new JSONObject(); +// jsonObject.put("dataType",2); +// jsonObject.put("zeroOrderCodes",orderCodes); +// jsonObject.put("warehouseId",warehouseId); +// jsonObject.put("sourceTrayName",sourceTrayName); +// jsonObject.put("targetTrayName",targetTrayName); +// +// FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.MOVETRAY.EXCHANGE).msg(jsonObject.toJSONString()).build(); +// +// sendFanoutService.sendFanoutMsg(fanoutMsg); +// +// }else if("3".equals(associationType)){ +// //获取trayGoodsEntities所有元素的associationValue放入一个List集合 +// List orderPackageCodes = trayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toList()); +// +// FindParamterDTO findParamterDTO = new FindParamterDTO(); +// findParamterDTO.setOrderCodeList(orderPackageCodes); +// findParamterDTO.setWarehouseId(warehouseId); +// List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); +// +// //把parcelListEntityList中的conditions进行分组 +// Map> parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); +// +// Long finalWarehouseId = warehouseId; +// parcelListEntityMap.keySet().forEach(conditions -> { +// List ls = parcelListEntityMap.get(conditions); +// JSONObject jsonObject = new JSONObject(); +// jsonObject.put("dataType",1); +// jsonObject.put("conditions",conditions); +// +// //把ls中所有元素的orderPackageCode装入一个Set中 +// Set orderPackageCodeSet = ls.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toSet()); +// +// jsonObject.put("orderPackageCodes",new ArrayList<>(orderPackageCodeSet)); +// jsonObject.put("warehouseId", finalWarehouseId); +// jsonObject.put("sourceTrayName",sourceTrayName); +// jsonObject.put("targetTrayName",targetTrayName); +// +// FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.MOVETRAY.EXCHANGE).msg(jsonObject.toJSONString()).build(); +// +// sendFanoutService.sendFanoutMsg(fanoutMsg); +// }); +// }else if("4".equals(associationType)){ +// List stockListIds = new ArrayList<>(); +// trayGoodsEntities.forEach(trayGoodsEntity -> { +// String materialCode = trayGoodsEntity.getAssociationValue(); +// String incomingBatch = trayGoodsEntity.getIncomingBatch(); +// Long marketId = trayGoodsEntity.getMarketId(); +// DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(marketId, materialCode, incomingBatch, warehouseId); +// if(!Objects.isNull(stockListEntity)){ +// stockListIds.add(stockListEntity.getId()); +// } +// }); +// JSONObject jsonObject = new JSONObject(); +// jsonObject.put("dataType",3); +// jsonObject.put("stockListIds",stockListIds); +// jsonObject.put("warehouseId",warehouseId); +// jsonObject.put("sourceTrayName",sourceTrayName); +// jsonObject.put("targetTrayName",targetTrayName); +// +// FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.MOVETRAY.EXCHANGE).msg(jsonObject.toJSONString()).build(); +// +// sendFanoutService.sendFanoutMsg(fanoutMsg); +// } +// }); +// }catch (Exception e){ +// log.warn("###########copyTrayGoodsToTargetTray: 发布广播失败"); +// } + return Resp.scanSuccess("合托成功","成功合托"+(totalNum+stockNum)+"件"); } @@ -2987,7 +3462,7 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl trayGoodsIds,String trayCode,Long warehouseId) { - Integer allNum = 0; + AtomicReference allNum = new AtomicReference<>(0); QueryWrapper trayTypeEntityQueryWrapper = new QueryWrapper<>(); trayTypeEntityQueryWrapper.eq("tray_code",trayCode) .eq("is_deleted",0); @@ -2998,45 +3473,84 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl trayGoodsEntities = warehouseTrayGoodsService.listByIds(trayGoodsIds); + //把trayGoodsEntities通过trayCode作为key进行分组,区分出有哪些托盘对应的包件 + Map> trayGoodsMap = trayGoodsEntities.stream().collect(Collectors.groupingBy(WarehouseTrayGoodsEntity::getTrayCode)); + WarehouseTrayTypeEntity finalTrayTypeEntity = trayTypeEntity; + trayGoodsMap.keySet().forEach(sourceTrayCode -> { + + BasicdataTrayEntity sourceTrayEntity = basicdataTrayClient.getTrayByTrayCode(sourceTrayCode); + String sourceTrayName = sourceTrayEntity.getPalletName(); + + List trayGoodsEntityList = trayGoodsMap.get(sourceTrayCode); + //把trayGoodsEntityList中所有元素的associationValue放入一个List + List orderPackageCodes = trayGoodsEntityList.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toList()); + orderPackageCodes.forEach(orderPackageCode -> { + //下托日志 + downPackageByOrderPackageCode(orderPackageCode,"移托:解除绑定",warehouseId); + + moveTrayOrderPackageCode(finalTrayTypeEntity, orderPackageCode); + + allNum.set(allNum.get() + 1); + }); + +// try{ +// +// FindParamterDTO findParamterDTO = new FindParamterDTO(); +// findParamterDTO.setOrderCodeList(orderPackageCodes); +// findParamterDTO.setWarehouseId(warehouseId); +// List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); +// //把parcelListEntityList通过conditions作为key进行分组,判断当前的包件有哪些是库存品哪些是订制品 +// Map> parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); +// +// parcelListEntityMap.keySet().forEach(conditions -> { +// List ls = parcelListEntityMap.get(conditions); +// //获取conditions对应的包件 +// //把ls中所有元素的orderPackageCode放入一个List +// List orderPackageCodeList = ls.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toList()); +// JSONObject jsonObject = new JSONObject(); +// jsonObject.put("dataType",1); +// jsonObject.put("conditions",conditions); +// jsonObject.put("orderPackageCodes",orderPackageCodeList); +// jsonObject.put("warehouseId", warehouseId); +// jsonObject.put("sourceTrayName",sourceTrayName); +// jsonObject.put("targetTrayName",targetTrayName); +// +// FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.MOVETRAY.EXCHANGE).msg(jsonObject.toJSONString()).build(); +// +// sendFanoutService.sendFanoutMsg(fanoutMsg); +// }); +// }catch (Exception e){ +// log.warn("###########copyTrayGoodsToTargetTray: 发布广播失败"); +// } + + }); - allNum = allNum + num; - } return Resp.scanSuccess("移托成功","成功移托"+allNum+"件"); } @@ -4116,12 +4630,17 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl orderPackageCodes = new ArrayList<>(); + orderPackageCodes.add(orderPackageCode); + jsonObject.put("orderPackageCodes",orderPackageCodes); + jsonObject.put("warehouseId",wid); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + return R.success("操作成功"); } - private void copyTrayGoodsToTargetTray(Long sourceTrayTypeId, WarehouseTrayTypeEntity targetTrayTypeEntity) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("tray_type_id",sourceTrayTypeId); - List sourceTrayGoodsList = warehouseTrayGoodsService.list(queryWrapper); + private void copyTrayGoodsToTargetTray(WarehouseTrayTypeEntity targetTrayTypeEntity,List sourceTrayGoodsList) { + String type = targetTrayTypeEntity.getType();//数据类型 + Long warehouseId = targetTrayTypeEntity.getWarehouseId(); String trayType = targetTrayTypeEntity.getTrayType();//打托方式 Long filterId = targetTrayTypeEntity.getFilterId(); String filterValue = targetTrayTypeEntity.getFilterValue(); + String targetTrayCode = targetTrayTypeEntity.getTrayCode(); + +// String sourceTrayCode = sourceTrayTypeEntity.getTrayCode(); + if("10".equals(trayType)){//服务号 panduanPackageByService(sourceTrayGoodsList,filterId,filterValue,targetTrayTypeEntity); @@ -4243,6 +4784,93 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl> map = sourceTrayGoodsList.stream().collect(Collectors.groupingBy(WarehouseTrayGoodsEntity::getAssociationType)); + map.keySet().forEach(associationType->{ + List trayGoodsEntities = map.get(associationType); + if("1".equals(associationType)){ + List orderCodes = trayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toList()); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",2); + jsonObject.put("operation",1); + jsonObject.put("orderCodes",orderCodes); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + }else if("3".equals(associationType)){ + //获取trayGoodsEntities所有元素的associationValue放入一个List集合 + List orderPackageCodes = trayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toList()); + + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(orderPackageCodes); + findParamterDTO.setWarehouseId(warehouseId); + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + + //把parcelListEntityList中的conditions进行分组 + Map> parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + Long finalWarehouseId = warehouseId; + parcelListEntityMap.keySet().forEach(conditions -> { + List ls = parcelListEntityMap.get(conditions); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("conditions",conditions); + jsonObject.put("operation",1); + //把ls中所有元素的orderPackageCode装入一个Set中 + List orderPackageCodeSet = ls.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toList()); + + jsonObject.put("orderPackageCodes",orderPackageCodeSet); + jsonObject.put("warehouseId", finalWarehouseId); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }); + }else if("4".equals(associationType)){ + List stockListIds = new ArrayList<>(); + trayGoodsEntities.forEach(trayGoodsEntity -> { + String materialCode = trayGoodsEntity.getAssociationValue(); + String incomingBatch = trayGoodsEntity.getIncomingBatch(); + Long marketId = trayGoodsEntity.getMarketId(); + DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(marketId, materialCode, incomingBatch, warehouseId); + if(!Objects.isNull(stockListEntity)){ + stockListIds.add(stockListEntity.getId()); + } + }); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",3); + jsonObject.put("operation",1); + jsonObject.put("stockListIds",stockListIds); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("trayName",trayName); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.TRAYTYPE.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + } + + + }); + + + + + }catch (Exception e){ + + } + + } private void panduanStockByMaterialId(List sourceTrayGoodsList, Long filterId, String filterValue,WarehouseTrayTypeEntity targetTrayTypeEntity) { diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownGoodsServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownGoodsServiceImpl.java index 47eb5bf00..ae2c74c8c 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownGoodsServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownGoodsServiceImpl.java @@ -174,7 +174,7 @@ public class WarehouseUpdownGoodsServiceImpl extends BaseServiceImpl orderPackageCodes) { @@ -941,6 +944,7 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl> map = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + map.keySet().forEach(conditions -> { + List list = map.get(conditions); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("conditions",conditions); + jsonObject.put("operation",3); + //把list中所有元素的orderPackageCode提取出来存入一个List + List orderPackageCodes = list.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toList()); + + jsonObject.put("orderPackageCodes",orderPackageCodes); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }); + + }catch (Exception e){ + log.warn("###########upShelfPackage: 发送打托广播失败"); + } + + // for (UpShelfPackageDTO upShelfPackageDTO : upShelfPackageList) { // String orderPackageCode = upShelfPackageDTO.getOrderPackageCode(); // log.info("##############upShelfPackage: 当前处理的包件码 orderPackageCode={}", orderPackageCode); @@ -1159,6 +1192,7 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl orderCodes = new ArrayList<>(); for (UpShelfZeroOrderDTO upShelfZeroOrderDTO : upShelfZeroOrderList) { num = num + upShelfZeroOrderDTO.getEnterNum(); - updateZeroOrderGroundingStatus(upShelfZeroOrderDTO.getOrderCode(), warehouseId); + orderCodes.add(upShelfZeroOrderDTO.getOrderCode()); +// updateZeroOrderGroundingStatus(upShelfZeroOrderDTO.getOrderCode(), warehouseId); } updateUpdownTypeNum(updownTypeEntity); @@ -1225,6 +1262,24 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl 0) { msg = msg + s + "超出输入数量,或输入数量为0,请输入正确数量再进行操作"; } + + try{ + + List stockListIds = new ArrayList<>(); + upShelfStockList.forEach(upShelfStockDTO -> { + String materialCode = upShelfStockDTO.getMaterialCode(); + String incomingBatch = upShelfStockDTO.getIncomingBatch(); + Long marketId = upShelfStockDTO.getMarketId(); + DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(marketId, materialCode, incomingBatch, warehouseId); + if(!Objects.isNull(stockListEntity)){ + stockListIds.add(stockListEntity.getId()); + } + }); + + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",3); + jsonObject.put("operation",3); + jsonObject.put("stockListIds",stockListIds); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + return Resp.scanSuccess(msg, "成功上架" + num + "件"); } @@ -1542,11 +1628,179 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl { + warehouseGoodsAllocationClient.updateAllocationCache(allocationId.toString()); + }); + + for (String orderCode : orderSet) { + distributionStockArticleClient.updateOrderInfo(orderCode, warehouseId); + } + + num = num + updownGoodsLogEntities.size(); + try{ + + //把parcelListEntityList中所有元素的conditions作为key进行分组成一个Map + Map> listMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + listMap.keySet().forEach(conditions -> { + List ls = listMap.get(conditions); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("conditions",conditions); + jsonObject.put("operation",4); + //把ls中所有元素的orderPackageCode放入一个List + List orderPackageCodes = ls.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toList()); + + jsonObject.put("orderPackageCodes",orderPackageCodes); + jsonObject.put("warehouseId",warehouseId); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + }); + + + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + return Resp.scanSuccess("下架成功", "成功下架" + num + "件"); + } + + + private R downPackageNoFanout(List upShelfPackageList, Long warehouseId, String remark) { + int num = 0; + Set orderSet = new HashSet<>(); + + //把upShelfPackageList中的orderPackageCde提取到List中 + List orderPackageCodeList = upShelfPackageList.stream().map(UpShelfPackageDTO::getOrderPackageCode).collect(Collectors.toList()); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("association_type", "3") + .eq("warehouse_id", warehouseId) + .in("association_value", orderPackageCodeList); + List updownGoodsEntities = warehouseUpdownGoodsService.list(queryWrapper); + + //把updownGoodsEntities的association_value提取到一个List中 + List associationValueList = updownGoodsEntities.stream().map(WarehouseUpdownGoodsEntity::getAssociationValue).collect(Collectors.toList()); + + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(associationValueList); + findParamterDTO.setWarehouseId(warehouseId); + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + //把parcelListEntityList转化成orderPackageCode为key的Map + Map parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity())); + + //把updownGoodsEntities通过allocatiionId进行分组 + Map> map = updownGoodsEntities.stream().collect(Collectors.groupingBy(WarehouseUpdownGoodsEntity::getAllocationId)); + + List allocationIds = new ArrayList<>(map.keySet()); + + QueryWrapper updownTypeEntityQueryWrapper = new QueryWrapper<>(); + updownTypeEntityQueryWrapper.in("allocation_id", allocationIds) + .eq("is_deleted", 0); + List updownTypeList = list(updownTypeEntityQueryWrapper); + //把updownTypeList转化成allocationId为key的Map + Map updownTypeMap = updownTypeList.stream().collect(Collectors.toMap(WarehouseUpdownTypeEntity::getAllocationId, Function.identity())); + + List toNullUpdownTypeIds = new ArrayList<>(); + List updateAllocationIds = new ArrayList<>(); + List deleteTrayAllocationList = new ArrayList<>(); + List updateUpdownTypeList = new ArrayList<>(); + List updownGoodsLogEntities = new ArrayList<>(); + List updownParcelEntities = new ArrayList<>(); + + map.keySet().forEach(allocationId -> { + QueryWrapper taryAllocationEntityQueryWrapper = new QueryWrapper<>(); + taryAllocationEntityQueryWrapper.eq("allocation_id", allocationId) + .eq("is_deleted", 0); + WarehouseTaryAllocationEntity taryAllocationEntity = warehouseTaryAllocationService.getOne(taryAllocationEntityQueryWrapper); + List updownGoodsEntities1 = map.get(allocationId); + List orderPackageCodes = updownGoodsEntities1.stream().map(WarehouseUpdownGoodsEntity::getAssociationValue).collect(Collectors.toList()); + if (!Objects.isNull(taryAllocationEntity)) { + warehouseTrayTypeService.downPackageByOrderPackageCodeList(orderPackageCodes, remark, warehouseId); + } + WarehouseUpdownTypeEntity updownTypeEntity = updownTypeMap.get(allocationId); + Long updownTypeId = updownTypeEntity.getId(); + //把updownGoodsEntities1的id提取到List中 + List updownGoodsIds = updownGoodsEntities1.stream().map(WarehouseUpdownGoodsEntity::getId).collect(Collectors.toList()); + + Integer residue = warehouseUpdownGoodsService.deleteByUpdownGoodsIds(updownGoodsIds, updownTypeEntity.getId()); + if (residue == 0) { + //删除上架方式 + toNullUpdownTypeIds.add(updownTypeId); + //修改库位状态为空闲 + updateAllocationIds.add(allocationId); +// basicdataGoodsAllocationClient.updateAllocationStatus(allocationId, "1"); + //如果有托盘还要删除托盘与库位的绑定 + if (!Objects.isNull(taryAllocationEntity)) { + deleteTrayAllocationList.add(taryAllocationEntity); +// warehouseTaryAllocationService.deleteById(taryAllocationEntity); + } + } else { + updateUpdownTypeList.add(updownTypeEntity); + } + + List parcelListEntities = new ArrayList<>(); + orderPackageCodes.forEach(orderPackageCode -> { + DistributionParcelListEntity parcelListEntity = parcelListEntityMap.get(orderPackageCode); + if (!Objects.isNull(parcelListEntity)) { + parcelListEntities.add(parcelListEntity); + } + }); + + parcelListEntities.forEach(parcelListEntity -> { + orderSet.add(parcelListEntity.getOrderCode()); + WarehouseUpdownGoodsLogEntity warehouseUpdownGoodsLogEntity = new WarehouseUpdownGoodsLogEntity(); + warehouseUpdownGoodsLogEntity.setCreateUser(1714696768639311873L); + warehouseUpdownGoodsLogEntity.setUpdateUser(1714696768639311873L); + warehouseUpdownGoodsLogEntity.setCreateDept(1649331096241836033L); + warehouseUpdownGoodsLogEntity.setTenantId(TenantNum.HUITONGCODE); + warehouseUpdownGoodsLogEntity.setUpdownTypeId(updownTypeEntity.getId()); + warehouseUpdownGoodsLogEntity.setAreaId(updownTypeEntity.getAreaId()); + warehouseUpdownGoodsLogEntity.setAreaTitle(updownTypeEntity.getAreaTitle()); + warehouseUpdownGoodsLogEntity.setShelfId(updownTypeEntity.getShelfId()); + warehouseUpdownGoodsLogEntity.setShelfTitle(updownTypeEntity.getShelfTitle()); + warehouseUpdownGoodsLogEntity.setAllocationId(updownTypeEntity.getAllocationId()); + warehouseUpdownGoodsLogEntity.setAllocationTitle(updownTypeEntity.getAllocationTitle()); + warehouseUpdownGoodsLogEntity.setPositionCode(updownTypeEntity.getPositionCode()); + warehouseUpdownGoodsLogEntity.setBindingType("2"); + warehouseUpdownGoodsLogEntity.setIsAlltrays(0); + warehouseUpdownGoodsLogEntity.setAssociationId(parcelListEntity.getId()); + warehouseUpdownGoodsLogEntity.setAssociationValue(parcelListEntity.getOrderPackageCode()); + warehouseUpdownGoodsLogEntity.setAssociationType("3"); + warehouseUpdownGoodsLogEntity.setNum(1); + warehouseUpdownGoodsLogEntity.setRemark(remark); + warehouseUpdownGoodsLogEntity.setWarehouseId(updownTypeEntity.getWarehouseId()); + updownGoodsLogEntities.add(warehouseUpdownGoodsLogEntity); + +// parcelListEntity.setOrderPackageGroundingStatus("10"); }); - updownParcelEntities.addAll(parcelListEntities); +// updownParcelEntities.addAll(parcelListEntities); }); @@ -1562,7 +1816,7 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl { warehouseGoodsAllocationClient.updateAllocationCache(allocationId.toString()); @@ -1572,11 +1826,12 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl upShelfPackageList, Long warehouseId) { int num = 0; @@ -1636,6 +1891,7 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl upShelfPackageList, Long warehouseId, String remark) { int num = 0; Set orderSet = new TreeSet<>(); + List orderPackageCodes = new ArrayList<>(); for (UpShelfPackageDTO upShelfPackageDTO : upShelfPackageList) { String orderPackageCode = upShelfPackageDTO.getOrderPackageCode(); //查询包件在哪个库位上 @@ -1686,16 +1942,50 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + + //把parcelListEntityList中所有元素的conditions作为key进行分组成一个Map + Map> listMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + listMap.keySet().forEach(conditions -> { + List ls = listMap.get(conditions); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("conditions",conditions); + jsonObject.put("operation",4); + //把ls中所有元素的orderPackageCode放入一个List + List packageCodes = ls.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toList()); + + jsonObject.put("orderPackageCodes",packageCodes); + jsonObject.put("warehouseId",warehouseId); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + }); + + + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); } return Resp.scanSuccess("下架成功", "成功下架" + num + "件"); @@ -1779,14 +2069,36 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl orderPackageCodes = new ArrayList<>(); + orderPackageCodes.add(orderPackageCode); + jsonObject.put("orderPackageCodes",orderPackageCodes); + jsonObject.put("warehouseId",warehouseId); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + + } + } } @@ -1794,16 +2106,16 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl orders = new ArrayList<>(orderSet); - if (orders.isEmpty()) { - return Resp.scanSuccess("下架成功", "成功下架" + num + "件"); - } +// List orders = new ArrayList<>(orderSet); +// if (orders.isEmpty()) { +// return Resp.scanSuccess("下架成功", "成功下架" + num + "件"); +// } - OrderPackageDTO orderPackageDTO1 = new OrderPackageDTO(); - orderPackageDTO1.setWarehouseId(warehouseId); - orderPackageDTO1.setStrings(orders); - distributionStockArticleClient.updateOrdersInfo(orderPackageDTO1); - log.info(">>>>> T downPackageAndDelTrayAndIsUpdate end"); +// OrderPackageDTO orderPackageDTO1 = new OrderPackageDTO(); +// orderPackageDTO1.setWarehouseId(warehouseId); +// orderPackageDTO1.setStrings(orders); +// distributionStockArticleClient.updateOrdersInfo(orderPackageDTO1); +// log.info(">>>>> T downPackageAndDelTrayAndIsUpdate end"); return Resp.scanSuccess("下架成功", "成功下架" + num + "件"); } @@ -1819,6 +2131,10 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("association_value", orderCode) @@ -1856,6 +2172,26 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl orderCodes = new ArrayList<>(); + orderCodes.add(orderCode); + jsonObject.put("orderCodes",orderCodes); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + } saveUpdownGoodsLog(updownGoodsList, "2", 0, remark, warehouseId); updateUpdownTypeNum(updownTypeEntity); @@ -1872,7 +2208,7 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); @@ -1971,6 +2311,29 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl stockListIds = new ArrayList<>(); + stockListIds.add(stockListEntity.getId()); + jsonObject.put("stockListIds",stockListIds); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + } //更新货位缓存 warehouseGoodsAllocationClient.updateAllocationCache(allocationId.toString()); @@ -2018,11 +2381,14 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl setOrder = new TreeSet<>(); for (WarehouseUpdownGoodsEntity updownGoodsEntity : updownGoodsList) { - String associationType = updownGoodsEntity.getAssociationType(); - String associationValue = updownGoodsEntity.getAssociationValue(); +// String associationType = updownGoodsEntity.getAssociationType(); +// String associationValue = updownGoodsEntity.getAssociationValue(); Integer num = updownGoodsEntity.getNum(); - if ("1".equals(associationType)) { - updateZeroOrderGroundingStatus(associationValue, warehouseId); - } else if ("3".equals(associationType)) { - DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(associationValue, warehouseId); - updatePackageGroundingStatus(associationValue, "10", warehouseId); - setOrder.add(parcelListEntity.getOrderCode()); - } +// if ("1".equals(associationType)) { +// updateZeroOrderGroundingStatus(associationValue, warehouseId); +// } else if ("3".equals(associationType)) { +// DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(associationValue, warehouseId); +// updatePackageGroundingStatus(associationValue, "10", warehouseId); +// setOrder.add(parcelListEntity.getOrderCode()); +// } allNum = allNum + num; } - for (String orderCode : setOrder) { - distributionStockArticleClient.updateOrderInfo(orderCode, warehouseId); +// for (String orderCode : setOrder) { +// distributionStockArticleClient.updateOrderInfo(orderCode, warehouseId); +// } + + try{ + //把updownGoodsList通过associationType进行分组associationType作为key + Map> map = updownGoodsList.stream().collect(Collectors.groupingBy(WarehouseUpdownGoodsEntity::getAssociationType)); + map.keySet().forEach(associationType -> { + List updownGoodsEntities = map.get(associationType); + //把updownGoodsEntities中所有元素的associationValue放入一个List + List associationValues = updownGoodsEntities.stream().map(WarehouseUpdownGoodsEntity::getAssociationValue).collect(Collectors.toList()); + + if("1".equals(associationType)){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",2); + jsonObject.put("operation",4); + jsonObject.put("orderCodes",associationValues); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }else if("3".equals(associationType)){ + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(associationValues); + findParamterDTO.setWarehouseId(warehouseId); + List listEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + //把listEntityList通过conditions进行分组 + Map> map1 = listEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + map1.keySet().forEach(conditions -> { + List parcelListEntityList = map1.get(conditions); + //把parcelListEntityList中所有元素的orderPackageCodes放入一个List + List orderPackageCodes = parcelListEntityList.stream().map(DistributionParcelListEntity::getOrderPackageCode).collect(Collectors.toList()); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("conditions",conditions); + jsonObject.put("operation",4); + jsonObject.put("orderPackageCodes",orderPackageCodes); + jsonObject.put("warehouseId",warehouseId); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }); + }else if("4".equals(associationType)){ + List stockListIds = new ArrayList<>(); + updownGoodsEntities.forEach(updownGoodsEntity -> { + String materialCode = updownGoodsEntity.getAssociationValue(); + String incomingBatch = updownGoodsEntity.getIncomingBatch(); + Long marketId = updownGoodsEntity.getMarketId(); + + DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(marketId, materialCode, incomingBatch, warehouseId); + if(!Objects.isNull(stockListEntity)){ + stockListIds.add(stockListEntity.getId()); + } + + }); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",3); + jsonObject.put("operation",4); + jsonObject.put("stockListIds",stockListIds); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + } + }); + }catch (Exception e){ + log.warn("################downAllocation: 下架库位存入广播失败"); } + + //修改库位状态 basicdataGoodsAllocationClient.updateAllocationStatus(allocationId, "1"); @@ -2166,6 +2604,7 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl> map = list.stream().collect(Collectors.groupingBy(WarehouseUpdownGoodsEntity::getAssociationType)); + + map.keySet().forEach(associationType -> { + List updownGoodsEntities = map.get(associationType); + //把trayGoodsEntities中所有元素的associationValue存入一个List集合 + List associationValues = updownGoodsEntities.stream().map(WarehouseUpdownGoodsEntity::getAssociationValue).collect(Collectors.toList()); + + if("1".equals(associationType)){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",2); + jsonObject.put("operation",3); + jsonObject.put("orderCodes",associationValues); + jsonObject.put("warehouseId",wid); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }else if ("3".equals(associationType)){ + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(associationValues); + findParamterDTO.setWarehouseId(wid); + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + //把parcelListEntityList通过conditions进行分组,conditions作为key的Map + Map> parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + parcelListEntityMap.keySet().forEach(conditions -> { + List parcelListEntities = parcelListEntityMap.get(conditions); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("operation",3); + jsonObject.put("conditions",conditions); + jsonObject.put("orderPackageCodes",associationValues); + jsonObject.put("warehouseId",wid); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + }); + }else if ("4".equals(associationType)){ + List stockListIds = new ArrayList<>(); + updownGoodsEntities.forEach(updownGoodsEntity -> { + String materialCode = updownGoodsEntity.getAssociationValue(); + String incomingBatch = updownGoodsEntity.getIncomingBatch(); + Long marketId = updownGoodsEntity.getMarketId(); + DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(marketId, incomingBatch, materialCode, wid); + if(!Objects.isNull(stockListEntity)){ + stockListIds.add(stockListEntity.getId()); + } + }); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",3); + jsonObject.put("operation",3); + jsonObject.put("stockListIds",stockListIds); + jsonObject.put("warehouseId",wid); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + } + + }); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + } @@ -2935,6 +3452,7 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl updownTypeQueryWrapper = new QueryWrapper<>(); @@ -2955,16 +3473,16 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl> map = trayGoodsList.stream().collect(Collectors.groupingBy(WarehouseTrayGoodsEntity::getAssociationType)); + + map.keySet().forEach(associationType -> { + List trayGoodsEntities = map.get(associationType); + //把trayGoodsEntities中所有元素的associationValue存入一个List集合 + List associationValues = trayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toList()); + + if("1".equals(associationType)){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",2); + jsonObject.put("operation",3); + jsonObject.put("orderCodes",associationValues); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + }else if ("3".equals(associationType)){ + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(associationValues); + findParamterDTO.setWarehouseId(warehouseId); + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + //把parcelListEntityList通过conditions进行分组,conditions作为key的Map + Map> parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); + + parcelListEntityMap.keySet().forEach(conditions -> { + List parcelListEntities = parcelListEntityMap.get(conditions); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",1); + jsonObject.put("operation",3); + jsonObject.put("conditions",conditions); + jsonObject.put("orderPackageCodes",associationValues); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + }); + }else if ("4".equals(associationType)){ + List stockListIds = new ArrayList<>(); + trayGoodsEntities.forEach(trayGoodsEntity -> { + String materialCode = trayGoodsEntity.getAssociationValue(); + String incomingBatch = trayGoodsEntity.getIncomingBatch(); + Long marketId = trayGoodsEntity.getMarketId(); + DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(marketId, incomingBatch, materialCode, warehouseId); + if(!Objects.isNull(stockListEntity)){ + stockListIds.add(stockListEntity.getId()); + } + }); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("dataType",3); + jsonObject.put("operation",3); + jsonObject.put("stockListIds",stockListIds); + jsonObject.put("warehouseId",warehouseId); + jsonObject.put("allocationName",qrCode); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.warehouse.ALLOCATION.EXCHANGE).msg(jsonObject.toJSONString()).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + } + + }); + }catch (Exception e){ + log.warn("###########saveTrayTypeByOrderPackageCode: 发送打托广播失败"); + } + + return Resp.scanSuccess("上架成功", "整托上架成功" + total + "件"); } @@ -3098,7 +3693,7 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl warehouseWayBillDetails, BasicPrintTemplateEntity template) throws Exception { PrintPreviewVO printPreviewVO = new PrintPreviewVO(); String html = TemplateUtil.getTemplateByUrl(template.getTemplateUrl());