fix: 水质达标统计优化

This commit is contained in:
tangwei 2026-08-07 10:57:14 +08:00
parent 7095dd459e
commit 0dea0c9ee0

View File

@ -1413,10 +1413,28 @@ public class QgcExportServiceImpl implements IQgcExportService {
String timestamp = String.valueOf(System.currentTimeMillis());
// 预查询测站信息年维度无关一次查询即可
// 先查所有电站名称不限 STTP用于占位电站显示名称
Map<String, String> allStationNames = new LinkedHashMap<>();
if (!stationCodes.isEmpty()) {
List<StationInfo> allStations = yearStatMapper.selectList(
new LambdaQueryWrapper<StationInfo>()
.and(w -> w.in(StationInfo::getRstcd, stationCodes)
.or()
.in(StationInfo::getStcd, stationCodes))
);
for (StationInfo s : allStations) {
String key = s.getRstcd() != null ? s.getRstcd() : s.getStcd();
// 取第一个非空名称ENNM > STNM > key
String name = s.getEnnm() != null ? s.getEnnm() : s.getStnm();
allStationNames.putIfAbsent(key, name != null ? name : key);
}
}
List<StationInfo> wqStations = null;
List<StationInfo> engStations = null;
if (hasWq && !stationCodes.isEmpty()) {
wqStations = yearStatMapper.selectList(
// 查询 V_MS_STBPRP_T MWAY=2自动站 WQ 测站
List<StationInfo> dbWqStations = yearStatMapper.selectList(
new LambdaQueryWrapper<StationInfo>()
.eq(StationInfo::getSttp, "WQ")
.eq(StationInfo::getMway, 2)
@ -1424,6 +1442,27 @@ public class QgcExportServiceImpl implements IQgcExportService {
.or()
.in(StationInfo::getStcd, stationCodes))
);
// 按前端传的 stationCodes 顺序构建完整列表无数据的电站也显示空行
Map<String, StationInfo> rstcdMap = new LinkedHashMap<>();
for (StationInfo s : dbWqStations) {
String key = s.getRstcd() != null ? s.getRstcd() : s.getStcd();
rstcdMap.putIfAbsent(key, s);
}
wqStations = new ArrayList<>();
for (String code : stationCodes) {
StationInfo found = rstcdMap.get(code);
if (found != null) {
wqStations.add(found);
} else {
// WQ 自动站数据的电站从名称映射中取名称
String name = allStationNames.getOrDefault(code, code);
StationInfo placeholder = new StationInfo();
placeholder.setRstcd(code);
placeholder.setStcd(code);
placeholder.setEnnm(name);
wqStations.add(placeholder);
}
}
if (!wqStations.isEmpty()) {
wqStations = sortStationsByOrder(wqStations);
}