Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopocarlini committed Nov 14, 2024
1 parent 7820460 commit 5e0ace1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;


@Service
Expand Down Expand Up @@ -86,12 +87,17 @@ public void pmDataExtraction(String dateFrom, String dateTo, List<String> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 5e0ace1

Please sign in to comment.