balance-service поправил валидаторы с null BigInt. 2.
This commit is contained in:
parent
9ae5936a01
commit
e22e422214
1 changed files with 14 additions and 10 deletions
|
|
@ -21,19 +21,23 @@ public enum Sdf16ValidationRule implements IValidationRule<ImdgValidationContext
|
|||
SDf16 sdf16 = context.getValidatedObject();
|
||||
Imdg<CompanySymbols> companySymbolsImdg = context.obtainMap(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
|
||||
Imdg<Company> companyImdg = context.obtainMap(IMDGDistributedNames.Map_Company, Company.class);
|
||||
if (sdf16.getInn() == null) {
|
||||
return of(BalanceError.CompanyNotFound, "empty inn");
|
||||
String sql = "";
|
||||
if (sdf16.getInn() != null) {
|
||||
String innStr = sdf16.getInn().setScale(0, RoundingMode.DOWN).toString();
|
||||
sql = String.format("(companySymbolValue = '%s' and companySymbol = '%s') ",
|
||||
innStr, CompanySymbol.INN.getKey());
|
||||
}
|
||||
if (sdf16.getBic() == null) {
|
||||
return of(BalanceError.CompanyNotFound, "empty bic");
|
||||
if (sdf16.getBic() != null) {
|
||||
if (!sql.isEmpty()) sql += " or ";
|
||||
String bicStr = sdf16.getBic().setScale(0, RoundingMode.DOWN).toString();
|
||||
sql += String.format("(companySymbolValue = '%s' and companySymbol = '%s') ",
|
||||
bicStr, CompanySymbol.BIC.getKey());
|
||||
}
|
||||
if (sql.isEmpty()) {
|
||||
return of(BalanceError.CompanyNotFound, "inn and bic is empty");
|
||||
}
|
||||
String innStr = sdf16.getInn().setScale(0, RoundingMode.DOWN).toString();
|
||||
String bicStr = sdf16.getBic().setScale(0, RoundingMode.DOWN).toString();
|
||||
CompanySymbols companySymbols = companySymbolsImdg.getSingleObjectBySQL(
|
||||
String.format("(companySymbolValue = '%s' and companySymbol = '%s') " +
|
||||
"or (companySymbolValue = '%s' and companySymbol = '%s')",
|
||||
innStr, CompanySymbol.INN.getKey(), bicStr, CompanySymbol.BIC.getKey()));
|
||||
Company company = null;
|
||||
CompanySymbols companySymbols = companySymbolsImdg.getSingleObjectBySQL(sql);
|
||||
if (companySymbols != null) {
|
||||
company = companyImdg.getSingleObjectByID(companySymbols.getCompanyId());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue