@ -16,24 +16,17 @@
* /
package com.logpm.warehouse.service.impl ;
import com.baomidou.mybatisplus.core.conditions.Wrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity ;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient ;
import com.logpm.distribution.entity.DisStockListDetailEntity ;
import com.logpm.distribution.entity.DistributionLoadscanEntity ;
import com.logpm.distribution.entity.DistributionParcelListEntity ;
import com.logpm.distribution.entity.DistributionParcelNumberEntity ;
import com.logpm.distribution.feign.IDistributionDeliveryListClient ;
import com.logpm.distribution.feign.IDistributionLoadscanClient ;
import com.logpm.distribution.feign.IDistributionParcelListClient ;
import com.logpm.distribution.feign.IDistributionReservationClient ;
import com.logpm.distribution.vo.DistributionDeliveryListVO ;
import com.logpm.distribution.vo.DistributionDeliverySelfVO ;
import com.logpm.oldproject.feign.IWarehouseClient ;
import com.logpm.warehouse.bean.Resp ;
import com.logpm.warehouse.dto.* ;
import com.logpm.warehouse.entity.WarehouseRetentionRecordEntity ;
@ -43,7 +36,6 @@ import com.logpm.warehouse.mapper.WarehouseRetentionRecordMapper;
import com.logpm.warehouse.service.IWarehouseRetentionRecordService ;
import com.logpm.warehouse.service.IWarehouseRetentionScanService ;
import com.logpm.warehouse.vo.WarehouseRetentionRecordVO ;
import com.logpm.warehouse.vo.WarehouseRetentionScanVO ;
import com.logpm.warehouse.vo.WarehouseWaybillDetentionVO ;
import com.logpm.warehouse.wrapper.WarehouseRetentionRecordWrapper ;
import com.logpm.warehouse.wrapper.WarehouseRetentionScanWrapper ;
@ -52,7 +44,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.DictBizConstant ;
import org.springblade.common.constant.common.IsOrNoConstant ;
import org.springblade.common.constant.retention.RetentionTypeConstant ;
import org.springblade.common.exception.CustomerException ;
import org.springblade.core.log.exception.ServiceException ;
import org.springblade.core.mp.base.BaseServiceImpl ;
import org.springblade.core.secure.BladeUser ;
@ -64,6 +55,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional ;
import java.util.* ;
import java.util.concurrent.atomic.AtomicBoolean ;
import java.util.concurrent.atomic.AtomicInteger ;
import java.util.function.Function ;
import java.util.stream.Collectors ;
@ -84,7 +76,7 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
private final IWarehouseRetentionScanService warehouseRetentionScanService ;
private final IDistributionDeliveryListClient deliveryListClient ;
private final IBasicdataWarehouseClient warehouseClient ;
// private final IDistributionReservationClient distributionReservationClient;
// private final IDistributionReservationClient distributionReservationClient;
private final IDistributionDeliveryListClient distributionDeliveryListClient ;
@Override
@ -94,7 +86,7 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
@Override
public IPage < WarehouseWaybillDetentionVO > selectWarehouseRetentionWaybillPage ( IPage < WarehouseWaybillDetentionVO > page , WarehouseWaybillDetentionVO warehouseWaybillDetentionVO ) {
List < WarehouseWaybillDetentionVO > warehouseRetentionRecordVOS = baseMapper . selectWarehouseWaybillRecordPage ( page , warehouseWaybillDetentionVO ) ;
List < WarehouseWaybillDetentionVO > warehouseRetentionRecordVOS = baseMapper . selectWarehouseWaybillRecordPage ( page , warehouseWaybillDetentionVO ) ;
return page . setRecords ( warehouseRetentionRecordVOS ) ;
}
@ -105,7 +97,7 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
page . setCurrent ( retentionDTO . getPageNum ( ) ) ;
page . setSize ( retentionDTO . getPageSize ( ) ) ;
IPage < WarehouseRetentionRecordEntity > pageList = baseMapper . retentionPackageList ( page , retentionDTO ) ;
IPage < WarehouseRetentionRecordEntity > pageList = baseMapper . retentionPackageList ( page , retentionDTO ) ;
return WarehouseRetentionRecordWrapper . build ( ) . pageVO ( pageList ) ;
}
@ -116,14 +108,14 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
//查询装车记录表,存入滞留包件记录
//查询配送装车记录表是否有包件记录
DistributionLoadscanEntity loadscanEntity = distributionLoadscanClient . getByOrderPackageCode ( orderPackageCode ) ;
if ( Objects . isNull ( loadscanEntity ) ) {
log . warn ( "#################retentionScanPackage: 未找到配送装车记录 orderPackageCode=" + orderPackageCode ) ;
return R . fail ( 403 , "未找到配送装车记录" ) ;
if ( Objects . isNull ( loadscanEntity ) ) {
log . warn ( "#################retentionScanPackage: 未找到配送装车记录 orderPackageCode=" + orderPackageCode ) ;
return R . fail ( 403 , "未找到配送装车记录" ) ;
}
DistributionParcelListEntity parcelListEntity = distributionParcelListClient . findByPacketBarCode ( orderPackageCode ) ;
if ( Objects . isNull ( parcelListEntity ) ) {
log . warn ( "#################retentionScanPackage: 未找到包件数据 orderPackageCode=" + orderPackageCode ) ;
return R . fail ( 403 , "未找到包件数据" ) ;
if ( Objects . isNull ( parcelListEntity ) ) {
log . warn ( "#################retentionScanPackage: 未找到包件数据 orderPackageCode=" + orderPackageCode ) ;
return R . fail ( 403 , "未找到包件数据" ) ;
}
WarehouseRetentionRecordEntity retentionRecordEntity = new WarehouseRetentionRecordEntity ( ) ;
@ -147,7 +139,7 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
WarehouseRetentionRecordEntity retentionRecordEntity = this . getOne ( Wrappers . < WarehouseRetentionRecordEntity > query ( ) . lambda ( )
. eq ( WarehouseRetentionRecordEntity : : getRetentionType , RetentionTypeConstant . peisongzhiliu . getValue ( ) )
. eq ( WarehouseRetentionRecordEntity : : getTaskId , deliveryId ) ) ;
if ( Func . isEmpty ( retentionRecordEntity ) ) {
if ( Func . isEmpty ( retentionRecordEntity ) ) {
return null ;
}
WarehouseRetentionRecordVO warehouseRetentionRecordVO = WarehouseRetentionRecordWrapper . build ( ) . entityVO ( retentionRecordEntity ) ;
@ -155,7 +147,7 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
List < WarehouseRetentionScanEntity > retentionScanEntityList = warehouseRetentionScanService . list ( Wrappers . < WarehouseRetentionScanEntity > query ( ) . lambda ( )
. eq ( WarehouseRetentionScanEntity : : getDeliveryId , retentionRecordEntity . getTaskId ( ) )
. eq ( WarehouseRetentionScanEntity : : getRefId , retentionRecordEntity . getId ( ) ) ) ;
if ( Func . isNotEmpty ( retentionScanEntityList ) ) {
if ( Func . isNotEmpty ( retentionScanEntityList ) ) {
warehouseRetentionRecordVO . setRetentionScanVOList ( WarehouseRetentionScanWrapper . build ( ) . listVO ( retentionScanEntityList ) ) ;
}
return warehouseRetentionRecordVO ;
@ -165,13 +157,13 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
@Transactional
public R saveRetentionList ( WarehouseRetentionRecordDTO warehouseRetentionRecordDTO ) {
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient . getMyCurrentWarehouse ( ) ;
if ( Func . isEmpty ( myCurrentWarehouse ) ) {
if ( Func . isEmpty ( myCurrentWarehouse ) ) {
return null ;
}
List < WarehouseRetentionScanDTO > warehouseRetentionScanDTOS = warehouseRetentionRecordDTO . getWarehouseRetentionScanDTOS ( ) ;
if ( Func . isEmpty ( warehouseRetentionScanDTOS ) ) {
if ( Func . isEmpty ( warehouseRetentionScanDTOS ) ) {
log . error ( "############用户提交空滞留列表" ) ;
return Resp . scanFail ( "操作失败" , "无滞留包件信息" ) ;
return Resp . scanFail ( "操作失败" , "无滞留包件信息" ) ;
}
BladeUser user = AuthUtil . getUser ( ) ;
//TODO 保存车次数据还需要处理
@ -187,7 +179,8 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
warehouseRetentionRecordEntity . setRetentionCreateUserName ( user . getUserName ( ) ) ;
this . save ( warehouseRetentionRecordEntity ) ;
AtomicInteger retentionTotal = new AtomicInteger ( ) ;
warehouseRetentionScanDTOS . forEach ( r - > {
AtomicBoolean saveFlah = new AtomicBoolean ( false ) ;
warehouseRetentionScanDTOS . forEach ( r - > {
//查询是否进行多次滞留
WarehouseRetentionScanEntity retentionScanServiceOne = warehouseRetentionScanService . getOne ( Wrappers . < WarehouseRetentionScanEntity > query ( ) . lambda ( )
. eq ( WarehouseRetentionScanEntity : : getConditions , r . getConditions ( ) )
@ -199,30 +192,44 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
. ne ( WarehouseRetentionScanEntity : : getCancelRetentionStatus , IsOrNoConstant . no . getValue ( ) )
) ;
//避免重复添加相同的滞留包件数据
if ( Func . isEmpty ( retentionScanServiceOne ) ) {
if ( Func . isEmpty ( retentionScanServiceOne ) ) {
r . setRetentionScanTime ( new Date ( ) ) ;
r . setRetentionScanUserId ( user . getUserId ( ) ) ;
r . setRetentionScanUsername ( user . getNickName ( ) ) ;
r . setRetentionQuantity ( r . getRetentionQuantity ( ) ) ;
retentionTotal . getAndAdd ( r . getRetentionQuantity ( ) ) ;
r . setDeliveryId ( warehouseRetentionRecordDTO . getDeliveryId ( ) ) ;
r . setRefId ( warehouseRetentionRecordEntity . getId ( ) ) ;
warehouseRetentionScanService . save ( Func . copy ( r , WarehouseRetentionScanEntity . class ) ) ;
warehouseRetentionScanService . save ( Func . copy ( r , WarehouseRetentionScanEntity . class ) ) ;
//进行滞留之后需要对包件进行取消配送的操作
if ( r . getConditions ( ) . equals ( 3 ) ) {
//零担滞留
} else {
//包件滞留
distributionDeliveryListClient . retentionDeliveryReservationPackage ( r . getDeliveryId ( ) , r . getReservationId ( ) , r . getOrderPackageId ( ) , r . getConditions ( ) ) ;
Integer conditions = r . getConditions ( ) ;
switch ( conditions ) {
case 1 :
//订制品
saveFlah . set ( distributionDeliveryListClient . retentionDeliveryReservationPackage ( r . getDeliveryId ( ) , r . getReservationId ( ) , r . getOrderPackageId ( ) , r . getConditions ( ) ) ) ;
break ;
case 2 :
//库存品
saveFlah . set ( distributionDeliveryListClient . retentionDeliveryReservationInventory ( r . getDeliveryId ( ) , r . getReservationId ( ) , r . getOrderPackageId ( ) ) ) ;
break ;
case 3 :
//零担
saveFlah . set ( distributionDeliveryListClient . retentionDeliveryReservationZeroPackage ( r . getDeliveryId ( ) , r . getReservationId ( ) , r . getOrderPackageId ( ) , r . getRetentionQuantity ( ) , r . getOrderId ( ) ) ) ;
break ;
}
}
//进行滞留操作的包件需要和原来订单 预约进行绑定解除
//TODO 需要一个取消配送包件的方法
// reservationClient.retentionCancelReservationPack();
} ) ;
warehouseRetentionRecordEntity . setRetentionQuantity ( retentionTotal . get ( ) ) ;
this . updateById ( warehouseRetentionRecordEntity ) ;
return Resp . scanSuccess ( "操作成功" , "操作成功" ) ;
if ( saveFlah . get ( ) ) {
warehouseRetentionRecordEntity . setRetentionQuantity ( retentionTotal . get ( ) ) ;
this . updateById ( warehouseRetentionRecordEntity ) ;
return Resp . scanSuccess ( "操作成功" , "操作成功" ) ;
} else {
throw new RuntimeException ( "服务器正忙..." ) ;
}
}
@Override
@ -230,13 +237,13 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
// 获取当前登录的仓库信息
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient . getMyCurrentWarehouse ( ) ;
if ( ObjectUtils . isNull ( myCurrentWarehouse ) ) {
if ( ObjectUtils . isNull ( myCurrentWarehouse ) ) {
throw new ServiceException ( "没有仓库信息!" ) ;
}
// 用户勾选数据的ids
Object ids = paramMap . get ( "ids" ) ;
List < String > idArr = null ;
if ( null ! = ids & & ! ids . toString ( ) . equals ( "" ) ) {
if ( null ! = ids & & ! ids . toString ( ) . equals ( "" ) ) {
idArr = Arrays . asList ( paramMap . get ( "ids" ) . toString ( ) . split ( "," ) ) ;
}
@ -254,13 +261,13 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
public R updateRetentionList ( WarehouseRetentionRecordDTO warehouseRetentionScanDTOS ) {
// 获取当前登录的仓库信息
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient . getMyCurrentWarehouse ( ) ;
if ( ObjectUtils . isNull ( myCurrentWarehouse ) ) {
return R . fail ( 403 , "无仓库信息" ) ;
if ( ObjectUtils . isNull ( myCurrentWarehouse ) ) {
return R . fail ( 403 , "无仓库信息" ) ;
}
List < WarehouseRetentionScanDTO > warehouseRetentionScanDTOList = warehouseRetentionScanDTOS . getWarehouseRetentionScanDTOS ( ) ;
if ( Func . isEmpty ( warehouseRetentionScanDTOList ) ) {
log . error ( "##########缺少滞留包件列表:{}" , warehouseRetentionScanDTOList ) ;
return Resp . scanFail ( "无滞留包件信息" , "无滞留包件信息" ) ;
if ( Func . isEmpty ( warehouseRetentionScanDTOList ) ) {
log . error ( "##########缺少滞留包件列表:{}" , warehouseRetentionScanDTOList ) ;
return Resp . scanFail ( "无滞留包件信息" , "无滞留包件信息" ) ;
}
//如果滞留全部为空,这里执行删除操作
//查询出该滞留任务是否存在
@ -268,21 +275,21 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
. eq ( WarehouseRetentionScanEntity : : getDeliveryId , warehouseRetentionScanDTOS . getDeliveryId ( ) )
. eq ( WarehouseRetentionScanEntity : : getRefId , warehouseRetentionScanDTOS . getId ( ) ) ) ;
WarehouseRetentionRecordEntity retentionRecordEntity = this . getById ( warehouseRetentionScanDTOS . getId ( ) ) ;
if ( Func . isNotEmpty ( retentionScanEntityList ) ) {
if ( Func . isNotEmpty ( retentionScanEntityList ) ) {
BladeUser user = AuthUtil . getUser ( ) ;
Map < Long , WarehouseRetentionScanEntity > retentionPackageMap = retentionScanEntityList . stream ( ) . collect ( Collectors . toMap ( WarehouseRetentionScanEntity : : getOrderPackageId , Function . identity ( ) , ( k1 , k2 ) - > k2 ) ) ;
warehouseRetentionScanDTOList . forEach ( rs - > {
if ( Func . isNotEmpty ( retentionPackageMap . get ( rs . getOrderPackageId ( ) ) ) ) {
warehouseRetentionScanDTOList . forEach ( rs - > {
if ( Func . isNotEmpty ( retentionPackageMap . get ( rs . getOrderPackageId ( ) ) ) ) {
//查看是否是零担,如果是零担需要查看是否发生数量修改
WarehouseRetentionScanEntity warehouseRetentionScanEntity = retentionPackageMap . get ( rs . getOrderPackageId ( ) ) ;
if ( retentionPackageMap . get ( rs . getOrderPackageId ( ) ) . getConditions ( ) = = 3 ) {
if ( retentionPackageMap . get ( rs . getOrderPackageId ( ) ) . getConditions ( ) = = 3 ) {
//零担查看是否发生数据修改
if ( warehouseRetentionScanEntity . getRetentionQuantity ( ) ! = rs . getRetentionQuantity ( ) & & rs . getRetentionQuantity ( ) > 0 ) {
if ( warehouseRetentionScanEntity . getRetentionQuantity ( ) ! = rs . getRetentionQuantity ( ) & & rs . getRetentionQuantity ( ) > 0 ) {
warehouseRetentionScanEntity . setRetentionQuantity ( rs . getRetentionQuantity ( ) ) ;
warehouseRetentionScanService . updateById ( warehouseRetentionScanEntity ) ;
}
}
} else {
} else {
//在原列表中查询不到,这里视为新增滞留包件
rs . setRetentionScanTime ( new Date ( ) ) ;
rs . setRetentionScanUserId ( user . getUserId ( ) ) ;
@ -291,8 +298,21 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
// retentionTotal.getAndAdd(r.getRetentionQuantity());
rs . setDeliveryId ( warehouseRetentionScanDTOS . getDeliveryId ( ) ) ;
rs . setRefId ( retentionRecordEntity . getId ( ) ) ;
warehouseRetentionScanService . save ( Func . copy ( rs , WarehouseRetentionScanEntity . class ) ) ;
distributionDeliveryListClient . retentionDeliveryReservationPackage ( rs . getDeliveryId ( ) , rs . getReservationId ( ) , rs . getOrderPackageId ( ) , rs . getConditions ( ) ) ;
warehouseRetentionScanService . save ( Func . copy ( rs , WarehouseRetentionScanEntity . class ) ) ;
switch ( rs . getConditions ( ) ) {
case 1 :
//订制品
distributionDeliveryListClient . retentionDeliveryReservationPackage ( rs . getDeliveryId ( ) , rs . getReservationId ( ) , rs . getOrderPackageId ( ) , rs . getConditions ( ) ) ;
break ;
case 2 :
//库存品
distributionDeliveryListClient . retentionDeliveryReservationInventory ( rs . getDeliveryId ( ) , rs . getReservationId ( ) , rs . getOrderPackageId ( ) ) ;
break ;
case 3 :
//零担
// distributionDeliveryListClient.retentionDeliveryReservationZeroPackage(rs.getDeliveryId(), rs.getReservationId(), rs.getOrderPackageId(),rs.getRetentionQuantity());
break ;
}
}
} ) ;
}
@ -302,7 +322,7 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl<Warehou
. eq ( WarehouseRetentionScanEntity : : getRefId , warehouseRetentionScanDTOS . getId ( ) ) ) . stream ( ) . mapToInt ( WarehouseRetentionScanEntity : : getRetentionQuantity ) . sum ( ) ;
retentionRecordEntity . setRetentionQuantity ( retentionTotal ) ;
this . updateById ( retentionRecordEntity ) ;
return Resp . scanSuccess ( "操作成功" , "操作成功" ) ;
return Resp . scanSuccess ( "操作成功" , "操作成功" ) ;
}
@Override