reports-service прикрутил генерацию тестов при запуске
This commit is contained in:
parent
a8f15eff9d
commit
4b5667747a
7 changed files with 54 additions and 3 deletions
|
|
@ -1,18 +1,42 @@
|
|||
package ru.spcex.clearing.reports;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import ru.spcex.clearing.reports.services.ReportDataCollector;
|
||||
import ru.spcex.clearing.reports.services.ReportsService;
|
||||
import ru.spcex.clearing.reports.services.builders.XMLReportBuilder;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Map;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ReportsServiceApplication {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
SpringApplicationBuilder builder = new SpringApplicationBuilder(ReportsServiceApplication.class);
|
||||
builder.run(args);
|
||||
ConfigurableApplicationContext context = builder.run(args);
|
||||
|
||||
//todo это тест. Переписать код:
|
||||
Logger log = LoggerFactory.getLogger(ReportsServiceApplication.class);
|
||||
ImdgProvider imdg = context.getBean(ImdgProvider.class);
|
||||
log.info("Wait IMDG...");
|
||||
imdg.waitAvailable();
|
||||
log.info("Run generate report.");
|
||||
Map<String, ReportDataCollector> allReports = context.getBeansOfType(ReportDataCollector.class);
|
||||
System.out.println(allReports);
|
||||
for (ReportDataCollector collector:allReports.values()) {
|
||||
XMLReportBuilder xmlReportBuilder = new XMLReportBuilder(collector.getReportClass(), collector);
|
||||
LocalDate date2 = LocalDate.now();
|
||||
LocalDate date1 = LocalDate.of(date2.getYear(), date2.getMonth(), 1);//date2.minusMonths(1);
|
||||
xmlReportBuilder.createReport(date1, date2);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LoggerFactory.getLogger(ReportsServiceApplication.class).error("DBF-Loader start failed: {} -> {}", e.getClass().getSimpleName(), e.getMessage());
|
||||
LoggerFactory.getLogger(ReportsServiceApplication.class).error("DBF-Loader start failed: {} -> {}", e.getClass().getSimpleName(), ExceptionUtils.getStackTrace(e));
|
||||
System.exit(-1);
|
||||
}
|
||||
ReportsService reportsService = new ReportsService();
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ public abstract class ReportDataCollector<T extends AbstractReport> {
|
|||
throw new IllegalArgumentException("deprecated");
|
||||
}
|
||||
|
||||
abstract public Class<T> getReportClass();
|
||||
|
||||
protected String toString(Long val) {
|
||||
if (val == null) return null;
|
||||
|
|
|
|||
|
|
@ -135,4 +135,9 @@ public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1
|
|||
return String.format("REPBR.0420315.P1.%s-%s.%s", DATE_FORMATTER.format(startDate), DATE_FORMATTER.format(endDate),
|
||||
DATE_TIME_FORMATTER.format(dateTimeNow));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReportBR_0420315_P1> getReportClass() {
|
||||
return ReportBR_0420315_P1.class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,4 +58,9 @@ public class Bt17_1_P2_collector extends ReportDataCollector<ReportBR_0420315_P2
|
|||
return String.format("REPBR.0420315.P2.%s-%s.%s", DATE_FORMATTER.format(startDate), DATE_FORMATTER.format(endDate),
|
||||
DATE_TIME_FORMATTER.format(dateTimeNow));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReportBR_0420315_P2> getReportClass() {
|
||||
return ReportBR_0420315_P2.class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,4 +74,9 @@ public class Bt17_2_collector extends ReportDataCollector<ReportBR_0420317> {
|
|||
return String.format("REPBR.0420317.%s-%s.%s", DATE_FORMATTER.format(startDate), DATE_FORMATTER.format(endDate),
|
||||
DATE_TIME_FORMATTER.format(dateTimeNow));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReportBR_0420317> getReportClass() {
|
||||
return ReportBR_0420317.class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,4 +61,9 @@ public class Bt17_5_P1_collector extends ReportDataCollector<ReportBR_0420312_P1
|
|||
return String.format("REPBR.0420312_р1-1.%s-%s.%s", DATE_FORMATTER.format(startDate), DATE_FORMATTER.format(endDate),
|
||||
DATE_TIME_FORMATTER.format(dateTimeNow));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReportBR_0420312_P1> getReportClass() {
|
||||
return ReportBR_0420312_P1.class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package ru.spcex.clearing.reports.services;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import ru.spcex.clearing.reports.reports.AbstractReport;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -28,7 +29,7 @@ class ReportDataCollectorTest extends ReportDataCollector {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||
public AbstractReport collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||
throw new IllegalStateException("test");
|
||||
}
|
||||
|
||||
|
|
@ -36,4 +37,9 @@ class ReportDataCollectorTest extends ReportDataCollector {
|
|||
public String getFileName(LocalDate startDate, LocalDate endDate, LocalDateTime dateTimeNow) {
|
||||
throw new IllegalStateException("test");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<AbstractReport> getReportClass() {
|
||||
return AbstractReport.class;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue