dbf-importer SDf06Table поправил формат inn, bic
This commit is contained in:
parent
94af268598
commit
4522aec93f
1 changed files with 18 additions and 8 deletions
|
|
@ -21,22 +21,32 @@ public class SDf06Table extends AbstractTable<SDf06> {
|
|||
public SDf06 getEntity(Object[] entity) {
|
||||
SDf06 result = new SDf06();
|
||||
result.setAccount((String) entity[0]);
|
||||
if (entity[1] instanceof BigDecimal) {
|
||||
result.setSum((BigDecimal) entity[1]);
|
||||
} else if (entity[1] instanceof String) {
|
||||
result.setSum(new BigDecimal((String) entity[1]));
|
||||
}
|
||||
result.setSum(anyNumberToBigDecimal(entity[1]));
|
||||
result.setMarket((String) entity[2]);
|
||||
result.setType((String) entity[3]);
|
||||
result.setDeal((String) entity[4]);
|
||||
result.setClientN((String) entity[5]);
|
||||
result.setInn((BigDecimal) entity[6]);
|
||||
result.setBic((BigDecimal) entity[7]);
|
||||
result.setInn(anyNumberToBigDecimal(entity[6]));
|
||||
result.setBic(anyNumberToBigDecimal(entity[7]));
|
||||
result.setSpec((String) entity[8]);
|
||||
result.setNumber((BigDecimal) entity[9]);
|
||||
result.setNumber(anyNumberToBigDecimal(entity[9]));
|
||||
result.setFileName(filename);
|
||||
result.setGenerationTime(Instant.now());
|
||||
result.setGenerationId(fileId);
|
||||
return result;
|
||||
}
|
||||
|
||||
BigDecimal anyNumberToBigDecimal(Object value) {
|
||||
if (value == null) return null;
|
||||
if (value instanceof BigDecimal) {
|
||||
return (BigDecimal) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return BigDecimal.valueOf(Long.parseLong((String)value));
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return BigDecimal.valueOf(((Number)value).longValue());
|
||||
}
|
||||
throw new IllegalArgumentException("Can not convert to BigDecimal " + value.getClass().getName() + " " + value);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue