fix: 优化首页监测数据查询
This commit is contained in:
parent
d255e2403c
commit
0514c15111
@ -215,18 +215,18 @@ public class AlongDetailServiceImpl extends ServiceImpl<AlongDetailMapper, SdAlo
|
|||||||
List<Map<String, Object>> dwtDataVoList = new ArrayList<>();
|
List<Map<String, Object>> dwtDataVoList = new ArrayList<>();
|
||||||
List<Map<String, Object>> wtvtDataVoList = new ArrayList<>();
|
List<Map<String, Object>> wtvtDataVoList = new ArrayList<>();
|
||||||
List<Map<String, Object>> hydropwDataVoList = new ArrayList<>();
|
List<Map<String, Object>> hydropwDataVoList = new ArrayList<>();
|
||||||
List<Map<String, Object>> pptnDataVoList = new ArrayList<>();
|
// List<Map<String, Object>> pptnDataVoList = new ArrayList<>();
|
||||||
List<Map<String, Object>> tmpDataVoList = new ArrayList<>();
|
List<Map<String, Object>> tmpDataVoList = new ArrayList<>();
|
||||||
List<Map<String, Object>> wtnpDataVoList;
|
List<Map<String, Object>> wtnpDataVoList;
|
||||||
|
|
||||||
if (wtrvInfo.getType() == 1) {
|
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<Date, List<Map<String, Object>>> wtvtDataVoMap;
|
Map<Date, List<Map<String, Object>>> wtvtDataVoMap;
|
||||||
if (wtrvInfo.getType() == 2) {
|
if (wtrvInfo.getType() == 2) {
|
||||||
iwtDataVoList.addAll(this.alongDetailMapper.getIwtrvDataList(wtrvInfo.getStcd(), null, startTime, endTime));
|
iwtDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getIwtrvDataList(wtrvInfo.getStcd(), null, startTime, endTime)));
|
||||||
wtvtDataVoList.addAll(this.alongDetailMapper.getWtvtDataList(null, wtrvInfo.getRstcd(), startTime, endTime));
|
wtvtDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getWtvtDataList(null, wtrvInfo.getRstcd(), startTime, endTime)));
|
||||||
wtvtDataVoMap = wtvtDataVoList.stream()
|
wtvtDataVoMap = wtvtDataVoList.stream()
|
||||||
.filter(it -> getDateValueIgnoreCase(it, "tm") != null)
|
.filter(it -> getDateValueIgnoreCase(it, "tm") != null)
|
||||||
.collect(Collectors.groupingBy(it -> getDateValueIgnoreCase(it, "tm")));
|
.collect(Collectors.groupingBy(it -> getDateValueIgnoreCase(it, "tm")));
|
||||||
@ -241,21 +241,24 @@ public class AlongDetailServiceImpl extends ServiceImpl<AlongDetailMapper, SdAlo
|
|||||||
.filter(it -> getDateValueIgnoreCase(it, "tm") != null)
|
.filter(it -> getDateValueIgnoreCase(it, "tm") != null)
|
||||||
.collect(Collectors.toMap(it -> getDateValueIgnoreCase(it, "tm"), Function.identity()));
|
.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<Date, Map<String, Object>> hydropwDataMap = hydropwDataVoList.stream()
|
Map<Date, Map<String, Object>> 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));
|
// pptnDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getPptnDataList(wtrvInfo.getStcd(), startTime, endTime)));
|
||||||
Map<Date, Map<String, Object>> pptnDataMap = pptnDataVoList.stream()
|
// Map<Date, Map<String, Object>> pptnDataMap = pptnDataVoList.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()));
|
||||||
|
|
||||||
tmpDataVoList.addAll(this.alongDetailMapper.getTmpDataList(wtrvInfo.getStcd(), startTime, endTime));
|
// tmpDataVoList.addAll(normalizeMapKeyList(this.alongDetailMapper.getTmpDataList(wtrvInfo.getStcd(), startTime, endTime)));
|
||||||
Map<Date, Map<String, Object>> tmpDataMap = tmpDataVoList.stream()
|
// Map<Date, Map<String, Object>> tmpDataMap = tmpDataVoList.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()));
|
||||||
|
|
||||||
Map<Integer, BigDecimal> wtnpDataMap = new HashMap<>();
|
Map<Integer, BigDecimal> wtnpDataMap = new HashMap<>();
|
||||||
if (StrUtil.isNotBlank(wtrvInfo.getRstcd())) {
|
if (StrUtil.isNotBlank(wtrvInfo.getRstcd())) {
|
||||||
wtnpDataVoList = this.alongDetailMapper.getNatureTmpDataList(wtrvInfo.getRstcd(), null);
|
wtnpDataVoList = normalizeMapKeyList(this.alongDetailMapper.getNatureTmpDataList(wtrvInfo.getRstcd(), null));
|
||||||
wtnpDataMap.putAll(wtnpDataVoList.stream()
|
wtnpDataMap.putAll(wtnpDataVoList.stream()
|
||||||
.filter(it -> getIntegerValueIgnoreCase(it, "mnth") != null)
|
.filter(it -> getIntegerValueIgnoreCase(it, "mnth") != null)
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
@ -276,8 +279,8 @@ public class AlongDetailServiceImpl extends ServiceImpl<AlongDetailMapper, SdAlo
|
|||||||
vo.put("type", wtrvInfo.getType());
|
vo.put("type", wtrvInfo.getType());
|
||||||
vo.put("natureTmp", wtnpDataMap.get(it.getMon()));
|
vo.put("natureTmp", wtnpDataMap.get(it.getMon()));
|
||||||
vo.put("hydropwDataVo", hydropwDataMap.get(it.getTm()));
|
vo.put("hydropwDataVo", hydropwDataMap.get(it.getTm()));
|
||||||
vo.put("pptnDataVo", pptnDataMap.get(it.getTm()));
|
// vo.put("pptnDataVo", pptnDataMap.get(it.getTm()));
|
||||||
vo.put("tmpDataVo", tmpDataMap.get(it.getTm()));
|
// vo.put("tmpDataVo", tmpDataMap.get(it.getTm()));
|
||||||
|
|
||||||
if (wtrvInfo.getType() == 1) {
|
if (wtrvInfo.getType() == 1) {
|
||||||
Map<String, Object> iwtVo = new HashMap<>();
|
Map<String, Object> iwtVo = new HashMap<>();
|
||||||
@ -354,6 +357,38 @@ public class AlongDetailServiceImpl extends ServiceImpl<AlongDetailMapper, SdAlo
|
|||||||
return dr;
|
return dr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Map<String, Object>> normalizeMapKeyList(List<Map<String, Object>> dataList) {
|
||||||
|
if (CollUtil.isEmpty(dataList)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return dataList.stream()
|
||||||
|
.map(this::normalizeMapKeys)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> normalizeMapKeys(Map<String, Object> source) {
|
||||||
|
if (source == null || source.isEmpty()) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
Map<String, Object> 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<String, Object> data, String key) {
|
private Object getValueIgnoreCase(Map<String, Object> data, String key) {
|
||||||
if (data == null || StrUtil.isBlank(key)) {
|
if (data == null || StrUtil.isBlank(key)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user