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 {
|
public class MarketCodesBySessionConfig {
|
||||||
|
|
||||||
@Bean(name = "marketCodesForBn")
|
@Bean(name = "marketCodesForBn")
|
||||||
public List<String> marketCodesForBn(ImdgProvider imdgProvider) {
|
public Supplier<List<String>> marketCodesForBn(ImdgProvider imdgProvider) {
|
||||||
// Imdg<Market> marketImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Market, Market.class);
|
return new MarketCodesProvider(imdgProvider, Section.FOND, MarketType.PRMR);
|
||||||
// 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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "marketCodesForT0")
|
@Bean(name = "marketCodesForT0")
|
||||||
public Supplier<List<String>> marketCodesForT0(ImdgProvider imdgProvider) {
|
public Supplier<List<String>> marketCodesForT0(ImdgProvider imdgProvider) {
|
||||||
final Object lock = new Object();
|
return new MarketCodesProvider(imdgProvider, Section.FOND, MarketType.SCND);
|
||||||
return new Supplier<>() {
|
}
|
||||||
private volatile List<String> codes;
|
|
||||||
@Override
|
private static class MarketCodesProvider implements Supplier<List<String>> {
|
||||||
public List<String> get() {
|
private volatile List<String> codes;
|
||||||
if (codes == null) {
|
private final Object lock = new Object();
|
||||||
synchronized (lock) {
|
private final ImdgProvider imdgProvider;
|
||||||
if (codes == null) {
|
private final Section section;
|
||||||
imdgProvider.waitAvailable();
|
private final MarketType marketType;
|
||||||
Imdg<Market> marketImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Market, Market.class);
|
|
||||||
Collection<Market> markets = marketImdg.getCollectionObjectsByFieldValues(Map.of(
|
public MarketCodesProvider(ImdgProvider imdgProvider, Section section, MarketType marketType) {
|
||||||
"section", Section.FOND.getKey(),
|
this.imdgProvider = imdgProvider;
|
||||||
"marketType", MarketType.SCND.getKey()));
|
this.section = section;
|
||||||
codes = markets.stream().map(Market::getCode).distinct().collect(Collectors.toList());
|
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.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PrimaryAuctionBnSession extends AbstractSession implements InitializingBean {
|
public class PrimaryAuctionBnSession extends AbstractSession implements InitializingBean {
|
||||||
|
|
@ -41,7 +42,7 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
||||||
private final EndStageNotification endStageNotification;
|
private final EndStageNotification endStageNotification;
|
||||||
|
|
||||||
private final Imdg<ExecutionFond> executionFondImdg;
|
private final Imdg<ExecutionFond> executionFondImdg;
|
||||||
private final List<String> marketCodes;
|
private final Supplier<List<String>> marketCodes;
|
||||||
|
|
||||||
|
|
||||||
public PrimaryAuctionBnSession(
|
public PrimaryAuctionBnSession(
|
||||||
|
|
@ -58,7 +59,7 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
||||||
EndStageNotification endStageNotification,
|
EndStageNotification endStageNotification,
|
||||||
IMessageResolver messageResolver,
|
IMessageResolver messageResolver,
|
||||||
InspectionObligations inspectionObligations,
|
InspectionObligations inspectionObligations,
|
||||||
@Qualifier("marketCodesForBn") List<String> marketCodes) {
|
@Qualifier("marketCodesForBn") Supplier<List<String>> marketCodes) {
|
||||||
super(imdgProvider, messageResolver);
|
super(imdgProvider, messageResolver);
|
||||||
this.balanceRevise = balanceRevise;
|
this.balanceRevise = balanceRevise;
|
||||||
this.dealsPrepare = dealsPrepare;
|
this.dealsPrepare = dealsPrepare;
|
||||||
|
|
@ -80,7 +81,7 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
||||||
dealsPrepare.searchForExecutions(ExecutionType.ExecutionFond);
|
dealsPrepare.searchForExecutions(ExecutionType.ExecutionFond);
|
||||||
ImdgPredicateBuilder execFondPb = executionFondImdg.predicateBuilder();
|
ImdgPredicateBuilder execFondPb = executionFondImdg.predicateBuilder();
|
||||||
dealsPrepare.addExecutionFondCondition(execFondPb.regex("settlementCode", "^B\\d{2}$"));
|
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) {
|
public void runSession(BaseRequest<?> req) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue