registry-service http://jira.mfd.msk:8088/browse/CLS-788 заполнение ТКР для ЛКЦ

This commit is contained in:
AKurakin 2024-10-31 17:58:39 +03:00
parent bf63c85837
commit 492e2bef95

View file

@ -24,6 +24,8 @@ import static ru.spcex.clearing.registry.reports.ReportUtils.getLocalDateFromSql
@Component
public class ExecutionCurrencyLoader extends IDBLoader<ExecutionCurrency> {
static final Long COMPANY_LKC_ID = 5L;
public ExecutionCurrencyLoader(AProperties properties, NamedParameterJdbcTemplate clearingJdbc) {
super(properties.getPeriod(), clearingJdbc);
}
@ -48,6 +50,7 @@ public class ExecutionCurrencyLoader extends IDBLoader<ExecutionCurrency> {
}
Map<Long, TradingClearingRegistry> tradingClearingRegistryById = new HashMap<>();
TradingClearingRegistry tcrForCompanyLKC = null;
{
Set<Long> tkrIds = executionCurrencys.stream()
.filter(eDep -> eDep.getPartyTradingClearingRegistry() == null) // оптимизация;
@ -70,6 +73,22 @@ public class ExecutionCurrencyLoader extends IDBLoader<ExecutionCurrency> {
tradingClearingRegistryById.put(tkr.getId(), tkr);
}
}
{
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
parameterSource.addValue("ids", COMPANY_LKC_ID);
List<TradingClearingRegistry> tradingClearingRegistries = clearingJdbc.query(
"select ID, CODE from TRADING_CLEARING_REGISTRY where COMPANY_ID = :ids",
parameterSource, new TradingClearingRegistryRowMapper()
);
for (TradingClearingRegistry tcr5 : tradingClearingRegistries) {
if (tcrForCompanyLKC != null)
log.warn("Has many TCR for company {}: another {}", COMPANY_LKC_ID, tcrForCompanyLKC.getCode());
tcrForCompanyLKC = tcr5;
}
if (tcrForCompanyLKC == null) {
log.warn("TCR for companyId={} not found", COMPANY_LKC_ID);
}
}
}
Map<Long, List<CompanySymbols>> companySymbolsForCompanyIdMap;
@ -153,16 +172,28 @@ public class ExecutionCurrencyLoader extends IDBLoader<ExecutionCurrency> {
}
}
executionCurrency.setBuyerTkrCode(getTCRCodeFromValueOrById(
if (COMPANY_LKC_ID.equals(executionCurrency.getCounterPartyId())) { // 800 ЛЦК 5
if (tcrForCompanyLKC != null) {
executionCurrency.setBuyerTkrCode(tcrForCompanyLKC.getCode());
}
} else {
executionCurrency.setBuyerTkrCode(getTCRCodeFromValueOrById(
executionCurrency.getCounterPartyTradingClearingRegistry(), // В execution Currency они заполнены
executionCurrency.getCounterPartyTradingClearingRegistryId(),
tradingClearingRegistryById
));
executionCurrency.setSellerTkrCode(getTCRCodeFromValueOrById(
executionCurrency.getPartyTradingClearingRegistry(), // В execution Currency они заполнены
executionCurrency.getTradingClearingRegistryId(),
tradingClearingRegistryById
));
));
}
if (COMPANY_LKC_ID.equals(executionCurrency.getCompanyId())) { // 800 ЛЦК 5
if (tcrForCompanyLKC != null) {
executionCurrency.setSellerTkrCode(tcrForCompanyLKC.getCode());
}
} else {
executionCurrency.setSellerTkrCode(getTCRCodeFromValueOrById(
executionCurrency.getPartyTradingClearingRegistry(), // В execution Currency они заполнены
executionCurrency.getTradingClearingRegistryId(),
tradingClearingRegistryById
));
}
} else if (MoneyFlowSide.BUY.equalsByKey(side) || Side.BUY.equalsByKey(side)) {
if (companyByCompanyId != null) {
executionCurrency.setBuyer(companyByCompanyId.getShortName());
@ -184,16 +215,28 @@ public class ExecutionCurrencyLoader extends IDBLoader<ExecutionCurrency> {
executionCurrency.setSellerCode(companySymbols.getCompanySymbolValue());
}
}
executionCurrency.setBuyerTkrCode(getTCRCodeFromValueOrById(
executionCurrency.getPartyTradingClearingRegistry(), // В execution Currency они заполнены
executionCurrency.getTradingClearingRegistryId(),
tradingClearingRegistryById
));
executionCurrency.setSellerTkrCode(getTCRCodeFromValueOrById(
executionCurrency.getCounterPartyTradingClearingRegistry(), // В execution Currency они заполнены
executionCurrency.getCounterPartyTradingClearingRegistryId(),
tradingClearingRegistryById
));
if (COMPANY_LKC_ID.equals(executionCurrency.getCompanyId())) { // 800 ЛЦК 5
if (tcrForCompanyLKC != null) {
executionCurrency.setBuyerTkrCode(tcrForCompanyLKC.getCode());
}
} else {
executionCurrency.setBuyerTkrCode(getTCRCodeFromValueOrById(
executionCurrency.getPartyTradingClearingRegistry(), // В execution Currency они заполнены
executionCurrency.getTradingClearingRegistryId(),
tradingClearingRegistryById
));
}
if (COMPANY_LKC_ID.equals(executionCurrency.getCounterPartyId())) { // 800 ЛЦК 5
if (tcrForCompanyLKC != null) {
executionCurrency.setSellerTkrCode(tcrForCompanyLKC.getCode());
}
} else {
executionCurrency.setSellerTkrCode(getTCRCodeFromValueOrById(
executionCurrency.getCounterPartyTradingClearingRegistry(), // В execution Currency они заполнены
executionCurrency.getCounterPartyTradingClearingRegistryId(),
tradingClearingRegistryById
));
}
} else {
log.warn("Unknown executionCurrency[{}].side={}", executionCurrency.getId(), executionCurrency.getSide());
}