xml-importer http://jira.mfd.msk:8088/browse/CLS-824 доделал валидацию ключевых полей
This commit is contained in:
parent
1eb124b209
commit
d542cc6159
1 changed files with 69 additions and 35 deletions
|
|
@ -19,12 +19,12 @@ import ru.spcex.clearing.xml.importer.logic.data.error.ValidationException;
|
|||
import ru.spcex.clearing.xml.importer.logic.data.tags.lks.AccountListCur;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.lks.AccountListRub;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.sdf.DocumentTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.sdf.objects.DF01ObjectTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.sdf.objects.DF06ObjectTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.sdf.objects.DF55ObjectTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.sdf.objects.DF57ObjectTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.sdf.objects.*;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
@Component
|
||||
public class ReadXMLFile {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
|
@ -72,17 +72,17 @@ public class ReadXMLFile {
|
|||
DocumentTag sdf01 = (DocumentTag) container.getXmlFile();
|
||||
for (Object rawrow : sdf01.getObjects()) {
|
||||
if (rawrow instanceof DF01ObjectTag row) {
|
||||
if (row.getCurrCode() == null)
|
||||
if (isEmpty(row.getCurrCode()))
|
||||
lostField.add("CURR_CODE");
|
||||
if (row.getAccount() == null)
|
||||
if (isEmpty(row.getAccount()))
|
||||
lostField.add("ACCOUNT");
|
||||
if (row.getRemainder() == null)
|
||||
if (isEmpty(row.getRemainder()))
|
||||
lostField.add("REMAINDER");
|
||||
if (row.getDat() == null)
|
||||
lostField.add("DAT");
|
||||
if (row.getMarket() == null)
|
||||
if (isEmpty(row.getMarket()))
|
||||
lostField.add("MARKET");
|
||||
if (row.getAccType() == null)
|
||||
if (isEmpty(row.getAccType()))
|
||||
lostField.add("ACC_TYPE");
|
||||
} else {
|
||||
log.warn("Unexpected row type: {}", rawrow);
|
||||
|
|
@ -94,45 +94,65 @@ public class ReadXMLFile {
|
|||
DocumentTag sdf06 = (DocumentTag) container.getXmlFile();
|
||||
for (Object rawrow : sdf06.getObjects()) {
|
||||
if (rawrow instanceof DF06ObjectTag row) {
|
||||
if (row.getAccount() == null)
|
||||
if (isEmpty(row.getAccount()))
|
||||
lostField.add("Account");
|
||||
if (row.getSum() == null)
|
||||
lostField.add("Sum");
|
||||
if (row.getMarket() == null)
|
||||
if (isEmpty(row.getMarket()))
|
||||
lostField.add("Market");
|
||||
if (row.getDeal() == null)
|
||||
if (isEmpty(row.getDeal()))
|
||||
lostField.add("DEAL");
|
||||
if (row.getSpec() == null)
|
||||
if (isEmpty(row.getSpec()))
|
||||
lostField.add("SPEC");
|
||||
if (row.getNumber() == null)
|
||||
lostField.add("Number");
|
||||
if (row.getDocNum() == null)
|
||||
if (isEmpty(row.getDocNum()))
|
||||
lostField.add("Doc_Num");
|
||||
if (row.getDocDate() == null)
|
||||
lostField.add("Doc_Date");
|
||||
if (row.getPayVal() == null)
|
||||
if (isEmpty(row.getPayVal()))
|
||||
lostField.add("Pay_Val");
|
||||
} else {
|
||||
log.warn("Unexpected row type: {}", rawrow);
|
||||
throw new ValidationException("DF06: wrong row format");
|
||||
}
|
||||
}
|
||||
} else if (ETable.DF_52 == container.getXmlTable()) {
|
||||
log.trace("Validate DF52");
|
||||
DocumentTag sdf52 = (DocumentTag) container.getXmlFile();
|
||||
for (Object rawrow : sdf52.getObjects()) {
|
||||
if (rawrow instanceof DF52ObjectTag row) {
|
||||
if (isEmpty(row.getAccount()))
|
||||
lostField.add("ACCOUNT");
|
||||
if (isEmpty(row.getDeal()))
|
||||
lostField.add("DEAL");
|
||||
if (row.getDate()==null)
|
||||
lostField.add("DATE");
|
||||
if (row.getStatus()==null)
|
||||
lostField.add("STATUS");
|
||||
if (isEmpty(row.getAccType()))
|
||||
lostField.add("ACC_TYPE");
|
||||
} else {
|
||||
log.warn("Unexpected row type: {}", rawrow);
|
||||
throw new ValidationException("DF52: wrong row format");
|
||||
}
|
||||
}
|
||||
} else if (ETable.DF_55 == container.getXmlTable()) {
|
||||
log.trace("Validate DF55");
|
||||
DocumentTag sdf55 = (DocumentTag) container.getXmlFile();
|
||||
for (Object rawrow : sdf55.getObjects()) {
|
||||
if (rawrow instanceof DF55ObjectTag row) {
|
||||
if (row.getDocnmRef() == null)
|
||||
if (isEmpty(row.getDocnmRef()))
|
||||
lostField.add("DOCNM_REF");
|
||||
if (row.getDocnmprev() == null)
|
||||
if (isEmpty(row.getDocnmprev()))
|
||||
lostField.add("DOCNMPREV");
|
||||
if (row.getPayVal() == null)
|
||||
if (isEmpty(row.getPayVal()))
|
||||
lostField.add("PAY_VAL");
|
||||
if (row.getSumDeb() == null)
|
||||
if (isEmpty(row.getSumDeb()))
|
||||
lostField.add("SUM_DEB");
|
||||
if (row.getSpecif1() == null)
|
||||
if (isEmpty(row.getSpecif1()))
|
||||
lostField.add("SPECIF_1");
|
||||
if (row.getDocResult() == null)
|
||||
if (isEmpty(row.getDocResult()))
|
||||
lostField.add("DOC_RESULT");
|
||||
} else {
|
||||
log.warn("Unexpected row type: {}", rawrow);
|
||||
|
|
@ -146,35 +166,49 @@ public class ReadXMLFile {
|
|||
if (rawrow instanceof DF57ObjectTag row) {
|
||||
if (row.getId() == null)
|
||||
lostField.add("ID");
|
||||
if (row.getDealDeb() == null && StringUtils.isNotEmpty(row.getAccDeb()))
|
||||
|
||||
// кросс-валидация условных полей DEAL_DEB и DEAL_CRED:
|
||||
if (isNotEmpty(row.getDealDeb())) {
|
||||
if (isEmpty(row.getAccDeb()))
|
||||
lostField.add("ACC_DEB");
|
||||
}
|
||||
if (isNotEmpty(row.getDealCred())) {
|
||||
if (isEmpty(row.getAccKr()))
|
||||
lostField.add("ACC_KR");
|
||||
}
|
||||
if (isEmpty(row.getDealDeb()) && isEmpty(row.getDealCred())) {
|
||||
lostField.add("DEAL_DEB");
|
||||
if (row.getDealCred() == null && StringUtils.isNotEmpty(row.getAccKr()))
|
||||
lostField.add("DEAL_CRED");
|
||||
if (isEmpty(row.getAccDeb()))
|
||||
lostField.add("ACC_DEB");
|
||||
if (isEmpty(row.getAccKr()))
|
||||
lostField.add("ACC_KR");
|
||||
} else if (isNotEmpty(row.getDealDeb()) && isNotEmpty(row.getDealCred())) {
|
||||
log.warn("Заполнены исключающие друг друга поля DEAL_DEB и DEAL_CRED");
|
||||
lostField.add("DEAL_DEB and DEAL_CRED can not use together");
|
||||
}
|
||||
|
||||
if (row.getPayDate() == null)
|
||||
lostField.add("PAY_DATE");
|
||||
if (row.getExtDate() == null)
|
||||
lostField.add("EXT_DATE");
|
||||
if (row.getPayVal() == null)
|
||||
if (isEmpty(row.getPayVal()))
|
||||
lostField.add("PAY_VAL");
|
||||
if (row.getSumDeb() == null)
|
||||
if (isEmpty(row.getSumDeb()))
|
||||
lostField.add("SUM_DEB");
|
||||
if (row.getAccDeb() == null)
|
||||
lostField.add("ACC_DEB");
|
||||
if (row.getAccKr() == null)
|
||||
lostField.add("ACC_KR");
|
||||
if (row.getSpecif() == null)
|
||||
if (isEmpty(row.getSpecif()))
|
||||
lostField.add("SPECIF");
|
||||
if (row.getDocNum() == null)
|
||||
if (isEmpty(row.getDocNum()))
|
||||
lostField.add("DOC_NUM");
|
||||
if (row.getDocDate() == null)
|
||||
lostField.add("DOC_DATE");
|
||||
if (row.getDtIn() == null)
|
||||
if (isEmpty(row.getDtIn()))
|
||||
lostField.add("DT_IN");
|
||||
if (row.getKtIn() == null)
|
||||
if (isEmpty(row.getKtIn()))
|
||||
lostField.add("KT_IN");
|
||||
if (row.getDtOut() == null)
|
||||
if (isEmpty(row.getDtOut()))
|
||||
lostField.add("DT_OUT");
|
||||
if (row.getKtOut() == null)
|
||||
if (isEmpty(row.getKtOut()))
|
||||
lostField.add("KT_OUT");
|
||||
} else {
|
||||
log.warn("Unexpected row type: {}", rawrow);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue