diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataVehicleController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataVehicleController.java index 754820195..ac756d579 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataVehicleController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataVehicleController.java @@ -86,7 +86,7 @@ public class BasicdataVehicleController extends BladeController { public R detail(@Param("id") Long id) { // BasicdataVehicleEntity detail = basicdataVehicleService.getOne(Condition.getQueryWrapper(basicdataVehicle)); - BasicdataVehicleEntity detail = basicdataVehicleService.getVehicleDetail(id); + BasicdataVehicleVO detail = basicdataVehicleService.getVehicleDetail(id); //查询历史照片 BasicdataVehicleVO basicdataVehicleVO = new BasicdataVehicleVO(); BeanUtils.copyProperties(detail,basicdataVehicleVO); diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataVehicleMapper.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataVehicleMapper.java index d6b788b68..bfddef518 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataVehicleMapper.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataVehicleMapper.java @@ -69,5 +69,5 @@ public interface BasicdataVehicleMapper extends BaseMapper - SELECT lbv.id id, lbv.tenant_id tenantId, diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataVehicleService.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataVehicleService.java index d69417978..a1902a62e 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataVehicleService.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataVehicleService.java @@ -99,5 +99,5 @@ public interface IBasicdataVehicleService extends BaseService selectNewDeliveryList(@Param("param") DistributionAppDeliveryListDTO distributionDeliveryList); + /** + * 查询车次信息内司机信息 + * @param id + * @param deliveryId + * @return + */ + DistributionDeliverySelfEntity selectDriverInfoByDeliveryIdAndDriverId(@Param("driverId")Long driverId,@Param("deliveryId") Long deliveryId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliverySelfMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliverySelfMapper.xml index a04171071..0858c2d8d 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliverySelfMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliverySelfMapper.xml @@ -89,5 +89,9 @@ + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryTripartiteMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryTripartiteMapper.java index 6128c9a4b..fc1f2ebfd 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryTripartiteMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryTripartiteMapper.java @@ -74,4 +74,11 @@ public interface DistributionDeliveryTripartiteMapper extends BaseMapper SELECT * logpm_distribution_delivery_tripartite WHERE delivery_id = #{deliveryId} + 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 dff5d0ceb..f63c6dfc6 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 @@ -781,14 +781,12 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl info = new HashMap<>(); info.put("orderPackageCode", parcelListEntity.getOrderPackageCode()); info.put("warehouseId", myCurrentWarehouse.getId()); - if (StringUtils.isNotBlank(parcelListEntity.getOrderPackageCode())) { warehouseUpdownTypeClient.downPackageOrDelTray(parcelListEntity.getOrderPackageCode(), myCurrentWarehouse.getId(), "扫描装车进行下架、解托"); } @@ -8009,74 +8007,285 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl packageLockIds = new ArrayList<>(); + //工厂回推 + List pushList = new ArrayList<>(); + //备货库位待下架 + List jsonObjects = new ArrayList<>(); + //查询司机信息 + DistributionDeliverySelfEntity distributionDeliverySelfEntity = getDriver(deliveryListEntity,user,distrilbutionloadingscanDTO,isDriverFlag); + switch (type) { + case 1: + if (Objects.isNull(distrilbutionloadingscanDTO.getBarcode())) { + log.error(method + "参数缺失Barcode"); + return Resp.fail("参数缺失,请联系管理员"); + } + List packageLogs = new ArrayList<>(); DistributionParcelListEntity parcelListEntity = distributionParcelListMapper.selectByOrderPackageCode(orderPackageCode, myCurrentWarehouse.getId()); - if (Objects.isNull(parcelListEntity)){ + if (Objects.isNull(parcelListEntity)) { //查询是否为库存品 List list = disStockListDetailService.list(Wrappers.query().lambda() .eq(DisStockListDetailEntity::getStockPackageCode, distrilbutionloadingscanDTO.getBarcode()) .ne(DisStockListDetailEntity::getStockPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) ); - if (list.isEmpty()){ + if (list.isEmpty()) { return Resp.scanFail("请在库存品页面扫描此码", "请在库存品页面扫描此码"); } else { return Resp.scanFail("系统无编码", "系统无编码"); } - if (OrderPackageLoadingStatusConstant.yizhuangche.getValue().equals(parcelListEntity.getOrderPackageLoadingStatus())){ + if (OrderPackageLoadingStatusConstant.yizhuangche.getValue().equals(parcelListEntity.getOrderPackageLoadingStatus())) { return Resp.scanFail("此包件已装车", "此包件已装车"); } //再次校验是否装车 - - + List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda() + .eq(DistributionLoadscanEntity::getOrderPackageCode, orderPackageCode) + .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) + ); + if (!loadscanEntityList.isEmpty()) { + return Resp.scanFail("此包件已装车", "此包件已装车"); + } //查询是否满足计划 以及计划在哪个客户中 - Long reservationId = baseMapper.selectPackageByorderPackageCodeAndDeliveryId(orderPackageCode,deliveryId,warehouseId); - if (Objects.isNull(reservationId)){ + Long reservationId = baseMapper.selectPackageByorderPackageCodeAndDeliveryId(orderPackageCode, deliveryId, warehouseId); + DistributionReservationEntity reservationEntity = distributionReservationService.getById(reservationId); + if (Objects.isNull(reservationEntity)) { + log.error(method + "预约任务错误reservationId:{}",reservationId); + return R.fail(403, "预约任务错误!!!"); + } + if (Objects.isNull(reservationId)) { //判定是否满足异常装车 + Boolean isAbnormalLoadingFlag = judgeIsAbnormalLoading(deliveryId, parcelListEntity); + if (isAbnormalLoadingFlag) { + return R.fail(5000, "异常装车"); + log.info("异常装车判定成功>>>>>>packageCode:{},reservationId:{}", distrilbutionloadingscanDTO.getBarcode(), distrilbutionloadingscanDTO.getReservationId()); + } + return Resp.scanFail("蹿货", "蹿货"); } //正常进行装车 + DistributionLoadscanEntity loadscanEntity = createdDistributionLoadscanEntity(deliveryListEntity,distributionDeliverySelfEntity,reservationId,parcelListEntity); + distributionLoadscanService.save(loadscanEntity); + //更新包件装车状态 + packageLockIds.add(parcelListEntity.getId()); + 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()); + if (StringUtils.isNotBlank(parcelListEntity.getOrderPackageCode())) { + warehouseUpdownTypeClient.downPackageOrDelTray(parcelListEntity.getOrderPackageCode(), myCurrentWarehouse.getId(), "扫描装车进行下架、解托"); + } + String content = "包件在" + myCurrentWarehouse.getName() + "由" + loadscanEntity.getScanUser() + "扫描装车,配送车次号:" + deliveryListEntity.getTrainNumber() + "预约任务号:" + reservationEntity.getReservationCode(); + JSONObject packageLog = handleLogJSONObject(myCurrentWarehouse, AuthUtil.getUser(), parcelListEntity.getOrderPackageCode(), content, WorkNodeEnums.DISTRIBUTION_LOADING.getCode()); + packageLogs.add(packageLog); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code", orderPackageCode); + jsonObject.put("warehouseId", myCurrentWarehouse.getId()); + jsonObject.put("taskId", reservationId); + jsonObject.put("type", 1); + jsonObject.put("num", 1); + jsonObject.put("remark", "装车下架"); + jsonObjects.add(jsonObject); + pushList.add(parcelListEntity); + } + break; + case 2: + if (Objects.isNull(distrilbutionloadingscanDTO.getParcelListDTOS())){ + log.error(method + "参数缺失ParcelListDTOS"); + return Resp.fail("参数缺失,请联系管理员"); + } + List parcelListDTOS = distrilbutionloadingscanDTO.getParcelListDTOS(); + break; - + } + //添加缓存 + if (!packageLockIds.isEmpty()) { + List a = bladeRedis.get("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + deliveryListEntity.getTrainNumber() + "orderPackageCode:"); + if (Func.isNotEmpty(a)) { + boolean flag = a.stream().anyMatch(any -> packageLockIds.contains(any)); + if (flag) { + //正在操作,请稍后重试 + throw new CustomerException("该包件正在被操作,请稍后再试!!!"); + } else { + packageLockIds.addAll(a); + bladeRedis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + deliveryListEntity.getTrainNumber() + "orderPackageCode:", packageLockIds, 60L); } - break; + } else { + bladeRedis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "trainNumber:" + deliveryListEntity.getTrainNumber() + "orderPackageCode:", packageLockIds, 60L); + } } + 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); + } + } + warehouseUpdownStockUpAreaClient.downStockUpShelf(jsonObjects); return null; } + private DistributionLoadscanEntity createdDistributionLoadscanEntity(DistributionDeliveryListEntity deliveryListEntity, + DistributionDeliverySelfEntity distributionDeliverySelfEntity, + Long reservationId, + DistributionParcelListEntity parcelListEntity, + BasicdataWarehouseEntity warehouseEntity, + BladeUser user) { + String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); + 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.setTrainNumber(deliveryListEntity.getTrainNumber()); + loadscanEntity.setScanStatus(LoadingStatusConstant.saomiao.getValue()); + loadscanEntity.setScanType("1"); + loadscanEntity.setOneClick(1); + loadscanEntity.setWarehouseId(warehouseEntity.getId()); + loadscanEntity.setWarehouseName(warehouseEntity.getName()); + loadscanEntity.setPackageId(parcelListEntity.getId()); + loadscanEntity.setOrderPackageCode(parcelListEntity.getOrderPackageCode()); + loadscanEntity.setPackageNub(parcelListEntity.getQuantity()); + loadscanEntity.setReservationId(reservationId); + loadscanEntity.setDeliveryId(deliveryListEntity.getId()); + loadscanEntity.setOrderId(parcelListEntity.getStockArticleId()); + loadscanEntity.setScanTime(now); + loadscanEntity.setScanUser(user.getNickName()); + loadscanEntity.setLoadingId(distributionDeliverySelfEntity.getId()+""); + loadscanEntity.setIsAbnormalLoading(1); + loadscanEntity.setLoadedNub(parcelListEntity.getQuantity()); + return loadscanEntity; + } + + private DistributionDeliverySelfEntity getDriver(DistributionDeliveryListEntity deliveryListEntity, BladeUser user,DistrilbutionloadingscanDTO distrilbutionloadingscanDTO,boolean isDriverFlag) { + DistributionDeliverySelfEntity distributionDeliverySelfEntity = new DistributionDeliverySelfEntity(); + if ("1".equals(deliveryListEntity.getKind())) { + if (isDriverFlag) { + BasicdataDriverArteryEntity driverArtery = iBasicdataDriverArteryClient.getDriverArtery(user.getUserId()); + if (null == driverArtery) { + log.error("没有司机的信息!!"); + throw new CustomerException("没有司机的信息"); + } + //查询当前扫描司机是否属于当前配送任务 + distributionDeliverySelfEntity = distributionDeliverySelfMapper.selectDriverInfoByDeliveryIdAndDriverId(driverArtery.getId(),deliveryListEntity.getId()); + } else { + if (Objects.isNull(distrilbutionloadingscanDTO.getDriverId())) { + log.error("文员扫描未选择司机!!"); + throw new CustomerException("文员扫描未选择司机"); + } + BasicdataDriverArteryEntity driverArtery = iBasicdataDriverArteryClient.getDriverArtery(distrilbutionloadingscanDTO.getDriverId()); + if (null == driverArtery) { + log.error("没有司机的信息!!"); + throw new CustomerException("没有司机的信息"); + } + //默认为文员进行扫描,此时需要文员选择进行帮助扫描的司机 + distributionDeliverySelfEntity = distributionDeliverySelfMapper.selectDriverInfoByDeliveryIdAndDriverId(driverArtery.getId(),deliveryListEntity.getId()); + } + } else { + DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectDriverInfoByDeliveryId(deliveryListEntity.getId()); + if (Func.isEmpty(distributionDeliveryTripartiteEntity)) { + log.error("没有司机的信息!!"); + throw new CustomerException("没有司机的信息"); + } + BeanUtils.copyProperties(distributionDeliveryTripartiteEntity, distributionDeliverySelfEntity); + } + + return distributionDeliverySelfEntity; + } + + private Boolean judgeIsAbnormalLoading(Long deliveryId, DistributionParcelListEntity parcelListEntity) { + List reservationEntityList = distributionDeliveryListMapper.selectReservationByDeliveryListId(deliveryId); + if (!reservationEntityList.isEmpty()) { + boolean shangpeiFlag = reservationEntityList.stream().allMatch(r -> r.getDeliveryType().equals(DistributionTypeConstant.shipie.getValue())); + 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()) && r.getId().equals(distrilbutionloadingscanDTO.getReservationId())).collect(Collectors.toList()); + //查看是否存在满足条件的预约单 + boolean flag = reservationEntityList.stream().anyMatch(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()) && r.getId().equals(distrilbutionloadingscanDTO.getReservationId())); + + //存在多个,操作人指定具体客户即可 + if (reservationEntities.size() == 1 && flag) { + return true; + } else { + return false; + } + } 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()) && r.getId().equals(distrilbutionloadingscanDTO.getReservationId())).collect(Collectors.toList()); + //查询是否满足商配异常装车 + boolean flag = reservationEntityList.stream().anyMatch(r -> r.getReceivingUnit().equals(stockArticleEntity.getConsigneeUnit()) && r.getMallName().equals(stockArticleEntity.getMallName())); + if (reservationEntities.size() == 1 && flag) { + return true; + } else { + return false; + } + } else { + log.error("配送计划预约类型错误:{}", reservationEntityList); + } + } + } + return false; + } + private List handleAppDeliveryInventory(DistributionAppDeliveryListDTO distributionAppDeliveryListDTO, BasicdataWarehouseEntity myCurrentWarehouse) { List distributionAppStockListVOS = new ArrayList<>(); List disStockListDetailEntities = baseMapper.selectInventoryListByDeliveryListId(distributionAppDeliveryListDTO.getId()); @@ -8097,10 +8306,10 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl entityList1 = inventoryPackageMap.get(inventoryId); planNum += entityList1.stream().mapToInt(DisStockListDetailEntity::getNum).sum(); - scanNum += entityList1.stream().filter(f->InventoryLoadingStatusConstant.yizhuangche.getValue().equals(f.getStockLockingStatus())).mapToInt(DisStockListDetailEntity::getNum).sum(); + scanNum += entityList1.stream().filter(f -> InventoryLoadingStatusConstant.yizhuangche.getValue().equals(f.getStockLockingStatus())).mapToInt(DisStockListDetailEntity::getNum).sum(); } } distributionAppStockListVO.setPlanNum(planNum);