http://jira.mfd.msk:8088/browse/CLS-25 http://jira.mfd.msk:8088/browse/CLS-26 рефакторинг коллекторов
This commit is contained in:
parent
2c5dbe9143
commit
6a3433c26f
5 changed files with 102 additions and 22 deletions
|
|
@ -7,6 +7,7 @@ import ru.spcex.clearing.reports.reports.AbstractReport;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -38,6 +39,7 @@ public abstract class ReportDataCollector<T extends AbstractReport, R> {
|
||||||
* @param dateTimeNow LocalDateTime.now()
|
* @param dateTimeNow LocalDateTime.now()
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
abstract public String getFileName(LocalDate startDate, LocalDate endDate, LocalDateTime dateTimeNow);
|
abstract public String getFileName(LocalDate startDate, LocalDate endDate, LocalDateTime dateTimeNow);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -48,6 +50,6 @@ public abstract class ReportDataCollector<T extends AbstractReport, R> {
|
||||||
|
|
||||||
protected String toString(Instant val) {
|
protected String toString(Instant val) {
|
||||||
if (val == null) return null;
|
if (val == null) return null;
|
||||||
return DATE_TIME_FORMATTER.format(val);//todo проверить работает ли - юниттест.
|
return DATE_TIME_FORMATTER.format(val.atZone(ZoneId.systemDefault()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,18 @@ public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1
|
||||||
listingImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Listing, Listing.class);
|
listingImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Listing, Listing.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param onMarket Market.mkrs.getKey()
|
||||||
|
* @param securityId liability.getSecurityId()
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected Listing findListing(Market onMarket, Long securityId) {
|
||||||
|
Map qParam = new HashMap<>();
|
||||||
|
qParam.put("market", onMarket.getKey());
|
||||||
|
qParam.put("securityId", securityId);
|
||||||
|
return listingImdg.getSingleObjectByFieldValues(qParam);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ReportBR_0420315_P1> collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
public List<ReportBR_0420315_P1> collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||||
if (startDate.isAfter(endDate)) {
|
if (startDate.isAfter(endDate)) {
|
||||||
|
|
@ -67,33 +79,20 @@ public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1
|
||||||
Company company = companyImdg.getSingleObjectByID(companyId);
|
Company company = companyImdg.getSingleObjectByID(companyId);
|
||||||
if (company != null) {
|
if (company != null) {
|
||||||
ClearingMemberCategory cmc = clearingMemberCategoryImdg.getSingleObjectByFieldValues(Map.of("companyId", companyId));
|
ClearingMemberCategory cmc = clearingMemberCategoryImdg.getSingleObjectByFieldValues(Map.of("companyId", companyId));
|
||||||
String checkCategory = cmc == null? null : cmc.getClearingMemberCategory();
|
String checkCategory = cmc == null ? null : cmc.getClearingMemberCategory();
|
||||||
if (!ALLOW_CLEARING_MEMBER_CATEGORY.contains(cmc.getClearingMemberCategory())) {
|
if (!ALLOW_CLEARING_MEMBER_CATEGORY.contains(checkCategory)) {
|
||||||
// фильтруются <> I, V
|
// фильтруются <> I, V
|
||||||
log.trace("Filtered ClearingMemberCategory[{}].ClearingMemberCategory={}",
|
log.trace("Filtered ClearingMemberCategory[{}].ClearingMemberCategory={}",
|
||||||
cmc == null ? null : cmc.getId(), cmc == null ? null : cmc.getClearingMemberCategory());
|
cmc == null ? null : cmc.getId(), checkCategory);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// ClearingStatusDictionary clearingStatus = clearingStatusDictionaryImdg.getSingleObjectByID(liability.getClearingStatus());
|
|
||||||
// if (clearingStatus == null || !ALLOW_CLEARING_STATUS.contains(clearingStatus.getCode())) {
|
|
||||||
// // фильтруются <> "OK" уже была, never
|
|
||||||
// log.warn("Found after filter LiabilitiesClaimsAssets[{}].getClearingStatus={}", liability.getId(), liability.getClearingStatus());
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
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",
|
||||||
cmc.getClearingMemberCategory(),
|
cmc.getClearingMemberCategory(),
|
||||||
ALLOW_CLEARING_STATUS //clearingStatus.getCode() "OK"
|
ALLOW_CLEARING_STATUS //clearingStatus.getCode() "OK"
|
||||||
);
|
);
|
||||||
|
|
||||||
Listing listing;
|
Listing listing = findListing(Market.mkrs, liability.getSecurityId());
|
||||||
{
|
|
||||||
Map qParam = new HashMap<>();
|
|
||||||
qParam.put("market", Market.MKRS.getKey());
|
|
||||||
qParam.put("securityId", liability.getSecurityId());
|
|
||||||
listing = listingImdg.getSingleObjectByFieldValues(qParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
List<LiabilitiesClaimsAssets> allContract = indexByCompany.get(companyId);
|
List<LiabilitiesClaimsAssets> allContract = indexByCompany.get(companyId);
|
||||||
long contractorQty;
|
long contractorQty;
|
||||||
|
|
@ -101,7 +100,7 @@ public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1
|
||||||
{
|
{
|
||||||
HashSet<String> collectedToSumm = new HashSet<>(); // чтобы дважды не посчитать 1 и тот же контракт
|
HashSet<String> collectedToSumm = new HashSet<>(); // чтобы дважды не посчитать 1 и тот же контракт
|
||||||
for (LiabilitiesClaimsAssets lContract : allContract) {
|
for (LiabilitiesClaimsAssets lContract : allContract) {
|
||||||
if (lContract.getPrice()!=null && StringUtils.isNotEmpty(lContract.getContract())
|
if (lContract.getPrice() != null && StringUtils.isNotEmpty(lContract.getContract())
|
||||||
&& !collectedToSumm.contains(lContract.getContract())) {
|
&& !collectedToSumm.contains(lContract.getContract())) {
|
||||||
collectedToSumm.add(lContract.getContract());
|
collectedToSumm.add(lContract.getContract());
|
||||||
liabilitiesAmount += lContract.getLiabilitiesQuantity().doubleValue();
|
liabilitiesAmount += lContract.getLiabilitiesQuantity().doubleValue();
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||||
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_2.ReportBR_0420317;
|
||||||
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;
|
||||||
|
|
||||||
|
|
@ -47,13 +48,13 @@ public class Bt17_2_collector extends ReportDataCollector<ReportBR_0420317, Repo
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CompanySymbols companySymbol = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
|
CompanySymbols companySymbol = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
|
||||||
"companySymbol", "INN",//todo use enum, todo ИНН или TIN участника клиринга
|
"companySymbol", DocumentTypes.inn.getKey(),// ИНН или TIN участника клиринга
|
||||||
"companyId", company.getId()
|
"companyId", company.getId()
|
||||||
));
|
));
|
||||||
ReportBR_0420317.Info_0420317 info_0420317 = new ReportBR_0420317.Info_0420317(
|
ReportBR_0420317.Info_0420317 info_0420317 = new ReportBR_0420317.Info_0420317(
|
||||||
company.getClearingCode(),
|
company.getClearingCode(),
|
||||||
toString(relation.getSupplierId()),
|
toString(relation.getSupplierId()),
|
||||||
relation.getService(), // todo "relationServiceId",
|
relation.getService(),
|
||||||
relation.getServiceStatus(),
|
relation.getServiceStatus(),
|
||||||
toString(relation.getUpdated()),
|
toString(relation.getUpdated()),
|
||||||
company.getFullName(),
|
company.getFullName(),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package ru.spcex.clearing.reports.services;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class ReportDataCollectorTest extends ReportDataCollector {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testToString() {
|
||||||
|
ReportDataCollectorTest instance = new ReportDataCollectorTest();
|
||||||
|
assertEquals(null, instance.toString((Long)null));
|
||||||
|
assertEquals("1", instance.toString((Long)1L));
|
||||||
|
assertEquals("1230", instance.toString((Long)1230L));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testToString1() {
|
||||||
|
ReportDataCollectorTest instance = new ReportDataCollectorTest();
|
||||||
|
assertEquals(null, instance.toString((Instant)null));
|
||||||
|
Instant val = Instant.ofEpochMilli(1672058774338L);
|
||||||
|
assertEquals("26.12.2022T15:46:14", instance.toString(val)); // msk timezone
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||||
|
throw new IllegalStateException("test");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFileName(LocalDate startDate, LocalDate endDate, LocalDateTime dateTimeNow) {
|
||||||
|
throw new IllegalStateException("test");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package ru.spcex.platform.enumeration;
|
||||||
|
|
||||||
|
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOCUMENT_TYPE_DICTIONARY
|
||||||
|
*/
|
||||||
|
public enum DocumentTypes implements IEnumKey {
|
||||||
|
pasp("PASP"), // Паспорт
|
||||||
|
icrt("ICRT"), // Удостоверение личности
|
||||||
|
prxy("PRXY"), // Доверенность
|
||||||
|
cntr("CNTR"), // Договор клиринга
|
||||||
|
regs("REGS"), // Регистрация
|
||||||
|
form("FORM"), // Анкета участника
|
||||||
|
ogrn("OGRN"), // ОГРН
|
||||||
|
licb("LICB"), // Банковская лицензия
|
||||||
|
licp("LICP"), // Лицензия проф. участника
|
||||||
|
plac("PLAC"), // Регистрация по месту пребывания
|
||||||
|
inn("INN"), // ИНН
|
||||||
|
cio("CIO"), // КИО
|
||||||
|
licr("LICR"), // Брокерская лицензия
|
||||||
|
fin("FIN"), // Финансовая отчетность
|
||||||
|
trst("TRST"), // Полномочия должностных лиц
|
||||||
|
pmkr("PMKR"), // Распоряжение на списание МКР
|
||||||
|
taut("TAUT"), // Допуск к торгам
|
||||||
|
edoc("EDOC"), // Договор об электронном взаимодействии
|
||||||
|
xcnt("XCNT"); // Документ о расторжении Договора клиринга
|
||||||
|
|
||||||
|
private final String key;
|
||||||
|
|
||||||
|
DocumentTypes(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue