diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java index 91dc0b9f2..11a19bfbe 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java @@ -2976,7 +2976,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { } @Override - @Async + @LogpmAsync("asyncExecutor") public void recordsReservationDeliveryLog(String reservationIds,BasicdataWarehouseEntity warehouse,BladeUser user,String trainNumber) { List list = Func.toLongList(reservationIds); if (!list.isEmpty()) { 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 8a2cb507d..4ab229496 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 @@ -583,21 +583,20 @@ 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); } - 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("此码不是订制品", "此码不是订制品"); - } - //查询当前扫描的包件是否进行了装车 - DistributionParcelListEntity parcelList = distributionParcelListService.selectByOrderPackageCode(distrilbutionloadingscanDTO.getBarcode(), myCurrentWarehouse.getId()); - if (Func.isEmpty(parcelList)){ - return Resp.scanFail("系统无编码", "系统无编码"); + } 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("请在库存品页面扫描此码", "请在库存品页面扫描此码"); } - if (!Objects.isNull(parcelList)) { - if (OrderPackageStatusConstant.yiqianshou.getValue().equals(parcelList.getOrderPackageStatus())) { - 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("包件已签收", "包件已签收"); } - if (!Objects.isNull(parcelList)) { - if (OrderPackageLoadingStatusConstant.yizhuangche.getValue().equals(parcelList.getOrderPackageLoadingStatus())) { - 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 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 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(); + 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()); + 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; - }); - 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()); + //更新签收表的装车数量 + 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= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_LOADING.getCode()); + aaa.add(trunklinePackageTrackLog); + orderPackageCodes.add(loadscanEntity.getOrderPackageCode()); + + pushList.add(parcelListEntity); - 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 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 { + return Resp.scanFail("窜货", "窜货"); + } } - DistributionStockArticleEntity stockArticleEntity = distributionStockArticleMapper.selectById(parcelListEntity.getStockArticleId()); + } else { + + shangpeiFlag = reservationEntityList.stream().allMatch(r -> r.getDeliveryType().equals(DistributionTypeConstant.shangpei.getValue())); 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()) { + 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, "异常装车"); -// return Resp.scanFail("装车失败","程序出错,请联系彪桑"); } else { - if (parcelListEntity.getConditions() == 2) { - return Resp.scanFail("此包件不是订制品", "此包件不是订制品"); - - } else { - return Resp.scanFail("窜货", "窜货"); - } + return Resp.scanFail("窜货", "窜货"); } } else { - - 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.error("配送计划预约类型错误:{}", reservationEntityList); } - 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("托盘存在其他货物", "托盘存在其他货物"); + 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("该托盘上无货物信息", "该托盘上无货物信息"); } - //判断该货物都属于同一客户才能进行装车 - 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(); -// 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); + } + 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= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_LOADING.getCode()); + 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("查询托盘货物失败", "查询托盘货物失败"); - } - } - 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 { + 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("该包件正在被操作,请稍后再试!!!"); }else { - bladeRedis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + "orderPackageCode:" ,packageLockIds,60L); + packageLockIds.addAll(a); + 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); - //查询已装车件数 -// String str = getLoadingMsg(distrilbutionloadingscanDTO); - trunklinePackageTrackLogClient.addPackageTrackLog(aaa); - - Integer carLaodNum = getCarLaodNum(distrilbutionloadingscanDTO.getDeliveryId()); - return Resp.scanSuccessWithData("装车成功", carLaodNum + "件", carLaodNum); - }catch (Exception e){ - log.error("装车扫码错误",e); - throw new CustomerException(e.getMessage()); } + //备货库位下架 + log.info("备货库位下架>>>>>>>>>>>>>>>>>>>>>>jsonObjects:{}",jsonObjects); + warehouseUpdownStockUpAreaClient.downStockUpShelf(jsonObjects); + //查询已装车件数 +// String str = getLoadingMsg(distrilbutionloadingscanDTO); + trunklinePackageTrackLogClient.addPackageTrackLog(aaa); - + Integer carLaodNum = getCarLaodNum(distrilbutionloadingscanDTO.getDeliveryId()); + return Resp.scanSuccessWithData("装车成功", carLaodNum + "件", carLaodNum); } private void extracteOrderPackageStatus(DistrilbutionloadingscanDTO distrilbutionloadingscanDTO, DistributionParcelListEntity parcelListEntity, BasicdataWarehouseEntity myCurrentWarehouse, DistributionReservationEntity reservationEntity) { @@ -5507,25 +5468,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl>>>>>>>>>>>>>>>>>>data:{}",trunklinePackageTrackLog); - } + JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_LOADING.getCode()); aaa.add(trunklinePackageTrackLog); orderPackageCodes.add(loadscanEntity.getOrderPackageCode()); @@ -7387,4 +7330,23 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl>>>>>>>>>Warehouse:{},ScanUser:{},TrainNumber:{},ReservationCode:{}",myCurrentWarehouse.getName(),distributionLoadscanEntity.getSigningUser(),deliveryListEntity.getTrainNumber(),distributionReservationEntity.getReservationCode()); String content = "包件在"+myCurrentWarehouse.getName()+"由"+distributionLoadscanEntity.getSigningUser()+"扫描签收,装车方式:补录装车,配送车次号:"+deliveryListEntity.getTrainNumber()+"预约任务号:"+distributionReservationEntity.getReservationCode(); - JSONObject trunklinePackageTrackLog= new JSONObject(); - trunklinePackageTrackLog.put("tenantId",distributionLoadscanEntity.getTenantId()); - trunklinePackageTrackLog.put("createTime",distributionLoadscanEntity.getCreateTime()); - trunklinePackageTrackLog.put("createUser",distributionLoadscanEntity.getCreateUser()); - trunklinePackageTrackLog.put("updateUser",distributionLoadscanEntity.getUpdateUser()); - trunklinePackageTrackLog.put("updateTime",distributionLoadscanEntity.getUpdateTime()); - trunklinePackageTrackLog.put("isDeleted",distributionLoadscanEntity.getIsDeleted()); - trunklinePackageTrackLog.put("status",distributionLoadscanEntity.getStatus()); - trunklinePackageTrackLog.put("createDept",distributionLoadscanEntity.getCreateDept()); - trunklinePackageTrackLog.put("orderPackageCode",distributionLoadscanEntity.getOrderPackageCode()); - trunklinePackageTrackLog.put("warehouseId",myCurrentWarehouse.getId()); - trunklinePackageTrackLog.put("warehouseName",myCurrentWarehouse.getName()); - trunklinePackageTrackLog.put("workNode", WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode()); - trunklinePackageTrackLog.put("content",content); - trunklinePackageTrackLog.put("operator",distributionLoadscanEntity.getScanUser()); + JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode()); aaa.add(trunklinePackageTrackLog); orderPackageCodes.add(distributionLoadscanEntity.getOrderPackageCode()); - - } //修改包件状态为装车、签收 DistributionParcelListEntity updatePackage = collect.get(0); @@ -3169,7 +3139,6 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl>>>>>>>>>>>>>>>data:{}",trunklinePackageTrackLog); - throw new RuntimeException("该包件正在被操作,请稍后再试!!!"); - } + JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_SIGN_FOR.getCode()); aaa.add(trunklinePackageTrackLog); orderPackageCodes.add(loadscanEntity.getOrderPackageCode()); @@ -5178,18 +5111,8 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl> packageMap = distributionParcelListEntities.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getConditions)); List ladingScanEntities = new ArrayList<>(); if (!packageMap.isEmpty()) { -// packageMap.forEach((k,v)->{ -// switch (k){ -// case 1: -// //定制品 -// for (DistributionParcelListEntity parcelListEntity : v) { -// DistributionBillLadingScanEntity distributionBillLadingScanEntity = new DistributionBillLadingScanEntity(); -// distributionBillLadingScanEntity.setPacketBarCode(parcelListEntity.getOrderPackageCode()); -// distributionBillLadingScanEntity.setScanType(3); -// distributionBillLadingScanEntity.setParcelListId(parcelListEntity.getId()); -// distributionBillLadingScanEntity.setOrderSelfNumbering(parcelListEntity.getOrderCode()); -// distributionBillLadingScanEntity.setStockArticleId(parcelListEntity.getStockArticleId()); -// distributionBillLadingScanEntity.setBillLadingId(distrilbutionBillLading.getId()); -// distributionBillLadingScanEntity.setMaterialType("2"); -// distributionBillLadingScanEntity.setQuantity(parcelListEntity.getQuantity()); -// ladingScanEntities.add(distributionBillLadingScanEntity); -// //修改包件状态 -// distributionParcelListService.update(Wrappers.update().lambda() -// .eq(DistributionParcelListEntity::getId,parcelListEntity.getId()) -// .set(DistributionParcelListEntity::getOrderPackageReservationStatus,OrderPackageReservationStatusConstant.yiyueyue.getValue()) -// .set(DistributionParcelListEntity::getOrderPackageLoadingStatus,OrderPackageLoadingStatusConstant.yizhuangche.getValue()) -// .set(DistributionParcelListEntity::getOrderPackageStatus,OrderPackageStatusConstant.yiqianshou.getValue()) -// ); -// //维护订单 -// orderCodes.add(parcelListEntity.getOrderCode()); -// } -// break; -// case 2: -// //零担 -// for (DistributionParcelListEntity parcelListEntity : v) { -// //查询计划零担数量 -// DistributionReservationZeroPackageEntity packageEntity = distributionZeroPackageService.getOne(Wrappers.query().lambda() -// .eq(DistributionReservationZeroPackageEntity::getReservationId, distrilbutionBillLading.getId()) -// .eq(DistributionReservationZeroPackageEntity::getType, "3") -// .eq(DistributionReservationZeroPackageEntity::getParcelListId, parcelListEntity.getId()) -// .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) -// ); -// //维护零担品类在库信息 -// DistributionParcelNumberEntity distributionParcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda() -// .eq(DistributionParcelNumberEntity::getParcelListId, parcelListEntity.getId()) -// .eq(DistributionParcelNumberEntity::getStockArticleId, parcelListEntity.getStockArticleId()) -// ); -// //零担在库数不足进行签收 -// if (distributionParcelNumberEntity.getHandQuantity() < packageEntity.getQuantity()){ -// log.info(method+"零担签收数量不足,计划数量:{},在库数量:{}",packageEntity.getQuantity(),distributionParcelNumberEntity.getHandQuantity()); -// throw new RuntimeException("零担在库数不足此次签收!!"); -// } -// DistributionBillLadingScanEntity distributionBillLadingScanEntity = new DistributionBillLadingScanEntity(); -// distributionBillLadingScanEntity.setPacketBarCode(parcelListEntity.getOrderPackageCode()); -// distributionBillLadingScanEntity.setScanType(3); -// distributionBillLadingScanEntity.setParcelListId(parcelListEntity.getId()); -// distributionBillLadingScanEntity.setOrderSelfNumbering(parcelListEntity.getOrderCode()); -// distributionBillLadingScanEntity.setStockArticleId(parcelListEntity.getStockArticleId()); -// distributionBillLadingScanEntity.setBillLadingId(distrilbutionBillLading.getId()); -// distributionBillLadingScanEntity.setMaterialType("3"); -// distributionBillLadingScanEntity.setQuantity(packageEntity.getQuantity()); -// ladingScanEntities.add(distributionBillLadingScanEntity); -// //维护零担在库信息 -// int newHandQuantity = distributionParcelNumberEntity.getHandQuantity() - packageEntity.getQuantity(); -// int newDeliveryQuantity = distributionParcelNumberEntity.getDeliveryQuantity() - packageEntity.getQuantity(); -// int newOutboundQuantity = distributionParcelNumberEntity.getOutboundQuantity() + packageEntity.getQuantity(); -// int newSigninQuantity = distributionParcelNumberEntity.getSigninQuantity() + packageEntity.getQuantity(); -// log.info(method+"维护前零担品类在库数量,在库数量:{},冻结数量:{},出库数量:{},签收数量:{}", -// distributionParcelNumberEntity.getHandQuantity(), -// distributionParcelNumberEntity.getDeliveryQuantity(), -// distributionParcelNumberEntity.getOutboundQuantity(), -// distributionParcelNumberEntity.getSigninQuantity()); -// //修改零担品类 -// distributionParcelNumberEntity.setHandQuantity(newHandQuantity); -// distributionParcelNumberEntity.setDeliveryQuantity(newDeliveryQuantity); -// distributionParcelNumberEntity.setOutboundQuantity(newOutboundQuantity); -// distributionParcelNumberEntity.setSigninQuantity(newSigninQuantity); -// log.info(method+"维护后零担品类在库数量,在库数量:{},冻结数量:{},出库数量:{},签收数量:{}", -// distributionParcelNumberEntity.getHandQuantity(), -// distributionParcelNumberEntity.getDeliveryQuantity(), -// distributionParcelNumberEntity.getOutboundQuantity(), -// distributionParcelNumberEntity.getSigninQuantity()); -// distributionParcelNumberService.updateById(distributionParcelNumberEntity); -// if (newOutboundQuantity == parcelListEntity.getQuantity()){ -// //全部出库 -// parcelListEntity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue()); -// parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); -// parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue()); -// } -// if (newSigninQuantity == parcelListEntity.getQuantity()){ -// //全部签收 -// parcelListEntity.setOrderPackageStatus(OrderPackageStatusConstant.yiqianshou.getValue()); -// parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue()); -// } -// distributionParcelListService.updateById(parcelListEntity); -// orderCodes.add(parcelListEntity.getOrderCode()); -// } -// break; -// } -// -// }); ladingScanEntities = handleSignPackage(packageMap, distrilbutionBillLading.getId(), myCurrentWarehouse.getId()); - if (!ladingScanEntities.isEmpty()) { // 进行签收扫描数据补录 distributionBillLadingScanService.saveBatch(ladingScanEntities);