добавил условие на 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.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
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.RgsError;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
@ -348,8 +350,8 @@ public class InspectionObligations implements ISessionStage {
private Collection<Registry> getRefundDateRgsIfPresent(List<Registry> registries) {
if (registries.stream().anyMatch(rgs -> rgs.getRefundDate() != null) && !SessionType.MEDM.equals(sessionType)) {
Optional<Pair<Long, LocalDate>> groupIdAndSettleDate = registries.stream()
.map(rgs -> new Pair<>(rgs.getGroupId(), rgs.getSettlementDate()))
Optional<Pair<GroupRgsKey, LocalDate>> groupIdAndSettleDate = registries.stream()
.map(rgs -> new Pair<>(new GroupRgsKey(rgs.getGroupId(),rgs.getMarket()), rgs.getSettlementDate()))
.filter(pair -> pair.getFirst() != null)
.filter(pair -> pair.getSecond() != null)
.findFirst();
@ -359,7 +361,11 @@ public class InspectionObligations implements ISessionStage {
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
return registryImdg.getCollectionObjectsByPredicate(
pb.and(
pb.equals("groupId", groupIdAndSettleDate.get().getFirst()),
pb.and(
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()))
)
);

View file

@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import ru.clearing.classes.statics.data.registry.Registry;
import ru.spcex.clearing.component.GroupRgsKey;
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) {
if (registries.stream().anyMatch(rgs -> rgs.getRefundDate() != null) && !SessionType.MEDM.equals(sessionType)) {
//доп группировка по market не нужна, лист registries уже сгруппирован
Optional<Pair<Long, LocalDate>> groupIdAndSettleDate = registries.stream()
.map(rgs -> new Pair<>(rgs.getGroupId(), rgs.getSettlementDate()))
Optional<Pair<GroupRgsKey, LocalDate>> groupIdAndSettleDate = registries.stream()
.map(rgs -> new Pair<>(new GroupRgsKey(rgs.getGroupId(),rgs.getMarket()), rgs.getSettlementDate()))
.filter(pair -> pair.getFirst() != null)
.filter(pair -> pair.getSecond() != null)
.findFirst();
@ -358,7 +359,11 @@ public class InspectionObligationsV2 implements ISessionStage {
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
return registryImdg.getCollectionObjectsByPredicate(
pb.and(
pb.equals("groupId", groupIdAndSettleDate.get().getFirst()),
pb.and(
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()))
)
);

View file

@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
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.ClearingAccount;
import ru.clearing.classes.statics.data.account.DepoAccount;
@ -363,7 +364,8 @@ public class RequirementsAndObligationCreation implements ISessionStage {
exec.getCompanyId(),
settlementDt(exec),
exec.getSessionId(),
exec.getExchangeExecutionId()
exec.getExchangeExecutionId(),
exec.getMarket()
);
}
@ -396,11 +398,12 @@ public class RequirementsAndObligationCreation implements ISessionStage {
exec.getCompanyId(),
((ExecutionDeposit) exec).getSecondLegSettlementDate(),
exec.getSessionId(),
exec.getExchangeExecutionId());
exec.getExchangeExecutionId(),
exec.getMarket());
}
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();
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
ImdgPredicate rgstrPredicate = pb.and(pb.sql(sql),
@ -408,7 +411,8 @@ public class RequirementsAndObligationCreation implements ISessionStage {
pb.equals("companyId", companyId),
pb.equals("settlementDate", settlementDt),
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);
log.trace("rgs.id={} found by: {}", rgs == null ? "'not found'" : rgs.getId(), rgstrPredicate.toString());