@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logpm.aftersales.entity.AftersalesAbnormalRecordEntity ;
import com.logpm.aftersales.feign.IAftersalesAbnormalRecordClient ;
import com.logpm.aftersales.feign.IAftersalesWorkOrderClient ;
import com.logpm.aftersales.vo.DealWithAbnormalVO ;
import com.logpm.basicdata.entity.BasicdataDriverArteryEntity ;
import com.logpm.basicdata.entity.BasicdataTrayEntity ;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity ;
@ -55,6 +56,7 @@ import com.logpm.warehouse.feign.IWarehouseTrayTypeClient;
import com.logpm.warehouse.feign.IWarehouseUpdownTypeClient ;
import com.logpm.warehouse.feign.IWarehouseWaybillClient ;
import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient ;
import com.logpm.warehouse.vo.WarehouseWaybillVO ;
import com.logpm.warehouse.vo.WaybillOrderTotalWeightAndVolumeVO ;
import lombok.AllArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
@ -67,6 +69,7 @@ import org.springblade.common.exception.CustomerException;
import org.springblade.common.utils.CommonUtil ;
import org.springblade.common.utils.QRCodeUtil ;
import org.springblade.core.mp.base.BaseServiceImpl ;
import org.springblade.core.redis.cache.BladeRedis ;
import org.springblade.core.secure.utils.AuthUtil ;
import org.springblade.core.tool.api.R ;
import org.springblade.core.tool.utils.BeanUtil ;
@ -133,6 +136,9 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
private final ITrunklineWaybillTrackService waybillTrackService ;
private final ITrunklineScanZeroDetailService scanZeroDetailService ;
private final ITrunklineCarsLoadLinePhotoService carsLoadLinePhotoService ;
private final ITrunklineAdvanceService advanceService ;
private final BladeRedis bladeRedis ;
@Override
public IPage < TrunklineCarsLoadVO > loadCarsPageList ( LoadCarsDTO loadCarsDTO ) {
@ -3582,6 +3588,10 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
if ( Objects . isNull ( trunklineAdvanceDetailEntity ) ) {
carsLoadScanEntity . setOrderCode ( "--" ) ;
carsLoadScanEntity . setIsData ( 0 ) ;
carsLoadScanEntity . setReserve1 ( "1" ) ;
//把其他仓reserve1为1的更新为2
trunklineCarsLoadScanService . updateReserve1ByOrderPackageCode ( orderPackageCode , "2" ) ;
isData = 0 ;
remark = "无系统数据,异常装车" ;
audio = "系统无编码" ;
@ -4524,6 +4534,294 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
return R . data ( orderScanDetailList ) ;
}
@Override
public R carsLoadDetailInfoNew ( LoadCarsDTO loadCarsDTO ) {
Long loadId = loadCarsDTO . getLoadId ( ) ;
//查询配载计划
TrunklineCarsLoadEntity carsLoadEntity = baseMapper . selectById ( loadId ) ;
if ( Objects . isNull ( carsLoadEntity ) ) {
log . warn ( "###################carsLoadDetailInfo: 配载计划信息为空 loadId={}" , loadId ) ;
return R . fail ( 405 , "配载计划信息为空" ) ;
}
BigDecimal countTransportCost = carsLoadEntity . getCountTransportCost ( ) ;
Integer unloadNumber = carsLoadEntity . getUnloadNumber ( ) ;
BigDecimal freightPrice = countTransportCost . divide ( new BigDecimal ( unloadNumber ) , 2 , RoundingMode . HALF_UP ) ;
List < TrunklineCarsLoadLineEntity > loadLineList = trunklineCarsLoadLineService . findListByLoadId ( loadId ) ;
TrunklineCarsLoadVO trunklineCarsLoadVO = new TrunklineCarsLoadVO ( ) ;
BeanUtil . copy ( carsLoadEntity , trunklineCarsLoadVO ) ;
trunklineCarsLoadVO . setCarsLoadLineList ( loadLineList ) ;
//所有车辆配载计划
List < TrunklineCarsOrderEntity > carsOrderList = trunklineCarsOrderService . findListByLoadId ( loadId ) ;
//把carsOrderList中所有waybillNo放入一个List
Set < String > planWaybillNoSet = carsOrderList . stream ( ) . map ( TrunklineCarsOrderEntity : : getWaybillNo ) . collect ( Collectors . toSet ( ) ) ;
//把carsOrderList通过waybillNo进行分组
Map < String , List < TrunklineCarsOrderEntity > > carsOrderMapByWaybillNo = carsOrderList . stream ( ) . filter ( item - > StringUtil . isNotBlank ( item . getWaybillNo ( ) ) ) . collect ( Collectors . groupingBy ( TrunklineCarsOrderEntity : : getWaybillNo ) ) ;
//所有车辆配载实际装车
List < TrunklineCarsLoadScanVO > loadScanList = trunklineCarsLoadScanService . findListAndPriceByLoadId ( loadId ) ;
//把carsOrderList中所有waybillNo放入一个List
Set < String > realWaybillNoSet = loadScanList . stream ( ) . filter ( item - > StringUtil . isNotBlank ( item . getWaybillNo ( ) ) ) . map ( TrunklineCarsLoadScanVO : : getWaybillNo ) . collect ( Collectors . toSet ( ) ) ;
//把loadScanList通过waybillNo分组
Map < String , List < TrunklineCarsLoadScanVO > > loadScanMapByWaybillNo = loadScanList . stream ( ) . filter ( item - > StringUtil . isNotBlank ( item . getWaybillNo ( ) ) ) . collect ( Collectors . groupingBy ( TrunklineCarsLoadScanVO : : getWaybillNo ) ) ;
//提出loadScanList中运单号为空的记录
List < TrunklineCarsLoadScanVO > noWaybillLoadScanList = loadScanList . stream ( ) . filter ( item - > StringUtil . isBlank ( item . getWaybillNo ( ) ) ) . collect ( Collectors . toList ( ) ) ;
//先把所有需要查询的运单信息查出来
Set < String > allWaybillNoSet = new HashSet < > ( ) ;
allWaybillNoSet . addAll ( planWaybillNoSet ) ;
allWaybillNoSet . addAll ( realWaybillNoSet ) ;
List < WarehouseWaybillVO > warehouseWaybillVOS = warehouseWaybillClient . findWaybillVOByWaybillNoSet ( allWaybillNoSet ) ;
List < CarsLoadWaybillInfoVO > carsLoadWaybillInfoVOList = new ArrayList < > ( ) ;
warehouseWaybillVOS . forEach ( item - > {
CarsLoadWaybillInfoVO carsLoadWaybillInfoVO = new CarsLoadWaybillInfoVO ( ) ;
BeanUtil . copy ( item , carsLoadWaybillInfoVO ) ;
String waybillNo = carsLoadWaybillInfoVO . getWaybillNo ( ) ;
Integer waybillNum = carsLoadWaybillInfoVO . getWaybillNum ( ) ;
String goodsName = carsLoadWaybillInfoVO . getGoodsName ( ) ;
String productPrice = carsLoadWaybillInfoVO . getProductPrice ( ) ;
String productNum = carsLoadWaybillInfoVO . getProductNum ( ) ;
String productVolume = carsLoadWaybillInfoVO . getProductVolume ( ) ;
String productWeight = carsLoadWaybillInfoVO . getProductWeight ( ) ;
String [ ] nameArray = goodsName . split ( "," ) ;
String [ ] priceArray = productPrice . split ( "," ) ;
String [ ] numArray = productNum . split ( "," ) ;
String [ ] volumeArray = productVolume . split ( "," ) ;
String [ ] weightArray = productWeight . split ( "," ) ;
//计算每个品类的单个价格 体积 重量
Map < String , String > priceMap = new HashMap < > ( ) ;
Map < String , String > volumeMap = new HashMap < > ( ) ;
Map < String , String > weightMap = new HashMap < > ( ) ;
for ( int i = 0 ; i < nameArray . length ; i + + ) {
priceMap . put ( nameArray [ i ] , priceArray [ i ] ) ;
String num = numArray [ i ] ;
String volume = volumeArray [ i ] ;
String weight = weightArray [ i ] ;
volumeMap . put ( nameArray [ i ] , new BigDecimal ( volume ) . divide ( new BigDecimal ( num ) , 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
weightMap . put ( nameArray [ i ] , new BigDecimal ( weight ) . divide ( new BigDecimal ( num ) , 2 , RoundingMode . HALF_UP ) . toString ( ) ) ;
}
List < CarsLoadOrderInfoVO > resulOrderList = new ArrayList < > ( ) ;
List < TrunklineCarsOrderEntity > carsOrderEntityList = carsOrderMapByWaybillNo . get ( waybillNo ) ; //计划订单列表
List < CarsLoadOrderInfoVO > carsLoadOrderInfoVOList = new ArrayList < > ( ) ;
if ( CollUtil . isNotEmpty ( carsOrderEntityList ) ) {
carsOrderEntityList . forEach ( carsOrderEntity - > {
Integer realNum = carsOrderEntity . getRealNum ( ) ;
CarsLoadOrderInfoVO carsLoadOrderInfoVO = new CarsLoadOrderInfoVO ( ) ;
carsLoadOrderInfoVO . setOrderCode ( carsOrderEntity . getOrderCode ( ) ) ;
carsLoadOrderInfoVO . setWaybillNo ( waybillNo ) ;
carsLoadOrderInfoVO . setOrderNum ( carsOrderEntity . getTotalNum ( ) ) ;
carsLoadOrderInfoVO . setPlanNum ( carsOrderEntity . getPlanNum ( ) ) ;
carsLoadOrderInfoVO . setLoadingNum ( realNum ) ;
carsLoadOrderInfoVO . setUnloadNum ( carsOrderEntity . getUnloadNum ( ) ) ;
carsLoadOrderInfoVO . setSignNum ( carsOrderEntity . getSignNum ( ) ) ;
carsLoadOrderInfoVO . setOrderFreight ( freightPrice . multiply ( new BigDecimal ( realNum ) ) . setScale ( 2 , RoundingMode . HALF_UP ) ) ;
carsLoadOrderInfoVOList . add ( carsLoadOrderInfoVO ) ;
} ) ;
}
//把carsLoadOrderInfoVOList转化成以orderCode为key的Map
Map < String , CarsLoadOrderInfoVO > carsLoadOrderInfoVOMap = carsLoadOrderInfoVOList . stream ( ) . collect ( Collectors . toMap ( CarsLoadOrderInfoVO : : getOrderCode , Function . identity ( ) ) ) ;
List < TrunklineCarsLoadScanVO > trunklineCarsLoadScanEntities = loadScanMapByWaybillNo . get ( waybillNo ) ; //订单实际装车
if ( CollUtil . isNotEmpty ( trunklineCarsLoadScanEntities ) ) {
//把trunklineCarsLoadScanEntities通过orderCode分组
Map < String , List < TrunklineCarsLoadScanVO > > trunklineCarsLoadScanMapByOrderCode = trunklineCarsLoadScanEntities . stream ( ) . collect ( Collectors . groupingBy ( TrunklineCarsLoadScanVO : : getOrderCode ) ) ;
trunklineCarsLoadScanMapByOrderCode . keySet ( ) . forEach ( orderCode - > {
List < TrunklineCarsLoadScanVO > trunklineCarsLoadScanListByOrderCode = trunklineCarsLoadScanMapByOrderCode . get ( orderCode ) ; //订单实际装车
//把trunklineCarsLoadScanListByOrderCode中所有元素num求和,num为空用0代替
Integer loadingNum = trunklineCarsLoadScanListByOrderCode . stream ( ) . map ( TrunklineCarsLoadScanVO : : getNum ) . reduce ( 0 , Integer : : sum ) ;
Integer unloadNum = trunklineCarsLoadScanListByOrderCode . stream ( ) . map ( TrunklineCarsLoadScanVO : : getUnloadNum ) . reduce ( 0 , Integer : : sum ) ;
Integer signNum = trunklineCarsLoadScanListByOrderCode . stream ( ) . filter ( t - > t . getScanStatus ( ) . equals ( "3" ) ) . map ( TrunklineCarsLoadScanVO : : getUnloadNum ) . reduce ( 0 , Integer : : sum ) ;
CarsLoadOrderInfoVO carsLoadOrderInfoVO = carsLoadOrderInfoVOMap . get ( orderCode ) ;
if ( Objects . isNull ( carsLoadOrderInfoVO ) ) {
carsLoadOrderInfoVO = new CarsLoadOrderInfoVO ( ) ;
carsLoadOrderInfoVO . setOrderCode ( orderCode ) ;
carsLoadOrderInfoVO . setWaybillNo ( waybillNo ) ;
TrunklineWaybillOrderEntity trunklineWaybillOrder = trunklineWaybillOrderService . findEntityByWaybillNoAndOrderCode ( waybillNo , orderCode ) ;
if ( ! Objects . isNull ( trunklineWaybillOrder ) ) {
carsLoadOrderInfoVO . setOrderNum ( trunklineWaybillOrder . getTotalNumber ( ) ) ;
} else {
carsLoadOrderInfoVO . setOrderNum ( 0 ) ;
}
carsLoadOrderInfoVO . setLoadingNum ( loadingNum ) ;
carsLoadOrderInfoVO . setUnloadNum ( unloadNum ) ;
carsLoadOrderInfoVO . setSignNum ( signNum ) ;
carsLoadOrderInfoVOMap . put ( orderCode , carsLoadOrderInfoVO ) ;
}
//把trunklineCarsLoadScanListByOrderCode通过type分组
Map < Integer , List < TrunklineCarsLoadScanVO > > trunklineCarsLoadScanMapByType = trunklineCarsLoadScanListByOrderCode . stream ( ) . collect ( Collectors . groupingBy ( TrunklineCarsLoadScanVO : : getType ) ) ;
AtomicReference < BigDecimal > totalIncomingParice = new AtomicReference < > ( BigDecimal . ZERO ) ;
AtomicReference < BigDecimal > totalVolume = new AtomicReference < > ( BigDecimal . ZERO ) ;
AtomicReference < BigDecimal > totalWeight = new AtomicReference < > ( BigDecimal . ZERO ) ;
trunklineCarsLoadScanMapByType . keySet ( ) . forEach ( type - > {
List < TrunklineCarsLoadScanVO > trunklineCarsLoadScanVOS = trunklineCarsLoadScanMapByType . get ( type ) ;
if ( NumberUtil . equals ( type , 1 ) ) {
//订制品
trunklineCarsLoadScanVOS . forEach ( trunklineCarsLoadScanVO - > {
String gn = trunklineCarsLoadScanVO . getGoodsName ( ) ;
Integer num = trunklineCarsLoadScanVO . getNum ( ) ;
Integer unloadNum1 = trunklineCarsLoadScanVO . getUnloadNum ( ) ;
if ( Objects . isNull ( unloadNum1 ) ) {
unloadNum1 = 0 ;
}
String price = priceMap . get ( gn ) ;
if ( StrUtil . isBlank ( price ) ) {
price = "0" ;
}
String oneVolume = volumeMap . get ( gn ) ;
if ( StrUtil . isBlank ( oneVolume ) ) {
oneVolume = "0" ;
}
String oneWeight = weightMap . get ( gn ) ;
if ( StrUtil . isBlank ( oneWeight ) ) {
oneWeight = "0" ;
}
totalIncomingParice . set ( totalIncomingParice . get ( ) . add ( new BigDecimal ( price ) . multiply ( new BigDecimal ( unloadNum1 ) ) ) ) ;
totalVolume . set ( totalVolume . get ( ) . add ( new BigDecimal ( oneVolume ) . multiply ( new BigDecimal ( unloadNum1 ) ) ) ) ;
totalWeight . set ( totalWeight . get ( ) . add ( new BigDecimal ( oneWeight ) . multiply ( new BigDecimal ( unloadNum1 ) ) ) ) ;
} ) ;
} else if ( NumberUtil . equals ( type , 2 ) ) {
trunklineCarsLoadScanVOS . forEach ( trunklineCarsLoadScanVO - > {
String scanCode = trunklineCarsLoadScanVO . getScanCode ( ) ;
Integer num = trunklineCarsLoadScanVO . getNum ( ) ;
Integer unloadNum1 = trunklineCarsLoadScanVO . getUnloadNum ( ) ;
if ( Objects . isNull ( unloadNum1 ) ) {
unloadNum1 = 0 ;
}
String price = priceMap . get ( scanCode ) ;
if ( StrUtil . isBlank ( price ) ) {
price = "0" ;
}
String oneVolume = volumeMap . get ( scanCode ) ;
if ( StrUtil . isBlank ( oneVolume ) ) {
oneVolume = "0" ;
}
String oneWeight = weightMap . get ( scanCode ) ;
if ( StrUtil . isBlank ( oneWeight ) ) {
oneWeight = "0" ;
}
totalIncomingParice . set ( totalIncomingParice . get ( ) . add ( new BigDecimal ( price ) . multiply ( new BigDecimal ( unloadNum1 ) ) ) ) ;
totalVolume . set ( totalVolume . get ( ) . add ( new BigDecimal ( oneVolume ) . multiply ( new BigDecimal ( unloadNum1 ) ) ) ) ;
totalWeight . set ( totalWeight . get ( ) . add ( new BigDecimal ( oneWeight ) . multiply ( new BigDecimal ( unloadNum1 ) ) ) ) ;
} ) ;
}
} ) ;
carsLoadOrderInfoVO . setUnloadIncome ( totalIncomingParice . get ( ) ) ;
carsLoadOrderInfoVO . setWeight ( totalWeight . get ( ) ) ;
carsLoadOrderInfoVO . setVolume ( totalVolume . get ( ) ) ;
resulOrderList . add ( carsLoadOrderInfoVO ) ;
} ) ;
}
TrunklineCostShareRecordEntity costShareRecordEntity = trunklineCostShareRecordService . findTotalUnloadNumByLoadAndWaybillNo ( loadId , waybillNo ) ;
carsLoadWaybillInfoVO . setCostPiece ( costShareRecordEntity . getCostPiece ( ) ) ;
carsLoadWaybillInfoVO . setCostZhang ( costShareRecordEntity . getCostZhang ( ) ) ;
carsLoadWaybillInfoVO . setCostNum ( costShareRecordEntity . getNum ( ) ) ;
carsLoadWaybillInfoVO . setCarsLoadOrderInfoList ( resulOrderList ) ;
carsLoadWaybillInfoVOList . add ( carsLoadWaybillInfoVO ) ;
} ) ;
//无系统编码的数据
CarsLoadWaybillInfoVO noWaybillNoCarsLoadWaybillInfoVO = new CarsLoadWaybillInfoVO ( ) ;
noWaybillNoCarsLoadWaybillInfoVO . setCheckStatus ( 0 ) ;
noWaybillNoCarsLoadWaybillInfoVO . setWaybillNum ( 0 ) ;
noWaybillNoCarsLoadWaybillInfoVO . setTotalVolume ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setTotalWeight ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setWaybillType ( 1 ) ;
noWaybillNoCarsLoadWaybillInfoVO . setTotalFreight ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setDeliveryFee ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setPickupFee ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setWarehouseManagementFee ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setStorageFee ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setSortingFee ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setHandlingFee ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setOtherFee ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setInsuranceFee ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setTotalFee ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setCostPiece ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setCostZhang ( BigDecimal . ZERO ) ;
noWaybillNoCarsLoadWaybillInfoVO . setCostNum ( 0 ) ;
List < CarsLoadOrderInfoVO > noWaybillOrderList = new ArrayList < > ( ) ;
//把noWaybillLoadScanList通过orderCode分组
Map < String , List < TrunklineCarsLoadScanVO > > noWaybillNoTrunklineCarsLoadScanMapByOrderCode = noWaybillLoadScanList . stream ( ) . collect ( Collectors . groupingBy ( TrunklineCarsLoadScanVO : : getOrderCode ) ) ;
noWaybillNoTrunklineCarsLoadScanMapByOrderCode . keySet ( ) . forEach ( orderCode - > {
List < TrunklineCarsLoadScanVO > trunklineCarsLoadScanVOS = noWaybillNoTrunklineCarsLoadScanMapByOrderCode . get ( orderCode ) ;
//把trunklineCarsLoadScanVOS中所有元素的num加起来,如果num为空则用0代替
Integer loadingNum = trunklineCarsLoadScanVOS . stream ( ) . map ( TrunklineCarsLoadScanVO : : getNum ) . reduce ( 0 , Integer : : sum ) ;
Integer unloadNum = trunklineCarsLoadScanVOS . stream ( ) . map ( TrunklineCarsLoadScanVO : : getUnloadNum ) . reduce ( 0 , Integer : : sum ) ;
Integer signNum = trunklineCarsLoadScanVOS . stream ( ) . filter ( t - > t . getScanStatus ( ) . equals ( "3" ) ) . map ( TrunklineCarsLoadScanVO : : getUnloadNum ) . reduce ( 0 , Integer : : sum ) ;
CarsLoadOrderInfoVO carsLoadOrderInfoVO = new CarsLoadOrderInfoVO ( ) ;
carsLoadOrderInfoVO . setOrderCode ( orderCode ) ;
carsLoadOrderInfoVO . setOrderNum ( 0 ) ;
carsLoadOrderInfoVO . setPlanNum ( 0 ) ;
carsLoadOrderInfoVO . setLoadingNum ( loadingNum ) ;
carsLoadOrderInfoVO . setUnloadNum ( unloadNum ) ;
carsLoadOrderInfoVO . setSignNum ( signNum ) ;
carsLoadOrderInfoVO . setUnloadIncome ( BigDecimal . ZERO ) ;
carsLoadOrderInfoVO . setCostPiece ( BigDecimal . ZERO ) ;
carsLoadOrderInfoVO . setCostPiece ( BigDecimal . ZERO ) ;
carsLoadOrderInfoVO . setWeight ( BigDecimal . ZERO ) ;
carsLoadOrderInfoVO . setVolume ( BigDecimal . ZERO ) ;
carsLoadOrderInfoVO . setIncome ( BigDecimal . ZERO ) ;
carsLoadOrderInfoVO . setOrderFreight ( freightPrice . multiply ( new BigDecimal ( unloadNum ) ) ) ;
noWaybillOrderList . add ( carsLoadOrderInfoVO ) ;
} ) ;
noWaybillNoCarsLoadWaybillInfoVO . setCarsLoadOrderInfoList ( noWaybillOrderList ) ;
//对元素中的waybillNo进行倒序排序
carsLoadWaybillInfoVOList . sort ( Comparator . comparing ( CarsLoadWaybillInfoVO : : getWaybillNo ) . reversed ( ) ) ;
carsLoadWaybillInfoVOList . add ( noWaybillNoCarsLoadWaybillInfoVO ) ;
trunklineCarsLoadVO . setCarsLoadWaybillInfoList ( carsLoadWaybillInfoVOList ) ;
return R . data ( trunklineCarsLoadVO ) ;
}
@Override
public R carsLoadDetailInfo ( LoadCarsDTO loadCarsDTO ) {
Long loadId = loadCarsDTO . getLoadId ( ) ;
@ -9194,6 +9492,9 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
trunklineCarsLoadScanEntity . setNum ( 1 ) ;
trunklineCarsLoadScanEntity . setType ( 1 ) ;
trunklineCarsLoadScanEntity . setIsData ( 0 ) ;
trunklineCarsLoadScanEntity . setReserve1 ( "1" ) ;
//把其他仓reserve1为1的更新为2
trunklineCarsLoadScanService . updateReserve1ByOrderPackageCode ( orderPackageCode , "2" ) ;
isData = 0 ;
trunklineCarsLoadScanEntity . setLoadingAbnormal ( 1 ) ;
trunklineCarsLoadScanEntity . setUnloadAbnormal ( 1 ) ;
@ -9525,6 +9826,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
//未入库
InComingDTO inComingDTO = new InComingDTO ( ) ;
inComingDTO . setOrderPackageCode ( orderPackageCode ) ;
inComingDTO . setIncomingType ( incomingType ) ;
inComingDTO . setWarehouseId ( warehouseId ) ;
inComingService . incomingPackage ( inComingDTO ) ;
@ -9568,6 +9870,10 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
isData = 1 ;
trunklineCarsLoadScanService . updateById ( carsLoadScanEntity ) ;
} else {
carsLoadScanEntity . setReserve1 ( "1" ) ;
trunklineCarsLoadScanService . updateById ( carsLoadScanEntity ) ;
}
}
}
@ -10431,6 +10737,148 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
return pageList ;
}
@Transactional ( rollbackFor = Exception . class )
@Override
public R syncNoSystemData ( Long loadId , Long warehouseId , String warehouseName ) {
String key = "syncNoSystemData:" + loadId + ":" + warehouseId ;
Boolean exists = bladeRedis . exists ( key ) ;
if ( exists ) {
return R . fail ( "正在同步中,请勿重复操作" ) ;
} else {
bladeRedis . set ( key , "1" ) ;
}
TrunklineCarsLoadEntity carsLoadEntity = baseMapper . selectById ( loadId ) ;
if ( Objects . isNull ( carsLoadEntity ) ) {
log . warn ( "###########syncNoSystemData: 配载计划不存在 loadId={}" , loadId ) ;
return R . fail ( 405 , "配载计划不存在" ) ;
}
List < TrunklineCarsLoadScanEntity > carsLoadScanEntities = trunklineCarsLoadScanService . findUnloadNoDataList ( loadId , warehouseId ) ;
//把carsLoadScanEntities中所有元素的scanCode放入一个Set集合
Set < String > scanCodeSet = carsLoadScanEntities . stream ( ) . map ( TrunklineCarsLoadScanEntity : : getScanCode ) . collect ( Collectors . toSet ( ) ) ;
log . info ( "###############syncNoSystemData: 当前同步的数据 {}" , scanCodeSet ) ;
List < String > scanCodeList = new ArrayList < > ( scanCodeSet ) ;
List < TrunklineAdvanceDetailEntity > allAdvanceDetailList = new ArrayList < > ( ) ;
int packageBatchSize = 500 ;
List < List < String > > orderPackageCodeGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < scanCodeList . size ( ) ; i + = packageBatchSize ) {
int endIndex = Math . min ( i + packageBatchSize , scanCodeList . size ( ) ) ;
orderPackageCodeGroups . add ( scanCodeList . subList ( i , endIndex ) ) ;
}
orderPackageCodeGroups . forEach ( orderPackageCodeGroup - > {
List < TrunklineAdvanceDetailEntity > advanceDetailEntityList = trunklineAdvanceDetailService . findListByOrderPackageCodeList ( orderPackageCodeGroup ) ;
allAdvanceDetailList . addAll ( advanceDetailEntityList ) ;
} ) ;
//把allAdvanceDetailList转化成orderPackageCode为key的Map
Map < String , TrunklineAdvanceDetailEntity > advanceDetailMap = allAdvanceDetailList . stream ( ) . collect ( Collectors . toMap ( TrunklineAdvanceDetailEntity : : getOrderPackageCode , Function . identity ( ) ) ) ;
List < TrunklineCarsLoadScanEntity > updateScanList = new ArrayList < > ( ) ;
List < TrunklineAdvanceDetailEntity > incomingAdvanceDetailList = new ArrayList < > ( ) ;
List < TrunklineAdvanceDetailEntity > udateAdvanceDetailList = new ArrayList < > ( ) ;
Set < String > orderPackageCodeSet = new HashSet < > ( ) ;
carsLoadScanEntities . forEach ( carsLoadScanEntity - > {
String orderPackageCode = carsLoadScanEntity . getScanCode ( ) ;
TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity = advanceDetailMap . get ( orderPackageCode ) ;
if ( ! Objects . isNull ( trunklineAdvanceDetailEntity ) ) {
orderPackageCodeSet . add ( orderPackageCode ) ;
TrunklineCarsLoadScanEntity updateScanEntity = new TrunklineCarsLoadScanEntity ( ) ;
updateScanEntity . setId ( carsLoadScanEntity . getId ( ) ) ;
String packageStatus = trunklineAdvanceDetailEntity . getPackageStatus ( ) ;
if ( packageStatus . equals ( "0" ) ) {
updateScanEntity . setFromWarehouseId ( trunklineAdvanceDetailEntity . getWarehouseId ( ) ) ;
incomingAdvanceDetailList . add ( trunklineAdvanceDetailEntity ) ;
} else {
updateScanEntity . setFromWarehouseId ( trunklineAdvanceDetailEntity . getNowWarehouseId ( ) ) ;
udateAdvanceDetailList . add ( trunklineAdvanceDetailEntity ) ;
}
updateScanEntity . setOrderCode ( trunklineAdvanceDetailEntity . getOrderCode ( ) ) ;
updateScanEntity . setWaybillId ( trunklineAdvanceDetailEntity . getWaybillId ( ) ) ;
updateScanEntity . setWaybillNo ( trunklineAdvanceDetailEntity . getWaybillNo ( ) ) ;
updateScanEntity . setIsData ( 1 ) ;
updateScanList . add ( updateScanEntity ) ;
}
} ) ;
if ( CollUtil . isNotEmpty ( incomingAdvanceDetailList ) ) {
for ( TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity : incomingAdvanceDetailList ) {
InComingDTO inComingDTO = new InComingDTO ( ) ;
inComingDTO . setOrderPackageCode ( trunklineAdvanceDetailEntity . getOrderPackageCode ( ) ) ;
inComingDTO . setIncomingType ( IncomingTypeEnum . SYNC_INCOMING . getCode ( ) ) ;
inComingDTO . setWarehouseId ( warehouseId ) ;
R r = inComingService . incomingPackage ( inComingDTO ) ;
if ( r . getCode ( ) ! = 200 ) {
throw new CustomerException ( 405 , "入库失败" ) ;
}
}
}
if ( CollUtil . isNotEmpty ( udateAdvanceDetailList ) ) {
List < DistributionParcelListEntity > updateParceList = new ArrayList < > ( ) ;
udateAdvanceDetailList . forEach ( trunklineAdvanceDetailEntity - > {
String orderPackageCode = trunklineAdvanceDetailEntity . getOrderPackageCode ( ) ;
List < DistributionParcelListEntity > list = distributionParcelListClient . findListByOrderPackageCodeAndStatus ( orderPackageCode , "20" ) ;
//把list通过warehouseId进行分组
if ( CollUtil . isNotEmpty ( list ) ) {
list . forEach ( distributionParcelListEntity - > {
DistributionParcelListEntity updateEntity = new DistributionParcelListEntity ( ) ;
updateEntity . setId ( distributionParcelListEntity . getId ( ) ) ;
updateEntity . setOrderPackageStatus ( "60" ) ;
updateParceList . add ( updateEntity ) ;
} ) ;
}
} ) ;
distributionParcelListClient . updateList ( updateParceList ) ;
advanceService . saveOrderAndPackages ( udateAdvanceDetailList , warehouseId ) ;
List < TrunklineAdvanceDetailEntity > updateNowWarehouseList = new ArrayList < > ( ) ;
udateAdvanceDetailList . forEach ( trunklineAdvanceDetailEntity - > {
TrunklineAdvanceDetailEntity updateEntity = new TrunklineAdvanceDetailEntity ( ) ;
updateEntity . setId ( trunklineAdvanceDetailEntity . getId ( ) ) ;
updateEntity . setNowWarehouseId ( warehouseId ) ;
updateEntity . setNowWarehouseName ( warehouseName ) ;
updateNowWarehouseList . add ( updateEntity ) ;
} ) ;
trunklineAdvanceDetailService . updateBatchById ( updateNowWarehouseList ) ;
}
trunklineCarsLoadScanService . updateBatchById ( updateScanList ) ;
int i = 0 ;
//完结所有包件异常列表
if ( CollUtil . isNotEmpty ( orderPackageCodeSet ) ) {
i = orderPackageCodeSet . size ( ) ;
DealWithAbnormalVO dealWithAbnormalVO = new DealWithAbnormalVO ( ) ;
dealWithAbnormalVO . setOrderPackageCodes ( new ArrayList < > ( orderPackageCodeSet ) ) ;
dealWithAbnormalVO . setCarsNo ( carsLoadEntity . getCarsNo ( ) ) ;
dealWithAbnormalVO . setWarehouseName ( warehouseName ) ;
dealWithAbnormalVO . setNickName ( AuthUtil . getNickName ( ) ) ;
abnormalRecordClient . dealwithOrderPackageCodes ( dealWithAbnormalVO ) ;
}
bladeRedis . del ( key ) ;
return R . success ( "同步成功" + i + "条" ) ;
}
@Override
public R unloadZero ( Long carsLoadScanId , Long loadId , String waybillNo , Integer enterNun , Long warehouseId , Integer unbindTray , String trayCode , String orderCode , String remark , String unloadTrayName , String unloadTrayCode , List < ZeroPackageDTO > zeroPackageList ) {
@ -11159,3 +11607,5 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
}