diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/impl/AlongDetailServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/impl/AlongDetailServiceImpl.java index b455ce4b..53be0477 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/impl/AlongDetailServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_env/wt/service/impl/AlongDetailServiceImpl.java @@ -215,18 +215,18 @@ public class AlongDetailServiceImpl extends ServiceImpl> dwtDataVoList = new ArrayList<>(); List> wtvtDataVoList = new ArrayList<>(); List> hydropwDataVoList = new ArrayList<>(); - List> pptnDataVoList = new ArrayList<>(); +// List> pptnDataVoList = new ArrayList<>(); List> tmpDataVoList = new ArrayList<>(); List> wtnpDataVoList; if (wtrvInfo.getType() == 1) { - dwtDataVoList.addAll(this.alongDetailMapper.getDwtrvDataList(wtrvInfo.getStcd(), null, startTime, endTime)); + dwtDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getDwtrvDataList(wtrvInfo.getStcd(), null, startTime, endTime))); } Map>> wtvtDataVoMap; if (wtrvInfo.getType() == 2) { - iwtDataVoList.addAll(this.alongDetailMapper.getIwtrvDataList(wtrvInfo.getStcd(), null, startTime, endTime)); - wtvtDataVoList.addAll(this.alongDetailMapper.getWtvtDataList(null, wtrvInfo.getRstcd(), startTime, endTime)); + iwtDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getIwtrvDataList(wtrvInfo.getStcd(), null, startTime, endTime))); + wtvtDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getWtvtDataList(null, wtrvInfo.getRstcd(), startTime, endTime))); wtvtDataVoMap = wtvtDataVoList.stream() .filter(it -> getDateValueIgnoreCase(it, "tm") != null) .collect(Collectors.groupingBy(it -> getDateValueIgnoreCase(it, "tm"))); @@ -241,21 +241,24 @@ public class AlongDetailServiceImpl extends ServiceImpl getDateValueIgnoreCase(it, "tm") != null) .collect(Collectors.toMap(it -> getDateValueIgnoreCase(it, "tm"), Function.identity())); - hydropwDataVoList.addAll(this.alongDetailMapper.getHydropwDataList(wtrvInfo.getStcd(), startTime, endTime)); + hydropwDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getHydropwDataList(wtrvInfo.getStcd(), startTime, endTime))); Map> hydropwDataMap = hydropwDataVoList.stream() - .collect(Collectors.toMap(it -> (Date) it.get("tm"), Function.identity())); + .filter(it -> getDateValueIgnoreCase(it, "tm") != null) + .collect(Collectors.toMap(it -> getDateValueIgnoreCase(it, "tm"), Function.identity())); - pptnDataVoList.addAll(this.alongDetailMapper.getPptnDataList(wtrvInfo.getStcd(), startTime, endTime)); - Map> pptnDataMap = pptnDataVoList.stream() - .collect(Collectors.toMap(it -> (Date) it.get("tm"), Function.identity())); +// pptnDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getPptnDataList(wtrvInfo.getStcd(), startTime, endTime))); +// Map> pptnDataMap = pptnDataVoList.stream() +// .filter(it -> getDateValueIgnoreCase(it, "tm") != null) +// .collect(Collectors.toMap(it -> getDateValueIgnoreCase(it, "tm"), Function.identity())); - tmpDataVoList.addAll(this.alongDetailMapper.getTmpDataList(wtrvInfo.getStcd(), startTime, endTime)); - Map> tmpDataMap = tmpDataVoList.stream() - .collect(Collectors.toMap(it -> (Date) it.get("tm"), Function.identity())); +// tmpDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getTmpDataList(wtrvInfo.getStcd(), startTime, endTime))); +// Map> tmpDataMap = tmpDataVoList.stream() +// .filter(it -> getDateValueIgnoreCase(it, "tm") != null) +// .collect(Collectors.toMap(it -> getDateValueIgnoreCase(it, "tm"), Function.identity())); Map wtnpDataMap = new HashMap<>(); if (StrUtil.isNotBlank(wtrvInfo.getRstcd())) { - wtnpDataVoList = this.alongDetailMapper.getNatureTmpDataList(wtrvInfo.getRstcd(), null); + wtnpDataVoList = normalizeMapKeyList(this.alongDetailMapper.getNatureTmpDataList(wtrvInfo.getRstcd(), null)); wtnpDataMap.putAll(wtnpDataVoList.stream() .filter(it -> getIntegerValueIgnoreCase(it, "mnth") != null) .collect(Collectors.toMap( @@ -276,8 +279,8 @@ public class AlongDetailServiceImpl extends ServiceImpl iwtVo = new HashMap<>(); @@ -354,6 +357,38 @@ public class AlongDetailServiceImpl extends ServiceImpl> normalizeMapKeyList(List> dataList) { + if (CollUtil.isEmpty(dataList)) { + return Collections.emptyList(); + } + return dataList.stream() + .map(this::normalizeMapKeys) + .collect(Collectors.toList()); + } + + private Map normalizeMapKeys(Map source) { + if (source == null || source.isEmpty()) { + return Collections.emptyMap(); + } + Map normalized = new LinkedHashMap<>(); + source.forEach((key, value) -> normalized.put(toLowerCamelKey(key), value)); + return normalized; + } + + private String toLowerCamelKey(String key) { + if (StrUtil.isBlank(key)) { + return key; + } + String trimmedKey = key.trim(); + if (trimmedKey.contains("_")) { + return StrUtil.toCamelCase(trimmedKey.toLowerCase(Locale.ROOT)); + } + if (trimmedKey.equals(trimmedKey.toUpperCase(Locale.ROOT))) { + return trimmedKey.toLowerCase(Locale.ROOT); + } + return Character.toLowerCase(trimmedKey.charAt(0)) + trimmedKey.substring(1); + } + private Object getValueIgnoreCase(Map data, String key) { if (data == null || StrUtil.isBlank(key)) { return null;