Commit 680df9b8 authored by sherlock's avatar sherlock

little bug

parent b5c11386
......@@ -3,9 +3,8 @@ package pwc.taxtech.atms.thirdparty;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.math.BigDecimal;
import java.text.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
......@@ -50,6 +49,7 @@ public class ExcelUtil {
private static Logger LG = LoggerFactory.getLogger(ExcelUtil.class);
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###,###.00");
/**
* 用来验证excel与Vo中的类型是否一致 <br>
* Map<栏位类型,只能是哪些Cell类型>
......@@ -343,6 +343,8 @@ public class ExcelUtil {
if (value instanceof Integer) {
int intValue = (Integer) value;
cell.setCellValue(intValue);
} else if(value instanceof BigDecimal){
textValue = DECIMAL_FORMAT.format(value);
} else if (value instanceof Float) {
float fValue = (Float) value;
cell.setCellValue(fValue);
......
......@@ -199,24 +199,24 @@ public class ReportGeneratorImpl {
dataSource.setColumnIndex(colNum - 1);
dataSource.setRowIndex(rowNum - 1);
if (((XSSFCell) cell).getRawValue() != "#VALUE!") {
if(StringUtils.isNotBlank(cell.getStringCellValue())
&& StringUtils.isNumeric(cell.getStringCellValue().replace(".", ""))){
dataSource.setAmount(new BigDecimal(cell.getStringCellValue()));
}
else if(StringUtils.isBlank(cell.getStringCellValue())){
dataSource.setAmount(new BigDecimal(Double.toString(cell.getNumericCellValue())));
}
// else {
// cell.setCellFormula(cell.getStringCellValue());
// FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
// dataSource.setAmount(new BigDecimal(formulaEvaluator.evaluate(cell).getNumberValue()));
// if(StringUtils.isNotBlank(cell.getStringCellValue())
// && StringUtils.isNumeric(cell.getStringCellValue().replace(".", ""))){
// dataSource.setAmount(new BigDecimal(cell.getStringCellValue()));
// }
// else if(StringUtils.isBlank(cell.getStringCellValue())){
// dataSource.setAmount(new BigDecimal(Double.toString(cell.getNumericCellValue())));
// }
// dataSource.setAmount(new BigDecimal(
// ((XSSFCell) cell).getRawValue() != null ?
// ((XSSFCell) cell).getRawValue()
// : (StringUtils.isNotBlank(cell.getStringCellValue())) ?
// cell.getStringCellValue()
// : Double.toString(cell.getNumericCellValue())));
//// else {
//// cell.setCellFormula(cell.getStringCellValue());
//// FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
//// dataSource.setAmount(new BigDecimal(formulaEvaluator.evaluate(cell).getNumberValue()));
//// }
dataSource.setAmount(new BigDecimal(
((XSSFCell) cell).getRawValue() != null ?
((XSSFCell) cell).getRawValue()
: (StringUtils.isNotBlank(cell.getStringCellValue())) ?
cell.getStringCellValue()
: Double.toString(cell.getNumericCellValue())));
} else {
dataSource.setAmount(new BigDecimal("0.0"));
}
......
......@@ -122,7 +122,7 @@ public class ReportServiceImpl {
periodTemplateList.stream().forEach(x -> ids.add(x.getTemplateId() + ""));
List<ReportDto> reportDtos = result.getData().stream().filter(x -> {
return ids.contains(x.getTemplateId());
return x.getId() != null && ids.contains(x.getTemplateId());
}).collect(Collectors.toList());
result.setData(reportDtos);
return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment