mirror of
https://github.com/dataease/dataease.git
synced 2025-02-24 19:42:56 +08:00
Merge pull request #13366 from dataease/pr@dev-v2@fixds
fix: 修复导出数据格式化数值失败
This commit is contained in:
commit
d7ea2639c8
@ -17,6 +17,7 @@ import io.dataease.exception.DEException;
|
|||||||
import io.dataease.exportCenter.manage.ExportCenterManage;
|
import io.dataease.exportCenter.manage.ExportCenterManage;
|
||||||
import io.dataease.extensions.datasource.dto.DatasetTableFieldDTO;
|
import io.dataease.extensions.datasource.dto.DatasetTableFieldDTO;
|
||||||
import io.dataease.extensions.view.dto.ChartViewDTO;
|
import io.dataease.extensions.view.dto.ChartViewDTO;
|
||||||
|
import io.dataease.extensions.view.dto.ChartViewFieldBaseDTO;
|
||||||
import io.dataease.extensions.view.dto.ChartViewFieldDTO;
|
import io.dataease.extensions.view.dto.ChartViewFieldDTO;
|
||||||
import io.dataease.extensions.view.dto.FormatterCfgDTO;
|
import io.dataease.extensions.view.dto.FormatterCfgDTO;
|
||||||
import io.dataease.license.manage.F2CLicLimitedManage;
|
import io.dataease.license.manage.F2CLicLimitedManage;
|
||||||
@ -129,12 +130,14 @@ public class ChartDataServer implements ChartDataApi {
|
|||||||
request.setExcelTypes(dsTypes);
|
request.setExcelTypes(dsTypes);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(tableRow)) {
|
if (CollectionUtils.isNotEmpty(tableRow)) {
|
||||||
|
FormatterCfgDTO formatterCfgDTO = new FormatterCfgDTO();
|
||||||
for (Object[] objects : tableRow) {
|
for (Object[] objects : tableRow) {
|
||||||
for (int i = 0; i < viewDTO.getXAxis().size(); i++) {
|
for (int i = 0; i < viewDTO.getXAxis().size(); i++) {
|
||||||
if (viewDTO.getXAxis().get(i).getDeType().equals(DeTypeConstants.DE_INT) || viewDTO.getXAxis().get(i).getDeType().equals(DeTypeConstants.DE_FLOAT)) {
|
if (viewDTO.getXAxis().get(i).getDeType().equals(DeTypeConstants.DE_INT) || viewDTO.getXAxis().get(i).getDeType().equals(DeTypeConstants.DE_FLOAT)) {
|
||||||
try {
|
try {
|
||||||
objects[i] = valueFormatter(BigDecimal.valueOf(Double.valueOf(objects[i].toString())), viewDTO.getXAxis().get(i).getFormatterCfg());
|
objects[i] = valueFormatter(new BigDecimal(String.valueOf(objects[i])), viewDTO.getXAxis().get(i).getFormatterCfg() == null ? formatterCfgDTO : viewDTO.getXAxis().get(i).getFormatterCfg());
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
|
ignore.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,7 +152,7 @@ public class ChartDataServer implements ChartDataApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String valueFormatter(BigDecimal value, FormatterCfgDTO formatter) {
|
public static String valueFormatter(BigDecimal value, FormatterCfgDTO formatter) {
|
||||||
if (value == null || formatter == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String result;
|
String result;
|
||||||
|
@ -11,5 +11,5 @@ public class FormatterCfgDTO {
|
|||||||
private Integer unit = 1; // 换算单位
|
private Integer unit = 1; // 换算单位
|
||||||
private String suffix = ""; // 单位后缀
|
private String suffix = ""; // 单位后缀
|
||||||
private Integer decimalCount = 2; // 小数位数
|
private Integer decimalCount = 2; // 小数位数
|
||||||
private Boolean thousandSeparator = true; // 千分符
|
private Boolean thousandSeparator = false; // 千分符
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user