reports-service ReportId добавил в ключи соответствие частям имён файлов, т.к. говорили, что с фронта будут по имени файла приходить (рекомендовали так, необходимо согласовать с frontend-api).

This commit is contained in:
AKurakin 2023-01-09 16:03:18 +03:00
parent fa5d6fbcc6
commit 0b27f29865
3 changed files with 39 additions and 14 deletions

View file

@ -1,24 +1,38 @@
package ru.spcex.clearing.reports.reports;
import ru.spcex.platform.utils.enumeration.IEnumKey;
/**
* Идентификаторы отчётов
*/
public enum ReportId {//todo переименовать в соответствии с именами файлов ()
PA_BT2_B, PA_BT2_IV,
public enum ReportId implements IEnumKey {
PA_BT2_B("REPPA.BT12.2.B"), PA_BT2_IV("REPPA.BT12.2.IV"),
BT13_11, BT13_12,
BT13_11("DOCIN"), BT13_12("DOCOUT"),
BT16_5,
BT16_5("INACCNT"),
BR_0420315_P1, BR_0420315_P2,
BR_0420315_P1("REPBR.0420315.P1"), BR_0420315_P2("REPBR.0420315.P2"),
BR_0420317,
BR_0420317("REPBR.0420317"),
BR_0420318,
BR_0420318("REPBR.0420318"),
BR_0420314_P1, BR_0420314_P2,
BR_0420314_P1("REPBR.0420314.P1"), BR_0420314_P2("REPBR.0420314.P2"),
BR_0420312_P1, BR_0420312_P2, BR_0420312_P3, BR_0420312_P4,
BR_0420312_P5, BR_0420312_P6, BR_0420312_P7, BR_0420312_P8,
BR_0420312_P9, BR_0420312_P10,
BR_0420312_P1("REPBR.0420312_р1-1"), BR_0420312_P2("REPBR.0420312_р1-2"), BR_0420312_P3("REPBR.0420312_р1-3"), BR_0420312_P4("REPBR.0420312_р1-4"),
BR_0420312_P5("REPBR.0420312_р1-5"), BR_0420312_P6("REPBR.0420312_р1-6"), BR_0420312_P7("REPBR.0420312_р1-7"), BR_0420312_P8("REPBR.0420312_р3-1"),
BR_0420312_P9("REPBR.0420312_р3-2"), BR_0420312_P10("REPBR.0420312_р3-3");
private final String key;
ReportId(String key) {
this.key = key;
}
@Override
public String getKey() {
return key;
}
}

View file

@ -91,7 +91,7 @@ public class ReportBR_0420312_P8 extends ReportWithPeriod {
@Override
public String getReportName(LocalDateTime reportDateTime) {
return " REPBR.0420312_р3-1.%s-%s.%s".formatted(
return "REPBR.0420312_р3-1.%s-%s.%s".formatted(
DATE_FORMATTER.format(startDate),
DATE_FORMATTER.format(endDate),
DATE_TIME_FORMATTER.format(reportDateTime)

View file

@ -1,5 +1,6 @@
package ru.spcex.clearing.reports.services;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -13,6 +14,7 @@ import ru.spcex.clearing.reports.reports.ReportId;
import ru.spcex.clearing.reports.services.builders.XMLReportBuilder;
import ru.spcex.platform.enumeration.Task;
import ru.spcex.platform.imdg.api.ImdgProvider;
import ru.spcex.platform.utils.enumeration.IEnumKey;
import ru.spcex.platform.utils.log.ExceptionUtils;
import java.io.File;
@ -52,14 +54,23 @@ public class QCommandExecutor extends QueueConsumer implements InitializingBean
.forDestination(Task.createReport.topic(), callbacks::put);
}
ReportId parseReportId(String reportStr) {
ReportId id = IEnumKey.getEnumByKey(ReportId.class, reportStr);
if (id == null) {
log.trace("");
id = ReportId.valueOf(reportStr);
}
return id;
}
private void newReportWithPeriod(BaseRequest<ReportWithPeriodRequest> reportRequest) {
log.debug("newReportWithPeriod request received");
ReportWithPeriodRequest request = reportRequest.getRequestPayload();
if (request.getReportId() == null || request.getReportId().isBlank())
if (StringUtils.isBlank(request.getReportId()))
throw new IllegalStateException("ReportID is empty");
ReportId reportId = ReportId.valueOf(request.getReportId());
ReportId reportId = parseReportId(request.getReportId());
ReportDataCollector<?> reportDataCollector = collectorForReport.get(reportId);
if (reportDataCollector == null)
throw new IllegalStateException("Collector for ReportID " + reportId + " not implemented yet");