ialbert 2026-04-30 16:03:10 +03:00
parent e21479305d
commit 0def756f08
3 changed files with 68 additions and 36 deletions

View file

@ -69,7 +69,11 @@ public class Sdf55Executor {
pmt.setUpdated(Instant.now());
pmtImdg.update(pmt);
String curr = TextUtil.isEmpty(sDf55.getPay_val()) ? CurrencyCode.RUB.getKey() : sDf55.getPay_val();
if (tcr != null) {
dmiService.setContract(tcr.getId(), curr, sDf54.getDocnm_ref(), sDf55.getDocnmprev());
} else {
dmiService.setContractByAcc(pmt.getCreditLeg_accountId(), curr, sDf54.getDocnm_ref(), sDf55.getDocnmprev());
}
assets.process(assetTrio.a__b(),
assetTrio.a__t(),
assetTrio.a__f(),

View file

@ -92,7 +92,23 @@ public class DmiService {
String securitySymbol,
String comment,
String contract) {
findDmiByComment(tcrId, securitySymbol, comment).ifPresentOrElse(d__i -> {
findDmiByComment(tcrId, securitySymbol, comment).ifPresentOrElse(
(d__i) -> updateD__i(d__i, contract, securitySymbol, comment),
() -> log.trace("didn't find DM*I by tcr.id={} securitySymbol={} comment={}",
tcrId, securitySymbol, comment));
}
public void setContractByAcc(Long accId,
String securitySymbol,
String comment,
String contract) {
findDmiByCommentAcc(accId, securitySymbol, comment).ifPresentOrElse(
(d__i) -> updateD__i(d__i, contract, securitySymbol, comment),
() -> log.trace("didn't find DM*I by acc.id={} securitySymbol={} comment={}",
accId, securitySymbol, comment));
}
private void updateD__i(Registry d__i, String contract, String securitySymbol, String comment) {
d__i.setContract(contract);
d__i.setUpdated(Instant.now());
try {
@ -108,8 +124,7 @@ public class DmiService {
if (stmt != null && OperationStatus.Executed.equalsByKey(stmt.getOperationStatus())) {
d__i.setRegistryStatus(RegistryStatus.OK.getKey());
} else {
log.warn("tcrId={} securitySymbol={} comment={} sdf57 dbfId={} found, stmt.id={} status {}. d**i status will not be updated",
tcrId,
log.warn("securitySymbol={} comment={} sdf57 dbfId={} found, stmt.id={} status {}. d**i status will not be updated",
securitySymbol,
comment,
dbfId,
@ -124,8 +139,6 @@ public class DmiService {
}
rgsImdg.update(d__i);
log.trace("set {}.id={} contract {}", d__i.getRegistryCode(), d__i.getId(), contract);
}, () -> log.trace("didn't find DM*I by tcr.id={} securitySymbol={} comment={}",
tcrId, securitySymbol, comment));
}
@ -178,6 +191,20 @@ public class DmiService {
return Optional.ofNullable(d__i);
}
private Optional<Registry> findDmiByCommentAcc(Long accId, String securitySymbol, String comment) {
ImdgPredicateBuilder pb = rgsImdg.predicateBuilder();
RegistryTradingParams rgsCde = RegistryTradingParams.D__I;
ImdgPredicate prdct = pb.and(
pb.sql(RegistryCodeSqlBuilder.getInstance(rgsCde).build()),
pb.equals("accountId", accId),
pb.equals("securitySymbol", securitySymbol),
pb.equals("comment", comment)
);
log.trace("searching D**I by {}", prdct);
Registry d__i = rgsImdg.getFirstObjectByPredicate(prdct);
return Optional.ofNullable(d__i);
}
public Optional<Registry> createDmi(Long tcrId,
String securitySymbol,
BigDecimal summ) {

View file

@ -104,9 +104,10 @@ public enum Sdf55ValidationRule implements IValidationRule<ImdgValidationContext
}
if (tcr == null) {
return of(ClearingError.RecordNotFound, errMsg);
}
log.debug("{}: TCR was not found; account will be used instead.", ruleName());
} else {
context.storeObject(ValidationStored.Sdf55Tcr, tcr);
}
return empty();
}
},