добавил условие на market на выборку регистри

This commit is contained in:
etreschenkov 2025-06-24 11:13:07 +03:00
parent 4efb263362
commit c6b644d118
3 changed files with 28 additions and 13 deletions

View file

@ -17,7 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import ru.clearing.classes.statics.data.registry.Registry; import ru.clearing.classes.statics.data.registry.Registry;
import ru.spcex.clearing.component.GroupRgsKey;
import ru.spcex.clearing.error.ClearingError; import ru.spcex.clearing.error.ClearingError;
import ru.spcex.clearing.error.RgsError; import ru.spcex.clearing.error.RgsError;
import ru.spcex.clearing.imdg.IMDGDistributedNames; import ru.spcex.clearing.imdg.IMDGDistributedNames;
@ -348,8 +350,8 @@ public class InspectionObligations implements ISessionStage {
private Collection<Registry> getRefundDateRgsIfPresent(List<Registry> registries) { private Collection<Registry> getRefundDateRgsIfPresent(List<Registry> registries) {
if (registries.stream().anyMatch(rgs -> rgs.getRefundDate() != null) && !SessionType.MEDM.equals(sessionType)) { if (registries.stream().anyMatch(rgs -> rgs.getRefundDate() != null) && !SessionType.MEDM.equals(sessionType)) {
Optional<Pair<Long, LocalDate>> groupIdAndSettleDate = registries.stream() Optional<Pair<GroupRgsKey, LocalDate>> groupIdAndSettleDate = registries.stream()
.map(rgs -> new Pair<>(rgs.getGroupId(), rgs.getSettlementDate())) .map(rgs -> new Pair<>(new GroupRgsKey(rgs.getGroupId(),rgs.getMarket()), rgs.getSettlementDate()))
.filter(pair -> pair.getFirst() != null) .filter(pair -> pair.getFirst() != null)
.filter(pair -> pair.getSecond() != null) .filter(pair -> pair.getSecond() != null)
.findFirst(); .findFirst();
@ -359,8 +361,12 @@ public class InspectionObligations implements ISessionStage {
ImdgPredicateBuilder pb = registryImdg.predicateBuilder(); ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
return registryImdg.getCollectionObjectsByPredicate( return registryImdg.getCollectionObjectsByPredicate(
pb.and( pb.and(
pb.equals("groupId", groupIdAndSettleDate.get().getFirst()), pb.and(
pb.not(pb.equals("settlementDate", groupIdAndSettleDate.get().getSecond())) pb.equals("groupId", groupIdAndSettleDate.get().getFirst().groupId()),
StringUtils.hasText(groupIdAndSettleDate.get().getFirst().market()) ?
pb.equals("market", groupIdAndSettleDate.get().getFirst().market()) : pb.alwaysTrue()
),
pb.not(pb.equals("settlementDate", groupIdAndSettleDate.get().getSecond()))
) )
); );
} else return Collections.emptyList(); } else return Collections.emptyList();

View file

@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import ru.clearing.classes.statics.data.registry.Registry; import ru.clearing.classes.statics.data.registry.Registry;
import ru.spcex.clearing.component.GroupRgsKey; import ru.spcex.clearing.component.GroupRgsKey;
import ru.spcex.clearing.component.predicate.cash.registry.AssetByTcrCompanyAccountCashedPredicate; import ru.spcex.clearing.component.predicate.cash.registry.AssetByTcrCompanyAccountCashedPredicate;
@ -347,8 +348,8 @@ public class InspectionObligationsV2 implements ISessionStage {
private Collection<Registry> getRefundDateRgsIfPresent(List<Registry> registries) { private Collection<Registry> getRefundDateRgsIfPresent(List<Registry> registries) {
if (registries.stream().anyMatch(rgs -> rgs.getRefundDate() != null) && !SessionType.MEDM.equals(sessionType)) { if (registries.stream().anyMatch(rgs -> rgs.getRefundDate() != null) && !SessionType.MEDM.equals(sessionType)) {
//доп группировка по market не нужна, лист registries уже сгруппирован //доп группировка по market не нужна, лист registries уже сгруппирован
Optional<Pair<Long, LocalDate>> groupIdAndSettleDate = registries.stream() Optional<Pair<GroupRgsKey, LocalDate>> groupIdAndSettleDate = registries.stream()
.map(rgs -> new Pair<>(rgs.getGroupId(), rgs.getSettlementDate())) .map(rgs -> new Pair<>(new GroupRgsKey(rgs.getGroupId(),rgs.getMarket()), rgs.getSettlementDate()))
.filter(pair -> pair.getFirst() != null) .filter(pair -> pair.getFirst() != null)
.filter(pair -> pair.getSecond() != null) .filter(pair -> pair.getSecond() != null)
.findFirst(); .findFirst();
@ -357,10 +358,14 @@ public class InspectionObligationsV2 implements ISessionStage {
} }
ImdgPredicateBuilder pb = registryImdg.predicateBuilder(); ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
return registryImdg.getCollectionObjectsByPredicate( return registryImdg.getCollectionObjectsByPredicate(
pb.and(
pb.and( pb.and(
pb.equals("groupId", groupIdAndSettleDate.get().getFirst()), pb.equals("groupId", groupIdAndSettleDate.get().getFirst().groupId()),
pb.not(pb.equals("settlementDate", groupIdAndSettleDate.get().getSecond())) StringUtils.hasText(groupIdAndSettleDate.get().getFirst().market()) ?
) pb.equals("market", groupIdAndSettleDate.get().getFirst().market()) : pb.alwaysTrue()
),
pb.not(pb.equals("settlementDate", groupIdAndSettleDate.get().getSecond()))
)
); );
} else return Collections.emptyList(); } else return Collections.emptyList();
} }

View file

@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import ru.clearing.classes.statics.data.account.Account; import ru.clearing.classes.statics.data.account.Account;
import ru.clearing.classes.statics.data.account.ClearingAccount; import ru.clearing.classes.statics.data.account.ClearingAccount;
import ru.clearing.classes.statics.data.account.DepoAccount; import ru.clearing.classes.statics.data.account.DepoAccount;
@ -363,7 +364,8 @@ public class RequirementsAndObligationCreation implements ISessionStage {
exec.getCompanyId(), exec.getCompanyId(),
settlementDt(exec), settlementDt(exec),
exec.getSessionId(), exec.getSessionId(),
exec.getExchangeExecutionId() exec.getExchangeExecutionId(),
exec.getMarket()
); );
} }
@ -396,11 +398,12 @@ public class RequirementsAndObligationCreation implements ISessionStage {
exec.getCompanyId(), exec.getCompanyId(),
((ExecutionDeposit) exec).getSecondLegSettlementDate(), ((ExecutionDeposit) exec).getSecondLegSettlementDate(),
exec.getSessionId(), exec.getSessionId(),
exec.getExchangeExecutionId()); exec.getExchangeExecutionId(),
exec.getMarket());
} }
public Optional<Registry> imdgRegSearch(RegistryTradingParams p, Long tcrId, Long companyId, LocalDate settlementDt, public Optional<Registry> imdgRegSearch(RegistryTradingParams p, Long tcrId, Long companyId, LocalDate settlementDt,
Long sessionId, Long exchangeExecutionId) { Long sessionId, Long exchangeExecutionId, String market) {
String sql = RegistryCodeSqlBuilder.getInstance(p).build(); String sql = RegistryCodeSqlBuilder.getInstance(p).build();
ImdgPredicateBuilder pb = registryImdg.predicateBuilder(); ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
ImdgPredicate rgstrPredicate = pb.and(pb.sql(sql), ImdgPredicate rgstrPredicate = pb.and(pb.sql(sql),
@ -408,7 +411,8 @@ public class RequirementsAndObligationCreation implements ISessionStage {
pb.equals("companyId", companyId), pb.equals("companyId", companyId),
pb.equals("settlementDate", settlementDt), pb.equals("settlementDate", settlementDt),
pb.equals("sessionId", sessionId), pb.equals("sessionId", sessionId),
pb.equals("groupId", exchangeExecutionId) pb.equals("groupId", exchangeExecutionId),
StringUtils.hasText(market) ? pb.equals("market", market) : pb.alwaysTrue()
); );
Registry rgs = registryImdg.getSingleObjectByPredicate(rgstrPredicate); Registry rgs = registryImdg.getSingleObjectByPredicate(rgstrPredicate);
log.trace("rgs.id={} found by: {}", rgs == null ? "'not found'" : rgs.getId(), rgstrPredicate.toString()); log.trace("rgs.id={} found by: {}", rgs == null ? "'not found'" : rgs.getId(), rgstrPredicate.toString());