marketCodesForT0 list
This commit is contained in:
parent
7d971cd054
commit
acd14d0390
1 changed files with 33 additions and 0 deletions
|
|
@ -2,9 +2,18 @@ package ru.spcex.clearing.config;
|
|||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.misc.Market;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.MarketType;
|
||||
import ru.spcex.platform.enumeration.Section;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Configuration
|
||||
public class MarketCodesBySessionConfig {
|
||||
|
|
@ -20,4 +29,28 @@ public class MarketCodesBySessionConfig {
|
|||
"AESC", "ABFC", "KBIC", "WBMC", "BMMC", "ABEC", "SMIC", "ABMC", "SMVC", "KBFC", "SKVC", "ABVC", "WEPC",
|
||||
"KBMC", "SMFC", "BKVC", "WBVC", "BMIC", "WESC");
|
||||
}
|
||||
|
||||
@Bean(name = "marketCodesForT0")
|
||||
public Supplier<List<String>> marketCodesForT0(ImdgProvider imdgProvider) {
|
||||
final Object lock = new Object();
|
||||
return new Supplier<>() {
|
||||
private volatile List<String> codes;
|
||||
@Override
|
||||
public List<String> get() {
|
||||
if (codes == null) {
|
||||
synchronized (lock) {
|
||||
if (codes == null) {
|
||||
imdgProvider.waitAvailable();
|
||||
Imdg<Market> marketImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Market, Market.class);
|
||||
Collection<Market> markets = marketImdg.getCollectionObjectsByFieldValues(Map.of(
|
||||
"section", Section.FOND.getKey(),
|
||||
"marketType", MarketType.SCND.getKey()));
|
||||
codes = markets.stream().map(Market::getCode).distinct().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
return codes;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue