clearing-service http://jira.mfd.msk:8088/browse/CLS-200 Сверка VerificationResult доделал
This commit is contained in:
parent
198daf9e62
commit
06b37a91cb
2 changed files with 52 additions and 17 deletions
|
|
@ -118,11 +118,14 @@ public class VerificationResultComponent {
|
||||||
for (VerificationResult rItem : result) {
|
for (VerificationResult rItem : result) {
|
||||||
verificationResultImdg.insert(rItem);
|
verificationResultImdg.insert(rItem);
|
||||||
}
|
}
|
||||||
|
vResLst.addAll(result);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error verification for company {}: {}",
|
log.error("Error verification for company {}: {}",
|
||||||
companyId, ExceptionUtils.getStackTrace(e));
|
companyId, ExceptionUtils.getStackTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
boolean allSuccess = vResLst.stream().allMatch(vr -> ResultStatuses.success.equalsByKey(vr.getGenerationStatus()));
|
||||||
|
log.debug("Total {} VerificationResult created. {}", vResLst.size(), allSuccess ? "All success." : "Has same mismatch data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -130,10 +133,13 @@ public class VerificationResultComponent {
|
||||||
* @param accountId Account.id by Account.account
|
* @param accountId Account.id by Account.account
|
||||||
* @return new
|
* @return new
|
||||||
*/
|
*/
|
||||||
VerificationResult newVerification(Company forCompany, Long accountId) {
|
VerificationResult newVerification(Instant now, Company forCompany, Long accountId) {
|
||||||
VerificationResult vResult = new VerificationResult();
|
VerificationResult vResult = new VerificationResult();
|
||||||
vResult.setId(idGenerator.nextId()); // imdg
|
vResult.setId(idGenerator.nextId()); // imdg
|
||||||
vResult.setCreated(Instant.now());
|
if (now == null) {
|
||||||
|
now = Instant.now();
|
||||||
|
}
|
||||||
|
vResult.setCreated(now);
|
||||||
if (forCompany != null) {
|
if (forCompany != null) {
|
||||||
vResult.setClearingCode(forCompany.getClearingCode());
|
vResult.setClearingCode(forCompany.getClearingCode());
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +152,8 @@ public class VerificationResultComponent {
|
||||||
protected List<VerificationResult> checkOnCompany(Company forCompany, Collection<SDf01> allSDf01,
|
protected List<VerificationResult> checkOnCompany(Company forCompany, Collection<SDf01> allSDf01,
|
||||||
Collection<AccountBalance> allAccountBalance,
|
Collection<AccountBalance> allAccountBalance,
|
||||||
Collection<Account> allAccount) {
|
Collection<Account> allAccount) {
|
||||||
ArrayList<VerificationResult> checks = new ArrayList<>();
|
final ArrayList<VerificationResult> checks = new ArrayList<>();
|
||||||
|
final Instant now = Instant.now();
|
||||||
|
|
||||||
Map<String, Long> indexAccountIdByAccount = new HashMap<>();
|
Map<String, Long> indexAccountIdByAccount = new HashMap<>();
|
||||||
for (Account account : allAccount) {
|
for (Account account : allAccount) {
|
||||||
|
|
@ -157,7 +164,7 @@ public class VerificationResultComponent {
|
||||||
{ // 1.70 verificationResult
|
{ // 1.70 verificationResult
|
||||||
Map<String, SDf01> indexSDf01 = index(allSDf01, SDf01::getAccount);
|
Map<String, SDf01> indexSDf01 = index(allSDf01, SDf01::getAccount);
|
||||||
for (AccountBalance account : allAccountBalance) {
|
for (AccountBalance account : allAccountBalance) {
|
||||||
VerificationResult vResult = newVerification(forCompany, indexAccountIdByAccount.get(account.getAccount()));
|
VerificationResult vResult = newVerification(now, forCompany, indexAccountIdByAccount.get(account.getAccount()));
|
||||||
checks.add(vResult);
|
checks.add(vResult);
|
||||||
|
|
||||||
SDf01 document = indexSDf01.get(account.getAccount());
|
SDf01 document = indexSDf01.get(account.getAccount());
|
||||||
|
|
@ -205,7 +212,7 @@ public class VerificationResultComponent {
|
||||||
boolean isOk = sDf01Keys.size() == accountKeys.size() &&
|
boolean isOk = sDf01Keys.size() == accountKeys.size() &&
|
||||||
sDf01Keys.containsAll(accountKeys) && accountKeys.containsAll(sDf01Keys);
|
sDf01Keys.containsAll(accountKeys) && accountKeys.containsAll(sDf01Keys);
|
||||||
|
|
||||||
VerificationResult vResult = newVerification(forCompany, null);
|
VerificationResult vResult = newVerification(now, forCompany, null);
|
||||||
checks.add(vResult);
|
checks.add(vResult);
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
vResult.setResultStatus(ResultStatuses.success.getKey());
|
vResult.setResultStatus(ResultStatuses.success.getKey());
|
||||||
|
|
@ -221,7 +228,7 @@ public class VerificationResultComponent {
|
||||||
long countSDf01 = allSDf01.stream().filter(sDf01 -> sDf01.getDeal() != null).count();
|
long countSDf01 = allSDf01.stream().filter(sDf01 -> sDf01.getDeal() != null).count();
|
||||||
long countAccount = allAccount.stream().filter(account -> account.getAccount() != null).count();
|
long countAccount = allAccount.stream().filter(account -> account.getAccount() != null).count();
|
||||||
boolean isOk = countSDf01 == countAccount;
|
boolean isOk = countSDf01 == countAccount;
|
||||||
VerificationResult vResult = newVerification(forCompany, null);
|
VerificationResult vResult = newVerification(now, forCompany, null);
|
||||||
checks.add(vResult);
|
checks.add(vResult);
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
vResult.setResultStatus(ResultStatuses.success.getKey());
|
vResult.setResultStatus(ResultStatuses.success.getKey());
|
||||||
|
|
@ -281,7 +288,7 @@ public class VerificationResultComponent {
|
||||||
fromSDf01 = fromSDf01.setScale(2, RoundingMode.HALF_UP);
|
fromSDf01 = fromSDf01.setScale(2, RoundingMode.HALF_UP);
|
||||||
BigDecimal diff = fromBalance.subtract(fromSDf01).setScale(2, RoundingMode.HALF_UP).abs();
|
BigDecimal diff = fromBalance.subtract(fromSDf01).setScale(2, RoundingMode.HALF_UP).abs();
|
||||||
|
|
||||||
VerificationResult vResult = newVerification(forCompany, indexAccountIdByAccount.get(account));
|
VerificationResult vResult = newVerification(now, forCompany, indexAccountIdByAccount.get(account));
|
||||||
checks.add(vResult);
|
checks.add(vResult);
|
||||||
if (BigDecimal.ZERO.compareTo(diff) == 0) {
|
if (BigDecimal.ZERO.compareTo(diff) == 0) {
|
||||||
vResult.setResultStatus(ResultStatuses.success.getKey());
|
vResult.setResultStatus(ResultStatuses.success.getKey());
|
||||||
|
|
@ -290,7 +297,7 @@ public class VerificationResultComponent {
|
||||||
}
|
}
|
||||||
vResult.setDiffSum(diff);
|
vResult.setDiffSum(diff);
|
||||||
vResult.setOutExtSum(fromSDf01);
|
vResult.setOutExtSum(fromSDf01);
|
||||||
log.trace("for comapny[{}], account \"{}\" summ of fromSDf01={}, of fromBalance={}; result {}",
|
log.trace("for company[{}], account \"{}\" summ of fromSDf01={}, of fromBalance={}; result {}",
|
||||||
forCompany.getId(), account, fromSDf01, fromBalance, vResult.getResultStatus());
|
forCompany.getId(), account, fromSDf01, fromBalance, vResult.getResultStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -303,15 +310,6 @@ public class VerificationResultComponent {
|
||||||
return checks;
|
return checks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Сумму по остаткам в бизнес-объекте accountBalance - sDf01.remainder = accountBalance.closeBalanceAmount [sDf01.account = accountBalance.account]
|
|
||||||
2. Расчет контрольных сумм:
|
|
||||||
2.1 Номера торговых/клиринговых счетов, соответствующие загруженным в КС -sDf01.deal = account.account & accountType=CLRN & accountStatus=UNBL
|
|
||||||
2.2 Количество торговых/клиринговых счетов, соответствующие загруженным в КС - COUNT[sDf01.deal] = COUNT [account.account]
|
|
||||||
2.3 Суммарный остаток по счетам - ∑sDf01.remainder = ∑accountBalance.closeBalanceAmount[sDf01.account = accountBalance.account]
|
|
||||||
3. Сверка остатков по клиринговым счетам СПВБ в бизнес-объекте accountBalance - sDf01.remainder = accountBalance.closeBalanceAmount [sDf01.account = accountBalance.account & accountType=INFO]
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
<K, V extends WithId> Map<K, V> index(Collection<V> from, Function<V, K> indexFieldExtractor) {
|
<K, V extends WithId> Map<K, V> index(Collection<V> from, Function<V, K> indexFieldExtractor) {
|
||||||
Map<K, V> index = new HashMap<>();
|
Map<K, V> index = new HashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>./logs/clearing-service.log</file>
|
||||||
|
<encoder>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||||
|
<fileNamePattern>
|
||||||
|
../logs/clearing-service.%i.log
|
||||||
|
</fileNamePattern>
|
||||||
|
<minIndex>1</minIndex>
|
||||||
|
<maxIndex>10</maxIndex>
|
||||||
|
</rollingPolicy>
|
||||||
|
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||||
|
<maxFileSize>500MB</maxFileSize>
|
||||||
|
</triggeringPolicy>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="warn">
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<logger name="ru.spcex" level="debug" additivity="false">
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</logger>
|
||||||
|
</configuration>
|
||||||
Loading…
Add table
Reference in a new issue