marketCodesForBn
This commit is contained in:
parent
ecbb5d1ed9
commit
d51cbf809a
2 changed files with 35 additions and 29 deletions
|
|
@ -19,38 +19,43 @@ import java.util.stream.Collectors;
|
|||
public class MarketCodesBySessionConfig {
|
||||
|
||||
@Bean(name = "marketCodesForBn")
|
||||
public List<String> marketCodesForBn(ImdgProvider imdgProvider) {
|
||||
// Imdg<Market> marketImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Market, Market.class);
|
||||
// Collection<Market> markets = marketImdg.getCollectionObjectsByFieldValues(Map.of(
|
||||
// "section", Section.FOND.getKey(),
|
||||
// "marketType", MarketType.PRMR.getKey()));
|
||||
// return markets.stream().map(Market::getCode).distinct().collect(Collectors.toList());
|
||||
return List.of("BMFC", "SMMC", "AEPC", "WBIC", "KBVC", "WBFC", "BMVC", "ABIC",
|
||||
"AESC", "ABFC", "KBIC", "WBMC", "BMMC", "ABEC", "SMIC", "ABMC", "SMVC", "KBFC", "SKVC", "ABVC", "WEPC",
|
||||
"KBMC", "SMFC", "BKVC", "WBVC", "BMIC", "WESC");
|
||||
public Supplier<List<String>> marketCodesForBn(ImdgProvider imdgProvider) {
|
||||
return new MarketCodesProvider(imdgProvider, Section.FOND, MarketType.PRMR);
|
||||
}
|
||||
|
||||
@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 new MarketCodesProvider(imdgProvider, Section.FOND, MarketType.SCND);
|
||||
}
|
||||
|
||||
private static class MarketCodesProvider implements Supplier<List<String>> {
|
||||
private volatile List<String> codes;
|
||||
private final Object lock = new Object();
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final Section section;
|
||||
private final MarketType marketType;
|
||||
|
||||
public MarketCodesProvider(ImdgProvider imdgProvider, Section section, MarketType marketType) {
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.section = section;
|
||||
this.marketType = marketType;
|
||||
}
|
||||
|
||||
@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.getKey(),
|
||||
"marketType", marketType.getKey()));
|
||||
codes = markets.stream().map(Market::getCode).distinct().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return codes;
|
||||
}
|
||||
};
|
||||
return codes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
|||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Service
|
||||
public class PrimaryAuctionBnSession extends AbstractSession implements InitializingBean {
|
||||
|
|
@ -41,7 +42,7 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
|||
private final EndStageNotification endStageNotification;
|
||||
|
||||
private final Imdg<ExecutionFond> executionFondImdg;
|
||||
private final List<String> marketCodes;
|
||||
private final Supplier<List<String>> marketCodes;
|
||||
|
||||
|
||||
public PrimaryAuctionBnSession(
|
||||
|
|
@ -58,7 +59,7 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
|||
EndStageNotification endStageNotification,
|
||||
IMessageResolver messageResolver,
|
||||
InspectionObligations inspectionObligations,
|
||||
@Qualifier("marketCodesForBn") List<String> marketCodes) {
|
||||
@Qualifier("marketCodesForBn") Supplier<List<String>> marketCodes) {
|
||||
super(imdgProvider, messageResolver);
|
||||
this.balanceRevise = balanceRevise;
|
||||
this.dealsPrepare = dealsPrepare;
|
||||
|
|
@ -80,7 +81,7 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
|||
dealsPrepare.searchForExecutions(ExecutionType.ExecutionFond);
|
||||
ImdgPredicateBuilder execFondPb = executionFondImdg.predicateBuilder();
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.regex("settlementCode", "^B\\d{2}$"));
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.in("market", marketCodes.toArray(new String[0])));
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.in("market", marketCodes.get().toArray(new String[0])));
|
||||
}
|
||||
|
||||
public void runSession(BaseRequest<?> req) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue