@ -1097,11 +1097,11 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < String > hasOrderPackageCodeList = new ArrayList < > ( ) ;
//把orderPackageCodeKeys每2000个元素为一组
int batchSize = 2 000;
int packageBatchSize = 1 000;
List < List < String > > orderPackageCodeGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderPackageCodeKeys . size ( ) ; i + = b atchSize) {
int endIndex = Math . min ( i + b atchSize, orderPackageCodeKeys . size ( ) ) ;
for ( int i = 0 ; i < orderPackageCodeKeys . size ( ) ; i + = packageB atchSize) {
int endIndex = Math . min ( i + packageB atchSize, orderPackageCodeKeys . size ( ) ) ;
orderPackageCodeGroups . add ( orderPackageCodeKeys . subList ( i , endIndex ) ) ;
}
@ -1141,6 +1141,8 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//把orderCodeList分成每2000个元素一组
List < List < String > > orderedGroups = new ArrayList < > ( ) ;
int batchSize = 1000 ;
for ( int i = 0 ; i < orderCodeList . size ( ) ; i + = batchSize ) {
int endIndex = Math . min ( i + batchSize , orderCodeList . size ( ) ) ;
orderedGroups . add ( orderCodeList . subList ( i , endIndex ) ) ;
@ -1160,6 +1162,8 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
advanceEntityMap . put ( key , advanceEntity ) ;
} ) ;
List < TrunklineAdvanceEntity > updateAdvanceEntityList = new ArrayList < > ( ) ;
listMap . keySet ( ) . forEach ( str - > {
List < PacakgeDetailExcelDTO > excelDTOS = listMap . get ( str ) ;
PacakgeDetailExcelDTO pacakgeDetailExcelDTO = excelDTOS . get ( 0 ) ;
@ -1217,14 +1221,16 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
advanceEntity . setCreateUserName ( AuthUtil . getNickName ( ) ) ;
advanceEntityList . add ( advanceEntity ) ;
} else {
advanceEntity . setTotalNum ( advanceEntity . getTotalNum ( ) + excelDTOS . size ( ) ) ;
updateAdvanceEntityList . add ( advanceEntity ) ;
advanceIds . add ( advanceEntity . getId ( ) ) ;
advanceEntityMap . put ( advanceEntity . getOrderCode ( ) + "&" + ( StringUtil . isBlank ( trainNumber ) ? "null" : trainNumber ) , advanceEntity ) ;
}
} ) ;
if ( ! advanceEntityList . isEmpty ( ) ) {
//把advanceDetailEntities分成相等数量的10个集合
List < List < TrunklineAdvanceEntity > > advanceEntitiesList = advanceEntityList . stream ( ) . collect ( Collectors . groupingBy ( item - > advanceDetail Entitie s . indexOf ( item ) / 1000 ) ) . entrySet ( ) . stream ( ) . map ( Map . Entry : : getValue ) . collect ( Collectors . toList ( ) ) ;
//把advanceEntityList每1000个元素分组
List < List < TrunklineAdvanceEntity > > advanceEntitiesList = advanceEntityList . stream ( ) . collect ( Collectors . groupingBy ( item - > advanceEntityL ist . indexOf ( item ) / 1000 ) ) . entrySet ( ) . stream ( ) . map ( Map . Entry : : getValue ) . collect ( Collectors . toList ( ) ) ;
List < CompletableFuture > comlist = new ArrayList < > ( ) ;
for ( int i = 0 ; i < advanceEntitiesList . size ( ) ; i + + ) {
List < TrunklineAdvanceEntity > list = advanceEntitiesList . get ( i ) ;
@ -1235,6 +1241,21 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
}
if ( ! updateAdvanceEntityList . isEmpty ( ) ) {
//把advanceDetailEntities分成相等数量的10个集合
List < List < TrunklineAdvanceEntity > > advanceEntitiesList = updateAdvanceEntityList . stream ( ) . collect ( Collectors . groupingBy ( item - > updateAdvanceEntityList . indexOf ( item ) / 1000 ) ) . entrySet ( ) . stream ( ) . map ( Map . Entry : : getValue ) . collect ( Collectors . toList ( ) ) ;
List < CompletableFuture > comlist = new ArrayList < > ( ) ;
for ( int i = 0 ; i < advanceEntitiesList . size ( ) ; i + + ) {
List < TrunklineAdvanceEntity > list = advanceEntitiesList . get ( i ) ;
CompletableFuture < Boolean > fromCpFirstReq = asyncService . updateAdvanceEntity ( list , i + 1 ) ;
comlist . add ( fromCpFirstReq ) ;
}
CompletableFuture . allOf ( comlist . toArray ( new CompletableFuture [ 0 ] ) ) . join ( ) ;
}
advanceEntityList . forEach ( advanceEntity - > {
advanceIds . add ( advanceEntity . getId ( ) ) ;
String trainNumber = advanceEntity . getTrainNumber ( ) ;
@ -1411,11 +1432,11 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < String > hasOrderPackageCodeList = new ArrayList < > ( ) ;
//把orderPackageCodeKeys每2000个元素为一组
int batchSize = 2 000;
int packageBatchSize = 1 000;
List < List < String > > orderPackageCodeGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderPackageCodeKeys . size ( ) ; i + = b atchSize) {
int endIndex = Math . min ( i + b atchSize, orderPackageCodeKeys . size ( ) ) ;
for ( int i = 0 ; i < orderPackageCodeKeys . size ( ) ; i + = packageB atchSize) {
int endIndex = Math . min ( i + packageB atchSize, orderPackageCodeKeys . size ( ) ) ;
orderPackageCodeGroups . add ( orderPackageCodeKeys . subList ( i , endIndex ) ) ;
}
@ -1428,6 +1449,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
importCustomizedOuPaiDTOS = importCustomizedOuPaiDTOS . stream ( ) . filter ( item - > ! hasOrderPackageCodeList . contains ( item . getOrderPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < TrunklineAdvanceEntity > advanceEntityList = new ArrayList < > ( ) ;
List < TrunklineAdvanceEntity > updateAdvanceEntityList = new ArrayList < > ( ) ;
if ( importCustomizedOuPaiDTOS . isEmpty ( ) ) {
log . warn ( "##################importCustomizedOuPai: 没有需要处理的数据 importCustomizedOuPaiDTOS={}" , importCustomizedOuPaiDTOS ) ;
@ -1447,6 +1469,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//把orderCodeList分成每2000个元素一组
List < List < String > > orderedGroups = new ArrayList < > ( ) ;
int batchSize = 1000 ;
for ( int i = 0 ; i < orderCodeList . size ( ) ; i + = batchSize ) {
int endIndex = Math . min ( i + batchSize , orderCodeList . size ( ) ) ;
orderedGroups . add ( orderCodeList . subList ( i , endIndex ) ) ;
@ -1525,6 +1548,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
advanceEntity . setHasPackage ( 1 ) ;
advanceEntityList . add ( advanceEntity ) ;
} else {
advanceEntity . setTotalNum ( advanceEntity . getTotalNum ( ) + excelDTOS . size ( ) ) ;
updateAdvanceEntityList . add ( advanceEntity ) ;
advanceIds . add ( advanceEntity . getId ( ) ) ;
String trainNumber = advanceEntity . getTrainNumber ( ) ;
advanceEntityMap . put ( advanceEntity . getOrderCode ( ) + "&" + ( StringUtil . isBlank ( trainNumber ) ? "null" : trainNumber ) , advanceEntity ) ;
@ -1533,7 +1559,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
if ( ! advanceEntityList . isEmpty ( ) ) {
//把advanceDetailEntities分成相等数量的10个集合
List < List < TrunklineAdvanceEntity > > advanceEntitiesList = advanceEntityList . stream ( ) . collect ( Collectors . groupingBy ( item - > advanceDetail Entitie s . indexOf ( item ) / 1000 ) ) . entrySet ( ) . stream ( ) . map ( Map . Entry : : getValue ) . collect ( Collectors . toList ( ) ) ;
List < List < TrunklineAdvanceEntity > > advanceEntitiesList = advanceEntityList . stream ( ) . collect ( Collectors . groupingBy ( item - > advanceEntityL ist . indexOf ( item ) / 1000 ) ) . entrySet ( ) . stream ( ) . map ( Map . Entry : : getValue ) . collect ( Collectors . toList ( ) ) ;
List < CompletableFuture > comlist = new ArrayList < > ( ) ;
for ( int i = 0 ; i < advanceEntitiesList . size ( ) ; i + + ) {
List < TrunklineAdvanceEntity > list = advanceEntitiesList . get ( i ) ;
@ -1544,6 +1570,20 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
}
if ( ! updateAdvanceEntityList . isEmpty ( ) ) {
//把advanceDetailEntities分成相等数量的10个集合
List < List < TrunklineAdvanceEntity > > advanceEntitiesList = updateAdvanceEntityList . stream ( ) . collect ( Collectors . groupingBy ( item - > updateAdvanceEntityList . indexOf ( item ) / 1000 ) ) . entrySet ( ) . stream ( ) . map ( Map . Entry : : getValue ) . collect ( Collectors . toList ( ) ) ;
List < CompletableFuture > comlist = new ArrayList < > ( ) ;
for ( int i = 0 ; i < advanceEntitiesList . size ( ) ; i + + ) {
List < TrunklineAdvanceEntity > list = advanceEntitiesList . get ( i ) ;
CompletableFuture < Boolean > fromCpFirstReq = asyncService . updateAdvanceEntity ( list , i + 1 ) ;
comlist . add ( fromCpFirstReq ) ;
}
CompletableFuture . allOf ( comlist . toArray ( new CompletableFuture [ 0 ] ) ) . join ( ) ;
}
advanceEntityList . forEach ( advanceEntity - > {
advanceIds . add ( advanceEntity . getId ( ) ) ;
String trainNumber = advanceEntity . getTrainNumber ( ) ;
@ -1672,11 +1712,11 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < String > hasOrderPackageCodeList = new ArrayList < > ( ) ;
//把orderPackageCodeKeys每2000个元素为一组
int batchSize = 2 000;
int packageBatchSize = 1 000;
List < List < String > > orderPackageCodeGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderPackageCodeKeys . size ( ) ; i + = b atchSize) {
int endIndex = Math . min ( i + b atchSize, orderPackageCodeKeys . size ( ) ) ;
for ( int i = 0 ; i < orderPackageCodeKeys . size ( ) ; i + = packageB atchSize) {
int endIndex = Math . min ( i + packageB atchSize, orderPackageCodeKeys . size ( ) ) ;
orderPackageCodeGroups . add ( orderPackageCodeKeys . subList ( i , endIndex ) ) ;
}
@ -1689,6 +1729,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
importStandardOuPaiDTOS = importStandardOuPaiDTOS . stream ( ) . filter ( item - > ! hasOrderPackageCodeList . contains ( item . getOrderPackageCode ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < TrunklineAdvanceEntity > advanceEntityList = new ArrayList < > ( ) ;
List < TrunklineAdvanceEntity > updateAdvanceEntityList = new ArrayList < > ( ) ;
if ( importStandardOuPaiDTOS . isEmpty ( ) ) {
log . warn ( "##################importStandardOuPai: 没有需要处理的数据 importStandardOuPaiDTOS={}" , importStandardOuPaiDTOS ) ;
@ -1714,6 +1755,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//把orderCodeList分成每2000个元素一组
List < List < String > > orderedGroups = new ArrayList < > ( ) ;
int batchSize = 1000 ;
for ( int i = 0 ; i < orderCodeList . size ( ) ; i + = batchSize ) {
int endIndex = Math . min ( i + batchSize , orderCodeList . size ( ) ) ;
orderedGroups . add ( orderCodeList . subList ( i , endIndex ) ) ;
@ -1781,6 +1823,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
advanceEntity . setHasPackage ( 1 ) ;
advanceEntityList . add ( advanceEntity ) ;
} else {
advanceEntity . setTotalNum ( advanceEntity . getTotalNum ( ) + excelDTOS . size ( ) ) ;
updateAdvanceEntityList . add ( advanceEntity ) ;
advanceIds . add ( advanceEntity . getId ( ) ) ;
String trainNumber = advanceEntity . getTrainNumber ( ) ;
advanceEntityMap . put ( advanceEntity . getOrderCode ( ) + "&" + ( StringUtil . isBlank ( trainNumber ) ? "null" : trainNumber ) , advanceEntity ) ;
@ -1796,6 +1841,18 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
comlist . add ( fromCpFirstReq ) ;
}
CompletableFuture . allOf ( comlist . toArray ( new CompletableFuture [ 0 ] ) ) . join ( ) ;
}
if ( ! updateAdvanceEntityList . isEmpty ( ) ) {
//把advanceDetailEntities分成相等数量的10个集合
List < List < TrunklineAdvanceEntity > > advanceEntitiesList = updateAdvanceEntityList . stream ( ) . collect ( Collectors . groupingBy ( item - > updateAdvanceEntityList . indexOf ( item ) / 1000 ) ) . entrySet ( ) . stream ( ) . map ( Map . Entry : : getValue ) . collect ( Collectors . toList ( ) ) ;
List < CompletableFuture > comlist = new ArrayList < > ( ) ;
for ( int i = 0 ; i < advanceEntitiesList . size ( ) ; i + + ) {
List < TrunklineAdvanceEntity > list = advanceEntitiesList . get ( i ) ;
CompletableFuture < Boolean > fromCpFirstReq = asyncService . updateAdvanceEntity ( list , i + 1 ) ;
comlist . add ( fromCpFirstReq ) ;
}
CompletableFuture . allOf ( comlist . toArray ( new CompletableFuture [ 0 ] ) ) . join ( ) ;
}
@ -2237,6 +2294,19 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//把importOrderNoPackageExcelDTOS中的orderCode存入一个set集合
Set < String > orderCodes = importOrderNoPackageExcelDTOS . parallelStream ( ) . map ( ImportOrderNoPackageExcelDTO : : getOrderCode ) . collect ( Collectors . toSet ( ) ) ;
Map < String , Long > orderCodeCounts = importOrderNoPackageExcelDTOS . stream ( )
. collect ( Collectors . groupingBy ( a - > a . getOrderCode ( ) + "&" + a . getTrainNumber ( ) , Collectors . counting ( ) ) ) ;
Set < String > duplicateOrderCodes = orderCodeCounts . entrySet ( ) . stream ( )
. filter ( entry - > entry . getValue ( ) > 1 )
. map ( Map . Entry : : getKey )
. collect ( Collectors . toSet ( ) ) ;
if ( ! duplicateOrderCodes . isEmpty ( ) ) {
log . warn ( "#####################openLabelHasPacakage: 订单重复 {}" , duplicateOrderCodes ) ;
return R . fail ( 405 , "包条码重复" + duplicateOrderCodes ) ;
}
//把importOrderNoPackageExcelDTOS的每个元素提取成一个key为orderCode和trainNumber的拼接,value为元素本身的map
Map < String , ImportOrderNoPackageExcelDTO > importOrderNoPackageExcelDTOMap = importOrderNoPackageExcelDTOS . parallelStream ( ) . collect ( Collectors . toMap ( a - > a . getOrderCode ( ) + "&" + a . getTrainNumber ( ) , a - > a ) ) ;
@ -2247,7 +2317,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//把orderCodes转成List
List < String > orderCodeList = new ArrayList < > ( orderCodes ) ;
//把orderCodeList分成每2000个元素一组
int batchSize = 2 000;
int batchSize = 1 000;
List < List < String > > orderedGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderCodeList . size ( ) ; i + = batchSize ) {