我正在处理报告代码,我需要生成此报告输出。
汽车对象具有50个字符串,50个整数,50个日期,50个大十进制字段。其中一些值已满。
如果需要,我通过输入200取消了这些控件,但我正在寻找更优化和通用的版本。
if (carDTO.getcarProperty() != null) {
if (carContent.getVariableType().equals(VariableType.STRING)) {
if (carDTO.getcustomEntryString1() != null) {
ReportUtils.setvalue(worksheet,rowIndex,cellIndex,carDTO.getcustomEntryString1());
} else if (carDTO.getcustomEntryString2() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryString2());
} else if (carDTO.getcustomEntryString3() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryString3());
}
...
else if (carDTO.getcustomEntryString50() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryString50());
}
} else if (carContent.getVariableType().equals(VariableType.BIGDECIMAL)) {
if (carDTO.getcustomEntryBigDecimal1() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryBigDecimal1());
} else if (carDTO.getcustomEntryBigDecimal2() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryBigDecimal2());
} else if (carDTO.getcustomEntryBigDecimal3() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryBigDecimal3());
}
...
else if (carDTO.getcustomEntryBigDecimal50() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryBigDecimal50());
}
} else if (carContent.getVariableType().equals(VariableType.INTEGER)) {
if (carDTO.getcustomEntryInteger1() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryInteger1());
} else if (carDTO.getcustomEntryInteger2() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryInteger2());
} else if (carDTO.getcustomEntryInteger3() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryInteger3());
}
...
else if (carDTO.getcustomEntryInteger50() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryInteger50());
}
} else if (carContent.getVariableType().equals(VariableType.ZONEDDATETIME)) {
if (carDTO.getcustomEntryDate1() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryDate1());
} else if (carDTO.getcustomEntryDate2() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryDate2());
} else if (carDTO.getcustomEntryDate3() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryDate3());
}
...
else if (carDTO.getcustomEntryDate50() != null) {
ReportUtils.setvalue(worksheet,carDTO.getcustomEntryDate50());
}
}
}
如果需要,我通过输入200取消了这些控件,但我正在寻找更优化和通用的版本。
例如;
carDTO.getcustomEntryString1()=“ test1”,
carDTO.getcustomEntryString2()=“ test2”,
carDTO.getcustomEntryString3()=“ test3”
字段carDTO.getcustomEntryString1(),carDTO.getcustomEntryString2(),carDTO.getcustomEntryString3()已满,但是在输入第一个(如果我为报告编写的代码中)后,它将保留条件并填充相同的数据。写入值为“ test1”的“ carDTO.getcustomEntryString1()”。
|-----------------------|----------------------|-----------------------|
| getcustomEntryString1 |getcustomEntryString2 | getcustomEntryString3 |
|-----------------------|----------------------|-----------------------|
| test1 | test1 | test1 |
|-----------------------|----------------------|-----------------------|
如何解决此问题并编写更优化的版本?
如何编写更优化和通用的而不是200?