@ -68,33 +68,33 @@ import java.util.stream.Collectors;
public class DistributionAddvalueServiceImpl extends BaseServiceImpl < DistributionAddvalueMapper , DistributionAddvalueEntity > implements IDistributionAddvalueService {
@Autowired
private DistributionAddvalueMapper distributionAddvalueMapper ;
private DistributionAddvalueMapper distributionAddvalueMapper ;
@Autowired
private DistributionReservationMapper distributionReservationMapper ;
private DistributionReservationMapper distributionReservationMapper ;
@Autowired
private IDistributionStockListService distributionStockListService ;
private IDistributionStockListService distributionStockListService ;
@Autowired
private DistributionDeliveryListMapper distributionDeliveryListMapper ;
private DistributionDeliveryListMapper distributionDeliveryListMapper ;
@Autowired
// private IDistributionAddvalueService distributionAddvalueService;
private IDistributionAddvaluePackageService distributionAddvaluePackageService ;
private IDistributionAddvaluePackageService distributionAddvaluePackageService ;
@Autowired
private IDistributionAddvalueDetailService distributionAddvalueDetailService ;
private IDistributionAddvalueDetailService distributionAddvalueDetailService ;
@Autowired
private DistributionAddvalueDetailMapper distributionAddvalueDetailMapper ;
private DistributionAddvalueDetailMapper distributionAddvalueDetailMapper ;
@Autowired
private DistributionAddvaluePackageMapper distributionAddvaluePackageMapper ;
private DistributionAddvaluePackageMapper distributionAddvaluePackageMapper ;
@Autowired
private IDistributionLoadscanService distributionLoadscanService ;
private IDistributionLoadscanService distributionLoadscanService ;
@Autowired
private IBasicdataPriceClient basicdataPriceClient ;
private IBasicdataPriceClient basicdataPriceClient ;
@Autowired
private IBasicdataClientClient basicdataClientClient ;
private IBasicdataClientClient basicdataClientClient ;
@Autowired
private IBasicdataFactoryCategoryClient basicdataFactoryCategoryClient ;
private IBasicdataFactoryCategoryClient basicdataFactoryCategoryClient ;
@Autowired
@Lazy
private IDistributionSignforService distributionSignforService ;
private IDistributionSignforService distributionSignforService ;
@Override
@ -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 ( "客户信息有误!!!" , "客户信息有误" ) ;
if ( Objects . isNull ( distributionAppAddvalueDTO . getReservationId ( ) ) ) {
log . error ( "#####################参数缺失reservationId" ) ;
}
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 < DistributionAddvaluePackageDTO > allPackageList = this . getAllPackageList ( distributionAppAddvalueDTO ) ;
if ( allPackageList . isEmpty ( ) ) {
log . error ( "#####################预约计划下无包件信息reservationId:{}" , distributionAppAddvalueDTO . getReservationId ( ) ) ;
}
List < DisStockListDetailEntity > collect2 = detailEntities . stream ( ) . filter ( i - > packageListIds . contains ( i . getId ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( collect2 . size ( ) = = 1 ) {
return Resp . scanFail ( "重复扫描" , "重复扫描" ) ;
if ( Objects . isNull ( distributionAppAddvalueDTO . getBarcode ( ) ) ) {
log . error ( "#####################参数缺失Barcode" ) ;
}
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" ) ;
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 ( "增值服务扫描计划内包件错误,同一包件存在多个" ) ;
}
//查询包件的结算单位
}
//不存在这里就需要进行系统是否存在该包件进行判断
log . error ( "增值服务扫描计划内包件错误,不存在此包件" ) ;
//判断怎么不存在
return Resp . scanFail ( "计划内无此包件信息" , "计划内无此包件信息" ) ;
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 ( "扫描失败" , "此码无效" ) ;
}
}
} else {
log . error ( "出现一个客户下重复库存品包件码的情况" ) ;
return Resp . scanFail ( "扫描失败" , "窜货" ) ;
}
} else {
log . error ( "出现一个客户下重复包件码的情况" ) ;
return Resp . scanFail ( "扫描失败" , "窜货" ) ;
}
return null ;
}
}
@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 )
. eq ( DistributionAddvalueDetailEntity : : getId , distributionAddvalueDetailEntity . getId ( ) )
. set ( DistributionAddvalueDetailEntity : : getFee , totalFee )
. set ( DistributionAddvalueDetailEntity : : getNum , totalNum . get ( ) )
) ;
return Resp . scanSuccess ( "添加成功" , "添加成功" ) ;
}
@ -399,7 +269,7 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
public R savePCAddvalueInfo ( DistributionAppAddvalueDTO distributionAppAddvalueDTO ) {
List < DistributionAddvaluePackageDTO > packageEntityList = new ArrayList < > ( ) ;
if ( ! Func . isEmpty ( distributionAppAddvalueDTO . getPackageEntityList ( ) ) ) {
if ( ! Func . isEmpty ( distributionAppAddvalueDTO . getPackageEntityList ( ) ) ) {
packageEntityList = distributionAppAddvalueDTO . getPackageEntityList ( ) ;
}
@ -435,24 +305,24 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
} else {
distributionAddvalueDetailEntity . setDistance ( distributionAppAddvalueDTO . getDistance ( ) ) ;
}
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFee ( ) ) ) {
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFee ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入超区费用" ) ;
} else {
} else {
totalFee = totalFee . add ( distributionAppAddvalueDTO . getFee ( ) ) ;
}
Map < String , Object > addValueDTO = new HashMap < > ( ) ;
addValueDTO . put ( "reservationId" , distributionAppAddvalueDTO . getReservationId ( ) . toString ( ) ) ;
addValueDTO . put ( "reservationId" , distributionAppAddvalueDTO . getReservationId ( ) . toString ( ) ) ;
//超区需要默认当前所有包件
List < DistributionAddvaluePackageDTO > superZoneList = distributionSignforService . checkAddValuePCPackageList ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
if ( ! Func . isEmpty ( superZoneList ) ) {
if ( ! Func . isEmpty ( superZoneList ) ) {
packageEntityList = superZoneList ;
//进行费用均摊
BigDecimal fee = distributionAppAddvalueDTO . getFee ( ) ;
if ( fee . equals ( BigDecimal . ZERO ) ) {
currencyUnitPrice = BigDecimal . ZERO ;
} else {
currencyUnitPrice = fee . divide ( BigDecimal . valueOf ( packageEntityList . size ( ) ) ) ;
}
//进行费用均摊
BigDecimal fee = distributionAppAddvalueDTO . getFee ( ) ;
if ( fee . equals ( BigDecimal . ZERO ) ) {
currencyUnitPrice = BigDecimal . ZERO ;
} else {
currencyUnitPrice = fee . divide ( BigDecimal . valueOf ( packageEntityList . size ( ) ) ) ;
}
}
break ;
case "3" :
@ -463,19 +333,19 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
}
break ;
case "6" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFee ( ) ) ) {
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFee ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入专车费用" ) ;
} else {
} else {
totalFee = totalFee . add ( distributionAppAddvalueDTO . getFee ( ) ) ;
}
List < DistributionAddvaluePackageDTO > specialCarList = distributionSignforService . checkAddValuePCPackageList ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
if ( ! Func . isEmpty ( specialCarList ) ) {
if ( ! Func . isEmpty ( specialCarList ) ) {
packageEntityList = specialCarList ;
//进行费用均摊
BigDecimal fee = distributionAppAddvalueDTO . getFee ( ) ;
if ( fee . equals ( BigDecimal . ZERO ) ) {
if ( fee . equals ( BigDecimal . ZERO ) ) {
currencyUnitPrice = BigDecimal . ZERO ;
} else {
} else {
currencyUnitPrice = fee . divide ( BigDecimal . valueOf ( packageEntityList . size ( ) ) ) ;
}
@ -524,7 +394,7 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
packageDTOList . stream ( ) . forEach ( p - > {
BigDecimal unitPrice = null ;
if ( Func . isEmpty ( addvaluePackageEntityMap . get ( p . getPackageId ( ) ) ) ) {
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFee ( ) ) ) {
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFee ( ) ) ) {
Integer conditions = p . getConditions ( ) ;
//获取结算单价
List < PriceDispatchAddClientVO > priceDispatchAddClientVOS = basicdataPriceClient . dispatchAddPrice ( BasicdatPriceApiVO . builder ( ) . clientId ( p . getClientId ( ) . toString ( ) ) . brandId ( p . getBrandId ( ) . toString ( ) ) . build ( ) ) ;
@ -542,12 +412,12 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
entity1 . setMaterielName ( p . getMaterialName ( ) ) ;
entity1 . setBrandId ( p . getBrandId ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity1 = basicdataFactoryCategoryClient . findEntityByThreeCategory ( entity1 ) ;
if ( Func . isEmpty ( factoryCategoryEntity1 ) ) {
if ( Func . isEmpty ( factoryCategoryEntity1 ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity1 ) ) {
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity1 ) ) {
//获取单价
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity1 , distributionAppAddvalueDTO ) ;
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity1 , distributionAppAddvalueDTO ) ;
}
//判定该包件是否属于该客户
List < DistributionParcelListEntity > parcelListEntities = distributionReservationMapper . selectPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
@ -561,12 +431,12 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
BasicdataFactoryCategoryEntity entity2 = new BasicdataFactoryCategoryEntity ( ) ;
entity2 . setMaterielName ( p . getMaterialName ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity2 = basicdataFactoryCategoryClient . findEntityByMaterielName ( entity2 ) ;
if ( Func . isEmpty ( factoryCategoryEntity2 ) ) {
if ( Func . isEmpty ( factoryCategoryEntity2 ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity2 ) ) {
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity2 ) ) {
//获取单价
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity2 , distributionAppAddvalueDTO ) ;
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity2 , distributionAppAddvalueDTO ) ;
}
List < DisStockListDetailEntity > detailEntities = distributionReservationMapper . selectInventoryListByReservation ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
// boolean inventoryPackageFlag = detailEntities.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));
@ -579,12 +449,12 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
BasicdataFactoryCategoryEntity entity3 = new BasicdataFactoryCategoryEntity ( ) ;
entity3 . setMaterielName ( p . getMaterialName ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity3 = basicdataFactoryCategoryClient . findEntityByCategoryName ( entity3 ) ;
if ( Func . isEmpty ( factoryCategoryEntity3 ) ) {
if ( Func . isEmpty ( factoryCategoryEntity3 ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity3 ) ) {
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity3 ) ) {
//获取单价
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity3 , distributionAppAddvalueDTO ) ;
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity3 , distributionAppAddvalueDTO ) ;
}
List < DistributionParcelNumberDTO > distributionParcelNumberDTOS = distributionReservationMapper . selectZeroPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
// boolean zeroPackageFlag = distributionParcelNumberDTOS.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));
@ -594,7 +464,7 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
}
break ;
}
} else {
} else {
unitPrice = finalCurrencyUnitPrice ;
}
p . setAddvalueDetailId ( distributionAddvalueDetailEntity . getId ( ) ) ;
@ -612,22 +482,22 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
} ) ;
if ( ! addvaluePackageEntities . isEmpty ( ) ) {
BigDecimal finalTotalFee = totalFee ;
addvaluePackageEntities . forEach ( p - > {
addvaluePackageEntities . forEach ( p - > {
finalTotalFee . add ( p . getFee ( ) ) ;
} ) ;
distributionAddvalueDetailEntity . setFee ( totalFee ) ;
distributionAddvalueDetailService . updateById ( distributionAddvalueDetailEntity ) ;
distributionAddvaluePackageService . saveBatch ( addvaluePackageEntities ) ;
return Resp . scanSuccess ( "添加成功" , "添加成功" ) ;
} else {
} else {
return Resp . scanFail ( "添加失败" , "添加失败" ) ;
}
}
private List < DistributionAddvaluePackageDTO > handleAddvaluePackageEntity ( List < DistributionAddvaluePackageVO > records ) {
List < DistributionAddvaluePackageDTO > packageDTOList = new ArrayList < > ( ) ;
records . forEach ( r - > {
List < DistributionAddvaluePackageDTO > packageDTOList = new ArrayList < > ( ) ;
records . forEach ( r - > {
DistributionAddvaluePackageDTO dto = Func . copy ( r , DistributionAddvaluePackageDTO . class ) ;
packageDTOList . add ( dto ) ;
@ -639,19 +509,19 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
List < PriceDispatchAddClientVO > collect = priceDispatchAddClientVOS . stream ( ) . filter ( f - > f . getCategoryId ( ) . equals ( factoryCategoryEntity . getId ( ) ) ) . collect ( Collectors . toList ( ) ) ;
BigDecimal unitPrice = null ;
if ( ! collect . isEmpty ( ) ) {
if ( collect . size ( ) > 1 ) {
log . info ( "存在多个相同分类的单价CategoryId:{}" , factoryCategoryEntity . getId ( ) ) ;
if ( ! collect . isEmpty ( ) ) {
if ( collect . size ( ) > 1 ) {
log . info ( "存在多个相同分类的单价CategoryId:{}" , factoryCategoryEntity . getId ( ) ) ;
}
PriceDispatchAddClientVO priceDispatchAddClientVO = collect . get ( 0 ) ;
switch ( distributionAppAddvalueDTO . getAddvalueType ( ) ) {
switch ( distributionAppAddvalueDTO . getAddvalueType ( ) ) {
case "1" :
//获取上楼费用
//比对是否超过了楼层
if ( priceDispatchAddClientVO . getDispatchStairsCarryingCharge ( ) > = distributionAppAddvalueDTO . getFloolNum ( ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
} else {
} else {
unitPrice = BigDecimal . valueOf ( priceDispatchAddClientVO . getUpstairsDeliveryPrice ( ) ) ;
}
break ;
@ -672,56 +542,139 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
unitPrice = BigDecimal . valueOf ( priceDispatchAddClientVO . getSortPrice ( ) ) ;
break ;
default :
log . info ( ">>>>>>>>>>>>>>对应客户未进行单价维护:{}" , priceDispatchAddClientVO . getCategoryId ( ) ) ;
log . info ( ">>>>>>>>>>>>>>对应客户未进行单价维护:{}" , priceDispatchAddClientVO . getCategoryId ( ) ) ;
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
break ;
}
} else {
} else {
return BigDecimal . ZERO ;
}
return unitPrice ;
}
@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 ( ) ) ;
}
} ) ;
}
parcelListEntities . addAll ( detailEntities ) ;
parcelListEntities . addAll ( zeroPackageList ) ;
if ( Func . isEmpty ( parcelListEntities ) ) {
log . error ( "################该客户下包件信息:{}" , parcelListEntities ) ;
log . error ( "################该客户下库存品包件信息:{}" , detailEntities ) ;
// return R.fail("服务器正忙....");
if ( Objects . isNull ( distributionAppAddvalueDTO . getReservationId ( ) ) ) {
log . error ( method + "参数缺失ReservationId" ) ;
return null ;
}
if ( Func . isNotEmpty ( parcelListEntities ) ) {
parcelListEntities . stream ( ) . forEach ( p - > {
p . setRecordType ( "1" ) ;
//进行客户信息完善
} ) ;
}
if ( Func . isNotEmpty ( zeroPackageList ) ) {
zeroPackageList . stream ( ) . forEach ( p - > {
p . setRecordType ( "1" ) ;
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 ) ;
}
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 ;
}
s . setUnitPrice ( unitPrice . get ( ) ) ;
} ) ;
}
return parcelListEntities ;
return superZoneList ;
}
@Override
@ -908,16 +861,16 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
@Transactional
public R cancelSignAddValuePackage ( DistributionAppAddvalueDTO distributionAppAddvalueDTO ) {
List < DistributionAddvaluePackageDTO > packageEntityList = new ArrayList < > ( ) ;
if ( distributionAppAddvalueDTO . getAddvalueType ( ) . equals ( "2" ) | | distributionAppAddvalueDTO . getAddvalueType ( ) . equals ( "6" ) ) {
if ( distributionAppAddvalueDTO . getAddvalueType ( ) . equals ( "2" ) | | distributionAppAddvalueDTO . getAddvalueType ( ) . equals ( "6" ) ) {
//专车和超区进行全部包件查询
Map < String , Object > addValueDTO = new HashMap < > ( ) ;
addValueDTO . put ( "reservationId" , distributionAppAddvalueDTO . getReservationId ( ) . toString ( ) ) ;
addValueDTO . put ( "reservationId" , distributionAppAddvalueDTO . getReservationId ( ) . toString ( ) ) ;
//超区需要默认当前所有包件
List < DistributionAddvaluePackageDTO > superZoneList = distributionSignforService . checkAddValuePCPackageList ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
if ( ! superZoneList . isEmpty ( ) ) {
packageEntityList = superZoneList ;
}
} else {
} else {
packageEntityList = distributionAppAddvalueDTO . getPackageEntityList ( ) ;
}
if ( Func . isEmpty ( packageEntityList ) ) {
@ -925,12 +878,12 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
}
//查询增值服务详情
DistributionAddvalueDetailEntity distributionAddvalueDetailEntity = distributionAddvalueDetailMapper . selectById ( distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ;
if ( Func . isEmpty ( distributionAddvalueDetailEntity ) ) {
log . error ( "################查询增值服务详情错误id:{}" , distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ;
if ( Func . isEmpty ( distributionAddvalueDetailEntity ) ) {
log . error ( "################查询增值服务详情错误id:{}" , distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ;
}
DistributionAddvalueEntity addvalueEntity = this . getById ( distributionAddvalueDetailEntity . getAddvalueId ( ) ) ;
if ( Func . isEmpty ( addvalueEntity ) ) {
log . error ( "################查询增值服务错误id:{}" , distributionAddvalueDetailEntity . getAddvalueId ( ) ) ;
if ( Func . isEmpty ( addvalueEntity ) ) {
log . error ( "################查询增值服务错误id:{}" , distributionAddvalueDetailEntity . getAddvalueId ( ) ) ;
}
AtomicReference < BigDecimal > newFee = new AtomicReference < > ( BigDecimal . ZERO ) ;
List < Long > packageIds = packageEntityList . stream ( ) . map ( DistributionAddvaluePackageDTO : : getPackageId ) . collect ( Collectors . toList ( ) ) ;
@ -944,8 +897,8 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
) ;
if ( ! addvaluePackageEntities . isEmpty ( ) ) {
List < DistributionAddvaluePackageEntity > entityList = addvaluePackageEntities . stream ( ) . filter ( f - > packageIds . contains ( f . getPackageId ( ) ) ) . collect ( Collectors . toList ( ) ) ;
entityList . forEach ( l - > {
newFee . set ( distributionAddvalueDetailEntity . getFee ( ) . subtract ( l . getUnitPrice ( ) ) ) ;
entityList . forEach ( l - > {
newFee . set ( distributionAddvalueDetailEntity . getFee ( ) . subtract ( l . getUnitPrice ( ) ) ) ;
} ) ;
}
@ -956,22 +909,22 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
distributionAddvalueDetailEntity . setNum ( distributionAddvalueDetailEntity . getNum ( ) - sum ) ;
distributionAddvalueDetailMapper . updateById ( distributionAddvalueDetailEntity ) ;
if ( Objects . equals ( packageIds . size ( ) , addvaluePackageEntities . size ( ) ) ) {
if ( Objects . equals ( packageIds . size ( ) , addvaluePackageEntities . size ( ) ) ) {
//此增值服务项进行全部取消
//这里就需要对整个增值服务项进行删除
distributionAddvalueDetailMapper . deleteAddvalueDetailById ( distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ;
distributionAddvalueMapper . deleteAddvalue ( distributionAppAddvalueDTO . getReservationId ( ) , distributionAppAddvalueDTO . getAddvalueType ( ) ) ;
}
//查看取消增值服务的保健是否存在该项增值服务中,存在才能继续执行
boolean isExistence = packageIds . stream ( ) . allMatch ( id - > addvaluePackageEntities . stream ( ) . map ( DistributionAddvaluePackageEntity : : getPackageId ) . collect ( Collectors . toList ( ) ) . contains ( id ) ) ;
if ( isExistence ) {
packageIds . forEach ( id - > {
distributionAddvaluePackageMapper . deleteAddvaluePackageByDetailId ( distributionAppAddvalueDTO . getReservationId ( ) , id , distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ;
} ) ;
} else {
log . error ( "###########该包件不存在增值服务项包件列表中" ) ;
return R . fail ( "取消包件失败,该包件不存在增值服务项列表中" ) ;
}
//查看取消增值服务的保健是否存在该项增值服务中,存在才能继续执行
boolean isExistence = packageIds . stream ( ) . allMatch ( id - > addvaluePackageEntities . stream ( ) . map ( DistributionAddvaluePackageEntity : : getPackageId ) . collect ( Collectors . toList ( ) ) . contains ( id ) ) ;
if ( isExistence ) {
packageIds . forEach ( id - > {
distributionAddvaluePackageMapper . deleteAddvaluePackageByDetailId ( distributionAppAddvalueDTO . getReservationId ( ) , id , distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ;
} ) ;
} else {
log . error ( "###########该包件不存在增值服务项包件列表中" ) ;
return R . fail ( "取消包件失败,该包件不存在增值服务项列表中" ) ;
}
return R . success ( "操作成功" ) ;
@ -1048,13 +1001,13 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
increasePackage . forEach ( ip - > {
if ( Func . isNotEmpty ( packageDTOMap . get ( ip ) ) ) {
//新增包件
BigDecimal unitPrice = null ;
BigDecimal unitPrice = null ;
//计算包件单价
DistributionAddvaluePackageDTO distributionAddvaluePackageDTO = packageDTOMap . get ( ip ) ;
List < PriceDispatchAddClientVO > priceDispatchAddClientVOS = basicdataPriceClient . dispatchAddPrice ( BasicdatPriceApiVO . builder ( ) . clientId ( distributionAddvaluePackageDTO . getClientId ( ) . toString ( ) ) . brandId ( distributionAddvaluePackageDTO . getClientId ( ) . toString ( ) ) . build ( ) ) ;
//查询价格模板
if ( Func . isEmpty ( priceDispatchAddClientVOS ) ) {
if ( Func . isEmpty ( priceDispatchAddClientVOS ) ) {
unitPrice = BigDecimal . ZERO ;
}
DistributionAddvaluePackageDTO dto = packageDTOMap . get ( ip ) ;
@ -1068,12 +1021,12 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
entity1 . setMaterielName ( dto . getMaterialName ( ) ) ;
entity1 . setBrandId ( dto . getBrandId ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity1 = basicdataFactoryCategoryClient . findEntityByThreeCategory ( entity1 ) ;
if ( Func . isEmpty ( factoryCategoryEntity1 ) ) {
if ( Func . isEmpty ( factoryCategoryEntity1 ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity1 ) ) {
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity1 ) ) {
//获取单价
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity1 , distributionAppAddvalueDTO ) ;
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity1 , distributionAppAddvalueDTO ) ;
}
//判定该包件是否属于该客户
List < DistributionParcelListEntity > parcelListEntities = distributionReservationMapper . selectPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
@ -1087,12 +1040,12 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
BasicdataFactoryCategoryEntity entity2 = new BasicdataFactoryCategoryEntity ( ) ;
entity2 . setMaterielName ( dto . getMaterialName ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity2 = basicdataFactoryCategoryClient . findEntityByMaterielName ( entity2 ) ;
if ( Func . isEmpty ( factoryCategoryEntity2 ) ) {
if ( Func . isEmpty ( factoryCategoryEntity2 ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity2 ) ) {
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity2 ) ) {
//获取单价
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity2 , distributionAppAddvalueDTO ) ;
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity2 , distributionAppAddvalueDTO ) ;
}
List < DisStockListDetailEntity > detailEntities = distributionReservationMapper . selectInventoryListByReservation ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
boolean inventoryPackageFlag = detailEntities . stream ( ) . map ( DisStockListDetailEntity : : getId ) . collect ( Collectors . toList ( ) ) . contains ( dto . getPackageId ( ) ) ;
@ -1104,12 +1057,12 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
BasicdataFactoryCategoryEntity entity3 = new BasicdataFactoryCategoryEntity ( ) ;
entity3 . setMaterielName ( dto . getMaterialName ( ) ) ;
BasicdataFactoryCategoryEntity factoryCategoryEntity3 = basicdataFactoryCategoryClient . findEntityByCategoryName ( entity3 ) ;
if ( Func . isEmpty ( factoryCategoryEntity3 ) ) {
if ( Func . isEmpty ( factoryCategoryEntity3 ) ) {
unitPrice = new BigDecimal ( BigInteger . ZERO ) ;
}
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity3 ) ) {
if ( ! Func . isEmpty ( priceDispatchAddClientVOS ) & & Func . isNotEmpty ( factoryCategoryEntity3 ) ) {
//获取单价
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity3 , distributionAppAddvalueDTO ) ;
unitPrice = getUnitPrice ( priceDispatchAddClientVOS , factoryCategoryEntity3 , distributionAppAddvalueDTO ) ;
}
List < DistributionParcelNumberDTO > distributionParcelNumberDTOS = distributionReservationMapper . selectZeroPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
// boolean zeroPackageFlag = distributionParcelNumberDTOS.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));