@ -601,7 +601,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
//判断是否是开单及入库的配置
Boolean aBoolean = basicdataOpenIncomingClient . checkOpenIncoming ( warehouseId , brandId ) ;
if ( Boolean . TRUE . equals ( aBoolean ) ) {
openOrderAsyncService . incomingPackageBatch ( advanceIds , AuthUtil . getUserId ( ) , Func . firstLong ( AuthUtil . getDeptId ( ) ) , AuthUtil . getTenantId ( ) , AuthUtil . getNickName ( ) , IncomingTypeEnum . OPEN_TO_IN . getCode ( ) , warehouseId , warehouseName ) ;
openOrderAsyncService . incomingPackageBatch ( advanceIds , AuthUtil . getUserId ( ) , Func . firstLong ( AuthUtil . getDeptId ( ) ) , AuthUtil . getTenantId ( ) , AuthUtil . getNickName ( ) , IncomingTypeEnum . OPEN_TO_IN . getCode ( ) , warehouseId , warehouseName , waybillEntity ) ;
waybillEntity . setStockCount ( waybillEntity . getTotalCount ( ) ) ;
waybillEntity . setWaybillStatus ( "20" ) ;
warehouseWaybillClient . updateEntity ( waybillEntity ) ;
@ -2100,49 +2100,62 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < ImportOrderNoPackageExcelDTO > importOrderNoPackageExcelDTOS = EasyExcel . read ( inputStream ) . head ( ImportOrderNoPackageExcelDTO . class ) . sheet ( 0 ) . headRowNumber ( 2 ) . doReadSync ( ) ;
Map < String , Long > orderCodeCounts = importOrderNoPackageExcelDTOS . stream ( )
. collect ( Collectors . groupingBy ( a - > ( a . getOrderCode ( ) + "&" + a . getFirsts ( ) ) , 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 ( "#################importCustomizedOuPai: 订单号品类重复 {}" , duplicateOrderCodes ) ;
return R . fail ( 405 , "包条码重复" + duplicateOrderCodes ) ;
}
//把importOrderNoPackageExcelDTOS中的orderCode存入一个set集合
Set < String > orderCodes = importOrderNoPackageExcelDTOS . parallelStream ( ) . map ( ImportOrderNoPackageExcelDTO : : getOrderCode ) . collect ( Collectors . toSet ( ) ) ;
// Set<String> orderCodes = importOrderNoPackageExcelDTOS.parallelStream().map(ImportOrderNoPackageExcelDTO::getOrderCode).collect(Collectors.toSet());
//把importOrderNoPackageExcelDTOS的每个元素提取成一个key为orderCode和trainNumber的拼接,value为元素本身的map
Map < String , ImportOrderNoPackageExcelDTO > importOrderNoPackageExcelDTOMap = importOrderNoPackageExcelDTOS . parallelStream ( ) . collect ( Collectors . toMap ( a - > a . getOrderCode ( ) + "&" + a . getTrainNumber ( ) , a - > a ) ) ;
Map < String , ImportOrderNoPackageExcelDTO > importOrderNoPackageExcelDTOMap = importOrderNoPackageExcelDTOS . parallelStream ( ) . collect ( Collectors . toMap ( a - > a . getOrderCode ( ) + "&" + a . getFirsts ( ) , a - > a ) ) ;
importOrderNoPackageExcelDTOMap . remove ( "null&null" ) ;
List < TrunklineAdvanceEntity > detailEntities = new ArrayList < > ( ) ;
//把orderCodes转成List
List < String > orderCodeList = new ArrayList < > ( orderCodes ) ;
// 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 ) {
int endIndex = Math . min ( i + batchSize , orderCodeList . size ( ) ) ;
orderedGroups . add ( orderCodeList . subList ( i , endIndex ) ) ;
}
for ( int i = 0 ; i < orderedGroups . size ( ) ; i + + ) {
List < String > set1 = orderedGroups . get ( i ) ;
List < TrunklineAdvanceEntity > entities = advanceService . findListByExistsAndOrderCodeSet ( set1 ) ;
detailEntities . addAll ( entities ) ;
}
// int batchSize = 2000;
// List<List<String>> orderedGroups = new ArrayList<>();
//
// for (int i = 0; i < orderCodeList.size(); i += batchSize) {
// int endIndex = Math.min(i + batchSize, orderCodeList.size());
// orderedGroups.add(orderCodeList.subList(i, endIndex));
// }
// for (int i = 0; i < orderedGroups.size(); i++) {
// List<String> set1 = orderedGroups.get(i);
// List<TrunklineAdvanceEntity> entities = advanceService.findListByExistsAndOrderCodeSet(set1);
// detailEntities.addAll(entities);
// }
Map < String , TrunklineAdvanceEntity > advanceEntityMap = new HashMap < > ( ) ;
//把detailEntities转化成以orderCode和trainNumber为key的map
detailEntities . forEach ( advanceEntity - > {
String orderCode = advanceEntity . getOrderCode ( ) ;
String trainNumber = advanceEntity . getTrainNumber ( ) ;
String key = orderCode + "&" + ( StringUtil . isBlank ( trainNumber ) ? "null" : trainNumber ) ;
advanceEntityMap . put ( key , advanceEntity ) ;
} ) ;
// detailEntities.forEach(advanceEntity -> {
// String orderCode = advanceEntity.getOrderCode();
// String packName = advanceEntity.getPackName();
// String key = orderCode + "&" + (StringUtil.isBlank(packName)?"null":packName);
// advanceEntityMap.put(key,advanceEntity);
// });
List < TrunklineAdvanceEntity > list = new ArrayList < > ( ) ;
importOrderNoPackageExcelDTOMap . keySet ( ) . forEach ( key - > {
ImportOrderNoPackageExcelDTO importOrderNoPackageExcelDTO = importOrderNoPackageExcelDTOMap . get ( key ) ;
TrunklineAdvanceEntity advanceEntity = advanceEntityMap . get ( key ) ;
if ( Objects . isNull ( advanceEntity ) ) {
if ( Objects . isNull ( importOrderNoPackageExcelDTO ) ) {
String orderCode = importOrderNoPackageExcelDTO . getOrderCode ( ) ;
advanceEntity = new TrunklineAdvanceVO ( ) ;
TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceVO ( ) ;
advanceEntity . setWarehouseId ( warehouseId ) ;
advanceEntity . setWarehouseName ( warehouseName ) ;
advanceEntity . setServiceNum ( importOrderNoPackageExcelDTO . getServiceNum ( ) ) ;
@ -2181,8 +2194,8 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < TrunklineAdvanceDetailEntity > advanceDetailEntities = new ArrayList < > ( ) ;
for ( TrunklineAdvanceEntity advanceEntity : list ) {
String orderCode = advanceEntity . getOrderCode ( ) ;
String trainNumber = advanceEntity . getTrainNumber ( ) ;
ImportOrderNoPackageExcelDTO importOrderNoPackageExcelDTO = importOrderNoPackageExcelDTOMap . get ( orderCode + "&" + ( StringUtil . isBlank ( trainNumber ) ? "null" : trainNumber ) ) ;
String packName = advanceEntity . getPackName ( ) ;
ImportOrderNoPackageExcelDTO importOrderNoPackageExcelDTO = importOrderNoPackageExcelDTOMap . get ( orderCode + "&" + ( StringUtil . isBlank ( packName ) ? "null" : packName ) ) ;
if ( ! Objects . isNull ( importOrderNoPackageExcelDTO ) ) {
String firsts = importOrderNoPackageExcelDTO . getFirsts ( ) ;
Integer totalNum = advanceEntity . getTotalNum ( ) ;
@ -2292,99 +2305,136 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
List < ImportOrderNoPackageExcelDTO > importOrderNoPackageExcelDTOS = EasyExcel . read ( inputStream ) . head ( ImportOrderNoPackageExcelDTO . class ) . sheet ( 0 ) . headRowNumber ( 2 ) . doReadSync ( ) ;
//把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 ) ) ;
importOrderNoPackageExcelDTOMap . remove ( "null&null" ) ;
List < TrunklineAdvanceEntity > detailEntities = new ArrayList < > ( ) ;
//把orderCodes转成List
List < String > orderCodeList = new ArrayList < > ( orderCodes ) ;
//把orderCodeList分成每2000个元素一组
int batchSize = 1000 ;
List < List < String > > orderedGroups = new ArrayList < > ( ) ;
for ( int i = 0 ; i < orderCodeList . size ( ) ; i + = batchSize ) {
int endIndex = Math . min ( i + batchSize , orderCodeList . size ( ) ) ;
orderedGroups . add ( orderCodeList . subList ( i , endIndex ) ) ;
}
for ( int i = 0 ; i < orderedGroups . size ( ) ; i + + ) {
List < String > set1 = orderedGroups . get ( i ) ;
List < TrunklineAdvanceEntity > entities = advanceService . findListByExistsAndOrderCodeSet ( set1 ) ;
detailEntities . addAll ( entities ) ;
}
Map < String , TrunklineAdvanceEntity > advanceEntityMap = new HashMap < > ( ) ;
//把detailEntities转化成以orderCode和trainNumber为key的map
detailEntities . forEach ( advanceEntity - > {
String orderCode = advanceEntity . getOrderCode ( ) ;
String trainNumber = advanceEntity . getTrainNumber ( ) ;
String key = orderCode + "&" + ( StringUtil . isBlank ( trainNumber ) ? "null" : trainNumber ) ;
advanceEntityMap . put ( key , advanceEntity ) ;
} ) ;
// 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));
//
// importOrderNoPackageExcelDTOMap.remove("null&null");
//
// List<TrunklineAdvanceEntity> detailEntities = new ArrayList<>();
//
// //把orderCodes转成List
// List<String> orderCodeList = new ArrayList<>(orderCodes);
// //把orderCodeList分成每2000个元素一组
// int batchSize = 1000;
// List<List<String>> orderedGroups = new ArrayList<>();
//
// for (int i = 0; i < orderCodeList.size(); i += batchSize) {
// int endIndex = Math.min(i + batchSize, orderCodeList.size());
// orderedGroups.add(orderCodeList.subList(i, endIndex));
// }
// for (int i = 0; i < orderedGroups.size(); i++) {
// List<String> set1 = orderedGroups.get(i);
// List<TrunklineAdvanceEntity> entities = advanceService.findListByExistsAndOrderCodeSet(set1);
// detailEntities.addAll(entities);
// }
//
// Map<String,TrunklineAdvanceEntity> advanceEntityMap = new HashMap<>();
//
// //把detailEntities转化成以orderCode和trainNumber为key的map
// detailEntities.forEach(advanceEntity -> {
// String orderCode = advanceEntity.getOrderCode();
// String trainNumber = advanceEntity.getTrainNumber();
// String key = orderCode + "&" + (StringUtil.isBlank(trainNumber)?"null":trainNumber);
// advanceEntityMap.put(key,advanceEntity);
// });
List < TrunklineAdvanceEntity > list = new ArrayList < > ( ) ;
importOrderNoPackageExcelDTOMap . keySet ( ) . forEach ( key - > {
ImportOrderNoPackageExcelDTO importOrderNoPackageExcelDTO = importOrderNoPackageExcelDTOMap . get ( key ) ;
TrunklineAdvanceEntity advanceEntity = advanceEntityMap . get ( key ) ;
if ( Objects . isNull ( advanceEntity ) ) {
String orderCode = importOrderNoPackageExcelDTO . getOrderCode ( ) ;
advanceEntity = new TrunklineAdvanceVO ( ) ;
advanceEntity . setWarehouseId ( warehouseId ) ;
advanceEntity . setWarehouseName ( warehouseName ) ;
advanceEntity . setServiceNum ( importOrderNoPackageExcelDTO . getServiceNum ( ) ) ;
advanceEntity . setOrderCode ( orderCode ) ;
advanceEntity . setArea ( importOrderNoPackageExcelDTO . getArea ( ) ) ;
advanceEntity . setBrand ( importOrderNoPackageExcelDTO . getBrand ( ) ) ;
advanceEntity . setTotalNum ( Integer . parseInt ( importOrderNoPackageExcelDTO . getCount ( ) ) ) ;
advanceEntity . setPackName ( importOrderNoPackageExcelDTO . getFirsts ( ) ) ;
advanceEntity . setDealerCode ( importOrderNoPackageExcelDTO . getDealerCode ( ) ) ;
advanceEntity . setDealerName ( importOrderNoPackageExcelDTO . getDealerName ( ) ) ;
advanceEntity . setCustomerName ( importOrderNoPackageExcelDTO . getCustomerName ( ) ) ;
advanceEntity . setCustomerPhone ( importOrderNoPackageExcelDTO . getCustomerPhone ( ) ) ;
advanceEntity . setCustomerAddress ( importOrderNoPackageExcelDTO . getCustomerAddress ( ) ) ;
advanceEntity . setConsigneePerson ( importOrderNoPackageExcelDTO . getConsigneePerson ( ) ) ;
advanceEntity . setConsigneeMobile ( importOrderNoPackageExcelDTO . getConsigneeMobile ( ) ) ;
advanceEntity . setConsigneeAddress ( importOrderNoPackageExcelDTO . getConsigneeAddress ( ) ) ;
advanceEntity . setSenderName ( importOrderNoPackageExcelDTO . getShipperPerson ( ) ) ;
advanceEntity . setSenderPhone ( importOrderNoPackageExcelDTO . getShipperMobile ( ) ) ;
advanceEntity . setSenderAddress ( importOrderNoPackageExcelDTO . getShipperAddress ( ) ) ;
advanceEntity . setTrainNumber ( importOrderNoPackageExcelDTO . getTrainNumber ( ) ) ;
advanceEntity . setSystemType ( "线上" ) ;
advanceEntity . setMatingType ( "1" ) ;
advanceEntity . setWaybillStatus ( "0" ) ;
advanceEntity . setFreezeStatus ( "0" ) ;
advanceEntity . setLegacyStatus ( "0" ) ;
if ( orderCode . contains ( "遗" ) ) {
advanceEntity . setLegacyStatus ( "1" ) ;
}
advanceEntity . setHasPackage ( 0 ) ;
advanceEntity . setCreateUserName ( AuthUtil . getNickName ( ) ) ;
list . add ( advanceEntity ) ;
// importOrderNoPackageExcelDTOMap.keySet().forEach(key -> {
// ImportOrderNoPackageExcelDTO importOrderNoPackageExcelDTO = importOrderNoPackageExcelDTOMap.get(key);
// TrunklineAdvanceEntity advanceEntity = advanceEntityMap.get(key);
// if(Objects.isNull(advanceEntity)){
// String orderCode = importOrderNoPackageExcelDTO.getOrderCode();
// advanceEntity = new TrunklineAdvanceVO();
// advanceEntity.setWarehouseId(warehouseId);
// advanceEntity.setWarehouseName(warehouseName);
// advanceEntity.setServiceNum(importOrderNoPackageExcelDTO.getServiceNum());
// advanceEntity.setOrderCode(orderCode);
// advanceEntity.setArea(importOrderNoPackageExcelDTO.getArea());
// advanceEntity.setBrand(importOrderNoPackageExcelDTO.getBrand());
// advanceEntity.setTotalNum(Integer.parseInt(importOrderNoPackageExcelDTO.getCount()));
// advanceEntity.setPackName(importOrderNoPackageExcelDTO.getFirsts());
// advanceEntity.setDealerCode(importOrderNoPackageExcelDTO.getDealerCode());
// advanceEntity.setDealerName(importOrderNoPackageExcelDTO.getDealerName());
// advanceEntity.setCustomerName(importOrderNoPackageExcelDTO.getCustomerName());
// advanceEntity.setCustomerPhone(importOrderNoPackageExcelDTO.getCustomerPhone());
// advanceEntity.setCustomerAddress(importOrderNoPackageExcelDTO.getCustomerAddress());
// advanceEntity.setConsigneePerson(importOrderNoPackageExcelDTO.getConsigneePerson());
// advanceEntity.setConsigneeMobile(importOrderNoPackageExcelDTO.getConsigneeMobile());
// advanceEntity.setConsigneeAddress(importOrderNoPackageExcelDTO.getConsigneeAddress());
// advanceEntity.setSenderName(importOrderNoPackageExcelDTO.getShipperPerson());
// advanceEntity.setSenderPhone(importOrderNoPackageExcelDTO.getShipperMobile());
// advanceEntity.setSenderAddress(importOrderNoPackageExcelDTO.getShipperAddress());
// advanceEntity.setTrainNumber(importOrderNoPackageExcelDTO.getTrainNumber());
// advanceEntity.setSystemType("线上");
// advanceEntity.setMatingType("1");
// advanceEntity.setWaybillStatus("0");
// advanceEntity.setFreezeStatus("0");
// advanceEntity.setLegacyStatus("0");
// if (orderCode.contains("遗")) {
// advanceEntity.setLegacyStatus("1");
// }
// advanceEntity.setHasPackage(0);
// advanceEntity.setCreateUserName(AuthUtil.getNickName());
// list.add(advanceEntity);
// }
// });
importOrderNoPackageExcelDTOS . forEach ( importOrderNoPackageExcelDTO - > {
String orderCode = importOrderNoPackageExcelDTO . getOrderCode ( ) ;
TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity ( ) ;
advanceEntity . setWarehouseId ( warehouseId ) ;
advanceEntity . setWarehouseName ( warehouseName ) ;
advanceEntity . setServiceNum ( importOrderNoPackageExcelDTO . getServiceNum ( ) ) ;
advanceEntity . setOrderCode ( orderCode ) ;
advanceEntity . setArea ( importOrderNoPackageExcelDTO . getArea ( ) ) ;
advanceEntity . setBrand ( importOrderNoPackageExcelDTO . getBrand ( ) ) ;
advanceEntity . setTotalNum ( Integer . parseInt ( importOrderNoPackageExcelDTO . getCount ( ) ) ) ;
advanceEntity . setPackName ( importOrderNoPackageExcelDTO . getFirsts ( ) ) ;
advanceEntity . setDealerCode ( importOrderNoPackageExcelDTO . getDealerCode ( ) ) ;
advanceEntity . setDealerName ( importOrderNoPackageExcelDTO . getDealerName ( ) ) ;
advanceEntity . setCustomerName ( importOrderNoPackageExcelDTO . getCustomerName ( ) ) ;
advanceEntity . setCustomerPhone ( importOrderNoPackageExcelDTO . getCustomerPhone ( ) ) ;
advanceEntity . setCustomerAddress ( importOrderNoPackageExcelDTO . getCustomerAddress ( ) ) ;
advanceEntity . setConsigneePerson ( importOrderNoPackageExcelDTO . getConsigneePerson ( ) ) ;
advanceEntity . setConsigneeMobile ( importOrderNoPackageExcelDTO . getConsigneeMobile ( ) ) ;
advanceEntity . setConsigneeAddress ( importOrderNoPackageExcelDTO . getConsigneeAddress ( ) ) ;
advanceEntity . setSenderName ( importOrderNoPackageExcelDTO . getShipperPerson ( ) ) ;
advanceEntity . setSenderPhone ( importOrderNoPackageExcelDTO . getShipperMobile ( ) ) ;
advanceEntity . setSenderAddress ( importOrderNoPackageExcelDTO . getShipperAddress ( ) ) ;
advanceEntity . setTrainNumber ( importOrderNoPackageExcelDTO . getTrainNumber ( ) ) ;
advanceEntity . setSystemType ( "线上" ) ;
advanceEntity . setMatingType ( "1" ) ;
advanceEntity . setWaybillStatus ( "0" ) ;
advanceEntity . setFreezeStatus ( "0" ) ;
advanceEntity . setLegacyStatus ( "0" ) ;
if ( orderCode . contains ( "遗" ) ) {
advanceEntity . setLegacyStatus ( "1" ) ;
}
advanceEntity . setHasPackage ( 0 ) ;
advanceEntity . setCreateUserName ( AuthUtil . getNickName ( ) ) ;
list . add ( advanceEntity ) ;
} ) ;
advanceService . saveBatch ( list ) ;
int successNum = list . size ( ) ;
return R . success ( "成功导入" + successNum + "件" ) ;
return R . success ( "成功导入" + successNum + "条 " ) ;
}
@Override