SDF57 обработка создание DM*X по TM*T
This commit is contained in:
parent
c7f1b490ed
commit
f5783dbdb6
2 changed files with 74 additions and 20 deletions
|
|
@ -173,7 +173,7 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
return;
|
||||
Optional<EnumMessage> err = validateActiveness(company, account);
|
||||
if (err.isEmpty()) {
|
||||
findRegByDesignation(stmt, RegistryDesignation.A).ifPresentOrElse(rgs -> {
|
||||
findRegByDesignation(stmt, RegistryTradingParams.AM_T, false, false).ifPresentOrElse(rgs -> {
|
||||
log.debug("stmt.id={}, found AM*T.id={}, updating...", stmt.getId(), rgs.getId());
|
||||
updateReg(stmt, rgs);
|
||||
//добавил создание если не найдены
|
||||
|
|
@ -218,23 +218,46 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
InOutDirection direction = IEnumKey.getEnumByKey(InOutDirection.class, stmt.getInOutDirection());
|
||||
if (!StringUtils.isEmpty(sdf57.getSpecif()) && pattern.matcher(sdf57.getSpecif()).find() && InOutDirection.in.equals(direction)) {
|
||||
//todo доделать 11. Идентификация средств УК на клиринговом счете
|
||||
findRegByDesignation(stmt, RegistryDesignation.D).ifPresentOrElse(rgs -> {
|
||||
rgs.setBalance(safeBD(rgs.getBalance()).add(safeBD(stmt.getAmount())));
|
||||
rgs.setUpdated(Instant.now());
|
||||
registryImdg.update(rgs);
|
||||
log.debug("stmt.id={}, sdf57.specif={} updated DM*T.id={}",
|
||||
stmt.getId(),
|
||||
sdf57.getSpecif(),
|
||||
rgs.getId());
|
||||
},
|
||||
() -> findRegByDesignation(stmt, RegistryDesignation.O).ifPresent(rgs -> {
|
||||
Registry registryD = copyRegD(rgs);
|
||||
//stmt.id=340270002, sdf57.specif=Возврат депозита по договору №DT1000S001U/280623/8/7 new DM*T.id=339610032
|
||||
//1. у stmt accountId 3021, addresseId 2610034, contract DT1000S001U/280623/8/7
|
||||
//
|
||||
Optional<Registry> dm__Found = findRegByDesignation(stmt, RegistryTradingParams.DM__, true, false);
|
||||
Optional<Registry> om_tFound = Optional.empty();
|
||||
Optional<Registry> tm_tFound = Optional.empty();
|
||||
if (dm__Found.isEmpty()) {
|
||||
om_tFound = findRegByDesignation(stmt, RegistryTradingParams.OM_T, true, true);
|
||||
}
|
||||
if (dm__Found.isEmpty() && om_tFound.isEmpty()) {
|
||||
tm_tFound = findRegByDesignation(stmt, RegistryTradingParams.TM_T, true, true);
|
||||
}
|
||||
if (dm__Found.isPresent()) {
|
||||
Registry dm__ = dm__Found.get();
|
||||
dm__.setBalance(safeBD(dm__.getBalance()).add(safeBD(stmt.getAmount())));
|
||||
dm__.setUpdated(Instant.now());
|
||||
registryImdg.update(dm__);
|
||||
log.debug("stmt.id={}, sdf57.specif={} updated DM**.id={}",
|
||||
stmt.getId(),
|
||||
sdf57.getSpecif(),
|
||||
dm__.getId());
|
||||
} else if (om_tFound.isPresent()) {
|
||||
Registry om_t = om_tFound.get();
|
||||
Registry registryD = copyRegD(om_t, RegistryUnit.T);
|
||||
registryImdg.insert(registryD);
|
||||
log.debug("stmt.id={}, sdf57.specif={} new DM*T.id={}",
|
||||
log.debug("stmt.id={}, sdf57.specif={}, found OM*T.id={} new DM*T.id={}",
|
||||
stmt.getId(),
|
||||
sdf57.getSpecif(),
|
||||
rgs.getId());
|
||||
}));
|
||||
om_t.getId(),
|
||||
registryD.getId());
|
||||
} else if (tm_tFound.isPresent()) {
|
||||
Registry tm_t = tm_tFound.get();
|
||||
Registry registryD = copyRegD(tm_t, RegistryUnit.X);
|
||||
registryImdg.insert(registryD);
|
||||
log.debug("stmt.id={}, sdf57.specif={} found TM*T.id={} new DM*X.id={}. Return money identification for Initiator account based on TM*T registry searchin on companyId, accountId, contract and registry_status=PROC|MGN",
|
||||
stmt.getId(),
|
||||
sdf57.getSpecif(),
|
||||
tm_t.getId(),
|
||||
registryD.getId());
|
||||
}
|
||||
}
|
||||
stmt.setOperationStatus(OperationStatus.Executed.getKey());
|
||||
statementImdg.update(stmt);
|
||||
|
|
@ -275,11 +298,12 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
return rgsF;
|
||||
}
|
||||
|
||||
private Registry copyRegD(Registry rgs) {
|
||||
Registry rgsB = rgs.clone();
|
||||
rgsB.setRegistryDesignation(RegistryDesignation.D.getKey());
|
||||
rgsB.setRegistryCode(RegistryUtil.clearingCode(rgsB));
|
||||
return rgsB;
|
||||
private Registry copyRegD(Registry rgs, RegistryUnit unit) {
|
||||
Registry rgsD = rgs.clone();
|
||||
rgsD.setRegistryDesignation(RegistryDesignation.D.getKey());
|
||||
rgsD.setRegistryUnit(unit.getKey());
|
||||
rgsD.setRegistryCode(RegistryUtil.clearingCode(rgsD));
|
||||
return rgsD;
|
||||
}
|
||||
|
||||
private record StmtCmpAcc(Statement statement, Company company, Account account) {
|
||||
|
|
@ -407,6 +431,31 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
r.setUpdated(Instant.now());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Optional<Registry> findRegByDesignation(Statement stmt,
|
||||
RegistryTradingParams rgsCode,
|
||||
boolean contractCondition,
|
||||
boolean statusCondition) {
|
||||
String sql = RegistryCodeSqlBuilder.getInstance(rgsCode).build();
|
||||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||
ImdgPredicate rgstrPredicate = pb.and(pb.sql(sql),
|
||||
pb.sql(sql),
|
||||
pb.equals("companyId", stmt.getAddresseeId()),
|
||||
pb.equals("accountId", stmt.getAccountId())
|
||||
);
|
||||
if (contractCondition) {
|
||||
rgstrPredicate = pb.and(rgstrPredicate, pb.equals("contract", stmt.getContract()));
|
||||
}
|
||||
if (statusCondition) {
|
||||
rgstrPredicate = pb.and(rgstrPredicate, pb.or(
|
||||
pb.equals("registryStatus", RegistryStatus.PROC.getKey()),
|
||||
pb.equals("registryStatus", RegistryStatus.MNG.getKey())
|
||||
));
|
||||
}
|
||||
return Optional.ofNullable(registryImdg.getSingleObjectByPredicate(rgstrPredicate));
|
||||
}
|
||||
|
||||
private Optional<Registry> findRegByDesignation(Statement s, RegistryDesignation des) {
|
||||
RegistryTradingParams p = new RegistryTradingParams(
|
||||
des, RegistryInstrumentType.M, null, RegistryUnit.T
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public record RegistryTradingParams(RegistryDesignation registryDesignation,
|
|||
public final static RegistryTradingParams CS_T;
|
||||
public final static RegistryTradingParams LS_T;
|
||||
public final static RegistryTradingParams L__T;
|
||||
public final static RegistryTradingParams DM__;
|
||||
|
||||
static {
|
||||
OS_T = new RegistryTradingParams(RegistryDesignation.O,
|
||||
|
|
@ -102,6 +103,10 @@ public record RegistryTradingParams(RegistryDesignation registryDesignation,
|
|||
null,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
DM__ = new RegistryTradingParams(RegistryDesignation.D,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue