@ -6758,6 +6758,51 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
}
@Override
public R cancelDelivery ( Long deliveryId ) {
String method = "###################DistributionDeliveryListServiceImpl执行方法cancelDelivery," ;
DistributionDeliveryListEntity deliveryListEntity = this . getById ( deliveryId ) ;
if ( Func . isEmpty ( deliveryListEntity ) ) {
log . info ( method + "参数缺失deliveryId:{}" , deliveryId ) ;
throw new RuntimeException ( "服务器正忙!!!" ) ;
}
List < DistributionReservationEntity > reservationEntities = distributionSignforService . selectReservationByDeliveryId ( deliveryId ) ;
if ( Func . isEmpty ( reservationEntities ) ) {
log . info ( method + "预约查询失败:{}" , deliveryId ) ;
throw new RuntimeException ( "服务器正忙!!!" ) ;
}
String reservationCodes = reservationEntities . stream ( ) . filter ( f - > ! f . getLoadingStatus ( ) . equals ( ReservationLoadingStatusConstant . daizhuangche . getValue ( ) ) ) . map ( DistributionReservationEntity : : getReservationCode ) . collect ( Collectors . joining ( "," ) ) ;
if ( Func . isNotEmpty ( reservationCodes ) ) {
log . info ( method + "存在装车数据:{}" , deliveryId ) ;
return R . fail ( reservationCodes + "存在装车数据!!!" ) ;
}
//该配送是否存在异常装车或者异常签收数据
List < DistributionLoadscanEntity > loadscanEntityList = distributionDeliveryListService . selectAbnormalLoadingBydeliveryId ( deliveryId ) ;
if ( Func . isNotEmpty ( loadscanEntityList ) ) {
log . info ( method + "存在异常装车数据:{}" , deliveryId ) ;
return R . fail ( reservationCodes + "存在异常装车、签收包条!!!" ) ;
}
boolean flag = false ;
for ( DistributionReservationEntity reservationEntity : reservationEntities ) {
DistributionReservationDTO reservationDTO = Func . copy ( reservationEntity , DistributionReservationDTO . class ) ;
flag = distributionReservationService . cancelReservation ( reservationDTO ) ;
if ( ! flag ) {
log . info ( method + "取消预约失败:{}" , deliveryId ) ;
throw new RuntimeException ( "取消配送计划失败,请联系管理员" ) ;
}
}
return R . status ( flag ) ;
}
@Override
public List < DistributionLoadscanEntity > selectAbnormalLoadingBydeliveryId ( Long deliveryId ) {
return distributionLoadscanService . list ( Wrappers . < DistributionLoadscanEntity > query ( ) . lambda ( )
. eq ( DistributionLoadscanEntity : : getDeliveryId , deliveryId )
. eq ( DistributionLoadscanEntity : : getScanStatus , LoadingStatusConstant . quxiao . getValue ( ) )
. eq ( DistributionLoadscanEntity : : getIsAbnormalLoading , 2 )
) ;
}
@Override
@Transactional
public void maintenanceDeliveryInfo ( Long deliveryId ) {