fix: 符号地图导出excel缺少字段

This commit is contained in:
fit2cloud-chenyw 2022-06-01 11:15:49 +08:00
parent 05963e8943
commit 4a62db8224
2 changed files with 14 additions and 4 deletions

View File

@ -787,7 +787,7 @@ public class ChartViewService {
data = datasourceProvider.getData(datasourceRequest); data = datasourceProvider.getData(datasourceRequest);
Map<String, Object> mapChart = pluginViewResult(pluginViewParam, view, data, isDrill); Map<String, Object> mapChart = pluginViewResult(pluginViewParam, view, data, isDrill);
Map<String, Object> mapTableNormal = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList); Map<String, Object> mapTableNormal = ChartDataBuild.transTableNormal(fieldMap, view, data, desensitizationList);
return uniteViewResult(datasourceRequest.getQuery(), mapChart, mapTableNormal, view, isDrill, drillFilters); return uniteViewResult(datasourceRequest.getQuery(), mapChart, mapTableNormal, view, isDrill, drillFilters);
// 如果是插件到此结束 // 如果是插件到此结束

View File

@ -859,9 +859,7 @@ public class ChartDataBuild {
// 表格 // 表格
public static Map<String, Object> transTableNormal(List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, ChartViewWithBLOBs view, List<String[]> data, List<ChartViewFieldDTO> extStack, List<String> desensitizationList) { public static Map<String, Object> transTableNormal(List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, ChartViewWithBLOBs view, List<String[]> data, List<ChartViewFieldDTO> extStack, List<String> desensitizationList) {
Map<String, Object> map = new TreeMap<>();
List<ChartViewFieldDTO> fields = new ArrayList<>(); List<ChartViewFieldDTO> fields = new ArrayList<>();
List<Map<String, Object>> tableRow = new ArrayList<>();
if (ObjectUtils.isNotEmpty(xAxis)) { if (ObjectUtils.isNotEmpty(xAxis)) {
fields.addAll(xAxis); fields.addAll(xAxis);
} }
@ -871,6 +869,18 @@ public class ChartDataBuild {
} }
} }
fields.addAll(yAxis); fields.addAll(yAxis);
return transTableNormal(fields, view, data, desensitizationList);
}
// 表格
public static Map<String, Object> transTableNormal(Map<String, List<ChartViewFieldDTO>> fieldMap, ChartViewWithBLOBs view, List<String[]> data, List<String> desensitizationList) {
List<ChartViewFieldDTO> fields = fieldMap.entrySet().stream().map(Map.Entry::getValue).flatMap(List::stream).collect(Collectors.toList());
return transTableNormal(fields, view, data, desensitizationList);
}
private static Map<String, Object> transTableNormal(List<ChartViewFieldDTO> fields, ChartViewWithBLOBs view, List<String[]> data, List<String> desensitizationList) {
Map<String, Object> map = new TreeMap<>();
List<Map<String, Object>> tableRow = new ArrayList<>();
data.forEach(ele -> { data.forEach(ele -> {
Map<String, Object> d = new HashMap<>(); Map<String, Object> d = new HashMap<>();
for (int i = 0; i < fields.size(); i++) { for (int i = 0; i < fields.size(); i++) {
@ -880,7 +890,7 @@ public class ChartDataBuild {
} }
ChartViewFieldDTO chartViewFieldDTO = fields.get(i); ChartViewFieldDTO chartViewFieldDTO = fields.get(i);
if (chartViewFieldDTO.getDeType() == 0 || chartViewFieldDTO.getDeType() == 1) { if (chartViewFieldDTO.getDeType() == 0 || chartViewFieldDTO.getDeType() == 1 || chartViewFieldDTO.getDeType() == 5) {
d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? "" : ele[i]); d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? "" : ele[i]);
} else if (chartViewFieldDTO.getDeType() == 2 || chartViewFieldDTO.getDeType() == 3) { } else if (chartViewFieldDTO.getDeType() == 2 || chartViewFieldDTO.getDeType() == 3) {
d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? null : new BigDecimal(ele[i]).setScale(2, RoundingMode.HALF_UP)); d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? null : new BigDecimal(ele[i]).setScale(2, RoundingMode.HALF_UP));