reports-service http://jira.mfd.msk:8088/browse/CLS-29 начало, рефакторинг опять.
This commit is contained in:
parent
af8ff434ec
commit
363a809afc
6 changed files with 79 additions and 39 deletions
|
|
@ -6,6 +6,8 @@ import ru.spcex.clearing.reports.ReportWithPeriod;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@XStreamAlias("clearingCoverage1")
|
@XStreamAlias("clearingCoverage1")
|
||||||
public class ReportBR_0420312_P1 extends ReportWithPeriod {
|
public class ReportBR_0420312_P1 extends ReportWithPeriod {
|
||||||
|
|
@ -13,9 +15,27 @@ public class ReportBR_0420312_P1 extends ReportWithPeriod {
|
||||||
@XStreamAlias("destination")
|
@XStreamAlias("destination")
|
||||||
private String destination;
|
private String destination;
|
||||||
|
|
||||||
@XStreamAlias("part_1")
|
@XStreamAlias("rows")
|
||||||
private final Info_0420312_P1 part_1;
|
private final List<Info_0420312_P1> rows = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
public ReportBR_0420312_P1(LocalDate startDate,
|
||||||
|
LocalDate endDate,
|
||||||
|
String destination) {
|
||||||
|
super("0.0.1",
|
||||||
|
"0420312",
|
||||||
|
"Сведения о клиринговом обеспечении, часть 1",
|
||||||
|
startDate,
|
||||||
|
endDate);
|
||||||
|
this.destination = destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Info_0420312_P1> getRows() {
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ReportBR_0420312_P1(LocalDate startDate,
|
public ReportBR_0420312_P1(LocalDate startDate,
|
||||||
LocalDate endDate,
|
LocalDate endDate,
|
||||||
String companyClearingCode,
|
String companyClearingCode,
|
||||||
|
|
@ -26,19 +46,14 @@ public class ReportBR_0420312_P1 extends ReportWithPeriod {
|
||||||
String companySymbolValue,
|
String companySymbolValue,
|
||||||
String companyInfoCountryCode,
|
String companyInfoCountryCode,
|
||||||
String clearingMemberCategoryClearingMemberCategory) {
|
String clearingMemberCategoryClearingMemberCategory) {
|
||||||
super("0.0.1",
|
this(startDate, endDate, destination);
|
||||||
"0420312",
|
getRows().add(new Info_0420312_P1(companyClearingCode,
|
||||||
"Сведения о клиринговом обеспечении, часть 1",
|
|
||||||
startDate,
|
|
||||||
endDate);
|
|
||||||
this.destination = destination;
|
|
||||||
part_1 = new Info_0420312_P1(companyClearingCode,
|
|
||||||
liabilitiesClaimsAssetsCompanyId,
|
liabilitiesClaimsAssetsCompanyId,
|
||||||
liabilitiesClaimsAssetsFullName,
|
liabilitiesClaimsAssetsFullName,
|
||||||
companySymbolCode,
|
companySymbolCode,
|
||||||
companySymbolValue,
|
companySymbolValue,
|
||||||
companyInfoCountryCode,
|
companyInfoCountryCode,
|
||||||
clearingMemberCategoryClearingMemberCategory);
|
clearingMemberCategoryClearingMemberCategory));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Info_0420312_P1 {
|
public static class Info_0420312_P1 {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,12 @@ public abstract class ReportDataCollector<T extends AbstractReport> {
|
||||||
|
|
||||||
abstract public Class<T> getReportClass();
|
abstract public Class<T> getReportClass();
|
||||||
|
|
||||||
|
protected void validateDateRange(LocalDate startDate, LocalDate endDate) throws IllegalArgumentException {
|
||||||
|
if (startDate.isAfter(endDate)) {
|
||||||
|
throw new IllegalArgumentException("startDate(" + startDate + ") > endDate(" + endDate + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected String toString(Long val) {
|
protected String toString(Long val) {
|
||||||
if (val == null) return null;
|
if (val == null) return null;
|
||||||
return val.toString();
|
return val.toString();
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,7 @@ public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReportBR_0420315_P1 collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
public ReportBR_0420315_P1 collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||||
if (startDate.isAfter(endDate)) {
|
validateDateRange(startDate, endDate);
|
||||||
throw new IllegalArgumentException("startDate(" + startDate + ") > endDate(" + endDate + ")");
|
|
||||||
}
|
|
||||||
ReportBR_0420315_P1 reportBR_0420315_p1 = new ReportBR_0420315_P1(startDate, endDate,
|
ReportBR_0420315_P1 reportBR_0420315_p1 = new ReportBR_0420315_P1(startDate, endDate,
|
||||||
"BR",
|
"BR",
|
||||||
"I,V", // cmc.getClearingMemberCategory()
|
"I,V", // cmc.getClearingMemberCategory()
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,7 @@ public class Bt17_1_P2_collector extends ReportDataCollector<ReportBR_0420315_P2
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReportBR_0420315_P2 collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
public ReportBR_0420315_P2 collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||||
if (startDate.isAfter(endDate)) {
|
validateDateRange(startDate, endDate);
|
||||||
throw new IllegalArgumentException("startDate(" + startDate + ") > endDate(" + endDate + ")");
|
|
||||||
}
|
|
||||||
String ql = String.format("'%s' <= refundDate and refundDate <= '%s'", startDate, endDate);
|
String ql = String.format("'%s' <= refundDate and refundDate <= '%s'", startDate, endDate);
|
||||||
Collection<LiabilitiesClaimsAssets> liabilities = liabilitiesClaimsAssetsImdg.getCollectionObjectsBySQL(ql);
|
Collection<LiabilitiesClaimsAssets> liabilities = liabilitiesClaimsAssetsImdg.getCollectionObjectsBySQL(ql);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,7 @@ public class Bt17_2_collector extends ReportDataCollector<ReportBR_0420317> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReportBR_0420317 collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
public ReportBR_0420317 collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||||
if (startDate.isAfter(endDate)) {
|
validateDateRange(startDate, endDate);
|
||||||
throw new IllegalArgumentException("startDate(" + startDate + ") > endDate(" + endDate + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
String ql = String.format("'%s' <= updated and updated <= '%s' and service='MKR'", startDate, endDate);
|
String ql = String.format("'%s' <= updated and updated <= '%s' and service='MKR'", startDate, endDate);
|
||||||
// todo обговорить про updatedAt updated, todo enum MKR
|
// todo обговорить про updatedAt updated, todo enum MKR
|
||||||
|
|
|
||||||
|
|
@ -5,52 +5,77 @@ import org.springframework.stereotype.Component;
|
||||||
import ru.clearing.classes.statics.data.company.Company;
|
import ru.clearing.classes.statics.data.company.Company;
|
||||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||||
|
import ru.clearing.classes.statics.data.generated.ClearingMemberCategory;
|
||||||
|
import ru.clearing.classes.transaction.data.execution.LiabilitiesClaimsAssets;
|
||||||
|
import ru.clearing.platform.dictionary.CountryCodeDictionary;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.reports.reports.bt_17_2.ReportBR_0420317;
|
|
||||||
import ru.spcex.clearing.reports.reports.bt_17_5.ReportBR_0420312_P1;
|
import ru.spcex.clearing.reports.reports.bt_17_5.ReportBR_0420312_P1;
|
||||||
import ru.spcex.clearing.reports.services.ReportDataCollector;
|
import ru.spcex.clearing.reports.services.ReportDataCollector;
|
||||||
|
import ru.spcex.platform.enumeration.DocumentTypes;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class Bt17_5_P1_collector extends ReportDataCollector<ReportBR_0420312_P1> {
|
public class Bt17_5_P1_collector extends ReportDataCollector<ReportBR_0420312_P1> {
|
||||||
private Imdg<Company> companyImdg;
|
private Imdg<Company> companyImdg;
|
||||||
private Imdg<Relation> relationImdg;
|
// private Imdg<Relation> relationImdg;
|
||||||
private Imdg<CompanySymbols> companySymbolsImdg;
|
private Imdg<CompanySymbols> companySymbolsImdg;
|
||||||
|
private Imdg<CountryCodeDictionary> countryCodeDictionaryImdg;
|
||||||
|
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||||
|
private Imdg<LiabilitiesClaimsAssets> liabilitiesClaimsAssetsImdg;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public Bt17_5_P1_collector(ImdgProvider imdgProvider) {
|
public Bt17_5_P1_collector(ImdgProvider imdgProvider) {
|
||||||
companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||||
relationImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
|
liabilitiesClaimsAssetsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_LiabilitiesClaimsAssets, LiabilitiesClaimsAssets.class);
|
||||||
|
// relationImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
|
||||||
companySymbolsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
|
companySymbolsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
|
||||||
|
clearingMemberCategoryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
||||||
|
countryCodeDictionaryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CountryCodeDictionary, CountryCodeDictionary.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CompanySymbols findSymbol(DocumentTypes docType, Long companyId) {
|
||||||
|
CompanySymbols companySymbol = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
|
||||||
|
"companySymbol", docType.getKey(),
|
||||||
|
"companyId", companyId
|
||||||
|
));
|
||||||
|
return companySymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReportBR_0420312_P1 collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
public ReportBR_0420312_P1 collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||||
if (startDate.isAfter(endDate)) {
|
validateDateRange(startDate, endDate);
|
||||||
throw new IllegalArgumentException("startDate(" + startDate + ") > endDate(" + endDate + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO ВСЁ по CLS-29...
|
ReportBR_0420312_P1 reportBR_0420312P1 = new ReportBR_0420312_P1(startDate, endDate, "BR");
|
||||||
String ql = String.format("'%s' <= updated and updated <= '%s' and service='MKR'", startDate, endDate);
|
|
||||||
// todo обговорить про updatedAt updated, todo enum MKR
|
// todo обговорить про updatedAt updated, todo enum MKR
|
||||||
Collection<Relation> relations = relationImdg.getCollectionObjectsBySQL(ql);
|
|
||||||
|
|
||||||
ReportBR_0420312_P1 reportBR_0420312P1 = new ReportBR_0420312_P1(LocalDate.now(),
|
String ql = String.format("'%s' <= refundDate and refundDate <= '%s'",
|
||||||
LocalDate.now(),
|
startDate, endDate);
|
||||||
"companyClearingCode",
|
Collection<LiabilitiesClaimsAssets> liabilities = liabilitiesClaimsAssetsImdg.getCollectionObjectsBySQL(ql);
|
||||||
"BR",
|
Map<Long, List<LiabilitiesClaimsAssets>> indexByCompany = MapUtil.indexList(liabilities, LiabilitiesClaimsAssets::getCompanyId);
|
||||||
"liabilitesClaimsAssetsCompanyId",
|
for (Map.Entry<Long, List<LiabilitiesClaimsAssets>> companyEntry : indexByCompany.entrySet()) {
|
||||||
"liabilitesClaimsAssetsFullName",
|
final Long companyId = companyEntry.getKey();
|
||||||
"companySymbolCode",
|
Company company = companyImdg.getSingleObjectByID(companyId);
|
||||||
"companySymbolValue",
|
CompanySymbols companySymbolINN = findSymbol(DocumentTypes.inn, company.getId());
|
||||||
"companyInfoCountryCode",
|
CompanySymbols companySymbolOGRN = findSymbol(DocumentTypes.ogrn, company.getId());
|
||||||
"clearingMemberCategory");
|
ClearingMemberCategory cmc = clearingMemberCategoryImdg.getSingleObjectByFieldValues(Map.of("companyId", companyId));
|
||||||
|
String clearingMemberCategory = cmc == null ? null : cmc.getClearingMemberCategory();
|
||||||
|
ReportBR_0420312_P1.Info_0420312_P1 info_0420312_p1 = new ReportBR_0420312_P1.Info_0420312_P1(
|
||||||
|
company.getClearingCode(),
|
||||||
|
toString(companyId),
|
||||||
|
company.getFullName(),
|
||||||
|
companySymbolINN == null ? null : companySymbolINN.getCompanySymbolValue(),
|
||||||
|
companySymbolOGRN == null ? null : companySymbolOGRN.getCompanySymbolValue(),
|
||||||
|
company.getProfile().getCountryCode(),
|
||||||
|
clearingMemberCategory
|
||||||
|
);
|
||||||
|
reportBR_0420312P1.getRows().add(info_0420312_p1);
|
||||||
|
}
|
||||||
|
|
||||||
return reportBR_0420312P1;
|
return reportBR_0420312P1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue