diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsStartNumVO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsStartNumVO.java new file mode 100644 index 000000000..19815d05d --- /dev/null +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsStartNumVO.java @@ -0,0 +1,16 @@ +package com.logpm.trunkline.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class CarsStartNumVO implements Serializable { + + private String carsNo; + private String orderCode; + private String waybillNo; + private String startNum; + + +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java index 08b70aa0b..abb51d1ef 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java @@ -2984,4 +2984,79 @@ public class CarsLoadController { } + @ResponseBody + @PostMapping("/findOrderPlanCarsNum") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "查询订单锁定配载计划", notes = "传入loadCarsDTO") + public R findOrderPlanCarsNum(@RequestBody LoadCarsDTO loadCarsDTO) { + String method = "############findOrderPlanCarsNum: "; + log.info(method+"请求参数{}",loadCarsDTO); + + String orderCode = loadCarsDTO.getOrderCode(); + + try{ + + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"请选择指定仓库"); + return R.fail(405,"请选择指定仓库"); + } + Long warehouseId = myCurrentWarehouse.getId(); + String warehouseName = myCurrentWarehouse.getName(); + + if(StringUtil.isNotBlank(orderCode)){ + log.warn(method+"查询参数为空"); + return R.fail(405,"查询参数为空"); + } + + return carsLoadService.findOrderPlanCarsNum(orderCode,warehouseId,warehouseName); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常",e); + return R.fail(500,"系统异常"); + } + } + + + + @ResponseBody + @PostMapping("/zeroUnloadEnter") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "零担卸车确认", notes = "传入loadCarsDTO") + public R zeroUnloadEnter(@RequestBody LoadCarsDTO loadCarsDTO) { + String method = "############zeroUnloadEnter: "; + log.info(method+"请求参数{}",loadCarsDTO); + + List loadScanIds = loadCarsDTO.getLoadScanIds(); + + try{ + + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"请选择指定仓库"); + return R.fail(405,"请选择指定仓库"); + } + Long warehouseId = myCurrentWarehouse.getId(); + String warehouseName = myCurrentWarehouse.getName(); + + if(CollUtil.isNotEmpty(loadScanIds)){ + log.warn(method+"明细id为空"); + return R.fail(405,"明细id为空"); + } + + return carsLoadService.zeroUnloadEnter(loadScanIds,warehouseId,warehouseName); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常",e); + return R.fail(500,"系统异常"); + } + } + + + + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java index 67ed434f7..f1d16af28 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java @@ -74,4 +74,6 @@ public interface TrunklineCarsOrderMapper extends BaseMapper findListByLoadId(@Param("loadId") Long loadId); List findLoadingOrderPlan(@Param("loadId") Long loadId, @Param("warehouseId") Long warehouseId); + + List findStartNumByOrderCodeAndWarehouseId(@Param("orderCode") String orderCode, @Param("warehouseId") Long warehouseId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml index 38d2cfc9e..a04b2506c 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml @@ -419,4 +419,17 @@ and t.scan_code is null + + + 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 46395b704..94c747ffe 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 @@ -275,4 +275,8 @@ public interface ITrunklineCarsLoadService extends BaseService loadScanIds, Long warehouseId, String warehouseName); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java index 54fe1a4e5..b954059d0 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java @@ -72,4 +72,5 @@ public interface ITrunklineCarsOrderService extends BaseService findLoadingOrderPlan(Long loadId, Long warehouseId); + List findStartNumByOrderCodeAndWarehouseId(String orderCode, Long warehouseId); } 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 40d963a3c..591be9597 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 @@ -1248,6 +1248,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl ls = trunklineCarsOrderService.findStartNumByOrderCodeAndWarehouseId(orderCode,warehouseId); + + + return R.data(ls); + } + + @Override + public R zeroUnloadEnter(List loadScanIds, Long warehouseId, String warehouseName) { + + List carsLoadScanEntityList = trunklineCarsLoadScanService.findListByIds(loadScanIds); + //排除carsLoadScanEntityList中unloadCheck为1的值 + carsLoadScanEntityList = carsLoadScanEntityList.stream().filter(carsLoadScanEntity -> !carsLoadScanEntity.getUnloadCheck().equals(1)).collect(Collectors.toList()); + + if(CollUtil.isNotEmpty(carsLoadScanEntityList)){ + TrunklineCarsLoadScanEntity carsLoadScanEntity1 = carsLoadScanEntityList.get(0); + Long loadId = carsLoadScanEntity1.getLoadId(); + + TrunklineCarsLoadEntity carsLoadEntity = baseMapper.selectById(loadId); + if(Objects.isNull(carsLoadEntity)){ + log.warn("#############zeroUnloadEnter: 配载计划不存在 loadId={}",loadId); + return R.fail("配载计划不存在"); + } + + //把carsLoadScanEntityList通过orderCode进行分组 + Map> orderCodemap = carsLoadScanEntityList.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getOrderCode)); + orderCodemap.keySet().forEach(orderCode -> { + List orderCodeList = orderCodemap.get(orderCode); + //把orderCodeList通过fromWarehouseId进行分组 + Map> fromWarehouseIdmap = orderCodeList.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getFromWarehouseId)); + fromWarehouseIdmap.keySet().forEach(fromWarehouseId -> { + List fromWarehouseIdList = fromWarehouseIdmap.get(fromWarehouseId); + + int realNum = fromWarehouseIdList.stream().mapToInt(TrunklineCarsLoadScanEntity::getNum).sum(); + //把fromWarehouseIdList中所有元素的unloadNum累加 + int unloadNum = fromWarehouseIdList.stream().mapToInt(TrunklineCarsLoadScanEntity::getUnloadNum).sum(); + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findZeroByOrderCodeAndWarehouseId(orderCode, fromWarehouseId); + if(!Objects.isNull(stockArticleEntity)){ + + if(unloadNum > realNum){ + //卸车数大于实际装车数 + throw new CustomerException(405,"零担订单"+orderCode+"卸车件数已大于实际装车件数,请去调整补录"); + }else { + + //把fromWarehouseIdList中所有元素的id放入一个集合 + List carsLoadScanIds = fromWarehouseIdList.stream().map(TrunklineCarsLoadScanEntity::getId).collect(Collectors.toList()); + + List zeroDetailVOList = scanZeroDetailService.findListByCarsLoadScanIds(carsLoadScanIds); + //把zeroDetailVOList所有元素通过goodsName进行分组 + Map> goodsNamemap = zeroDetailVOList.stream().collect(Collectors.groupingBy(TrunklineScanZeroDetailVO::getGoodsName)); + + + DistributionStockArticleEntity newStockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); + if (Objects.isNull(newStockArticleEntity)) { + newStockArticleEntity = new DistributionStockArticleEntity(); + BeanUtil.copy(stockArticleEntity, newStockArticleEntity); + Integer totalNumber = stockArticleEntity.getTotalNumber(); + newStockArticleEntity.setId(null); + if(totalNumber == unloadNum){ + newStockArticleEntity.setOrderReceiveStatus("30"); + }else{ + newStockArticleEntity.setOrderReceiveStatus("20"); + } + newStockArticleEntity.setOrderStatus("10"); + newStockArticleEntity.setHandQuantity(unloadNum); + newStockArticleEntity.setIncomingNum(unloadNum); + newStockArticleEntity.setWarehouse(warehouseName); + newStockArticleEntity.setWarehouseId(warehouseId); + newStockArticleEntity.setAllocation(null); + newStockArticleEntity.setTrays(null); + newStockArticleEntity.setCarsLoadNum(0); + Long orderId = distributionStockArticleClient.addData(newStockArticleEntity); + if (orderId != 0) { + + Integer isTransfer = 1; + List parcelListEntityList = distributionParcelListClient.findEntityVOListByOrderCode(orderCode, fromWarehouseId); + List ls = new ArrayList<>(); + for (DistributionParcelListVO parcelListEntity : parcelListEntityList) { + DistributionParcelListEntity newParcelListEntity = new DistributionParcelListEntity(); + String firsts = parcelListEntity.getFirsts(); + List detailVOList = goodsNamemap.get(firsts); + //把detailVOList所有元素的unloadNum求和,如果为空用0代替 + int totalUnloadNum = detailVOList.stream() + .mapToInt(vo -> Optional.ofNullable(vo.getUnloadNum()).orElse(0)) + .sum(); + + BeanUtil.copy(parcelListEntity, newParcelListEntity); + newParcelListEntity.setId(null); + newParcelListEntity.setWarehouseId(warehouseId); + newParcelListEntity.setWarehouse(warehouseName); + newParcelListEntity.setStockArticleId(orderId); + newParcelListEntity.setQuantity(totalUnloadNum); + Long acceptWarehouseId = parcelListEntity.getAcceptWarehouseId(); + if(warehouseId.equals(acceptWarehouseId)){ + newParcelListEntity.setIsTransfer(0); + isTransfer = 0; + }else{ + newParcelListEntity.setIsTransfer(1); + } + Long orderPackageId = distributionParcelListClient.addReturnId(newParcelListEntity); + + DistributionParcelNumberEntity parcelNumberEntity = new DistributionParcelNumberEntity(); + parcelNumberEntity.setStockArticleId(orderId); + parcelNumberEntity.setParcelListId(orderPackageId); + parcelNumberEntity.setQuantity(parcelListEntity.getZeroPackageTotalNum()); + parcelNumberEntity.setHandQuantity(totalUnloadNum); + parcelNumberEntity.setDeliveryQuantity(0); + parcelNumberEntity.setSigninQuantity(0); + parcelNumberEntity.setOutboundQuantity(0); + parcelNumberEntity.setWarehouseId(warehouseId); + ls.add(parcelNumberEntity); + } + distributionParcelNumberClient.addBatch(ls); + } + } else { + Integer hQuantity = newStockArticleEntity.getHandQuantity() + unloadNum; + Integer incomingNum = newStockArticleEntity.getIncomingNum() + unloadNum; + Integer totalNumber = newStockArticleEntity.getTotalNumber(); + String reservationStatus = newStockArticleEntity.getReservationStatus(); + String orderStatus = newStockArticleEntity.getOrderStatus(); + + + if (incomingNum.equals(totalNumber)) { + newStockArticleEntity.setOrderStatus("20"); + newStockArticleEntity.setOrderReceiveStatus("30"); + } else { + newStockArticleEntity.setOrderReceiveStatus("20"); + } + + if("30".equals(reservationStatus)){ + newStockArticleEntity.setReservationStatus("20"); + } + if("80".equals(orderStatus)){ + newStockArticleEntity.setOrderStatus("70"); + } + + newStockArticleEntity.setHandQuantity(hQuantity); + newStockArticleEntity.setIncomingNum(incomingNum); + + List listEntityList = distributionParcelListClient.findEntityListByOrderCode(orderCode, warehouseId); + //把listEntityList中所有元素的id放入一个集合 + List parcelListIds = listEntityList.stream().map(DistributionParcelListEntity::getId).collect(Collectors.toList()); + List parceNumberList = distributionParcelNumberClient.findListByParcelListIds(parcelListIds); + //把parceNumberList转化成以parcelListId为key的Map + Map mapByParcelListId = parceNumberList.stream() + .collect(Collectors.toMap( + DistributionParcelNumberEntity::getParcelListId, + entity -> entity, + (entity1, entity2) -> entity1)); // 处理可能的键冲突 + + List updateParceList = new ArrayList<>(); + List updateParceNumberList = new ArrayList<>(); + + listEntityList.forEach(entity -> { + Long parceListId = entity.getId(); + String firsts = entity.getFirsts(); + List detailVOList = goodsNamemap.get(firsts); + //把detailVOList所有元素的unloadNum求和,如果为空用0代替 + int totalUnloadNum = detailVOList.stream() + .mapToInt(vo -> Optional.ofNullable(vo.getUnloadNum()).orElse(0)) + .sum(); + Integer quantity = entity.getQuantity(); + DistributionParcelListEntity updatePaceList = new DistributionParcelListEntity(); + updatePaceList.setId(parceListId); + updatePaceList.setQuantity(quantity+totalUnloadNum); + updatePaceList.setOrderPackageStatus("20"); + updatePaceList.setOrderPackageStockupStatus("10"); + updatePaceList.setOrderPackageReservationStatus("10"); + updatePaceList.setOrderPackageLoadingStatus("10"); + updateParceList.add(updatePaceList); + + DistributionParcelNumberEntity parcelNumberEntity = mapByParcelListId.get(parceListId); + if(!Objects.isNull(parcelNumberEntity)){ + Integer handQuantity = parcelNumberEntity.getHandQuantity(); + DistributionParcelNumberEntity updateParceNumberEntity = new DistributionParcelNumberEntity(); + updateParceNumberEntity.setId(parcelNumberEntity.getId()); + updateParceNumberEntity.setHandQuantity(handQuantity + totalUnloadNum); + updateParceNumberList.add(updateParceNumberEntity); + } + }); + + if(CollUtil.isNotEmpty(updateParceList)){ + distributionParcelListClient.updateList(updateParceList); + } + if(CollUtil.isNotEmpty(updateParceNumberList)){ + distributionParcelNumberClient.updateList(updateParceNumberList); + } + distributionStockArticleClient.saveOrUpdate(newStockArticleEntity); + + } + } + } + }); + + WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillClient.findByWaybillNo(orderCode); + waybillPackageService.updateWaybillStatus(warehouseWaybillEntity); + + }); + + + //把carsLoadScanEntityList中所有id放入一个List + List scanIds = carsLoadScanEntityList.stream().map(TrunklineCarsLoadScanEntity::getId).collect(Collectors.toList()); + List zeroDetailVOList = scanZeroDetailService.findListByCarsLoadScanIds(scanIds); + //把zeroDetailVOList中所有元素通过scanId进行分组 + Map> mapByScanId = zeroDetailVOList.stream() + .collect(Collectors.groupingBy(TrunklineScanZeroDetailVO::getScanId)); + + + carsLoadScanEntityList.forEach(carsLoadScanEntity -> { + + Long scanId = carsLoadScanEntity.getId(); + + List list = mapByScanId.get(scanId); + + carsLoadAsyncService.sendReportZeroPackageUnloadData(AuthUtil.getUserId(), AuthUtil.getNickName(), warehouseId, warehouseName,list,carsLoadScanEntity,carsLoadEntity); + + }); + + + } + + return R.success("操作成功"); + } + private void updateParcelListToWarehouse(TrunklineAdvanceDetailEntity advanceDetailEntity, Long warehouseId, String status) { String orderPackageCode = advanceDetailEntity.getOrderPackageCode(); String orderCode = advanceDetailEntity.getOrderCode(); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java index fed869e00..2620d8e15 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java @@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.List; @Slf4j @@ -173,4 +174,9 @@ public class TrunklineCarsOrderEntityServiceImpl extends BaseServiceImpl findStartNumByOrderCodeAndWarehouseId(String orderCode, Long warehouseId) { + return baseMapper.findStartNumByOrderCodeAndWarehouseId(orderCode,warehouseId); + } + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml index 6aa317d3b..bb4124a62 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml @@ -1035,18 +1035,6 @@ #{id} - - and ( - lww.departure_warehouse_id in - - #{item} - - or lww.destination_warehouse_id in - - #{item} - - ) - and Locate(#{param.waybillNo},lww.waybill_no) > 0