Commit 2ace9b19 authored by Eddie.Wu's avatar Eddie.Wu

Merge branch 'dev_mysql_chase_bug_1' into 'dev_mysql'

fix 报表计算小数位问题

See merge request root/atms!446
parents 6d9665a9 b38ab489
...@@ -174,6 +174,13 @@ public class ReportGeneratorImpl { ...@@ -174,6 +174,13 @@ public class ReportGeneratorImpl {
//如果有正则匹配就进行更新公式解析 //如果有正则匹配就进行更新公式解析
if (isFind) { if (isFind) {
periodCellTemplateConfig.setParsedFormula(StringUtils.isNotBlank(resultFormula) ? resultFormula : null); periodCellTemplateConfig.setParsedFormula(StringUtils.isNotBlank(resultFormula) ? resultFormula : null);
if (StringUtils.isNotBlank(resultFormula)) {
Pattern pattern = Pattern.compile("[0-9.]*");
Matcher isNum = pattern.matcher(resultFormula);
if (isNum.matches()) {
periodCellTemplateConfig.setParsedFormula(new BigDecimal(resultFormula).setScale(2, BigDecimal.ROUND_CEILING).toString());
}
}
periodCellTemplateConfigMapper.updateByPrimaryKeySelective(periodCellTemplateConfig); periodCellTemplateConfigMapper.updateByPrimaryKeySelective(periodCellTemplateConfig);
} }
...@@ -211,7 +218,7 @@ public class ReportGeneratorImpl { ...@@ -211,7 +218,7 @@ public class ReportGeneratorImpl {
Pattern pattern = Pattern.compile("[0-9.]*"); Pattern pattern = Pattern.compile("[0-9.]*");
Matcher isNum = pattern.matcher(data); Matcher isNum = pattern.matcher(data);
if (isNum.matches()) { if (isNum.matches()) {
cellData.setData(new BigDecimal(data).toString()); cellData.setData(new BigDecimal(data).setScale(2, BigDecimal.ROUND_CEILING).toString());
} else { } else {
cellData.setData(data); cellData.setData(data);
} }
...@@ -275,7 +282,13 @@ public class ReportGeneratorImpl { ...@@ -275,7 +282,13 @@ public class ReportGeneratorImpl {
cellData.setData("0.0"); cellData.setData("0.0");
if (StringUtils.isEmpty(cellData.getFormulaExp().trim())) if (StringUtils.isEmpty(cellData.getFormulaExp().trim()))
cellData.setFormulaExp("0.0"); cellData.setFormulaExp("0.0");
if (StringUtils.isNotBlank(cellData.getData())) {
Pattern pattern = Pattern.compile("[0-9.]*");
Matcher isNum = pattern.matcher(cellData.getData());
if (isNum.matches()) {
cellData.setData(new BigDecimal(cellData.getData()).setScale(2, BigDecimal.ROUND_CEILING).toString());
}
}
PeriodCellDataSource cellDataSource = new PeriodCellDataSource(); PeriodCellDataSource cellDataSource = new PeriodCellDataSource();
cellDataSource.setId(distributedIdService.nextId()); cellDataSource.setId(distributedIdService.nextId());
cellDataSource.setCellTemplateId(keyInCellTemplateConfig.getCellTemplateId()); cellDataSource.setCellTemplateId(keyInCellTemplateConfig.getCellTemplateId());
......
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