Commit 680df9b8 authored by sherlock's avatar sherlock

little bug

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