SDF01 обработка, логи
This commit is contained in:
parent
6219add3c9
commit
864f64bba3
1 changed files with 15 additions and 2 deletions
|
|
@ -107,6 +107,7 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
Long generationIdForGroup = imdgProvider.getImdgIdGenerator().nextId();
|
||||
result.setGenerationId(generationIdForGroup);
|
||||
boolean reviseFailed = false;
|
||||
log.info("SDF01 execution: sdf01 number={}, groupId={}", sdf.size(), sdf.stream().findFirst().map(SDf01::getGenerationId).orElse(null));
|
||||
for (SDf01 sdf01 : sdf) {
|
||||
IValidator validator = sDf01Validator.apply(sdf01);
|
||||
Optional<EnumMessage> error = validator.tillFirstError();
|
||||
|
|
@ -121,7 +122,7 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
log.warn("account {} for sdf01.id={} not found. Can not send request for creation, cause company not found too", sdf01.getAccount(), sdf01.getId());
|
||||
} else {
|
||||
result.getAccountRequests().add(createAccountRequestPart(sdf01.getId(), sdf01.getAccount(), sdf01.getAcc_type(), company.getId()));
|
||||
log.info("account {} for sdf01.id={} not found - send request for creation", sdf01.getAccount(), sdf01.getId());
|
||||
log.debug("account {} for sdf01.id={} not found - send request for creation", sdf01.getAccount(), sdf01.getId());
|
||||
}
|
||||
continue;
|
||||
} else if (ClearingErrorInternal.AccountNotPresent.equals(error.map(EnumMessage::getSubject).orElse(null))) {
|
||||
|
|
@ -133,6 +134,7 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
sdf02Imdg.insert(createErrorSdf02(sdf01, error.get(), generationIdForGroup));
|
||||
continue;
|
||||
}
|
||||
log.debug("sdf01.id={} validation passed", sdf01.getId());
|
||||
|
||||
Statement stmt = createSdf01Statement(sdf01, company, account);
|
||||
|
||||
|
|
@ -140,11 +142,16 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
sdf02Imdg.insert(sdf02New);
|
||||
stmt.setOutSDfId(sdf02New.getId());
|
||||
statementImdg.insert(stmt);
|
||||
log.debug("sdf01.id={} sdf02 created id {}, statement created id {}", sdf01.getId(), sdf02New.getId(), stmt.getId());
|
||||
|
||||
Optional<EnumMessage> err = validateActiveness(company, account);
|
||||
if (err.isEmpty()) {
|
||||
Optional<Registry> reg = findReg(stmt);
|
||||
Registry rgs;
|
||||
log.debug("sdf01.id={}, stmt.id={}: registry {}",
|
||||
sdf01.getId(),
|
||||
stmt.getId(),
|
||||
reg.map(r -> "found id=" + r.getId()).orElse("not found"));
|
||||
if (reg.isPresent()) {
|
||||
rgs = reg.get();
|
||||
updateReg(stmt, rgs);
|
||||
|
|
@ -153,14 +160,19 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
rgs = createRegistryByStatement(stmt, company, account);
|
||||
registryImdg.insert(rgs);
|
||||
}
|
||||
//todo
|
||||
if (!BigDecimal.ZERO.equals(rgs.getDiffBalance())) {
|
||||
log.info("sdf01.id={}, stmt.id={}, registry.id={} diffBalance is not zero: {}",
|
||||
sdf01.getId(),
|
||||
stmt.getId(),
|
||||
rgs.getId(),
|
||||
rgs.getDiffBalance());
|
||||
reviseFailed = true;
|
||||
}
|
||||
//2. отправить notification на backend
|
||||
stmt.setOperationStatus(OperationStatus.Executed.getKey());
|
||||
statementImdg.update(stmt);
|
||||
} else {
|
||||
log.debug("sdf01.id={} activeness checks failed {}", sdf01.getId(), messageResolver.resolve(err.get()));
|
||||
stmt.setErrorCodeId(err.get().getSubject().getId()); // fixme ErrorText insert
|
||||
stmt.setOperationStatus(OperationStatus.Rejected.getKey());
|
||||
statementImdg.update(stmt);
|
||||
|
|
@ -171,6 +183,7 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
reviseNotification.setComment(reviseFailed ? reviseFailedMessage : reviseSuccessMessage);
|
||||
reviseNotification.setPriority(Priority.HIGH.getKey());
|
||||
kafkaSender.sendRequestToQueue(Consts.NOTIFICATION_NEW, reviseNotification);
|
||||
log.info("revise notification sent (revise {})", reviseFailed ? "error" : "success");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue