diff --git a/src/main/java/it/gov/pagopa/bizpmingestion/service/impl/PMExtractionService.java b/src/main/java/it/gov/pagopa/bizpmingestion/service/impl/PMExtractionService.java index 09ce41c..c0de00f 100644 --- a/src/main/java/it/gov/pagopa/bizpmingestion/service/impl/PMExtractionService.java +++ b/src/main/java/it/gov/pagopa/bizpmingestion/service/impl/PMExtractionService.java @@ -30,6 +30,7 @@ import java.util.Comparator; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; @Service @@ -86,12 +87,17 @@ public void pmDataExtraction(String dateFrom, String dateTo, List taxCod + " transactions to save on Cosmos DB." + " Setted Filters: dateFrom=" + CommonUtility.sanitize(dateFrom) + ", dateFrom=" + CommonUtility.sanitize(dateTo) + ", taxCodes=" + CommonUtility.sanitize(taxCodes.toString()) + "." + " Started at " + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now()))); - int importedEventsCounter = ppTrList.parallelStream() - .map(ppTransaction -> { + + var pmEventList = ppTrList.stream() + .map(ppTransaction -> modelMapper.map(ppTransaction, PMEvent.class)) + .toList(); + + int importedEventsCounter = pmEventList.parallelStream() + .map(pmEvent -> { try { - return transactionService.elaboration(ppTransaction, paymentMethodType); + return transactionService.elaboration(pmEvent, paymentMethodType); } catch (Exception e) { - log.error(String.format(LOG_BASE_HEADER_INFO, METHOD, CommonUtility.sanitize(pmExtractionType.toString()) + " type data extraction info: Error importing PM event with id=" + ppTransaction.getId() + log.error(String.format(LOG_BASE_HEADER_INFO, METHOD, CommonUtility.sanitize(pmExtractionType.toString()) + " type data extraction info: Error importing PM event with id=" + pmEvent.getPkTransactionId() + " (err desc = " + e.getMessage() + ")")); return 0; } diff --git a/src/main/java/it/gov/pagopa/bizpmingestion/service/impl/TransactionService.java b/src/main/java/it/gov/pagopa/bizpmingestion/service/impl/TransactionService.java index c0d0f95..036d8e8 100644 --- a/src/main/java/it/gov/pagopa/bizpmingestion/service/impl/TransactionService.java +++ b/src/main/java/it/gov/pagopa/bizpmingestion/service/impl/TransactionService.java @@ -36,8 +36,7 @@ public class TransactionService { @Transactional - public int elaboration(PPTransaction ppTransaction, PaymentMethodType paymentMethodType) { - PMEvent pmEvent = modelMapper.map(ppTransaction, PMEvent.class); + public int elaboration(PMEvent pmEvent, PaymentMethodType paymentMethodType) { PMEventPaymentDetail pmEventPaymentDetail = pmEvent.getPaymentDetailList() .stream() .max(Comparator.comparing(PMEventPaymentDetail::getImporto))