diff --git a/src/main/java/neatlogic/module/report/service/ReportServiceImpl.java b/src/main/java/neatlogic/module/report/service/ReportServiceImpl.java index 8fe625d53d09987547e8b1a17b7d3cfc5dda3e7c..6cbbbf631430ba41981fe561e04f2d6a65117a11 100644 --- a/src/main/java/neatlogic/module/report/service/ReportServiceImpl.java +++ b/src/main/java/neatlogic/module/report/service/ReportServiceImpl.java @@ -123,15 +123,19 @@ public class ReportServiceImpl implements ReportService { private List> selectTableColumns(List showColumnList, List> tmpList) { /* 筛选表格显示列 */ - for (Map map : tmpList) { - map.entrySet().removeIf(stringObjectEntry -> !showColumnList.contains(stringObjectEntry.getKey())); - } +// for (Map map : tmpList) { +// map.entrySet().removeIf(stringObjectEntry -> !showColumnList.contains(stringObjectEntry.getKey())); +// } /* 排序 */ List> sqList = new ArrayList<>(); for (Map map : tmpList) { Map _map = new LinkedHashMap<>(); for (String s : showColumnList) { - _map.put(s, map.get(s)); + Object value = map.get(s); + if (value == null) { + value = "null"; + } + _map.put(s, value); } sqList.add(_map); } @@ -343,14 +347,26 @@ public class ReportServiceImpl implements ReportService { if (object == null) { continue; } + List propertyList = sqlInfo.getPropertyList(); if (object instanceof List) { List> resultList = new ArrayList<>(); List list = (List) object; for (Object obj : list) { if (obj instanceof Map) { + Map map = (Map) obj; Map hashMap = new LinkedHashMap<>(); - for (Map.Entry entity : ((Map) obj).entrySet()) { - hashMap.put((String) entity.getKey(), entity.getValue()); + if (CollectionUtils.isNotEmpty(propertyList)) { + for (String property : propertyList) { + Object value = map.get(property); + if (value == null) { + value = "null"; + } + hashMap.put(property, value); + } + } else { + for (Map.Entry entity : map.entrySet()) { + hashMap.put((String) entity.getKey(), entity.getValue()); + } } resultList.add(hashMap); } @@ -414,14 +430,32 @@ public class ReportServiceImpl implements ReportService { if (object == null) { return resultMap; } + List propertyList = new ArrayList<>(); + for (SqlInfo sqlInfo : sqlInfoList) { + if (Objects.equals(sqlInfo.getId(), id)) { + propertyList = sqlInfo.getPropertyList(); + break; + } + } if (object instanceof List) { List> resultList = new ArrayList<>(); List list = (List) object; for (Object obj : list) { if (obj instanceof Map) { - Map hashMap = new HashMap<>(); - for (Map.Entry entity : ((Map) obj).entrySet()) { - hashMap.put((String) entity.getKey(), entity.getValue()); + Map map = (Map) obj; + Map hashMap = new LinkedHashMap<>(); + if (CollectionUtils.isNotEmpty(propertyList)) { + for (String property : propertyList) { + Object value = map.get(property); + if (value == null) { + value = "null"; + } + hashMap.put(property, value); + } + } else { + for (Map.Entry entity : map.entrySet()) { + hashMap.put((String) entity.getKey(), entity.getValue()); + } } resultList.add(hashMap); }