diff --git a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/NotificationBuilder.java b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/NotificationBuilder.java index cc212b236..56cdad6b8 100644 --- a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/NotificationBuilder.java +++ b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/NotificationBuilder.java @@ -5,7 +5,13 @@ import ru.spcex.clearing.reports.services.DOCXService; import java.io.File; import java.net.URL; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.time.format.TextStyle; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; public abstract class NotificationBuilder { protected final DateTimeFormatter filenameDateTimeFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy'T'HH:mm:ss"); @@ -20,6 +26,21 @@ public abstract class NotificationBuilder { abstract public File buildNotification(Long consumerId); + protected void fillHeaderValues(Map valuesMap, Long notificationId) { + LocalDate notificationDate = LocalDate.now(); + int day = notificationDate.getDayOfMonth(); + int month = notificationDate.getMonthValue(); + int year = notificationDate.getYear(); + String dateStr = "%04d%02d%02d".formatted(year, month, day); + + valuesMap.put("${dateStr}", dateStr); + valuesMap.put("${count}", String.valueOf(notificationId)); + valuesMap.put("${currDay}", "%02d".formatted(day)); + valuesMap.put("${currMonth}", notificationDate.getMonth().getDisplayName(TextStyle.FULL, new Locale("ru"))); + valuesMap.put("${currYear}", "%02d".formatted(year % 100)); + + } + protected File getTemplateFile() { File templateFile; String templateResourceName = getTemplateResourceName(); diff --git a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/REXNotificationBuilder.java b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/REXNotificationBuilder.java index 48f539fc2..b09df0225 100644 --- a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/REXNotificationBuilder.java +++ b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/REXNotificationBuilder.java @@ -69,21 +69,11 @@ public class REXNotificationBuilder extends NotificationBuilder { return null; } - LocalDateTime notificationDate = LocalDateTime.now(); - int day = notificationDate.getDayOfMonth(); - int month = notificationDate.getMonthValue(); - int year = notificationDate.getYear(); - String dateStr = "%02d%02d%04d".formatted(day, month, year); - Map valuesForTemplate = new HashMap<>(); - valuesForTemplate.put("${dateStr}", dateStr); - valuesForTemplate.put("${count}", String.valueOf(notificationId)); - valuesForTemplate.put("${currDay}", "%02d".formatted(day)); - valuesForTemplate.put("${currMonth}", notificationDate.getMonth().getDisplayName(TextStyle.FULL, new Locale("ru"))); - valuesForTemplate.put("${currYear}", "%02d".formatted(year % 100)); - valuesForTemplate.put("${validFromDate}", "%02d.%02d.%04d".formatted(day, month, year)); + fillHeaderValues(valuesForTemplate, notificationId); + valuesForTemplate.put("${validFromDate}", dateFormatter.format(validFromDate)); - String outputFilename = "REX.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(notificationDate)); + String outputFilename = "REX.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(LocalDateTime.now())); outputFilename = normalizeFilenameForOS(outputFilename); File outputFile = new File(outputFilename); diff --git a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_ACTV_NotificationBuilder.java b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_ACTV_NotificationBuilder.java index 9ec7c85e2..b09813c5d 100644 --- a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_ACTV_NotificationBuilder.java +++ b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_ACTV_NotificationBuilder.java @@ -74,25 +74,14 @@ public class ROOT_ACTV_NotificationBuilder extends NotificationBuilder { return null; } - LocalDateTime notificationDate = LocalDateTime.now(); - int day = notificationDate.getDayOfMonth(); - int month = notificationDate.getMonthValue(); - int year = notificationDate.getYear(); - String dateStr = "%02d%02d%04d".formatted(day, month, year); - Map valuesForTemplate = new HashMap<>(); - valuesForTemplate.put("${dateStr}", dateStr); - valuesForTemplate.put("${count}", String.valueOf(notificationId)); - valuesForTemplate.put("${currDay}", "%02d".formatted(day)); - valuesForTemplate.put("${currMonth}", notificationDate.getMonth().getDisplayName(TextStyle.FULL, new Locale("ru"))); - valuesForTemplate.put("${currYear}", "%02d".formatted(year % 100)); - + fillHeaderValues(valuesForTemplate, notificationId); valuesForTemplate.put("${companyFullName}", company.getFullName()); valuesForTemplate.put("${companySymbolsINN}", companySymbols.getCompanySymbolValue()); valuesForTemplate.put("${companyClearingCode}", companyClearingCode); valuesForTemplate.put("${relationUpdatedAt}", dateFormatter.format(updatedAt.atZone(ZoneId.systemDefault()).toLocalDate())); - String outputFilename = "ROOT.ACTV.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(notificationDate)); + String outputFilename = "ROOT.ACTV.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(LocalDateTime.now())); outputFilename = normalizeFilenameForOS(outputFilename); File outputFile = new File(outputFilename); diff --git a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_BLKD_NotificationBuilder.java b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_BLKD_NotificationBuilder.java index a9d757451..f16848526 100644 --- a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_BLKD_NotificationBuilder.java +++ b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_BLKD_NotificationBuilder.java @@ -74,25 +74,14 @@ public class ROOT_BLKD_NotificationBuilder extends NotificationBuilder { return null; } - LocalDateTime notificationDate = LocalDateTime.now(); - int day = notificationDate.getDayOfMonth(); - int month = notificationDate.getMonthValue(); - int year = notificationDate.getYear(); - String dateStr = "%02d%02d%04d".formatted(day, month, year); - Map valuesForTemplate = new HashMap<>(); - valuesForTemplate.put("${dateStr}", dateStr); - valuesForTemplate.put("${count}", String.valueOf(notificationId)); - valuesForTemplate.put("${currDay}", "%02d".formatted(day)); - valuesForTemplate.put("${currMonth}", notificationDate.getMonth().getDisplayName(TextStyle.FULL, new Locale("ru"))); - valuesForTemplate.put("${currYear}", "%02d".formatted(year % 100)); - + fillHeaderValues(valuesForTemplate, notificationId); valuesForTemplate.put("${companyFullName}", company.getFullName()); valuesForTemplate.put("${companySymbolsINN}", companySymbols.getCompanySymbolValue()); valuesForTemplate.put("${companyClearingCode}", companyClearingCode); valuesForTemplate.put("${relationUpdatedAt}", dateFormatter.format(updatedAt.atZone(ZoneId.systemDefault()).toLocalDate())); - String outputFilename = "ROOT.BLKD.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(notificationDate)); + String outputFilename = "ROOT.BLKD.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(LocalDateTime.now())); outputFilename = normalizeFilenameForOS(outputFilename); File outputFile = new File(outputFilename); diff --git a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_CLOS_NotificationBuilder.java b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_CLOS_NotificationBuilder.java index 4ccbb8d21..2ac7b9083 100644 --- a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_CLOS_NotificationBuilder.java +++ b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_CLOS_NotificationBuilder.java @@ -82,25 +82,15 @@ public class ROOT_CLOS_NotificationBuilder extends NotificationBuilder { return null; } - LocalDateTime notificationDate = LocalDateTime.now(); - int day = notificationDate.getDayOfMonth(); - int month = notificationDate.getMonthValue(); - int year = notificationDate.getYear(); - String dateStr = "%02d%02d%04d".formatted(day, month, year); - Map valuesForTemplate = new HashMap<>(); - valuesForTemplate.put("${dateStr}", dateStr); - valuesForTemplate.put("${count}", String.valueOf(notificationId)); - valuesForTemplate.put("${currDay}", "%02d".formatted(day)); - valuesForTemplate.put("${currMonth}", notificationDate.getMonth().getDisplayName(TextStyle.FULL, new Locale("ru"))); - valuesForTemplate.put("${currYear}", "%02d".formatted(year % 100)); + fillHeaderValues(valuesForTemplate, notificationId); valuesForTemplate.put("${companyFullName}", company.getFullName()); valuesForTemplate.put("${companySymbolsINN}", companySymbols.getCompanySymbolValue()); valuesForTemplate.put("${companyClearingCode}", companyClearingCode); valuesForTemplate.put("${profileDocumentNumber}", currentProfileDocument.getNumber()); valuesForTemplate.put("${validFromDate}", dateFormatter.format(validFromDate)); - String outputFilename = "ROOT.CLOS.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(notificationDate)); + String outputFilename = "ROOT.CLOS.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(LocalDateTime.now())); outputFilename = normalizeFilenameForOS(outputFilename); File outputFile = new File(outputFilename); diff --git a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_NEW_NotificationBuilder.java b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_NEW_NotificationBuilder.java index f341e75d1..abcfcdd01 100644 --- a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_NEW_NotificationBuilder.java +++ b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_NEW_NotificationBuilder.java @@ -82,25 +82,15 @@ public class ROOT_NEW_NotificationBuilder extends NotificationBuilder { return null; } - LocalDateTime notificationDate = LocalDateTime.now(); - int day = notificationDate.getDayOfMonth(); - int month = notificationDate.getMonthValue(); - int year = notificationDate.getYear(); - String dateStr = "%02d%02d%04d".formatted(day, month, year); - Map valuesForTemplate = new HashMap<>(); - valuesForTemplate.put("${dateStr}", dateStr); - valuesForTemplate.put("${count}", String.valueOf(notificationId)); - valuesForTemplate.put("${currDay}", "%02d".formatted(day)); - valuesForTemplate.put("${currMonth}", notificationDate.getMonth().getDisplayName(TextStyle.FULL, new Locale("ru"))); - valuesForTemplate.put("${currYear}", "%02d".formatted(year % 100)); + fillHeaderValues(valuesForTemplate, notificationId); valuesForTemplate.put("${companyFullName}", company.getFullName()); valuesForTemplate.put("${companySymbolsINN}", companySymbols.getCompanySymbolValue()); valuesForTemplate.put("${companyClearingCode}", companyClearingCode); valuesForTemplate.put("${profileDocumentNumber}", currentProfileDocument.getNumber()); valuesForTemplate.put("${validFromDate}", dateFormatter.format(validFromDate)); - String outputFilename = "ROOT.NEW.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(notificationDate)); + String outputFilename = "ROOT.NEW.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(LocalDateTime.now())); outputFilename = normalizeFilenameForOS(outputFilename); File outputFile = new File(outputFilename); diff --git a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_SSPD_NotificationBuilder.java b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_SSPD_NotificationBuilder.java index 73569c55a..eb009a49b 100644 --- a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_SSPD_NotificationBuilder.java +++ b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/ROOT_SSPD_NotificationBuilder.java @@ -14,7 +14,6 @@ import ru.spcex.platform.imdg.api.ImdgProvider; import java.io.File; import java.time.Instant; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.TextStyle; @@ -74,25 +73,14 @@ public class ROOT_SSPD_NotificationBuilder extends NotificationBuilder { return null; } - LocalDateTime notificationDate = LocalDateTime.now(); - int day = notificationDate.getDayOfMonth(); - int month = notificationDate.getMonthValue(); - int year = notificationDate.getYear(); - String dateStr = "%02d%02d%04d".formatted(day, month, year); - Map valuesForTemplate = new HashMap<>(); - valuesForTemplate.put("${dateStr}", dateStr); - valuesForTemplate.put("${count}", String.valueOf(notificationId)); - valuesForTemplate.put("${currDay}", "%02d".formatted(day)); - valuesForTemplate.put("${currMonth}", notificationDate.getMonth().getDisplayName(TextStyle.FULL, new Locale("ru"))); - valuesForTemplate.put("${currYear}", "%02d".formatted(year % 100)); - + fillHeaderValues(valuesForTemplate, notificationId); valuesForTemplate.put("${companyFullName}", company.getFullName()); valuesForTemplate.put("${companySymbolsINN}", companySymbols.getCompanySymbolValue()); valuesForTemplate.put("${companyClearingCode}", companyClearingCode); valuesForTemplate.put("${relationUpdatedAt}", dateFormatter.format(updatedAt.atZone(ZoneId.systemDefault()).toLocalDate())); - String outputFilename = "ROOT.SSPD.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(notificationDate)); + String outputFilename = "ROOT.SSPD.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(LocalDateTime.now())); outputFilename = normalizeFilenameForOS(outputFilename); File outputFile = new File(outputFilename); diff --git a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/RRPCNotificationBuilder.java b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/RRPCNotificationBuilder.java index 609531c94..797d6cbfb 100644 --- a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/RRPCNotificationBuilder.java +++ b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/notifications/RRPCNotificationBuilder.java @@ -73,18 +73,8 @@ public class RRPCNotificationBuilder extends NotificationBuilder { return null; } - LocalDateTime notificationDate = LocalDateTime.now(); - int day = notificationDate.getDayOfMonth(); - int month = notificationDate.getMonthValue(); - int year = notificationDate.getYear(); - String dateStr = "%02d%02d%04d".formatted(day, month, year); - Map valuesForTemplate = new HashMap<>(); - valuesForTemplate.put("${dateStr}", dateStr); - valuesForTemplate.put("${count}", String.valueOf(notificationId)); - valuesForTemplate.put("${currDay}", "%02d".formatted(day)); - valuesForTemplate.put("${currMonth}", notificationDate.getMonth().getDisplayName(TextStyle.FULL, new Locale("ru"))); - valuesForTemplate.put("${currYear}", "%02d".formatted(year % 100)); + fillHeaderValues(valuesForTemplate, notificationId); valuesForTemplate.put("${relationUpdatedAt}", dateFormatter.format(updatedAt.atZone(ZoneId.systemDefault()).toLocalDate())); valuesForTemplate.put("${companyFullName}", company.getFullName()); @@ -92,7 +82,7 @@ public class RRPCNotificationBuilder extends NotificationBuilder { valuesForTemplate.put("${companySymbolsINN}", companySymbols.getCompanySymbolValue()); valuesForTemplate.put("${companyClearingCode}", companyClearingCode); - String outputFilename = "RRPC.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(notificationDate)); + String outputFilename = "RRPC.%s.%s.docx".formatted(companyClearingCode, filenameDateTimeFormatter.format(LocalDateTime.now())); outputFilename = normalizeFilenameForOS(outputFilename); File outputFile = new File(outputFilename);