@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity ;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient ;
import com.logpm.distribution.dto.DistributionLoadingNumDTO ;
import com.logpm.distribution.dto.DistributionStockArticleDTO ;
import com.logpm.distribution.dto.app.DistrilbutionloadingscanDTO ;
import com.logpm.distribution.dto.app.StockupDTO ;
@ -358,112 +359,47 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService {
@Async
@Override
@Transactional ( isolation = Isolation . READ_UNCOMMITTED , rollbackFor = Exception . class )
public void changeMarketDeliveryListStatus ( String barcode , Long deliveryId ) {
//修改包件状态
//这里需要查询出该包件
DistributionParcelListEntity parcelListEntity = distributionDeliveryListMapper . getLoadingPackageDetails ( barcode , deliveryId ) ;
if ( Func . isNotEmpty ( parcelListEntity ) ) {
parcelListEntity . setOrderPackageLoadingStatus ( OrderPackageLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
parcelListEntity . setOrderPackageStatus ( OrderPackageStatusConstant . yichuku . getValue ( ) ) ;
//修改包件状态
distributionParcelListService . updateById ( parcelListEntity ) ;
List < DistributionParcelListEntity > parcelListEntityList = distributionParcelListService . getBaseMapper ( ) . selectList ( Wrappers . < DistributionParcelListEntity > query ( ) . lambda ( ) . eq ( DistributionParcelListEntity : : getStockArticleId , parcelListEntity . getStockArticleId ( ) ) ) ;
boolean flag = parcelListEntityList . stream ( ) . allMatch ( p - > p . getOrderPackageLoadingStatus ( ) . equals ( OrderPackageLoadingStatusConstant . yizhuangche . getValue ( ) ) ) ;
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService . getById ( parcelListEntity . getStockArticleId ( ) ) ;
//维护包件、订单扫描装车状态
if ( flag ) {
stockArticleEntity . setOrderStatus ( OrderStatusConstant . chuku . getValue ( ) ) ;
} else {
flag = parcelListEntityList . stream ( ) . allMatch ( p - > p . getOrderPackageLoadingStatus ( ) . equals ( OrderPackageLoadingStatusConstant . weizhuancghe . getValue ( ) ) ) ;
if ( flag ) {
stockArticleEntity . setOrderStatus ( OrderStatusConstant . ruku . getValue ( ) ) ;
} else {
stockArticleEntity . setOrderStatus ( OrderStatusConstant . bufenchuku . getValue ( ) ) ;
}
}
distributionStockArticleService . updateById ( stockArticleEntity ) ;
} else {
//查询库存品
DisStockListDetailEntity loadingInventoryDetail = distributionDeliveryListMapper . getLoadingInventoryDetail ( barcode , deliveryId ) ;
loadingInventoryDetail . setStockLockingStatus ( InventoryLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
disStockListDetailService . updateById ( loadingInventoryDetail ) ;
public void changeMarketDeliveryListStatus ( String barcode , Long deliveryId , Long reservationId ) {
//查询库存品
DisStockListDetailEntity loadingInventoryDetail = distributionDeliveryListMapper . getLoadingInventoryDetail ( barcode , deliveryId ) ;
loadingInventoryDetail . setStockLockingStatus ( InventoryLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
disStockListDetailService . updateById ( loadingInventoryDetail ) ;
// DistributionStockListEntity stockListEntity = distributionStockListMapper.selectOne(Wrappers.<DistributionStockListEntity>query().lambda().eq(DistributionStockListEntity::getId, loadingInventoryDetail.getStockListId()));
// stockListEntity.setQuantityStock(stockListEntity.getQuantityStock() - loadingInventoryDetail.getNum());
// stockListEntity.setQuantityOccupied(stockListEntity.getQuantityOccupied() - loadingInventoryDetail.getNum());
// stockListEntity.setOutboundQuantity(stockListEntity.getOutboundQuantity() + loadingInventoryDetail.getNum());
// distributionStockListMapper.updateById(stockListEntity);
//查询出这个库存品的所有需要装车的包件维度库存品
List < DisStockListDetailEntity > list = disStockListDetailService . list ( Wrappers . < DisStockListDetailEntity > query ( ) . lambda ( )
. eq ( DisStockListDetailEntity : : getReservationId , loadingInventoryDetail . getReservationId ( ) )
. eq ( DisStockListDetailEntity : : getStockListId , loadingInventoryDetail . getStockListId ( ) )
. ne ( DisStockListDetailEntity : : getStockPackageStatus , InventoryPackageStatusConstant . quxiao . getValue ( ) ) ) ;
boolean inventoryFlag = list . stream ( ) . allMatch ( l - > l . getStockLockingStatus ( ) . equals ( InventoryLoadingStatusConstant . yizhuangche . getValue ( ) ) ) ;
List < DistributionReservationStocklistEntity > reservationStockarticleEntityList = distributionReservationStocklistMapper . selectList ( Wrappers . < DistributionReservationStocklistEntity > query ( ) . lambda ( )
. eq ( DistributionReservationStocklistEntity : : getReservationId , loadingInventoryDetail . getReservationId ( ) )
. eq ( DistributionReservationStocklistEntity : : getStocklistId , loadingInventoryDetail . getStockListId ( ) )
. ne ( DistributionReservationStocklistEntity : : getStockListStatus , ReservationInventoryStatusConstant . quxiao . getValue ( ) ) ) ;
if ( reservationStockarticleEntityList . size ( ) = = 1 ) {
//修改状态
DistributionReservationStocklistEntity reservationStockarticleEntity = reservationStockarticleEntityList . get ( 0 ) ;
if ( inventoryFlag ) {
//查询出库存品进行全部状态的变更
reservationStockarticleEntity . setLoadingStatus ( ReservationInventoryLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
} else {
inventoryFlag = list . stream ( ) . allMatch ( l - > l . getStockLockingStatus ( ) . equals ( InventoryLoadingStatusConstant . weizhuangche . getValue ( ) ) ) ;
if ( inventoryFlag ) {
reservationStockarticleEntity . setLoadingStatus ( ReservationInventoryLoadingStatusConstant . weizhuangche . getValue ( ) ) ;
} else {
reservationStockarticleEntity . setLoadingStatus ( ReservationInventoryLoadingStatusConstant . bufenzhuangche . getValue ( ) ) ;
}
}
distributionReservationStocklistMapper . updateById ( reservationStockarticleEntity ) ;
} else {
log . error ( "####库存品记录错误+{" + reservationStockarticleEntityList + "}" ) ;
return ;
}
}
//查询出这个预约下的包件信息和库存品信息分别进行判断是否都完成装车
List < DistributionReservationEntity > reservationEntityList = distributionDeliveryListMapper . selectReservationByDeliveryListId ( deliveryId ) ;
reservationEntityList . forEach ( r - > {
//查询预约下的所有包件信息
List < DistributionParcelListEntity > parcelListEntities = distributionReservationMapper . selectPackageListByReservationId ( r . getId ( ) ) ;
boolean reservationLoadingFlag = parcelListEntities . stream ( ) . allMatch ( p - > p . getOrderPackageLoadingStatus ( ) . equals ( InventoryLoadingStatusConstant . yizhuangche . getValue ( ) ) ) ;
List < DistributionReservationStocklistEntity > distributionReservationStocklistEntities = distributionReservationStocklistMapper . selectList ( Wrappers . < DistributionReservationStocklistEntity > query ( ) . lambda ( )
. eq ( DistributionReservationStocklistEntity : : getReservationId , r . getId ( ) )
. ne ( DistributionReservationStocklistEntity : : getStockListStatus , ReservationInventoryStatusConstant . quxiao . getValue ( ) ) ) ;
boolean inventoryLoadingFlag = distributionReservationStocklistEntities . stream ( ) . allMatch ( i - > i . getLoadingStatus ( ) . equals ( ReservationInventoryLoadingStatusConstant . yizhuangche . getValue ( ) ) ) ;
if ( reservationLoadingFlag & & inventoryLoadingFlag ) {
r . setLoadingStatus ( ReservationLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
//查询出这个库存品的所有需要装车的包件维度库存品
List < DisStockListDetailEntity > list = disStockListDetailService . list ( Wrappers . < DisStockListDetailEntity > query ( ) . lambda ( )
. eq ( DisStockListDetailEntity : : getReservationId , loadingInventoryDetail . getReservationId ( ) )
. eq ( DisStockListDetailEntity : : getStockListId , loadingInventoryDetail . getStockListId ( ) )
. ne ( DisStockListDetailEntity : : getStockPackageStatus , InventoryPackageStatusConstant . quxiao . getValue ( ) ) ) ;
boolean inventoryFlag = list . stream ( ) . allMatch ( l - > l . getStockLockingStatus ( ) . equals ( InventoryLoadingStatusConstant . yizhuangche . getValue ( ) ) ) ;
List < DistributionReservationStocklistEntity > reservationStockarticleEntityList = distributionReservationStocklistMapper . selectList ( Wrappers . < DistributionReservationStocklistEntity > query ( ) . lambda ( )
. eq ( DistributionReservationStocklistEntity : : getReservationId , loadingInventoryDetail . getReservationId ( ) )
. eq ( DistributionReservationStocklistEntity : : getStocklistId , loadingInventoryDetail . getStockListId ( ) )
. ne ( DistributionReservationStocklistEntity : : getStockListStatus , ReservationInventoryStatusConstant . quxiao . getValue ( ) ) ) ;
if ( reservationStockarticleEntityList . size ( ) = = 1 ) {
//修改状态
DistributionReservationStocklistEntity reservationStockarticleEntity = reservationStockarticleEntityList . get ( 0 ) ;
if ( inventoryFlag ) {
//查询出库存品进行全部状态的变更
reservationStockarticleEntity . setLoadingStatus ( ReservationInventoryLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
} else {
reservationLoadingFlag = parcelListEntities . stream ( ) . allMatch ( p - > p . getOrderPackageLoadingStatus ( ) . equals ( OrderPackageLoadingStatusConstant . weizhuancghe . getValue ( ) ) ) ;
inventoryLoadingFlag = distributionReservationStocklistEntities . stream ( ) . allMatch ( i - > i . getLoadingStatus ( ) . equals ( ReservationInventoryLoadingStatusConstant . weizhuangche . getValue ( ) ) ) ;
if ( reservationLoadingFlag & & inventoryLoadingFlag ) {
r . setLoadingStatus ( ReservationLoadingStatusConstant . daizhuangche . getValue ( ) ) ;
inventoryFlag = list . stream ( ) . allMatch ( l - > l . getStockLockingStatus ( ) . equals ( InventoryLoadingStatusConstant . weizhuangche . getValue ( ) ) ) ;
if ( inventoryFlag ) {
reservationStockarticleEntity . setLoadingStatus ( ReservationInventoryLoadingStatusConstant . weizhuangche . getValue ( ) ) ;
} else {
r . setLoadingStatus ( ReservationLoadingStatusConstant . bufenzhuangche . getValue ( ) ) ;
reservationStockarticleEntity . setLoadingStatus ( ReservationInventoryLoadingStatusConstant . bufenzhuangche . getValue ( ) ) ;
}
}
distributionReservationMapper . updateById ( r ) ;
} ) ;
List < DistributionParcelListEntity > deliveryParcelListEntityList = distributionDeliveryListMapper . selectPackageListByDeliveryListId ( deliveryId ) ;
List < DisStockListDetailEntity > detailEntities = distributionDeliveryListMapper . selectInventoryListByDeliveryListId ( deliveryId ) ;
boolean deliveryLoadingFlag = deliveryParcelListEntityList . stream ( ) . allMatch ( p - > p . getOrderPackageLoadingStatus ( ) . equals ( OrderPackageLoadingStatusConstant . yizhuangche . getValue ( ) ) ) ;
boolean deliveryInventoryLoadingFlag = detailEntities . stream ( ) . allMatch ( i - > i . getStockLockingStatus ( ) . equals ( ReservationInventoryLoadingStatusConstant . yizhuangche . getValue ( ) ) ) ;
DistributionDeliveryListEntity deliveryListEntity = distributionDeliveryListMapper . selectOne ( Wrappers . < DistributionDeliveryListEntity > query ( ) . lambda ( ) . eq ( DistributionDeliveryListEntity : : getId , deliveryId ) ) ;
if ( deliveryLoadingFlag & & deliveryInventoryLoadingFlag ) {
deliveryListEntity . setDeliveryListLoadingStatus ( DeliveryLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
distributionReservationStocklistMapper . updateById ( reservationStockarticleEntity ) ;
} else {
deliveryLoadingFlag = deliveryParcelListEntityList . stream ( ) . allMatch ( p - > p . getOrderPackageLoadingStatus ( ) . equals ( OrderPackageLoadingStatusConstant . weizhuancghe . getValue ( ) ) ) ;
deliveryInventoryLoadingFlag = detailEntities . stream ( ) . allMatch ( i - > i . getStockLockingStatus ( ) . equals ( ReservationInventoryLoadingStatusConstant . weizhuangche . getValue ( ) ) ) ;
if ( deliveryLoadingFlag & & deliveryInventoryLoadingFlag ) {
deliveryListEntity . setDeliveryListLoadingStatus ( DeliveryLoadingStatusConstant . weizhuangche . getValue ( ) ) ;
} else {
deliveryListEntity . setDeliveryListLoadingStatus ( DeliveryLoadingStatusConstant . bunfenzhuangche . getValue ( ) ) ;
}
log . error ( "####库存品记录错误+{" + reservationStockarticleEntityList + "}" ) ;
return ;
}
distributionDeliveryListMapper . updateById ( deliveryListEntity ) ;
checkReservationAndDeliveryLoadingStatus ( deliveryId , reservationId ) ;
}
@Async
@ -730,14 +666,71 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService {
throw new RuntimeException ( "包件信息异常" ) ;
}
//维护包件所属订单是否均已完成装车,如果均已完成装车则订单进行装车状态的修改
switch ( parcelListEntity . getConditions ( ) ) {
case 1 :
break ;
if ( parcelListEntity . getConditions ( ) ! = 2 ) {
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService . getById ( parcelListEntity . getStockArticleId ( ) ) ;
//查询出该订单的装车件数
Integer orderLoadingNum = distributionLoadscanMapper . selectOrderLoadingNum ( stockArticleEntity . getId ( ) ) ;
if ( Func . isNotEmpty ( orderLoadingNum ) & & orderLoadingNum > 0 ) {
//存在装车数量,需要对装车数量进行判定
if ( orderLoadingNum = = stockArticleEntity . getTotalNumber ( ) ) {
stockArticleEntity . setOrderStatus ( OrderStatusConstant . chuku . getValue ( ) ) ;
} else {
stockArticleEntity . setOrderStatus ( OrderStatusConstant . bufenchuku . getValue ( ) ) ;
}
distributionStockArticleService . updateById ( stockArticleEntity ) ;
}
}
case 3 :
break ;
checkReservationAndDeliveryLoadingStatus ( deliveryId , reservationId ) ;
}
@Transactional ( rollbackFor = Exception . class )
private void checkReservationAndDeliveryLoadingStatus ( Long deliveryId , Long reservationId ) {
//判断客户是否完成装车
DistributionReservationEntity distributionReservationEntity = distributionReservationMapper . selectById ( reservationId ) ;
int reservationPackageTotal = distributionReservationEntity . getReservationNum ( ) + distributionReservationEntity . getReservationStockListNum ( ) ;
if ( reservationPackageTotal ! = 0 ) {
DistributionLoadingNumDTO reservationLoadingNum = distributionReservationMapper . selectReservationLoadingNum ( distributionReservationEntity . getId ( ) ) ;
if ( Func . isNotEmpty ( reservationLoadingNum ) ) {
int reservationLoadingQuantity = reservationLoadingNum . getPackageLoadingQuantity ( ) + reservationLoadingNum . getInventoryLoadingQuantity ( ) ;
if ( reservationLoadingQuantity = = reservationPackageTotal ) {
distributionReservationEntity . setLoadingStatus ( ReservationLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
} else {
distributionReservationEntity . setLoadingStatus ( ReservationLoadingStatusConstant . bufenzhuangche . getValue ( ) ) ;
}
distributionReservationMapper . updateById ( distributionReservationEntity ) ;
}
} else {
log . error ( "##########查询客户配送数量为0" ) ;
}
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService . getById ( parcelListEntity . getStockArticleId ( ) ) ;
DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper . selectById ( deliveryId ) ;
int deliveryPackageTotal = distributionDeliveryListEntity . getDeliveryNumber ( ) ;
if ( deliveryPackageTotal ! = 0 ) {
DistributionLoadingNumDTO deliveryLoadingNum = distributionDeliveryListMapper . selectDeliveryLoadingNum ( distributionDeliveryListEntity . getId ( ) ) ;
if ( Func . isNotEmpty ( deliveryLoadingNum ) ) {
int deliveryLoadingQuantity = deliveryLoadingNum . getPackageLoadingQuantity ( ) + deliveryLoadingNum . getInventoryLoadingQuantity ( ) ;
if ( deliveryPackageTotal = = deliveryLoadingQuantity ) {
distributionReservationEntity . setLoadingStatus ( DeliveryLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
} else {
distributionReservationEntity . setLoadingStatus ( DeliveryLoadingStatusConstant . bunfenzhuangche . getValue ( ) ) ;
}
distributionDeliveryListMapper . updateById ( distributionDeliveryListEntity ) ;
}
} else {
log . error ( "##########查询客户配送数量为0" ) ;
}
}
// switch (parcelListEntity.getConditions()){
// case 1:
//
// break;
// case 3:
//
// break;
// }
// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelListEntity.getStockArticleId());
// //首先能够进入这个检测方法那么此包件就是进行装车了,这里对包件装车状态再次进行维护
@ -806,7 +799,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService {
}
// }
@Override
@ -1056,12 +1049,11 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService {
}
}
distributionStockArticleService . updateById ( stockArticleEntity ) ;
}
@Override
@Transactional
public void checkZeroStockArticleLoadingStatus ( DistributionParcelNumberEntity parcelNumberEntity ) {
public void checkZeroStockArticleLoadingStatus ( DistributionParcelNumberEntity parcelNumberEntity , Long deliveryId , Long reservationId ) {
if ( Func . isEmpty ( parcelNumberEntity ) ) {
log . error ( "#################parcelNumberEntity参数错误:{}" , parcelNumberEntity ) ;
return ;
@ -1102,6 +1094,80 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService {
stockArticleEntity . setDeliveryQuantity ( stockArticleEntity . getDeliveryQuantity ( ) + outboundQuantity ) ;
}
distributionStockArticleService . updateById ( stockArticleEntity ) ;
//维护预约客户和配送任务装车状态
checkReservationAndDeliveryLoadingStatus ( deliveryId , reservationId ) ;
}
@Override
public void checkSignStatus ( Long packageId , Long reservationId , Long deliveryId ) {
if ( Func . isNotEmpty ( packageId ) ) {
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( packageId ) ;
//维护包件所属订单签收状态
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService . getById ( parcelListEntity . getStockArticleId ( ) ) ;
//维护该订单的签收状态
if ( Func . isNotEmpty ( stockArticleEntity ) ) {
Integer totalNumber = stockArticleEntity . getTotalNumber ( ) ;
Integer orderSignNum = distributionLoadscanMapper . selectOrderSignNum ( stockArticleEntity . getId ( ) ) ;
Integer orderLoadingNum = distributionLoadscanMapper . selectOrderLoadingNum ( stockArticleEntity . getId ( ) ) ;
if ( Func . isNotEmpty ( orderSignNum ) & & orderSignNum > 0 ) {
if ( totalNumber = = orderSignNum ) {
stockArticleEntity . setOrderStatus ( OrderStatusConstant . qianshou . getValue ( ) ) ;
} else {
stockArticleEntity . setOrderStatus ( OrderStatusConstant . bufenqianshou . getValue ( ) ) ;
}
}
distributionStockArticleService . updateById ( stockArticleEntity ) ;
}
}
checkReservationAndDeliveryLoadingStatus ( deliveryId , reservationId ) ;
checkReservationAndDeliverySigningStatus ( reservationId , deliveryId ) ;
//注意:这里对于异常装车的包件也需要进行统计
}
@Transactional
private void checkReservationAndDeliverySigningStatus ( Long reservationId , Long deliveryId ) {
//维护客户签收状态
DistributionReservationEntity distributionReservationEntity = distributionReservationMapper . selectById ( reservationId ) ;
if ( Func . isNotEmpty ( distributionReservationEntity ) ) {
int reservationTotal = distributionReservationEntity . getReservationNum ( ) + distributionReservationEntity . getReservationStockListNum ( ) ;
//查询该客户的签收数量
DistributionLoadingNumDTO reservationSigningNum = distributionReservationMapper . selectReservationSigningNum ( distributionReservationEntity . getId ( ) ) ;
if ( Func . isNotEmpty ( reservationSigningNum ) ) {
int reservationSigningQuantity = reservationSigningNum . getPackageSigningQuantity ( ) + reservationSigningNum . getInventorySigningQuantity ( ) ;
if ( reservationSigningQuantity > 0 ) {
if ( reservationTotal = = reservationSigningQuantity ) {
distributionReservationEntity . setSigningStatus ( ReservationSigningStatusConstant . yiqianshou . getValue ( ) ) ;
} else {
distributionReservationEntity . setSigningStatus ( ReservationSigningStatusConstant . bufenqianshou . getValue ( ) ) ;
}
distributionReservationMapper . updateById ( distributionReservationEntity ) ;
}
}
}
//维护配送任务签收状态
DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper . selectById ( deliveryId ) ;
if ( Func . isNotEmpty ( distributionDeliveryListEntity ) ) {
Integer deliverySigningTotal = distributionDeliveryListEntity . getDeliveryNumber ( ) ;
DistributionLoadingNumDTO deliverySigningNum = distributionDeliveryListMapper . selectDeliverySigningNum ( distributionReservationEntity . getId ( ) ) ;
if ( Func . isNotEmpty ( deliverySigningNum ) ) {
int deliverySigningQuantity = deliverySigningNum . getPackageSigningQuantity ( ) + deliverySigningNum . getInventorySigningQuantity ( ) ;
if ( deliverySigningQuantity > 0 ) {
if ( deliverySigningTotal = = deliverySigningQuantity ) {
distributionDeliveryListEntity . setDeliveryStatus ( DeliveryStatusConstant . yiwancheng . getValue ( ) ) ;
} else {
distributionDeliveryListEntity . setDeliveryStatus ( DeliveryStatusConstant . peisongzhong . getValue ( ) ) ;
}
distributionReservationMapper . updateById ( distributionReservationEntity ) ;
}
}
}
}