diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/UnloadPackageDTO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/UnloadPackageDTO.java index 16dcc7245..55fe9531f 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/UnloadPackageDTO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/UnloadPackageDTO.java @@ -8,5 +8,5 @@ import java.io.Serializable; public class UnloadPackageDTO implements Serializable { private String orderPackageCode; - + private Long carsLoadScanId; } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java index 5ad639ca6..d7f358df2 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java @@ -43,6 +43,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** * 在库订单包件清单 Feign实现类 @@ -116,7 +117,18 @@ public class DistributionParcelListClient implements IDistributionParcelListClie @Override @PostMapping(API_PREFIX+"/addBatch") public boolean addBatch(List parcelListEntityList) { - return distributionParcelListService.saveBatch(parcelListEntityList); + boolean b = distributionParcelListService.saveBatch(parcelListEntityList); + if(b){ + Long warehouseId = parcelListEntityList.get(0).getWarehouseId(); + //把parcelListEntityList中的ordeCode存入一个Set + Set orderCodes = parcelListEntityList.stream().map(DistributionParcelListEntity::getOrderCode).collect(Collectors.toSet()); + orderCodes.forEach(orderCode -> { + distributionStockArticleService.updateOrderInfo(orderCode,warehouseId); + }); + return b; + }else{ + return b; + } } @Override @@ -326,9 +338,12 @@ public class DistributionParcelListClient implements IDistributionParcelListClie distributionParcelListService.updatePackageStatus(orderPackageCodes,warehouseId,packageStatus); List list = distributionParcelListService.findListByOrderPackageCode(orderPackageCodes,warehouseId); - //循环list调用更新updateOrderInfo方法 - list.forEach(item->{ - distributionStockArticleService.updateOrderInfo(item.getOrderCode(),warehouseId); + //把list中的orderCode放入一个set + Set orderCodeSet = list.stream().map(DistributionParcelListEntity::getOrderCode).collect(Collectors.toSet()); + orderCodeSet.forEach(orderCode -> { + distributionStockArticleService.updateOrderInfo(orderCode,warehouseId); }); + + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java index 15dae2f56..bc95863cf 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java @@ -2,10 +2,13 @@ package com.logpm.trunkline.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; import com.logpm.trunkline.dto.LoadCarsDTO; import com.logpm.trunkline.dto.ProductInfoDTO; import com.logpm.trunkline.entity.TrunklineCarsLoadScanEntity; import com.logpm.trunkline.vo.*; +import com.logpm.warehouse.entity.WarehouseWaybillEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -132,4 +135,14 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper findParceListByCarsLoadScanIds(@Param("carsLoadScanIds") List carsLoadScanIds); + + List findOrderListByCarsLoadScanIds(@Param("carsLoadScanIds") List carsLoadScanIds); + + List findWaybillListByCarsLoadScanIds(@Param("carsLoadScanIds") List carsLoadScanIds); + + List findListByIdsNoPackage(@Param("carsLoadScanIds") List carsLoadScanIds,@Param("warehouseId") Long warehouseId); + + List findIncomingOrdeCodesByCarsLoadScanIds(@Param("carsLoadScanIds") List carsLoadScanIds, @Param("warehouseId") Long warehouseId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml index 36a7ea1e8..61492874b 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml @@ -641,4 +641,65 @@ where ltcls.load_id = + + + + + + + + + + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java index 0e4110a87..1c75f1b46 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java @@ -1,9 +1,12 @@ package com.logpm.trunkline.service; +import com.logpm.warehouse.entity.WarehousePackageTrackLogEntity; + import java.util.List; public interface IPackageTrackLogAsyncService { void addPackageTrackLog(String tenantId, Long userId, Long deptId, String nickName, List orderPackageCodes, Long warehouseId, String warehouseName, Integer workNode, String content); + void addBatchPackageTrackLog(List addPackageTrackLogList, List orderPackageCodes, Integer code); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java index 8f40bfd92..4852f1c60 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java @@ -1,10 +1,13 @@ package com.logpm.trunkline.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; import com.logpm.trunkline.dto.LoadCarsDTO; import com.logpm.trunkline.dto.ProductInfoDTO; import com.logpm.trunkline.entity.TrunklineCarsLoadScanEntity; import com.logpm.trunkline.vo.*; +import com.logpm.warehouse.entity.WarehouseWaybillEntity; import org.springblade.core.mp.base.BaseService; import java.util.List; @@ -127,4 +130,14 @@ public interface ITrunklineCarsLoadScanService extends BaseService findParceListByCarsLoadScanIds(List carsLoadScanIds); + + List findOrderListByCarsLoadScanIds(List carsLoadScanIds); + + List findWaybillListByCarsLoadScanIds(List carsLoadScanIds); + + List findListByIdsNoPackage(List carsLoadScanIds, Long warehouseId); + + List findIncomingOrdeCodesByCarsLoadScanIds(List carsLoadScanIds, Long warehouseId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index 2599b448c..19e0673df 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -586,7 +586,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService { // sendRabbitMessageLoadScanData(JSONUtil.parseArray(advanceIds)); carsLoadService.sendRabbitMessageOpenOrder(advanceIds, waybillId); - return R.success("开单成功"); + Map map = new HashMap<>(); + map.put("waybillId",waybillId); + return R.data(map); } @Override @@ -784,7 +786,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService { trunklineWaybillOrderEntity.setHandleNumber(waybillEntity.getTotalCount()); trunklineWaybillOrderService.save(trunklineWaybillOrderEntity); - return R.success("开单成功"); + Map map = new HashMap<>(); + map.put("waybillId",waybillId); + return R.data(map); } @Override diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java index 4581a3f82..713602916 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java @@ -46,6 +46,16 @@ public class PackageTrackLogAsyncServiceImpl implements IPackageTrackLogAsyncSer } warehousePackageTrackLogClient.addLogList(list); - waybillPackageService.updatePackageStatus(orderPackageCodes,workNode); + waybillPackageService.updatePackageStatus(orderPackageCodes, workNode); } + + @Async + @Override + public void addBatchPackageTrackLog(List addPackageTrackLogList, List orderPackageCodes, Integer workNode) { + warehousePackageTrackLogClient.addLogList(addPackageTrackLogList); + + waybillPackageService.updatePackageStatus(orderPackageCodes, workNode); + } + } + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java index 7f7c2668e..cb9c0ae77 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java @@ -1,12 +1,15 @@ package com.logpm.trunkline.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; import com.logpm.trunkline.dto.LoadCarsDTO; import com.logpm.trunkline.dto.ProductInfoDTO; import com.logpm.trunkline.entity.TrunklineCarsLoadScanEntity; import com.logpm.trunkline.mapper.TrunklineCarsLoadScanMapper; import com.logpm.trunkline.service.ITrunklineCarsLoadScanService; import com.logpm.trunkline.vo.*; +import com.logpm.warehouse.entity.WarehouseWaybillEntity; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; @@ -313,4 +316,29 @@ public class TrunklineCarsLoadScanServiceImpl extends BaseServiceImpl findParceListByCarsLoadScanIds(List carsLoadScanIds) { + return baseMapper.findParceListByCarsLoadScanIds(carsLoadScanIds); + } + + @Override + public List findOrderListByCarsLoadScanIds(List carsLoadScanIds) { + return baseMapper.findOrderListByCarsLoadScanIds(carsLoadScanIds); + } + + @Override + public List findWaybillListByCarsLoadScanIds(List carsLoadScanIds) { + return baseMapper.findWaybillListByCarsLoadScanIds(carsLoadScanIds); + } + + @Override + public List findListByIdsNoPackage(List carsLoadScanIds, Long warehouseId) { + return baseMapper.findListByIdsNoPackage(carsLoadScanIds,warehouseId); + } + + @Override + public List findIncomingOrdeCodesByCarsLoadScanIds(List carsLoadScanIds, Long warehouseId) { + return baseMapper.findIncomingOrdeCodesByCarsLoadScanIds(carsLoadScanIds,warehouseId); + } + } 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 9810ee88a..0d76ee70a 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 @@ -34,6 +34,7 @@ import com.logpm.trunkline.entity.*; import com.logpm.trunkline.mapper.TrunklineCarsLoadMapper; import com.logpm.trunkline.service.*; import com.logpm.trunkline.vo.*; +import com.logpm.warehouse.entity.WarehousePackageTrackLogEntity; import com.logpm.warehouse.entity.WarehouseWayBillDetail; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import com.logpm.warehouse.feign.IWarehouseTrayTypeClient; @@ -3390,12 +3391,18 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl unloadPackageList = batchUnloadDTO.getUnloadPackageList(); List unloadZeroList = batchUnloadDTO.getUnloadZeroList(); - for (UnloadPackageDTO unloadPackageDTO : unloadPackageList) { - String orderPackageCode = unloadPackageDTO.getOrderPackageCode(); - unloadPackage(loadId, orderPackageCode, warehouseId, 1, "批量卸车包件正常卸车", incomingType); - } - - for (UnloadZeroDTO unloadZeroDTO : unloadZeroList) { String waybillNo = unloadZeroDTO.getWaybillNo(); Integer enterNum = unloadZeroDTO.getEnterNum(); String trayCode = unloadZeroDTO.getTrayCode(); String orderCode = unloadZeroDTO.getOrderCode(); - unloadZero(loadId, waybillNo, enterNum, warehouseId, 1, trayCode, orderCode, "批量卸车零担正常卸车"); + } + + List carsLoadScanIds = new ArrayList<>(); + for (UnloadPackageDTO unloadPackageDTO : unloadPackageList) { + carsLoadScanIds.add(unloadPackageDTO.getCarsLoadScanId()); + } + + if(!carsLoadScanIds.isEmpty()){ + + List loadScanEntityList = trunklineCarsLoadScanService.findListByIdsNoPackage(carsLoadScanIds,warehouseId); + List parcelListEntities = trunklineCarsLoadScanService.findParceListByCarsLoadScanIds(carsLoadScanIds); + //把parcelListEntities转成orderPackageCode为键值的map + Map parcelListMap = parcelListEntities.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, e -> e)); + List stockArticleEntities = trunklineCarsLoadScanService.findOrderListByCarsLoadScanIds(carsLoadScanIds); + //把stockArticleEntities转成orderCode为键值的map + Map stockArticleMap = stockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, e -> e)); +// List waybillEntities = trunklineCarsLoadScanService.findWaybillListByCarsLoadScanIds(carsLoadScanIds); +// //把waybillEntities转成WaybillNo为键值的map +// Map waybillMap = waybillEntities.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, e -> e)); + + List orderCodeList = trunklineCarsLoadScanService.findIncomingOrdeCodesByCarsLoadScanIds(carsLoadScanIds,warehouseId); + Map orderCodes = new HashMap<>(); + if(!Objects.isNull(orderCodeList)){ + Map finalOrderCodes2 = orderCodes; + orderCodeList.forEach(e -> { + String[] split = e.split("----"); + finalOrderCodes2.put(split[0],Long.valueOf(split[1])); + }); + orderCodes = finalOrderCodes2; + } + + List updateScanEntityList = new ArrayList<>(); + //把loadScanEntityList通过isData=0和isData=1分成两个新的list + List loadScanEntityListNoData = loadScanEntityList.stream().filter(e -> e.getIsData() == 0).collect(Collectors.toList()); + loadScanEntityListNoData.forEach(e -> { + e.setScanStatus("2"); + e.setUnloadNodeId(warehouseId); + e.setUnloadNodeName(warehouseName); + e.setUnloadAbnormal(0); + e.setUnloadNum(1); + e.setUnloadUserName(nickName); + updateScanEntityList.add(e); + }); + + + //需要解托下架的包件嘛 + Map> unbingTrayAndDelAllocationPackages = new HashMap<>(); + //直接新增的包件 + List newParcelListEntities = new ArrayList<>(); + //需要修改仓库信息的打托数据 + List trayCodes = new ArrayList<>(); + List orderPackageCodes = new ArrayList<>(); + + + + List loadScanEntityListHasData = loadScanEntityList.stream().filter(e -> e.getIsData() == 1).collect(Collectors.toList()); + //把loadScanEntityListHasData通过tray_code is null和tray_code is not null 分成两个新的list + List loadScanEntityListHasDataNoTray = loadScanEntityListHasData.stream().filter(e -> StringUtil.isBlank(e.getTrayCode())).collect(Collectors.toList()); + //把loadScanEntityListHasDataNoTray通过orderCode进行分组 + Map> loadScanEntityListHasDataNoTrayMap = loadScanEntityListHasDataNoTray.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getOrderCode)); + Map finalOrderCodes = orderCodes; + loadScanEntityListHasDataNoTrayMap.keySet().forEach(e -> { + //判断是否有已经有order了 + Long orderId = null; + if(!finalOrderCodes.isEmpty()){ + orderId = finalOrderCodes.get(e); + } + + if(ObjectUtil.isNull(orderId)){ + //没有id + DistributionStockArticleEntity stockArticleEntity = stockArticleMap.get(e); + DistributionStockArticleEntity newStockArticleEntity = new DistributionStockArticleEntity(); + BeanUtil.copy(stockArticleEntity,newStockArticleEntity); + newStockArticleEntity.setId(null); + newStockArticleEntity.setWarehouseId(warehouseId); + newStockArticleEntity.setWarehouse(warehouseName); + newStockArticleEntity.setHandQuantity(0); + newStockArticleEntity.setIncomingNum(0); + newStockArticleEntity.setCreateUserName(nickName); + newStockArticleEntity.setOrderStatus("10"); + newStockArticleEntity.setStockupStatus("10"); + newStockArticleEntity.setReservationStatus("10"); + newStockArticleEntity.setGroundingStatus("10"); + newStockArticleEntity.setOrderReceiveStatus("10"); + newStockArticleEntity.setFreezeStatus("10"); + orderId = distributionStockArticleClient.addData(newStockArticleEntity); + finalOrderCodes.put(e,orderId); + } + + + List carsLoadScanEntities = loadScanEntityListHasDataNoTrayMap.get(e); + Long finalOrderId = orderId; + carsLoadScanEntities.forEach(p -> { + Long fromWarehouseId = p.getFromWarehouseId(); + DistributionParcelListEntity parcelListEntity = parcelListMap.get(p.getScanCode()); + Long acceptWarehouseId = parcelListEntity.getAcceptWarehouseId(); + DistributionParcelListEntity newNoOrderPackage = new DistributionParcelListEntity(); + BeanUtil.copy(parcelListEntity,newNoOrderPackage); + newNoOrderPackage.setId(null); + newNoOrderPackage.setWarehouseId(warehouseId); + newNoOrderPackage.setWarehouse(warehouseName); + newNoOrderPackage.setStockArticleId(finalOrderId); + newNoOrderPackage.setOrderPackageStatus("20"); + newNoOrderPackage.setOrderPackageFreezeStatus("10"); + newNoOrderPackage.setOrderPackageGroundingStatus("10"); + newNoOrderPackage.setOrderPackageStockupStatus("10"); + newNoOrderPackage.setOrderPackageReservationStatus("10"); + newNoOrderPackage.setOrderPackageLoadingStatus("10"); + if(acceptWarehouseId.equals(warehouseId)){ + newNoOrderPackage.setIsTransfer(0); + }else{ + newNoOrderPackage.setIsTransfer(1); + } + newParcelListEntities.add(newNoOrderPackage); + orderPackageCodes.add(p.getScanCode()); + + List list = unbingTrayAndDelAllocationPackages.get(fromWarehouseId); + if(Objects.isNull(list)){ + list = new ArrayList<>(); + list.add(p.getScanCode()); + }else{ + list.add(p.getScanCode()); + } + unbingTrayAndDelAllocationPackages.put(fromWarehouseId,list); + + p.setScanStatus("2"); + p.setUnloadNodeId(warehouseId); + p.setUnloadNodeName(warehouseName); + p.setUnloadAbnormal(0); + p.setUnloadNum(1); + p.setUnloadUserName(nickName); + updateScanEntityList.add(p); + }); + + }); + orderCodes = finalOrderCodes; + + List loadScanEntityListHasDataHasTray = loadScanEntityListHasData.stream().filter(e -> StringUtil.isNotBlank(e.getTrayCode())).collect(Collectors.toList()); + //把loadScanEntityListHasDataHasTray通过TrayCode进行分组 + Map> loadScanEntityListHasDataHasTrayMap = loadScanEntityListHasDataHasTray.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getTrayCode)); + Map finalOrderCodes1 = orderCodes; + loadScanEntityListHasDataHasTrayMap.keySet().forEach(o -> { + trayCodes.add(o); + List carsLoadScanEntities = loadScanEntityListHasDataHasTrayMap.get(o); + //把carsLoadScanEntities通过orderCode进行分组 + Map> carsLoadScanEntitiesMap = carsLoadScanEntities.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getOrderCode)); + carsLoadScanEntitiesMap.keySet().forEach(e -> { + //判断是否有已经有order了 + Long orderId = finalOrderCodes1.get(e); + if(ObjectUtil.isNull(orderId)){ + //没有id + DistributionStockArticleEntity stockArticleEntity = stockArticleMap.get(e); + DistributionStockArticleEntity newStockArticleEntity = new DistributionStockArticleEntity(); + BeanUtil.copy(stockArticleEntity,newStockArticleEntity); + newStockArticleEntity.setId(null); + newStockArticleEntity.setWarehouseId(warehouseId); + newStockArticleEntity.setWarehouse(warehouseName); + newStockArticleEntity.setHandQuantity(0); + newStockArticleEntity.setIncomingNum(0); + newStockArticleEntity.setCreateUserName(nickName); + newStockArticleEntity.setOrderStatus("10"); + newStockArticleEntity.setStockupStatus("10"); + newStockArticleEntity.setReservationStatus("10"); + newStockArticleEntity.setGroundingStatus("10"); + newStockArticleEntity.setOrderReceiveStatus("10"); + newStockArticleEntity.setFreezeStatus("10"); + orderId = distributionStockArticleClient.addData(newStockArticleEntity); + finalOrderCodes1.put(e,orderId); + } + + List carsLoadScanList = carsLoadScanEntitiesMap.get(e); + Long finalOrderId = orderId; + carsLoadScanList.forEach(p -> { + DistributionParcelListEntity parcelListEntity = parcelListMap.get(p.getScanCode()); + Long acceptWarehouseId = parcelListEntity.getAcceptWarehouseId(); + DistributionParcelListEntity newNoOrderPackage = new DistributionParcelListEntity(); + BeanUtil.copy(parcelListEntity,newNoOrderPackage); + newNoOrderPackage.setId(null); + newNoOrderPackage.setWarehouseId(warehouseId); + newNoOrderPackage.setWarehouse(warehouseName); + newNoOrderPackage.setStockArticleId(finalOrderId); + newNoOrderPackage.setOrderPackageStatus("20"); + newNoOrderPackage.setOrderPackageFreezeStatus("10"); + newNoOrderPackage.setOrderPackageGroundingStatus("10"); + newNoOrderPackage.setOrderPackageStockupStatus("10"); + newNoOrderPackage.setOrderPackageReservationStatus("10"); + newNoOrderPackage.setOrderPackageLoadingStatus("10"); + if(acceptWarehouseId.equals(warehouseId)){ + newNoOrderPackage.setIsTransfer(0); + }else{ + newNoOrderPackage.setIsTransfer(1); + } + newParcelListEntities.add(newNoOrderPackage); + orderPackageCodes.add(p.getScanCode()); + + p.setScanStatus("2"); + p.setUnloadNodeId(warehouseId); + p.setUnloadNodeName(warehouseName); + p.setUnloadAbnormal(0); + p.setUnloadNum(1); + p.setUnloadUserName(nickName); + updateScanEntityList.add(p); + }); + }); + }); + + //直接新增的包件 + distributionParcelListClient.addBatch(newParcelListEntities); + + trunklineCarsLoadScanService.updateBatchById(updateScanEntityList); + + //需要解托下架的包件嘛 + unbingTrayAndDelAllocationPackages.keySet().forEach(w -> { + List list = unbingTrayAndDelAllocationPackages.get(w); + updownTypeClient.downPackageOrDelTray(StringUtil.join(list),w,"批量入库解托下架"); + }); + + //需要修改仓库信息的打托数据 + trayCodes.forEach(trayCode -> { + trayTypeClient.changeTrayWarehouseInfo(trayCode,warehouseId); + }); + + newParcelListEntities.forEach(e -> { + carsLoadAsyncService.dealwithAfterAbnormalPackage(e.getOrderPackageCode(),warehouseId,warehouseName,carsLoadEntity.getCarsNo(),userId, deptId, nickName); + }); + + String content = "包件在 " + warehouseName + "卸车,卸车方式:" + IncomingTypeEnum.getValue(incomingType); + packageTrackLogAsyncService.addPackageTrackLog(tenantId, userId, deptId, nickName, orderPackageCodes, warehouseId, warehouseName, WorkNodeEnums.UNLOAD_INCOMING_WAREHOUSE.getCode(), content); } + updateNumByLoadId(loadId); + return R.success("卸车成功"); } @@ -3928,12 +4164,14 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl carsOrderEntityList = trunklineCarsOrderService.findListByLoadIdAndNodeId(loadId, warehouseId); - for (TrunklineCarsOrderEntity carsOrderEntity : carsOrderEntityList) { - Integer type = carsOrderEntity.getType(); - Integer realNum = carsOrderEntity.getRealNum(); - if (type.equals(1)) { - //订制品订单 - String orderCode = carsOrderEntity.getOrderCode(); - Integer planNum = carsOrderEntity.getPlanNum(); - String waybillNo = carsOrderEntity.getWaybillNo(); - List entityListByOrderCode = distributionParcelListClient.findEntityListByOrderCodeAndStatus(orderCode, warehouseId, "20",waybillNo); - int size = entityListByOrderCode.size(); - if (planNum.equals(size + realNum)) { - for (DistributionParcelListEntity parcelListEntity : entityListByOrderCode) { - String orderPackageCode = parcelListEntity.getOrderPackageCode(); - //查询包件是否已经装车 - TrunklineCarsLoadScanEntity carsLoadScanEntity = trunklineCarsLoadScanService.findEntityByLoadIdAndOrderPackageCode(loadId, orderPackageCode); - if (Objects.isNull(carsLoadScanEntity)) { - loadingScan(loadId, warehouseId, orderPackageCode, null, "手动一键装车"); - } - } - } - } else if (type.equals(2)) { - //零担订单 - String orderCode = carsOrderEntity.getOrderCode(); - String waybillNo = carsOrderEntity.getWaybillNo(); - Integer planNum = carsOrderEntity.getPlanNum(); -// Integer realNum = carsOrderEntity.getRealNum(); - if (realNum.equals(0)) { - loadingZero(loadId, warehouseId, waybillNo, orderCode, null, planNum, "手动一键装车"); + //把carsOrderEntityList通过type分组成两个新的集合 + List packageOrderList = carsOrderEntityList.stream().filter(e -> e.getType().equals(1)).collect(Collectors.toList()); + List zeroOrderList = carsOrderEntityList.stream().filter(e -> e.getType().equals(2)).collect(Collectors.toList()); + //零担批量装车 + zeroOrderList.stream().forEach(e -> { + //零担订单 + Integer realNum = e.getRealNum(); + String orderCode = e.getOrderCode(); + String waybillNo = e.getWaybillNo(); + Integer planNum = e.getPlanNum(); + if (realNum.equals(0)) { + loadingZero(loadId, warehouseId, waybillNo, orderCode, null, planNum, "手动一键装车"); + } + }); + + List addCarsLoadScanList = new ArrayList<>(); + List addPackageTrackLogList = new ArrayList<>(); + List orderPackageCodes = new ArrayList<>(); + List parcelList = new ArrayList<>(); + packageOrderList.stream().forEach(e -> { + Integer realNum = e.getRealNum(); + String orderCode = e.getOrderCode(); + Integer planNum = e.getPlanNum(); + String waybillNo = e.getWaybillNo(); + Long finalNodeId = e.getFinalNodeId(); + String finalNodeName = null; + BasicdataWarehouseEntity finalNodeWarehouse = basicdataWarehouseClient.getEntityWarehouseId(finalNodeId); + if (Objects.nonNull(finalNodeWarehouse)){ + finalNodeName = finalNodeWarehouse.getName(); + } + List entityListByOrderCode = distributionParcelListClient.findEntityListByOrderCodeAndStatus(orderCode, warehouseId, "20",waybillNo); + int size = entityListByOrderCode.size(); + if(planNum.equals(size + realNum)){ + for (DistributionParcelListEntity parcelListEntity : entityListByOrderCode) { + String orderPackageCode = parcelListEntity.getOrderPackageCode(); + TrunklineCarsLoadScanEntity carsLoadScanEntity = new TrunklineCarsLoadScanEntity(); + carsLoadScanEntity.setLoadId(loadId); + carsLoadScanEntity.setWarehouseId(warehouseId); + carsLoadScanEntity.setWarehouseName(warehouseName); + carsLoadScanEntity.setLoadCode(carsNo); + carsLoadScanEntity.setWaybillId(parcelListEntity.getWaybillId()); + carsLoadScanEntity.setWaybillNo(parcelListEntity.getWaybillNumber()); + carsLoadScanEntity.setOrderCode(parcelListEntity.getOrderCode()); + carsLoadScanEntity.setScanCode(orderPackageCode); + carsLoadScanEntity.setScanStatus("1"); + carsLoadScanEntity.setNum(1); + carsLoadScanEntity.setType(1); + carsLoadScanEntity.setIsData(1); + carsLoadScanEntity.setLoadingAbnormal(0); + carsLoadScanEntity.setUnloadAbnormal(0); + carsLoadScanEntity.setFromWarehouseId(warehouseId); + carsLoadScanEntity.setUnloadNum(0); + carsLoadScanEntity.setFinalNodeId(finalNodeId); + carsLoadScanEntity.setFinalNodeName(finalNodeName); + carsLoadScanEntity.setUnloadCheck(0); + carsLoadScanEntity.setIsSupple(0); + carsLoadScanEntity.setLoadingUserName(AuthUtil.getNickName()); + addCarsLoadScanList.add(carsLoadScanEntity); + + Date date = new Date(); + WarehousePackageTrackLogEntity warehousePackageTrackLogEntity = new WarehousePackageTrackLogEntity(); + warehousePackageTrackLogEntity.setTenantId(tenantId); + warehousePackageTrackLogEntity.setCreateUser(userId); + warehousePackageTrackLogEntity.setCreateTime(date); + warehousePackageTrackLogEntity.setUpdateUser(userId); + warehousePackageTrackLogEntity.setUpdateTime(date); + warehousePackageTrackLogEntity.setIsDeleted(0); + warehousePackageTrackLogEntity.setStatus(1); + warehousePackageTrackLogEntity.setCreateDept(deptId); + warehousePackageTrackLogEntity.setOrderPackageCode(orderPackageCode); + warehousePackageTrackLogEntity.setWarehouseId(warehouseId); + warehousePackageTrackLogEntity.setWarehouseName(warehouseName); + warehousePackageTrackLogEntity.setWorkNode(WorkNodeEnums.INITIAL_WAREHOUSE_LOADING.getCode()); + String content = "包件在 " + warehouseName + "手动批量装车,配载计划目的仓 " + carsLoadScanEntity.getFinalNodeName() + ",数据来源仓库 " + warehouseName; + warehousePackageTrackLogEntity.setContent(content); + warehousePackageTrackLogEntity.setOperator(nickName); + addPackageTrackLogList.add(warehousePackageTrackLogEntity); + orderPackageCodes.add(orderPackageCode); } } - } + }); + + distributionParcelListClient.updatePackageStatus(orderPackageCodes,warehouseId,"60"); + + trunklineCarsLoadScanService.saveBatch(addCarsLoadScanList); + + updateNumByLoadId(loadId); + + addCarsLoadScanList.forEach(e -> { + trunklineCarsLoadingLogService.savaLoadingLog(warehouseId, warehouseName, loadId, e.getLoadCode(), e.getWaybillId(), e.getWaybillNo(), e.getOrderCode(), e.getScanCode(), 1, + 1, 1, 0, null, null, null, e.getFromWarehouseId(), e.getId(), remark); + }); + + packageTrackLogAsyncService.addBatchPackageTrackLog(addPackageTrackLogList,orderPackageCodes,WorkNodeEnums.INITIAL_WAREHOUSE_LOADING.getCode()); return R.success("装车完成"); }