@ -5,16 +5,21 @@ import com.logpm.basicdata.entity.*;
import com.logpm.basicdata.feign.* ;
import com.logpm.oldproject.entity.* ;
import com.logpm.oldproject.feign.* ;
import com.logpm.patch.service.ISendFanoutService ;
import com.logpm.patch.service.IWarehouseMappingDataService ;
import com.logpm.warehouse.feign.IWarehouseWaybillClient ;
import com.logpm.patch.vo.* ;
import com.logpm.warehouse.feign.IWarehouseUpdownTypeClient ;
import com.xxl.job.core.biz.model.ReturnT ;
import com.xxl.job.core.handler.annotation.XxlJob ;
import lombok.AllArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import org.springblade.common.constant.broadcast.FanoutConstants ;
import org.springblade.common.model.FanoutMsg ;
import org.springblade.core.tool.utils.StringUtil ;
import org.springframework.stereotype.Component ;
import java.util.* ;
import java.util.stream.Collectors ;
@Slf4j
@AllArgsConstructor
@ -28,7 +33,8 @@ public class SyncWarehouseData {
private final IBasicdataGoodsAllocationClient basicdataGoodsAllocationClient ; //货位
private final IBasicdataTrayClient basicdataTrayClient ; //托盘
private final IWarehouseWaybillClient warehouseWaybillClient ;
private final ISendFanoutService sendFanoutMsg ;
private final IWarehouseUpdownTypeClient warehouseUpdownTypeClient ;
//-----------------老系统
private final IWarehouseClient warehouseClient ; //仓库
@ -377,4 +383,270 @@ public class SyncWarehouseData {
return true ;
}
@XxlJob ( "syncAllTrayAndAllocation" )
public ReturnT < String > syncAllTrayAndAllocation ( String param ) {
log . info ( "############syncAllTrayAndAllocation: 处理所有包件零担库存品的托盘库位信息 开始 param={}" , param ) ;
//需要下架解托的包件Map
Map < Long , List < String > > delTrayAndAllocationPackageMap = new HashMap < > ( ) ;
//托盘信息
//包件
List < PackageTrayInfoVO > packageTrayList = warehouseMappingDataService . findPackageTraysInfo ( ) ;
//把packageTrayList中所有元素根据orderPackageStatus进行分组
Map < String , List < PackageTrayInfoVO > > packageTrayMap = packageTrayList . stream ( ) . collect ( Collectors . groupingBy ( PackageTrayInfoVO : : getOrderPackageStatus ) ) ;
packageTrayMap . keySet ( ) . forEach ( orderPackageStatus - > {
List < PackageTrayInfoVO > packageTrayInfoVOS = packageTrayMap . get ( orderPackageStatus ) ;
if ( ! packageTrayInfoVOS . isEmpty ( ) ) {
if ( "60" . equals ( orderPackageStatus ) | | "70" . equals ( orderPackageStatus ) ) {
//把packageTrayInfoVOS通过warehouseId进行分组,来分仓处理下架解托的包件
Map < Long , List < PackageTrayInfoVO > > packageTrayInfoVOSMap = packageTrayInfoVOS . stream ( ) . collect ( Collectors . groupingBy ( PackageTrayInfoVO : : getWarehouseId ) ) ;
packageTrayInfoVOSMap . keySet ( ) . forEach ( warehouseId - > {
List < PackageTrayInfoVO > packageTrayInfoVOS1 = packageTrayInfoVOSMap . get ( warehouseId ) ;
if ( ! packageTrayInfoVOS1 . isEmpty ( ) ) {
//把packageTrayInfoVOS1中的orderPackageCode放入一个List
List < String > orderPackageCodeList = packageTrayInfoVOS1 . stream ( ) . map ( PackageTrayInfoVO : : getOrderPackageCode ) . collect ( Collectors . toList ( ) ) ;
List < String > list = delTrayAndAllocationPackageMap . get ( warehouseId ) ;
if ( list . isEmpty ( ) ) {
delTrayAndAllocationPackageMap . put ( warehouseId , orderPackageCodeList ) ;
} else {
list . addAll ( orderPackageCodeList ) ;
delTrayAndAllocationPackageMap . put ( warehouseId , list ) ;
}
}
} ) ;
} else {
//如果不是签收或者出库的包件
//把packageTrayInfoVOS通过conditions进行分组
Map < Integer , List < PackageTrayInfoVO > > packageTrayInfoVOSMap = packageTrayInfoVOS . stream ( ) . collect ( Collectors . groupingBy ( PackageTrayInfoVO : : getConditions ) ) ;
packageTrayInfoVOSMap . keySet ( ) . forEach ( conditions - > {
List < PackageTrayInfoVO > packageTrayInfoVOS1 = packageTrayInfoVOSMap . get ( conditions ) ;
if ( ! packageTrayInfoVOS1 . isEmpty ( ) ) {
//把packageTrayInfoVOS1中所有元素的warehouseId进行分组
Map < Long , List < PackageTrayInfoVO > > packageTrayInfoVOSMap1 = packageTrayInfoVOS1 . stream ( ) . collect ( Collectors . groupingBy ( PackageTrayInfoVO : : getWarehouseId ) ) ;
packageTrayInfoVOSMap1 . keySet ( ) . forEach ( warehouseId - > {
List < PackageTrayInfoVO > packageTrayInfoVOS2 = packageTrayInfoVOSMap1 . get ( warehouseId ) ;
if ( ! packageTrayInfoVOS2 . isEmpty ( ) ) {
//把packageTrayInfoVOS2中所有元素根据trayName进行分组
Map < String , List < PackageTrayInfoVO > > packageTrayInfoVOSMap2 = packageTrayInfoVOS2 . stream ( ) . collect ( Collectors . groupingBy ( PackageTrayInfoVO : : getTrayName ) ) ;
packageTrayInfoVOSMap2 . keySet ( ) . forEach ( trayName - > {
List < PackageTrayInfoVO > packageTrayInfoVOS3 = packageTrayInfoVOSMap2 . get ( trayName ) ;
if ( ! packageTrayInfoVOS3 . isEmpty ( ) ) {
//订制品
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . set ( "dataType" , 1 ) ;
jsonObject . set ( "operation" , 1 ) ;
jsonObject . set ( "conditions" , conditions ) ;
List < String > orderPackageCodes = packageTrayInfoVOS3 . stream ( ) . map ( PackageTrayInfoVO : : getOrderPackageCode ) . collect ( Collectors . toList ( ) ) ;
jsonObject . set ( "orderPackageCodes" , orderPackageCodes ) ;
jsonObject . set ( "warehouseId" , warehouseId ) ;
jsonObject . set ( "trayName" , trayName ) ;
FanoutMsg fanoutMsg = FanoutMsg . builder ( ) . exchange ( FanoutConstants . warehouse . TRAYTYPE . EXCHANGE ) . msg ( jsonObject . toString ( ) ) . build ( ) ;
sendFanoutMsg . sendFanoutMsg ( fanoutMsg ) ;
}
} ) ;
}
} ) ;
}
} ) ;
}
}
} ) ;
//零担
List < ZeroTrayInfoVO > zeroTrayList = warehouseMappingDataService . findZeroTraysInfo ( ) ;
//把zeroTrayList通过warehouseId进行分组
Map < Long , List < ZeroTrayInfoVO > > zeroTrayMap = zeroTrayList . stream ( ) . collect ( Collectors . groupingBy ( ZeroTrayInfoVO : : getWarehouseId ) ) ;
zeroTrayMap . keySet ( ) . forEach ( warehouseId - > {
List < ZeroTrayInfoVO > zeroTrayInfoVOS = zeroTrayMap . get ( warehouseId ) ;
if ( ! zeroTrayInfoVOS . isEmpty ( ) ) {
//把zeroTrayInfoVOS通过trayName进行分组
Map < String , List < ZeroTrayInfoVO > > zeroTrayInfoVOSMap = zeroTrayInfoVOS . stream ( ) . collect ( Collectors . groupingBy ( ZeroTrayInfoVO : : getTrayName ) ) ;
zeroTrayInfoVOSMap . keySet ( ) . forEach ( trayName - > {
List < ZeroTrayInfoVO > zeroTrayInfoVOS1 = zeroTrayInfoVOSMap . get ( trayName ) ;
if ( ! zeroTrayInfoVOS1 . isEmpty ( ) ) {
//把zeroTrayInfoVOS1中所有元素的orderCode放入一个List
List < String > orderCodes = zeroTrayInfoVOS1 . stream ( ) . map ( ZeroTrayInfoVO : : getOrderCode ) . collect ( Collectors . toList ( ) ) ;
//订制品
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . set ( "dataType" , 2 ) ;
jsonObject . set ( "operation" , 1 ) ;
jsonObject . set ( "orderCodes" , orderCodes ) ;
jsonObject . set ( "warehouseId" , warehouseId ) ;
jsonObject . set ( "trayName" , trayName ) ;
FanoutMsg fanoutMsg = FanoutMsg . builder ( ) . exchange ( FanoutConstants . warehouse . TRAYTYPE . EXCHANGE ) . msg ( jsonObject . toString ( ) ) . build ( ) ;
sendFanoutMsg . sendFanoutMsg ( fanoutMsg ) ;
}
} ) ;
}
} ) ;
//无数据库存品
List < StockTrayInfoVO > stockTrayList = warehouseMappingDataService . findStockTraysInfo ( ) ;
//把stockTrayList通过warehouseId分组
Map < Long , List < StockTrayInfoVO > > stockTrayMap = stockTrayList . stream ( ) . collect ( Collectors . groupingBy ( StockTrayInfoVO : : getWarehouseId ) ) ;
stockTrayMap . keySet ( ) . forEach ( warehouseId - > {
List < StockTrayInfoVO > stockTrayInfoVOS = stockTrayMap . get ( warehouseId ) ;
if ( ! stockTrayInfoVOS . isEmpty ( ) ) {
//把stockTrayInfoVOS通过trayName进行分组
Map < String , List < StockTrayInfoVO > > stockTrayInfoVOSMap = stockTrayInfoVOS . stream ( ) . collect ( Collectors . groupingBy ( StockTrayInfoVO : : getTrayName ) ) ;
stockTrayInfoVOSMap . keySet ( ) . forEach ( trayName - > {
List < StockTrayInfoVO > stockTrayInfoVOS1 = stockTrayInfoVOSMap . get ( trayName ) ;
if ( ! stockTrayInfoVOS1 . isEmpty ( ) ) {
//把stockTrayInfoVOS1中所有元素的stockListId放入一个List
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . set ( "dataType" , 3 ) ;
jsonObject . set ( "operation" , 1 ) ;
List < Long > stockListIds = stockTrayInfoVOS1 . stream ( ) . map ( StockTrayInfoVO : : getStockListId ) . collect ( Collectors . toList ( ) ) ;
jsonObject . set ( "stockListIds" , stockListIds ) ;
jsonObject . set ( "warehouseId" , warehouseId ) ;
jsonObject . set ( "trayName" , trayName ) ;
FanoutMsg fanoutMsg = FanoutMsg . builder ( ) . exchange ( FanoutConstants . warehouse . TRAYTYPE . EXCHANGE ) . msg ( jsonObject . toString ( ) ) . build ( ) ;
sendFanoutMsg . sendFanoutMsg ( fanoutMsg ) ;
}
} ) ;
}
} ) ;
//库位
//包件
List < PackageAllocationInfoVO > packageAllocationData = warehouseMappingDataService . findPackageAllocationData ( ) ;
//把packageTrayList中所有元素根据orderPackageStatus进行分组
Map < String , List < PackageAllocationInfoVO > > packageAllocationMap = packageAllocationData . stream ( ) . collect ( Collectors . groupingBy ( PackageAllocationInfoVO : : getOrderPackageStatus ) ) ;
packageAllocationMap . keySet ( ) . forEach ( orderPackageStatus - > {
List < PackageAllocationInfoVO > packageAllocationInfoVOS = packageAllocationMap . get ( orderPackageStatus ) ;
if ( ! packageAllocationInfoVOS . isEmpty ( ) ) {
if ( "60" . equals ( orderPackageStatus ) | | "70" . equals ( orderPackageStatus ) ) {
//把packageTrayInfoVOS通过warehouseId进行分组,来分仓处理下架解托的包件
Map < Long , List < PackageAllocationInfoVO > > packageAllocationInfoVOSMap = packageAllocationInfoVOS . stream ( ) . collect ( Collectors . groupingBy ( PackageAllocationInfoVO : : getWarehouseId ) ) ;
packageAllocationInfoVOSMap . keySet ( ) . forEach ( warehouseId - > {
List < PackageAllocationInfoVO > packageAllocationInfoVOS1 = packageAllocationInfoVOSMap . get ( warehouseId ) ;
if ( ! packageAllocationInfoVOS1 . isEmpty ( ) ) {
//把packageTrayInfoVOS1中的orderPackageCode放入一个List
List < String > orderPackageCodeList = packageAllocationInfoVOS1 . stream ( ) . map ( PackageAllocationInfoVO : : getOrderPackageCode ) . collect ( Collectors . toList ( ) ) ;
List < String > list = delTrayAndAllocationPackageMap . get ( warehouseId ) ;
if ( list . isEmpty ( ) ) {
delTrayAndAllocationPackageMap . put ( warehouseId , orderPackageCodeList ) ;
} else {
list . addAll ( orderPackageCodeList ) ;
delTrayAndAllocationPackageMap . put ( warehouseId , list ) ;
}
}
} ) ;
} else {
//如果不是签收或者出库的包件
//把packageTrayInfoVOS通过conditions进行分组
Map < Integer , List < PackageAllocationInfoVO > > packageAllocationInfoVOSMap = packageAllocationInfoVOS . stream ( ) . collect ( Collectors . groupingBy ( PackageAllocationInfoVO : : getConditions ) ) ;
packageAllocationInfoVOSMap . keySet ( ) . forEach ( conditions - > {
List < PackageAllocationInfoVO > packageAllocationInfoVOS1 = packageAllocationInfoVOSMap . get ( conditions ) ;
if ( ! packageAllocationInfoVOS1 . isEmpty ( ) ) {
//把packageTrayInfoVOS1中所有元素的warehouseId进行分组
Map < Long , List < PackageAllocationInfoVO > > packageAllocationInfoVOSMap1 = packageAllocationInfoVOS1 . stream ( ) . collect ( Collectors . groupingBy ( PackageAllocationInfoVO : : getWarehouseId ) ) ;
packageAllocationInfoVOSMap1 . keySet ( ) . forEach ( warehouseId - > {
List < PackageAllocationInfoVO > packageAllocationInfoVOS2 = packageAllocationInfoVOSMap1 . get ( warehouseId ) ;
if ( ! packageAllocationInfoVOS2 . isEmpty ( ) ) {
//把packageTrayInfoVOS2中所有元素根据trayName进行分组
Map < String , List < PackageAllocationInfoVO > > packageAllocationInfoVOSMap2 = packageAllocationInfoVOS2 . stream ( ) . collect ( Collectors . groupingBy ( PackageAllocationInfoVO : : getAllocationName ) ) ;
packageAllocationInfoVOSMap2 . keySet ( ) . forEach ( allocationName - > {
List < PackageAllocationInfoVO > packageAllocationInfoVOS3 = packageAllocationInfoVOSMap2 . get ( allocationName ) ;
if ( ! packageAllocationInfoVOS3 . isEmpty ( ) ) {
//订制品
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . set ( "dataType" , 1 ) ;
jsonObject . set ( "operation" , 3 ) ;
jsonObject . set ( "conditions" , conditions ) ;
List < String > orderPackageCodes = packageAllocationInfoVOS3 . stream ( ) . map ( PackageAllocationInfoVO : : getOrderPackageCode ) . collect ( Collectors . toList ( ) ) ;
jsonObject . set ( "orderPackageCodes" , orderPackageCodes ) ;
jsonObject . set ( "warehouseId" , warehouseId ) ;
jsonObject . set ( "allocationName" , allocationName ) ;
FanoutMsg fanoutMsg = FanoutMsg . builder ( ) . exchange ( FanoutConstants . warehouse . ALLOCATION . EXCHANGE ) . msg ( jsonObject . toString ( ) ) . build ( ) ;
sendFanoutMsg . sendFanoutMsg ( fanoutMsg ) ;
}
} ) ;
}
} ) ;
}
} ) ;
}
}
} ) ;
//零担
List < ZeroAllocationInfoVO > zeroAllocationList = warehouseMappingDataService . findZeroAllocationInfo ( ) ;
//把zeroTrayList通过warehouseId进行分组
Map < Long , List < ZeroAllocationInfoVO > > zeroAllocationMap = zeroAllocationList . stream ( ) . collect ( Collectors . groupingBy ( ZeroAllocationInfoVO : : getWarehouseId ) ) ;
zeroAllocationMap . keySet ( ) . forEach ( warehouseId - > {
List < ZeroAllocationInfoVO > zeroAllocationInfoVOS = zeroAllocationMap . get ( warehouseId ) ;
if ( ! zeroAllocationInfoVOS . isEmpty ( ) ) {
//把zeroTrayInfoVOS通过trayName进行分组
Map < String , List < ZeroAllocationInfoVO > > zeroAllocationInfoVOSMap = zeroAllocationInfoVOS . stream ( ) . collect ( Collectors . groupingBy ( ZeroAllocationInfoVO : : getAllocationName ) ) ;
zeroAllocationInfoVOSMap . keySet ( ) . forEach ( allocationName - > {
List < ZeroAllocationInfoVO > zeroAllocationInfoVOS1 = zeroAllocationInfoVOSMap . get ( allocationName ) ;
if ( ! zeroAllocationInfoVOS1 . isEmpty ( ) ) {
//把zeroTrayInfoVOS1中所有元素的orderCode放入一个List
List < String > orderCodes = zeroAllocationInfoVOS1 . stream ( ) . map ( ZeroAllocationInfoVO : : getOrderCode ) . collect ( Collectors . toList ( ) ) ;
//订制品
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . set ( "dataType" , 2 ) ;
jsonObject . set ( "operation" , 3 ) ;
jsonObject . set ( "orderCodes" , orderCodes ) ;
jsonObject . set ( "warehouseId" , warehouseId ) ;
jsonObject . set ( "allocationName" , allocationName ) ;
FanoutMsg fanoutMsg = FanoutMsg . builder ( ) . exchange ( FanoutConstants . warehouse . ALLOCATION . EXCHANGE ) . msg ( jsonObject . toString ( ) ) . build ( ) ;
sendFanoutMsg . sendFanoutMsg ( fanoutMsg ) ;
}
} ) ;
}
} ) ;
//无数据库存品
List < StockAllocationInfoVO > stockAllocationList = warehouseMappingDataService . findStockAllocationInfo ( ) ;
//把stockTrayList通过warehouseId分组
Map < Long , List < StockAllocationInfoVO > > stockAllocationMap = stockAllocationList . stream ( ) . collect ( Collectors . groupingBy ( StockAllocationInfoVO : : getWarehouseId ) ) ;
stockAllocationMap . keySet ( ) . forEach ( warehouseId - > {
List < StockAllocationInfoVO > stockAllocationInfoVOS = stockAllocationMap . get ( warehouseId ) ;
if ( ! stockAllocationInfoVOS . isEmpty ( ) ) {
//把stockTrayInfoVOS通过trayName进行分组
Map < String , List < StockAllocationInfoVO > > stockAllocationInfoVOSMap = stockAllocationInfoVOS . stream ( ) . collect ( Collectors . groupingBy ( StockAllocationInfoVO : : getAllocationName ) ) ;
stockAllocationInfoVOSMap . keySet ( ) . forEach ( allocationName - > {
List < StockAllocationInfoVO > stockAllocationInfoVOS1 = stockAllocationInfoVOSMap . get ( allocationName ) ;
if ( ! stockAllocationInfoVOS1 . isEmpty ( ) ) {
//把stockTrayInfoVOS1中所有元素的stockListId放入一个List
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . set ( "dataType" , 3 ) ;
jsonObject . set ( "operation" , 3 ) ;
List < Long > stockListIds = stockAllocationInfoVOS1 . stream ( ) . map ( StockAllocationInfoVO : : getStockListId ) . collect ( Collectors . toList ( ) ) ;
jsonObject . set ( "stockListIds" , stockListIds ) ;
jsonObject . set ( "warehouseId" , warehouseId ) ;
jsonObject . set ( "allocationName" , allocationName ) ;
FanoutMsg fanoutMsg = FanoutMsg . builder ( ) . exchange ( FanoutConstants . warehouse . ALLOCATION . EXCHANGE ) . msg ( jsonObject . toString ( ) ) . build ( ) ;
sendFanoutMsg . sendFanoutMsg ( fanoutMsg ) ;
}
} ) ;
}
} ) ;
delTrayAndAllocationPackageMap . keySet ( ) . forEach ( warehouseId - > {
List < String > list = delTrayAndAllocationPackageMap . get ( warehouseId ) ;
if ( ! list . isEmpty ( ) ) {
Set < String > orderPackageCodes = new HashSet < > ( list ) ;
warehouseUpdownTypeClient . downPackageOrDelTray ( StringUtil . join ( orderPackageCodes , "," ) , warehouseId , "系统因为签收或者出库下架解托" ) ;
}
} ) ;
log . info ( "############syncAllTrayAndAllocation: 处理所有包件零担库存品的托盘库位信息 结束" ) ;
return ReturnT . SUCCESS ;
}
}