diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java index d0a32149e..a92bc2e66 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java @@ -72,4 +72,7 @@ public interface IBasicdataGoodsAllocationClient { @GetMapping(API_PREFIX+"/findStockUpAllocationById") BasicdataGoodsAllocationEntity findStockUpAllocationById(@RequestParam Long warehouseId,@RequestParam Long stockUpAllocationId); + + @PostMapping(API_PREFIX+"/updateListAllocationStatus") + void updateListAllocationStatus(@RequestParam List updateAllocationIds, @RequestParam String allocationStatus); } diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataTrayClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataTrayClient.java index 14f2f6a31..da210c5cf 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataTrayClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataTrayClient.java @@ -79,4 +79,7 @@ public interface IBasicdataTrayClient { */ @GetMapping(API_PREFIX+"/findByTrayName") BasicdataTrayEntity findByTrayName(@RequestParam String positions); + + @PostMapping(API_PREFIX+"/updateTrayStatusByTrayIds") + void updateTrayStatusByTrayIds(@RequestParam List trayIds, @RequestParam int trayStatus); } 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 2ceb8e3f4..224c02070 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 @@ -192,4 +192,9 @@ public interface IDistributionParcelListClient { @PostMapping(API_PREFIX + "/findListByOrderCodesAndWarehouseId") List findListByOrderCodesAndWarehouseId(@RequestParam Set orderCodeSet, @RequestParam Long warehouseId); + @PostMapping(API_PREFIX + "/findListByOrderPackageCodeList") + List findListByOrderPackageCodeList(@RequestParam List orderPackageCodeList, @RequestParam Long warehouseId); + + @PostMapping(API_PREFIX + "/findALLNoUpShelfPackageByOrderCodeList") + List findALLNoUpShelfPackageByOrderCodeList(@RequestParam List orderCodeList, @RequestParam Long warehouseId); } diff --git a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataMessageSender.java b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataMessageSender.java index ddfbd69e4..843f91dd1 100644 --- a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataMessageSender.java +++ b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataMessageSender.java @@ -1,11 +1,14 @@ package com.logpm.factorydata.util; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.logpm.factorydata.feign.IFactoryDataClient; import com.logpm.factorydata.vo.NodePushMsg; import com.logpm.factorydata.vo.SendMsg; import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.factorydata.FactoryDataConstants; import org.springblade.common.utils.HutoolConfigUtil; import org.springframework.stereotype.Component; @@ -17,6 +20,7 @@ import org.springframework.stereotype.Component; @Component @Builder @AllArgsConstructor +@Slf4j public class FactoryDataMessageSender { private final IFactoryDataClient factoryDataClient; @@ -27,9 +31,17 @@ public class FactoryDataMessageSender { * @param data */ public void sendNodeDataByBrand(NodePushMsg data) { - String routingKeyByName = FactoryDataUtil.findRoutingKeyByName(data.getBrand()); - SendMsg build = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH).routingKey(routingKeyByName).message(JSONUtil.toJsonStr(data, HutoolConfigUtil.jsonConfigByDataTimeFormat())).build(); - factoryDataClient.sendMessage(build); + try{ + String routingKeyByName = FactoryDataUtil.findRoutingKeyByName(data.getBrand()); + if(StrUtil.isEmpty(routingKeyByName)){ + return ; + } + SendMsg build = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH).routingKey(routingKeyByName).message(JSONUtil.toJsonStr(data, HutoolConfigUtil.jsonConfigByDataTimeFormat())).build(); + factoryDataClient.sendMessage(build); + }catch (Exception e){ + log.error("sendNodeDataByBrand >>>>" ,e); + } + } } diff --git a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java index 8f93fe967..8e3935afb 100644 --- a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java +++ b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/util/FactoryDataUtil.java @@ -35,7 +35,7 @@ public class FactoryDataUtil { * @return 指定路由key */ public static String findRoutingKeyByName(BrandEnums brand) { - if (ObjectUtil.hasNull(brand, factorys.get(brand.getValue()))) { + if (ObjectUtil.isEmpty(brand) || ObjectUtil.isEmpty(factorys.get(brand.getValue()))) { // TODO 业务调用不规范,特殊处理 return null; } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java index e8b6b4354..34c2b95c8 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java @@ -114,4 +114,12 @@ public class BasicdataGoodsAllocationClient implements IBasicdataGoodsAllocation return BasicdataGoodsAllocationService.findStockUpAllocationById(warehouseId,stockUpAllocationId); } + @Override + public void updateListAllocationStatus(List updateAllocationIds, String allocationStatus) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("allocation_status",allocationStatus) + .in("id",updateAllocationIds); + BasicdataGoodsAllocationService.update(updateWrapper); + } + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataTrayClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataTrayClient.java index 252d32087..129062373 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataTrayClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataTrayClient.java @@ -116,4 +116,13 @@ public class BasicdataTrayClient implements IBasicdataTrayClient { ).get(0); } + @Override + public void updateTrayStatusByTrayIds(List trayIds, int trayStatus) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("tray_status",trayStatus) + .in("id",trayIds) + .eq("is_deleted",0); + basicdataTrayService.update(updateWrapper); + } + } 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 54da62f38..1c50b868f 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 @@ -430,4 +430,18 @@ public class DistributionParcelListClient implements IDistributionParcelListClie return distributionParcelListService.list(queryWrapper); } + + @Override + public List findListByOrderPackageCodeList(List orderPackageCodeList, Long warehouseId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in("order_package_code", orderPackageCodeList) + .eq("warehouse_id", warehouseId); + + return distributionParcelListService.list(queryWrapper); + } + + @Override + public List findALLNoUpShelfPackageByOrderCodeList(List orderCodeList, Long warehouseId) { + return distributionParcelListService.findALLNoUpShelfPackageByOrderCodeList(orderCodeList,warehouseId); + } } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java index 46a5239d8..df28d3560 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 @@ -277,4 +277,6 @@ public interface DistributionParcelListMapper extends BaseMapper advanceIds, @Param("warehouseId") Long warehouseId); List> findPackageCodeByCodes(@Param("keySet") Set keySet); + + List findALLNoUpShelfPackageByOrderCodeList(@Param("orderCodeList") List orderCodeList, @Param("warehouseId") Long warehouseId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml index 8d37b1b99..ca5ed687a 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 @@ -1765,4 +1765,23 @@ + + + + + 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 d39754577..5d834e357 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 @@ -242,4 +242,6 @@ public interface IDistributionParcelListService extends BaseService> findPackageCodeByCodes(Set keySet); + + List findALLNoUpShelfPackageByOrderCodeList(List orderCodeList, Long warehouseId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java index cda6b9753..8a2cb507d 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java @@ -581,23 +581,23 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl packageLockIds = new ArrayList<>(); - List jsonObjects = new ArrayList<>(); - List aaa = new ArrayList<>(); - List orderPackageCodes = new ArrayList<>(); + List packageLockIds = new ArrayList<>(); + List jsonObjects = new ArrayList<>(); + List aaa = new ArrayList<>(); + List orderPackageCodes = new ArrayList<>(); - DistributionDeliverySelfEntity distributionDeliverySelfEntity = new DistributionDeliverySelfEntity(); - if ("1".equals(distributionDeliveryListEntity.getKind())) { - if (!Objects.isNull(distrilbutionloadingscanDTO.getLoadingId())) { - distributionDeliverySelfEntity = distributionDeliverySelfMapper.selectById(distrilbutionloadingscanDTO.getLoadingId()); - if (Func.isEmpty(distributionDeliverySelfEntity)) { - //通过装车扫描传递的车次ID发生变化,提示文员进行计划变更 - return Resp.scanFail(13000, null, null, null); + DistributionDeliverySelfEntity distributionDeliverySelfEntity = new DistributionDeliverySelfEntity(); + if ("1".equals(distributionDeliveryListEntity.getKind())) { + if (!Objects.isNull(distrilbutionloadingscanDTO.getLoadingId())) { + distributionDeliverySelfEntity = distributionDeliverySelfMapper.selectById(distrilbutionloadingscanDTO.getLoadingId()); + if (Func.isEmpty(distributionDeliverySelfEntity)) { + //通过装车扫描传递的车次ID发生变化,提示文员进行计划变更 + return Resp.scanFail(13000, null, null, null); + } } + } else { + DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectById(distrilbutionloadingscanDTO.getLoadingId()); + BeanUtils.copyProperties(distributionDeliveryTripartiteEntity, distributionDeliverySelfEntity); } - } else { - DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectById(distrilbutionloadingscanDTO.getLoadingId()); - BeanUtils.copyProperties(distributionDeliveryTripartiteEntity, distributionDeliverySelfEntity); - } - List pushList = new ArrayList<>(); - if (distrilbutionloadingscanDTO.getType() == 1) { - List list = disStockListDetailService.list(Wrappers.query().lambda() - .eq(DisStockListDetailEntity::getStockPackageCode, distrilbutionloadingscanDTO.getBarcode()) - .ne(DisStockListDetailEntity::getStockPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) - ); - if (Func.isNotEmpty(list)) { - //满足条件此码必定为库存品 - //判断该库存品是否属于当前客户 - List collect = list.stream().filter(l -> l.getReservationId().equals(distrilbutionloadingscanDTO.getReservationId())).collect(Collectors.toList()); - if (Func.isNotEmpty(collect)) { - return Resp.scanFail("请在库存品页面扫描此码", "请在库存品页面扫描此码"); + List pushList = new ArrayList<>(); + if (distrilbutionloadingscanDTO.getType() == 1) { + List list = disStockListDetailService.list(Wrappers.query().lambda() + .eq(DisStockListDetailEntity::getStockPackageCode, distrilbutionloadingscanDTO.getBarcode()) + .ne(DisStockListDetailEntity::getStockPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) + ); + if (Func.isNotEmpty(list)) { + //满足条件此码必定为库存品 + //判断该库存品是否属于当前客户 + List collect = list.stream().filter(l -> l.getReservationId().equals(distrilbutionloadingscanDTO.getReservationId())).collect(Collectors.toList()); + if (Func.isNotEmpty(collect)) { + return Resp.scanFail("请在库存品页面扫描此码", "请在库存品页面扫描此码"); + } + return Resp.scanFail("此码不是订制品", "此码不是订制品"); } - return Resp.scanFail("此码不是订制品", "此码不是订制品"); - } - //查询当前扫描的包件是否进行了装车 - DistributionParcelListEntity parcelList = distributionParcelListService.selectByOrderPackageCode(distrilbutionloadingscanDTO.getBarcode(), myCurrentWarehouse.getId()); - if (Func.isEmpty(parcelList)){ - return Resp.scanFail("系统无编码", "系统无编码"); - } - if (!Objects.isNull(parcelList)) { - if (OrderPackageStatusConstant.yiqianshou.getValue().equals(parcelList.getOrderPackageStatus())) { - return Resp.scanFail("包件已签收", "包件已签收"); + //查询当前扫描的包件是否进行了装车 + DistributionParcelListEntity parcelList = distributionParcelListService.selectByOrderPackageCode(distrilbutionloadingscanDTO.getBarcode(), myCurrentWarehouse.getId()); + if (Func.isEmpty(parcelList)){ + return Resp.scanFail("系统无编码", "系统无编码"); } - } - if (!Objects.isNull(parcelList)) { - if (OrderPackageLoadingStatusConstant.yizhuangche.getValue().equals(parcelList.getOrderPackageLoadingStatus())) { - return Resp.scanFail("包件已装车", "包件已装车"); + if (!Objects.isNull(parcelList)) { + if (OrderPackageStatusConstant.yiqianshou.getValue().equals(parcelList.getOrderPackageStatus())) { + return Resp.scanFail("包件已签收", "包件已签收"); + } + } + if (!Objects.isNull(parcelList)) { + if (OrderPackageLoadingStatusConstant.yizhuangche.getValue().equals(parcelList.getOrderPackageLoadingStatus())) { + return Resp.scanFail("包件已装车", "包件已装车"); + } } - } - List abnormalEntities = distributionLoadscanAbnormalService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanAbnormalEntity::getPackageCode, distrilbutionloadingscanDTO.getBarcode()) - .eq(DistributionLoadscanAbnormalEntity::getPackageId, parcelList.getId()) - ); + List abnormalEntities = distributionLoadscanAbnormalService.list(Wrappers.query().lambda() + .eq(DistributionLoadscanAbnormalEntity::getPackageCode, distrilbutionloadingscanDTO.getBarcode()) + .eq(DistributionLoadscanAbnormalEntity::getPackageId, parcelList.getId()) + ); - if (!abnormalEntities.isEmpty()) { - //判断异常是否属于自身 - boolean flag = abnormalEntities.stream().allMatch(a -> !distributionDeliveryListEntity.getId().equals(a.getDeliveryListId()) || !distrilbutionloadingscanDTO.getReservationId().equals(a.getReservationId())); - if (flag){ - //该异常属于其他车次 - String collect = abnormalEntities.stream().map(DistributionLoadscanAbnormalEntity::getTrainNumber).collect(Collectors.joining(",")); - log.info("包件已在其他车次存在异常 >>>>当前车次:{},其他车次:{}",distributionDeliveryListEntity.getTrainNumber(),collect); - return Resp.scanFail("包件已在其他车次存在异常", "包件已在其他车次存在异常"); + if (!abnormalEntities.isEmpty()) { + //判断异常是否属于自身 + boolean flag = abnormalEntities.stream().allMatch(a -> !distributionDeliveryListEntity.getId().equals(a.getDeliveryListId()) || !distrilbutionloadingscanDTO.getReservationId().equals(a.getReservationId())); + if (flag){ + //该异常属于其他车次 + String collect = abnormalEntities.stream().map(DistributionLoadscanAbnormalEntity::getTrainNumber).collect(Collectors.joining(",")); + log.info("包件已在其他车次存在异常 >>>>当前车次:{},其他车次:{}",distributionDeliveryListEntity.getTrainNumber(),collect); + return Resp.scanFail("包件已在其他车次存在异常", "包件已在其他车次存在异常"); + } } - } - List distributionParcelListEntities = distributionDeliveryListMapper.selectPackageListByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); - if (Func.isNotEmpty(distrilbutionloadingscanDTO.getReservationId())) { - //在客户列表进行装车 - distributionParcelListEntities = distributionReservationMapper.selectPackageListByReservationId(distrilbutionloadingscanDTO.getReservationId()); - } - List parcelListEntityList = distributionParcelListEntities.stream().filter(p -> Func.equals(p.getOrderPackageCode(), distrilbutionloadingscanDTO.getBarcode())).collect(Collectors.toList()); - if (parcelListEntityList.size() == 1) { - //在配送任务中存在该包件的计划 - List distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); - if (Func.isNotEmpty(distributionLoadscanEntitiesflag) && distributionLoadscanEntitiesflag.size() == 1) { - return Resp.scanFail("重复扫码", "重复扫码"); + List distributionParcelListEntities = distributionDeliveryListMapper.selectPackageListByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); + if (Func.isNotEmpty(distrilbutionloadingscanDTO.getReservationId())) { + //在客户列表进行装车 + distributionParcelListEntities = distributionReservationMapper.selectPackageListByReservationId(distrilbutionloadingscanDTO.getReservationId()); } - DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); - if (Func.isNotEmpty(distributionDeliverySelfEntity.getDeliveryId())) { - loadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId()); - } - if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverName())) { - loadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName()); - } - if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleNub())) { - loadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub()); - } - if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleId())) { - loadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId()); - } - if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverPhone())) { - loadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone()); - } - DistributionParcelListEntity parcelListEntity = parcelListEntityList.get(0); - //添加车次号 - loadscanEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber()); - loadscanEntity.setScanStatus(LoadingStatusConstant.saomiao.getValue()); - loadscanEntity.setScanType("1"); - loadscanEntity.setOneClick(1); - loadscanEntity.setWarehouseId(myCurrentWarehouse.getId()); - loadscanEntity.setWarehouseName(myCurrentWarehouse.getName()); - loadscanEntity.setPackageId(parcelListEntity.getId()); - loadscanEntity.setOrderPackageCode(parcelListEntity.getOrderPackageCode()); - loadscanEntity.setPackageNub(parcelListEntity.getQuantity()); - DistributionReservationEntity reservationEntity = distributionDeliveryListMapper.selectReservationByPackageAndDeliveryId(parcelListEntity.getOrderPackageCode(), distrilbutionloadingscanDTO.getDeliveryId()); - - loadscanEntity.setReservationId(reservationEntity.getId()); - - loadscanEntity.setDeliveryId(distrilbutionloadingscanDTO.getDeliveryId()); - loadscanEntity.setOrderId(parcelListEntity.getStockArticleId()); - loadscanEntity.setScanTime(now); - BladeUser user = AuthUtil.getUser(); + List parcelListEntityList = distributionParcelListEntities.stream().filter(p -> Func.equals(p.getOrderPackageCode(), distrilbutionloadingscanDTO.getBarcode())).collect(Collectors.toList()); + if (parcelListEntityList.size() == 1) { + //在配送任务中存在该包件的计划 + List distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + if (Func.isNotEmpty(distributionLoadscanEntitiesflag) && distributionLoadscanEntitiesflag.size() == 1) { + return Resp.scanFail("重复扫码", "重复扫码"); + } + DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); + if (Func.isNotEmpty(distributionDeliverySelfEntity.getDeliveryId())) { + loadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId()); + } + if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverName())) { + loadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName()); + } + if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleNub())) { + loadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub()); + } + if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleId())) { + loadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId()); + } + if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverPhone())) { + loadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone()); + } + DistributionParcelListEntity parcelListEntity = parcelListEntityList.get(0); + //添加车次号 + loadscanEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber()); + loadscanEntity.setScanStatus(LoadingStatusConstant.saomiao.getValue()); + loadscanEntity.setScanType("1"); + loadscanEntity.setOneClick(1); + loadscanEntity.setWarehouseId(myCurrentWarehouse.getId()); + loadscanEntity.setWarehouseName(myCurrentWarehouse.getName()); + loadscanEntity.setPackageId(parcelListEntity.getId()); + loadscanEntity.setOrderPackageCode(parcelListEntity.getOrderPackageCode()); + loadscanEntity.setPackageNub(parcelListEntity.getQuantity()); + DistributionReservationEntity reservationEntity = distributionDeliveryListMapper.selectReservationByPackageAndDeliveryId(parcelListEntity.getOrderPackageCode(), distrilbutionloadingscanDTO.getDeliveryId()); + + loadscanEntity.setReservationId(reservationEntity.getId()); + + loadscanEntity.setDeliveryId(distrilbutionloadingscanDTO.getDeliveryId()); + loadscanEntity.setOrderId(parcelListEntity.getStockArticleId()); + loadscanEntity.setScanTime(now); + BladeUser user = AuthUtil.getUser(); // loadscanEntity.setScanUser(user.getUserName()); - loadscanEntity.setScanUser(user.getNickName()); - loadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId()); - loadscanEntity.setIsAbnormalLoading(1); - loadscanEntity.setLoadedNub(parcelListEntity.getQuantity()); - distributionLoadscanService.save(loadscanEntity); - //更新包件装车状态 - packageLockIds.add(loadscanEntity.getPackageId()); - parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); - parcelListEntity.setOrderPackageGroundingStatus(OrderPackageGroundingStatusConstant.daishangjia.getValue()); - parcelListEntity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue()); - distributionParcelListService.updateById(parcelListEntity); - //更新装车时间 - Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId()); - - //更新签收表的装车数量 - Integer j = distributionSignforMapper.updateloadByReservationId(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); - //进行解托操作 - Map info = new HashMap<>(); - info.put("orderPackageCode",parcelListEntity.getOrderPackageCode()); - info.put("warehouseId",myCurrentWarehouse.getId()); - - warehouseUpdownTypeClient.downPackageAndDelTrayAndIsUpdate(parcelListEntity.getOrderPackageCode(),myCurrentWarehouse.getId(),"扫描装车进行下架、解托",false); - - Map map = new HashMap(); - String distrilbutionloadingscanDTOJson = JSONObject.toJSONString(distrilbutionloadingscanDTO); - map.put("distrilbutionloadingscanDTO", distrilbutionloadingscanDTOJson); - String parcelListEntityJson = JSONObject.toJSONString(parcelListEntity); - map.put("parcelListEntity", parcelListEntityJson); - map.put("myCurrentWarehouseId", myCurrentWarehouse.getId()); - String reservationEntityJson = JSONObject.toJSONString(reservationEntity); - map.put("reservationEntity", reservationEntityJson); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("code",loadscanEntity.getOrderPackageCode()); - jsonObject.put("warehouseId",myCurrentWarehouse.getId()); - jsonObject.put("taskId",loadscanEntity.getReservationId()); - jsonObject.put("type",1); - jsonObject.put("num",1); - jsonObject.put("remark","装车下架"); - jsonObjects.add(jsonObject); - log.info(">>>>>>>>>>>>> 进入延迟队列处理包件相关信息状态"); - rabbitTemplate.convertAndSend(RabbitConstant.ORDER_PACKAGE_STATUS_INFO_EXCHANGE, RabbitConstant.ORDER_PACKAGE_STATUS_INFO_ROUTING, map, message -> { - message.getMessageProperties() - .setHeader("x-delay", 3000); - return message; - }); - String content = "包件在"+myCurrentWarehouse.getName()+"由"+loadscanEntity.getScanUser()+"扫描装车,配送车次号:"+distributionDeliveryListEntity.getTrainNumber()+"预约任务号:"+reservationEntity.getReservationCode(); - JSONObject trunklinePackageTrackLog= new JSONObject(); - try { - trunklinePackageTrackLog.put("tenantId",loadscanEntity.getTenantId()); - trunklinePackageTrackLog.put("createTime",loadscanEntity.getCreateTime()); - trunklinePackageTrackLog.put("createUser",loadscanEntity.getCreateUser()); - trunklinePackageTrackLog.put("updateUser",loadscanEntity.getUpdateUser()); - trunklinePackageTrackLog.put("updateTime",loadscanEntity.getUpdateTime()); - trunklinePackageTrackLog.put("isDeleted",loadscanEntity.getIsDeleted()); - trunklinePackageTrackLog.put("status",loadscanEntity.getStatus()); - trunklinePackageTrackLog.put("createDept",loadscanEntity.getCreateDept()); - trunklinePackageTrackLog.put("orderPackageCode",loadscanEntity.getOrderPackageCode()); - trunklinePackageTrackLog.put("warehouseId",myCurrentWarehouse.getId()); - trunklinePackageTrackLog.put("warehouseName",myCurrentWarehouse.getName()); - trunklinePackageTrackLog.put("workNode",WorkNodeEnums.DISTRIBUTION_LOADING.getCode()); - trunklinePackageTrackLog.put("content",content); - trunklinePackageTrackLog.put("operator",loadscanEntity.getScanUser()); - }catch (Exception e){ - log.error("装车日志数据错误",e); - } - aaa.add(trunklinePackageTrackLog); - orderPackageCodes.add(loadscanEntity.getOrderPackageCode()); + loadscanEntity.setScanUser(user.getNickName()); + loadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId()); + loadscanEntity.setIsAbnormalLoading(1); + loadscanEntity.setLoadedNub(parcelListEntity.getQuantity()); + distributionLoadscanService.save(loadscanEntity); + //更新包件装车状态 + packageLockIds.add(loadscanEntity.getPackageId()); + parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); + parcelListEntity.setOrderPackageGroundingStatus(OrderPackageGroundingStatusConstant.daishangjia.getValue()); + parcelListEntity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue()); + distributionParcelListService.updateById(parcelListEntity); + //更新装车时间 + Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId()); - pushList.add(parcelListEntity); + //更新签收表的装车数量 + Integer j = distributionSignforMapper.updateloadByReservationId(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); + //进行解托操作 + Map info = new HashMap<>(); + info.put("orderPackageCode",parcelListEntity.getOrderPackageCode()); + info.put("warehouseId",myCurrentWarehouse.getId()); + + warehouseUpdownTypeClient.downPackageAndDelTrayAndIsUpdate(parcelListEntity.getOrderPackageCode(),myCurrentWarehouse.getId(),"扫描装车进行下架、解托",false); + + Map map = new HashMap(); + String distrilbutionloadingscanDTOJson = JSONObject.toJSONString(distrilbutionloadingscanDTO); + map.put("distrilbutionloadingscanDTO", distrilbutionloadingscanDTOJson); + String parcelListEntityJson = JSONObject.toJSONString(parcelListEntity); + map.put("parcelListEntity", parcelListEntityJson); + map.put("myCurrentWarehouseId", myCurrentWarehouse.getId()); + String reservationEntityJson = JSONObject.toJSONString(reservationEntity); + map.put("reservationEntity", reservationEntityJson); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code",loadscanEntity.getOrderPackageCode()); + jsonObject.put("warehouseId",myCurrentWarehouse.getId()); + jsonObject.put("taskId",loadscanEntity.getReservationId()); + jsonObject.put("type",1); + jsonObject.put("num",1); + jsonObject.put("remark","装车下架"); + jsonObjects.add(jsonObject); + log.info(">>>>>>>>>>>>> 进入延迟队列处理包件相关信息状态"); + rabbitTemplate.convertAndSend(RabbitConstant.ORDER_PACKAGE_STATUS_INFO_EXCHANGE, RabbitConstant.ORDER_PACKAGE_STATUS_INFO_ROUTING, map, message -> { + message.getMessageProperties() + .setHeader("x-delay", 3000); + return message; + }); + JSONObject trunklinePackageTrackLog= new JSONObject(); + try { + String content = "包件在"+myCurrentWarehouse.getName()+"由"+loadscanEntity.getScanUser()+"扫描装车,配送车次号:"+distributionDeliveryListEntity.getTrainNumber()+"预约任务号:"+reservationEntity.getReservationCode(); + trunklinePackageTrackLog.put("tenantId",loadscanEntity.getTenantId()); + trunklinePackageTrackLog.put("createTime",loadscanEntity.getCreateTime()); + trunklinePackageTrackLog.put("createUser",loadscanEntity.getCreateUser()); + trunklinePackageTrackLog.put("updateUser",loadscanEntity.getUpdateUser()); + trunklinePackageTrackLog.put("updateTime",loadscanEntity.getUpdateTime()); + trunklinePackageTrackLog.put("isDeleted",loadscanEntity.getIsDeleted()); + trunklinePackageTrackLog.put("status",loadscanEntity.getStatus()); + trunklinePackageTrackLog.put("createDept",loadscanEntity.getCreateDept()); + trunklinePackageTrackLog.put("orderPackageCode",loadscanEntity.getOrderPackageCode()); + trunklinePackageTrackLog.put("warehouseId",myCurrentWarehouse.getId()); + trunklinePackageTrackLog.put("warehouseName",myCurrentWarehouse.getName()); + trunklinePackageTrackLog.put("workNode",WorkNodeEnums.DISTRIBUTION_LOADING.getCode()); + trunklinePackageTrackLog.put("content",content); + trunklinePackageTrackLog.put("operator",loadscanEntity.getScanUser()); + }catch (Exception e){ + log.error("装车日志数据错误",e); + } + aaa.add(trunklinePackageTrackLog); + orderPackageCodes.add(loadscanEntity.getOrderPackageCode()); + pushList.add(parcelListEntity); - //extracteOrderPackageStatus(distrilbutionloadingscanDTO, parcelListEntity, myCurrentWarehouse, reservationEntity); + //extracteOrderPackageStatus(distrilbutionloadingscanDTO, parcelListEntity, myCurrentWarehouse, reservationEntity); - } else if (parcelListEntityList.isEmpty()) { - //查找出该包件信息 - DistributionParcelListEntity parcelListEntity = distributionParcelListService.getOne(Wrappers.query().lambda().eq(DistributionParcelListEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()).eq(DistributionParcelListEntity::getWarehouseId, myCurrentWarehouse.getId())); - List reservationEntityList = distributionDeliveryListMapper.selectReservationByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); - boolean shangpeiFlag = reservationEntityList.stream().allMatch(r -> r.getDeliveryType().equals(DistributionTypeConstant.shipie.getValue())); - if (Func.isEmpty(parcelListEntity)) { - return Resp.scanFail("无包件信息", "无包件信息"); - } - DistributionStockArticleEntity stockArticleEntity = distributionStockArticleMapper.selectById(parcelListEntity.getStockArticleId()); - if (shangpeiFlag) { - List reservationEntities = reservationEntityList.stream().filter(r -> Func.isNotEmpty(r.getConsignee()) && r.getConsignee().equals(stockArticleEntity.getCustomerName()) && r.getDeliveryAddress().equals(stockArticleEntity.getCustomerAddress()) && r.getDeliveryPhone().equals(stockArticleEntity.getCustomerTelephone()) && r.getMallName().equals(stockArticleEntity.getMallName())).collect(Collectors.toList()); - //查看是否存在满足条件的预约单 - //存在多个,操作人指定具体客户即可 - if (!reservationEntities.isEmpty()) { - if (Func.isEmpty(distrilbutionloadingscanDTO.getReservationId())) { - log.info("异常装车未指定客户"); - return Resp.scanFail("请指定客户进行异常装车", "请指定客户进行异常装车"); - } - return R.fail(5000, "异常装车"); -// return Resp.scanFail("装车失败","程序出错,请联系彪桑"); - } else { - if (parcelListEntity.getConditions() == 2) { - return Resp.scanFail("此包件不是订制品", "此包件不是订制品"); - } else { - return Resp.scanFail("窜货", "窜货"); - } + } else if (parcelListEntityList.isEmpty()) { + //查找出该包件信息 + DistributionParcelListEntity parcelListEntity = distributionParcelListService.getOne(Wrappers.query().lambda().eq(DistributionParcelListEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()).eq(DistributionParcelListEntity::getWarehouseId, myCurrentWarehouse.getId())); + List reservationEntityList = distributionDeliveryListMapper.selectReservationByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); + boolean shangpeiFlag = reservationEntityList.stream().allMatch(r -> r.getDeliveryType().equals(DistributionTypeConstant.shipie.getValue())); + if (Func.isEmpty(parcelListEntity)) { + return Resp.scanFail("无包件信息", "无包件信息"); } - } else { - - shangpeiFlag = reservationEntityList.stream().allMatch(r -> r.getDeliveryType().equals(DistributionTypeConstant.shangpei.getValue())); + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleMapper.selectById(parcelListEntity.getStockArticleId()); if (shangpeiFlag) { - List reservationEntities = reservationEntityList.stream().filter(r -> r.getReceivingUnit().equals(stockArticleEntity.getConsigneeUnit()) && r.getMallName().equals(stockArticleEntity.getMallName())).collect(Collectors.toList()); - //查询是否满足商配异常装车 - boolean flag = reservationEntityList.stream().anyMatch(r -> r.getReceivingUnit().equals(stockArticleEntity.getConsigneeUnit()) && r.getMallName().equals(stockArticleEntity.getMallName())); - if (reservationEntities.size() == 1) { + List reservationEntities = reservationEntityList.stream().filter(r -> Func.isNotEmpty(r.getConsignee()) && r.getConsignee().equals(stockArticleEntity.getCustomerName()) && r.getDeliveryAddress().equals(stockArticleEntity.getCustomerAddress()) && r.getDeliveryPhone().equals(stockArticleEntity.getCustomerTelephone()) && r.getMallName().equals(stockArticleEntity.getMallName())).collect(Collectors.toList()); + //查看是否存在满足条件的预约单 + //存在多个,操作人指定具体客户即可 + if (!reservationEntities.isEmpty()) { if (Func.isEmpty(distrilbutionloadingscanDTO.getReservationId())) { log.info("异常装车未指定客户"); return Resp.scanFail("请指定客户进行异常装车", "请指定客户进行异常装车"); } return R.fail(5000, "异常装车"); +// return Resp.scanFail("装车失败","程序出错,请联系彪桑"); } else { - return Resp.scanFail("窜货", "窜货"); + if (parcelListEntity.getConditions() == 2) { + return Resp.scanFail("此包件不是订制品", "此包件不是订制品"); + + } else { + return Resp.scanFail("窜货", "窜货"); + } } } else { - log.error("配送计划预约类型错误:{}", reservationEntityList); + + shangpeiFlag = reservationEntityList.stream().allMatch(r -> r.getDeliveryType().equals(DistributionTypeConstant.shangpei.getValue())); + if (shangpeiFlag) { + List reservationEntities = reservationEntityList.stream().filter(r -> r.getReceivingUnit().equals(stockArticleEntity.getConsigneeUnit()) && r.getMallName().equals(stockArticleEntity.getMallName())).collect(Collectors.toList()); + //查询是否满足商配异常装车 + boolean flag = reservationEntityList.stream().anyMatch(r -> r.getReceivingUnit().equals(stockArticleEntity.getConsigneeUnit()) && r.getMallName().equals(stockArticleEntity.getMallName())); + if (reservationEntities.size() == 1) { + if (Func.isEmpty(distrilbutionloadingscanDTO.getReservationId())) { + log.info("异常装车未指定客户"); + return Resp.scanFail("请指定客户进行异常装车", "请指定客户进行异常装车"); + } + return R.fail(5000, "异常装车"); + } else { + return Resp.scanFail("窜货", "窜货"); + } + } else { + log.error("配送计划预约类型错误:{}", reservationEntityList); + } } + log.info("异常装车判定成功>>>>>>packageCode:{},reservationId:{}",distrilbutionloadingscanDTO.getBarcode(),distrilbutionloadingscanDTO.getReservationId()); } - log.info("异常装车判定成功>>>>>>packageCode:{},reservationId:{}",distrilbutionloadingscanDTO.getBarcode(),distrilbutionloadingscanDTO.getReservationId()); - } - } else if (distrilbutionloadingscanDTO.getType() == 2) { - log.info("#########!!!!!!!!!!!!!!!!!--------- 000000000 type={}", distrilbutionloadingscanDTO.getType()); - TrayTypeDataVO trayTypeDataVO = warehouseTrayTypeClient.selectListByTrayCode(distrilbutionloadingscanDTO.getBarcode()); - if (Func.isNotEmpty(trayTypeDataVO)) { - List voGoodsLsit = trayTypeDataVO.getGoodsLsit(); - boolean isAllProducts = voGoodsLsit.stream().allMatch(t -> "3".equals(t.getAssociationType())); - if (isAllProducts) { - //该托盘商全部都是订制品 - List trayGoodIds = voGoodsLsit.stream().filter(v -> "3".equals(v.getAssociationType())).map(WarehouseTrayGoodsEntity::getAssociationId).collect(Collectors.toList()); - List parcelListEntities = distributionParcelListService.listByIds(trayGoodIds); - if (trayGoodIds.size() != parcelListEntities.size()) { - return Resp.scanFail("托盘存在其他货物", "托盘存在其他货物"); - } - //判断该货物都属于同一客户才能进行装车 - List parcelListEntityList = distributionReservationMapper.selectPackageListByReservationId(distrilbutionloadingscanDTO.getReservationId()); - boolean isBelongToReservation = parcelListEntities.stream().allMatch(tp -> parcelListEntityList.stream().map(DistributionParcelListEntity::getId).collect(Collectors.toList()).contains(tp.getId())); - log.info("#########!!!!!!!!!!!!!!!!!--------- 111111111 isBelongToReservation={}", isBelongToReservation); - if (isBelongToReservation) { - log.info("#########!!!!!!!!!!!!!!!!!--------- 222222222"); - List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).ne(DistributionLoadscanEntity::getScanStatus, 1).eq(DistributionLoadscanEntity::getTrayNo, distrilbutionloadingscanDTO.getBarcode())); - boolean trayLoadingStatus = parcelListEntities.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())); - log.info("#########!!!!!!!!!!!!!!!!!--------- 333333333 trayLoadingStatus={} loadscanEntityList={}", trayLoadingStatus, loadscanEntityList); - if (Func.isNotEmpty(loadscanEntityList) && !loadscanEntityList.isEmpty() && trayLoadingStatus) { - return Resp.scanFail("重复扫描", "重复扫描"); - } - log.info("#########!!!!!!!!!!!!!!!!!--------- 444444444 parcelListEntities={}", parcelListEntities); - if (Func.isEmpty(parcelListEntities) || parcelListEntities.size() <= 0) { - return Resp.scanFail("该托盘上无货物信息", "该托盘上无货物信息"); + } else if (distrilbutionloadingscanDTO.getType() == 2) { + log.info("#########!!!!!!!!!!!!!!!!!--------- 000000000 type={}", distrilbutionloadingscanDTO.getType()); + TrayTypeDataVO trayTypeDataVO = warehouseTrayTypeClient.selectListByTrayCode(distrilbutionloadingscanDTO.getBarcode()); + if (Func.isNotEmpty(trayTypeDataVO)) { + List voGoodsLsit = trayTypeDataVO.getGoodsLsit(); + boolean isAllProducts = voGoodsLsit.stream().allMatch(t -> "3".equals(t.getAssociationType())); + if (isAllProducts) { + //该托盘商全部都是订制品 + List trayGoodIds = voGoodsLsit.stream().filter(v -> "3".equals(v.getAssociationType())).map(WarehouseTrayGoodsEntity::getAssociationId).collect(Collectors.toList()); + List parcelListEntities = distributionParcelListService.listByIds(trayGoodIds); + if (trayGoodIds.size() != parcelListEntities.size()) { + return Resp.scanFail("托盘存在其他货物", "托盘存在其他货物"); } + //判断该货物都属于同一客户才能进行装车 + List parcelListEntityList = distributionReservationMapper.selectPackageListByReservationId(distrilbutionloadingscanDTO.getReservationId()); + boolean isBelongToReservation = parcelListEntities.stream().allMatch(tp -> parcelListEntityList.stream().map(DistributionParcelListEntity::getId).collect(Collectors.toList()).contains(tp.getId())); + log.info("#########!!!!!!!!!!!!!!!!!--------- 111111111 isBelongToReservation={}", isBelongToReservation); + if (isBelongToReservation) { + log.info("#########!!!!!!!!!!!!!!!!!--------- 222222222"); + List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).ne(DistributionLoadscanEntity::getScanStatus, 1).eq(DistributionLoadscanEntity::getTrayNo, distrilbutionloadingscanDTO.getBarcode())); + boolean trayLoadingStatus = parcelListEntities.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())); + log.info("#########!!!!!!!!!!!!!!!!!--------- 333333333 trayLoadingStatus={} loadscanEntityList={}", trayLoadingStatus, loadscanEntityList); + if (Func.isNotEmpty(loadscanEntityList) && !loadscanEntityList.isEmpty() && trayLoadingStatus) { + return Resp.scanFail("重复扫描", "重复扫描"); + } + log.info("#########!!!!!!!!!!!!!!!!!--------- 444444444 parcelListEntities={}", parcelListEntities); + if (Func.isEmpty(parcelListEntities) || parcelListEntities.size() <= 0) { + return Resp.scanFail("该托盘上无货物信息", "该托盘上无货物信息"); + } - log.info("#########!!!!!!!!!!!!!!!!!--------- 55555555555 distrilbutionloadingscanDTO={}", distrilbutionloadingscanDTO); - if (Func.isNotEmpty(distrilbutionloadingscanDTO.getReservationId())) { - //存在客户 这里就是针对客户进行的整托装车 + log.info("#########!!!!!!!!!!!!!!!!!--------- 55555555555 distrilbutionloadingscanDTO={}", distrilbutionloadingscanDTO); + if (Func.isNotEmpty(distrilbutionloadingscanDTO.getReservationId())) { + //存在客户 这里就是针对客户进行的整托装车 // List parcelListEntityList = distributionReservationMapper.selectPackageListByReservationId(distrilbutionloadingscanDTO.getReservationId()); - Map parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.toMap(DistributionParcelListEntity::getId, Function.identity(), (k1, k2) -> k2)); - boolean reservationFlag = parcelListEntities.stream().allMatch(p -> Func.isNotEmpty(parcelListEntityMap.get(p.getId()))); - log.info("#########!!!!!!!!!!!!!!!!!--------- 6666666666 reservationFlag={}", reservationFlag); - if (reservationFlag) { - try { - warehouseUpdownTypeClient.downTray(distrilbutionloadingscanDTO.getBarcode(), myCurrentWarehouse.getId()); - } catch (Exception e) { - log.error("#################货物下架错误:{}", distrilbutionloadingscanDTO.getBarcode()); + Map parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.toMap(DistributionParcelListEntity::getId, Function.identity(), (k1, k2) -> k2)); + boolean reservationFlag = parcelListEntities.stream().allMatch(p -> Func.isNotEmpty(parcelListEntityMap.get(p.getId()))); + log.info("#########!!!!!!!!!!!!!!!!!--------- 6666666666 reservationFlag={}", reservationFlag); + if (reservationFlag) { + try { + warehouseUpdownTypeClient.downTray(distrilbutionloadingscanDTO.getBarcode(), myCurrentWarehouse.getId()); + } catch (Exception e) { + log.error("#################货物下架错误:{}", distrilbutionloadingscanDTO.getBarcode()); // return Resp.scanFail("装车失败", "装车失败"); - } - DistributionReservationEntity reservationEntity = distributionReservationService.getById(distrilbutionloadingscanDTO.getReservationId()); - List reservationLoadscanEntities = new ArrayList<>(); - List orderCodes = new ArrayList<>(); - for (DistributionParcelListEntity parcelListEntity : parcelListEntities) { - log.info("#########!!!!!!!!!!!!!!!!!--------- 88888888888 parcelListEntities={}", parcelListEntities); - if (parcelListEntity.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())) { - parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); - parcelListEntity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue()); - distributionParcelListService.updateById(parcelListEntity); - DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); - log.info("#########!!!!!!!!!!!!!!!!!--------- 77777777777 distributionDeliverySelfEntity={}", distributionDeliverySelfEntity); - if (Func.isNotEmpty(distributionDeliverySelfEntity.getDeliveryId())) { - loadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId()); - } - if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverName())) { - loadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName()); - } - if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleNub())) { - loadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub()); - } - if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleId())) { - loadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId()); - } - if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverPhone())) { - loadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone()); - } - loadscanEntity.setScanTime(now); - loadscanEntity.setOrderId(parcelListEntity.getStockArticleId()); - loadscanEntity.setOrderPackageCode(parcelListEntity.getOrderPackageCode()); - loadscanEntity.setReservationId(distrilbutionloadingscanDTO.getReservationId()); - loadscanEntity.setDeliveryId(distrilbutionloadingscanDTO.getDeliveryId()); - loadscanEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber()); - loadscanEntity.setPackageNub(parcelListEntity.getQuantity()); - loadscanEntity.setPackageId(parcelListEntity.getId()); - BladeUser user = AuthUtil.getUser(); + } + DistributionReservationEntity reservationEntity = distributionReservationService.getById(distrilbutionloadingscanDTO.getReservationId()); + List reservationLoadscanEntities = new ArrayList<>(); + List orderCodes = new ArrayList<>(); + for (DistributionParcelListEntity parcelListEntity : parcelListEntities) { + log.info("#########!!!!!!!!!!!!!!!!!--------- 88888888888 parcelListEntities={}", parcelListEntities); + if (parcelListEntity.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())) { + parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); + parcelListEntity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue()); + distributionParcelListService.updateById(parcelListEntity); + DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); + log.info("#########!!!!!!!!!!!!!!!!!--------- 77777777777 distributionDeliverySelfEntity={}", distributionDeliverySelfEntity); + if (Func.isNotEmpty(distributionDeliverySelfEntity.getDeliveryId())) { + loadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId()); + } + if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverName())) { + loadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName()); + } + if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleNub())) { + loadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub()); + } + if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleId())) { + loadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId()); + } + if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverPhone())) { + loadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone()); + } + loadscanEntity.setScanTime(now); + loadscanEntity.setOrderId(parcelListEntity.getStockArticleId()); + loadscanEntity.setOrderPackageCode(parcelListEntity.getOrderPackageCode()); + loadscanEntity.setReservationId(distrilbutionloadingscanDTO.getReservationId()); + loadscanEntity.setDeliveryId(distrilbutionloadingscanDTO.getDeliveryId()); + loadscanEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber()); + loadscanEntity.setPackageNub(parcelListEntity.getQuantity()); + loadscanEntity.setPackageId(parcelListEntity.getId()); + BladeUser user = AuthUtil.getUser(); // loadscanEntity.setScanUser(user.getUserName()); - loadscanEntity.setScanUser(user.getNickName()); - loadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId()); - loadscanEntity.setOneClick(1); - loadscanEntity.setScanType("2"); - loadscanEntity.setScanStatus("2"); - loadscanEntity.setIsInsert(1); - loadscanEntity.setMsg("司机整托装车"); - loadscanEntity.setTrayNo(trayTypeDataVO.getTrayCode()); - reservationLoadscanEntities.add(loadscanEntity); - Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId()); - //更新签收表的装车数量 - Integer j = distributionSignforMapper.updateloadByReservationId(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); - //扣减订单的在库数量 - orderCodes.add(parcelListEntity.getOrderCode()); - //修改包件为装车状态 - orderPackageCodes.add(parcelListEntity.getOrderPackageCode()); - parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); - distributionParcelListService.updateById(parcelListEntity); - packageLockIds.add(loadscanEntity.getPackageId()); - - String content = "包件在"+myCurrentWarehouse.getName()+"由"+loadscanEntity.getScanUser()+"扫描托盘:"+loadscanEntity.getTrayNo()+"装车,配送车次号:"+distributionDeliveryListEntity.getTrainNumber()+"预约任务号:"+reservationEntity.getReservationCode(); - JSONObject trunklinePackageTrackLog= new JSONObject(); - trunklinePackageTrackLog.put("tenantId",loadscanEntity.getTenantId()); - trunklinePackageTrackLog.put("createTime",loadscanEntity.getCreateTime()); - trunklinePackageTrackLog.put("createUser",loadscanEntity.getCreateUser()); - trunklinePackageTrackLog.put("updateUser",loadscanEntity.getUpdateUser()); - trunklinePackageTrackLog.put("updateTime",loadscanEntity.getUpdateTime()); - trunklinePackageTrackLog.put("isDeleted",loadscanEntity.getIsDeleted()); - trunklinePackageTrackLog.put("status",loadscanEntity.getStatus()); - trunklinePackageTrackLog.put("createDept",loadscanEntity.getCreateDept()); - trunklinePackageTrackLog.put("orderPackageCode",loadscanEntity.getOrderPackageCode()); - trunklinePackageTrackLog.put("warehouseId",loadscanEntity.getWarehouseId()==null?myCurrentWarehouse.getId():loadscanEntity.getWarehouseId()); - trunklinePackageTrackLog.put("warehouseName",loadscanEntity.getWarehouseName()==null?myCurrentWarehouse.getName():loadscanEntity.getWarehouseName()); - trunklinePackageTrackLog.put("workNode",WorkNodeEnums.DISTRIBUTION_LOADING.getCode()); - trunklinePackageTrackLog.put("content",content); - trunklinePackageTrackLog.put("operator",loadscanEntity.getScanUser()); - aaa.add(trunklinePackageTrackLog); - orderPackageCodes.add(loadscanEntity.getOrderPackageCode()); - pushList.add(parcelListEntity); + loadscanEntity.setScanUser(user.getNickName()); + loadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId()); + loadscanEntity.setOneClick(1); + loadscanEntity.setScanType("2"); + loadscanEntity.setScanStatus("2"); + loadscanEntity.setIsInsert(1); + loadscanEntity.setMsg("司机整托装车"); + loadscanEntity.setTrayNo(trayTypeDataVO.getTrayCode()); + reservationLoadscanEntities.add(loadscanEntity); + Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId()); + //更新签收表的装车数量 + Integer j = distributionSignforMapper.updateloadByReservationId(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); + //扣减订单的在库数量 + orderCodes.add(parcelListEntity.getOrderCode()); + //修改包件为装车状态 + orderPackageCodes.add(parcelListEntity.getOrderPackageCode()); + parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); + distributionParcelListService.updateById(parcelListEntity); + packageLockIds.add(loadscanEntity.getPackageId()); + + String content = "包件在"+myCurrentWarehouse.getName()+"由"+loadscanEntity.getScanUser()+"扫描托盘:"+loadscanEntity.getTrayNo()+"装车,配送车次号:"+distributionDeliveryListEntity.getTrainNumber()+"预约任务号:"+reservationEntity.getReservationCode(); + JSONObject trunklinePackageTrackLog= new JSONObject(); + trunklinePackageTrackLog.put("tenantId",loadscanEntity.getTenantId()); + trunklinePackageTrackLog.put("createTime",loadscanEntity.getCreateTime()); + trunklinePackageTrackLog.put("createUser",loadscanEntity.getCreateUser()); + trunklinePackageTrackLog.put("updateUser",loadscanEntity.getUpdateUser()); + trunklinePackageTrackLog.put("updateTime",loadscanEntity.getUpdateTime()); + trunklinePackageTrackLog.put("isDeleted",loadscanEntity.getIsDeleted()); + trunklinePackageTrackLog.put("status",loadscanEntity.getStatus()); + trunklinePackageTrackLog.put("createDept",loadscanEntity.getCreateDept()); + trunklinePackageTrackLog.put("orderPackageCode",loadscanEntity.getOrderPackageCode()); + trunklinePackageTrackLog.put("warehouseId",loadscanEntity.getWarehouseId()==null?myCurrentWarehouse.getId():loadscanEntity.getWarehouseId()); + trunklinePackageTrackLog.put("warehouseName",loadscanEntity.getWarehouseName()==null?myCurrentWarehouse.getName():loadscanEntity.getWarehouseName()); + trunklinePackageTrackLog.put("workNode",WorkNodeEnums.DISTRIBUTION_LOADING.getCode()); + trunklinePackageTrackLog.put("content",content); + trunklinePackageTrackLog.put("operator",loadscanEntity.getScanUser()); + aaa.add(trunklinePackageTrackLog); + orderPackageCodes.add(loadscanEntity.getOrderPackageCode()); + pushList.add(parcelListEntity); + } } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code",trayTypeDataVO.getTrayCode()); + jsonObject.put("warehouseId",myCurrentWarehouse.getId()); + jsonObject.put("taskId",distrilbutionloadingscanDTO.getReservationId()); + jsonObject.put("type",1); + jsonObject.put("num",1); + jsonObject.put("remark","装车下架"); + jsonObjects.add(jsonObject); + distributionLoadscanService.saveBatch(reservationLoadscanEntities); + //这里则进行整托装车的数据构建 + //维护订单的信息 + if (Func.isNotEmpty(orderCodes)) { + String orderCode = orderCodes.stream().distinct().collect(Collectors.joining(",")); + distributionStockArticleService.maintenanceOrderInfo(orderCode, myCurrentWarehouse.getId()); + } + if (Func.isNotEmpty(orderPackageCodes)) { + String orderPackages = orderPackageCodes.stream().distinct().collect(Collectors.joining(",")); + Map map = new HashMap<>(); + map.put("orderPackageCode",orderPackages); + map.put("warehouseId",myCurrentWarehouse.getId()); + warehouseUpdownTypeClient.downDeliveryPackage(map); + } + //维护预约的信息 + distributionReservationService.maintenanceReservationInfo(distrilbutionloadingscanDTO.getReservationId()); + //维护配送任务信息 + distributionDeliveryListService.maintenanceDeliveryInfo(distrilbutionloadingscanDTO.getDeliveryId()); + } else { + log.info("#########!!!!!!!!!!!!!!!!!--------- 101010101010 存在其他客户货物"); + return Resp.scanFail("整托装车失败", "存在其他客户货物"); } - JSONObject jsonObject = new JSONObject(); - jsonObject.put("code",trayTypeDataVO.getTrayCode()); - jsonObject.put("warehouseId",myCurrentWarehouse.getId()); - jsonObject.put("taskId",distrilbutionloadingscanDTO.getReservationId()); - jsonObject.put("type",1); - jsonObject.put("num",1); - jsonObject.put("remark","装车下架"); - jsonObjects.add(jsonObject); - distributionLoadscanService.saveBatch(reservationLoadscanEntities); - //这里则进行整托装车的数据构建 - //维护订单的信息 - if (Func.isNotEmpty(orderCodes)) { - String orderCode = orderCodes.stream().distinct().collect(Collectors.joining(",")); - distributionStockArticleService.maintenanceOrderInfo(orderCode, myCurrentWarehouse.getId()); - } - if (Func.isNotEmpty(orderPackageCodes)) { - String orderPackages = orderPackageCodes.stream().distinct().collect(Collectors.joining(",")); - Map map = new HashMap<>(); - map.put("orderPackageCode",orderPackages); - map.put("warehouseId",myCurrentWarehouse.getId()); - warehouseUpdownTypeClient.downDeliveryPackage(map); - } - //维护预约的信息 - distributionReservationService.maintenanceReservationInfo(distrilbutionloadingscanDTO.getReservationId()); - //维护配送任务信息 - distributionDeliveryListService.maintenanceDeliveryInfo(distrilbutionloadingscanDTO.getDeliveryId()); - } else { - log.info("#########!!!!!!!!!!!!!!!!!--------- 101010101010 存在其他客户货物"); - return Resp.scanFail("整托装车失败", "存在其他客户货物"); } + } else { + log.info("#########!!!!!!!!!!!!!!!!!--------- 101010101010 存在其他客户货物"); + return Resp.scanFail("整托装车失败", "存在其他客户货物"); } - } else { - log.info("#########!!!!!!!!!!!!!!!!!--------- 101010101010 存在其他客户货物"); - return Resp.scanFail("整托装车失败", "存在其他客户货物"); } + } else { + log.info("#########!!!!!!!!!!!!!!!!!--------- 101010101010 查询托盘货物失败"); + return Resp.scanFail("查询托盘货物失败", "查询托盘货物失败"); } - } else { - log.info("#########!!!!!!!!!!!!!!!!!--------- 101010101010 查询托盘货物失败"); - return Resp.scanFail("查询托盘货物失败", "查询托盘货物失败"); - } - } - if(CollUtil.isNotEmpty(pushList)){ - for (DistributionParcelListEntity parcelListEntity : pushList) { - List contents = new ArrayList<>(); - PushData pushData = PushData.builder() - .packageCode(parcelListEntity.getOrderPackageCode()) - .orderCode(parcelListEntity.getOrderCode()) - .warehouseName(myCurrentWarehouse.getName()) - .waybillNumber(parcelListEntity.getWaybillNumber()).build(); - contents.add(pushData); - NodePushMsg msg = new NodePushMsg(); - msg.setNode(WorkNodeEnums.DISTRIBUTION_LOADING); - msg.setBrand(BrandEnums.getByValue(parcelListEntity.getBrandName())); - msg.setOperator(AuthUtil.getNickName()); - msg.setOperatorTime(new Date()); - msg.setContent(contents); - log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg)); - factoryDataMessageSender.sendNodeDataByBrand(msg); - } - } - //添加缓存 - if (!packageLockIds.isEmpty()){ - List a = bladeRedis.get("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + "orderPackageCode:"); - if (Func.isNotEmpty(a)){ - boolean flag = a.stream().anyMatch(any -> packageLockIds.contains(any)); - if (flag){ - //正在操作,请稍后重试 - throw new RuntimeException("该包件正在被操作,请稍后再试!!!"); + } + if(CollUtil.isNotEmpty(pushList)){ + for (DistributionParcelListEntity parcelListEntity : pushList) { + List contents = new ArrayList<>(); + PushData pushData = PushData.builder() + .packageCode(parcelListEntity.getOrderPackageCode()) + .orderCode(parcelListEntity.getOrderCode()) + .warehouseName(myCurrentWarehouse.getName()) + .waybillNumber(parcelListEntity.getWaybillNumber()).build(); + contents.add(pushData); + NodePushMsg msg = new NodePushMsg(); + msg.setNode(WorkNodeEnums.DISTRIBUTION_LOADING); + msg.setBrand(BrandEnums.getByValue(parcelListEntity.getBrandName())); + msg.setOperator(AuthUtil.getNickName()); + msg.setOperatorTime(new Date()); + msg.setContent(contents); + log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg)); + factoryDataMessageSender.sendNodeDataByBrand(msg); + } + } + //添加缓存 + if (!packageLockIds.isEmpty()){ + List a = bladeRedis.get("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + "orderPackageCode:"); + if (Func.isNotEmpty(a)){ + boolean flag = a.stream().anyMatch(any -> packageLockIds.contains(any)); + if (flag){ + //正在操作,请稍后重试 + throw new RuntimeException("该包件正在被操作,请稍后再试!!!"); + }else { + packageLockIds.addAll(a); + bladeRedis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + "orderPackageCode:",packageLockIds,60L); + } }else { - packageLockIds.addAll(a); - bladeRedis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + "orderPackageCode:",packageLockIds,60L); + bladeRedis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + "orderPackageCode:" ,packageLockIds,60L); } - }else { - bladeRedis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + "orderPackageCode:" ,packageLockIds,60L); } - } - //备货库位下架 - log.info("备货库位下架>>>>>>>>>>>>>>>>>>>>>>jsonObjects:{}",jsonObjects); - warehouseUpdownStockUpAreaClient.downStockUpShelf(jsonObjects); - //查询已装车件数 + //备货库位下架 + log.info("备货库位下架>>>>>>>>>>>>>>>>>>>>>>jsonObjects:{}",jsonObjects); + warehouseUpdownStockUpAreaClient.downStockUpShelf(jsonObjects); + //查询已装车件数 // String str = getLoadingMsg(distrilbutionloadingscanDTO); - trunklinePackageTrackLogClient.addPackageTrackLog(aaa); + trunklinePackageTrackLogClient.addPackageTrackLog(aaa); + + Integer carLaodNum = getCarLaodNum(distrilbutionloadingscanDTO.getDeliveryId()); + return Resp.scanSuccessWithData("装车成功", carLaodNum + "件", carLaodNum); + }catch (Exception e){ + log.error("装车扫码错误",e); + throw new CustomerException(e.getMessage()); + } + - Integer carLaodNum = getCarLaodNum(distrilbutionloadingscanDTO.getDeliveryId()); - return Resp.scanSuccessWithData("装车成功", carLaodNum + "件", carLaodNum); } private void extracteOrderPackageStatus(DistrilbutionloadingscanDTO distrilbutionloadingscanDTO, DistributionParcelListEntity parcelListEntity, BasicdataWarehouseEntity myCurrentWarehouse, DistributionReservationEntity reservationEntity) { 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 f2ba7bd7f..3fa109637 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 @@ -1286,4 +1286,9 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl findALLNoUpShelfPackageByOrderCodeList(List orderCodeList, Long warehouseId) { + return baseMapper.findALLNoUpShelfPackageByOrderCodeList(orderCodeList,warehouseId); + } + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayGoodsMapper.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayGoodsMapper.java index e9a905555..860c8b33c 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayGoodsMapper.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayGoodsMapper.java @@ -94,4 +94,6 @@ public interface WarehouseTrayGoodsMapper extends BaseMapper getPackageTrayInfo(@Param("param")Map map); + + void deleteEntityByTrayGoodsIds(@Param("trayGoodsIds") List trayGoodsIds); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayGoodsMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayGoodsMapper.xml index 5ea664fd5..cd9365f17 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayGoodsMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayGoodsMapper.xml @@ -442,4 +442,12 @@ + + delete from logpm_warehouse_tray_goods + WHERE id in + + #{item} + + + diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java index e9298c9ba..42f92431b 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java @@ -133,6 +133,11 @@ public interface WarehouseUpdownGoodsMapper extends BaseMapper findParcelListByAllocationIdAndWarehouseId(@Param("allocationId") String allocationId, @Param("warehouseId") Long warehouseId); + + List findOrderPackageCodesByOrderPackageCodeList(@Param("orderPackageCodeList") List orderPackageCodeList, @Param("warehouseId") Long warehouseId); + + void deleteByUpdownGoodsIds(@Param("updownGoodsIds") List updownGoodsIds); + // /** // * 根据货位查询货物 // * diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml index 0c1a7b6c4..b155e25f2 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml @@ -537,4 +537,22 @@ and ldpl.warehouse_id = #{warehouseId} + + + + delete from logpm_warehouse_updown_goods + where id in + + #{item} + + + diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseTrayGoodsService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseTrayGoodsService.java index 3a8a05d9f..e12774a75 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseTrayGoodsService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseTrayGoodsService.java @@ -29,6 +29,8 @@ public interface IWarehouseTrayGoodsService extends BaseService trayGoodsIds, Long trayTypeId,Long warehouseId); + Boolean downZeroByTrayId(Long trayGoodsId,Long orderId,Long warehouseId,Integer num,String remark); List getZeroListByTrayTypeId(Long trayTypeId,Long warehouseId); diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseTrayTypeService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseTrayTypeService.java index 499778a40..13c37814f 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseTrayTypeService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseTrayTypeService.java @@ -2,6 +2,7 @@ package com.logpm.warehouse.service; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.logpm.distribution.entity.DistributionParcelListEntity; import com.logpm.warehouse.dto.TrayTypeDTO; import com.logpm.warehouse.dto.ZeroOrderVO; import com.logpm.warehouse.entity.WarehouseTrayTypeEntity; @@ -57,6 +58,8 @@ public interface IWarehouseTrayTypeService extends BaseService orderPackageCodeList,String remark,Long warehouseId); + void updateEntityNumByTrayGoodsIdAndNumStock(Long trayGoodsId, Integer enterNum,String remark); void downTrayGoodsByTrayId(Long trayId,String remark); @@ -113,4 +116,6 @@ public interface IWarehouseTrayTypeService extends BaseService parcelListEntityList, Long warehouseId, String remark); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownGoodsService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownGoodsService.java index 88af6a62d..35800937e 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownGoodsService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownGoodsService.java @@ -76,6 +76,7 @@ public interface IWarehouseUpdownGoodsService extends BaseService findListByUpdownTypeIdAndOrderCode(Long updownTypeId, String orderCode); void bindingAllocationAndPackage(WarehouseUpdownTypeEntity updownTypeEntity, DistributionParcelListEntity parcelListEntity, String bindingType,Integer isAlltrays,String remark); + void bindingAllocationAndPackageList(WarehouseUpdownTypeEntity updownTypeEntity, List parcelListEntities, String bindingType,Integer isAlltrays,String remark); Map getTotalNumberAndNum(Long updownTypeId); @@ -105,6 +106,7 @@ public interface IWarehouseUpdownGoodsService extends BaseService updownGoodsIds,Long updownTypeId); void updeteNumByUpdownGoodsId(int num, Long updownGoodsId); @@ -154,4 +156,6 @@ public interface IWarehouseUpdownGoodsService extends BaseService getAllocationsByOrderPackages(List orderPackageOrders, Long warehouseId); List getAllocationsByWarehouseIdAndMarketIdAndSku(Long mallId, String sku, Long warehouseId); + + List findOrderPackageCodesByOrderPackageCodeList(List orderPackageCodeList, Long warehouseId); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayGoodsServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayGoodsServiceImpl.java index 300f87826..9f68c9af3 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayGoodsServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayGoodsServiceImpl.java @@ -102,6 +102,17 @@ public class WarehouseTrayGoodsServiceImpl extends BaseServiceImpl trayGoodsIds, Long trayTypeId,Long warehouseId) { + baseMapper.deleteEntityByTrayGoodsIds(trayGoodsIds); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("tray_type_id",trayTypeId); + List list = baseMapper.selectList(queryWrapper); + return list.size(); + } + + + @Override public Boolean downZeroByTrayId(Long trayId,Long orderId,Long warehouseId,Integer num,String remark) { WarehouseTrayGoodsEntity trayGoodsEntity = baseMapper.selectOne(Wrappers.query().lambda() 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 31cbdfb18..02ec1f2ac 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 @@ -62,6 +62,8 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; @Log4j2 @Service @@ -686,6 +688,193 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl parcelListEntityList,Long warehouseId,String remark) { + + String tt = trayTypeEntity.getTrayType(); + Long filterId = trayTypeEntity.getFilterId(); + String filterValue = trayTypeEntity.getFilterValue(); + if(StringUtil.isBlank(filterValue)){ + filterValue = ""; + } + Long trayTypeId = trayTypeEntity.getId(); + Long trayTypeEntityWarehouseId = trayTypeEntity.getWarehouseId(); + + if(!trayTypeEntityWarehouseId.equals(warehouseId)){ + log.warn("##############orderScanOrderPackageCode: 托盘已在其他仓库打托 {}={}",trayTypeEntityWarehouseId,warehouseId); + throw new CustomerException(2001,"托盘已在其他仓库打托"); + } + + //把parcelListEntityList通过orderCode进行分组 + Map> map = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getOrderCode)); + + List stockArticleEntityList = distributionStockArticleClient.findListByOrderCodesAndWarehouseId(map.keySet(), warehouseId); + //把stockArticleEntityList转化成orderCode为key的Map + Map stockArticleEntityMap = stockArticleEntityList.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity())); + + Map orderPackageChuanMap = new HashMap<>(); + + String finalFilterValue = filterValue; + parcelListEntityList.forEach(parcelListEntity -> { + String orderPackageCode = parcelListEntity.getOrderPackageCode(); + String orderCode = parcelListEntity.getOrderCode(); + DistributionStockArticleEntity stockArticleEntity = stockArticleEntityMap.get(orderCode); + + boolean chuanFlag = false; + String msg = ""; + if("10".equals(tt)){//服务号 + String serviceNumber = stockArticleEntity.getServiceNumber(); + if(!finalFilterValue.equals(serviceNumber)){ + chuanFlag = true; + msg = "服务号"+ finalFilterValue; + } + }else if("20".equals(tt)){//订单自编号 + String oc = stockArticleEntity.getOrderCode(); + if(!finalFilterValue.equals(oc)){ + chuanFlag = true; + msg = "订单自编号"+ finalFilterValue; + } + }else if("30".equals(tt)){//商场 + Long mallId = stockArticleEntity.getMallId(); + String mallName = null; + if(!Objects.isNull(mallId)){ + mallName = stockArticleEntity.getMallName(); + }else{ + String dealerName = stockArticleEntity.getDealerName(); + String brand = stockArticleEntity.getBrand(); + Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, brand); + if(!Objects.isNull(clientId)){ + BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId); + if(Objects.isNull(basicdataClientEntity)){ + log.error("#############saveTrayTypeByOrderPackageCode: 未找到三方商场对应的汇通商场 clientId={}",clientId); + throw new CustomerException(405,"未找到三方商场对应的汇通商场"); + } + mallName = basicdataClientEntity.getClientName(); + }else{ + mallName = dealerName; + } + } + if(!finalFilterValue.equals(mallName)){ + chuanFlag = true; + msg = "商场"+ finalFilterValue; + } + }else if("40".equals(tt)){//门店 + Long storeId = stockArticleEntity.getStoreId(); + String storeName = stockArticleEntity.getStoreName(); + if(!finalFilterValue.equals(storeName)){ + chuanFlag = true; + msg = "门店"+ finalFilterValue; + } + }else if("50".equals(tt)){//客户 + String customerName = stockArticleEntity.getCustomerName(); + String customerTelephone = stockArticleEntity.getCustomerTelephone(); + if(!finalFilterValue.equals(customerName+customerTelephone)){ + chuanFlag = true; + msg = "客户"+ finalFilterValue; + } + }else if("60".equals(tt)){//仓库 + String warehouse = null; + String waybillNumber = parcelListEntity.getWaybillNumber(); + if(StringUtil.isBlank(waybillNumber)){ + //如果运单为空则去找有没有对应的dealName是否有对应的维护的商场信息 + String brand = stockArticleEntity.getBrand(); + String dealerName = parcelListEntity.getDealerName(); + Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, brand); + if(!Objects.isNull(clientId)){ + BasicdataStorageServicesEntity storageServicesEntity = basicdataStorageServicesClient.findEntityBySendWarehouseIdAndClientId(warehouseId, clientId); + if(!Objects.isNull(storageServicesEntity)){ + warehouse = storageServicesEntity.getServeWarehouseName(); + }else{ + warehouse = ""; + } + }else{ + warehouse = ""; + } + }else{ + WarehouseWaybillEntity waybillEntity = warehouseWaybillService.findByWaybillNo(waybillNumber); + if(!Objects.isNull(waybillEntity)){ + warehouse = waybillEntity.getDestinationWarehouseName(); + }else{ + warehouse = ""; + } + } + if(!finalFilterValue.equals(warehouse)){ + chuanFlag = true; + msg = "仓库"+ finalFilterValue; + } + } + orderPackageChuanMap.put(orderPackageCode,chuanFlag?1:0); + + }); + + List trayGoodsEntities = new ArrayList<>(); + List trayGoodsLogEntities = new ArrayList<>(); + + parcelListEntityList.forEach(parcelListEntity -> { + String orderPackageCode = parcelListEntity.getOrderPackageCode(); + Integer chuanFlag = orderPackageChuanMap.get(orderPackageCode); + if(Objects.isNull(chuanFlag)){ + chuanFlag = 1; + } + + Date date = new Date(); + WarehouseTrayGoodsEntity trayGoodsEntity = new WarehouseTrayGoodsEntity(); + BladeUser user = AuthUtil.getUser(); + if(user==null){ + trayGoodsEntity.setTenantId(TenantNum.HUITONGCODE); + trayGoodsEntity.setCreateUser(1714696768639311873L); + trayGoodsEntity.setUpdateUser(1714696768639311873L); + trayGoodsEntity.setCreateDept(1649331096241836033L); + } + + trayGoodsEntity.setTrayId(trayTypeEntity.getTrayId()); + trayGoodsEntity.setTrayTypeId(trayTypeEntity.getId()); + trayGoodsEntity.setTrayCode(trayTypeEntity.getTrayCode()); + trayGoodsEntity.setGoodsType(1); + trayGoodsEntity.setAssociationId(parcelListEntity.getId()); + trayGoodsEntity.setAssociationValue(parcelListEntity.getOrderPackageCode()); + trayGoodsEntity.setAssociationType("3"); + trayGoodsEntity.setGoodsName(parcelListEntity.getMaterialName()); + trayGoodsEntity.setNum(1); + if(chuanFlag.equals(1)){ + trayGoodsEntity.setIsFleeing("1"); + }else{ + trayGoodsEntity.setIsFleeing("0"); + } + trayGoodsEntity.setWarehouseId(trayTypeEntity.getWarehouseId()); + trayGoodsEntities.add(trayGoodsEntity); + + WarehouseTrayGoodsLogEntity trayGoodsLogEntity = new WarehouseTrayGoodsLogEntity(); + if(user==null){ + trayGoodsLogEntity.setTenantId(TenantNum.HUITONGCODE); + trayGoodsLogEntity.setCreateUser(1714696768639311873L); + trayGoodsLogEntity.setUpdateUser(1714696768639311873L); + trayGoodsLogEntity.setCreateDept(1649331096241836033L); + } + trayGoodsLogEntity.setTrayId(trayTypeEntity.getTrayId()); + trayGoodsLogEntity.setTrayTypeId(trayTypeEntity.getId()); + trayGoodsLogEntity.setAssociationId(parcelListEntity.getId()); + trayGoodsLogEntity.setAssociationValue(parcelListEntity.getOrderPackageCode()); + trayGoodsLogEntity.setAssociationType("3"); + trayGoodsLogEntity.setBindingType("1"); + trayGoodsLogEntity.setRemark(remark); + trayGoodsLogEntity.setPalletizingType("1"); + trayGoodsLogEntity.setNum(1); + trayGoodsLogEntity.setWarehouseId(trayTypeEntity.getWarehouseId()); + trayGoodsLogEntities.add(trayGoodsLogEntity); + }); + + warehouseTrayGoodsService.saveBatch(trayGoodsEntities); + warehouseTrayGoodsLogService.saveBatch(trayGoodsLogEntities); + + //更新打托方式上的值 + updateNumByTrayTypeId(trayTypeEntity); + + } + + + @Override public R orderScanOrderPackageCodeSync(String trayType, String trayCode, String orderPackageCode,Long warehouseId) { @@ -2150,6 +2339,113 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl orderPackageCodeList,String remark,Long warehouseId) { + +// List distributionParcelListEntities = distributionParcelListClient.findListByOrderPackageCodeList(orderPackageCodeList,warehouseId); +// //把distributionParcelListEntities转化成orderPackageCode为key的Map +// Map orderPackageCodeToParcelMap = distributionParcelListEntities.stream() +// .collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity(), (entity1, entity2) -> entity1)); + + QueryWrapper trayGoodsQueryWrapper = new QueryWrapper<>(); + trayGoodsQueryWrapper.eq("association_type","3") + .in("association_value",orderPackageCodeList); + List trayGoodsEntityList = warehouseTrayGoodsService.list(trayGoodsQueryWrapper); + + //把trayGoodsEntityList通过trayTypeId进行分组 + Map> trayTypeIdToTrayGoodsListMap = trayGoodsEntityList.stream() + .collect(Collectors.groupingBy(WarehouseTrayGoodsEntity::getTrayTypeId)); + + Set trayTypeIds = trayTypeIdToTrayGoodsListMap.keySet(); + List warehouseTrayTypeEntities = baseMapper.selectBatchIds(trayTypeIds); + + Map trayTypeMap = warehouseTrayTypeEntities.stream() + .collect(Collectors.toMap(WarehouseTrayTypeEntity::getId, Function.identity(), (entity1, entity2) -> entity1)); + + List toNullTrayTypeIds = new ArrayList<>(); + List updateTrayTypeIds = new ArrayList<>(); + List updateTrayIds = new ArrayList<>(); + List addTrayGoodsLogEntities = new ArrayList<>(); + + trayTypeIdToTrayGoodsListMap.keySet().forEach(trayTypeId -> { + List warehouseTrayGoodsEntities = trayTypeIdToTrayGoodsListMap.get(trayTypeId); + if(!warehouseTrayGoodsEntities.isEmpty()){ + WarehouseTrayTypeEntity trayTypeEntity = trayTypeMap.get(trayTypeId); + Long trayId = trayTypeEntity.getTrayId(); + + warehouseTrayGoodsEntities.forEach(warehouseTrayGoodsEntity -> { + WarehouseTrayGoodsLogEntity trayGoodsLogEntity = new WarehouseTrayGoodsLogEntity(); + trayGoodsLogEntity.setTrayId(warehouseTrayGoodsEntity.getTrayId()); + trayGoodsLogEntity.setTrayTypeId(trayTypeId); + trayGoodsLogEntity.setAssociationId(warehouseTrayGoodsEntity.getAssociationId()); + trayGoodsLogEntity.setAssociationValue(warehouseTrayGoodsEntity.getAssociationValue()); + trayGoodsLogEntity.setAssociationType("3"); + trayGoodsLogEntity.setBindingType("0"); + trayGoodsLogEntity.setRemark(remark); + trayGoodsLogEntity.setPalletizingType("1"); + trayGoodsLogEntity.setNum(1); + trayGoodsLogEntity.setWarehouseId(warehouseId); + addTrayGoodsLogEntities.add(trayGoodsLogEntity); + }); + + List trayGoodsIds = warehouseTrayGoodsEntities.stream() + .map(WarehouseTrayGoodsEntity::getId) + .collect(Collectors.toList()); + Integer residueNum = warehouseTrayGoodsService.deleteByTrayGoodsIds(trayGoodsIds, trayTypeId, warehouseId); + if(residueNum == 0){ + //空置托盘 + toNullTrayTypeIds.add(trayTypeId); + //更新托盘状态 + updateTrayIds.add(trayId); + }else{ + updateTrayTypeIds.add(trayTypeId); + } + } + }); + + //空置的托盘打托id + removeByIds(toNullTrayTypeIds); + //更新托盘状态 + basicdataTrayClient.updateTrayStatusByTrayIds(updateTrayIds,1); + //添加下托日志 + warehouseTrayGoodsLogService.saveBatch(addTrayGoodsLogEntities); + updateTrayTypeIds.forEach(trayTypeId -> { + WarehouseTrayTypeEntity trayTypeEntity = trayTypeMap.get(trayTypeId); + if(!Objects.isNull(trayTypeEntity)){ + updateNumByTrayTypeId(trayTypeEntity); + } + }); + +// if (!Objects.isNull(trayGoodsEntity)){ +// Long trayGoodsId = trayGoodsEntity.getId(); +// Long trayTypeId = trayGoodsEntity.getTrayTypeId(); +// Long trayId = trayGoodsEntity.getTrayId(); +// 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()); +// } + } + + @Override public void updateEntityNumByTrayGoodsIdAndNumStock(Long trayGoodsId, Integer enterNum,String remark) { WarehouseTrayGoodsEntity trayGoodsEntity = warehouseTrayGoodsService.getById(trayGoodsId); 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 58b020cbf..47eb5bf00 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 @@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.distribution.entity.DistributionParcelListEntity; import com.logpm.warehouse.entity.WarehouseUpdownGoodsEntity; +import com.logpm.warehouse.entity.WarehouseUpdownGoodsLogEntity; import com.logpm.warehouse.entity.WarehouseUpdownTypeEntity; import com.logpm.warehouse.excel.WarehouseUpdownGoodsExcel; import com.logpm.warehouse.mapper.WarehouseUpdownGoodsMapper; @@ -124,6 +125,65 @@ public class WarehouseUpdownGoodsServiceImpl extends BaseServiceImpl parcelListEntities, String bindingType,Integer isAlltrays,String remark) { + List updownGoodsEntities = new ArrayList<>(); + List updownGoodsLogEntities = new ArrayList<>(); + parcelListEntities.forEach(parcelListEntity -> { + WarehouseUpdownGoodsEntity updownGoodsEntity = new WarehouseUpdownGoodsEntity(); + updownGoodsEntity.setCreateUser(1714696768639311873L); + updownGoodsEntity.setUpdateUser(1714696768639311873L); + updownGoodsEntity.setCreateDept(1649331096241836033L); + updownGoodsEntity.setTenantId(TenantNum.HUITONGCODE); + updownGoodsEntity.setUpdownTypeId(updownTypeEntity.getId()); + updownGoodsEntity.setAreaId(updownTypeEntity.getAreaId()); + updownGoodsEntity.setAreaTitle(updownTypeEntity.getAreaTitle()); + updownGoodsEntity.setShelfId(updownTypeEntity.getShelfId()); + updownGoodsEntity.setShelfTitle(updownTypeEntity.getShelfTitle()); + updownGoodsEntity.setAllocationId(updownTypeEntity.getAllocationId()); + updownGoodsEntity.setAllocationTitle(updownTypeEntity.getAllocationTitle()); + updownGoodsEntity.setPositionCode(updownTypeEntity.getPositionCode()); + updownGoodsEntity.setAssociationId(parcelListEntity.getId()); + updownGoodsEntity.setAssociationValue(parcelListEntity.getOrderPackageCode()); + updownGoodsEntity.setAssociationType("3");//包件 + updownGoodsEntity.setNum(1); + updownGoodsEntity.setWarehouseId(updownTypeEntity.getWarehouseId()); + updownGoodsEntities.add(updownGoodsEntity); + + 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(bindingType); + warehouseUpdownGoodsLogEntity.setIsAlltrays(isAlltrays); + 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("20"); + + }); + + saveBatch(updownGoodsEntities); + warehouseUpdownGoodsLogService.saveBatch(updownGoodsLogEntities); + } + + + @Override public Map getTotalNumberAndNum(Long updownTypeId) { return baseMapper.getTotalNumberAndNum(updownTypeId); @@ -173,6 +233,15 @@ public class WarehouseUpdownGoodsServiceImpl extends BaseServiceImpl updownGoodsIds,Long updownTypeId) { + baseMapper.deleteByUpdownGoodsIds(updownGoodsIds); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("updown_type_id",updownTypeId); + List updownGoodsEntities = baseMapper.selectList(queryWrapper); + return updownGoodsEntities.size(); + } + @Override public void updeteNumByUpdownGoodsId(int num, Long updownGoodsId) { baseMapper.updeteNumByUpdownGoodsId(num,updownGoodsId); @@ -273,4 +342,9 @@ public class WarehouseUpdownGoodsServiceImpl extends BaseServiceImpl findOrderPackageCodesByOrderPackageCodeList(List orderPackageCodeList, Long warehouseId) { + return baseMapper.findOrderPackageCodesByOrderPackageCodeList(orderPackageCodeList,warehouseId); + } + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java index 6f506edba..1c0f73355 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java @@ -32,6 +32,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; @Log4j2 @@ -828,19 +829,18 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl upShelfOrderList, Long allocationId, Long warehouseId, String remrk) { int num = 0; String trayCode = null; + WarehouseTrayTypeEntity trayTypeEntity = null; //判断货位是否有托盘 BasicdataTrayEntity trayEntity = warehouseTaryAllocationService.getTrayByAllocationId(allocationId); String trayType = null; if (!Objects.isNull(trayEntity)) { trayCode = trayEntity.getPalletCode(); - //如果有托盘 - TrayTypeDataVO entityByTrayCode = warehouseTrayTypeService.getEntityByTrayCodeWithUpdown(trayCode); - trayType = entityByTrayCode.getTrayType(); -// String type = entityByTrayCode.getType();//数据类型 1订制品 2零担 3 4 库存品 -// if(!"1".equals(type)){ -// log.warn("##############upShelfOrder: 库位上的托盘是定制品类型 allocationId={}",allocationId); -// return R.fail(403,"库位上的托盘是定制品类型"); -// } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("tray_code", trayCode) + .eq("is_deleted", 0); + trayTypeEntity = warehouseTrayTypeService.getOne(queryWrapper); + trayType = trayTypeEntity.getTrayType(); + } @@ -877,46 +877,27 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl orderCodeList = upShelfOrderList.stream().map(UpShelfOrderDTO::getOrderCode).collect(Collectors.toList()); + List parcelListList = distributionParcelListClient.findALLNoUpShelfPackageByOrderCodeList(orderCodeList, warehouseId); - for (UpShelfOrderDTO upShelfOrderDTO : upShelfOrderList) { - String orderCode = upShelfOrderDTO.getOrderCode(); - if (StringUtil.isBlank(orderCode)) { - log.warn("##############upShelfOrder: 订单号不存在 orderCode={}", orderCode); - continue; - } - //查询所有该订单号未上架的数据 - List parcelListList = distributionParcelListClient.findALLNoUpShelfPackageByOrderCode(orderCode, warehouseId); - for (DistributionParcelListEntity parcelListEntity : parcelListList) { - try { - String orderPackageCode = parcelListEntity.getOrderPackageCode(); - Integer quantity = parcelListEntity.getQuantity(); - - if (StringUtil.hasLength(trayCode)) { + List upShelfPackageList = new ArrayList<>(); - //存入托盘信息 - warehouseTrayTypeService.orderScanOrderPackageCode(trayType, trayCode, orderPackageCode, warehouseId, remrk + "并上架"); - } - //包件级别的上架 - upShelfPackageNoTray(parcelListEntity, goodsAllocationEntity, goodsShelfEntity, goodsAreaEntity, warehouseId, remrk); + parcelListList.forEach(parcelListEntity -> { + UpShelfPackageDTO upShelfPackageDTO = new UpShelfPackageDTO(); + upShelfPackageDTO.setOrderPackageCode(parcelListEntity.getOrderPackageCode()); + upShelfPackageList.add(upShelfPackageDTO); + }); - num = num + quantity; - } catch (CustomerException e) { - log.warn(e.message); - continue; - } catch (Exception e) { - log.warn(e.getMessage()); - continue; - } - } - } - return Resp.scanSuccess("上架成功", "成功上架" + num + "条"); + return upShelfPackage(upShelfPackageList, allocationId, warehouseId, remrk); } + @Transactional(rollbackFor = Exception.class) @Override public R upShelfPackage(List upShelfPackageList, Long allocationId, Long warehouseId, String remark) { int num = 0; String trayCode = null; - String trayType = null; + WarehouseTrayTypeEntity trayTypeEntity = null; //判断货位是否有托盘 BasicdataTrayEntity trayEntity = warehouseTaryAllocationService.getTrayByAllocationId(allocationId); if (!Objects.isNull(trayEntity)) { @@ -925,8 +906,7 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("tray_code", trayCode) .eq("is_deleted", 0); - WarehouseTrayTypeEntity trayTypeEntity = warehouseTrayTypeService.getOne(queryWrapper); - trayType = trayTypeEntity.getTrayType(); + trayTypeEntity = warehouseTrayTypeService.getOne(queryWrapper); // String type = trayTypeEntity.getType();//数据类型 1订制品 2零担 3 4 库存品 // if(!"1".equals(type)){ // log.warn("##############upShelfOrder: 库位上的托盘是定制品类型 allocationId={}",allocationId); @@ -973,60 +953,89 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl + List orderPackageCodeList = upShelfPackageList.stream().map(UpShelfPackageDTO::getOrderPackageCode).collect(Collectors.toList()); + log.info("##############upShelfPackage: 当前处理的包件码 orderPackageCodeList={}", orderPackageCodeList); + //判断包件是否已经上架 + List hasOrderPackageCodes = warehouseUpdownGoodsService.findOrderPackageCodesByOrderPackageCodeList(orderPackageCodeList, warehouseId); + orderPackageCodeList.removeAll(hasOrderPackageCodes); - for (UpShelfPackageDTO upShelfPackageDTO : upShelfPackageList) { - String orderPackageCode = upShelfPackageDTO.getOrderPackageCode(); - log.info("##############upShelfPackage: 当前处理的包件码 orderPackageCode={}", orderPackageCode); - try { - //判断包件是否已经上架 - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("association_value", orderPackageCode) - .eq("warehouse_id", warehouseId); - WarehouseUpdownGoodsEntity updownGoodsEntity = warehouseUpdownGoodsService.getOne(queryWrapper); - if (!Objects.isNull(updownGoodsEntity)) { - log.warn("##############upShelfPackage: 包件已上架 orderPackageCode={}", orderPackageCode); - continue; - } - //判断包件是否有绑托盘, - QueryWrapper trayGoodsQueryWrapper = new QueryWrapper<>(); - trayGoodsQueryWrapper.eq("association_value", orderPackageCode); - WarehouseTrayGoodsEntity trayGoodsEntity = warehouseTrayGoodsService.getOne(trayGoodsQueryWrapper); - if (!Objects.isNull(trayGoodsEntity)) { -// log.warn("##############upShelfPackage: 包件已打托 orderPackageCode={}",orderPackageCode); -// continue; - //已打托的数据需要取消托盘绑定 - warehouseTrayTypeService.downPackageByOrderPackageCode(orderPackageCode, "扫描上架:包件下托", warehouseId); - } + //判断包件是否有绑托盘, + QueryWrapper trayGoodsQueryWrapper = new QueryWrapper<>(); + trayGoodsQueryWrapper.in("association_value", orderPackageCodeList); + List trayGoodsEntityList = warehouseTrayGoodsService.list(trayGoodsQueryWrapper); + if(!trayGoodsEntityList.isEmpty()){ + //把trayGoodsEntityList中的association_value提取出来存入一个List + List orderPackageCodes = trayGoodsEntityList.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toList()); + warehouseTrayTypeService.downPackageByOrderPackageCodeList(orderPackageCodes,"同步处理:包件解托",warehouseId); + } + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(orderPackageCodeList, warehouseId); + //排除parcelListEntityList中元素orderPackageStatus 不等于20的 + parcelListEntityList = parcelListEntityList.stream().filter(parcelListEntity -> "20".equals(parcelListEntity.getOrderPackageStatus())).collect(Collectors.toList()); - DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId); - Integer conditions = parcelListEntity.getConditions(); - Integer quantity = parcelListEntity.getQuantity(); - String orderPackageStatus = parcelListEntity.getOrderPackageStatus(); - if (!"20".equals(orderPackageStatus)) { - log.warn("##############upShelfPackage: 包件已不在库 orderPackageCode={} warehouseId={}", orderPackageCode, warehouseId); - return Resp.scanFail(403, "包件已不在库", "包件已不在库"); - } -// if(conditions != 1){ -// log.warn("##############upShelfPackage: 包件已转库存品 orderPackageCode={}",orderPackageCode); -// continue; -// } - if (StringUtil.hasLength(trayCode)) { - //存入托盘信息 - warehouseTrayTypeService.orderScanOrderPackageCode(trayType, trayCode, orderPackageCode, warehouseId, remark + "并打托"); - } - //包件级别的上架 - upShelfPackageNoTray(parcelListEntity, goodsAllocationEntity, goodsShelfEntity, goodsAreaEntity, warehouseId, remark); - num = num + quantity; - } catch (CustomerException e) { - log.warn(e.message); - continue; - } catch (Exception e) { - log.warn(e.getMessage()); - continue; - } + if (StringUtil.hasLength(trayCode)) { + //存入托盘信息 + warehouseTrayTypeService.orderScanOrderPackageCodeList(trayTypeEntity, parcelListEntityList, warehouseId, remark + "并打托"); } + //包件级别的上架 + upShelfPackageListNoTray(parcelListEntityList, goodsAllocationEntity, goodsShelfEntity, goodsAreaEntity, warehouseId, remark); + num = num + parcelListEntityList.size(); + //更新货位缓存 warehouseGoodsAllocationClient.updateAllocationCache(allocationId.toString()); + +// for (UpShelfPackageDTO upShelfPackageDTO : upShelfPackageList) { +// String orderPackageCode = upShelfPackageDTO.getOrderPackageCode(); +// log.info("##############upShelfPackage: 当前处理的包件码 orderPackageCode={}", orderPackageCode); +// try { +// //判断包件是否已经上架 +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq("association_value", orderPackageCode) +// .eq("warehouse_id", warehouseId); +// WarehouseUpdownGoodsEntity updownGoodsEntity = warehouseUpdownGoodsService.getOne(queryWrapper); +// if (!Objects.isNull(updownGoodsEntity)) { +// log.warn("##############upShelfPackage: 包件已上架 orderPackageCode={}", orderPackageCode); +// continue; +// } +// //判断包件是否有绑托盘, +// QueryWrapper trayGoodsQueryWrapper = new QueryWrapper<>(); +// trayGoodsQueryWrapper.eq("association_value", orderPackageCode); +// WarehouseTrayGoodsEntity trayGoodsEntity = warehouseTrayGoodsService.getOne(trayGoodsQueryWrapper); +// if (!Objects.isNull(trayGoodsEntity)) { +//// log.warn("##############upShelfPackage: 包件已打托 orderPackageCode={}",orderPackageCode); +//// continue; +// //已打托的数据需要取消托盘绑定 +// warehouseTrayTypeService.downPackageByOrderPackageCode(orderPackageCode, "扫描上架:包件下托", warehouseId); +// } +// +// DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId); +// Integer conditions = parcelListEntity.getConditions(); +// Integer quantity = parcelListEntity.getQuantity(); +// String orderPackageStatus = parcelListEntity.getOrderPackageStatus(); +// if (!"20".equals(orderPackageStatus)) { +// log.warn("##############upShelfPackage: 包件已不在库 orderPackageCode={} warehouseId={}", orderPackageCode, warehouseId); +// return Resp.scanFail(403, "包件已不在库", "包件已不在库"); +// } +//// if(conditions != 1){ +//// log.warn("##############upShelfPackage: 包件已转库存品 orderPackageCode={}",orderPackageCode); +//// continue; +//// } +// if (StringUtil.hasLength(trayCode)) { +// //存入托盘信息 +// warehouseTrayTypeService.orderScanOrderPackageCodeList(trayTypeEntity, orderPackageCodeList, warehouseId, remark + "并打托"); +// } +// //包件级别的上架 +// upShelfPackageNoTray(parcelListEntity, goodsAllocationEntity, goodsShelfEntity, goodsAreaEntity, warehouseId, remark); +// num = num + quantity; +// } catch (CustomerException e) { +// log.warn(e.message); +// continue; +// } catch (Exception e) { +// log.warn(e.getMessage()); +// continue; +// } +// } + return Resp.scanSuccess("上架成功", "成功上架" + num + "条"); } @@ -1405,58 +1414,133 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl upShelfPackageList, Long warehouseId, String remark) { int num = 0; - Set orderSet = new TreeSet<>(); - for (UpShelfPackageDTO upShelfPackageDTO : upShelfPackageList) { - String orderPackageCode = upShelfPackageDTO.getOrderPackageCode(); - //查询包件在哪个库位上 - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("association_type", "3") - .eq("warehouse_id", warehouseId) - .eq("association_value", orderPackageCode); - WarehouseUpdownGoodsEntity updownGoodsEntity = warehouseUpdownGoodsService.getOne(queryWrapper); - if (Objects.isNull(updownGoodsEntity)) { - log.warn("##############downPackage: 包件没有上架记录 orderPackageCode={}", orderPackageCode); - continue; - } - Long allocationId = updownGoodsEntity.getAllocationId(); - DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId); - Integer quantity = parcelListEntity.getQuantity(); - String orderCode = parcelListEntity.getOrderCode(); - Long updownGoodsId = updownGoodsEntity.getId(); - Long updownTypeId = updownGoodsEntity.getUpdownTypeId(); - WarehouseUpdownTypeEntity updownTypeEntity = baseMapper.selectById(updownTypeId); + 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()); + + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(associationValueList, warehouseId); + //把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); -// BasicdataTrayEntity trayEntity = warehouseTaryAllocationService.getTrayByAllocationId(allocationId); - if (!Objects.isNull(taryAllocationEntity)) { - //有托盘,托盘下托 - warehouseTrayTypeService.downPackageByOrderPackageCode(orderPackageCode, remark + ":同步下托", warehouseId); + List updownGoodsEntities1 = map.get(allocationId); + List orderPackageCodes = updownGoodsEntities1.stream().map(WarehouseUpdownGoodsEntity::getAssociationValue).collect(Collectors.toList()); + if(!Objects.isNull(taryAllocationEntity)){ + warehouseTrayTypeService.downPackageByOrderPackageCodeList(orderPackageCodes, remark, warehouseId); } - Integer residue = warehouseUpdownGoodsService.deleteByUpdownGoodsId(updownGoodsId); + 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) { //删除上架方式 - removeById(updownTypeId); + toNullUpdownTypeIds.add(updownTypeId); //修改库位状态为空闲 - basicdataGoodsAllocationClient.updateAllocationStatus(allocationId, "1"); + updateAllocationIds.add(allocationId); +// basicdataGoodsAllocationClient.updateAllocationStatus(allocationId, "1"); //如果有托盘还要删除托盘与库位的绑定 if (!Objects.isNull(taryAllocationEntity)) { - warehouseTaryAllocationService.deleteById(taryAllocationEntity); + deleteTrayAllocationList.add(taryAllocationEntity); +// warehouseTaryAllocationService.deleteById(taryAllocationEntity); } + }else{ + updateUpdownTypeList.add(updownTypeEntity); } - warehouseUpdownGoodsLogService.saveAllocationAndPackage(updownTypeEntity, parcelListEntity, "2", 0, remark + ":包件下架"); - updatePackageGroundingStatus(orderPackageCode, "10", warehouseId); - updateUpdownTypeNum(updownTypeEntity); - orderSet.add(orderCode); - num = num + quantity; + + 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); + + }); + + removeByIds(toNullUpdownTypeIds); + basicdataGoodsAllocationClient.updateListAllocationStatus(updateAllocationIds,"1"); + warehouseTaryAllocationService.removeBatchByIds(deleteTrayAllocationList); + + updateUpdownTypeList.forEach(this::updateUpdownTypeNum); + + warehouseUpdownGoodsLogService.saveBatch(updownGoodsLogEntities); + + distributionParcelListClient.updateList(updownParcelEntities); + + map.keySet().forEach(allocationId -> { warehouseGoodsAllocationClient.updateAllocationCache(allocationId.toString()); - } + }); for (String orderCode : orderSet) { distributionStockArticleClient.updateOrderInfo(orderCode, warehouseId); } + num = num + updownParcelEntities.size(); return Resp.scanSuccess("下架成功", "成功下架" + num + "件"); } @@ -2961,6 +3045,37 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl parcelListEntities, BasicdataGoodsAllocationEntity goodsAllocationEntity, BasicdataGoodsShelfEntity goodsShelfEntity, BasicdataGoodsAreaEntity goodsAreaEntity, Long warehouseId, String remrk) { + log.info("###########upShelfPackageNoTray: 上架包件没有托盘 parcelListEntities={} allocationCode={}", parcelListEntities, goodsAllocationEntity.getGoodsAllocationName()); + //修改上架方式的数量 + + QueryWrapper updownTypeEntityQueryWrapper = new QueryWrapper<>(); + updownTypeEntityQueryWrapper.eq("allocation_id", goodsAllocationEntity.getId()) + .eq("is_deleted", 0); + WarehouseUpdownTypeEntity updownTypeEntity = baseMapper.selectOne(updownTypeEntityQueryWrapper); + if (Objects.isNull(updownTypeEntity)) { + updownTypeEntity = createUpdownType("1", goodsAllocationEntity, goodsShelfEntity, goodsAreaEntity, warehouseId); + } + + Long wid = updownTypeEntity.getWarehouseId(); + if (!wid.equals(warehouseId)) { + log.warn("##############upShelfPackageNoTray: 库位不在当前仓库 wid={}", wid); + throw new CustomerException(403, "库位不在当前仓库"); + } + + //货物和库位绑定 + warehouseUpdownGoodsService.bindingAllocationAndPackageList(updownTypeEntity, parcelListEntities, "1", 0, remrk); + + distributionParcelListClient.updateList(parcelListEntities); + + //修改上架方式上的数据 + updateUpdownTypeNum(updownTypeEntity); + + } + + + private void updateUpdownTypeNum(WarehouseUpdownTypeEntity updownTypeEntity) { Long updownTypeId = updownTypeEntity.getId(); Long warehouseId = updownTypeEntity.getWarehouseId();