Merge pull request #13105 from dataease/pr@dev-v2@fix_ds_decimal

fix(数据集): 修复小数类型字段出现科学计数的问题
This commit is contained in:
xuwei-fit2cloud 2024-11-04 18:45:09 +08:00 committed by GitHub
commit 012f83c1c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
}
}
}