@ -30,11 +30,14 @@ import com.logpm.distribution.mapper.*;
import com.logpm.distribution.service.* ;
import com.logpm.distribution.vo.* ;
import com.logpm.distribution.wrapper.DistributionParcelListWrapper ;
import com.logpm.distribution.wrapper.DistributionStockArticleWrapper ;
import com.logpm.distribution.wrapper.DistributionStockListWrapper ;
import org.springblade.common.constant.DistributionTypeConstant ;
import org.springblade.common.constant.delivery.DeliveryStatusConstant ;
import org.springblade.common.constant.order.OrderReservationStatusConstant ;
import org.springblade.common.constant.orderpackage.OrderPackageFreezeStatusConstant ;
import org.springblade.common.constant.orderpackage.OrderPackageReservationStatusConstant ;
import org.springblade.common.constant.orderpackage.OrderPackageStatusConstant ;
import org.springblade.common.constant.orderpackage.OrderPackageStockupStatusConstant ;
import org.springblade.common.constant.reservation.* ;
import org.springblade.common.constant.signing.SignforStatusConstant ;
@ -508,23 +511,23 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
//查询根据预约ID查询这些预约的备货状态
List < DistributionReservationEntity > reservationEntityList = baseMapper . selectList ( Wrappers . < DistributionReservationEntity > query ( ) . lambda ( ) . in ( DistributionReservationEntity : : getId , ids ) ) ;
boolean flag = reservationEntityList . stream ( ) . anyMatch ( s - > s . getStockupStatus ( ) . equals ( ReservationStockupStatusConstant . weibeihuo . getValue ( ) ) ) ;
if ( flag ) {
if ( Func . isNotEmpty ( stockup . getLoaderName ( ) ) ) {
if ( flag ) {
if ( Func . isNotEmpty ( stockup . getLoaderName ( ) ) ) {
distributionStockupEntity . setLoaderName ( stockup . getLoaderName ( ) ) ;
distributionStockupEntity . setLoaderId ( stockup . getLoaderId ( ) ) ;
}
if ( Func . isNotEmpty ( stockup . getGoodsAreaName ( ) ) ) {
if ( Func . isNotEmpty ( stockup . getGoodsAreaName ( ) ) ) {
distributionStockupEntity . setStockupArea ( stockup . getGoodsAreaName ( ) ) ;
distributionStockupEntity . setGoodsAreaId ( stockup . getGoodsAreaId ( ) ) ;
}
if ( Func . isNotEmpty ( stockup . getGoodsAreaName ( ) ) ) {
if ( Func . isNotEmpty ( stockup . getGoodsAreaName ( ) ) ) {
distributionStockupEntity . setStockupArea ( stockup . getGoodsAreaName ( ) ) ;
distributionStockupEntity . setGoodsAreaId ( stockup . getGoodsAreaId ( ) ) ;
}
if ( Func . isNotEmpty ( stockup . getLoadAndUnload ( ) ) ) {
if ( Func . isNotEmpty ( stockup . getLoadAndUnload ( ) ) ) {
distributionStockupEntity . setTeamResponsibility ( stockup . getLoadAndUnload ( ) ) ;
}
if ( Func . isNotEmpty ( stockup . getOutboundDate ( ) ) ) {
if ( Func . isNotEmpty ( stockup . getOutboundDate ( ) ) ) {
distributionStockupEntity . setOutboundDate ( stockup . getOutboundDate ( ) ) ;
}
BladeUser user = AuthUtil . getUser ( ) ;
@ -535,7 +538,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
}
for ( int i = 0 ; i < ids . size ( ) ; i + + ) {
DistributionReservationEntity reservationEntity = this . getById ( ids . get ( i ) ) ;
if ( Func . equals ( reservationEntity . getStockupStatus ( ) , ReservationStockupStatusConstant . weibeihuo . getValue ( ) ) ) {
if ( Func . equals ( reservationEntity . getStockupStatus ( ) , ReservationStockupStatusConstant . weibeihuo . getValue ( ) ) ) {
//如果预约已经备货
DistributionStockupInfoEntity stockupInfoEntity = new DistributionStockupInfoEntity ( ) ;
stockupInfoEntity . setReservationId ( ids . get ( i ) ) ;
@ -699,24 +702,15 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
List < DistributionStockArticleVO > distrinbutionStockArticleVOS = distributionStockArticleMapper . getStockArticleByReservationId ( reservationEntity . getId ( ) ) ;
distrinbutionStockArticleVOS . forEach ( s - > {
//这里查询两个东西,一个是该订单在预约中所被选取的包件信息,以及该订单下所有的包件列表
Page < DistributionParcelListEntity > pageVOList = distributionParcelListMapper . getPageVOList ( new Page < > ( ) , s . getId ( ) ) ;
s . setParcelListVOS ( DistributionParcelListWrapper . build ( ) . page VO( pageVOList ) . getRecords ( ) ) ;
List < DistributionParcelListEntity > pageVOList = distributionParcelListMapper . getPageVOList ( s . getId ( ) ) ;
s . setParcelListVOS ( DistributionParcelListWrapper . build ( ) . list VO( pageVOList ) ) ;
//这里查询出该订单下已经被选取的包件信息
Page < DistributionParcelListEntity > packageVOList = distributionReservationPackageMapper . selectPackageVOList ( new Page < > ( ) , reservationEntity . getId ( ) , s . getId ( ) ) ;
s . setPackageList ( DistributionParcelListWrapper . build ( ) . page VO( packageVOList ) . getRecords ( ) ) ;
List < DistributionParcelListEntity > packageVOList = distributionReservationPackageMapper . selectPackageVOList ( reservationEntity . getId ( ) , s . getId ( ) ) ;
s . setPackageList ( DistributionParcelListWrapper . build ( ) . list VO( packageVOList ) ) ;
} ) ;
reservationVO . setStockArticleList ( distrinbutionStockArticleVOS ) ;
if ( ! Func . isEmpty ( reservationStocklistEntityList ) ) {
List < DistributionStockListEntity > stockArticleEntityList = new ArrayList < > ( ) ;
reservationStocklistEntityList . forEach ( a2 - > {
DistributionStockListEntity stockListEntity = distributionStockListService . getById ( a2 . getStocklistId ( ) ) ;
stockListEntity . setReservationNum ( a2 . getReservationNum ( ) ) ;
stockArticleEntityList . add ( stockListEntity ) ;
} ) ;
List < DistributionStockListVO > stockListVOList = Func . copy ( stockArticleEntityList , DistributionStockListVO . class ) ;
//查询出 库存信息
reservationVO . setInventoryList ( stockListVOList ) ;
}
List < DistributionStockListEntity > stockArticleEntityList = distributionReservationStocklistMapper . selectInventory ( reservationEntity . getId ( ) ) ;
reservationVO . setInventoryList ( DistributionStockListWrapper . build ( ) . listVO ( stockArticleEntityList ) ) ;
return R . data ( reservationVO ) ;
}
@ -732,244 +726,182 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
Long id = distributionReservationDTO . getId ( ) ;
//这里需要查询出这个预约原来的订单、包件信息
List < DistributionReservationStockarticleEntity > distributionReservationStockarticleEntities = distributionReservationStockarticleService . getBaseMapper ( ) . selectList ( Wrappers . < DistributionReservationStockarticleEntity > query ( ) . lambda ( ) . eq ( DistributionReservationStockarticleEntity : : getReservationId , id ) ) ;
Map < Long , List < DistributionReservationStockarticleEntity > > reservationStockarticleMap = distributionReservationStockarticleEntities . stream ( ) . collect ( Collectors . groupingBy ( DistributionReservationStockarticleEntity : : getStockArticleId ) ) ;
Map < Long , List < DistributionReservationStockarticleEntity > > oldStockArticle = distributionReservationStockarticleEntities . stream ( ) . collect ( Collectors . groupingBy ( DistributionReservationStockarticleEntity : : getStockArticleId ) ) ;
List < DistributionStockArticleDTO > dtoStockArticleList = distributionReservationDTO . getStockArticleList ( ) ;
Map < Long , List < DistributionStockArticleDTO > > newStockArticleMap = dtoStockArticleList . stream ( ) . collect ( Collectors . groupingBy ( DistributionStockArticleDTO : : getId ) ) ;
newStockArticleMap . forEach ( ( k , v ) - > {
if ( Func . isNotEmpty ( reservationStockarticleMap . get ( k ) ) ) {
List < DistributionStockArticleDTO > distributionStockArticleDTOS = newStockArticleMap . get ( k ) ;
DistributionStockArticleDTO distributionStockArticleDTO = distributionStockArticleDTOS . get ( 0 ) ;
DistributionStockArticleEntity stockArticleEntity = Func . copy ( distributionStockArticleDTO , DistributionStockArticleEntity . class ) ;
//查询出预约订单中间表数据,进行包件数量维护
DistributionReservationStockarticleEntity reservationStockarticleEntity = distributionReservationStockarticleMapper . selectReservationAndStockArticleId ( id , k ) ;
Integer reservationNum = reservationStockarticleEntity . getReservationNum ( ) ;
List < DistributionParcelListEntity > packageList = distributionStockArticleDTO . getPackageListInfo ( ) ;
//这里将包件数据和原来预约的包件数据进行比对
//查询出这个预约的这个订单下的包包件预约情况
// Page<DistributionParcelListEntity> packageVOList = distributionReservationPackageMapper.selectPackageVOList(new Page<>(), id, k);
List < DistributionReservationPackageEntity > parcelListEntities = distributionReservationPackageMapper . selectPackageByReservationAndStockArticleId ( id , k ) ;
//查询出原计划的包件选取情况
Map < Long , List < DistributionReservationPackageEntity > > oldPackageListMap = parcelListEntities . stream ( ) . collect ( Collectors . groupingBy ( DistributionReservationPackageEntity : : getParceListId ) ) ;
Map < Long , List < DistributionParcelListEntity > > newPackageListMap = packageList . stream ( ) . collect ( Collectors . groupingBy ( DistributionParcelListEntity : : getId ) ) ;
//表示原来的这个订单在预约单下已经存在
//包件数量累加
Map < Long , List < DistributionStockArticleDTO > > newStockArticle = dtoStockArticleList . stream ( ) . collect ( Collectors . groupingBy ( DistributionStockArticleDTO : : getId ) ) ;
AtomicInteger packTotal = new AtomicInteger ( ) ;
AtomicInteger reduceTotal = new AtomicInteger ( ) ;
newStockArticle . forEach ( ( k , v ) - > {
if ( Func . isEmpty ( oldStockArticle . get ( k ) ) ) {
//这里发生了新增订单的操作
DistributionStockArticleDTO distributionStockArticleDTO = v . get ( 0 ) ;
List < DistributionParcelListEntity > packageListInfo = distributionStockArticleDTO . getPackageListInfo ( ) ;
AtomicInteger packageNum = new AtomicInteger ( ) ;
newPackageListMap . forEach ( ( p , i ) - > {
if ( Func . isNotEmpty ( oldPackageListMap . get ( p ) ) ) {
//原计划中不存在这个包件信息,这里需要将这条包件信息进行添加
oldPackageListMap . remove ( p ) ;
} else {
//从记录中获取不到这个包件信息,这里就需要将这个包件信息和这个预约信息进行关系的绑定
DistributionParcelListEntity distributionParcelListEntity = i . get ( 0 ) ;
DistributionReservationPackageEntity distributionReservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
distributionReservationPackageEntity . setReservationId ( id ) ;
distributionReservationPackageEntity . setStockArticleId ( k ) ;
distributionReservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . zhengchang . getValue ( ) ) ;
distributionReservationPackageEntity . setParceListId ( p ) ;
distributionReservationPackageService . save ( distributionReservationPackageEntity ) ;
packageListInfo . forEach ( p - > {
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
reservationPackageEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
reservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . xinzeng . getValue ( ) ) ;
reservationPackageEntity . setPacketBarCode ( p . getOrderPackageCode ( ) ) ;
reservationPackageEntity . setParceListId ( p . getId ( ) ) ;
reservationPackageEntity . setReservationId ( id ) ;
distributionReservationPackageService . save ( reservationPackageEntity ) ;
packageNum . getAndAdd ( p . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( p . getId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
} ) ;
DistributionReservationStockarticleEntity reservationStockarticleEntity = new DistributionReservationStockarticleEntity ( ) ;
reservationStockarticleEntity . setStockArticleStatus ( ReservationOrderStatusConstant . zengjia . getValue ( ) ) ;
reservationStockarticleEntity . setStockArticleCode ( distributionStockArticleDTO . getStockArticleCode ( ) ) ;
reservationStockarticleEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
reservationStockarticleEntity . setReservationId ( id ) ;
reservationStockarticleEntity . setReservationNum ( packageNum . get ( ) ) ;
distributionReservationStockarticleService . save ( reservationStockarticleEntity ) ;
packTotal . getAndAdd ( reservationStockarticleEntity . getReservationNum ( ) ) ;
String status = distributionReservationPackageService . judgmentStatus ( distributionStockArticleDTO ) ;
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService . getById ( distributionStockArticleDTO . getId ( ) ) ;
stockArticleEntity . setReservationStatus ( status ) ;
distributionStockArticleService . updateById ( stockArticleEntity ) ;
} else {
//查询出这个订单原来在这个预约中的勾选情况
DistributionStockArticleDTO distributionStockArticleDTO = v . get ( 0 ) ;
List < DistributionReservationPackageEntity > packageEntityList = distributionReservationPackageMapper . selectPackageByReservationAndStockArticleId ( id , k ) ;
Map < Long , List < DistributionReservationPackageEntity > > oldPackage = packageEntityList . stream ( ) . collect ( Collectors . groupingBy ( DistributionReservationPackageEntity : : getParceListId ) ) ;
Map < Long , List < DistributionParcelListEntity > > newPackage = distributionStockArticleDTO . getPackageListInfo ( ) . stream ( ) . collect ( Collectors . groupingBy ( DistributionParcelListEntity : : getId ) ) ;
AtomicInteger packageNum = new AtomicInteger ( ) ;
AtomicInteger reduceNum = new AtomicInteger ( ) ;
newPackage . forEach ( ( m , n ) - > {
if ( Func . isEmpty ( oldPackage . get ( m ) ) ) {
DistributionParcelListEntity distributionParcelListEntity = n . get ( 0 ) ;
//新增
DistributionReservationPackageEntity reservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
reservationPackageEntity . setStockArticleId ( distributionStockArticleDTO . getId ( ) ) ;
reservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . xinzeng . getValue ( ) ) ;
reservationPackageEntity . setPacketBarCode ( distributionParcelListEntity . getOrderPackageCode ( ) ) ;
reservationPackageEntity . setParceListId ( distributionParcelListEntity . getId ( ) ) ;
reservationPackageEntity . setReservationId ( id ) ;
distributionReservationPackageService . save ( reservationPackageEntity ) ;
packageNum . getAndAdd ( distributionParcelListEntity . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( distributionParcelListEntity . getId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . yiyueyue . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
} else {
oldPackage . remove ( m ) ;
//移除
}
} ) ;
AtomicInteger deleteNum = new AtomicInteger ( ) ;
//这里就需要将原来记录剩下的数据进行取消操作,
oldPackageListMap . forEach ( ( o , q ) - > {
DistributionReservationPackageEntity distributionReservationPackageEntity = q . get ( 0 ) ;
distributionReservationPackageEntity . setPacketBarCode ( ReservationPackageStatusConstant . quxiao . getValue ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( o ) ;
//移除包件进行取消
oldPackage . forEach ( ( o , p ) - > {
DistributionReservationPackageEntity reservationPackageEntity = p . get ( 0 ) ;
reservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . quxiao . getValue ( ) ) ;
distributionReservationPackageService . updateById ( reservationPackageEntity ) ;
//统计减少包件数量
reduceNum . getAndAdd ( distributionParcelListService . getById ( reservationPackageEntity . getParceListId ( ) ) . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( reservationPackageEntity . getParceListId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . daiyuyue . getValue ( ) ) ;
//将预约订单中间表的数据进行减少
deleteNum . getAndAdd ( parcelListEntity . getQuantity ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
} ) ;
reservationStockarticleEntity . setReservationNum ( reservationNum + packageNum . get ( ) - deleteNum . get ( ) ) ;
//对存在订单进行维护
DistributionReservationStockarticleEntity reservationStockarticleEntity = oldStockArticle . get ( k ) . get ( 0 ) ;
Integer reservationNum = reservationStockarticleEntity . getReservationNum ( ) ;
reservationStockarticleEntity . setReservationNum ( reservationNum + packageNum . get ( ) - reduceNum . get ( ) ) ;
distributionReservationStockarticleService . updateById ( reservationStockarticleEntity ) ;
reservationStockarticleMap . remove ( k ) ;
} else {
//这里表示这个订单是新增的
DistributionStockArticleDTO distributionStockArticleDTO = v . get ( 0 ) ;
DistributionStockArticleEntity stockArticleEntity = Func . copy ( distributionStockArticleDTO , DistributionStockArticleEntity . class ) ;
List < DistributionParcelListEntity > packageList = distributionStockArticleDTO . getPackageListInfo ( ) ;
//包件数量累加
AtomicInteger packageCount = new AtomicInteger ( ) ;
packageList . forEach ( p - > {
DistributionReservationPackageEntity distributionReservationPackageEntity = new DistributionReservationPackageEntity ( ) ;
distributionReservationPackageEntity . setReservationId ( id ) ;
distributionReservationPackageEntity . setParceListId ( p . getId ( ) ) ;
distributionReservationPackageEntity . setStockArticleId ( stockArticleEntity . getId ( ) ) ;
distributionReservationPackageEntity . setPacketBarStatus ( ReservationPackageStatusConstant . zhengchang . getValue ( ) ) ;
distributionReservationPackageService . save ( distributionReservationPackageEntity ) ;
packageCount . getAndAdd ( p . getQuantity ( ) ) ;
} ) ;
DistributionReservationStockarticleEntity reservationStockarticleEntity = new DistributionReservationStockarticleEntity ( ) ;
reservationStockarticleEntity . setReservationNum ( packageCount . get ( ) ) ;
reservationStockarticleEntity . setReservationId ( id ) ;
reservationStockarticleEntity . setStockArticleId ( k ) ;
reservationStockarticleEntity . setStockArticleCode ( ReservationOrderStatusConstant . zhengchang . getValue ( ) ) ;
distributionReservationStockarticleService . save ( reservationStockarticleEntity ) ;
//查询订单下的包件数量,对包件状态进行变更
List < DistributionParcelListEntity > parcelListEntityList = distributionParcelListMapper . selectList ( Wrappers . < DistributionParcelListEntity > query ( ) . lambda ( ) . eq ( DistributionParcelListEntity : : getStockArticleId , k ) ) ;
if ( parcelListEntityList . size ( ) = = packageList . size ( ) ) {
stockArticleEntity . setReservationStatus ( OrderReservationStatusConstant . yiyueyue . getValue ( ) ) ;
} else if ( parcelListEntityList . size ( ) > packageList . size ( ) ) {
stockArticleEntity . setReservationStatus ( OrderReservationStatusConstant . daiyuyue . getValue ( ) ) ;
} else {
log . error ( "订单包件数量有误" ) ;
packTotal . getAndAdd ( reservationStockarticleEntity . getReservationNum ( ) ) ;
oldStockArticle . remove ( k ) ;
String status = distributionReservationPackageService . judgmentStatus ( distributionStockArticleDTO ) ;
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService . getById ( distributionStockArticleDTO . getId ( ) ) ;
stockArticleEntity . setReservationStatus ( status ) ;
distributionStockArticleService . updateById ( stockArticleEntity ) ;
}
} ) ;
oldStockArticle . forEach ( ( i , j ) - > {
//这里就是需要进行取消的订单信息
DistributionReservationStockarticleEntity reservationStockarticleEntity = j . get ( 0 ) ;
reservationStockarticleEntity . setStockArticleStatus ( ReservationOrderStatusConstant . quxiao . getValue ( ) ) ;
List < DistributionReservationPackageEntity > packageEntityList = distributionReservationPackageMapper . selectPackageByReservationAndStockArticleId ( id , reservationStockarticleEntity . getStockArticleId ( ) ) ;
packageEntityList . forEach ( p - > {
p . setPacketBarStatus ( ReservationPackageStatusConstant . quxiao . getValue ( ) ) ;
distributionReservationPackageService . updateById ( p ) ;
reduceTotal . getAndAdd ( distributionParcelListService . getById ( p . getParceListId ( ) ) . getQuantity ( ) ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getById ( p . getParceListId ( ) ) ;
parcelListEntity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . daiyuyue . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
} ) ;
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService . getById ( i ) ;
DistributionStockArticleDTO stockArticleDTO = Func . copy ( stockArticleEntity , DistributionStockArticleDTO . class ) ;
String status = distributionReservationPackageService . judgmentStatus ( stockArticleDTO ) ;
stockArticleEntity . setReservationStatus ( status ) ;
reservationStockarticleEntity . setStockArticleStatus ( ReservationOrderStatusConstant . quxiao . getValue ( ) ) ;
distributionReservationStockarticleService . updateById ( reservationStockarticleEntity ) ;
} ) ;
//库存品修改
//查询出原来的库存品信息
List < DistributionReservationStocklistEntity > reservationStocklistEntities = distributionReservationStocklistService . getBaseMapper ( ) . selectList ( Wrappers . < DistributionReservationStocklistEntity > query ( ) . lambda ( ) . eq ( DistributionReservationStocklistEntity : : getReservationId , id ) ) ;
Map < Long , List < DistributionReservationStocklistEntity > > oleInventoryList = reservationStocklistEntities . stream ( ) . collect ( Collectors . groupingBy ( DistributionReservationStocklistEntity : : getStocklistId ) ) ;
List < DistributionStockListDTO > inventoryList = distributionReservationDTO . getInventoryList ( ) ;
Map < Long , List < DistributionStockListDTO > > newInventoryList = inventoryList . stream ( ) . collect ( Collectors . groupingBy ( DistributionStockListDTO : : getId ) ) ;
AtomicInteger inventorTotal = new AtomicInteger ( ) ;
newInventoryList . forEach ( ( c , d ) - > {
DistributionReservationStocklistEntity reservationStocklistEntity = new DistributionReservationStocklistEntity ( ) ;
DistributionStockListDTO distributionStockListDTO = d . get ( 0 ) ;
if ( Func . isEmpty ( oleInventoryList . get ( c ) ) ) {
//新增库存品
reservationStocklistEntity . setStocklistId ( distributionStockListDTO . getId ( ) ) ;
reservationStocklistEntity . setReservationId ( id ) ;
reservationStocklistEntity . setReservationNum ( distributionStockListDTO . getReservationNum ( ) ) ;
reservationStocklistEntity . setUnit ( distributionStockListDTO . getCargoUnit ( ) ) ;
// reservationStocklistEntity.setIsUnpackProduct(distributionStockListDTO.getUnpack());
reservationStocklistEntity . setStockListStatus ( ReservationInventoryStatusConstant . zengjia . getValue ( ) ) ;
distributionReservationStocklistService . save ( reservationStocklistEntity ) ;
//TODO 这里新增还需要对库存品的数量进行修改
DistributionStockListEntity stockListEntity = Func . copy ( distributionStockListDTO , DistributionStockListEntity . class ) ;
Integer quantityOccupied = stockListEntity . getQuantityOccupied ( ) ;
stockListEntity . setQuantityOccupied ( quantityOccupied + reservationStocklistEntity . getReservationNum ( ) ) ;
distributionStockListService . updateById ( stockListEntity ) ;
} else {
DistributionReservationStocklistEntity distributionReservationStocklistEntity = oleInventoryList . get ( c ) . get ( 0 ) ;
// DistributionStockListDTO distributionStockListDTO = newInventoryList.get(c).get(0);
//比对原来的库存品数量和现在的数量是否一致
if ( ! Func . equals ( distributionStockListDTO . getReservationNum ( ) , distributionReservationStocklistEntity . getReservationNum ( ) ) ) {
Integer reservationNum = distributionReservationStocklistEntity . getReservationNum ( ) ;
DistributionStockListEntity stockListEntity = distributionStockListService . getById ( distributionReservationStocklistEntity . getStocklistId ( ) ) ;
Integer quantityOccupied = stockListEntity . getQuantityOccupied ( ) ;
Integer total = quantityOccupied - reservationNum ;
distributionReservationStocklistEntity . setReservationNum ( distributionStockListDTO . getReservationNum ( ) ) ;
distributionReservationStocklistService . updateById ( distributionReservationStocklistEntity ) ;
stockListEntity . setQuantityOccupied ( total + distributionReservationStocklistEntity . getReservationNum ( ) ) ;
distributionStockListService . updateById ( stockListEntity ) ;
//TODO 对库存品数量修改
}
oleInventoryList . remove ( c ) ;
//比较库存品之间的数据
}
inventorTotal . getAndAdd ( distributionStockListDTO . getReservationNum ( ) ) ;
} ) ;
//对移除的库存品进行取消操作
oleInventoryList . forEach ( ( k , v ) - > {
DistributionReservationStocklistEntity distributionReservationStocklistEntity = v . get ( 0 ) ;
distributionReservationStocklistEntity . setStockListStatus ( ReservationInventoryStatusConstant . quxiao . getValue ( ) ) ;
distributionReservationStocklistService . updateById ( distributionReservationStocklistEntity ) ;
//TODO 库存品数量变更
} ) ;
//删除原有
// DistributionReservationEntity distributionReservationEntity = this.getById(distributionReservationDTO.getId());
// Func.copy(distributionReservationDTO, distributionReservationEntity);
// QueryWrapper<DistributionReservationStockarticleEntity> q = Condition.getQueryWrapper(new HashMap<String, Object>(), DistributionReservationStockarticleEntity.class);
// q.lambda().eq(DistributionReservationStockarticleEntity::getReservationId, distributionReservationEntity.getId());
// QueryWrapper<DistributionReservationStocklistEntity> w = Condition.getQueryWrapper(new HashMap<String, Object>(), DistributionReservationStocklistEntity.class);
// w.lambda().eq(DistributionReservationStocklistEntity::getReservationId, distributionReservationEntity.getId());
// QueryWrapper<DistributionReservationPackageEntity> o = Condition.getQueryWrapper(new HashMap<String, Object>(), DistributionReservationPackageEntity.class);
// o.lambda().eq(DistributionReservationPackageEntity::getReservationId, distributionReservationEntity.getId());
// //查询已有的中间表信息
// List<DistributionReservationStockarticleEntity> reservationStockarticleEntityList = distributionReservationStockarticleService.getBaseMapper().selectList(q);
// List<DistributionReservationStocklistEntity> reservationStocklistEntityList = distributionReservationStocklistService.getBaseMapper().selectList(w);
// List<DistributionReservationPackageEntity> reservationPackageEntityList = distributionReservationPackageMapper.selectList(o);
// if (!Func.isEmpty(reservationStockarticleEntityList)) {
// //对已有预约信息的订单包件数量进行清理
// reservationStockarticleEntityList.forEach(s1 -> {
// //删除前需要对订单的可用数进行操作
// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(s1.getStockArticleId());
// stockArticleEntity.setAvailableQuantity(s1.getReservationNum() + stockArticleEntity.getAvailableQuantity());
// stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.daiyuyue.getValue());
// distributionStockArticleService.updateById(stockArticleEntity);
// //这里对原表进行物理删除
// distributionReservationStockarticleMapper.deleteReservationStockarticle(distributionReservationDTO.getId(),s1.getId());
// });
// }
// if (!Func.isEmpty(reservationStocklistEntityList)) {
// //对已有预约信息的库存品数据进行维护
// reservationStocklistEntityList.forEach(r1 -> {
// Long stocklistId = r1.getStocklistId();
// DistributionStockListEntity stockListEntity = distributionStockListService.getById(stocklistId);
// int num = stockListEntity.getQuantityOccupied() - r1.getReservationNum();
// stockListEntity.setQuantityOccupied(num);
//// stockListEntity.setQuantityOccupied(stockListEntity.getQuantityOccupied() + r1.getReservationNum());
// //这里对原表进行物理删除
// distributionStockListService.updateById(stockListEntity);
// distributionReservationStocklistMapper.deleteReservationStocklist(distributionReservationDTO.getId());
// });
// }
// if (!Func.isEmpty(reservationPackageEntityList)) {
// //对已有预约信息的订单包件数量进行清理
// reservationPackageEntityList.forEach(p1 -> {
// DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(p1.getParceListId());
// parcelListEntity.setOrderPackageStockupStatus(OrderPackageStockupStatusConstant.daibeihuo.getValue());
// parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.daiyuyue.getValue());
// //todo 这里需要将包件状态设置成未预约;备货信息设置为未备货
//// parcelListEntity.setOrderPackageReservationStatus();
// //这里对原表进行物理删除
// distributionReservationPackageMapper.deleteReservationPackage(distributionReservationDTO.getId());
// });
// }
// //包件数量累加
// AtomicInteger packageCount = new AtomicInteger();
// //计算总费用
// AtomicReference<BigDecimal> initTotal = new AtomicReference<>(BigDecimal.ZERO);
// //订单自编号拼接
// HashSet<String> hashSet = new HashSet<>();
// List<DistributionStockArticleDTO> stockArticleList = distributionReservationDTO.getStockArticleList();
// if (!Func.isEmpty(stockArticleList)) {
// //这里判断修改内容是否存在订单信息,如果存在则进行中间表数据的重新插入
// stockArticleList.forEach(s -> {
// List<DistributionParcelListEntity> packageList = s.getPackageList();
// QueryWrapper<DistributionParcelListEntity> parcelListEntityQueryWrapper = new QueryWrapper<>();
// LambdaQueryWrapper<DistributionParcelListEntity> queryWrapper = parcelListEntityQueryWrapper.lambda().eq(DistributionParcelListEntity::getStockArticleId, s.getId());
// List<DistributionParcelListEntity> parcelListEntityList = distributionParcelListService.getBaseMapper().selectList(queryWrapper);
// if (packageList.size() != parcelListEntityList.size()) {
// s.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue());
// } else {
// s.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue());
// }
// AtomicInteger packageNum = new AtomicInteger();
// if (Func.isEmpty(packageList)) {
// Map<String, Object> map = new HashMap<>();
// map.put("stockArticleId", s.getId());
// QueryWrapper<DistributionParcelListEntity> qw = Condition.getQueryWrapper(map, DistributionParcelListEntity.class);
// //添加订单下的所有在库订单
// List<DistributionParcelListEntity> distributionParcelListEntities = distributionParcelListService.getBaseMapper().selectList(qw);
// distributionParcelListEntities.forEach(p -> {
// packageNum.getAndIncrement();
// DistributionReservationPackageEntity distributionReservationPackageEntity = new DistributionReservationPackageEntity();
// distributionReservationPackageEntity.setReservationId(distributionReservationDTO.getId());
// distributionReservationPackageEntity.setPacketBarCode(p.getOrderPackageCode());
// distributionReservationPackageEntity.setParceListId(p.getId());
// distributionReservationPackageEntity.setStockArticleId(s.getId());
// //维护订单下包件信息
// distributionReservationPackageService.save(distributionReservationPackageEntity);
// p.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue());
// distributionParcelListService.updateById(p);
// });
// //设置订单可用数为0
// s.setAvailableQuantity(0);
// } else {
// //维护选中的包件信息
// packageList.forEach(p -> {
// packageNum.getAndIncrement();
// DistributionReservationPackageEntity distributionReservationPackageEntity = new DistributionReservationPackageEntity();
// distributionReservationPackageEntity.setReservationId(distributionReservationDTO.getId());
// distributionReservationPackageEntity.setParceListId(p.getId());
// distributionReservationPackageEntity.setStockArticleId(s.getId());
// distributionReservationPackageEntity.setPacketBarCode(p.getOrderPackageCode());
// distributionReservationPackageService.save(distributionReservationPackageEntity);
// p.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue());
// distributionParcelListService.updateById(p);
// });
// s.setAvailableQuantity(s.getAvailableQuantity() - s.getReservationNum());
//
// }
// DistributionReservationStockarticleEntity distributionReservationStockarticleEntity = new DistributionReservationStockarticleEntity();
// //构建预约订单中间表信息
// distributionReservationStockarticleEntity.setReservationNum(packageNum.get());
// distributionReservationStockarticleEntity.setStockArticleId(s.getId());
// distributionReservationStockarticleEntity.setIsHaveData(s.getIsHaveData());
// distributionReservationStockarticleEntity.setReservationId(distributionReservationEntity.getId());
// distributionReservationStockarticleService.save(distributionReservationStockarticleEntity);
// packageCount.getAndAdd(distributionReservationStockarticleEntity.getReservationNum());
// //统计订单包件数量
// //订单到付费用
//// initTotal.getAndAccumulate(new BigDecimal(s.getCollectFee().toString()), BigDecimal::add);
//// //订单仓储费
//// initTotal.getAndAccumulate(new BigDecimal(s.getStorageFee().toString()), BigDecimal::add);
//// //协商费用
//// initTotal.getAndAccumulate(new BigDecimal(s.getRate().toString()), BigDecimal::add);
// hashSet.add(s.getOrderCode());
// });
// }
// List<DistributionStockListDTO> inventoryList = distributionReservationDTO.getInventoryList();
// AtomicInteger stockListNum = new AtomicInteger();
// if (!Func.isEmpty(inventoryList)) {
// //重新构建预约和库存之间的关系
// inventoryList.forEach(i -> {
// DistributionStockListEntity stockListEntity = distributionStockListService.getById(i.getId());
// int count = stockListEntity.getQuantityOccupied() + i.getReservationNum();
// stockListEntity.setQuantityOccupied(count);
// distributionStockListService.updateById(stockListEntity);
// DistributionReservationStocklistEntity distributionReservationStocklistEntity = new DistributionReservationStocklistEntity();
// distributionReservationStocklistEntity.setReservationId(distributionReservationEntity.getId());
// distributionReservationStocklistEntity.setReservationNum(i.getReservationNum());
// distributionReservationStocklistEntity.setStocklistId(i.getId());
// distributionReservationStocklistService.save(distributionReservationStocklistEntity);
// hashSet.add(i.getOrderCode());
// stockListNum.getAndAdd(distributionReservationStocklistEntity.getReservationNum());
// });
// }
// String orderId = String.join(",", hashSet);
// distributionReservationEntity.setFee(initTotal.get());
// distributionReservationEntity.setServeType(DistributionTypeConstant.shipie.getValue());
// distributionReservationEntity.setReservationNum(packageCount.get());
// distributionReservationEntity.setStockArticleId(orderId);
// distributionReservationEntity.setReservationStockListNum(stockListNum.get());
// distributionReservationMapper.updateById(distributionReservationEntity);
DistributionReservationEntity reservationEntity = this . getById ( id ) ;
Integer reservationNum = reservationEntity . getReservationNum ( ) ;
reservationEntity . setOtherFee ( distributionReservationDTO . getOtherFee ( ) ) ;
reservationEntity . setDeliveryType ( distributionReservationDTO . getDeliveryType ( ) ) ;
reservationEntity . setDeliveryWay ( distributionReservationDTO . getDeliveryWay ( ) ) ;
reservationEntity . setServeType ( distributionReservationDTO . getServeType ( ) ) ;
reservationEntity . setReservationNum ( packTotal . get ( ) ) ;
reservationEntity . setReservationStockListNum ( inventorTotal . get ( ) ) ;
reservationEntity . setReservationDate ( distributionReservationDTO . getReservationDate ( ) ) ;
reservationEntity . setPeriodOfTime ( distributionReservationDTO . getPeriodOfTime ( ) ) ;
reservationEntity . setReplaceFee ( distributionReservationDTO . getReplaceFee ( ) ) ;
// reservationEntity.setCollectFee(distributionReservationDTO.getCollectFee());
reservationEntity . setRemarks ( distributionReservationDTO . getRemarks ( ) ) ;
reservationEntity . setIsUrgent ( distributionReservationDTO . getIsUrgent ( ) ) ;
this . updateById ( reservationEntity ) ;
return true ;
}
@ -1066,7 +998,7 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
// TODO 计算总费用
// AtomicReference<BigDecimal> initTotal = new AtomicReference<>(BigDecimal.ZERO);
//统计包件数量
AtomicInteger packageTotal = new AtomicInteger ( ) ;
AtomicInteger packageTotal = new AtomicInteger ( ) ;
v . forEach ( a - > {
orderTotal . getAndIncrement ( ) ;
DistributionStockArticleEntity stockArticleEntity = Func . copy ( a , DistributionStockArticleEntity . class ) ;