From a5f3af5c6e8d552324bd16b1f3aa317026e240cd Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Thu, 18 Jul 2024 17:55:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E5=B9=B2=E7=BA=BFbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DistributionStockArticleServiceImpl.java | 1 + .../controller/CarsLoadController.java | 46 +- .../mapper/TrunklineLoadSignOrderMapper.xml | 2 +- .../service/ICarsLoadAsyncService.java | 2 +- .../service/ITrunklineCarsLoadService.java | 2 + .../impl/CarsLoadAsyncServiceImpl.java | 3 +- .../impl/TrunklineCarsLoadServiceImpl.java | 1085 ++++++++++++++--- 7 files changed, 981 insertions(+), 160 deletions(-) diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java index 23cb05820..bb2efa666 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java @@ -2566,6 +2566,7 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl and ltlso.load_id = #{param.loadId} - + and ltcl.cars_no = #{param.loadCarsNo} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java index ee8ea20a8..3a801de16 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java @@ -19,7 +19,7 @@ public interface ICarsLoadAsyncService { void abnormalListUnloadByLoadIdAndWarehouseId(Long loadId, Long warehouseId, String warehouseName, Long loadScanId, String tenantId, Long userId, String nickName, Long firstLong); - void abnormalListUnloadCheckByLoadIdAndWarehouseId(Long loadId, Long warehouseId, String nodeName, String tenantId, Long userId, String nickName, Long firstLong); + void abnormalListUnloadCheckByLoadIdAndWarehouseId(Long loadId, Long warehouseId, String nodeName, String tenantId, Long userId, String nickName, Long firstLong,TrunklineCarsLoadLineEntity carsLoadLineEntity); void dealwithAfterAbnormalPackage(String orderPackageCode, Long warehouseId, String warehouseName, String carsNo, Long userId, Long aLong, String nickName); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java index 75d6eca9a..7fcd9fc1f 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java @@ -219,4 +219,6 @@ public interface ITrunklineCarsLoadService extends BaseService orderPackageCodes = trunklineCarsLoadScanService.findUnloadByLoadIdAndWarehouseId(loadId, warehouseId); String content = "包件在 " + warehouseEntity.getName() + "卸车确认"; @@ -1432,6 +1432,45 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl moreCarsLineList = trunklineCarsLoadLineService.findListMoreSortByLoadId(loadId,sort); + List allCarsLineList = trunklineCarsLoadLineService.findListByLoadId(loadId); + + Map map = new HashMap<>(); + map.put("carsLoadEntity", loadEntity); + map.put("allCarsLineList", allCarsLineList); + List loadingType = DictBizCache.getList(DictBizConstant.CARS_LOADING_TYPE); + map.put("loadingType", loadingType); + List chargeType = DictBizCache.getList(DictBizConstant.BILLLADING_CHARGE_TYPE); + map.put("chargeType", chargeType); + List loadType = DictBizCache.getList(DictBizConstant.CARS_LOAD_TYPE); + map.put("loadType", loadType); +// BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); +// map.put("warehouseId", basicdataWarehouseEntity.getId()); +// map.put("warehouseName", basicdataWarehouseEntity.getName()); + map.put("allWarehouseIds", allWarehouseIds.split(",")); +// map.put("moreCarsLineList",moreCarsLineList); + return R.data(map); + } + + + @Override public R updateCarsLoadBasicData(TrunklineCarsLoadDTO carsLoadDTO, Long warehouseId) { Long loadId = carsLoadDTO.getId(); @@ -6042,7 +6081,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("waybill_no", waybillNo) - .eq("load_id", loadId) - .eq("final_node_id", warehouseId) - .eq("order_code", orderCode); - TrunklineCarsLoadScanEntity carsLoadScanEntity = trunklineCarsLoadScanService.getOne(queryWrapper); + //先判断包件是否在配载计划的装车扫描中 + QueryWrapper loadScanQueryWrapper = new QueryWrapper<>(); + loadScanQueryWrapper.eq("load_id", loadId) + .eq("scan_code", orderPackageCode); + TrunklineCarsLoadScanEntity carsLoadScanEntity = trunklineCarsLoadScanService.getOne(loadScanQueryWrapper); + //判断是否有装车扫描记录 if (Objects.isNull(carsLoadScanEntity)) { - log.warn("#############unloadZero: 零担信息不存在 waybillNo={} order_code={} loadId={} finalNodeId={}", waybillNo, orderCode, loadId, warehouseId); - return R.fail(405, "零担信息不存在"); - } + //没有装车扫码记录 - Integer isAbnormal = 0; - Integer num = carsLoadScanEntity.getNum(); - Long fromWarehouseId = carsLoadScanEntity.getFromWarehouseId(); - Long waybillId = carsLoadScanEntity.getWaybillId(); - String scanCode = carsLoadScanEntity.getScanCode(); - Long loadScanId = carsLoadScanEntity.getId(); - if (enterNun > num) { - log.warn("#############unloadZero: 零担信息卸车数量大于装车件数 enterNun={} num={}", enterNun, num); - return R.fail(405, "零担信息卸车数量大于装车件数"); - } + //不在计划中,则查询在哪个仓库中 + DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByOrderPackageCodeAndStatus(orderPackageCode); + Long loadScanId = null; + if (Objects.isNull(parcelListEntity)) { + //没有包件数据 + TrunklineAdvanceDetailEntity advanceDetailEntity = trunklineAdvanceDetailService.findEntityByOrderPackageCode(orderPackageCode); + if(!Objects.isNull(advanceDetailEntity)){ + String packageStatus = advanceDetailEntity.getPackageStatus(); + if("0".equals(packageStatus)){ + InComingDTO inComingDTO = new InComingDTO(); + inComingDTO.setOrderPackageCode(orderPackageCode); + inComingDTO.setIncomingType(incomingType); + inComingDTO.setWarehouseId(warehouseId); + inComingService.incomingPackage(inComingDTO); - carsLoadScanEntity.setUnloadNum(enterNun); - carsLoadScanEntity.setUnloadNodeId(warehouseId); - carsLoadScanEntity.setUnloadNodeName(warehouseName); - carsLoadScanEntity.setUnloadAbnormal(0); - carsLoadScanEntity.setScanStatus("2"); - carsLoadScanEntity.setLoadingUserName(AuthUtil.getNickName()); - carsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName()); - carsLoadScanEntity.setUnloadTime(new Date()); - trunklineCarsLoadScanService.updateById(carsLoadScanEntity); + //需要补装车扫记录 + TrunklineCarsLoadScanEntity trunklineCarsLoadScanEntity = new TrunklineCarsLoadScanEntity(); + trunklineCarsLoadScanEntity.setWarehouseId(warehouseId); + trunklineCarsLoadScanEntity.setWarehouseName(warehouseName); + trunklineCarsLoadScanEntity.setOrderCode(advanceDetailEntity.getOrderCode()); + trunklineCarsLoadScanEntity.setWaybillId(advanceDetailEntity.getWaybillId()); + trunklineCarsLoadScanEntity.setWaybillNo(advanceDetailEntity.getWaybillNo()); + trunklineCarsLoadScanEntity.setLoadId(loadId); + trunklineCarsLoadScanEntity.setLoadCode(loadCode); + trunklineCarsLoadScanEntity.setScanCode(orderPackageCode); + trunklineCarsLoadScanEntity.setScanStatus("2"); + trunklineCarsLoadScanEntity.setNum(1); + trunklineCarsLoadScanEntity.setType(1); + trunklineCarsLoadScanEntity.setIsData(1); + trunklineCarsLoadScanEntity.setLoadingAbnormal(1); + trunklineCarsLoadScanEntity.setUnloadAbnormal(1); + trunklineCarsLoadScanEntity.setUnloadNodeName(warehouseName); + trunklineCarsLoadScanEntity.setUnloadNodeId(warehouseId); + trunklineCarsLoadScanEntity.setUnloadNum(1); + trunklineCarsLoadScanEntity.setIsSupple(0); + trunklineCarsLoadScanEntity.setLoadingUserName(AuthUtil.getNickName()); + trunklineCarsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName()); + trunklineCarsLoadScanEntity.setUnloadTime(new Date()); + trunklineCarsLoadScanService.save(trunklineCarsLoadScanEntity); + loadScanId = trunklineCarsLoadScanEntity.getId(); - trunklineCarsUnloadLogService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, waybillId, waybillNo, orderCode, - scanCode, enterNun, 2, 1, isAbnormal, trayId, trayCode, trayName, fromWarehouseId, loadScanId, remark); + trunklineCarsLoadingLogService.savaLoadingLog(warehouseId, warehouseName, loadId, loadCode, null, null, null, orderPackageCode, 1, + 1, 1, 1, trayId, trayCode, trayName, null, loadScanId, "有数据,补装车计划,异常装车"); - if (unbindTray == 1) { - if (!StringUtil.isBlank(trayCode)) { - trayTypeClient.deleteZeroOrderByTrayCode(orderCode, trayCode, fromWarehouseId, "干线卸车零担解托"); - } - } + trunklineCarsUnloadLogService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, null, null, null, orderPackageCode, 1, + 1, 1, 1, trayId, trayCode, trayName, null, loadScanId, "有数据,异常卸车"); -// DistributionStockArticleEntity newStockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); -// if (Objects.isNull(newStockArticleEntity)) { -// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, fromWarehouseId); -// newStockArticleEntity = new DistributionStockArticleEntity(); -// BeanUtil.copy(stockArticleEntity, newStockArticleEntity); -// newStockArticleEntity.setId(null); -// newStockArticleEntity.setOrderReceiveStatus("20"); -// newStockArticleEntity.setOrderStatus("10"); -// newStockArticleEntity.setHandQuantity(enterNun); -// newStockArticleEntity.setIncomingNum(enterNun); -// newStockArticleEntity.setWarehouse(basicdataWarehouseEntity.getName()); -// newStockArticleEntity.setWarehouseId(basicdataWarehouseEntity.getId()); -// newStockArticleEntity.setCarsLoadNum(0); -// Long orderId = distributionStockArticleClient.addData(newStockArticleEntity); -// if (orderId != 0) { -// List parcelListEntityList = distributionParcelListClient.findEntityListByOrderCode(orderCode, fromWarehouseId); -// List ls = new ArrayList<>(); -// for (DistributionParcelListEntity parcelListEntity : parcelListEntityList) { -// DistributionParcelListEntity newParcelListEntity = new DistributionParcelListEntity(); -// BeanUtil.copy(parcelListEntity, newParcelListEntity); -// newParcelListEntity.setId(null); -// newParcelListEntity.setWarehouseId(warehouseId); -// newParcelListEntity.setWarehouse(warehouseName); -// newParcelListEntity.setStockArticleId(orderId); -// Long acceptWarehouseId = parcelListEntity.getAcceptWarehouseId(); -// if(warehouseId.equals(acceptWarehouseId)){ -// newParcelListEntity.setIsTransfer(0); -// }else{ -// newParcelListEntity.setIsTransfer(1); -// } -// Long orderPackageId = distributionParcelListClient.addReturnId(newParcelListEntity); -// -// DistributionParcelNumberEntity parcelNumberEntity = new DistributionParcelNumberEntity(); -// parcelNumberEntity.setStockArticleId(orderId); -// parcelNumberEntity.setParcelListId(orderPackageId); -// parcelNumberEntity.setQuantity(newParcelListEntity.getQuantity()); -// parcelNumberEntity.setHandQuantity(0); -// parcelNumberEntity.setDeliveryQuantity(0); -// parcelNumberEntity.setSigninQuantity(0); -// parcelNumberEntity.setOutboundQuantity(0); -// parcelNumberEntity.setWarehouseId(warehouseId); -// ls.add(parcelNumberEntity); -// } -// distributionParcelNumberClient.addBatch(ls); -// } -// } else { -// Integer handQuantity = newStockArticleEntity.getHandQuantity() + enterNun; -// Integer incomingNum = newStockArticleEntity.getIncomingNum() + enterNun; -// Integer totalNumber = newStockArticleEntity.getTotalNumber(); -// -// if (incomingNum.equals(totalNumber)) { -// if (handQuantity.equals(totalNumber)) { -// newStockArticleEntity.setOrderStatus("20"); -// } else { -// newStockArticleEntity.setOrderStatus("30"); -// } -// newStockArticleEntity.setOrderReceiveStatus("30"); -// } else { -// if (incomingNum.equals(handQuantity)) { -// newStockArticleEntity.setOrderStatus("10"); -// } else { -// newStockArticleEntity.setOrderStatus("30"); -// } -// newStockArticleEntity.setOrderReceiveStatus("20"); -// } -// newStockArticleEntity.setHandQuantity(handQuantity); -// newStockArticleEntity.setIncomingNum(incomingNum); -// -// distributionStockArticleClient.saveOrUpdate(newStockArticleEntity); -// } + }else{ + //已入库 + Long nowWarehouseId = advanceDetailEntity.getNowWarehouseId(); + String nowWarehouseName = advanceDetailEntity.getNowWarehouseName(); + + //需要补装车扫记录 + TrunklineCarsLoadScanEntity trunklineCarsLoadScanEntity = new TrunklineCarsLoadScanEntity(); + trunklineCarsLoadScanEntity.setWarehouseId(warehouseId); + trunklineCarsLoadScanEntity.setWarehouseName(warehouseName); + trunklineCarsLoadScanEntity.setOrderCode(advanceDetailEntity.getOrderCode()); + trunklineCarsLoadScanEntity.setWaybillId(advanceDetailEntity.getWaybillId()); + trunklineCarsLoadScanEntity.setWaybillNo(advanceDetailEntity.getWaybillNo()); + trunklineCarsLoadScanEntity.setLoadId(loadId); + trunklineCarsLoadScanEntity.setLoadCode(loadCode); + trunklineCarsLoadScanEntity.setScanCode(orderPackageCode); + trunklineCarsLoadScanEntity.setScanStatus("2"); + trunklineCarsLoadScanEntity.setNum(1); + trunklineCarsLoadScanEntity.setType(1); + trunklineCarsLoadScanEntity.setIsData(1); + trunklineCarsLoadScanEntity.setLoadingAbnormal(1); + trunklineCarsLoadScanEntity.setUnloadAbnormal(1); + trunklineCarsLoadScanEntity.setUnloadNodeName(warehouseName); + trunklineCarsLoadScanEntity.setUnloadNodeId(warehouseId); + trunklineCarsLoadScanEntity.setUnloadNum(1); + trunklineCarsLoadScanEntity.setIsSupple(0); + trunklineCarsLoadScanEntity.setLoadingUserName(AuthUtil.getNickName()); + trunklineCarsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName()); + trunklineCarsLoadScanEntity.setUnloadTime(new Date()); + trunklineCarsLoadScanEntity.setFromWarehouseId(nowWarehouseId); + trunklineCarsLoadScanEntity.setRemark("无装车记录卸车"); + trunklineCarsLoadScanService.save(trunklineCarsLoadScanEntity); + loadScanId = trunklineCarsLoadScanEntity.getId(); + + trunklineCarsLoadingLogService.savaLoadingLog(warehouseId, warehouseName, loadId, loadCode, null, null, null, orderPackageCode, 1, + 1, 1, 1, trayId, trayCode, trayName, null, loadScanId, "有数据,无计划,无装车,补装车计划,异常装车"); + + trunklineCarsUnloadLogService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, null, null, null, orderPackageCode, 1, + 1, 1, 1, trayId, trayCode, trayName, null, loadScanId, "有数据,无计划,无装车,异常卸车"); + + //无装车记录异常日志记录 + try { + carsLoadAsyncService.abnormalListUnloadByLoadIdAndWarehouseId(loadId, warehouseId, warehouseName, loadScanId, AuthUtil.getTenantId(), AuthUtil.getUserId(), AuthUtil.getNickName(), Func.firstLong(AuthUtil.getDeptId())); + } catch (Exception e) { + log.warn("###############unloadPackage: 存入异常列表记录失败"); + } + + + DistributionParcelListEntity nowParcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, nowWarehouseId); + if(Objects.isNull(nowParcelListEntity)){ + log.warn("###############unloadPackage: 包件信息不存在 orderPackageCode={},nowWarehouseId={}",orderPackageCode,nowWarehouseId); + return R.fail(405,"包件信息不存在"); + } + orderCode = nowParcelListEntity.getOrderCode(); + Long packageId = nowParcelListEntity.getId(); + String orderPackageStatus = nowParcelListEntity.getOrderPackageStatus(); + String waybillNumber = nowParcelListEntity.getWaybillNumber(); + + DistributionStockArticleEntity nowDistributionStockArticle = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, nowWarehouseId); + if(Objects.isNull(nowDistributionStockArticle)){ + log.warn("###############unloadPackage: 订单信息不存在 orderCode={},nowWarehouseId={}",orderCode,nowWarehouseId); + return R.fail(405,"订单信息不存在"); + } + Long articleId = nowDistributionStockArticle.getId(); + + if(!"70".equals(orderPackageStatus)){ + distributionStockArticleClient.submitHandleNumByOrderId(1, articleId); + distributionParcelListClient.updateOrderPackageCodeById(packageId, "60"); + } + + + Long currentOrderId = null; + //查询当前仓库订单信息有没有 + DistributionStockArticleEntity currentStockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); + if (Objects.isNull(currentStockArticleEntity)) { + //查询包件前面仓的订单信息 + currentStockArticleEntity = new DistributionStockArticleEntity(); + BeanUtil.copy(nowDistributionStockArticle, currentStockArticleEntity); + currentStockArticleEntity.setId(null); + currentStockArticleEntity.setWarehouseId(warehouseId); + currentStockArticleEntity.setWarehouse(warehouseName); + currentStockArticleEntity.setHandQuantity(0); + currentStockArticleEntity.setCompleteSet(1); + currentStockArticleEntity.setStockupStatus("10"); + currentStockArticleEntity.setReservationStatus("10"); + currentStockArticleEntity.setOrderStatus("10"); + currentStockArticleEntity.setGroundingStatus("10"); + currentStockArticleEntity.setOrderReceiveStatus("10"); + currentStockArticleEntity.setFreezeStatus("10"); + currentStockArticleEntity.setSortingQuantity(0); + currentStockArticleEntity.setDeliveryQuantity(0); + currentStockArticleEntity.setTransferQuantity(0); + currentStockArticleEntity.setSigninQuantity(0); + currentStockArticleEntity.setIncomingNum(0); + currentOrderId = distributionStockArticleClient.addData(currentStockArticleEntity); + currentStockArticleEntity.setId(currentOrderId); + } else { + currentOrderId = currentStockArticleEntity.getId(); + } + + //判断包件当前仓是否是目的仓 + WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNumber); + + if (Objects.isNull(distributionParcelListEntity)) { + distributionParcelListEntity = new DistributionParcelListEntity(); + BeanUtil.copy(nowParcelListEntity, distributionParcelListEntity); + distributionParcelListEntity.setId(null); + distributionParcelListEntity.setIsTransfer(1); + if (!Objects.isNull(warehouseWaybillEntity)) { + Long destinationWarehouseId = warehouseWaybillEntity.getDestinationWarehouseId();//目的仓 + if (destinationWarehouseId.equals(warehouseId)) { + distributionParcelListEntity.setIsTransfer(0); + } + } + distributionParcelListEntity.setAdvanceId(nowParcelListEntity.getAdvanceId()); + distributionParcelListEntity.setOrderPackageStatus("20"); + distributionParcelListEntity.setWarehouseId(warehouseId); + distributionParcelListEntity.setWarehouse(warehouseName); + distributionParcelListEntity.setTrainNumber(loadCode); + distributionParcelListEntity.setStockArticleId(currentOrderId); + distributionParcelListEntity.setOrderPackageFreezeStatus("10"); + distributionParcelListEntity.setOrderPackageGroundingStatus("10"); + distributionParcelListEntity.setOrderPackageStockupStatus("10"); + distributionParcelListEntity.setOrderPackageReservationStatus("10"); + distributionParcelListEntity.setOrderPackageLoadingStatus("10"); + distributionParcelListEntity.setWarehouseEntryTimeEnd(new Date()); + boolean add = distributionParcelListClient.add(distributionParcelListEntity); + if (add) { + distributionStockArticleClient.addIncomingNum(currentOrderId, 1); + } + } else { + distributionParcelListEntity.setOrderPackageStatus("20"); + if (!Objects.isNull(warehouseWaybillEntity)) { + Long destinationWarehouseId = warehouseWaybillEntity.getDestinationWarehouseId();//目的仓 + if (destinationWarehouseId.equals(warehouseId)) { + distributionParcelListEntity.setIsTransfer(0); + } else { + distributionParcelListEntity.setIsTransfer(1); + } + } + distributionParcelListClient.update(distributionParcelListEntity); + } + updownTypeClient.downPackageOrDelTray(orderPackageCode, nowWarehouseId, "干线卸车下架解托"); + } + }else{ + //需要补装车扫记录 + TrunklineCarsLoadScanEntity trunklineCarsLoadScanEntity = new TrunklineCarsLoadScanEntity(); + trunklineCarsLoadScanEntity.setWarehouseId(warehouseId); + trunklineCarsLoadScanEntity.setWarehouseName(warehouseName); + trunklineCarsLoadScanEntity.setLoadId(loadId); + trunklineCarsLoadScanEntity.setLoadCode(loadCode); + trunklineCarsLoadScanEntity.setOrderCode("--"); + trunklineCarsLoadScanEntity.setScanCode(orderPackageCode); + trunklineCarsLoadScanEntity.setScanStatus("2"); + trunklineCarsLoadScanEntity.setNum(1); + trunklineCarsLoadScanEntity.setType(1); + trunklineCarsLoadScanEntity.setIsData(0); + isData=0; + trunklineCarsLoadScanEntity.setLoadingAbnormal(1); + trunklineCarsLoadScanEntity.setUnloadAbnormal(1); + trunklineCarsLoadScanEntity.setUnloadNodeName(warehouseName); + trunklineCarsLoadScanEntity.setUnloadNodeId(warehouseId); + trunklineCarsLoadScanEntity.setUnloadNum(1); + trunklineCarsLoadScanEntity.setIsSupple(0); + trunklineCarsLoadScanEntity.setLoadingUserName(AuthUtil.getNickName()); + trunklineCarsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName()); + trunklineCarsLoadScanEntity.setUnloadTime(new Date()); + trunklineCarsLoadScanService.save(trunklineCarsLoadScanEntity); + loadScanId = trunklineCarsLoadScanEntity.getId(); + + trunklineCarsLoadingLogService.savaLoadingLog(warehouseId, warehouseName, loadId, loadCode, null, null, null, orderPackageCode, 1, + 1, 0, 1, trayId, trayCode, trayName, null, loadScanId, "无数据,补装车计划,异常装车"); + + trunklineCarsUnloadLogService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, null, null, null, orderPackageCode, 1, + 1, 0, 1, trayId, trayCode, trayName, null, loadScanId, "无数据,异常卸车"); + + } + } else { + String waybillNumber = parcelListEntity.getWaybillNumber(); + orderCode = parcelListEntity.getOrderCode(); + Long wid = parcelListEntity.getWarehouseId(); + String wName = parcelListEntity.getWarehouse(); + Long pacakageId = parcelListEntity.getId(); + Long waybillId = null; + + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, wid); + if (Objects.isNull(stockArticleEntity)) { + log.warn("##############unloadPackage: 订单信息不存在 orderCode={} wid={}", orderCode, wid); + return R.fail(405, "订单信息不存在"); + } + Long articleId = stockArticleEntity.getId(); + + //需要补装车扫记录 + TrunklineCarsLoadScanEntity trunklineCarsLoadScanEntity = new TrunklineCarsLoadScanEntity(); + trunklineCarsLoadScanEntity.setWarehouseId(warehouseId); + trunklineCarsLoadScanEntity.setWarehouseName(warehouseName); + trunklineCarsLoadScanEntity.setLoadId(loadId); + trunklineCarsLoadScanEntity.setLoadCode(loadCode); + WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNumber); + if (!Objects.isNull(waybillEntity)) { + waybillId = waybillEntity.getId(); + trunklineCarsLoadScanEntity.setWaybillId(waybillId); + trunklineCarsLoadScanEntity.setWaybillNo(waybillNumber); + } + trunklineCarsLoadScanEntity.setOrderCode(orderCode); + trunklineCarsLoadScanEntity.setScanCode(orderPackageCode); + trunklineCarsLoadScanEntity.setScanStatus("2"); + trunklineCarsLoadScanEntity.setNum(1); + trunklineCarsLoadScanEntity.setType(1); + trunklineCarsLoadScanEntity.setIsData(1); + trunklineCarsLoadScanEntity.setLoadingAbnormal(1); + trunklineCarsLoadScanEntity.setUnloadAbnormal(1); + trunklineCarsLoadScanEntity.setFromWarehouseId(wid); + trunklineCarsLoadScanEntity.setUnloadNodeId(warehouseId); + trunklineCarsLoadScanEntity.setUnloadNodeName(warehouseName); + trunklineCarsLoadScanEntity.setUnloadNum(1); + trunklineCarsLoadScanEntity.setLoadingUserName(AuthUtil.getNickName()); + trunklineCarsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName()); + trunklineCarsLoadScanEntity.setUnloadTime(new Date()); + trunklineCarsLoadScanService.save(trunklineCarsLoadScanEntity); + + isData = 1; + loadScanId = trunklineCarsLoadScanEntity.getId(); + + // + trunklineCarsLoadingLogService.savaLoadingLog(warehouseId, warehouseName, loadId, loadCode, waybillId, waybillNumber, orderCode, orderPackageCode, 1, + 1, 1, 1, trayId, trayCode, trayName, wid, loadScanId, "有数据,补装车计划,异常装车"); + + trunklineCarsUnloadLogService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, waybillId, waybillNumber, orderCode, orderPackageCode, 1, + 1, 1, 1, trayId, trayCode, trayName, wid, loadScanId, "有数据,异常卸车"); + + distributionStockArticleClient.submitHandleNumByOrderId(1, articleId); + distributionParcelListClient.updateOrderPackageCodeById(pacakageId, "60"); + + + Long currentOrderId = null; + //查询当前仓库订单信息有没有 + DistributionStockArticleEntity currentStockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); + if (Objects.isNull(currentStockArticleEntity)) { + //查询包件前面仓的订单信息 + currentStockArticleEntity = new DistributionStockArticleEntity(); + BeanUtil.copy(stockArticleEntity, currentStockArticleEntity); + currentStockArticleEntity.setId(null); + currentStockArticleEntity.setWarehouseId(warehouseId); + currentStockArticleEntity.setWarehouse(warehouseName); + currentStockArticleEntity.setHandQuantity(0); + currentStockArticleEntity.setCompleteSet(1); + currentStockArticleEntity.setStockupStatus("10"); + currentStockArticleEntity.setReservationStatus("10"); + currentStockArticleEntity.setOrderStatus("10"); + currentStockArticleEntity.setGroundingStatus("10"); + currentStockArticleEntity.setOrderReceiveStatus("10"); + currentStockArticleEntity.setFreezeStatus("10"); + currentStockArticleEntity.setSortingQuantity(0); + currentStockArticleEntity.setDeliveryQuantity(0); + currentStockArticleEntity.setTransferQuantity(0); + currentStockArticleEntity.setSigninQuantity(0); + currentStockArticleEntity.setIncomingNum(0); + currentOrderId = distributionStockArticleClient.addData(currentStockArticleEntity); + currentStockArticleEntity.setId(currentOrderId); + } else { + currentOrderId = currentStockArticleEntity.getId(); + } + + //判断包件当前仓是否是目的仓 + WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNumber); + + if (Objects.isNull(distributionParcelListEntity)) { + distributionParcelListEntity = new DistributionParcelListEntity(); + BeanUtil.copy(parcelListEntity, distributionParcelListEntity); + distributionParcelListEntity.setId(null); + distributionParcelListEntity.setIsTransfer(1); + if (!Objects.isNull(warehouseWaybillEntity)) { + Long destinationWarehouseId = warehouseWaybillEntity.getDestinationWarehouseId();//目的仓 + if (destinationWarehouseId.equals(warehouseId)) { + distributionParcelListEntity.setIsTransfer(0); + } + } + distributionParcelListEntity.setAdvanceId(parcelListEntity.getAdvanceId()); + distributionParcelListEntity.setOrderPackageStatus("20"); + distributionParcelListEntity.setWarehouseId(warehouseId); + distributionParcelListEntity.setWarehouse(warehouseName); + distributionParcelListEntity.setTrainNumber(loadCode); + distributionParcelListEntity.setStockArticleId(currentOrderId); + distributionParcelListEntity.setOrderPackageFreezeStatus("10"); + distributionParcelListEntity.setOrderPackageGroundingStatus("10"); + distributionParcelListEntity.setOrderPackageStockupStatus("10"); + distributionParcelListEntity.setOrderPackageReservationStatus("10"); + distributionParcelListEntity.setOrderPackageLoadingStatus("10"); + distributionParcelListEntity.setWarehouseEntryTimeEnd(new Date()); + boolean add = distributionParcelListClient.add(distributionParcelListEntity); + if (add) { + distributionStockArticleClient.addIncomingNum(currentOrderId, 1); + } + } else { + distributionParcelListEntity.setOrderPackageStatus("20"); + if (!Objects.isNull(warehouseWaybillEntity)) { + Long destinationWarehouseId = warehouseWaybillEntity.getDestinationWarehouseId();//目的仓 + if (destinationWarehouseId.equals(warehouseId)) { + distributionParcelListEntity.setIsTransfer(0); + } else { + distributionParcelListEntity.setIsTransfer(1); + } + } + distributionParcelListClient.update(distributionParcelListEntity); + } + updownTypeClient.downPackageOrDelTray(orderPackageCode, wid, "干线卸车下架解托"); + } + + //无装车记录异常日志记录 + try { + + + carsLoadAsyncService.abnormalListUnloadByLoadIdAndWarehouseId(loadId, warehouseId, warehouseName, loadScanId, AuthUtil.getTenantId(), AuthUtil.getUserId(), AuthUtil.getNickName(), Func.firstLong(AuthUtil.getDeptId())); + } catch (Exception e) { + log.warn("###############unloadPackage: 存入异常列表记录失败"); + } + + } else { + String scanStatus = carsLoadScanEntity.getScanStatus(); + if(!"1".equals(scanStatus)){ + log.warn("##############unloadPackage: 包件已卸车 orderPackageCode={}", orderPackageCode); + return R.fail(405, "包件已卸车"); + } + + Long finalNodeId = carsLoadScanEntity.getFinalNodeId(); + Long waybillId = carsLoadScanEntity.getWaybillId(); + String waybillNo = carsLoadScanEntity.getWaybillNo(); + orderCode = carsLoadScanEntity.getOrderCode(); + Long loadScanId = carsLoadScanEntity.getId(); + Long fromWarehouseId = carsLoadScanEntity.getFromWarehouseId(); + isData = carsLoadScanEntity.getIsData(); + Integer isAbnormal = 0; + if (warehouseId.equals(finalNodeId)) { + carsLoadScanEntity.setUnloadAbnormal(0); + } else { + isAbnormal = 1; + carsLoadScanEntity.setUnloadAbnormal(1); + remark = "有数据,有计划,有装车,卸车目的地不正确,异常卸车"; + } + carsLoadScanEntity.setUnloadNodeId(warehouseId); + carsLoadScanEntity.setUnloadNodeName(warehouseName); + carsLoadScanEntity.setUnloadNum(carsLoadScanEntity.getNum()); + carsLoadScanEntity.setScanStatus("2"); + carsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName()); + carsLoadScanEntity.setUnloadTime(new Date()); + trayCode = carsLoadScanEntity.getTrayCode(); + if (!StringUtil.isBlank(trayCode)) { + BasicdataTrayEntity trayEntity = basicdataTrayClient.getTrayByTrayCode(trayCode); + trayId = trayEntity.getId(); + trayName = trayEntity.getPalletName(); + } + if (unbindTray == 1) { + updownTypeClient.downPackageOrDelTray(orderPackageCode, fromWarehouseId, "干线卸车下架解托"); + } + trunklineCarsLoadScanService.updateById(carsLoadScanEntity); + + trunklineCarsUnloadLogService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, waybillId, waybillNo, orderCode, orderPackageCode, 1, + 1, 1, isAbnormal, trayId, trayCode, trayName, fromWarehouseId, loadScanId, remark); + + if (1 == isData) { + DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, fromWarehouseId); + if (Objects.isNull(parcelListEntity)) { + InComingDTO inComingDTO = new InComingDTO(); + inComingDTO.setOrderPackageCode(orderPackageCode); + inComingDTO.setIncomingType(incomingType); + inComingDTO.setWarehouseId(warehouseId); + R r = inComingService.incomingPackage(inComingDTO); + int code = r.getCode(); + if(code != 200){ + log.warn("##############unloadPackage: 包件入库失败 orderPackageCode={}", orderPackageCode); + return R.fail(405, "包件入库失败"); + } +// parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId); + }else{ + Long currentOrderId = null; + //查询当前仓库订单信息有没有 + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); + if (Objects.isNull(stockArticleEntity)) { + //查询包件前面仓的订单信息 + DistributionStockArticleEntity articleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, fromWarehouseId); + stockArticleEntity = new DistributionStockArticleEntity(); + BeanUtil.copy(articleEntity, stockArticleEntity); + stockArticleEntity.setId(null); + stockArticleEntity.setWarehouseId(warehouseId); + stockArticleEntity.setWarehouse(warehouseName); + stockArticleEntity.setHandQuantity(0); + stockArticleEntity.setCompleteSet(1); + stockArticleEntity.setStockupStatus("10"); + stockArticleEntity.setReservationStatus("10"); + stockArticleEntity.setOrderStatus("10"); + stockArticleEntity.setGroundingStatus("10"); + stockArticleEntity.setOrderReceiveStatus("10"); + stockArticleEntity.setFreezeStatus("10"); + stockArticleEntity.setSortingQuantity(0); + stockArticleEntity.setDeliveryQuantity(0); + stockArticleEntity.setTransferQuantity(0); + stockArticleEntity.setSigninQuantity(0); + stockArticleEntity.setIncomingNum(0); + currentOrderId = distributionStockArticleClient.addData(stockArticleEntity); + stockArticleEntity.setId(currentOrderId); + } else { + currentOrderId = stockArticleEntity.getId(); + } + + //判断包件当前仓是否是目的仓 + WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + + if (Objects.isNull(distributionParcelListEntity)) { + distributionParcelListEntity = new DistributionParcelListEntity(); + BeanUtil.copy(parcelListEntity, distributionParcelListEntity); + distributionParcelListEntity.setId(null); + distributionParcelListEntity.setOrderPackageStatus("20"); + if (!Objects.isNull(warehouseWaybillEntity)) { + Long destinationWarehouseId = warehouseWaybillEntity.getDestinationWarehouseId();//目的仓 + if (destinationWarehouseId.equals(warehouseId)) { + distributionParcelListEntity.setIsTransfer(0); + } else { + distributionParcelListEntity.setIsTransfer(1); + } + } + distributionParcelListEntity.setWarehouseId(warehouseId); + distributionParcelListEntity.setWarehouse(warehouseName); + distributionParcelListEntity.setTrainNumber(loadCode); + distributionParcelListEntity.setStockArticleId(currentOrderId); + distributionParcelListEntity.setOrderPackageFreezeStatus("10"); + distributionParcelListEntity.setOrderPackageGroundingStatus("10"); + distributionParcelListEntity.setOrderPackageStockupStatus("10"); + distributionParcelListEntity.setOrderPackageReservationStatus("10"); + distributionParcelListEntity.setOrderPackageLoadingStatus("10"); + distributionParcelListEntity.setWarehouseEntryTimeEnd(new Date()); + boolean add = distributionParcelListClient.add(distributionParcelListEntity); + if (add) { + distributionStockArticleClient.addIncomingNum(currentOrderId, 1); + } + } else { + if (!Objects.isNull(warehouseWaybillEntity)) { + Long destinationWarehouseId = warehouseWaybillEntity.getDestinationWarehouseId();//目的仓 + if (destinationWarehouseId.equals(warehouseId)) { + distributionParcelListEntity.setIsTransfer(0); + } else { + distributionParcelListEntity.setIsTransfer(1); + } + } + distributionParcelListClient.update(distributionParcelListEntity); + } + } + + } else { + //无数据 + TrunklineAdvanceDetailEntity advanceDetailEntity = trunklineAdvanceDetailService.findEntityByOrderPackageCode(orderPackageCode); + if (!Objects.isNull(advanceDetailEntity)) { + String packageStatus = advanceDetailEntity.getPackageStatus(); + orderCode = advanceDetailEntity.getOrderCode(); + String waybillNo1 = advanceDetailEntity.getWaybillNo(); + if ("0".equals(packageStatus)) { + //未入库 + InComingDTO inComingDTO = new InComingDTO(); + inComingDTO.setOrderPackageCode(orderPackageCode); + inComingDTO.setWarehouseId(warehouseId); + inComingService.incomingPackage(inComingDTO); + + } else { + DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByOrderPackageCodeAndStatus(orderPackageCode); + if (!Objects.isNull(parcelListEntity)) { + String orderCode2 = parcelListEntity.getOrderCode(); + DistributionStockArticleEntity newStockArticle = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode2, warehouseId); + Long orderId = null; + if (Objects.isNull(newStockArticle)) { + newStockArticle = new DistributionStockArticleEntity(); + Long stockArticleId = parcelListEntity.getStockArticleId(); + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findEntityByStockArticleId(stockArticleId); + BeanUtil.copy(stockArticleEntity, newStockArticle); + newStockArticle.setId(null); + newStockArticle.setWarehouseId(warehouseId); + newStockArticle.setWarehouse(basicdataWarehouseEntity.getName()); + orderId = distributionStockArticleClient.addData(newStockArticle); + } else { + orderId = newStockArticle.getId(); + } + DistributionParcelListEntity newParcelListEntity = new DistributionParcelListEntity(); + BeanUtil.copy(parcelListEntity, newParcelListEntity); + newParcelListEntity.setId(null); + newParcelListEntity.setWarehouseId(warehouseId); + newParcelListEntity.setWarehouse(basicdataWarehouseEntity.getName()); + newParcelListEntity.setStockArticleId(orderId); + distributionParcelListClient.add(newParcelListEntity); + } + } + + carsLoadScanEntity.setOrderCode(orderCode); + carsLoadScanEntity.setWaybillNo(waybillNo1); + carsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName()); + carsLoadScanEntity.setUnloadTime(new Date()); + carsLoadScanEntity.setIsData(1); + isData = 1; + trunklineCarsLoadScanService.updateById(carsLoadScanEntity); + + } + } + } + updateNumByLoadId(loadId); + + try { + + carsLoadAsyncService.dealwithAfterAbnormalPackage(orderPackageCode, warehouseId, warehouseName, carsLoadEntity.getCarsNo(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName()); + + List orderPackageCodes = new ArrayList<>(); + + orderPackageCodes.add(orderPackageCode); + String content = "包件在 " + warehouseName + "卸车,卸车方式:" + IncomingTypeEnum.getValue(incomingType); + packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, warehouseId, warehouseName, WorkNodeEnums.UNLOAD_INCOMING_WAREHOUSE.getCode(), content); + try { + if (StrUtil.isNotEmpty(orderCode)) { + // 发送入库消息 + OrderStatusDTO orderStatusDTO = new OrderStatusDTO(); + // 通过包件id 查询包件 + orderStatusDTO.setUnitNo(orderPackageCode); + orderStatusDTO.setOrderNo(orderCode); + orderStatusDTO.setStatus("4"); + orderStatusDTO.setOperationTime(DateUtil.now()); + orderStatusDTO.setCurrentWarehouse(warehouseId.toString()); + Map map = new HashMap<>(); + map.put("messageData", JSONUtil.toJsonStr(orderStatusDTO)); + rabbitTemplate.convertAndSend(RabbitConstant.HWY_ORDER_STATUS_EXCHANGE, RabbitConstant.HWY_ORDER_STATUS_ROUTING, map); + + NodePushMsg nodePushMsg = NodePushMsg.builder() + .operator(AuthUtil.getNickName()) + .operatorTime(new Date()) + .address("在【" + warehouseName + "】入库") + .brand(BrandEnums.getByValue(distributionParcelListEntity.getBrandName())) + .node(WorkNodeEnums.UNLOAD_INCOMING_WAREHOUSE) + .content(Collections.singletonList(PushData.builder() + .packageCode(orderPackageCode) + .warehouseName(warehouseName) + .orderCode(orderCode) + .build())) + .build(); + factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); + } + } catch (Exception e) { + log.error("入库推送失败:{}", e); + } + } catch (Exception e) { + log.warn("#########卸车存入日志失败"); + } + + JSONObject jsonObject = trunklineCarsLoadScanService.findUnloadNumAudio(loadId,warehouseId); + Integer totalUnloadNum = jsonObject.getInteger("totalUnloadNum"); + Integer abnormalUnloadNum = jsonObject.getInteger("abnormalUnloadNum"); + StringBuilder audio = new StringBuilder(); + audio.append("卸车").append(totalUnloadNum).append("件"); + if(!Objects.isNull(abnormalUnloadNum) && !abnormalUnloadNum.equals(0)){ + audio.append("异常卸车").append(abnormalUnloadNum).append("件"); + } + + if (isData == 0) { + return Resp.scanSuccess("卸车成功", "系统无编码"); + } + return Resp.scanSuccess("卸车成功", audio.toString()); + } + + + @Override + public R unloadZero(Long loadId, String waybillNo, Integer enterNun, Long warehouseId, Integer unbindTray, String trayCode, String orderCode, String remark) { + log.info("#############unloadZero: 卸车零担"); + + TrunklineCarsLoadEntity carsLoadEntity = baseMapper.selectById(loadId); + if (Objects.isNull(carsLoadEntity)) { + log.warn("#############unloadZero: 配载计划信息不存在 loadId={}", loadId); + return R.fail(405, "配载计划信息不存在"); + } + + String loadCode = carsLoadEntity.getCarsNo(); + TrunklineCarsLoadLineEntity loadLineEntity = trunklineCarsLoadLineService.findEntityByLoadIdAndNodeId(loadId, warehouseId); + if (Objects.isNull(loadLineEntity)) { + log.warn("############unloadZero: 配载计划节点信息不存在 loadId={} warehouseId={}", loadId, warehouseId); + return R.fail(405, "配载计划节点信息不存在"); + } + String unloadStatus = loadLineEntity.getUnloadStatus(); + if (!"0".equals(unloadStatus)) { + log.warn("############unloadZero: 当前网点已经卸车确认 loadId={} warehouseId={}", loadId, warehouseId); + return R.fail(405, "当前网点已经卸车确认"); + } + + BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + if (Objects.isNull(basicdataWarehouseEntity)) { + log.warn("#############unloadZero: 仓库信息不存在 warehouseId={}", warehouseId); + return R.fail(405, "仓库信息不存在"); + } + + String warehouseName = basicdataWarehouseEntity.getName(); + + WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + if (Objects.isNull(waybillEntity)) { + log.warn("#############unloadZero: 运单信息不存在 waybillNo={}", waybillNo); + return R.fail(405, "运单信息不存在"); + } + + Long trayId = null; + String trayName = null; + if (!StringUtil.isBlank(trayCode)) { + BasicdataTrayEntity trayEntity = basicdataTrayClient.getTrayByTrayCode(trayCode); + if (!Objects.isNull(trayEntity)) { + trayId = trayEntity.getId(); + trayName = trayEntity.getPalletName(); + } + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("waybill_no", waybillNo) + .eq("load_id", loadId) + .eq("final_node_id", warehouseId) + .eq("order_code", orderCode); + TrunklineCarsLoadScanEntity carsLoadScanEntity = trunklineCarsLoadScanService.getOne(queryWrapper); + if (Objects.isNull(carsLoadScanEntity)) { + log.warn("#############unloadZero: 零担信息不存在 waybillNo={} order_code={} loadId={} finalNodeId={}", waybillNo, orderCode, loadId, warehouseId); + return R.fail(405, "零担信息不存在"); + } + + Integer isAbnormal = 0; + Integer num = carsLoadScanEntity.getNum(); + Long fromWarehouseId = carsLoadScanEntity.getFromWarehouseId(); + Long waybillId = carsLoadScanEntity.getWaybillId(); + String scanCode = carsLoadScanEntity.getScanCode(); + Long loadScanId = carsLoadScanEntity.getId(); + if (enterNun > num) { + log.warn("#############unloadZero: 零担信息卸车数量大于装车件数 enterNun={} num={}", enterNun, num); + return R.fail(405, "零担信息卸车数量大于装车件数"); + } + + carsLoadScanEntity.setUnloadNum(enterNun); + carsLoadScanEntity.setUnloadNodeId(warehouseId); + carsLoadScanEntity.setUnloadNodeName(warehouseName); + carsLoadScanEntity.setUnloadAbnormal(0); + carsLoadScanEntity.setScanStatus("2"); + carsLoadScanEntity.setLoadingUserName(AuthUtil.getNickName()); + carsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName()); + carsLoadScanEntity.setUnloadTime(new Date()); + trunklineCarsLoadScanService.updateById(carsLoadScanEntity); + + trunklineCarsUnloadLogService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, waybillId, waybillNo, orderCode, + scanCode, enterNun, 2, 1, isAbnormal, trayId, trayCode, trayName, fromWarehouseId, loadScanId, remark); + + if (unbindTray == 1) { + if (!StringUtil.isBlank(trayCode)) { + trayTypeClient.deleteZeroOrderByTrayCode(orderCode, trayCode, fromWarehouseId, "干线卸车零担解托"); + } + } + +// DistributionStockArticleEntity newStockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); +// if (Objects.isNull(newStockArticleEntity)) { +// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, fromWarehouseId); +// newStockArticleEntity = new DistributionStockArticleEntity(); +// BeanUtil.copy(stockArticleEntity, newStockArticleEntity); +// newStockArticleEntity.setId(null); +// newStockArticleEntity.setOrderReceiveStatus("20"); +// newStockArticleEntity.setOrderStatus("10"); +// newStockArticleEntity.setHandQuantity(enterNun); +// newStockArticleEntity.setIncomingNum(enterNun); +// newStockArticleEntity.setWarehouse(basicdataWarehouseEntity.getName()); +// newStockArticleEntity.setWarehouseId(basicdataWarehouseEntity.getId()); +// newStockArticleEntity.setCarsLoadNum(0); +// Long orderId = distributionStockArticleClient.addData(newStockArticleEntity); +// if (orderId != 0) { +// List parcelListEntityList = distributionParcelListClient.findEntityListByOrderCode(orderCode, fromWarehouseId); +// List ls = new ArrayList<>(); +// for (DistributionParcelListEntity parcelListEntity : parcelListEntityList) { +// DistributionParcelListEntity newParcelListEntity = new DistributionParcelListEntity(); +// BeanUtil.copy(parcelListEntity, newParcelListEntity); +// newParcelListEntity.setId(null); +// newParcelListEntity.setWarehouseId(warehouseId); +// newParcelListEntity.setWarehouse(warehouseName); +// newParcelListEntity.setStockArticleId(orderId); +// Long acceptWarehouseId = parcelListEntity.getAcceptWarehouseId(); +// if(warehouseId.equals(acceptWarehouseId)){ +// newParcelListEntity.setIsTransfer(0); +// }else{ +// newParcelListEntity.setIsTransfer(1); +// } +// Long orderPackageId = distributionParcelListClient.addReturnId(newParcelListEntity); +// +// DistributionParcelNumberEntity parcelNumberEntity = new DistributionParcelNumberEntity(); +// parcelNumberEntity.setStockArticleId(orderId); +// parcelNumberEntity.setParcelListId(orderPackageId); +// parcelNumberEntity.setQuantity(newParcelListEntity.getQuantity()); +// parcelNumberEntity.setHandQuantity(0); +// parcelNumberEntity.setDeliveryQuantity(0); +// parcelNumberEntity.setSigninQuantity(0); +// parcelNumberEntity.setOutboundQuantity(0); +// parcelNumberEntity.setWarehouseId(warehouseId); +// ls.add(parcelNumberEntity); +// } +// distributionParcelNumberClient.addBatch(ls); +// } +// } else { +// Integer handQuantity = newStockArticleEntity.getHandQuantity() + enterNun; +// Integer incomingNum = newStockArticleEntity.getIncomingNum() + enterNun; +// Integer totalNumber = newStockArticleEntity.getTotalNumber(); +// +// if (incomingNum.equals(totalNumber)) { +// if (handQuantity.equals(totalNumber)) { +// newStockArticleEntity.setOrderStatus("20"); +// } else { +// newStockArticleEntity.setOrderStatus("30"); +// } +// newStockArticleEntity.setOrderReceiveStatus("30"); +// } else { +// if (incomingNum.equals(handQuantity)) { +// newStockArticleEntity.setOrderStatus("10"); +// } else { +// newStockArticleEntity.setOrderStatus("30"); +// } +// newStockArticleEntity.setOrderReceiveStatus("20"); +// } +// newStockArticleEntity.setHandQuantity(handQuantity); +// newStockArticleEntity.setIncomingNum(incomingNum); +// +// distributionStockArticleClient.saveOrUpdate(newStockArticleEntity); +// } + + updateNumByLoadId(loadId); + + return R.success("卸车成功"); + } + + + public R unloadZeroNoXz(Long loadId, String waybillNo, Integer enterNun, Long warehouseId, Integer unbindTray, String trayCode, String orderCode, String remark) { + log.info("#############unloadZero: 卸车零担"); + + TrunklineCarsLoadEntity carsLoadEntity = baseMapper.selectById(loadId); + if (Objects.isNull(carsLoadEntity)) { + log.warn("#############unloadZero: 配载计划信息不存在 loadId={}", loadId); + return R.fail(405, "配载计划信息不存在"); + } + + String loadCode = carsLoadEntity.getCarsNo(); + TrunklineCarsLoadLineEntity loadLineEntity = trunklineCarsLoadLineService.findEntityByLoadIdAndNodeId(loadId, warehouseId); + if (Objects.isNull(loadLineEntity)) { + log.warn("############unloadZero: 配载计划节点信息不存在 loadId={} warehouseId={}", loadId, warehouseId); + return R.fail(405, "配载计划节点信息不存在"); + } + + BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + if (Objects.isNull(basicdataWarehouseEntity)) { + log.warn("#############unloadZero: 仓库信息不存在 warehouseId={}", warehouseId); + return R.fail(405, "仓库信息不存在"); + } + + String warehouseName = basicdataWarehouseEntity.getName(); + + WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + if (Objects.isNull(waybillEntity)) { + log.warn("#############unloadZero: 运单信息不存在 waybillNo={}", waybillNo); + return R.fail(405, "运单信息不存在"); + } + + Long trayId = null; + String trayName = null; + if (!StringUtil.isBlank(trayCode)) { + BasicdataTrayEntity trayEntity = basicdataTrayClient.getTrayByTrayCode(trayCode); + if (!Objects.isNull(trayEntity)) { + trayId = trayEntity.getId(); + trayName = trayEntity.getPalletName(); + } + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("waybill_no", waybillNo) + .eq("load_id", loadId) + .eq("final_node_id", warehouseId) + .eq("order_code", orderCode); + TrunklineCarsLoadScanEntity carsLoadScanEntity = trunklineCarsLoadScanService.getOne(queryWrapper); + if (Objects.isNull(carsLoadScanEntity)) { + log.warn("#############unloadZero: 零担信息不存在 waybillNo={} order_code={} loadId={} finalNodeId={}", waybillNo, orderCode, loadId, warehouseId); + return R.fail(405, "零担信息不存在"); + } + + Integer isAbnormal = 0; + Integer num = carsLoadScanEntity.getNum(); + Long fromWarehouseId = carsLoadScanEntity.getFromWarehouseId(); + Long waybillId = carsLoadScanEntity.getWaybillId(); + String scanCode = carsLoadScanEntity.getScanCode(); + Long loadScanId = carsLoadScanEntity.getId(); + if (enterNun > num) { + log.warn("#############unloadZero: 零担信息卸车数量大于装车件数 enterNun={} num={}", enterNun, num); + return R.fail(405, "零担信息卸车数量大于装车件数"); + } + + carsLoadScanEntity.setUnloadNum(enterNun); + carsLoadScanEntity.setUnloadNodeId(warehouseId); + carsLoadScanEntity.setUnloadNodeName(warehouseName); + carsLoadScanEntity.setUnloadAbnormal(0); + carsLoadScanEntity.setScanStatus("2"); + carsLoadScanEntity.setLoadingUserName(AuthUtil.getNickName()); + carsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName()); + carsLoadScanEntity.setUnloadTime(new Date()); + trunklineCarsLoadScanService.updateById(carsLoadScanEntity); + + trunklineCarsUnloadLogService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, waybillId, waybillNo, orderCode, + scanCode, enterNun, 2, 1, isAbnormal, trayId, trayCode, trayName, fromWarehouseId, loadScanId, remark); + + if (unbindTray == 1) { + if (!StringUtil.isBlank(trayCode)) { + trayTypeClient.deleteZeroOrderByTrayCode(orderCode, trayCode, fromWarehouseId, "干线卸车零担解托"); + } + } updateNumByLoadId(loadId); From 1d1f0b910b9ac34e61f9dd84e3cf8f70bb60bf52 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Thu, 18 Jul 2024 18:19:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1.=E5=B9=B2=E7=BA=BFbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TrunklineCarsLoadServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 453a3fbc3..b8092f416 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -6699,11 +6699,11 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl