From 9be034db43421fff7fc90ce51dd52ff1ea9d9e4a Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Fri, 10 May 2024 16:06:02 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=B9=B2=E7=BA=BF=E6=9A=82=E5=AD=98=E5=8D=95?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8C=85=E4=BB=B6=E9=87=8D=E5=A4=8D=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/TrunklineAdvanceDetailMapper.java | 2 + .../mapper/TrunklineAdvanceDetailMapper.xml | 18 +++ .../ITrunklineAdvanceDetailService.java | 3 + .../service/impl/OpenOrderServiceImpl.java | 150 +++++++++++++++++- .../TrunklineAdvanceDetailServiceImpl.java | 5 + 5 files changed, 170 insertions(+), 8 deletions(-) diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java index f1157dc66..5311d9c8e 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java @@ -60,4 +60,6 @@ public interface TrunklineAdvanceDetailMapper extends BaseMapper findOrderDetails(IPage page, @Param("param") OrderDetailsDTO orderDetailsDTO); void updateWaybillNoIsNullByAdvanceIds(@Param("advanceIds") List advanceIds); + + List findListByExistsAndOrderPackageCodes(@Param("orderPackageCodeGroup") List orderPackageCodeGroup); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml index 92afe2a98..2354dffcd 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml @@ -346,4 +346,22 @@ + + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java index 191aad0ce..5c4a4983f 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java @@ -74,4 +74,7 @@ public interface ITrunklineAdvanceDetailService extends BaseService advanceIds); + + List findListByExistsAndOrderPackageCodes(List orderPackageCodeGroup); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index 84905bcf5..a61c1a758 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -1070,6 +1070,52 @@ public class OpenOrderServiceImpl implements IOpenOrderService { InputStream inputStream = file.getInputStream(); List 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 pacakgeDetailExcelDTOSet = pacakgeDetailExcelDTOS.stream().map(PacakgeDetailExcelDTO::getOrderPackageCode).collect(Collectors.toSet()); + + //把pacakgeDetailExcelDTOS中的元素的orderPackageCode属性分组 + Map orderPackageCodeCounts = pacakgeDetailExcelDTOS.stream() + .collect(Collectors.groupingBy(PacakgeDetailExcelDTO::getOrderPackageCode, Collectors.counting())); + + Set 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 orderPackageCodeKeys = new ArrayList<>(pacakgeDetailExcelDTOSet); + + List hasOrderPackageCodeList = new ArrayList<>(); + + //把orderPackageCodeKeys每2000个元素为一组 + int batchSize = 2000; + List> 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 hasOrderPackageCodes = advanceDetailService.findListByExistsAndOrderPackageCodes(orderPackageCodeGroup); + hasOrderPackageCodeList.addAll(hasOrderPackageCodes); + }); + + //排除pacakgeDetailExcelDTOS中orderPackageCode在hasOrderPackageCodeList中存在的元素 + pacakgeDetailExcelDTOS = pacakgeDetailExcelDTOS.stream().filter(item -> !hasOrderPackageCodeList.contains(item.getOrderPackageCode())).collect(Collectors.toList()); + + List advanceEntityList = new ArrayList<>(); + + if(pacakgeDetailExcelDTOS.isEmpty()){ + log.warn("##################openLabelHasPacakage: 没有需要处理的数据 pacakgeDetailExcelDTOS={}",pacakgeDetailExcelDTOS); + return R.data(advanceEntityList); + } Map> listMap = pacakgeDetailExcelDTOS.parallelStream().collect(Collectors.groupingBy(a -> a.getOrderCode() + "&" + a.getTrainNumber())); @@ -1080,7 +1126,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { List advanceDetailEntities = new ArrayList<>(); - List advanceEntityList = new ArrayList<>(); + Map advanceEntityMap = new HashMap<>(); @@ -1090,7 +1136,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { //把orderCodes转成List List orderCodeList = new ArrayList<>(orderCodes); //把orderCodeList分成每2000个元素一组 - int batchSize = 2000; List> orderedGroups = new ArrayList<>(); for (int i = 0; i < orderCodeList.size(); i += batchSize) { @@ -1333,6 +1378,53 @@ public class OpenOrderServiceImpl implements IOpenOrderService { List 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 importCustomizedOuPaiDTOSet = importCustomizedOuPaiDTOS.stream().map(ImportCustomizedOuPaiDTO::getOrderPackageCode).collect(Collectors.toSet()); + + //把pacakgeDetailExcelDTOS中的元素的orderPackageCode属性分组 + Map orderPackageCodeCounts = importCustomizedOuPaiDTOS.stream() + .collect(Collectors.groupingBy(ImportCustomizedOuPaiDTO::getOrderPackageCode, Collectors.counting())); + + Set 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 orderPackageCodeKeys = new ArrayList<>(importCustomizedOuPaiDTOSet); + + List hasOrderPackageCodeList = new ArrayList<>(); + + //把orderPackageCodeKeys每2000个元素为一组 + int batchSize = 2000; + List> 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 hasOrderPackageCodes = advanceDetailService.findListByExistsAndOrderPackageCodes(orderPackageCodeGroup); + hasOrderPackageCodeList.addAll(hasOrderPackageCodes); + }); + + //排除pacakgeDetailExcelDTOS中orderPackageCode在hasOrderPackageCodeList中存在的元素 + importCustomizedOuPaiDTOS = importCustomizedOuPaiDTOS.stream().filter(item -> !hasOrderPackageCodeList.contains(item.getOrderPackageCode())).collect(Collectors.toList()); + + List advanceEntityList = new ArrayList<>(); + + if(importCustomizedOuPaiDTOS.isEmpty()){ + log.warn("##################importCustomizedOuPai: 没有需要处理的数据 importCustomizedOuPaiDTOS={}",importCustomizedOuPaiDTOS); + return R.data(advanceEntityList); + } + Map> listMap = importCustomizedOuPaiDTOS.parallelStream().collect(Collectors.groupingBy(a -> a.getOrderCode() + "&" + a.getTrainNumber())); listMap.remove("null&null"); @@ -1344,7 +1436,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { //把orderCodes转成List List orderCodeList = new ArrayList<>(orderCodes); //把orderCodeList分成每2000个元素一组 - int batchSize = 2000; List> orderedGroups = new ArrayList<>(); for (int i = 0; i < orderCodeList.size(); i += batchSize) { @@ -1354,8 +1445,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { List advanceDetailEntities = new ArrayList<>(); - List advanceEntityList = new ArrayList<>(); - Map advanceEntityMap = new HashMap<>(); List advanceIds = new ArrayList<>(); @@ -1544,6 +1633,54 @@ public class OpenOrderServiceImpl implements IOpenOrderService { InputStream inputStream = file.getInputStream(); List 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 importStandardOuPaiDTOSet = importStandardOuPaiDTOS.stream().map(ImportStandardOuPaiDTO::getOrderPackageCode).collect(Collectors.toSet()); + + //把pacakgeDetailExcelDTOS中的元素的orderPackageCode属性分组 + Map orderPackageCodeCounts = importStandardOuPaiDTOS.stream() + .collect(Collectors.groupingBy(ImportStandardOuPaiDTO::getOrderPackageCode, Collectors.counting())); + + Set 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 orderPackageCodeKeys = new ArrayList<>(importStandardOuPaiDTOSet); + + List hasOrderPackageCodeList = new ArrayList<>(); + + //把orderPackageCodeKeys每2000个元素为一组 + int batchSize = 2000; + List> 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 hasOrderPackageCodes = advanceDetailService.findListByExistsAndOrderPackageCodes(orderPackageCodeGroup); + hasOrderPackageCodeList.addAll(hasOrderPackageCodes); + }); + + //排除importStandardOuPaiDTOS中orderPackageCode在hasOrderPackageCodeList中存在的元素 + importStandardOuPaiDTOS = importStandardOuPaiDTOS.stream().filter(item -> !hasOrderPackageCodeList.contains(item.getOrderPackageCode())).collect(Collectors.toList()); + + List advanceEntityList = new ArrayList<>(); + + if(importStandardOuPaiDTOS.isEmpty()){ + log.warn("##################importStandardOuPai: 没有需要处理的数据 importStandardOuPaiDTOS={}",importStandardOuPaiDTOS); + return R.data(advanceEntityList); + } + Map> listMap = importStandardOuPaiDTOS.parallelStream().collect(Collectors.groupingBy(a -> a.getOrderCode() + "&" + a.getTrainNumber())); listMap.remove("null&null"); @@ -1553,8 +1690,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { List advanceDetailEntities = new ArrayList<>(); - List advanceEntityList = new ArrayList<>(); - Map advanceEntityMap = new HashMap<>(); List advanceIds = new ArrayList<>(); @@ -1563,7 +1698,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { //把orderCodes转成List List orderCodeList = new ArrayList<>(orderCodes); //把orderCodeList分成每2000个元素一组 - int batchSize = 2000; List> orderedGroups = new ArrayList<>(); for (int i = 0; i < orderCodeList.size(); i += batchSize) { diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java index 0e93914f5..025824561 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java @@ -271,4 +271,9 @@ public class TrunklineAdvanceDetailServiceImpl extends BaseServiceImpl advanceIds) { baseMapper.updateWaybillNoIsNullByAdvanceIds(advanceIds); } + + @Override + public List findListByExistsAndOrderPackageCodes(List orderPackageCodeGroup) { + return baseMapper.findListByExistsAndOrderPackageCodes(orderPackageCodeGroup); + } }