forked from github/dataease
Merge pull request #13105 from dataease/pr@dev-v2@fix_ds_decimal
fix(数据集): 修复小数类型字段出现科学计数的问题
This commit is contained in:
commit
012f83c1c6
@ -50,6 +50,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -452,11 +453,17 @@ public class DatasetDataManage {
|
||||
LinkedHashMap<String, Object> obj = new LinkedHashMap<>();
|
||||
if (row.length > 0) {
|
||||
for (int j = 0; j < fields.size(); j++) {
|
||||
// 如果字段类型是数值类型的小数,将结果保留8位小数,同时去除科学计数
|
||||
String res = row[j];
|
||||
if (fields.get(j).getDeType() == 3) {
|
||||
BigDecimal bigDecimal = new BigDecimal(res);
|
||||
res = String.format("%.8f", bigDecimal);
|
||||
}
|
||||
if (desensitizationList.keySet().contains(fields.get(j).getDataeaseName())) {
|
||||
obj.put(fields.get(j).getDataeaseName(), ChartDataBuild.desensitizationValue(desensitizationList.get(fields.get(j).getDataeaseName()), String.valueOf(row[j])));
|
||||
obj.put(fields.get(j).getDataeaseName(), ChartDataBuild.desensitizationValue(desensitizationList.get(fields.get(j).getDataeaseName()), String.valueOf(res)));
|
||||
} else {
|
||||
obj.put(ObjectUtils.isNotEmpty(fields.get(j).getDataeaseName()) ?
|
||||
fields.get(j).getDataeaseName() : fields.get(j).getOriginName(), row[j]);
|
||||
fields.get(j).getDataeaseName() : fields.get(j).getOriginName(), res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user