fix: 水质达标统计优化
This commit is contained in:
parent
7095dd459e
commit
0dea0c9ee0
@ -1413,10 +1413,28 @@ public class QgcExportServiceImpl implements IQgcExportService {
|
|||||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
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> wqStations = null;
|
||||||
List<StationInfo> engStations = null;
|
List<StationInfo> engStations = null;
|
||||||
if (hasWq && !stationCodes.isEmpty()) {
|
if (hasWq && !stationCodes.isEmpty()) {
|
||||||
wqStations = yearStatMapper.selectList(
|
// 查询 V_MS_STBPRP_T 中 MWAY=2(自动站)的 WQ 测站
|
||||||
|
List<StationInfo> dbWqStations = yearStatMapper.selectList(
|
||||||
new LambdaQueryWrapper<StationInfo>()
|
new LambdaQueryWrapper<StationInfo>()
|
||||||
.eq(StationInfo::getSttp, "WQ")
|
.eq(StationInfo::getSttp, "WQ")
|
||||||
.eq(StationInfo::getMway, 2)
|
.eq(StationInfo::getMway, 2)
|
||||||
@ -1424,6 +1442,27 @@ public class QgcExportServiceImpl implements IQgcExportService {
|
|||||||
.or()
|
.or()
|
||||||
.in(StationInfo::getStcd, stationCodes))
|
.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()) {
|
if (!wqStations.isEmpty()) {
|
||||||
wqStations = sortStationsByOrder(wqStations);
|
wqStations = sortStationsByOrder(wqStations);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user