@ -189,13 +189,14 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
}
@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 ( "操作失败" , "无可用包件信息" ) ;
if ( Func . isEmpty ( packageDTOList ) ) {
return Resp . scanFail ( "操作失败" , "无可用包件信息" ) ;
}
//查询是否重复添加
DistributionAddvalueEntity addvalueEntity = distributionAddvalueMapper . selectOne ( Wrappers . < DistributionAddvalueEntity > query ( ) . lambda ( )
@ -203,17 +204,17 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
. eq ( DistributionAddvalueEntity : : getRefId , distributionAppAddvalueDTO . getReservationId ( ) )
. eq ( DistributionAddvalueEntity : : getRefType , 1 ) ) ;
if ( Func . isNotEmpty ( addvalueEntity ) ) {
if ( Func . isNotEmpty ( addvalueEntity ) ) {
return Resp . scanFail ( "操作失败" , "存在该类型增值服务项,如需更改请编辑" ) ;
}
DistributionAddvalueDetailEntity distributionAddvalueDetailEntity = new DistributionAddvalueDetailEntity ( ) ;
if ( Func . isEmpty ( distributionAppAddvalueDTO . getNum ( ) ) ) {
return Resp . scanFail ( "添加失败" , "错误的包件数量" ) ;
} else {
} else {
distributionAddvalueDetailEntity . setNum ( distributionAppAddvalueDTO . getNum ( ) ) ;
}
DistributionReservationEntity reservationEntity = distributionReservationMapper . selectById ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
if ( Func . isEmpty ( reservationEntity ) ) {
if ( Func . isEmpty ( reservationEntity ) ) {
return Resp . scanFail ( "添加失败" , "客户信息错误" ) ;
}
// 上楼 超区 平移 搬运 分拣 专车
@ -244,7 +245,7 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
if ( Func . isEmpty ( distributionAppAddvalueDTO . getNum ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入件数" ) ;
} else {
distributionAddvalueDetailEntity . setNum ( packageEntityList . stream ( ) . mapToInt ( DistributionAddvaluePackageDTO : : getQuantity ) . sum ( ) ) ;
distributionAddvalueDetailEntity . setNum ( packageEntityList . stream ( ) . mapToInt ( DistributionAddvaluePackageEntity : : getQuantity ) . sum ( ) ) ;
}
break ;
case "6" :
@ -263,13 +264,116 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
distributionAddvalueEntity . setRefType ( 1 ) ;
distributionAddvalueEntity . setRefId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
distributionAddvalueEntity . setDeliveryListId ( distributionAppAddvalueDTO . getDeliveryId ( ) ) ;
this . save ( distributionAddvalueEntity ) ;
distributionAddvalueDetailEntity . setAddvalueId ( distributionAddvalueEntity . getId ( ) ) ;
distributionAddvalueDetailEntity . setRecordType ( 2 ) ;
List < DistributionParcelListEntity > parcelListEntities = distributionReservationMapper . selectPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
if ( parcelListEntities . size ( ) = = packageEntityList . size ( ) ) {
distributionAddvalueDetailEntity . setRecordType ( 1 ) ;
}
distributionAddvalueDetailService . save ( distributionAddvalueDetailEntity ) ;
List < DistributionAddvaluePackageEntity > addvaluePackageEntities = new ArrayList < > ( ) ;
packageEntityList . stream ( ) . forEach ( p - > { p . setAddvalueDetailId ( distributionAddvalueDetailEntity . getId ( ) ) ; p . setQuantity ( p . getZeroQuantity ( ) ) ; addvaluePackageEntities . add ( Func . copy ( p , DistributionAddvaluePackageEntity . class ) ) ; } ) ;
distributionAddvaluePackageService . saveBatch ( addvaluePackageEntities ) ;
return Resp . scanSuccess ( "添加成功" , "添加成功" ) ;
}
@Override
@Transactional
public R savePCAddvalueInfo ( 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 ( ) )
. eq ( DistributionAddvalueEntity : : getRefId , distributionAppAddvalueDTO . getReservationId ( ) )
. eq ( DistributionAddvalueEntity : : getRefType , 1 ) ) ;
if ( Func . isNotEmpty ( addvalueEntity ) ) {
return Resp . scanFail ( "操作失败" , "存在该类型增值服务项,如需更改请编辑" ) ;
}
DistributionAddvalueDetailEntity distributionAddvalueDetailEntity = new DistributionAddvalueDetailEntity ( ) ;
// if (Func.isEmpty(distributionAppAddvalueDTO.getNum())) {
// return Resp.scanFail("添加失败", "错误的包件数量");
// } else {
// distributionAddvalueDetailEntity.setNum(distributionAppAddvalueDTO.getNum());
// }
DistributionReservationEntity reservationEntity = distributionReservationMapper . selectById ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
if ( Func . isEmpty ( reservationEntity ) ) {
return Resp . scanFail ( "添加失败" , "客户信息错误" ) ;
}
// 上楼 超区 平移 搬运 分拣 专车
switch ( distributionAppAddvalueDTO . getAddvalueType ( ) ) {
case "1" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFloolNum ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入楼层数" ) ;
} else {
distributionAddvalueDetailEntity . setFloolNum ( distributionAppAddvalueDTO . getFloolNum ( ) ) ;
}
break ;
case "2" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getDistance ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入超区公里数" ) ;
} else {
distributionAddvalueDetailEntity . setDistance ( distributionAppAddvalueDTO . getDistance ( ) ) ;
}
break ;
case "3" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getDistance ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入平移距离" ) ;
} else {
distributionAddvalueDetailEntity . setDistance ( distributionAppAddvalueDTO . getDistance ( ) ) ;
}
break ;
// case "4":
// case "5":
// if (Func.isEmpty(distributionAppAddvalueDTO.getNum())) {
// return Resp.scanFail("添加失败", "请输入件数");
// } else {
// distributionAddvalueDetailEntity.setNum(packageEntityList.stream().mapToInt(DistributionAddvaluePackageDTO::getQuantity).sum());
// }
// break;
// case "6":
// if (Func.isEmpty(distributionAppAddvalueDTO.getFee())) {
// return Resp.scanFail("添加失败", "请输入件数");
// } else {
// distributionAddvalueDetailEntity.setFee(distributionAppAddvalueDTO.getFee());
// }
// break;
default :
return Resp . scanFail ( "添加失败" , "服务器正忙" ) ;
}
int total = packageEntityList . stream ( ) . mapToInt ( DistributionAddvaluePackageDTO : : getQuantity ) . sum ( ) ;
if ( total = = 0 ) {
return Resp . scanFail ( "添加失败" , "包件数量错误" ) ;
} else {
distributionAddvalueDetailEntity . setNum ( packageEntityList . stream ( ) . mapToInt ( DistributionAddvaluePackageDTO : : getQuantity ) . sum ( ) ) ;
}
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFee ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入费用" ) ;
} else {
distributionAddvalueDetailEntity . setFee ( distributionAppAddvalueDTO . getFee ( ) ) ;
}
DistributionAddvalueEntity distributionAddvalueEntity = new DistributionAddvalueEntity ( ) ;
distributionAddvalueEntity . setAddvalueId ( distributionAppAddvalueDTO . getAddvalueType ( ) ) ;
distributionAddvalueEntity . setCode ( reservationEntity . getReservationCode ( ) ) ;
distributionAddvalueEntity . setRefType ( 1 ) ;
distributionAddvalueEntity . setRefId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
distributionAddvalueEntity . setDeliveryListId ( distributionAppAddvalueDTO . getDeliveryId ( ) ) ;
distributionAddvalueEntity . setWarehouseId ( reservationEntity . getWarehouseId ( ) ) ;
distributionAddvalueEntity . setWarehouseName ( reservationEntity . getWarehouseName ( ) ) ;
this . save ( distributionAddvalueEntity ) ;
distributionAddvalueDetailEntity . setAddvalueId ( distributionAddvalueEntity . getId ( ) ) ;
distributionAddvalueDetailEntity . setRecordType ( 2 ) ;
// List<DistributionParcelListEntity> parcelListEntities = distributionReservationMapper.selectPackageListByReservationId(distributionAppAddvalueDTO.getReservationId());
if ( reservationEntity . getReservationNum ( ) + reservationEntity . getReservationStockListNum ( ) = = packageEntityList . size ( ) ) {
if ( reservationEntity . getReservationNum ( ) + reservationEntity . getReservationStockListNum ( ) = = packageEntityList . size ( ) ) {
distributionAddvalueDetailEntity . setRecordType ( 1 ) ;
}
distributionAddvalueDetailService . save ( distributionAddvalueDetailEntity ) ;
@ -283,28 +387,36 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
case 1 :
//判定该包件是否属于该客户
List < DistributionParcelListEntity > parcelListEntities = distributionReservationMapper . selectPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
boolean packageFlag = parcelListEntities . stream ( ) . allMatch ( pack - > ! Func . equals ( pack . getId ( ) , p . getPackageId ( ) ) ) ;
if ( packageFlag ) {
// boolean packageFlag = parcelListEntities.stream().allMatch(pack -> !Func.equals(pack.getId(), p.getPackageId()));
boolean packageFlag = parcelListEntities . stream ( ) . map ( DistributionParcelListEntity : : getId ) . collect ( Collectors . toList ( ) ) . contains ( p . getPackageId ( ) ) ;
if ( ! packageFlag ) {
throw new RuntimeException ( "不属于该客户包件" ) ;
}
break ;
case 2 :
List < DistributionParcelNumberDTO > distributionParcelNumberDTOS = distributionReservationMapper . selectZeroPackageListByReservationId ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
boolean zeroPackageFlag = distributionParcelNumberDTOS . stream ( ) . allMatch ( pack - > ! Func . equals ( pack . getId ( ) , p . getPackageId ( ) ) ) ;
if ( zeroPackageFlag ) {
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 :
List < DisStockListDetailEntity > detailEntities = distributionReservationMapper . selectInventoryListByReservation ( distributionAppAddvalueDTO . getReservationId ( ) ) ;
boolean inventoryPackageFlag = detailEntities . stream ( ) . allMatch ( pack - > ! Func . equals ( pack . getId ( ) , p . getPackageId ( ) ) ) ;
if ( inventoryPackageFlag ) {
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 ;
}
p . setAddvalueDetailId ( distributionAddvalueDetailEntity . getId ( ) ) ;
addvaluePackageEntities . add ( Func . copy ( p , DistributionAddvaluePackageEntity . class ) ) ;
DistributionAddvaluePackageEntity addvaluePackageEntity = Func . copy ( p , DistributionAddvaluePackageEntity . class ) ;
if ( Func . isNotEmpty ( p . getZeroQuantity ( ) ) ) {
addvaluePackageEntity . setQuantity ( p . getZeroQuantity ( ) ) ;
}
addvaluePackageEntities . add ( addvaluePackageEntity ) ;
}
} ) ;
distributionAddvaluePackageService . saveBatch ( addvaluePackageEntities ) ;
@ -552,13 +664,20 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
. eq ( DistributionAddvaluePackageEntity : : getReservationId , distributionAppAddvalueDTO . getReservationId ( ) )
. eq ( DistributionAddvaluePackageEntity : : getAddvalueDetailId , distributionAppAddvalueDTO . getAddvalueDetailId ( ) )
) ;
packageIds . forEach ( id - > {
distributionAddvaluePackageMapper . deleteAddvaluePackage ( distributionAppAddvalueDTO . getReservationId ( ) , id ) ;
} ) ;
if ( packageIds . size ( ) = = addvaluePackageEntities . size ( ) ) {
//这里就需要对整个增值服务项进行删除
distributionAddvalueDetailMapper . deleteAddvalueDetail ( 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 ) {
if ( packageIds . size ( ) = = addvaluePackageEntities . size ( ) ) {
//这里就需要对整个增值服务项进行删除
distributionAddvalueDetailMapper . deleteAddvalueDetailById ( distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ;
distributionAddvalueMapper . deleteAddvalue ( distributionAppAddvalueDTO . getReservationId ( ) , distributionAppAddvalueDTO . getAddvalueType ( ) ) ;
}
packageIds . forEach ( id - > {
distributionAddvaluePackageMapper . deleteAddvaluePackage ( distributionAppAddvalueDTO . getReservationId ( ) , id ) ;
} ) ;
} else {
log . error ( "###########该包件不存在增值服务项包件列表中" ) ;
return R . fail ( "取消包件失败,该包件不存在增值服务项列表中" ) ;
}
return R . success ( "操作成功" ) ;
}
@ -566,117 +685,207 @@ public class DistributionAddvalueServiceImpl extends BaseServiceImpl<Distributio
@Override
public R updatePCAddvalueInfo ( DistributionAppAddvalueDTO distributionAppAddvalueDTO ) {
List < DistributionAddvaluePackageDTO > packageEntityList = distributionAppAddvalueDTO . getPackageEntityList ( ) ;
if ( Func . isEmpty ( packageEntityList ) ) {
if ( Func . isEmpty ( packageEntityList ) ) {
return R . fail ( "无包件信息" ) ;
}
Map < Long , DistributionAddvaluePackageDTO > packageDTOMap = packageEntityList . stream ( ) . collect ( Collectors . toMap ( DistributionAddvaluePackageDTO : : getPackageId , Function . identity ( ) , ( k1 , k2 ) - > k2 ) ) ;
List < Long > zeroPackageIds = packageEntityList . stream ( ) . filter ( p - > p . getConditions ( ) = = 3 ) . collect ( Collectors . toList ( ) ) . stream ( ) . map ( DistributionAddvaluePackageDTO : : getPackageId ) . collect ( Collectors . toList ( ) ) ;
//这里需要查询出原来的增值服务项详情
DistributionAddvalueDetailEntity detailEntity = distributionAddvalueDetailMapper . selectById ( distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ;
if ( Func . isEmpty ( detailEntity ) ) {
log . error ( "###########查询增值服务详情错误:{}" , detailEntity ) ;
log . error ( "###########AddvalueDetailId>>>>>>>>>>>>>>>>>>>>>>>>>>>:{}" , detailEntity ) ;
return R . fail ( "服务器正忙............" ) ;
}
String addvalueType = distributionAppAddvalueDTO . getAddvalueType ( ) ;
switch ( addvalueType ) {
case "1" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFloolNum ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入楼层数" ) ;
} else {
detailEntity . setFloolNum ( distributionAppAddvalueDTO . getFloolNum ( ) ) ;
}
break ;
case "2" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getDistance ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入超区公里数" ) ;
} else {
detailEntity . setDistance ( distributionAppAddvalueDTO . getDistance ( ) ) ;
}
break ;
case "3" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getDistance ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入平移距离" ) ;
} else {
detailEntity . setDistance ( distributionAppAddvalueDTO . getDistance ( ) ) ;
}
break ;
case "4" :
case "5" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getNum ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入件数" ) ;
} else {
detailEntity . setNum ( distributionAppAddvalueDTO . getNum ( ) ) ;
}
break ;
case "6" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFee ( ) ) ) {
return Resp . scanFail ( "添加失败" , "错误的包件数量" ) ;
} else {
detailEntity . setFee ( distributionAppAddvalueDTO . getFee ( ) ) ;
}
break ;
default :
return Resp . scanFail ( "添加失败" , "服务器正忙" ) ;
//查询出对应所有增值服务项的包件信息
List < DistributionAddvaluePackageEntity > addvaluePackageEntities = distributionAddvaluePackageMapper . selectList ( Wrappers . < DistributionAddvaluePackageEntity > query ( ) . lambda ( )
. eq ( DistributionAddvaluePackageEntity : : getReservationId , distributionAppAddvalueDTO . getReservationId ( ) )
. eq ( DistributionAddvaluePackageEntity : : getAddvalueDetailId , distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ) ;
List < Long > increasePackage = packageEntityList . stream ( )
. map ( DistributionAddvaluePackageDTO : : getPackageId )
. filter ( p - > ! addvaluePackageEntities . stream ( )
. map ( DistributionAddvaluePackageEntity : : getPackageId )
. collect ( Collectors . toList ( ) ) . contains ( p ) )
. collect ( Collectors . toList ( ) ) ;
if ( Func . isNotEmpty ( zeroPackageIds ) ) {
increasePackage . addAll ( zeroPackageIds ) ;
}
distributionAddvalueDetailMapper . updateById ( detailEntity ) ;
//查询出原来的包件信息
DistributionAddvalueVO addvalueVO = distributionAddvalueMapper . selectReservationAddvalue ( distributionAppAddvalueDTO . getReservationId ( ) , addvalueType ) ;
String packageListIds = addvalueVO . getPackageListIds ( ) ;
if ( Func . isEmpty ( packageListIds ) ) {
log . error ( "##############查询增值服务包件列表DI错误:{}" , packageListIds ) ;
if ( increasePackage . size ( ) = = 0 ) {
//添加包件都已经存在在增值服务列表
return Resp . scanFail ( "添加失败" , "包件已存在" ) ;
}
List < DistributionAddvaluePackageEntity > distributionAddvaluePackageEntities = distributionAddvaluePackageService . list ( Wrappers . < DistributionAddvaluePackageEntity > query ( ) . lambda ( )
. in ( DistributionAddvaluePackageEntity : : getPackageId , Func . toLongList ( packageListIds ) )
. eq ( DistributionAddvaluePackageEntity : : getAddvalueDetailId , distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ) ;
Map < Long , List < DistributionAddvaluePackageEntity > > oldPackageList = distributionAddvaluePackageEntities . stream ( ) . collect ( Collectors . groupingBy ( DistributionAddvaluePackageEntity : : getPackageId ) ) ;
Map < Long , List < DistributionAddvaluePackageDTO > > newPackageList = packageEntityList . stream ( ) . collect ( Collectors . groupingBy ( DistributionAddvaluePackageEntity : : getPackageId ) ) ;
newPackageList . forEach ( ( k , v ) - > {
DistributionAddvaluePackageDTO distributionAddvaluePackageEntity = v . get ( 0 ) ;
//只要不存在与就是新增,这里PC操作是一个包件累加操作,如果已经存在列表之中那么不进行添加
if ( Func . isEmpty ( oldPackageList . get ( k ) ) ) {
//从老的包件中无法进行获取,这里进行包件的新增
DistributionAddvaluePackageEntity addvaluePackageEntity = new DistributionAddvaluePackageEntity ( ) ;
addvaluePackageEntity . setQuantity ( distributionAddvaluePackageEntity . getZeroQuantity ( ) ) ;
addvaluePackageEntity . setAddvalueDetailId ( distributionAddvaluePackageEntity . getAddvalueDetailId ( ) ) ;
addvaluePackageEntity . setStockArticleId ( distributionAddvaluePackageEntity . getStockArticleId ( ) ) ;
addvaluePackageEntity . setMaterialName ( distributionAddvaluePackageEntity . getMaterialName ( ) ) ;
addvaluePackageEntity . setPackageId ( distributionAddvaluePackageEntity . getPackageId ( ) ) ;
addvaluePackageEntity . setReservationId ( distributionAddvaluePackageEntity . getReservationId ( ) ) ;
if ( distributionAddvaluePackageEntity . getConditions ( ) = = 3 ) {
addvaluePackageEntity . setConditions ( 3 ) ;
addvaluePackageEntity . setRecordType ( "3" ) ;
distributionAddvaluePackageService . save ( addvaluePackageEntity ) ;
} else if ( distributionAddvaluePackageEntity . getConditions ( ) = = 1 ) {
//新增订制品
addvaluePackageEntity . setOrderPackageCode ( distributionAddvaluePackageEntity . getOrderPackageCode ( ) ) ;
addvaluePackageEntity . setRecordType ( "1" ) ;
addvaluePackageEntity . setConditions ( 1 ) ;
} else {
//新增库存品
addvaluePackageEntity . setOrderPackageCode ( distributionAddvaluePackageEntity . getOrderPackageCode ( ) ) ;
addvaluePackageEntity . setRecordType ( "2" ) ;
addvaluePackageEntity . setConditions ( 2 ) ;
}
// distributionAddvaluePackageEntity.setAddvalueDetailId(distributionAddvaluePackageEntities.get(0).getAddvalueDetailId());
distributionAddvaluePackageService . save ( addvaluePackageEntity ) ;
} else {
if ( distributionAddvaluePackageEntity . getConditions ( ) = = 3 ) {
if ( distributionAddvaluePackageEntity . getZeroQuantity ( ) ! = 0 ) {
if ( distributionAddvaluePackageEntity . getZeroQuantity ( ) > 0 ) {
distributionAddvaluePackageEntity . setQuantity ( distributionAddvaluePackageEntity . getZeroQuantity ( ) ) ;
distributionAddvaluePackageService . updateById ( distributionAddvaluePackageEntity ) ;
} else {
log . error ( "###############零担品类录入数量有误:{}" , distributionAddvaluePackageEntity . getZeroQuantity ( ) ) ;
if ( increasePackage . size ( ) > 0 ) {
//统计该项增值服务包件数量
int num = detailEntity . getNum ( ) + increasePackage . size ( ) ;
detailEntity . setNum ( num ) ;
switch ( distributionAppAddvalueDTO . getAddvalueType ( ) ) {
case "1" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getFloolNum ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入楼层数" ) ;
} else {
detailEntity . setFloolNum ( distributionAppAddvalueDTO . getFloolNum ( ) ) ;
}
break ;
case "2" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getDistance ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入超区公里数" ) ;
} else {
detailEntity . setDistance ( distributionAppAddvalueDTO . getDistance ( ) ) ;
}
break ;
case "3" :
if ( Func . isEmpty ( distributionAppAddvalueDTO . getDistance ( ) ) ) {
return Resp . scanFail ( "添加失败" , "请输入平移距离" ) ;
} else {
detailEntity . setDistance ( distributionAppAddvalueDTO . getDistance ( ) ) ;
}
break ;
// case "4":
// case "5":
// if (Func.isEmpty(distributionAppAddvalueDTO.getNum())) {
// return Resp.scanFail("添加失败", "请输入件数");
// } else {
// detailEntity.setNum(num);
// }
// break;
// case "6":
// if (Func.isEmpty(distributionAppAddvalueDTO.getFee())) {
// return Resp.scanFail("添加失败", "错误的包件数量");
// } else {
// detailEntity.setFee(distributionAppAddvalueDTO.getFee());
// }
// break;
default :
return Resp . scanFail ( "添加失败" , "服务器正忙" ) ;
}
detailEntity . setFee ( distributionAppAddvalueDTO . getFee ( ) ) ;
detailEntity . setNum ( num ) ;
distributionAddvalueDetailMapper . updateById ( detailEntity ) ;
//添加新的包件信息
increasePackage . forEach ( ip - > {
if ( Func . isNotEmpty ( packageDTOMap . get ( ip ) ) ) {
//新增包件
DistributionAddvaluePackageDTO distributionAddvaluePackageDTO = packageDTOMap . get ( ip ) ;
DistributionAddvaluePackageEntity distributionAddvaluePackageEntity = distributionAddvaluePackageMapper . selectOne ( Wrappers . < DistributionAddvaluePackageEntity > query ( ) . lambda ( )
. eq ( DistributionAddvaluePackageEntity : : getReservationId , distributionAddvaluePackageDTO . getReservationId ( ) )
. eq ( DistributionAddvaluePackageEntity : : getPackageId , distributionAddvaluePackageDTO . getPackageId ( ) )
. eq ( DistributionAddvaluePackageEntity : : getAddvalueDetailId , distributionAddvaluePackageDTO . getAddvalueDetailId ( ) )
. eq ( DistributionAddvaluePackageEntity : : getStockArticleId , distributionAddvaluePackageDTO . getStockArticleId ( ) )
) ;
if ( distributionAddvaluePackageDTO . getConditions ( ) = = 3 ) {
if ( Func . isEmpty ( distributionAddvaluePackageEntity ) ) {
//新增零担
// DistributionAddvaluePackageEntity zeroAddvaluePackageEntity = new DistributionAddvaluePackageEntity();
if ( distributionAddvaluePackageDTO . getZeroQuantity ( ) > 0 ) {
DistributionAddvaluePackageEntity zeroAddvaluePackageEntity = Func . copy ( distributionAddvaluePackageDTO , DistributionAddvaluePackageEntity . class ) ;
distributionAddvaluePackageEntity . setQuantity ( distributionAddvaluePackageDTO . getZeroQuantity ( ) ) ;
distributionAddvaluePackageService . updateById ( zeroAddvaluePackageEntity ) ;
} else {
log . error ( "###############零担品类录入数量0:{}" , distributionAddvaluePackageDTO . getPackageId ( ) ) ;
}
} else {
if ( distributionAddvaluePackageDTO . getZeroQuantity ( ) > 0 ) {
distributionAddvaluePackageEntity . setQuantity ( distributionAddvaluePackageDTO . getZeroQuantity ( ) ) ;
distributionAddvaluePackageService . updateById ( distributionAddvaluePackageEntity ) ;
} else {
log . error ( "###############零担品类录入数量0:{}" , distributionAddvaluePackageDTO . getPackageId ( ) ) ;
}
}
} else {
//删除对应的包件信息
distributionAddvaluePackageMapper . deleteAddvaluePackage ( distributionAddvaluePackageEntity . getReservationId ( ) , distributionAddvaluePackageEntity . getPackageId ( ) ) ;
DistributionAddvaluePackageEntity addvaluePackageEntity = new DistributionAddvaluePackageEntity ( ) ;
addvaluePackageEntity . setAddvalueDetailId ( distributionAddvaluePackageDTO . getAddvalueDetailId ( ) ) ;
addvaluePackageEntity . setStockArticleId ( distributionAddvaluePackageDTO . getStockArticleId ( ) ) ;
addvaluePackageEntity . setAddvalueDetailId ( distributionAppAddvalueDTO . getAddvalueDetailId ( ) ) ;
addvaluePackageEntity . setOrderCode ( distributionAddvaluePackageDTO . getOrderCode ( ) ) ;
addvaluePackageEntity . setMaterialName ( distributionAddvaluePackageDTO . getMaterialName ( ) ) ;
addvaluePackageEntity . setPackageId ( distributionAddvaluePackageDTO . getPackageId ( ) ) ;
addvaluePackageEntity . setReservationId ( distributionAddvaluePackageDTO . getReservationId ( ) ) ;
addvaluePackageEntity . setQuantity ( distributionAddvaluePackageDTO . getQuantity ( ) ) ;
if ( distributionAddvaluePackageDTO . getConditions ( ) = = 1 ) {
//新增订制品
addvaluePackageEntity . setOrderPackageCode ( distributionAddvaluePackageDTO . getOrderPackageCode ( ) ) ;
addvaluePackageEntity . setRecordType ( "3" ) ;
addvaluePackageEntity . setConditions ( 1 ) ;
} else {
//新增库存品
addvaluePackageEntity . setMaterialName ( distributionAddvaluePackageDTO . getMaterialName ( ) ) ;
addvaluePackageEntity . setOrderPackageCode ( distributionAddvaluePackageDTO . getOrderPackageCode ( ) ) ;
addvaluePackageEntity . setRecordType ( "3" ) ;
addvaluePackageEntity . setConditions ( 2 ) ;
}
distributionAddvaluePackageService . save ( addvaluePackageEntity ) ;
}
}
}
} ) ;
return R . status ( true ) ;
} ) ;
}
return R . status ( true ) ;
}
// if (Func.isEmpty(detailEntity)) {
// log.error("###########查询增值服务详情错误:{}", detailEntity);
// log.error("###########AddvalueDetailId>>>>>>>>>>>>>>>>>>>>>>>>>>>:{}", detailEntity);
// return R.fail("服务器正忙............");
// }
// String addvalueType = distributionAppAddvalueDTO.getAddvalueType();
//
// distributionAddvalueDetailMapper.updateById(detailEntity);
//查询出原来的包件信息
// DistributionAddvalueVO addvalueVO = distributionAddvalueMapper.selectReservationAddvalue(distributionAppAddvalueDTO.getReservationId(), addvalueType);
// String packageListIds = addvalueVO.getPackageListIds();
// if (Func.isEmpty(packageListIds)) {
// log.error("##############查询增值服务包件列表DI错误:{}", packageListIds);
// }
// List<DistributionAddvaluePackageEntity> distributionAddvaluePackageEntities = distributionAddvaluePackageService.list(Wrappers.<DistributionAddvaluePackageEntity>query().lambda()
// .in(DistributionAddvaluePackageEntity::getPackageId, Func.toLongList(packageListIds))
// .eq(DistributionAddvaluePackageEntity::getAddvalueDetailId, distributionAppAddvalueDTO.getAddvalueDetailId()));
// Map<Long, List<DistributionAddvaluePackageEntity>> oldPackageList = distributionAddvaluePackageEntities.stream().collect(Collectors.groupingBy(DistributionAddvaluePackageEntity::getPackageId));
// Map<Long, List<DistributionAddvaluePackageDTO>> newPackageList = packageEntityList.stream().collect(Collectors.groupingBy(DistributionAddvaluePackageEntity::getPackageId));
// newPackageList.forEach((k, v) -> {
// DistributionAddvaluePackageDTO distributionAddvaluePackageEntity = v.get(0);
// //只要不存在与就是新增,这里PC操作是一个包件累加操作,如果已经存在列表之中那么不进行添加
// if (Func.isEmpty(oldPackageList.get(k))) {
// //从老的包件中无法进行获取,这里进行包件的新增
// DistributionAddvaluePackageEntity addvaluePackageEntity = new DistributionAddvaluePackageEntity();
// addvaluePackageEntity.setQuantity(distributionAddvaluePackageEntity.getZeroQuantity());
// addvaluePackageEntity.setAddvalueDetailId(distributionAddvaluePackageEntity.getAddvalueDetailId());
// addvaluePackageEntity.setStockArticleId(distributionAddvaluePackageEntity.getStockArticleId());
// addvaluePackageEntity.setMaterialName(distributionAddvaluePackageEntity.getMaterialName());
// addvaluePackageEntity.setPackageId(distributionAddvaluePackageEntity.getPackageId());
// addvaluePackageEntity.setReservationId(distributionAddvaluePackageEntity.getReservationId());
// if (distributionAddvaluePackageEntity.getConditions() == 3) {
// addvaluePackageEntity.setConditions(3);
// addvaluePackageEntity.setRecordType("3");
// distributionAddvaluePackageService.save(addvaluePackageEntity);
// } else if (distributionAddvaluePackageEntity.getConditions() == 1) {
// //新增订制品
// addvaluePackageEntity.setOrderPackageCode(distributionAddvaluePackageEntity.getOrderPackageCode());
// addvaluePackageEntity.setRecordType("1");
// addvaluePackageEntity.setConditions(1);
// } else {
// //新增库存品
// addvaluePackageEntity.setOrderPackageCode(distributionAddvaluePackageEntity.getOrderPackageCode());
// addvaluePackageEntity.setRecordType("2");
// addvaluePackageEntity.setConditions(2);
// }
//// distributionAddvaluePackageEntity.setAddvalueDetailId(distributionAddvaluePackageEntities.get(0).getAddvalueDetailId());
// distributionAddvaluePackageService.save(addvaluePackageEntity);
// } else {
// if (distributionAddvaluePackageEntity.getConditions() == 3) {
// if (distributionAddvaluePackageEntity.getZeroQuantity() != 0) {
// if (distributionAddvaluePackageEntity.getZeroQuantity() > 0) {
// distributionAddvaluePackageEntity.setQuantity(distributionAddvaluePackageEntity.getZeroQuantity());
// distributionAddvaluePackageService.updateById(distributionAddvaluePackageEntity);
// } else {
// log.error("###############零担品类录入数量有误:{}", distributionAddvaluePackageEntity.getZeroQuantity());
// }
// } else {
// //删除对应的包件信息
// distributionAddvaluePackageMapper.deleteAddvaluePackage(distributionAddvaluePackageEntity.getReservationId(), distributionAddvaluePackageEntity.getPackageId());
// }
// }
// }
// });
// return R.status(true);
// }
// @Override
// public List<DistributionAddvaluePackageEntity> getAddvalueBySignfor(DistributionAddvalueDTO distributionAddvalueDTO) {
// DistributionAddvalueVO addvalueVO = distributionAddvalueMapper.getAddvalueBySignfor(distributionAddvalueDTO);