@ -93,6 +93,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
private final ITrunklineCarsLoadScanService trunklineCarsLoadScanService ;
private final IBasicdataStoreContactClient basicdataStoreContactClient ;
private final IAsyncService asyncService ;
private final ICarsLoadAsyncService carsLoadAsyncService ;
@Override
public IPage < TrunklineAdvanceVO > advancePageList ( AdvanceDTO advanceDTO ) {
@ -619,7 +620,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//队列处理包件补数据
// sendRabbitMessageLoadScanData(JSONUtil.parseArray(advanceIds));
carsLoadService . sendRabbitMessageOpenOrder ( advanceIds , waybillId ) ;
Map < String , Object > map = new HashMap < > ( ) ;
@ -1062,7 +1062,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
@Transactional ( rollbackFor = Exception . class )
@Override
public R < List < TrunklineAdvanceEntity > > openLabelHasPacakage ( Long warehouseId , String warehouseName , MultipartFile file ) throws IOException {
public R openLabelHasPacakage ( Long warehouseId , String warehouseName , MultipartFile file ) throws IOException {
if ( Objects . isNull ( file ) ) {
log . warn ( "##################openLabelHasPacakage: 文件不存在" ) ;
return R . fail ( 405 , "文件不存在" ) ;
@ -1070,6 +1070,52 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
InputStream inputStream = file . getInputStream ( ) ;
List < PacakgeDetailExcelDTO > pacakgeDetailExcelDTOS = EasyExcel . read ( inputStream ) . head ( PacakgeDetailExcelDTO . class ) . sheet ( 0 ) . headRowNumber ( 2 ) . doReadSync ( ) ;
//排除pacakgeDetailExcelDTOS中的orderPackageCode为空的元素
pacakgeDetailExcelDTOS = pacakgeDetailExcelDTOS . stream ( ) . filter ( item - > StringUtil . isNotBlank ( item . getOrderPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
//把pacakgeDetailExcelDTOS转成以orderPacakgeCode为一个Set集合
Set < String > pacakgeDetailExcelDTOSet = pacakgeDetailExcelDTOS . stream ( ) . map ( PacakgeDetailExcelDTO : : getOrderPackageCode ) . collect ( Collectors . toSet ( ) ) ;
//把pacakgeDetailExcelDTOS中的元素的orderPackageCode属性分组
Map < String , Long > orderPackageCodeCounts = pacakgeDetailExcelDTOS . stream ( )
. collect ( Collectors . groupingBy ( PacakgeDetailExcelDTO : : getOrderPackageCode , Collectors . counting ( ) ) ) ;
Set < String > duplicateOrderPackageCodes = orderPackageCodeCounts . entrySet ( ) . stream ( )
. filter ( entry - > entry . getValue ( ) > 1 )
. map ( Map . Entry : : getKey )
. collect ( Collectors . toSet ( ) ) ;
if ( ! duplicateOrderPackageCodes . isEmpty ( ) ) {
log . warn ( "#####################openLabelHasPacakage: 包条码重复 {}" , duplicateOrderPackageCodes ) ;
return R . fail ( 405 , "包条码重复" + duplicateOrderPackageCodes ) ;
}
List < String > orderPackageCodeKeys = new ArrayList < > ( pacakgeDetailExcelDTOSet ) ;
List < String > hasOrderPackageCodeList = new ArrayList < > ( ) ;
//把orderPackageCodeKeys每2000个元素为一组
int batchSize = 2000 ;
List < List < String > > orderPackageCodeGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderPackageCodeKeys . size ( ) ; i + = batchSize ) {
int endIndex = Math . min ( i + batchSize , orderPackageCodeKeys . size ( ) ) ;
orderPackageCodeGroups . add ( orderPackageCodeKeys . subList ( i , endIndex ) ) ;
}
orderPackageCodeGroups . forEach ( orderPackageCodeGroup - > {
List < String > hasOrderPackageCodes = advanceDetailService . findListByExistsAndOrderPackageCodes ( orderPackageCodeGroup ) ;
hasOrderPackageCodeList . addAll ( hasOrderPackageCodes ) ;
} ) ;
//排除pacakgeDetailExcelDTOS中orderPackageCode在hasOrderPackageCodeList中存在的元素
pacakgeDetailExcelDTOS = pacakgeDetailExcelDTOS . stream ( ) . filter ( item - > ! hasOrderPackageCodeList . contains ( item . getOrderPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < TrunklineAdvanceEntity > advanceEntityList = new ArrayList < > ( ) ;
if ( pacakgeDetailExcelDTOS . isEmpty ( ) ) {
log . warn ( "##################openLabelHasPacakage: 没有需要处理的数据 pacakgeDetailExcelDTOS={}" , pacakgeDetailExcelDTOS ) ;
return R . data ( advanceEntityList ) ;
}
Map < String , List < PacakgeDetailExcelDTO > > listMap = pacakgeDetailExcelDTOS . parallelStream ( ) . collect ( Collectors . groupingBy ( a - > a . getOrderCode ( ) + "&" + a . getTrainNumber ( ) ) ) ;
@ -1080,7 +1126,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < TrunklineAdvanceDetailEntity > advanceDetailEntities = new ArrayList < > ( ) ;
List < TrunklineAdvanceEntity > advanceEntityList = new ArrayList < > ( ) ;
Map < String , TrunklineAdvanceEntity > advanceEntityMap = new HashMap < > ( ) ;
@ -1090,7 +1136,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//把orderCodes转成List
List < String > orderCodeList = new ArrayList < > ( orderCodes ) ;
//把orderCodeList分成每2000个元素一组
int batchSize = 2000 ;
List < List < String > > orderedGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderCodeList . size ( ) ; i + = batchSize ) {
@ -1307,7 +1352,13 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
}
return R . data ( advanceEntityList ) ;
if ( ! CollUtil . isEmpty ( advanceEntityList ) ) {
carsLoadAsyncService . sendRabbitMessageLoadScanData ( advanceEntityList ) ;
}
int successNum = advanceDetailEntities . size ( ) ;
return R . success ( "成功处理包件" + successNum + "件" ) ;
}
public int findFirstDigitIndex ( String str ) {
@ -1322,7 +1373,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
@Transactional ( rollbackFor = Exception . class )
@Override
public R < List < TrunklineAdvanceEntity > > importCustomizedOuPai ( Long warehouseId , String warehouseName , MultipartFile file ) throws IOException {
public R importCustomizedOuPai ( Long warehouseId , String warehouseName , MultipartFile file ) throws IOException {
if ( Objects . isNull ( file ) ) {
log . warn ( "##################importCustomizedOuPai: 文件不存在" ) ;
return R . fail ( 405 , "文件不存在" ) ;
@ -1333,6 +1384,53 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < ImportCustomizedOuPaiDTO > importCustomizedOuPaiDTOS = EasyExcel . read ( inputStream ) . head ( ImportCustomizedOuPaiDTO . class ) . sheet ( 0 ) . headRowNumber ( 1 ) . doReadSync ( ) ;
//排除pacakgeDetailExcelDTOS中的orderPackageCode为空的元素
importCustomizedOuPaiDTOS = importCustomizedOuPaiDTOS . stream ( ) . filter ( item - > StringUtil . isNotBlank ( item . getOrderPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
//把pacakgeDetailExcelDTOS转成以orderPacakgeCode为一个Set集合
Set < String > importCustomizedOuPaiDTOSet = importCustomizedOuPaiDTOS . stream ( ) . map ( ImportCustomizedOuPaiDTO : : getOrderPackageCode ) . collect ( Collectors . toSet ( ) ) ;
//把pacakgeDetailExcelDTOS中的元素的orderPackageCode属性分组
Map < String , Long > orderPackageCodeCounts = importCustomizedOuPaiDTOS . stream ( )
. collect ( Collectors . groupingBy ( ImportCustomizedOuPaiDTO : : getOrderPackageCode , Collectors . counting ( ) ) ) ;
Set < String > duplicateOrderPackageCodes = orderPackageCodeCounts . entrySet ( ) . stream ( )
. filter ( entry - > entry . getValue ( ) > 1 )
. map ( Map . Entry : : getKey )
. collect ( Collectors . toSet ( ) ) ;
if ( ! duplicateOrderPackageCodes . isEmpty ( ) ) {
log . warn ( "#################importCustomizedOuPai: 包条码重复 {}" , duplicateOrderPackageCodes ) ;
return R . fail ( 405 , "包条码重复" + duplicateOrderPackageCodes ) ;
}
List < String > orderPackageCodeKeys = new ArrayList < > ( importCustomizedOuPaiDTOSet ) ;
List < String > hasOrderPackageCodeList = new ArrayList < > ( ) ;
//把orderPackageCodeKeys每2000个元素为一组
int batchSize = 2000 ;
List < List < String > > orderPackageCodeGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderPackageCodeKeys . size ( ) ; i + = batchSize ) {
int endIndex = Math . min ( i + batchSize , orderPackageCodeKeys . size ( ) ) ;
orderPackageCodeGroups . add ( orderPackageCodeKeys . subList ( i , endIndex ) ) ;
}
orderPackageCodeGroups . forEach ( orderPackageCodeGroup - > {
List < String > hasOrderPackageCodes = advanceDetailService . findListByExistsAndOrderPackageCodes ( orderPackageCodeGroup ) ;
hasOrderPackageCodeList . addAll ( hasOrderPackageCodes ) ;
} ) ;
//排除pacakgeDetailExcelDTOS中orderPackageCode在hasOrderPackageCodeList中存在的元素
importCustomizedOuPaiDTOS = importCustomizedOuPaiDTOS . stream ( ) . filter ( item - > ! hasOrderPackageCodeList . contains ( item . getOrderPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < TrunklineAdvanceEntity > advanceEntityList = new ArrayList < > ( ) ;
if ( importCustomizedOuPaiDTOS . isEmpty ( ) ) {
log . warn ( "##################importCustomizedOuPai: 没有需要处理的数据 importCustomizedOuPaiDTOS={}" , importCustomizedOuPaiDTOS ) ;
return R . data ( advanceEntityList ) ;
}
Map < String , List < ImportCustomizedOuPaiDTO > > listMap = importCustomizedOuPaiDTOS . parallelStream ( ) . collect ( Collectors . groupingBy ( a - > a . getOrderCode ( ) + "&" + a . getTrainNumber ( ) ) ) ;
listMap . remove ( "null&null" ) ;
@ -1344,7 +1442,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//把orderCodes转成List
List < String > orderCodeList = new ArrayList < > ( orderCodes ) ;
//把orderCodeList分成每2000个元素一组
int batchSize = 2000 ;
List < List < String > > orderedGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderCodeList . size ( ) ; i + = batchSize ) {
@ -1354,8 +1451,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < TrunklineAdvanceDetailEntity > advanceDetailEntities = new ArrayList < > ( ) ;
List < TrunklineAdvanceEntity > advanceEntityList = new ArrayList < > ( ) ;
Map < String , TrunklineAdvanceEntity > advanceEntityMap = new HashMap < > ( ) ;
List < Long > advanceIds = new ArrayList < > ( ) ;
@ -1530,13 +1625,18 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
log . info ( "################本次耗时 " + ( end - start ) + "ms" ) ;
int size = advanceDetailEntities . size ( ) ;
if ( ! CollUtil . isEmpty ( advanceEntityList ) ) {
carsLoadAsyncService . sendRabbitMessageLoadScanData ( advanceEntityList ) ;
}
return R . data ( advanceEntityList ) ;
return R . success ( "成功导入" + size + "条" ) ;
}
@Transactional ( rollbackFor = Exception . class )
@Override
public R < List < TrunklineAdvanceEntity > > importStandardOuPai ( Long warehouseId , String warehouseName , MultipartFile file ) throws IOException {
public R importStandardOuPai ( Long warehouseId , String warehouseName , MultipartFile file ) throws IOException {
if ( Objects . isNull ( file ) ) {
log . warn ( "##################importStandardOuPai: 文件不存在" ) ;
return R . fail ( 405 , "文件不存在" ) ;
@ -1544,6 +1644,54 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
InputStream inputStream = file . getInputStream ( ) ;
List < ImportStandardOuPaiDTO > importStandardOuPaiDTOS = EasyExcel . read ( inputStream ) . head ( ImportStandardOuPaiDTO . class ) . sheet ( 0 ) . headRowNumber ( 1 ) . doReadSync ( ) ;
//排除importStandardOuPaiDTOS中的orderPackageCode为空的元素
importStandardOuPaiDTOS = importStandardOuPaiDTOS . stream ( ) . filter ( item - > StringUtil . isNotBlank ( item . getOrderPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
//把importStandardOuPaiDTOS转成以orderPacakgeCode为一个Set集合
Set < String > importStandardOuPaiDTOSet = importStandardOuPaiDTOS . stream ( ) . map ( ImportStandardOuPaiDTO : : getOrderPackageCode ) . collect ( Collectors . toSet ( ) ) ;
//把pacakgeDetailExcelDTOS中的元素的orderPackageCode属性分组
Map < String , Long > orderPackageCodeCounts = importStandardOuPaiDTOS . stream ( )
. collect ( Collectors . groupingBy ( ImportStandardOuPaiDTO : : getOrderPackageCode , Collectors . counting ( ) ) ) ;
Set < String > duplicateOrderPackageCodes = orderPackageCodeCounts . entrySet ( ) . stream ( )
. filter ( entry - > entry . getValue ( ) > 1 )
. map ( Map . Entry : : getKey )
. collect ( Collectors . toSet ( ) ) ;
if ( ! duplicateOrderPackageCodes . isEmpty ( ) ) {
log . warn ( "#################importStandardOuPai: 包条码重复 {}" , duplicateOrderPackageCodes ) ;
return R . fail ( 405 , "包条码重复" + duplicateOrderPackageCodes ) ;
}
List < String > orderPackageCodeKeys = new ArrayList < > ( importStandardOuPaiDTOSet ) ;
List < String > hasOrderPackageCodeList = new ArrayList < > ( ) ;
//把orderPackageCodeKeys每2000个元素为一组
int batchSize = 2000 ;
List < List < String > > orderPackageCodeGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderPackageCodeKeys . size ( ) ; i + = batchSize ) {
int endIndex = Math . min ( i + batchSize , orderPackageCodeKeys . size ( ) ) ;
orderPackageCodeGroups . add ( orderPackageCodeKeys . subList ( i , endIndex ) ) ;
}
orderPackageCodeGroups . forEach ( orderPackageCodeGroup - > {
List < String > hasOrderPackageCodes = advanceDetailService . findListByExistsAndOrderPackageCodes ( orderPackageCodeGroup ) ;
hasOrderPackageCodeList . addAll ( hasOrderPackageCodes ) ;
} ) ;
//排除importStandardOuPaiDTOS中orderPackageCode在hasOrderPackageCodeList中存在的元素
importStandardOuPaiDTOS = importStandardOuPaiDTOS . stream ( ) . filter ( item - > ! hasOrderPackageCodeList . contains ( item . getOrderPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < TrunklineAdvanceEntity > advanceEntityList = new ArrayList < > ( ) ;
if ( importStandardOuPaiDTOS . isEmpty ( ) ) {
log . warn ( "##################importStandardOuPai: 没有需要处理的数据 importStandardOuPaiDTOS={}" , importStandardOuPaiDTOS ) ;
return R . data ( advanceEntityList ) ;
}
Map < String , List < ImportStandardOuPaiDTO > > listMap = importStandardOuPaiDTOS . parallelStream ( ) . collect ( Collectors . groupingBy ( a - > a . getOrderCode ( ) + "&" + a . getTrainNumber ( ) ) ) ;
listMap . remove ( "null&null" ) ;
@ -1553,8 +1701,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < TrunklineAdvanceDetailEntity > advanceDetailEntities = new ArrayList < > ( ) ;
List < TrunklineAdvanceEntity > advanceEntityList = new ArrayList < > ( ) ;
Map < String , TrunklineAdvanceEntity > advanceEntityMap = new HashMap < > ( ) ;
List < Long > advanceIds = new ArrayList < > ( ) ;
@ -1563,7 +1709,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//把orderCodes转成List
List < String > orderCodeList = new ArrayList < > ( orderCodes ) ;
//把orderCodeList分成每2000个元素一组
int batchSize = 2000 ;
List < List < String > > orderedGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderCodeList . size ( ) ; i + = batchSize ) {
@ -1773,10 +1918,15 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
comlist . add ( fromCpFirstReq ) ;
}
CompletableFuture . allOf ( comlist . toArray ( new CompletableFuture [ 0 ] ) ) . join ( ) ;
}
if ( ! CollUtil . isEmpty ( advanceEntityList ) ) {
carsLoadAsyncService . sendRabbitMessageLoadScanData ( advanceEntityList ) ;
}
return R . data ( advanceEntityList ) ;
int successNum = advanceDetailEntities . size ( ) ;
return R . success ( "成功导入" + successNum + "条" ) ;
}
@Override
@ -2072,7 +2222,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
@Transactional ( rollbackFor = Exception . class )
@Override
public R < List < TrunklineAdvanceEntity > > importOrderNoPackage ( Long warehouseId , String warehouseName , String warehouseCode , MultipartFile file ) throws IOException {
public R importOrderNoPackage ( Long warehouseId , String warehouseName , String warehouseCode , MultipartFile file ) throws IOException {
if ( Objects . isNull ( file ) ) {
log . warn ( "##################importOrderNoPackage: 文件不存在" ) ;
return R . fail ( 405 , "文件不存在" ) ;
@ -2159,7 +2309,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
} ) ;
advanceService . saveBatch ( list ) ;
return R . data ( list ) ;
int successNum = list . size ( ) ;
return R . success ( "成功导入" + successNum + "件" ) ;
}
@Override