Skip to content

Commit

Permalink
Merge branch 'main' into PAGOPA-2353-refix
Browse files Browse the repository at this point in the history
  • Loading branch information
aomegax authored Nov 13, 2024
2 parents 703b591 + e079215 commit 08f2949
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-wisp-converter
description: A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing them with GPD system
type: application
version: 0.268.0
appVersion: 0.4.28
version: 0.271.0
appVersion: 0.4.28-3-catch-re-exception
dependencies:
- name: microservice-chart
version: 3.0.0
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart: &microservice-chart
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "0.4.28"
tag: "0.4.28-3-catch-re-exception"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart: &microservice-chart
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "0.4.28"
tag: "0.4.28-3-catch-re-exception"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart: &microservice-chart
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "0.4.28"
tag: "0.4.28-3-catch-re-exception"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion openapi/openapi_redirect.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.1",
"info": {
"title": "WISP-Converter-redirect",
"version": "0.4.28"
"version": "0.4.28-3-catch-re-exception"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>wisp-converter</artifactId>
<version>0.4.28</version>
<version>0.4.28-3-catch-re-exception</version>
<name>pagoPA WISP Converter</name>
<description>A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

@Component
@Slf4j
Expand All @@ -40,15 +41,19 @@ public RecoveryScheduler(RecoveryService recoveryService) {
@Scheduled(cron = "${cron.job.schedule.recovery.receipt-ko.trigger}")
@Async
public void recoverReceiptKOCronJob() {
ZonedDateTime dateFrom = ZonedDateTime.now(ZoneOffset.UTC).minusHours(fromHoursAgo);
ZonedDateTime dateTo = ZonedDateTime.now(ZoneOffset.UTC).minusHours(untilHoursAgo);
ZonedDateTime dateFrom = ZonedDateTime.now(ZoneOffset.UTC).minusHours(fromHoursAgo).truncatedTo(ChronoUnit.HOURS);
ZonedDateTime dateTo = ZonedDateTime.now(ZoneOffset.UTC).minusHours(untilHoursAgo).truncatedTo(ChronoUnit.HOURS);
log.info("[WISP-Recovery][Scheduled][Start] Reconciliation Cron: recoverReceiptKOCronJob running at {}, for recover stale RPT from {} to {}",
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now()), dateFrom, dateTo);

int missingRTRecovered = this.recoveryService.recoverReceiptKOByDate(dateFrom, dateTo).getPayments().size();
// recover RPT without redirect
int missingRedirectRecovered = this.recoveryService.recoverMissingRedirect(dateFrom, dateTo);

log.info("[WISP-Recovery][Scheduled][Stop] Reconciliation Cron: recoverReceiptKOCronJob {} receipt-ko sent", missingRedirectRecovered + missingRTRecovered);
// recover receipt-rt in state redirect or sending with rt equals to null
int missingRTRecovered = this.recoveryService.recoverReceiptKOByDate(dateFrom, dateTo).getPayments().size();

log.info("[WISP-Recovery][Scheduled][Stop] Reconciliation Cron: recoverReceiptKOCronJob {} receipt-ko sent," +
" missingRedirect: {}, missingRTRecovered: {}", missingRedirectRecovered + missingRTRecovered, missingRedirectRecovered, missingRTRecovered);
this.threadOfExecution = Thread.currentThread();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void addRe(ReEventDto reEventDto) {
ReEventEntity reEventEntity = reEventMapper.toReEventEntity(reEventDto);
reEventRepository.save(reEventEntity);
} catch (Exception e) {
throw new AppException(AppErrorCodeMessageEnum.PERSISTENCE_SAVING_RE_ERROR, e);
log.error("[RE-429][sessionId:{}] Exception: {}", reEventDto.getSessionId(), AppErrorCodeMessageEnum.PERSISTENCE_SAVING_RE_ERROR.getDetail());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

@Service
Expand All @@ -69,6 +68,7 @@ public class RecoveryService {

private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
private static final String DATE_FORMAT_DAY = "yyyy-MM-dd";
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
private static final List<String> blockedReceiptStatus = List.of(
ReceiptStatusEnum.NOT_SENT.name(),
ReceiptStatusEnum.REDIRECT.name(),
Expand Down Expand Up @@ -134,7 +134,8 @@ public RecoveryReceiptResponse recoverReceiptKOByCI(String creditorInstitution,
// Recover by dates (cron)
public RecoveryReceiptResponse recoverReceiptKOByDate(ZonedDateTime dateFrom, ZonedDateTime dateTo) {
// Query database for blocked Receipt in given timestamp
List<RTEntity> rtEntities = rtRepository.findByMidReceiptStatusInAndTimestampBetween(dateFrom.toString(), dateTo.toString());
List<RTEntity> rtEntities = rtRepository.findByMidReceiptStatusInAndTimestampBetween(
dateFrom.format(DATE_TIME_FORMATTER), dateTo.format(DATE_TIME_FORMATTER));
// For each entity call send receipt KO
rtEntities.forEach(rtEntity -> callSendReceiptKO(rtEntity.getDomainId(), rtEntity.getIuv(), rtEntity.getCcp(), rtEntity.getSessionId()));
return this.extractRecoveryReceiptResponse(rtEntities);
Expand Down

0 comments on commit 08f2949

Please sign in to comment.