forked from github/dataease
fix(数据集): 修复小数类型字段出现科学计数的问题
This commit is contained in:
parent
eb835c4990
commit
3a5e0e5cc3
@ -50,6 +50,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -452,11 +453,17 @@ public class DatasetDataManage {
|
|||||||
LinkedHashMap<String, Object> obj = new LinkedHashMap<>();
|
LinkedHashMap<String, Object> obj = new LinkedHashMap<>();
|
||||||
if (row.length > 0) {
|
if (row.length > 0) {
|
||||||
for (int j = 0; j < fields.size(); j++) {
|
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())) {
|
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 {
|
} else {
|
||||||
obj.put(ObjectUtils.isNotEmpty(fields.get(j).getDataeaseName()) ?
|
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