@ -122,107 +122,38 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
@Override
public R scanAddvaluePackage ( DistributionAppAddvalueDTO distributionAppAddvalueDTO ) {
Long reservationId = distributionAppAddvalueDTO . getReservationId ( ) ;
List < DistributionParcelListEntity > parcelListEntityList = distributionReservationMapper . selectPackageListByReservationId ( reservationId ) ;
List < DisStockListDetailEntity > detailEntities = distributionReservationMapper . selectInventoryListByReservation ( reservationId ) ;
if ( Func . isEmpty ( parcelListEntityList ) & & Func . isEmpty ( detailEntities ) ) {
//该客户不存在包件信息
return Resp . scanFail ( "客户信息有误!!!" , "客户信息有误" ) ;
}
List < Long > packageListIds = distributionAppAddvalueDTO . getPackageListIds ( ) ;
Integer isManual = distributionAppAddvalueDTO . getIsManual ( ) ;
List < DistributionParcelListEntity > collect1 = parcelListEntityList . stream ( ) . filter ( p - > packageListIds . contains ( p . getId ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( collect1 . size ( ) = = 1 ) {
return Resp . scanFail ( "重复扫描" , "重复扫描" ) ;
}
List < DisStockListDetailEntity > collect2 = detailEntities . stream ( ) . filter ( i - > packageListIds . contains ( i . getId ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( collect2 . size ( ) = = 1 ) {
return Resp . scanFail ( "重复扫描" , "重复扫描" ) ;
}
List < DistributionParcelListEntity > packageInfo = parcelListEntityList . stream ( ) . filter ( p - > p . getOrderPackageCode ( ) . equals ( distributionAppAddvalueDTO . getBarcode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
// DistributionAddvaluePackageEntity distributionAddvaluePackageEntiy = new DistributionAddvaluePackageEntity();
if ( Func . isNotEmpty ( packageInfo ) & & packageInfo . size ( ) = = 1 ) {
DistributionParcelListEntity parcelListEntity = packageInfo . get ( 0 ) ;
DistributionAddvaluePackageEntity distributionAddvaluePackageEntiy = Func . copy ( parcelListEntity , DistributionAddvaluePackageEntity . class ) ;
assert distributionAddvaluePackageEntiy ! = null ;
distributionAddvaluePackageEntiy . setConditions ( 1 ) ;
distributionAddvaluePackageEntiy . setId ( null ) ;
distributionAddvaluePackageEntiy . setQuantity ( parcelListEntity . getQuantity ( ) ) ;
distributionAddvaluePackageEntiy . setPackageId ( parcelListEntity . getId ( ) ) ;
distributionAddvaluePackageEntiy . setMaterialName ( parcelListEntity . getMaterialName ( ) ) ;
distributionAddvaluePackageEntiy . setReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
distributionAddvaluePackageEntiy . setStockArticleId ( parcelListEntity . getStockArticleId ( ) ) ;
distributionAddvaluePackageEntiy . setOrderPackageCode ( parcelListEntity . getOrderPackageCode ( ) ) ;
distributionAddvaluePackageEntiy . setRecordType ( "1" ) ;
if ( isManual . equals ( 2 ) ) {
distributionAddvaluePackageEntiy . setRecordType ( "1" ) ;
}
//查询包件的结算单位
return Res . scanSuccess ( "扫描成功" , "扫描成功" , distributionAddvaluePackageEntiy ) ;
} else if ( packageInfo . isEmpty ( ) ) {
//包件列表不存在,这里查询看库存品是否存在?
List < DisStockListDetailEntity > inventoryInfo = detailEntities . stream ( ) . filter ( i - > Func . isNotEmpty ( i . getStockPackageCode ( ) ) & & i . getStockPackageCode ( ) . equals ( distributionAppAddvalueDTO . getBarcode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( Func . isNotEmpty ( inventoryInfo ) & & inventoryInfo . size ( ) = = 1 ) {
DisStockListDetailEntity disStockListDetailEntity = inventoryInfo . get ( 0 ) ;
DistributionStockListEntity stockListEntity = distributionStockListService . getById ( disStockListDetailEntity . getStockListId ( ) ) ;
DistributionAddvaluePackageEntity distributionAddvaluePackageEntiy = Func . copy ( disStockListDetailEntity , DistributionAddvaluePackageEntity . class ) ;
assert distributionAddvaluePackageEntiy ! = null ;
distributionAddvaluePackageEntiy . setConditions ( 2 ) ;
distributionAddvaluePackageEntiy . setQuantity ( disStockListDetailEntity . getNum ( ) ) ;
distributionAddvaluePackageEntiy . setPackageId ( disStockListDetailEntity . getId ( ) ) ;
distributionAddvaluePackageEntiy . setMaterialName ( stockListEntity . getDescriptionGoods ( ) ) ;
distributionAddvaluePackageEntiy . setReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
distributionAddvaluePackageEntiy . setStockArticleId ( disStockListDetailEntity . getStockListId ( ) ) ;
distributionAddvaluePackageEntiy . setOrderPackageCode ( disStockListDetailEntity . getStockPackageCode ( ) ) ;
distributionAddvaluePackageEntiy . setRecordType ( "1" ) ;
if ( isManual . equals ( 2 ) ) {
distributionAddvaluePackageEntiy . setRecordType ( "1" ) ;
}
return Res . scanSuccess ( "扫描成功" , "扫描成功" , distributionAddvaluePackageEntiy ) ;
} else if ( inventoryInfo . size ( ) = = 0 ) {
//该客户下既不存在该包件,也不存在该库存品 ---
//查询是否属于该配送任务
List < DistributionParcelListEntity > parcelListEntities = distributionDeliveryListMapper . selectPackageListByDeliveryListId ( distributionAppAddvalueDTO . getDeliveryId ( ) ) ;
if ( Func . isNotEmpty ( parcelListEntities ) ) {
List < DistributionParcelListEntity > collect = parcelListEntities . stream ( ) . filter ( s - > s . getOrderPackageCode ( ) . equals ( distributionAppAddvalueDTO . getBarcode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( Func . isNotEmpty ( collect ) ) {
return Resp . scanFail ( "扫描失败" , "窜货" ) ;
}
} else {
//查询是否该配送任务中是否存在该库存品包件信息
List < DisStockListDetailEntity > stockListDetailEntities = distributionDeliveryListMapper . selectInventoryListByDeliveryListId ( distributionAppAddvalueDTO . getDeliveryId ( ) ) ;
if ( Func . isNotEmpty ( stockListDetailEntities ) ) {
List < DisStockListDetailEntity > detailEntityList = stockListDetailEntities . stream ( ) . filter ( s - > s . getStockPackageCode ( ) . equals ( distributionAppAddvalueDTO . getBarcode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( Func . isNotEmpty ( detailEntityList ) ) {
return Resp . scanFail ( "扫描失败" , "窜货" ) ;
}
} else {
return Resp . scanFail ( "扫描失败" , "此码无效" ) ;
if ( Objects . isNull ( distributionAppAddvalueDTO . getReservationId ( ) ) ) {
log . error ( "#####################参数缺失reservationId" ) ;
}
List < DistributionAddvaluePackageDTO > allPackageList = this . getAllPackageList ( distributionAppAddvalueDTO ) ;
if ( allPackageList . isEmpty ( ) ) {
log . error ( "#####################预约计划下无包件信息reservationId:{}" , distributionAppAddvalueDTO . getReservationId ( ) ) ;
}
} else {
log . error ( "出现一个客户下重复库存品包件码的情况" ) ;
return Resp . scanFail ( "扫描失败" , "窜货" ) ;
if ( Objects . isNull ( distributionAppAddvalueDTO . getBarcode ( ) ) ) {
log . error ( "#####################参数缺失Barcode" ) ;
}
List < DistributionAddvaluePackageDTO > scanList = allPackageList . stream ( ) . filter ( f - > distributionAppAddvalueDTO . getBarcode ( ) . equals ( f . getOrderPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( ! scanList . isEmpty ( ) ) {
//存在
if ( scanList . size ( ) = = 1 ) {
return R . data ( scanList . get ( 0 ) ) ;
} else {
log . error ( "出现一个客户下重复包件码的情况" ) ;
return Resp . scanFail ( "扫描失败" , "窜货" ) ;
log . error ( "增值服务扫描计划内包件错误,同一包件存在多个" ) ;
}
return null ;
}
//不存在这里就需要进行系统是否存在该包件进行判断
log . error ( "增值服务扫描计划内包件错误,不存在此包件" ) ;
//判断怎么不存在
return Resp . scanFail ( "计划内无此包件信息" , "计划内无此包件信息" ) ;
}
@Override
@Transactional
public R saveAddvalueInfo ( DistributionAppAddvalueDTO distributionAppAddvalueDTO ) {
List < DistributionAddvaluePackageDTO > packageEntityList = distributionAppAddvalueDTO . getPackageEntityList ( ) ;
List < DistributionAddvaluePackageDTO > packageDTOList = packageEntityList . stream ( ) . filter ( p - > Func . isNotEmpty ( p . getQuantity ( ) ) & & p . getQuantity ( ) > 0 ) . collect ( Collectors . toList ( ) ) ;
if ( Func . isEmpty ( packageDTOList ) ) {
return Resp . scanFail ( "操作失败" , "无可用包件信息" ) ;
}
//查询是否重复添加
DistributionAddvalueEntity addvalueEntity = distributionAddvalueMapper . selectOne ( Wrappers . < DistributionAddvalueEntity > query ( ) . lambda ( )
. eq ( DistributionAddvalueEntity : : getAddvalueId , distributionAppAddvalueDTO . getAddvalueType ( ) )
@ -257,6 +188,7 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
} else {
distributionAddvalueDetailEntity . setDistance ( distributionAppAddvalueDTO . getDistance ( ) ) ;
}
break ;
case "3" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getDistance ( ) ) ) {
@ -265,24 +197,29 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
distributionAddvalueDetailEntity . setDistance ( distributionAppAddvalueDTO . getDistance ( ) ) ;
}
break ;
case "4" :
case "5" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getNum ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入件数" ) ;
} else {
distributionAddvalueDetailEntity . setNum ( packageEntityList . stream ( ) . mapToInt ( DistributionAddvaluePackageEntity : : getQuantity ) . sum ( ) ) ;
}
break ;
case "6" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFee ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入件数" ) ;
} else {
distributionAddvalueDetailEntity . setFee ( distributionAppAddvalueDTO . getFee ( ) ) ;
}
break ;
// case "4":
// case "5":
// if (Func.isEmpty(distributionAppAddvalueDTO.getNum())) {
// return Resp.scanFail("添加失败", "请输入件数");
// } else {
// distributionAddvalueDetailEntity.setNum(packageEntityList.stream().mapToInt(DistributionAddvaluePackageEntity::getQuantity).sum());
// }
// break;
// case "6":
// if (Func.isEmpty(distributionAppAddvalueDTO.getFee())) {
// return Resp.scanFail("添加失败", "请输入件数");
// } else {
// distributionAddvalueDetailEntity.setFee(distributionAppAddvalueDTO.getFee());
// }
// break;
default :
return Resp . scanFail ( "添加失败" , "服务器正忙" ) ;
}
List < DistributionAddvaluePackageDTO > packageEntityList = distributionAppAddvalueDTO . getPackageEntityList ( ) ;
List < DistributionAddvaluePackageDTO > packageDTOList = packageEntityList . stream ( ) . filter ( p - > Func . isNotEmpty ( p . getQuantity ( ) ) & & p . getQuantity ( ) > 0 ) . collect ( Collectors . toList ( ) ) ;
if ( Func . isEmpty ( packageDTOList ) ) {
return Resp . scanFail ( "操作失败" , "无可用包件信息" ) ;
}
DistributionAddvalueEntity distributionAddvalueEntity = new DistributionAddvalueEntity ( ) ;
distributionAddvalueEntity . setAddvalueId ( distributionAppAddvalueDTO . getAddvalueType ( ) ) ;
distributionAddvalueEntity . setCode ( reservationEntity . getReservationCode ( ) ) ;
@ -299,96 +236,29 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
distributionAddvalueDetailService . save ( distributionAddvalueDetailEntity ) ;
List < DistributionAddvaluePackageEntity > addvaluePackageEntities = new ArrayList < > ( ) ;
BigDecimal totalFee = new BigDecimal ( BigInteger . ZERO ) ;
packageEntityList . stream ( ) . forEach ( p - > {
AtomicReference < Integer > totalNum = new AtomicReference < > ( new Integer ( 0 ) ) ;
packageEntityList . forEach ( p - > {
if ( Func . isEmpty ( p . getUnitPrice ( ) ) ) {
p . setUnitPrice ( BigDecimal . ZERO ) ;
}
p . setAddvalueDetailId ( distributionAddvalueDetailEntity . getId ( ) ) ;
p . setQuantity ( p . getZeroQuantity ( ) ) ;
p . setScanUserName ( AuthUtil . getNickName ( ) ) ;
DistributionAddvaluePackageEntity addvaluePackageEntity = Func . copy ( p , DistributionAddvaluePackageEntity . class ) ;
//构建增值服务包件的收入
BigDecimal unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
//查询此包件匹配的计划模板
//获取结算单价
List < PriceDispatchAddClientVO > priceDispatchAddClientVOS = basicdataPriceClient . dispatchAddPrice ( BasicdatPriceApiVO . builder ( ) . clientId ( p . getClientId ( ) . toString ( ) ) . brandId ( p . getBrandId ( ) . toString ( ) ) . build ( ) ) ;
if ( Func . isEmpty ( priceDispatchAddClientVOS ) ) {
//此客户品牌下无单价信息
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
switch ( p . getConditions ( ) ) {
case 1 :
//查询订制品结算品类
BasicdataFactoryCategoryEntity entity1 = new BasicdataFactoryCategoryEntity ( ) ;
entity1 . setFirsts ( p . getFirsts ( ) ) ;
entity1 . setSeconds ( p . getSecond ( ) ) ;
entity1 . setThirds ( p . getThirdProduct ( ) ) ;
entity1 . setMaterielName ( p . getMaterialName ( ) ) ;
entity1 . setBrandId ( p . getBrandId ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity1 = basicdataFactoryCategoryClient . findEntityByThreeCategory ( entity1 ) ;
if ( Func . isEmpty ( factoryCategoryEntity1 ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity1 ) ) {
//获取单价
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity1 , distributionAppAddvalueDTO ) ;
}
//判定该包件是否属于该客户
List < DistributionParcelListEntity > parcelListEntityList = distributionReservationMapper . selectPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
// boolean packageFlag = parcelListEntities.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));
boolean packageFlag = parcelListEntityList . stream ( ) . map ( DistributionParcelListEntity : : getId ) . collect ( Collectors . toList ( ) ) . contains ( p . getPackageId ( ) ) ;
if ( ! packageFlag ) {
throw new RuntimeException ( "不属于该客户包件" ) ;
}
break ;
case 2 :
BasicdataFactoryCategoryEntity entity2 = new BasicdataFactoryCategoryEntity ( ) ;
entity2 . setMaterielName ( p . getMaterialName ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity2 = basicdataFactoryCategoryClient . findEntityByMaterielName ( entity2 ) ;
if ( Func . isEmpty ( factoryCategoryEntity2 ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity2 ) ) {
//获取单价
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity2 , distributionAppAddvalueDTO ) ;
}
List < DisStockListDetailEntity > detailEntities = distributionReservationMapper . selectInventoryListByReservation ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
// boolean inventoryPackageFlag = detailEntities.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));
boolean inventoryPackageFlag = detailEntities . stream ( ) . map ( DisStockListDetailEntity : : getId ) . collect ( Collectors . toList ( ) ) . contains ( p . getPackageId ( ) ) ;
if ( ! inventoryPackageFlag ) {
throw new RuntimeException ( "不属于该客户包件" ) ;
}
break ;
case 3 :
BasicdataFactoryCategoryEntity entity3 = new BasicdataFactoryCategoryEntity ( ) ;
entity3 . setMaterielName ( p . getMaterialName ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity3 = basicdataFactoryCategoryClient . findEntityByCategoryName ( entity3 ) ;
if ( Func . isEmpty ( factoryCategoryEntity3 ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity3 ) ) {
//获取单价
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity3 , distributionAppAddvalueDTO ) ;
}
List < DistributionParcelNumberDTO > distributionParcelNumberDTOS = distributionReservationMapper . selectZeroPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
// boolean zeroPackageFlag = distributionParcelNumberDTOS.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));
boolean zeroPackageFlag = distributionParcelNumberDTOS . stream ( ) . map ( DistributionParcelNumberDTO : : getId ) . collect ( Collectors . toList ( ) ) . contains ( p . getPackageId ( ) ) ;
if ( ! zeroPackageFlag ) {
throw new RuntimeException ( "不属于该客户包件" ) ;
}
break ;
}
addvaluePackageEntity . setScanUserName ( AuthUtil . getNickName ( ) ) ;
addvaluePackageEntity . setUnitPrice ( unitPrice ) ;
addvaluePackageEntity . setUnitPrice ( p . getUnitPrice ( ) ) ;
addvaluePackageEntity . setRecordType ( "1" ) ;
//计算收入
addvaluePackageEntity . setFee ( unitPrice . multiply ( BigDecimal . valueOf ( p . getQuantity ( ) ) ) ) ;
addvaluePackageEntity . setFee ( p . getUnitPrice ( ) . multiply ( BigDecimal . valueOf ( p . getQuantity ( ) ) ) ) ;
addvaluePackageEntities . add ( addvaluePackageEntity ) ;
totalFee . add ( addvaluePackageEntity . getFee ( ) ) ;
totalNum . updateAndGet ( v - > v + p . getQuantity ( ) ) ;
} ) ;
distributionAddvaluePackageService . saveBatch ( addvaluePackageEntities ) ;
//最后进行该增值服务项的费用统计
distributionAddvalueDetailService . update ( Wrappers . < DistributionAddvalueDetailEntity > update ( ) . lambda ( )
. eq ( DistributionAddvalueDetailEntity : : getId , distributionAddvalueDetailEntity . getId ( ) )
. set ( DistributionAddvalueDetailEntity : : getFee , totalFee )
. set ( DistributionAddvalueDetailEntity : : getNum , totalNum . get ( ) )
) ;
return Resp . scanSuccess ( "添加成功" , "添加成功" ) ;
}
@ -683,45 +553,128 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
}
@Override
public List < DistributionAddvaluePackageV O > getAllPackageList ( DistributionAppAddvalueDTO distributionAppAddvalueDTO ) {
public List < DistributionAddvaluePackageDT O > getAllPackageList ( DistributionAppAddvalueDTO distributionAppAddvalueDTO ) {
// List<DistributionAddvaluePackageEntity> packageEntityList = distributionAppAddvalueDTO.getPackageEntityList();
List < Long > packageListIds = distributionAppAddvalueDTO . getPackageListIds ( ) ;
// List<Long> packageListIds = distributionAppAddvalueDTO.getPackageListIds();
// Long reservationId = distributionAppAddvalueDTO.getReservationId();
//// List<DistributionAddvaluePackageVO> parcelListEntities = distributionReservationMapper.selectAppPackageListByReservationId(reservationId);
//// List<DistributionAddvaluePackageVO> zeroPackageList = distributionReservationMapper.selectAppZeroPackageListByReservationId(reservationId);
//// List<DistributionAddvaluePackageVO> detailEntities = distributionReservationMapper.selectAppInventoryListByReservation(reservationId);
// if (Func.isNotEmpty(zeroPackageList)) {
// zeroPackageList.forEach(zp -> {
// //查询最大输入数量
// DistributionLoadscanEntity loadscanEntities = distributionLoadscanService.getOne(Wrappers.<DistributionLoadscanEntity>query().lambda().eq(DistributionLoadscanEntity::getReservationId, distributionAppAddvalueDTO.getReservationId()).eq(DistributionLoadscanEntity::getPackageId, zp.getPackageId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()));
// zp.setMaxQuantity(0);
// if (Func.isNotEmpty(loadscanEntities)) {
// zp.setMaxQuantity(loadscanEntities.getReceivedQuantity());
// }
// });
// }
// parcelListEntities.addAll(detailEntities);
// parcelListEntities.addAll(zeroPackageList);
// if (Func.isEmpty(parcelListEntities)) {
// log.error("################该客户下包件信息:{}", parcelListEntities);
// log.error("################该客户下库存品包件信息:{}", detailEntities);
//// return R.fail("服务器正忙....");
// }
// if (Func.isNotEmpty(parcelListEntities)) {
// parcelListEntities.stream().forEach(p -> {
// p.setRecordType("1");
// //进行客户信息完善
//
//
//
// });
// }
// if (Func.isNotEmpty(zeroPackageList)) {
// zeroPackageList.stream().forEach(p -> {
// p.setRecordType("1");
// });
// }
String method = "#####################################DistributionAddvalueServiceImpl.getAllPackageList" ;
Long reservationId = distributionAppAddvalueDTO . getReservationId ( ) ;
List < DistributionAddvaluePackageVO > parcelListEntities = distributionReservationMapper . selectAppPackageListByReservationId ( reservationId ) ;
List < DistributionAddvaluePackageVO > zeroPackageList = distributionReservationMapper . selectAppZeroPackageListByReservationId ( reservationId ) ;
List < DistributionAddvaluePackageVO > detailEntities = distributionReservationMapper . selectAppInventoryListByReservation ( reservationId ) ;
if ( Func . isNotEmpty ( zeroPackageList ) ) {
zeroPackageList . forEach ( zp - > {
//查询最大输入数量
DistributionLoadscanEntity loadscanEntities = distributionLoadscanService . getOne ( Wrappers . < DistributionLoadscanEntity > query ( ) . lambda ( ) . eq ( DistributionLoadscanEntity : : getReservationId , distributionAppAddvalueDTO . getReservationId ( ) ) . eq ( DistributionLoadscanEntity : : getPackageId , zp . getPackageId ( ) ) . ne ( DistributionLoadscanEntity : : getScanStatus , LoadingStatusConstant . quxiao . getValue ( ) ) ) ;
zp . setMaxQuantity ( 0 ) ;
if ( Func . isNotEmpty ( loadscanEntities ) ) {
zp . setMaxQuantity ( loadscanEntities . getReceivedQuantity ( ) ) ;
if ( Objects . isNull ( distributionAppAddvalueDTO . getReservationId ( ) ) ) {
log . error ( method + "参数缺失ReservationId" ) ;
return null ;
}
} ) ;
List < DistributionAddvaluePackageDTO > superZoneList = distributionSignforService . checkAddValuePCPackageList ( reservationId ) ;
if ( ! superZoneList . isEmpty ( ) ) {
//进行单价获取
AtomicReference < BigDecimal > unitPrice = new AtomicReference < > ( BigDecimal . ZERO ) ;
superZoneList . forEach ( s - > {
Integer conditions = s . getConditions ( ) ;
//获取结算单价
List < PriceDispatchAddClientVO > priceDispatchAddClientVOS = basicdataPriceClient . dispatchAddPrice ( BasicdatPriceApiVO . builder ( ) . clientId ( s . getClientId ( ) . toString ( ) ) . brandId ( s . getBrandId ( ) . toString ( ) ) . build ( ) ) ;
if ( Func . isEmpty ( priceDispatchAddClientVOS ) ) {
//此客户品牌下无单价信息
unitPrice . set ( BigDecimal . ZERO ) ;
}
parcelListEntities . addAll ( detailEntities ) ;
parcelListEntities . addAll ( zeroPackageList ) ;
if ( Func . isEmpty ( parcelListEntities ) ) {
log . error ( "################该客户下包件信息:{}" , parcelListEntities ) ;
log . error ( "################该客户下库存品包件信息:{}" , detailEntities ) ;
// return R.fail("服务器正忙....");
}
if ( Func . isNotEmpty ( parcelListEntities ) ) {
parcelListEntities . stream ( ) . forEach ( p - > {
p . setRecordType ( "1" ) ;
//进行客户信息完善
} ) ;
switch ( conditions ) {
case 1 :
//查询订制品结算品类
BasicdataFactoryCategoryEntity entity1 = new BasicdataFactoryCategoryEntity ( ) ;
entity1 . setFirsts ( s . getFirsts ( ) ) ;
entity1 . setSeconds ( s . getSecond ( ) ) ;
entity1 . setThirds ( s . getThirdProduct ( ) ) ;
entity1 . setMaterielName ( s . getMaterialName ( ) ) ;
entity1 . setBrandId ( s . getBrandId ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity1 = basicdataFactoryCategoryClient . findEntityByThreeCategory ( entity1 ) ;
if ( Func . isEmpty ( factoryCategoryEntity1 ) ) {
unitPrice . set ( BigDecimal . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity1 ) ) {
//获取单价
unitPrice . set ( getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity1 , distributionAppAddvalueDTO ) ) ;
}
//判定该包件是否属于该客户
List < DistributionParcelListEntity > parcelListEntities = distributionReservationMapper . selectPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
// boolean packageFlag = parcelListEntities.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));
boolean packageFlag = parcelListEntities . stream ( ) . map ( DistributionParcelListEntity : : getId ) . collect ( Collectors . toList ( ) ) . contains ( s . getPackageId ( ) ) ;
if ( ! packageFlag ) {
throw new RuntimeException ( "不属于该客户包件" ) ;
}
break ;
case 2 :
BasicdataFactoryCategoryEntity entity2 = new BasicdataFactoryCategoryEntity ( ) ;
entity2 . setMaterielName ( s . getMaterialName ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity2 = basicdataFactoryCategoryClient . findEntityByMaterielName ( entity2 ) ;
if ( Func . isEmpty ( factoryCategoryEntity2 ) ) {
unitPrice . set ( BigDecimal . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity2 ) ) {
//获取单价
unitPrice . set ( getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity2 , distributionAppAddvalueDTO ) ) ;
}
List < DisStockListDetailEntity > detailEntities = distributionReservationMapper . selectInventoryListByReservation ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
// boolean inventoryPackageFlag = detailEntities.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));
boolean inventoryPackageFlag = detailEntities . stream ( ) . map ( DisStockListDetailEntity : : getId ) . collect ( Collectors . toList ( ) ) . contains ( s . getPackageId ( ) ) ;
if ( ! inventoryPackageFlag ) {
throw new RuntimeException ( "不属于该客户包件" ) ;
}
break ;
case 3 :
BasicdataFactoryCategoryEntity entity3 = new BasicdataFactoryCategoryEntity ( ) ;
entity3 . setMaterielName ( s . getMaterialName ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity3 = basicdataFactoryCategoryClient . findEntityByCategoryName ( entity3 ) ;
if ( Func . isEmpty ( factoryCategoryEntity3 ) ) {
unitPrice . set ( BigDecimal . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity3 ) ) {
//获取单价
unitPrice . set ( getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity3 , distributionAppAddvalueDTO ) ) ;
}
List < DistributionParcelNumberDTO > distributionParcelNumberDTOS = distributionReservationMapper . selectZeroPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
// boolean zeroPackageFlag = distributionParcelNumberDTOS.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));
boolean zeroPackageFlag = distributionParcelNumberDTOS . stream ( ) . map ( DistributionParcelNumberDTO : : getId ) . collect ( Collectors . toList ( ) ) . contains ( s . getPackageId ( ) ) ;
if ( ! zeroPackageFlag ) {
throw new RuntimeException ( "不属于该客户包件" ) ;
}
break ;
}
if ( Func . isNotEmpty ( zeroPackageList ) ) {
zeroPackageList . stream ( ) . forEach ( p - > {
p . setRecordType ( "1" ) ;
s . setUnitPrice ( unitPrice . get ( ) ) ;
} ) ;
}
return parcelListEntities ;
return superZoneList ;
}
@Override