@ -45,7 +45,11 @@ import com.logpm.distribution.wrapper.DistributionDeliveryListWrapper;
import com.logpm.distribution.wrapper.DistributionParcelListWrapper ;
import com.logpm.distribution.wrapper.DistributionReservationWrapper ;
import com.logpm.distribution.wrapper.DistributionStockArticleWrapper ;
import com.logpm.warehouse.entity.WarehouseTrayGoodsEntity ;
import com.logpm.warehouse.entity.WarehouseTrayTypeEntity ;
import com.logpm.warehouse.feign.IWarehouseTrayTypeClient ;
import com.logpm.warehouse.feign.IWarehouseUpdownTypeClient ;
import com.logpm.warehouse.vo.TrayTypeDataVO ;
import lombok.AllArgsConstructor ;
import lombok.extern.log4j.Log4j2 ;
import org.apache.commons.lang.StringUtils ;
@ -90,6 +94,7 @@ import java.math.BigDecimal;
import java.text.SimpleDateFormat ;
import java.util.* ;
import java.util.concurrent.atomic.AtomicInteger ;
import java.util.function.Function ;
import java.util.stream.Collectors ;
import java.util.stream.Stream ;
@ -138,6 +143,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
private final DistributionStockListMapper distributionStockListMapper ;
private final IWarehouseUpdownTypeClient warehouseUpdownTypeClient ;
private final IBasicPrintTemplateClient basicPrintTemplateClient ;
private final IWarehouseTrayTypeClient warehouseTrayTypeClient ;
@Override
public IPage < DistributionDeliveryListEntity > selectDistributionDeliveryListPage ( IPage < DistributionDeliveryListEntity > page , DistributionDeliveryListDTO distributionDeliveryList ) {
@ -397,8 +403,12 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
@Override
@Transactional ( isolation = Isolation . READ_COMMITTED , rollbackFor = Exception . class )
// synchronized
public Resp loadingscan ( DistrilbutionloadingscanDTO distrilbutionloadingscanDTO ) {
public R loadingscan ( DistrilbutionloadingscanDTO distrilbutionloadingscanDTO ) {
// -----------------------------------2023-09-25 签收调整----------------------------------------------------------------
// 首先这里需要查看该包件是否属于该配送任务
// 属于该配送任务需要进行是否属于该客户进行判断
// 如果属于该客户则进行装车扫描
//
//获取当前用户司机
DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper . selectById ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
//异步确认包条扫描信息
@ -412,130 +422,551 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
BeanUtils . copyProperties ( distributionDeliveryTripartiteEntity , distributionDeliverySelfEntity ) ;
}
if ( distrilbutionloadingscanDTO . getType ( ) = = 1 ) {
// if (distrilbutionloadingscanDTO.getStockType() == 1) {
//查询该包条是否属于该配送任务
List < DistributionLoadscanEntity > distributionLoadscanEntities = baseMapper . selectdeliverywork ( distrilbutionloadingscanDTO . getBarcode ( ) , distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
if ( distributionLoadscanEntities . size ( ) < = 0 ) {
return Resp . scanSuccess ( "窜货" , "窜货" ) ;
}
for ( DistributionLoadscanEntity distributionLoadscanEntity : distributionLoadscanEntities ) {
//查询是否重复扫码
if ( distrilbutionloadingscanDTO . getType ( ) = = 1 ) {
List < DistributionParcelListEntity > distributionParcelListEntities = distributionDeliveryListMapper . selectPackageListByDeliveryListId ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
List < DistributionParcelListEntity > parcelListEntityList = distributionParcelListEntities . stream ( ) . filter ( p - > Func . equals ( p . getOrderPackageCode ( ) , distrilbutionloadingscanDTO . getBarcode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( parcelListEntityList . size ( ) = = 1 ) {
//在配送任务中存在该包件的计划
List < DistributionLoadscanEntity > distributionLoadscanEntitiesflag = distributionLoadscanMapper . selectList ( new QueryWrapper < DistributionLoadscanEntity > ( ) . lambda ( )
. eq ( DistributionLoadscanEntity : : getDeliveryId , distributionLoadscanEntity . getDeliveryId ( ) )
. eq ( DistributionLoadscanEntity : : getOrderPackageCode , distributionLoadscanEntity . getOrderPackageC ode ( ) )
. ne ( DistributionLoadscanEntity : : getScanStatus , 1 )
) ;
if ( ! distributionLoadscanEntitiesflag . isEmpty ( ) ) {
. eq ( DistributionLoadscanEntity : : getDeliveryId , distrilbutionloadingscanDTO . getDeliveryId ( ) )
. eq ( DistributionLoadscanEntity : : getOrderPackageCode , distrilbutionloadingscanDTO . getBarcode ( ) )
. ne ( DistributionLoadscanEntity : : getScanStatus , LoadingStatusConstant . quxiao . getValue ( ) ) ) ;
if ( Func . isNotEmpty ( distributionLoadscanEntitiesflag ) & & distributionLoadscanEntitiesflag . size ( ) = = 1 ) {
return Resp . scanSuccess ( "重复扫码" , "重复扫码" ) ;
}
//依次插入该装车记录,设置车辆
if ( null ! = distributionDeliverySelfEntity . getDriver Id( ) ) {
distributionL oadscanEntity. setDriverId ( distributionDeliverySelfEntity . getDriverId ( ) ) ;
DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity ( ) ;
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getDelivery Id( ) ) ) {
l oadscanEntity. setDriverId ( distributionDeliverySelfEntity . getDriverId ( ) ) ;
}
//添加车次号
distributionLoadscanEntity . setTrainNumber ( distributionDeliveryListEntity . getTrainNumber ( ) ) ;
distributionLoadscanEntity . setDriverName ( distributionDeliverySelfEntity . getDriverName ( ) ) ;
distributionLoadscanEntity . setVehicleName ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ;
distributionLoadscanEntity . setScanStatus ( LoadingStatusConstant . saomiao . getValue ( ) ) ;
distributionLoadscanEntity . setScanType ( "1" ) ;
distributionLoadscanEntity . setScanTime ( new Date ( ) ) ;
BladeUser user = AuthUtil . getUser ( ) ;
distributionLoadscanEntity . setScanUser ( user . getNickName ( ) ) ;
if ( null ! = distributionDeliverySelfEntity . getDriverPhone ( ) ) {
distributionLoadscanEntity . setDriverPhone ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ;
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getDriverName ( ) ) ) {
loadscanEntity . setDriverName ( distributionDeliverySelfEntity . getDriverName ( ) ) ;
}
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ) {
loadscanEntity . setVehicleName ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ;
}
if ( null ! = distributionDeliverySelfEntity . getVehicleId ( ) ) {
distributionL oadscanEntity. setVehicleId ( distributionDeliverySelfEntity . getVehicleId ( ) ) ;
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getVehicleId ( ) ) ) {
loadscanEntity . setVehicleId ( distributionDeliverySelfEntity . getVehicleId ( ) ) ;
}
distributionLoadscanEntity . setLoadingId ( distrilbutionloadingscanDTO . getLoadingId ( ) ) ;
//distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.);
//依次更新该装车记录,设置车辆
// distributionLoadscanMapper.updateSumById(distributionLoadscanEntity.getId(), distrilbutionloadingscanDTO);
// distributionLoadscanordMapper.updateSumById(distributionLoadscanEntity.getOrderId(),distrilbutionloadingscanDTO);
// distributionLoadscanresMapper.updateSumById(distributionLoadscanEntity.getReservationId(),distrilbutionloadingscanDTO);
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ) {
loadscanEntity . setDriverPhone ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ;
}
DistributionParcelListEntity parcelListEntity = parcelListEntityList . get ( 0 ) ;
//添加车次号
loadscanEntity . setTrainNumber ( distributionDeliveryListEntity . getTrainNumber ( ) ) ;
loadscanEntity . setScanStatus ( LoadingStatusConstant . saomiao . getValue ( ) ) ;
loadscanEntity . setScanType ( "1" ) ;
loadscanEntity . setOneClick ( 1 ) ;
loadscanEntity . setPackageId ( parcelListEntity . getId ( ) ) ;
loadscanEntity . setOrderPackageCode ( parcelListEntity . getOrderPackageCode ( ) ) ;
loadscanEntity . setPackageNub ( parcelListEntity . getQuantity ( ) ) ;
loadscanEntity . setReservationId ( distrilbutionloadingscanDTO . getReservationId ( ) ) ;
loadscanEntity . setDeliveryId ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
loadscanEntity . setOrderId ( parcelListEntity . getStockArticleId ( ) ) ;
loadscanEntity . setScanTime ( new Date ( ) ) ;
BladeUser user = AuthUtil . getUser ( ) ;
loadscanEntity . setScanUser ( user . getUserName ( ) ) ;
loadscanEntity . setLoadingId ( distrilbutionloadingscanDTO . getLoadingId ( ) ) ;
//出库
warehouseUpdownTypeClient . downPackage ( distrilbutionloadingscanDTO . getBarcode ( ) ) ;
distributionLoadscanService . save ( loadscanEntity ) ;
//查询本车次是否第一次扫码,没有则更新上车时间
Integer i = distributionDeliveryListMapper . updateloadingTimeById ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
//更新签收表的装车数量
Integer j = distributionSignforMapper . updateloadByReservationId ( distributionLoadscanEntity . getDeliveryId ( ) , distributionLoadscanEntity . getReservationId ( ) , distributionLoadscanEntity . getPackageNub ( ) ) ;
//判断是商配还是市配
// DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper.selectById(distrilbutionloadingscanDTO.getDeliveryId());
// if (distributionDeliveryListEntity.getType().equals("1")) {
// //判断签收表有无客户信息,没有就加入信息
// Long c = distributionSignforMapper.selectCount(new QueryWrapper<DistributionSignforEntity>().lambda()
// .eq(DistributionSignforEntity::getDeliveryType,"1")
// .eq(DistributionSignforEntity::getReservationId,distributionLoadscanEntity.getReservationId())
// );
// //冗余加入
// if (c<=0){
// DistributionReservationEntity distributionReservationEntity = distributionReservationMapper.selectById(distributionLoadscanEntity.getReservationId());
// DistributionSignforEntity distributionSignforEntity = new DistributionSignforEntity();
// BeanUtils.copyProperties(distributionReservationEntity,distributionSignforEntity);
// distributionSignforEntity.setReservationId(distributionReservationEntity.getId());
// //设置车次
// distributionSignforEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber());
// distributionSignforEntity.setDeliveryType(distributionDeliveryListEntity.getType());
// distributionSignforEntity.setId(null);
// distributionSignforEntity.setLoadingTime(distributionDeliveryListEntity.getLoadingTime());
// distributionSignforEntity.setDeliveryDriverName(distributionDeliveryListEntity.getDriverName());
// distributionSignforEntity.setSigningStatus("1");
// distributionSignforEntity.setDriverSigning("1");
// distributionSignforMapper.insert(distributionSignforEntity);
// }
// }
Integer j = distributionSignforMapper . updateloadByReservationId ( loadscanEntity . getDeliveryId ( ) , loadscanEntity . getReservationId ( ) , loadscanEntity . getPackageNub ( ) ) ;
//这里还需要一个维护状态的方法
} else if ( parcelListEntityList . size ( ) = = 0 ) {
//查找出该包件信息
DistributionParcelListEntity parcelListEntity = distributionParcelListService . getOne ( Wrappers . < DistributionParcelListEntity > query ( ) . lambda ( )
. eq ( DistributionParcelListEntity : : getOrderPackageCode , distrilbutionloadingscanDTO . getBarcode ( ) ) ) ;
List < DistributionReservationEntity > reservationEntityList = distributionDeliveryListMapper . selectReservationByDeliveryListId ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
boolean shangpeiFlag = reservationEntityList . stream ( ) . allMatch ( r - > r . getDeliveryType ( ) . equals ( DistributionTypeConstant . shipie . getValue ( ) ) ) ;
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleMapper . selectById ( parcelListEntity . getStockArticleId ( ) ) ;
if ( shangpeiFlag ) {
List < DistributionReservationEntity > reservationEntities = reservationEntityList . stream ( ) . filter ( r - > Func . isNotEmpty ( r . getConsignee ( ) )
& & r . getConsignee ( ) . equals ( stockArticleEntity . getCustomerName ( ) )
& & r . getDeliveryAddress ( ) . equals ( stockArticleEntity . getCustomerAddress ( ) )
& & r . getDeliveryPhone ( ) . equals ( stockArticleEntity . getCustomerTelephone ( ) )
& & r . getMallName ( ) . equals ( stockArticleEntity . getMallName ( ) ) ) . collect ( Collectors . toList ( ) ) ;
//查看是否存在满足条件的预约单
if ( reservationEntities . size ( ) = = 1 ) {
return R . fail ( 5000 , "异常装车" ) ;
// return Resp.scanFail("装车失败","程序出错,请联系张思雨");
} else {
return Resp . scanFail ( "装车失败" , "窜货" ) ;
}
} else {
shangpeiFlag = reservationEntityList . stream ( ) . allMatch ( r - > r . getDeliveryType ( ) . equals ( DistributionTypeConstant . shangpei . getValue ( ) ) ) ;
if ( shangpeiFlag ) {
List < DistributionReservationEntity > reservationEntities = reservationEntityList . stream ( ) . filter ( r - > Func . isNotEmpty ( r ) & & r . getConsignee ( ) . equals ( stockArticleEntity . getConsigneeUnit ( ) ) & & r . getMallName ( ) . equals ( stockArticleEntity . getMallName ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( reservationEntities . size ( ) = = 1 ) {
return R . fail ( 5000 , "异常装车" ) ;
} else {
return Resp . scanFail ( "装车失败" , "窜货" ) ;
}
} else {
log . error ( "配送计划预约类型错误:{}" , reservationEntityList ) ;
}
}
//不存在配送计划中,这里进行客户的判断
}
} else if ( distrilbutionloadingscanDTO . getType ( ) = = 2 ) {
TrayTypeDataVO trayTypeDataVO = warehouseTrayTypeClient . selectListByTrayCode ( distrilbutionloadingscanDTO . getBarcode ( ) ) ;
if ( Func . isNotEmpty ( trayTypeDataVO ) ) {
List < WarehouseTrayGoodsEntity > voGoodsLsit = trayTypeDataVO . getGoodsLsit ( ) ;
List < Long > trayGoodIds = voGoodsLsit . stream ( ) . filter ( v - > v . getAssociationType ( ) . equals ( "3" ) ) . map ( WarehouseTrayGoodsEntity : : getAssociationId ) . collect ( Collectors . toList ( ) ) ;
//此时经过过滤后的包件ID和托盘上的所有包件ID数量一致,视为该托盘上的均为包件
if ( voGoodsLsit . size ( ) = = trayGoodIds . size ( ) ) {
List < DistributionParcelListEntity > parcelListEntities = distributionParcelListService . listByIds ( trayGoodIds ) ;
boolean trayLoadingStatus = parcelListEntities . stream ( ) . allMatch ( p - > p . getOrderPackageLoadingStatus ( ) . equals ( OrderPackageLoadingStatusConstant . yizhuangche . getValue ( ) ) ) ;
if ( trayLoadingStatus ) {
return Resp . scanFail ( "托盘装车完毕" , "托盘装车完毕" ) ;
}
if ( Func . isEmpty ( parcelListEntities ) | | parcelListEntities . size ( ) < = 0 ) {
return Resp . scanFail ( "操作失败" , "该托盘上无货物信息" ) ;
}
if ( Func . isNotEmpty ( distrilbutionloadingscanDTO . getReservationId ( ) ) ) {
//存在客户 这里就是针对客户进行的整托装车
List < DistributionParcelListEntity > parcelListEntityList = distributionReservationMapper . selectPackageListByReservationId ( distrilbutionloadingscanDTO . getReservationId ( ) ) ;
Map < Long , DistributionParcelListEntity > parcelListEntityMap = parcelListEntityList . stream ( ) . collect ( Collectors . toMap ( DistributionParcelListEntity : : getId , Function . identity ( ) , ( k1 , k2 ) - > k2 ) ) ;
boolean reservationFlag = parcelListEntities . stream ( ) . allMatch ( p - > Func . isNotEmpty ( parcelListEntityMap . get ( p . getId ( ) ) ) ) ;
if ( reservationFlag ) {
List < DistributionLoadscanEntity > reservationLoadscanEntities = new ArrayList < > ( ) ;
for ( DistributionParcelListEntity parcelListEntity : parcelListEntities ) {
if ( parcelListEntity . getOrderPackageLoadingStatus ( ) . equals ( OrderPackageLoadingStatusConstant . weizhuancghe . getValue ( ) ) ) {
parcelListEntity . setOrderPackageLoadingStatus ( OrderPackageLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
parcelListEntity . setOrderPackageStatus ( OrderPackageStatusConstant . yichuku . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity ( ) ;
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getDeliveryId ( ) ) ) {
loadscanEntity . setDriverId ( distributionDeliverySelfEntity . getDriverId ( ) ) ;
}
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getDriverName ( ) ) ) {
loadscanEntity . setDriverName ( distributionDeliverySelfEntity . getDriverName ( ) ) ;
}
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ) {
loadscanEntity . setVehicleName ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ;
}
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getVehicleId ( ) ) ) {
loadscanEntity . setVehicleId ( distributionDeliverySelfEntity . getVehicleId ( ) ) ;
}
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ) {
loadscanEntity . setDriverPhone ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ;
}
loadscanEntity . setOrderId ( parcelListEntity . getStockArticleId ( ) ) ;
loadscanEntity . setOrderPackageCode ( parcelListEntity . getOrderPackageCode ( ) ) ;
loadscanEntity . setReservationId ( distrilbutionloadingscanDTO . getReservationId ( ) ) ;
loadscanEntity . setDeliveryId ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
loadscanEntity . setTrainNumber ( distributionDeliveryListEntity . getTrainNumber ( ) ) ;
loadscanEntity . setPackageNub ( parcelListEntity . getQuantity ( ) ) ;
loadscanEntity . setScanTime ( new Date ( ) ) ;
BladeUser user = AuthUtil . getUser ( ) ;
loadscanEntity . setScanUser ( user . getUserName ( ) ) ;
loadscanEntity . setLoadingId ( distrilbutionloadingscanDTO . getLoadingId ( ) ) ;
loadscanEntity . setOneClick ( 1 ) ;
loadscanEntity . setScanType ( "2" ) ;
loadscanEntity . setScanStatus ( "2" ) ;
loadscanEntity . setIsInsert ( 1 ) ;
loadscanEntity . setMsg ( "司机按照预约整托装车" ) ;
loadscanEntity . setTrayNo ( trayTypeDataVO . getTrayCode ( ) ) ;
reservationLoadscanEntities . add ( loadscanEntity ) ;
Integer i = distributionDeliveryListMapper . updateloadingTimeById ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
//更新签收表的装车数量
Integer j = distributionSignforMapper . updateloadByReservationId ( loadscanEntity . getDeliveryId ( ) , loadscanEntity . getReservationId ( ) , loadscanEntity . getPackageNub ( ) ) ;
}
//TODO 需要一个维护状态的异步方法
}
distributionLoadscanService . saveBatch ( reservationLoadscanEntities ) ;
//这里则进行整托装车的数据构建
} else {
return Resp . scanFail ( "整托装车失败" , "存在其他客户货物" ) ;
}
} else {
//不存在客户 这里就是针对配送任务进行的整托装车
List < DistributionParcelListEntity > deliveryPackageList = distributionDeliveryListMapper . selectPackageListByDeliveryListId ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
Map < Long , DistributionParcelListEntity > deliveryPackageMap = deliveryPackageList . stream ( ) . collect ( Collectors . toMap ( DistributionParcelListEntity : : getId , Function . identity ( ) , ( k1 , k2 ) - > k2 ) ) ;
boolean delivaryFlag = parcelListEntities . stream ( ) . allMatch ( p - > Func . isNotEmpty ( deliveryPackageMap . get ( p . getId ( ) ) ) ) ;
if ( delivaryFlag ) {
List < DistributionLoadscanEntity > deliveryLoadscanEntities = new ArrayList < > ( ) ;
for ( DistributionParcelListEntity parcelListEntity : parcelListEntities ) {
if ( parcelListEntity . getOrderPackageLoadingStatus ( ) . equals ( OrderPackageLoadingStatusConstant . weizhuancghe . getValue ( ) ) ) {
parcelListEntity . setOrderPackageLoadingStatus ( OrderPackageLoadingStatusConstant . yizhuangche . getValue ( ) ) ;
parcelListEntity . setOrderPackageStatus ( OrderPackageStatusConstant . yichuku . getValue ( ) ) ;
distributionParcelListService . updateById ( parcelListEntity ) ;
DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity ( ) ;
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getDeliveryId ( ) ) ) {
loadscanEntity . setDriverId ( distributionDeliverySelfEntity . getDriverId ( ) ) ;
}
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getDriverName ( ) ) ) {
loadscanEntity . setDriverName ( distributionDeliverySelfEntity . getDriverName ( ) ) ;
}
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ) {
loadscanEntity . setVehicleName ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ;
}
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getVehicleId ( ) ) ) {
loadscanEntity . setVehicleId ( distributionDeliverySelfEntity . getVehicleId ( ) ) ;
}
if ( Func . isNotEmpty ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ) {
loadscanEntity . setDriverPhone ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ;
}
loadscanEntity . setOrderId ( parcelListEntity . getStockArticleId ( ) ) ;
loadscanEntity . setOrderPackageCode ( parcelListEntity . getOrderPackageCode ( ) ) ;
loadscanEntity . setReservationId ( distrilbutionloadingscanDTO . getReservationId ( ) ) ;
loadscanEntity . setDeliveryId ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
loadscanEntity . setTrainNumber ( distributionDeliveryListEntity . getTrainNumber ( ) ) ;
loadscanEntity . setPackageNub ( parcelListEntity . getQuantity ( ) ) ;
loadscanEntity . setScanTime ( new Date ( ) ) ;
BladeUser user = AuthUtil . getUser ( ) ;
loadscanEntity . setScanUser ( user . getUserName ( ) ) ;
loadscanEntity . setLoadingId ( distrilbutionloadingscanDTO . getLoadingId ( ) ) ;
loadscanEntity . setOneClick ( 1 ) ;
loadscanEntity . setScanType ( "2" ) ;
loadscanEntity . setScanStatus ( "2" ) ;
loadscanEntity . setIsInsert ( 1 ) ;
loadscanEntity . setMsg ( "司机按照计划整托装车" ) ;
loadscanEntity . setTrayNo ( trayTypeDataVO . getTrayCode ( ) ) ;
deliveryLoadscanEntities . add ( loadscanEntity ) ;
//更新装车时间
Integer i = distributionDeliveryListMapper . updateloadingTimeById ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
//更新签收表的装车数量
Integer j = distributionSignforMapper . updateloadByReservationId ( loadscanEntity . getDeliveryId ( ) , loadscanEntity . getReservationId ( ) , loadscanEntity . getPackageNub ( ) ) ;
}
//TODO 需要一个维护状态的异步方法
}
distributionLoadscanService . saveBatch ( deliveryLoadscanEntities ) ;
//这里则进行整托装车的数据构建
} else {
return Resp . scanFail ( "整托装车失败" , "存在其他客户货物" ) ;
}
}
} else {
log . error ( "托盘存放货物类型不单一:{}" , trayTypeDataVO ) ;
}
}
warehouseUpdownTypeClient . downPackage ( distrilbutionloadingscanDTO . getBarcode ( ) ) ;
distributionLoadscanService . saveBatch ( distributionLoadscanEntities ) ;
// //找出该包条码
// List<DistributionParcelListEntity> distributionParcelListEntities = distributionParcelListMapper.selectList(new QueryWrapper<DistributionParcelListEntity>().lambda()
// .eq(DistributionParcelListEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()));
// for (DistributionParcelListEntity e : distributionParcelListEntities) {
// String trainNumber = distributionLoadscanMapper.selecttrainNumberByPackageId(e.getId());
// if (!trainNumber.equals(distributionDeliveryListEntities.get(0).getTrainNumber())) {
// return R.fail(3002, "不是当前司机配送车次");
}
return Resp . scanSuccess ( "装车成功" , "装车成功" ) ;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// if (distrilbutionloadingscanDTO.getType() == 1) {
// // if (distrilbutionloadingscanDTO.getStockType() == 1) {
// //查询该包条是否属于该配送任务
// List<DistributionLoadscanEntity> distributionLoadscanEntities = baseMapper.selectdeliverywork(distrilbutionloadingscanDTO.getBarcode(), distrilbutionloadingscanDTO.getDeliveryId());
// if (distributionLoadscanEntities.size() <= 0) {
//
// return Resp.scanSuccess("窜货", "窜货");
// }
// for (DistributionLoadscanEntity distributionLoadscanEntity : distributionLoadscanEntities) {
// //查询是否重复扫码
// List<DistributionLoadscanEntity> distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper<DistributionLoadscanEntity>().lambda()
// .eq(DistributionLoadscanEntity::getDeliveryId, distributionLoadscanEntity.getDeliveryId())
// .eq(DistributionLoadscanEntity::getOrderPackageCode, distributionLoadscanEntity.getOrderPackageCode())
// .ne(DistributionLoadscanEntity::getScanStatus, 1)
// );
// if (!distributionLoadscanEntitiesflag.isEmpty()) {
// return Resp.scanSuccess("重复扫码", "重复扫码");
// }
// if (Func.notNull(bladeRedis.get("ZC" + user.getUserId()))) {
// if (!(bladeRedis.get("ZC" + user.getUserId().toString()).equals(trainNumber))) {
// return R.fail(3003, "串货");
// }
// } else {
// //第一次缓存
// bladeRedis.setEx("ZC" + user.getUserId(), trainNumber, 3600L);
// //TODO 查询本车次是否第一次扫码,没有则更新上车时间
// Integer i = distributionDeliveryListMapper.updateloadingTimeById(distributionDeliveryListEntities.get(0).getId());
// //查询该车次包条,加入签收表
// //依次插入该装车记录,设置车辆
// if (null != distributionDeliverySelfEntity.getDriverId()) {
// distributionLoadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId());
// }
// //添加车次号
// distributionLoadscanEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber());
// distributionLoadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName());
// distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub());
// distributionLoadscanEntity.setScanStatus(LoadingStatusConstant.saomiao.getValue());
// distributionLoadscanEntity.setScanType("1");
// distributionLoadscanEntity.setScanTime(new Date());
// BladeUser user = AuthUtil.getUser();
// distributionLoadscanEntity.setScanUser(user.getNickName());
// if (null != distributionDeliverySelfEntity.getDriverPhone()) {
// distributionLoadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone());
// }
// if (null != distributionDeliverySelfEntity.getVehicleId()) {
// distributionLoadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId());
// }
// distributionLoadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId());
// //distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.);
// //依次更新该装车记录,设置车辆
// // distributionLoadscanMapper.updateSumById(distributionLoadscanEntity.getId(), distrilbutionloadingscanDTO);
//// distributionLoadscanordMapper.updateSumById(distributionLoadscanEntity.getOrderId(),distrilbutionloadingscanDTO);
//// distributionLoadscanresMapper.updateSumById(distributionLoadscanEntity.getReservationId(),distrilbutionloadingscanDTO);
// //查询本车次是否第一次扫码,没有则更新上车时间
// Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId());
// //更新签收表的装车数量
// Integer j = distributionSignforMapper.updateloadByReservationId(distributionLoadscanEntity.getDeliveryId(), distributionLoadscanEntity.getReservationId(), distributionLoadscanEntity.getPackageNub());
// //判断是商配还是市配
//// DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper.selectById(distrilbutionloadingscanDTO.getDeliveryId());
//// if (distributionDeliveryListEntity.getType().equals("1")) {
//// //判断签收表有无客户信息,没有就加入信息
//// Long c = distributionSignforMapper.selectCount(new QueryWrapper<DistributionSignforEntity>().lambda()
//// .eq(DistributionSignforEntity::getDeliveryType,"1")
//// .eq(DistributionSignforEntity::getReservationId,distributionLoadscanEntity.getReservationId())
//// );
//// //冗余加入
//// if (c<=0){
//// DistributionReservationEntity distributionReservationEntity = distributionReservationMapper.selectById(distributionLoadscanEntity.getReservationId());
//// DistributionSignforEntity distributionSignforEntity = new DistributionSignforEntity();
//// BeanUtils.copyProperties(distributionReservationEntity,distributionSignforEntity);
//// distributionSignforEntity.setReservationId(distributionReservationEntity.getId());
//// //设置车次
//// distributionSignforEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber());
//// distributionSignforEntity.setDeliveryType(distributionDeliveryListEntity.getType());
//// distributionSignforEntity.setId(null);
//// distributionSignforEntity.setLoadingTime(distributionDeliveryListEntity.getLoadingTime());
//// distributionSignforEntity.setDeliveryDriverName(distributionDeliveryListEntity.getDriverName());
//// distributionSignforEntity.setSigningStatus("1");
//// distributionSignforEntity.setDriverSigning("1");
//// distributionSignforMapper.insert(distributionSignforEntity);
//// }
// // }
// }
//
//// //找出该包条码
//// List<DistributionParcelListEntity> distributionParcelListEntities = distributionParcelListMapper.selectList(new QueryWrapper<DistributionParcelListEntity>().lambda()
//// .eq(DistributionParcelListEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()));
//// for (DistributionParcelListEntity e : distributionParcelListEntities) {
//// String trainNumber = distributionLoadscanMapper.selecttrainNumberByPackageId(e.getId());
//// if (!trainNumber.equals(distributionDeliveryListEntities.get(0).getTrainNumber())) {
//// return R.fail(3002, "不是当前司机配送车次");
//// }
//// if (Func.notNull(bladeRedis.get("ZC" + user.getUserId()))) {
//// if (!(bladeRedis.get("ZC" + user.getUserId().toString()).equals(trainNumber))) {
//// return R.fail(3003, "串货");
//// }
//// } else {
//// //第一次缓存
//// bladeRedis.setEx("ZC" + user.getUserId(), trainNumber, 3600L);
//// //TODO 查询本车次是否第一次扫码,没有则更新上车时间
//// Integer i = distributionDeliveryListMapper.updateloadingTimeById(distributionDeliveryListEntities.get(0).getId());
//// //查询该车次包条,加入签收表
////
////
//// //修改对应的装车表
////
//// distributionLoadscanMapper.updateByPackageId(e.getId());
//// }
//// }
//// } else if (distrilbutionloadingscanDTO.getStockType() == 2) {
//// //库存品
//// //查询该包条是否属于该配送任务
//// List<DistributionLoadscaninvnEntity> distributionLoadscanvnEntities = baseMapper.selectdeliveryworkVn(distrilbutionloadingscanDTO.getBarcode(), distrilbutionloadingscanDTO.getDeliveryId());
//// if (distributionLoadscanvnEntities.size() <= 0) {
//// return R.fail(3001, "窜货");
//// }
//// for (DistributionLoadscaninvnEntity distributionLoadscanEntity : distributionLoadscanvnEntities) {
//// //查询是否重复扫码
//// List<DistributionLoadscanEntity> distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper<DistributionLoadscanEntity>().lambda()
//// .eq(DistributionLoadscanEntity::getDeliveryId, distributionLoadscanEntity.getReservationId())
//// .eq(DistributionLoadscanEntity::getOrderPackageCode, distributionLoadscanEntity.getOrderPackageCode())
//// .ne(DistributionLoadscanEntity::getScanStatus, 1)
//// );
//// if (distributionLoadscanEntitiesflag.size() > 0) {
//// return R.fail(3002, "重复扫码");
//// }
//// //依次插入该装车记录,设置车辆
//// if (null != distributionDeliverySelfEntity.getDriverId()) {
//// distributionLoadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId());
//// }
//// distributionLoadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName());
//// distributionLoadscanEntity.setScanStatus(2);
//// distributionLoadscanEntity.setScanType("1");
//// distributionLoadscanEntity.setScanTime(new Date());
//// distributionLoadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId());
//// distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub());
//// if (null != distributionDeliverySelfEntity.getDriverPhone()) {
//// distributionLoadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone());
//// }
//// if (null != distributionDeliverySelfEntity.getVehicleId()) {
//// distributionLoadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId());
//// }
//// //distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.);
//// //依次更新该装车记录,设置车辆
//// // distributionLoadscanMapper.updateSumById(distributionLoadscanEntity.getId(), distrilbutionloadingscanDTO);
////// distributionLoadscanordMapper.updateSumById(distributionLoadscanEntity.getOrderId(),distrilbutionloadingscanDTO);
////// distributionLoadscanresMapper.updateSumById(distributionLoadscanEntity.getReservationId(),distrilbutionloadingscanDTO);
//// //查询本车次是否第一次扫码,没有则更新上车时间
//// Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId());
//// //更新签收表的装车数量
//// Integer j = distributionSignforMapper.updateloadByReservationId(distributionLoadscanEntity.getReservationId(), 1);
////
//// }
//// distributionLoadscaninvnService.saveBatch(distributionLoadscanvnEntities);
////
//// }
// } else if (distrilbutionloadingscanDTO.getType() == 2) {
// //TODO 托盘扫描
// //查询出该托盘下的所有货物
// List<DistributionLoadscanEntity> parcelListEntityList = baseMapper.selectTrayPackageList(distrilbutionloadingscanDTO.getBarcode());
// //查询出配送任务下的所有包件信息
// Map<Long, List<DistributionLoadscanEntity>> trayPackage = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionLoadscanEntity::getPackageId));
//
//
// //修改对应的装车表
// //查询该包条是否属于该配送任务
// List<DistributionLoadscanEntity> distributionLoadscanEntities = baseMapper.selectdeliverypallet(distrilbutionloadingscanDTO.getBarcode(), distrilbutionloadingscanDTO.getDeliveryId());
// Map<Long, List<DistributionLoadscanEntity>> deliveryPackage = distributionLoadscanEntities.stream().collect(Collectors.groupingBy(DistributionLoadscanEntity::getPackageId));
// Iterator<Map.Entry<Long, List<DistributionLoadscanEntity>>> iterator = trayPackage.entrySet().iterator();
// while (iterator.hasNext()) {
// Map.Entry<Long, List<DistributionLoadscanEntity>> entry = iterator.next();
// Long key = entry.getKey();
// List<DistributionLoadscanEntity> loadscanEntities = deliveryPackage.get(key);
// if (Func.isEmpty(deliveryPackage.get(entry.getKey()))) {
// //todo 未完成代码
// }
//
// distributionLoadscanMapper.updateByPackageId(e.getId());
// }
//// trayPackage.forEach((k,v)->{
//// //这里就是托盘出现了配送任务中没有的包件
//// if (Func.isEmpty(deliveryPackage.get(k))){
//// return Resp.scanSuccess("串货", "串货");
//// }
//// });
//
//
// if (distributionLoadscanEntities.size() <= 0) {
// return Resp.scanSuccess("串货", "串货");
// }
// //库存品
//
// //查询该包条是否属于该配送任务
// List<DistributionLoadscaninvnEntity> distributionLoadscanvnEntities = baseMapper.selectdeliveryworkVn(distrilbutionloadingscanDTO.getBarcode(), distrilbutionloadingscanDTO.getDeliveryId());
// if (distributionLoadscanvnEntities.size() <= 0) {
// return Resp.scanSuccess("串货", "串货");
// }
// for (DistributionLoadscanEntity distributionLoadscanEntity : distributionLoadscanEntities) {
// //查询是否重复扫码
// List<DistributionLoadscanEntity> distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper<DistributionLoadscanEntity>().lambda()
// .eq(DistributionLoadscanEntity::getDeliveryId, distributionLoadscanEntity.getDeliveryId())
// .eq(DistributionLoadscanEntity::getOrderPackageCode, distributionLoadscanEntity.getOrderPackageCode())
// .ne(DistributionLoadscanEntity::getScanStatus, 1)
// );
// if (!distributionLoadscanEntitiesflag.isEmpty()) {
// return Resp.scanSuccess("有扫描过的货物", "有扫描过的货物");
// }
// if (!Objects.equals(distributionLoadscanEntity.getDeliveryId(), distrilbutionloadingscanDTO.getDeliveryId())) {
// return Resp.scanSuccess("有其他车次货物", "有其他车次货物");
// }
// //依次插入该装车记录,设置车辆
// if (null != distributionDeliverySelfEntity.getDriverId()) {
// distributionLoadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId());
// }
// distributionLoadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName());
// distributionLoadscanEntity.setScanStatus(LoadingStatusConstant.saomiao.getValue());
// distributionLoadscanEntity.setScanType("2");
// distributionLoadscanEntity.setScanTime(new Date());
// distributionLoadscanEntity.setTrayNo(distributionLoadscanEntity.getOrderPackageCode());
// distributionLoadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId());
// distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub());
// if (null != distributionDeliverySelfEntity.getDriverPhone()) {
// distributionLoadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone());
// }
// if (null != distributionDeliverySelfEntity.getVehicleId()) {
// distributionLoadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId());
// }
// //查询本车次是否第一次扫码,没有则更新上车时间
// Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId());
// //更新签收表的装车数量
// Integer j = distributionSignforMapper.updateloadByReservationId(distributionLoadscanEntity.getDeliveryId(), distributionLoadscanEntity.getReservationId(), distributionLoadscanEntity.getPackageNub());
// }
// distributionLoadscanService.saveBatch(distributionLoadscanEntities);
//
// for (DistributionLoadscaninvnEntity distributionLoadscanEntity : distributionLoadscanvnEntities) {
// //查询是否重复扫码
// List<DistributionLoadscanEntity> distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper<DistributionLoadscanEntity>().lambda()
// .eq(DistributionLoadscanEntity::getDeliveryId, distributionLoadscanEntity.getDeliveryId())
// .eq(DistributionLoadscanEntity::getOrderPackageCode, distributionLoadscanEntity.getOrderPackageCode())
// .ne(DistributionLoadscanEntity::getScanStatus, 1)
// );
// if (!distributionLoadscanEntitiesflag.isEmpty()) {
// return Resp.scanSuccess("重复扫描", "重复扫描");
// }
// //依次插入该装车记录,设置车辆
// if (null != distributionDeliverySelfEntity.getDriverId()) {
// distributionLoadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId());
// }
// distributionLoadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName());
// distributionLoadscanEntity.setScanStatus(LoadingStatusConstant.saomiao.getValue());
// distributionLoadscanEntity.setScanType("1");
// distributionLoadscanEntity.setScanTime(new Date());
// distributionLoadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId());
// distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub());
// if (null != distributionDeliverySelfEntity.getDriverPhone()) {
// distributionLoadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone());
// }
// if (null != distributionDeliverySelfEntity.getVehicleId()) {
// distributionLoadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId());
// }
// //查询本车次是否第一次扫码,没有则更新上车时间
// Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId());
// //更新签收表的装车数量
// Integer j = distributionSignforMapper.updateloadByReservationId(distributionLoadscanEntity.getDeliveryId(), distributionLoadscanEntity.getReservationId(), 1);
// }
// } else if (distrilbutionloadingscanDTO.getStockType() == 2) {
// //库存品
// //查询该包条是否属于该配送任务
// List<DistributionLoadscaninvnEntity> distributionLoadscanvnEntities = baseMapper.selectdeliveryworkVn(distrilbutionloadingscanDTO.getBarcode(), distrilbutionloadingscanDTO.getDeliveryId());
// if (distributionLoadscanvnEntities.size() <= 0) {
// return R.fail(3001, "窜货");
// distributionLoadscaninvnService.saveBatch(distributionLoadscanvnEntities);
// } else if (distrilbutionloadingscanDTO.getType() == 3) {
// //订单扫描,查询该订单是否有数据
// DistributionReservationStockarticleEntity distributionReservationStockarticleEntity = distributionReservationStockarticleMapper.selectOne(
// new QueryWrapper<DistributionReservationStockarticleEntity>().lambda()
// .eq(DistributionReservationStockarticleEntity::getStockArticleId, distrilbutionloadingscanDTO.getBarcode()));
// if (distributionReservationStockarticleEntity.getIsHaveData() == 1) {
// //查询订单是否属于该配送任务
// List<DistributionLoadscanEntity> distributionLoadscanEntities = baseMapper.selectOrderpallet(distrilbutionloadingscanDTO.getBarcode(), distrilbutionloadingscanDTO.getDeliveryId());
// for (DistributionLoadscanEntity distributionLoadscanEntity : distributionLoadscanEntities) {
// //查询是否重复扫码
// List<DistributionLoadscanEntity> distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper<DistributionLoadscanEntity>().lambda()
// .eq(DistributionLoadscanEntity::getDeliveryId, distributionLoadscanEntity.getDeliveryId())
// .eq(DistributionLoadscanEntity::getOrderPackageCode, distributionLoadscanEntity.getOrderPackageCode())
// .ne(DistributionLoadscanEntity::getScanStatus, 1)
// );
// if (!distributionLoadscanEntitiesflag.isEmpty()) {
// return Resp.scanSuccess("重复扫描", "重复扫描");
// }
// //依次插入该装车记录,设置车辆
// if (null != distributionDeliverySelfEntity.getDriverId()) {
// distributionLoadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId());
// }
// distributionLoadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName());
// distributionLoadscanEntity.setScanStatus(LoadingStatusConstant.saomiao.getValue());
// distributionLoadscanEntity.setScanType("3");
// distributionLoadscanEntity.setScanTime(new Date());
// distributionLoadscanEntity.setScanState(1);
// distributionLoadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId());
// distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub());
// if (null != distributionDeliverySelfEntity.getDriverPhone()) {
// distributionLoadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone());
// }
// if (null != distributionDeliverySelfEntity.getVehicleId()) {
// distributionLoadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId());
// }
// //查询本车次是否第一次扫码,没有则更新上车时间
// Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId());
// //更新签收表的装车数量
// Integer j = distributionSignforMapper.updateloadByReservationId(distributionLoadscanEntity.getDeliveryId(), distributionLoadscanEntity.getReservationId(), distributionLoadscanEntity.getPackageNub());
// }
// for (DistributionLoadscaninvnEntity distributionLoadscanEntity : distributionLoadscanvnEntities) {
// distributionLoadscanService.saveBatch(distributionLoadscanEntities);
// } else {
// //查询订单是否属于该配送任务
// List<DistributionLoadscanEntity> distributionLoadscanEntities = baseMapper.selectOrderStrip(distrilbutionloadingscanDTO.getBarcode(), distrilbutionloadingscanDTO.getDeliveryId());
// for (DistributionLoadscanEntity distributionLoadscanEntity : distributionLoadscanEntities) {
// //查询是否重复扫码
// List<DistributionLoadscanEntity> distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper<DistributionLoadscanEntity>().lambda()
// .eq(DistributionLoadscanEntity::getDeliveryId, distributionLoadscanEntity.getReservationId())
// .eq(DistributionLoadscanEntity::getDeliveryId, distributionLoadscanEntity.getDelivery Id())
// .eq(DistributionLoadscanEntity::getOrderPackageCode, distributionLoadscanEntity.getOrderPackageCode())
// .ne(DistributionLoadscanEntity::getScanStatus, 1)
// );
// if (distributionLoadscanEntitiesflag.size() > 0) {
// return R.fail(3002, "重复扫码");
// if (!distributionLoadscanEntitiesflag.isEmpty() ) {
// return Resp.scanSuccess("重复扫描", "重复扫描 ");
// }
// //依次插入该装车记录,设置车辆
// if (null != distributionDeliverySelfEntity.getDriverId()) {
// distributionLoadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId());
// }
// distributionLoadscanEntity.setDriverId(distrilbutionloadingscanDTO.getLoadingId());
// distributionLoadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName());
// distributionLoadscanEntity.setScanStatus(2);
// distributionLoadscanEntity.setScanType("1");
// distributionLoadscanEntity.setScanStatus(LoadingStatusConstant.saomiao.getValue());
// distributionLoadscanEntity.setScanTime(new Date());
// distributionLoadscanEntity.setScanType("3");
// distributionLoadscanEntity.setLoadingId(distrilbutionloadingscanDTO.getLoadingId());
// distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub());
// if (null != distributionDeliverySelfEntity.getDriverPhone()) {
@ -544,225 +975,32 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
// if (null != distributionDeliverySelfEntity.getVehicleId()) {
// distributionLoadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId());
// }
// //distributionLoadscanEntity.setVehicleName(distributionDeliverySelfEntity.);
// //依次更新该装车记录,设置车辆
// // distributionLoadscanMapper.updateSumById(distributionLoadscanEntity.getId(), distrilbutionloadingscanDTO);
//// distributionLoadscanordMapper.updateSumById(distributionLoadscanEntity.getOrderId(),distrilbutionloadingscanDTO);
//// distributionLoadscanresMapper.updateSumById(distributionLoadscanEntity.getReservationId(),distrilbutionloadingscanDTO);
// //查询本车次是否第一次扫码,没有则更新上车时间
// Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId());
// //更新签收表的装车数量
// Integer j = distributionSignforMapper.updateloadByReservationId(distributionLoadscanEntity.getReservationId(), 1);
//
// Integer j = distributionSignforMapper.updateloadByReservationId(distributionLoadscanEntity.getDeliveryId(), distributionLoadscanEntity.getReservationId(), distributionLoadscanEntity.getPackageNub());
// }
// distributionLoadscaninvnService.saveBatch(distributionLoadscanvnEntities);
//
// distributionLoadscanService.saveBatch(distributionLoadscanEntities);
// }
} else if ( distrilbutionloadingscanDTO . getType ( ) = = 2 ) {
//TODO 托盘扫描
//查询出该托盘下的所有货物
List < DistributionLoadscanEntity > parcelListEntityList = baseMapper . selectTrayPackageList ( distrilbutionloadingscanDTO . getBarcode ( ) ) ;
//查询出配送任务下的所有包件信息
Map < Long , List < DistributionLoadscanEntity > > trayPackage = parcelListEntityList . stream ( ) . collect ( Collectors . groupingBy ( DistributionLoadscanEntity : : getPackageId ) ) ;
//查询该包条是否属于该配送任务
List < DistributionLoadscanEntity > distributionLoadscanEntities = baseMapper . selectdeliverypallet ( distrilbutionloadingscanDTO . getBarcode ( ) , distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
Map < Long , List < DistributionLoadscanEntity > > deliveryPackage = distributionLoadscanEntities . stream ( ) . collect ( Collectors . groupingBy ( DistributionLoadscanEntity : : getPackageId ) ) ;
Iterator < Map . Entry < Long , List < DistributionLoadscanEntity > > > iterator = trayPackage . entrySet ( ) . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
Map . Entry < Long , List < DistributionLoadscanEntity > > entry = iterator . next ( ) ;
Long key = entry . getKey ( ) ;
List < DistributionLoadscanEntity > loadscanEntities = deliveryPackage . get ( key ) ;
if ( Func . isEmpty ( deliveryPackage . get ( entry . getKey ( ) ) ) ) {
//todo 未完成代码
}
}
// trayPackage.forEach((k,v)->{
// //这里就是托盘出现了配送任务中没有的包件
// if (Func.isEmpty(deliveryPackage.get(k))){
// return Resp.scanSuccess("串货", "串货");
// }
// });
if ( distributionLoadscanEntities . size ( ) < = 0 ) {
return Resp . scanSuccess ( "串货" , "串货" ) ;
}
//库存品
//查询该包条是否属于该配送任务
List < DistributionLoadscaninvnEntity > distributionLoadscanvnEntities = baseMapper . selectdeliveryworkVn ( distrilbutionloadingscanDTO . getBarcode ( ) , distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
if ( distributionLoadscanvnEntities . size ( ) < = 0 ) {
return Resp . scanSuccess ( "串货" , "串货" ) ;
}
for ( DistributionLoadscanEntity distributionLoadscanEntity : distributionLoadscanEntities ) {
//查询是否重复扫码
List < DistributionLoadscanEntity > distributionLoadscanEntitiesflag = distributionLoadscanMapper . selectList ( new QueryWrapper < DistributionLoadscanEntity > ( ) . lambda ( )
. eq ( DistributionLoadscanEntity : : getDeliveryId , distributionLoadscanEntity . getDeliveryId ( ) )
. eq ( DistributionLoadscanEntity : : getOrderPackageCode , distributionLoadscanEntity . getOrderPackageCode ( ) )
. ne ( DistributionLoadscanEntity : : getScanStatus , 1 )
) ;
if ( ! distributionLoadscanEntitiesflag . isEmpty ( ) ) {
return Resp . scanSuccess ( "有扫描过的货物" , "有扫描过的货物" ) ;
}
if ( ! Objects . equals ( distributionLoadscanEntity . getDeliveryId ( ) , distrilbutionloadingscanDTO . getDeliveryId ( ) ) ) {
return Resp . scanSuccess ( "有其他车次货物" , "有其他车次货物" ) ;
}
//依次插入该装车记录,设置车辆
if ( null ! = distributionDeliverySelfEntity . getDriverId ( ) ) {
distributionLoadscanEntity . setDriverId ( distributionDeliverySelfEntity . getDriverId ( ) ) ;
}
distributionLoadscanEntity . setDriverName ( distributionDeliverySelfEntity . getDriverName ( ) ) ;
distributionLoadscanEntity . setScanStatus ( LoadingStatusConstant . saomiao . getValue ( ) ) ;
distributionLoadscanEntity . setScanType ( "2" ) ;
distributionLoadscanEntity . setScanTime ( new Date ( ) ) ;
distributionLoadscanEntity . setTrayNo ( distributionLoadscanEntity . getOrderPackageCode ( ) ) ;
distributionLoadscanEntity . setLoadingId ( distrilbutionloadingscanDTO . getLoadingId ( ) ) ;
distributionLoadscanEntity . setVehicleName ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ;
if ( null ! = distributionDeliverySelfEntity . getDriverPhone ( ) ) {
distributionLoadscanEntity . setDriverPhone ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ;
}
if ( null ! = distributionDeliverySelfEntity . getVehicleId ( ) ) {
distributionLoadscanEntity . setVehicleId ( distributionDeliverySelfEntity . getVehicleId ( ) ) ;
}
//查询本车次是否第一次扫码,没有则更新上车时间
Integer i = distributionDeliveryListMapper . updateloadingTimeById ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
//更新签收表的装车数量
Integer j = distributionSignforMapper . updateloadByReservationId ( distributionLoadscanEntity . getDeliveryId ( ) , distributionLoadscanEntity . getReservationId ( ) , distributionLoadscanEntity . getPackageNub ( ) ) ;
}
distributionLoadscanService . saveBatch ( distributionLoadscanEntities ) ;
for ( DistributionLoadscaninvnEntity distributionLoadscanEntity : distributionLoadscanvnEntities ) {
//查询是否重复扫码
List < DistributionLoadscanEntity > distributionLoadscanEntitiesflag = distributionLoadscanMapper . selectList ( new QueryWrapper < DistributionLoadscanEntity > ( ) . lambda ( )
. eq ( DistributionLoadscanEntity : : getDeliveryId , distributionLoadscanEntity . getDeliveryId ( ) )
. eq ( DistributionLoadscanEntity : : getOrderPackageCode , distributionLoadscanEntity . getOrderPackageCode ( ) )
. ne ( DistributionLoadscanEntity : : getScanStatus , 1 )
) ;
if ( ! distributionLoadscanEntitiesflag . isEmpty ( ) ) {
return Resp . scanSuccess ( "重复扫描" , "重复扫描" ) ;
}
//依次插入该装车记录,设置车辆
if ( null ! = distributionDeliverySelfEntity . getDriverId ( ) ) {
distributionLoadscanEntity . setDriverId ( distributionDeliverySelfEntity . getDriverId ( ) ) ;
}
distributionLoadscanEntity . setDriverName ( distributionDeliverySelfEntity . getDriverName ( ) ) ;
distributionLoadscanEntity . setScanStatus ( LoadingStatusConstant . saomiao . getValue ( ) ) ;
distributionLoadscanEntity . setScanType ( "1" ) ;
distributionLoadscanEntity . setScanTime ( new Date ( ) ) ;
distributionLoadscanEntity . setLoadingId ( distrilbutionloadingscanDTO . getLoadingId ( ) ) ;
distributionLoadscanEntity . setVehicleName ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ;
if ( null ! = distributionDeliverySelfEntity . getDriverPhone ( ) ) {
distributionLoadscanEntity . setDriverPhone ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ;
}
if ( null ! = distributionDeliverySelfEntity . getVehicleId ( ) ) {
distributionLoadscanEntity . setVehicleId ( distributionDeliverySelfEntity . getVehicleId ( ) ) ;
}
//查询本车次是否第一次扫码,没有则更新上车时间
Integer i = distributionDeliveryListMapper . updateloadingTimeById ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
//更新签收表的装车数量
Integer j = distributionSignforMapper . updateloadByReservationId ( distributionLoadscanEntity . getDeliveryId ( ) , distributionLoadscanEntity . getReservationId ( ) , 1 ) ;
}
distributionLoadscaninvnService . saveBatch ( distributionLoadscanvnEntities ) ;
} else if ( distrilbutionloadingscanDTO . getType ( ) = = 3 ) {
//订单扫描,查询该订单是否有数据
DistributionReservationStockarticleEntity distributionReservationStockarticleEntity = distributionReservationStockarticleMapper . selectOne (
new QueryWrapper < DistributionReservationStockarticleEntity > ( ) . lambda ( )
. eq ( DistributionReservationStockarticleEntity : : getStockArticleId , distrilbutionloadingscanDTO . getBarcode ( ) ) ) ;
if ( distributionReservationStockarticleEntity . getIsHaveData ( ) = = 1 ) {
//查询订单是否属于该配送任务
List < DistributionLoadscanEntity > distributionLoadscanEntities = baseMapper . selectOrderpallet ( distrilbutionloadingscanDTO . getBarcode ( ) , distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
for ( DistributionLoadscanEntity distributionLoadscanEntity : distributionLoadscanEntities ) {
//查询是否重复扫码
List < DistributionLoadscanEntity > distributionLoadscanEntitiesflag = distributionLoadscanMapper . selectList ( new QueryWrapper < DistributionLoadscanEntity > ( ) . lambda ( )
. eq ( DistributionLoadscanEntity : : getDeliveryId , distributionLoadscanEntity . getDeliveryId ( ) )
. eq ( DistributionLoadscanEntity : : getOrderPackageCode , distributionLoadscanEntity . getOrderPackageCode ( ) )
. ne ( DistributionLoadscanEntity : : getScanStatus , 1 )
) ;
if ( ! distributionLoadscanEntitiesflag . isEmpty ( ) ) {
return Resp . scanSuccess ( "重复扫描" , "重复扫描" ) ;
}
//依次插入该装车记录,设置车辆
if ( null ! = distributionDeliverySelfEntity . getDriverId ( ) ) {
distributionLoadscanEntity . setDriverId ( distributionDeliverySelfEntity . getDriverId ( ) ) ;
}
distributionLoadscanEntity . setDriverName ( distributionDeliverySelfEntity . getDriverName ( ) ) ;
distributionLoadscanEntity . setScanStatus ( LoadingStatusConstant . saomiao . getValue ( ) ) ;
distributionLoadscanEntity . setScanType ( "3" ) ;
distributionLoadscanEntity . setScanTime ( new Date ( ) ) ;
distributionLoadscanEntity . setScanState ( 1 ) ;
distributionLoadscanEntity . setLoadingId ( distrilbutionloadingscanDTO . getLoadingId ( ) ) ;
distributionLoadscanEntity . setVehicleName ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ;
if ( null ! = distributionDeliverySelfEntity . getDriverPhone ( ) ) {
distributionLoadscanEntity . setDriverPhone ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ;
}
if ( null ! = distributionDeliverySelfEntity . getVehicleId ( ) ) {
distributionLoadscanEntity . setVehicleId ( distributionDeliverySelfEntity . getVehicleId ( ) ) ;
}
//查询本车次是否第一次扫码,没有则更新上车时间
Integer i = distributionDeliveryListMapper . updateloadingTimeById ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
//更新签收表的装车数量
Integer j = distributionSignforMapper . updateloadByReservationId ( distributionLoadscanEntity . getDeliveryId ( ) , distributionLoadscanEntity . getReservationId ( ) , distributionLoadscanEntity . getPackageNub ( ) ) ;
}
distributionLoadscanService . saveBatch ( distributionLoadscanEntities ) ;
} else {
//查询订单是否属于该配送任务
List < DistributionLoadscanEntity > distributionLoadscanEntities = baseMapper . selectOrderStrip ( distrilbutionloadingscanDTO . getBarcode ( ) , distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
for ( DistributionLoadscanEntity distributionLoadscanEntity : distributionLoadscanEntities ) {
//查询是否重复扫码
List < DistributionLoadscanEntity > distributionLoadscanEntitiesflag = distributionLoadscanMapper . selectList ( new QueryWrapper < DistributionLoadscanEntity > ( ) . lambda ( )
. eq ( DistributionLoadscanEntity : : getDeliveryId , distributionLoadscanEntity . getDeliveryId ( ) )
. eq ( DistributionLoadscanEntity : : getOrderPackageCode , distributionLoadscanEntity . getOrderPackageCode ( ) )
. ne ( DistributionLoadscanEntity : : getScanStatus , 1 )
) ;
if ( ! distributionLoadscanEntitiesflag . isEmpty ( ) ) {
return Resp . scanSuccess ( "重复扫描" , "重复扫描" ) ;
}
//依次插入该装车记录,设置车辆
if ( null ! = distributionDeliverySelfEntity . getDriverId ( ) ) {
distributionLoadscanEntity . setDriverId ( distributionDeliverySelfEntity . getDriverId ( ) ) ;
}
distributionLoadscanEntity . setDriverId ( distrilbutionloadingscanDTO . getLoadingId ( ) ) ;
distributionLoadscanEntity . setDriverName ( distributionDeliverySelfEntity . getDriverName ( ) ) ;
distributionLoadscanEntity . setScanStatus ( LoadingStatusConstant . saomiao . getValue ( ) ) ;
distributionLoadscanEntity . setScanTime ( new Date ( ) ) ;
distributionLoadscanEntity . setScanType ( "3" ) ;
distributionLoadscanEntity . setLoadingId ( distrilbutionloadingscanDTO . getLoadingId ( ) ) ;
distributionLoadscanEntity . setVehicleName ( distributionDeliverySelfEntity . getVehicleNub ( ) ) ;
if ( null ! = distributionDeliverySelfEntity . getDriverPhone ( ) ) {
distributionLoadscanEntity . setDriverPhone ( distributionDeliverySelfEntity . getDriverPhone ( ) ) ;
}
if ( null ! = distributionDeliverySelfEntity . getVehicleId ( ) ) {
distributionLoadscanEntity . setVehicleId ( distributionDeliverySelfEntity . getVehicleId ( ) ) ;
}
//查询本车次是否第一次扫码,没有则更新上车时间
Integer i = distributionDeliveryListMapper . updateloadingTimeById ( distrilbutionloadingscanDTO . getDeliveryId ( ) ) ;
//更新签收表的装车数量
Integer j = distributionSignforMapper . updateloadByReservationId ( distributionLoadscanEntity . getDeliveryId ( ) , distributionLoadscanEntity . getReservationId ( ) , distributionLoadscanEntity . getPackageNub ( ) ) ;
}
distributionLoadscanService . saveBatch ( distributionLoadscanEntities ) ;
}
}
Long deliveryId = distrilbutionloadingscanDTO . getDeliveryId ( ) ;
// distributionAsyncService.changeOrderStatus(distrilbutionloadingscanDTO.getBarcode(),deliveryId);
//修改配送任务状态
String barcode = distrilbutionloadingscanDTO . getBarcode ( ) ;
DistributionDeliveryListEntity deliveryListEntity = distributionDeliveryListMapper . selectOne ( Wrappers . < DistributionDeliveryListEntity > query ( ) . lambda ( ) . eq ( DistributionDeliveryListEntity : : getId , deliveryId ) ) ;
//判断配送计划是否需要进行库存品状态的变更
if ( deliveryListEntity . getType ( ) . equals ( DistributionTypeConstant . shangpei . getValue ( ) ) ) {
distributionAsyncService . changeDiscussDeliveryListStatus ( barcode , deliveryId ) ;
} else if ( deliveryListEntity . getType ( ) . equals ( DistributionTypeConstant . shipie . getValue ( ) ) ) {
//需要判断是否依据库存品进行变更
distributionAsyncService . changeMarketDeliveryListStatus ( barcode , deliveryId ) ;
}
// }
// Long deliveryId = distrilbutionloadingscanDTO.getDeliveryId();
//// distributionAsyncService.changeOrderStatus(distrilbutionloadingscanDTO.getBarcode(),deliveryId);
// //修改配送任务状态
// String barcode = distrilbutionloadingscanDTO.getBarcode();
// DistributionDeliveryListEntity deliveryListEntity = distributionDeliveryListMapper.selectOne(Wrappers.<DistributionDeliveryListEntity>query().lambda().eq(DistributionDeliveryListEntity::getId, deliveryId));
// //判断配送计划是否需要进行库存品状态的变更
// if (deliveryListEntity.getType().equals(DistributionTypeConstant.shangpei.getValue())) {
// distributionAsyncService.changeDiscussDeliveryListStatus(barcode, deliveryId);
// } else if (deliveryListEntity.getType().equals(DistributionTypeConstant.shipie.getValue())) {
// //需要判断是否依据库存品进行变更
// distributionAsyncService.changeMarketDeliveryListStatus(barcode, deliveryId);
//
//
// }
// this.changeDeliveryListStatuss(distrilbutionloadingscanDTO.getBarcode(), deliveryId);
return Resp . scanSuccess ( "成功" , "成功" ) ;
}
// return Resp.scanSuccess("成功", "成功");
// }
@Transactional ( isolation = Isolation . READ_UNCOMMITTED , rollbackFor = Exception . class )
public void changeDeliveryListStatuss ( String barcode , Long deliveryId ) {
@ -3305,6 +3543,13 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
return list ;
}
@Override
public IPage < DistributionAppReservationVO > getAppDeliveryreservationTraysPage ( IPage < DistributionAppReservationVO > page , DistributionAppDeliveryListDTO distributionDeliveryList ) {
// ---------------------------------2023-09-25 新增托盘详情---------------------------------------------------------------------------------------
List < DistributionAppReservationVO > customList = distributionDeliveryInfoMapper . selectAppTarysListPage ( page , Long . parseLong ( distributionDeliveryList . getReservationId ( ) ) ) ;
return page . setRecords ( customList ) ;
}
public Map < String , String > getDriverCar ( String kind , Long deliveryListEntityId ) {
Map < String , String > map = new HashMap < > ( ) ;
String dirverName = null ;