reports-service http://jira.mfd.msk:8088/browse/CLS-497 KSRepCashRegisterSumsReportBuilder поправил парсинг человекочитаемого формата данных
This commit is contained in:
parent
57bbce07da
commit
53b71431ea
2 changed files with 50 additions and 10 deletions
|
|
@ -100,23 +100,19 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
|
|||
}
|
||||
TradingClearingRegistry tkr;
|
||||
if (searchTCRAsInfo) {
|
||||
String code = statement.getComment();
|
||||
int i = code.lastIndexOf("ТКР");
|
||||
if (i >= 0) {
|
||||
code = code.substring(i + 3).trim();
|
||||
}
|
||||
if (i < 0 || code.isBlank()) {
|
||||
String code = parseCodeFromStatementComment(statement.getComment());
|
||||
if (code == null || code.isBlank()) {
|
||||
log.warn("For statement id = {} empty or unparseable code=\"{}\" (comment \"{}\"), statement was skipped",
|
||||
code, statement.getComment(), statement.getId());
|
||||
continue;
|
||||
}
|
||||
log.debug("Search TCR by code={}", code);
|
||||
log.debug("Search TradingClearingRegistry by code={}", code);
|
||||
tkr = tradingClearingRegistryImdg.getFirstObjectByFieldValues(Map.of("code", code));
|
||||
if (tkr == null) {
|
||||
log.warn(
|
||||
"For statement id = {} and code = {} not found TradingClearingRegistry",
|
||||
"For statement id = {} and code = {} (or unparseable comment=\"{}\") not found TradingClearingRegistry, statement was skipped",
|
||||
statement.getId(),
|
||||
code
|
||||
code, statement.getComment()
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -130,7 +126,7 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
|
|||
tkr = tradingClearingRegistryImdg.getFirstObjectByFieldValues(Map.of("moneyAccountId", accountId));
|
||||
if (tkr == null) {
|
||||
log.warn(
|
||||
"For statement id = {} and accountId = {} not found TradingClearingRegistry",
|
||||
"For statement id = {} and accountId = {} not found TradingClearingRegistry, statement was skipped",
|
||||
statement.getId(),
|
||||
accountId
|
||||
);
|
||||
|
|
@ -238,4 +234,25 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String parseCodeFromStatementComment(String comment) {
|
||||
if (comment == null)
|
||||
return null;
|
||||
int i = comment.lastIndexOf("ТКР");
|
||||
String code = comment;
|
||||
if (i >= 0) {
|
||||
code = code.substring(i + 3).trim();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
i = -1;
|
||||
for (String end : Arrays.asList(".", ";", " ")) {
|
||||
int p = code.indexOf(end);
|
||||
if (p > 0 && (i <= 0 || i > p)) i = p;
|
||||
}
|
||||
if (i > 0) {
|
||||
code = code.substring(0, i);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package ru.spcex.clearing.reports.reports.ks;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class KSRepCashRegisterSumsReportBuilderTest {
|
||||
|
||||
@Test
|
||||
void parseCodeFromStatementComment() {
|
||||
KSRepCashRegisterSumsReportBuilder reportB = new KSRepCashRegisterSumsReportBuilder(Mockito.mock(ImdgProvider.class));
|
||||
assertNull(reportB.parseCodeFromStatementComment(null));
|
||||
assertEquals(null, reportB.parseCodeFromStatementComment(""));
|
||||
assertEquals(null, reportB.parseCodeFromStatementComment(" TTTAAA "));
|
||||
assertEquals("0045CAT00001", reportB.parseCodeFromStatementComment("Возврат на депозит №DSTAA10S003/150923/45/23091500000008 по ТКР 0045CAT00001"));
|
||||
assertEquals("0574MAT00001", reportB.parseCodeFromStatementComment("Вывод средств по ТКР 0574MAT00001. Поручения 777."));
|
||||
assertEquals("0574MAT00001", reportB.parseCodeFromStatementComment("ТКР 0574MAT00001"));
|
||||
assertEquals("0574MAT00001", reportB.parseCodeFromStatementComment("ТКР0574MAT00001"));
|
||||
assertEquals("", reportB.parseCodeFromStatementComment("ТКР"));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue