This commit is contained in:
parent
e21479305d
commit
0def756f08
3 changed files with 68 additions and 36 deletions
|
|
@ -69,7 +69,11 @@ public class Sdf55Executor {
|
||||||
pmt.setUpdated(Instant.now());
|
pmt.setUpdated(Instant.now());
|
||||||
pmtImdg.update(pmt);
|
pmtImdg.update(pmt);
|
||||||
String curr = TextUtil.isEmpty(sDf55.getPay_val()) ? CurrencyCode.RUB.getKey() : sDf55.getPay_val();
|
String curr = TextUtil.isEmpty(sDf55.getPay_val()) ? CurrencyCode.RUB.getKey() : sDf55.getPay_val();
|
||||||
dmiService.setContract(tcr.getId(), curr, sDf54.getDocnm_ref(), sDf55.getDocnmprev());
|
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(),
|
assets.process(assetTrio.a__b(),
|
||||||
assetTrio.a__t(),
|
assetTrio.a__t(),
|
||||||
assetTrio.a__f(),
|
assetTrio.a__f(),
|
||||||
|
|
|
||||||
|
|
@ -92,42 +92,55 @@ public class DmiService {
|
||||||
String securitySymbol,
|
String securitySymbol,
|
||||||
String comment,
|
String comment,
|
||||||
String contract) {
|
String contract) {
|
||||||
findDmiByComment(tcrId, securitySymbol, comment).ifPresentOrElse(d__i -> {
|
findDmiByComment(tcrId, securitySymbol, comment).ifPresentOrElse(
|
||||||
d__i.setContract(contract);
|
(d__i) -> updateD__i(d__i, contract, securitySymbol, comment),
|
||||||
d__i.setUpdated(Instant.now());
|
() -> log.trace("didn't find DM*I by tcr.id={} securitySymbol={} comment={}",
|
||||||
try {
|
|
||||||
Long dbfId = Long.valueOf(contract);
|
|
||||||
SDf57 sdf57 = sDf57Imdg.getFirstObjectBySQL("dbfId=%d".formatted(dbfId));
|
|
||||||
if (sdf57 != null) {
|
|
||||||
ImdgPredicateBuilder pb = statementImdg.predicateBuilder();
|
|
||||||
ImdgPredicate stmtPrdct = pb.and(
|
|
||||||
pb.equals("inSDfId", sdf57.getId()),
|
|
||||||
pb.equals("inOutSDfType", InOutSDfType.type57.getKey())
|
|
||||||
);
|
|
||||||
Statement stmt = statementImdg.getFirstObjectByPredicate(stmtPrdct);
|
|
||||||
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,
|
|
||||||
securitySymbol,
|
|
||||||
comment,
|
|
||||||
dbfId,
|
|
||||||
stmt != null ? stmt.getId() : null,
|
|
||||||
stmt != null ? stmt.getOperationStatus() : null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
log.error("sdf57 search by {}: error {}",
|
|
||||||
contract,
|
|
||||||
ExceptionUtils.getStackTrace(e));
|
|
||||||
}
|
|
||||||
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));
|
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 {
|
||||||
|
Long dbfId = Long.valueOf(contract);
|
||||||
|
SDf57 sdf57 = sDf57Imdg.getFirstObjectBySQL("dbfId=%d".formatted(dbfId));
|
||||||
|
if (sdf57 != null) {
|
||||||
|
ImdgPredicateBuilder pb = statementImdg.predicateBuilder();
|
||||||
|
ImdgPredicate stmtPrdct = pb.and(
|
||||||
|
pb.equals("inSDfId", sdf57.getId()),
|
||||||
|
pb.equals("inOutSDfType", InOutSDfType.type57.getKey())
|
||||||
|
);
|
||||||
|
Statement stmt = statementImdg.getFirstObjectByPredicate(stmtPrdct);
|
||||||
|
if (stmt != null && OperationStatus.Executed.equalsByKey(stmt.getOperationStatus())) {
|
||||||
|
d__i.setRegistryStatus(RegistryStatus.OK.getKey());
|
||||||
|
} else {
|
||||||
|
log.warn("securitySymbol={} comment={} sdf57 dbfId={} found, stmt.id={} status {}. d**i status will not be updated",
|
||||||
|
securitySymbol,
|
||||||
|
comment,
|
||||||
|
dbfId,
|
||||||
|
stmt != null ? stmt.getId() : null,
|
||||||
|
stmt != null ? stmt.getOperationStatus() : null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.error("sdf57 search by {}: error {}",
|
||||||
|
contract,
|
||||||
|
ExceptionUtils.getStackTrace(e));
|
||||||
|
}
|
||||||
|
rgsImdg.update(d__i);
|
||||||
|
log.trace("set {}.id={} contract {}", d__i.getRegistryCode(), d__i.getId(), contract);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ищем D**I по tcrId/security/contract
|
* ищем D**I по tcrId/security/contract
|
||||||
|
|
@ -178,6 +191,20 @@ public class DmiService {
|
||||||
return Optional.ofNullable(d__i);
|
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,
|
public Optional<Registry> createDmi(Long tcrId,
|
||||||
String securitySymbol,
|
String securitySymbol,
|
||||||
BigDecimal summ) {
|
BigDecimal summ) {
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,10 @@ public enum Sdf55ValidationRule implements IValidationRule<ImdgValidationContext
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tcr == null) {
|
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);
|
||||||
}
|
}
|
||||||
context.storeObject(ValidationStored.Sdf55Tcr, tcr);
|
|
||||||
return empty();
|
return empty();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue