From 0dea0c9ee00582509d853ce718a85975044b8d70 Mon Sep 17 00:00:00 2001 From: tangwei Date: Fri, 7 Aug 2026 10:57:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B0=B4=E8=B4=A8=E8=BE=BE=E6=A0=87?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/QgcExportServiceImpl.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/yfd/platform/qgc_export/service/impl/QgcExportServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_export/service/impl/QgcExportServiceImpl.java index 68c0cba9..e3d8497f 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_export/service/impl/QgcExportServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_export/service/impl/QgcExportServiceImpl.java @@ -1413,10 +1413,28 @@ public class QgcExportServiceImpl implements IQgcExportService { String timestamp = String.valueOf(System.currentTimeMillis()); // 预查询测站信息(年维度无关,一次查询即可) + // 先查所有电站名称(不限 STTP),用于占位电站显示名称 + Map allStationNames = new LinkedHashMap<>(); + if (!stationCodes.isEmpty()) { + List allStations = yearStatMapper.selectList( + new LambdaQueryWrapper() + .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 wqStations = null; List engStations = null; if (hasWq && !stationCodes.isEmpty()) { - wqStations = yearStatMapper.selectList( + // 查询 V_MS_STBPRP_T 中 MWAY=2(自动站)的 WQ 测站 + List dbWqStations = yearStatMapper.selectList( new LambdaQueryWrapper() .eq(StationInfo::getSttp, "WQ") .eq(StationInfo::getMway, 2) @@ -1424,6 +1442,27 @@ public class QgcExportServiceImpl implements IQgcExportService { .or() .in(StationInfo::getStcd, stationCodes)) ); + // 按前端传的 stationCodes 顺序构建完整列表(无数据的电站也显示空行) + Map 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); }