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..a07e72020 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 @@ -6,6 +6,7 @@ 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 +18,7 @@ import org.springframework.stereotype.Component; @Component @Builder @AllArgsConstructor +@Slf4j public class FactoryDataMessageSender { private final IFactoryDataClient factoryDataClient; @@ -27,9 +29,18 @@ 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(routingKeyByName == null){ + 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..f269eee84 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.isAllEmpty(brand, brand.getValue(),factorys.get(brand.getValue()))) { // TODO 业务调用不规范,特殊处理 return null; } 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) {