fix: 优化过鱼数据填报逻辑

This commit is contained in:
tangwei 2026-06-05 09:30:48 +08:00
parent af87b8ca9a
commit eddf659bc2
5 changed files with 288 additions and 164 deletions

View File

@ -12,6 +12,7 @@ import java.util.List;
public class SdEngInfoBHRequest {
private String baseId;
private String hbrvcd;
private String rvcd;
private List<String> basIds;
private List<String> hbrvcds;
private List<String> rvcds;

View File

@ -2,6 +2,7 @@ package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -84,11 +85,13 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
String baseId = sdEngInfoBHRequest.getBaseId();
String hbrvcd = sdEngInfoBHRequest.getHbrvcd();
String ennm = sdEngInfoBHRequest.getEnnm();
String rvcd = sdEngInfoBHRequest.getRvcd();
List<String> rvcds = sdEngInfoBHRequest.getRvcds();
List<String> hbrvcds = sdEngInfoBHRequest.getHbrvcds();
LambdaQueryWrapper<SdEngInfoBH> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.hasText(baseId), SdEngInfoBH::getBaseId, baseId)
.eq(StringUtils.hasText(hbrvcd), SdEngInfoBH::getHbrvcd, hbrvcd)
.eq(StrUtil.isNotBlank(rvcd), SdEngInfoBH::getRvcd, rvcd)
.in(rvcds != null && !rvcds.isEmpty(), SdEngInfoBH::getRvcd, rvcds)
.in(hbrvcds != null && !hbrvcds.isEmpty(), SdEngInfoBH::getHbrvcd, hbrvcds)
.like(StringUtils.hasText(ennm), SdEngInfoBH::getEnnm, ennm)

View File

@ -1095,21 +1095,25 @@ public class FishDraftDataController {
private void validateAndNormalizeData(FishDraftData data, FishImportResult.FishImportRow importRow,
List<String> warnings) {
if (data.getStcd() == null || data.getStcd().isEmpty()) {
warnings.add("stcd");
addWarning(warnings, "stcd");
} else {
String stcd = fishImportService.resolveFpssCode(data.getStcd(), data.getStnm());
if (stcd == null) {
warnings.add("stcd");
addWarning(warnings, "stcd");
} else {
data.setStcd(stcd);
}
}
if (data.getRstcd() != null && !data.getRstcd().isEmpty()) {
String stationCode = fishImportService.resolveStationCode(data.getRstcd(), data.getEnnm());
if (stationCode == null) {
warnings.add("rstcd");
addWarning(warnings, "rstcd");
} else {
data.setRstcd(stationCode);
}
} else {
warnings.add("rstcd");
addWarning(warnings, "rstcd");
}
// if (data.getBaseId() != null && !data.getBaseId().isEmpty()) {
@ -1122,14 +1126,18 @@ public class FishDraftDataController {
if (data.getHbrvcd() != null && !data.getHbrvcd().isEmpty()) {
String baseId = fishImportService.resolveHbrvcdCode(data.getHbrvcd(), data.getHbrvnm());
if (baseId == null) {
warnings.add("hbrvcd");
addWarning(warnings, "hbrvcd");
} else {
data.setHbrvcd(baseId);
}
}
if (data.getRvcd() != null && !data.getRvcd().isEmpty()) {
String rvcd = fishImportService.resolveRiverCode(data.getRvcd(), data.getRvcd());
String rvcd = fishImportService.resolveRiverCode(data.getRvcd(), data.getRvnm());
if (rvcd == null) {
warnings.add("rvcd");
addWarning(warnings, "rvcd");
} else {
data.setRvcd(rvcd);
}
}
@ -1145,55 +1153,64 @@ public class FishDraftDataController {
// }
if (data.getFtp() == null || data.getFtp().isEmpty()) {
warnings.add("ftp");
addWarning(warnings, "ftp");
} else {
String ftpCode = fishImportService.resolveFishDictCode(data.getFtp(), data.getFtpName());
if (ftpCode == null) {
warnings.add("ftp");
addWarning(warnings, "ftp");
} else {
data.setFtp(ftpCode);
}
}
if (data.getFcnt() == null) {
warnings.add("fcnt");
addWarning(warnings, "fcnt");
}
if (data.getStrdt() == null) {
warnings.add("strdt");
addWarning(warnings, "strdt");
}
if (data.getEnddt() != null && data.getStrdt() != null && data.getEnddt().before(data.getStrdt())) {
warnings.add("enddt");
addWarning(warnings, "enddt");
}
if (data.getDirection() == null || data.getDirection().isEmpty()) {
warnings.add("direction");
addWarning(warnings, "direction");
} else {
String direction = fishImportService.resolveDirection(data.getDirection().trim(), importRow);
if (direction == null) {
warnings.add("direction");
addWarning(warnings, "direction");
}
}
if (data.getIsfs() == null) {
warnings.add("isfs");
addWarning(warnings, "isfs");
} else {
String isfs = fishImportService.resolveIsfs(String.valueOf(data.getIsfs()), importRow);
if (isfs == null) {
warnings.add("isfs");
addWarning(warnings, "isfs");
}
}
if (StringUtils.hasText(data.getHbrvcd()) && StringUtils.hasText(data.getRstcd())) {
if (!fishImportService.validateStationBelongsToBase(data.getRstcd(), data.getHbrvcd())) {
warnings.add("hbrvcd");
warnings.add("rstcd");
addWarning(warnings, "hbrvcd");
addWarning(warnings, "rstcd");
}
}
if (StringUtils.hasText(data.getRvcd()) && StringUtils.hasText(data.getRstcd())) {
if (!fishImportService.validateStationBelongsToRiver(data.getRstcd(), data.getRvcd())) {
addWarning(warnings, "rvcd");
addWarning(warnings, "rstcd");
}
}
if (StringUtils.hasText(data.getRstcd()) && StringUtils.hasText(data.getStcd())) {
if (!fishImportService.validateFpssBelongsToStation(data.getStcd(), data.getRstcd())) {
warnings.add("stcd");
warnings.add("rstcd");
addWarning(warnings, "stcd");
addWarning(warnings, "rstcd");
}
}
@ -1202,6 +1219,12 @@ public class FishDraftDataController {
// }
}
private void addWarning(List<String> warnings, String field) {
if (!warnings.contains(field)) {
warnings.add(field);
}
}
@PostMapping("/validateAndMatchRow")
@Operation(summary = "校验数据并匹配到成功或失败列表")
public ResponseResult validateAndMatchRow(@RequestBody FishImportRowRequest request) {

View File

@ -50,6 +50,8 @@ public interface IFishImportService {
boolean validateStationBelongsToBase(String stationCode, String baseId);
boolean validateStationBelongsToRiver(String stationCode, String rvcd);
boolean validateFpssBelongsToStation(String fpssCode, String stationCode);
void processAttachments(FishImportResult result, ZipFileUtil.ZipContent zipContent);

View File

@ -831,248 +831,343 @@ public class FishImportServiceImpl implements IFishImportService {
public String resolveStationCode(String stationName) {
if (stationName == null) {
String normalizedName = normalizeInput(stationName);
if (!StringUtils.hasText(normalizedName)) {
return null;
}
String lowerName = stationName.toLowerCase().trim();
if (STATION_NAME_CACHE.containsKey(lowerName)) {
return STATION_NAME_CACHE.get(lowerName);
SdEngInfoBH exactMatch = findFirst(engInfoBHMapper.selectList(new LambdaQueryWrapper<SdEngInfoBH>()
.select(SdEngInfoBH::getStcd, SdEngInfoBH::getEnnm)
.eq(SdEngInfoBH::getEnnm, normalizedName)));
if (exactMatch != null) {
return exactMatch.getStcd();
}
for (Map.Entry<String, String> entry : STATION_NAME_CACHE.entrySet()) {
if (entry.getKey().contains(lowerName)) {
return entry.getValue();
}
}
return null;
SdEngInfoBH fuzzyMatch = findFirst(engInfoBHMapper.selectList(new LambdaQueryWrapper<SdEngInfoBH>()
.select(SdEngInfoBH::getStcd, SdEngInfoBH::getEnnm)
.like(SdEngInfoBH::getEnnm, normalizedName)));
return fuzzyMatch == null ? null : fuzzyMatch.getStcd();
}
public String resolveFpssCode(String name) {
if (name == null) {
String normalizedName = normalizeInput(name);
if (!StringUtils.hasText(normalizedName)) {
return null;
}
String lowerName = name.toLowerCase().trim();
if (FPSS_BH_CACHE.containsKey(lowerName)) {
return FPSS_BH_CACHE.get(lowerName);
SdFpssBH exactMatch = findFirst(fpssBHMapper.selectList(new LambdaQueryWrapper<SdFpssBH>()
.select(SdFpssBH::getStcd, SdFpssBH::getStnm, SdFpssBH::getRstcd)
.eq(SdFpssBH::getStnm, normalizedName)));
if (exactMatch != null) {
return exactMatch.getStcd();
}
for (Map.Entry<String, String> entry : FPSS_BH_CACHE.entrySet()) {
if (entry.getKey().contains(lowerName)) {
return entry.getValue();
}
}
return null;
SdFpssBH fuzzyMatch = findFirst(fpssBHMapper.selectList(new LambdaQueryWrapper<SdFpssBH>()
.select(SdFpssBH::getStcd, SdFpssBH::getStnm, SdFpssBH::getRstcd)
.like(SdFpssBH::getStnm, normalizedName)));
return fuzzyMatch == null ? null : fuzzyMatch.getStcd();
}
@Override
public String resolveStationCode(String code, String stationName) {
if (code == null && stationName == null) {
String normalizedCode = normalizeInput(code);
// String normalizedName = normalizeInput(stationName);
if (!StringUtils.hasText(normalizedCode)) {
return null;
}
loadStationAndBaseCache();
String lowerCode = code != null ? code.trim().toLowerCase() : null;
String lowerName = stationName != null ? stationName.trim().toLowerCase() : null;
if (lowerCode != null && lowerName != null) {
String cachedName = STATION_CODE_TO_NAME_CACHE.get(lowerCode);
if (cachedName != null && cachedName.equals(lowerName)) {
return code.trim();
if (StringUtils.hasText(normalizedCode)) {
SdEngInfoBH exact = findFirst(engInfoBHMapper.selectList(new LambdaQueryWrapper<SdEngInfoBH>()
.select(SdEngInfoBH::getStcd, SdEngInfoBH::getEnnm)
.eq(SdEngInfoBH::getStcd, normalizedCode)));
// .eq(SdEngInfoBH::getEnnm, normalizedName)));
if (exact != null) {
return exact.getStcd();
}
}
String resultByName = resolveStationCode(stationName);
if (resultByName != null && resultByName.equalsIgnoreCase(code)) {
return resultByName;
}
// if (StringUtils.hasText(normalizedCode)) {
// SdEngInfoBH byCode = engInfoBHMapper.selectById(normalizedCode);
// if (byCode != null && (!StringUtils.hasText(normalizedName) || normalizedName.equals(byCode.getEnnm()))) {
// return byCode.getStcd();
// }
// }
// if (StringUtils.hasText(normalizedName)) {
// String resultByName = resolveStationCode(normalizedName);
// if (!StringUtils.hasText(normalizedCode) || normalizedCode.equalsIgnoreCase(resultByName)) {
// return resultByName;
// }
// }
return null;
}
@Override
public String resolveFpssCode(String code, String name) {
if (code == null && name == null) {
String normalizedCode = normalizeInput(code);
// String normalizedName = normalizeInput(name);
if (!StringUtils.hasText(normalizedCode)) {
return null;
}
loadStationAndBaseCache();
String lowerCode = code != null ? code.trim().toLowerCase() : null;
String lowerName = name != null ? name.trim().toLowerCase() : null;
if (lowerCode != null && lowerName != null) {
String cachedName = FPSS_CODE_TO_NAME_CACHE.get(lowerCode);
if (cachedName != null && cachedName.equals(lowerName)) {
return code.trim();
if (StringUtils.hasText(normalizedCode)) {
SdFpssBH exact = findFirst(fpssBHMapper.selectList(new LambdaQueryWrapper<SdFpssBH>()
.select(SdFpssBH::getStcd, SdFpssBH::getStnm, SdFpssBH::getRstcd)
.eq(SdFpssBH::getStcd, normalizedCode)));
// .eq(SdFpssBH::getStnm, normalizedName)));
if (exact != null) {
return exact.getStcd();
}
}
String resultByName = resolveFpssCode(name);
if (resultByName != null && resultByName.equalsIgnoreCase(code)) {
return resultByName;
}
// if (StringUtils.hasText(normalizedCode)) {
// SdFpssBH byCode = fpssBHMapper.selectById(normalizedCode);
// if (byCode != null && (!StringUtils.hasText(normalizedName) || normalizedName.equals(byCode.getStnm()))) {
// return byCode.getStcd();
// }
// }
// if (StringUtils.hasText(normalizedName)) {
// String resultByName = resolveFpssCode(normalizedName);
// if (!StringUtils.hasText(normalizedCode) || normalizedCode.equalsIgnoreCase(resultByName)) {
// return resultByName;
// }
// }
return null;
}
public String resolveFishDictCode(String name) {
if (name == null) {
String normalizedName = normalizeInput(name);
if (!StringUtils.hasText(normalizedName)) {
return null;
}
String lowerName = name.toLowerCase().trim();
if (FISH_DICT_CACHE.containsKey(lowerName)) {
return FISH_DICT_CACHE.get(lowerName);
SdFishDictoryB exactMatch = findFirst(fishDictoryBMapper.selectList(new LambdaQueryWrapper<SdFishDictoryB>()
.select(SdFishDictoryB::getCode, SdFishDictoryB::getName)
.eq(SdFishDictoryB::getName, normalizedName)));
if (exactMatch != null) {
return exactMatch.getCode();
}
for (Map.Entry<String, String> entry : FISH_DICT_CACHE.entrySet()) {
if (entry.getKey().contains(lowerName) || lowerName.contains(entry.getKey())) {
return entry.getValue();
}
}
return null;
SdFishDictoryB fuzzyMatch = findFirst(fishDictoryBMapper.selectList(new LambdaQueryWrapper<SdFishDictoryB>()
.select(SdFishDictoryB::getCode, SdFishDictoryB::getName)
.and(wrapper -> wrapper.like(SdFishDictoryB::getName, normalizedName)
.or()
.like(SdFishDictoryB::getAlias, normalizedName))));
return fuzzyMatch == null ? null : fuzzyMatch.getCode();
}
@Override
public String resolveFishDictCode(String code, String name) {
if (code == null && name == null) {
String normalizedCode = normalizeInput(code);
// String normalizedName = normalizeInput(name);
if (!StringUtils.hasText(normalizedCode)) {
return null;
}
loadStationAndBaseCache();
String lowerCode = code != null ? code.trim().toLowerCase() : null;
String lowerName = name != null ? name.trim().toLowerCase() : null;
if (lowerCode != null && lowerName != null) {
String cachedName = FISH_CODE_TO_NAME_CACHE.get(lowerCode);
if (cachedName != null && cachedName.equals(lowerName)) {
return code.trim();
if (StringUtils.hasText(normalizedCode)) {
SdFishDictoryB exact = findFirst(fishDictoryBMapper.selectList(new LambdaQueryWrapper<SdFishDictoryB>()
.select(SdFishDictoryB::getCode, SdFishDictoryB::getName)
.eq(SdFishDictoryB::getCode, normalizedCode)));
// .eq(SdFishDictoryB::getName, normalizedName)));
if (exact != null) {
return exact.getCode();
}
}
String resultByName = resolveFishDictCode(name);
if (resultByName != null && resultByName.equalsIgnoreCase(code)) {
return resultByName;
}
// if (StringUtils.hasText(normalizedCode)) {
// SdFishDictoryB byCode = findFirst(fishDictoryBMapper.selectList(new LambdaQueryWrapper<SdFishDictoryB>()
// .select(SdFishDictoryB::getCode, SdFishDictoryB::getName)
// .eq(SdFishDictoryB::getCode, normalizedCode)));
// if (byCode != null && (!StringUtils.hasText(normalizedName) || normalizedName.equals(byCode.getName()))) {
// return byCode.getCode();
// }
// }
// if (StringUtils.hasText(normalizedName)) {
// String resultByName = resolveFishDictCode(normalizedName);
// if (!StringUtils.hasText(normalizedCode) || normalizedCode.equalsIgnoreCase(resultByName)) {
// return resultByName;
// }
// }
return null;
}
public String resolveBaseCode(String baseName) {
if (baseName == null) {
String normalizedName = normalizeInput(baseName);
if (!StringUtils.hasText(normalizedName)) {
return null;
}
String lowerName = baseName.toLowerCase().trim();
if (BASE_NAME_CACHE.containsKey(lowerName)) {
return BASE_NAME_CACHE.get(lowerName);
SdHydrobase exactMatch = findFirst(hydrobaseMapper.selectList(new LambdaQueryWrapper<SdHydrobase>()
.select(SdHydrobase::getBaseid, SdHydrobase::getBasename)
.eq(SdHydrobase::getBasename, normalizedName)));
if (exactMatch != null) {
return exactMatch.getBaseid();
}
for (Map.Entry<String, String> entry : BASE_NAME_CACHE.entrySet()) {
if (entry.getKey().contains(lowerName)) {
return entry.getValue();
}
}
return null;
SdHydrobase fuzzyMatch = findFirst(hydrobaseMapper.selectList(new LambdaQueryWrapper<SdHydrobase>()
.select(SdHydrobase::getBaseid, SdHydrobase::getBasename)
.like(SdHydrobase::getBasename, normalizedName)));
return fuzzyMatch == null ? null : fuzzyMatch.getBaseid();
}
@Override
public String resolveBaseCode(String code, String baseName) {
if (code == null && baseName == null) {
String normalizedCode = normalizeInput(code);
String normalizedName = normalizeInput(baseName);
if (!StringUtils.hasText(normalizedCode) && !StringUtils.hasText(normalizedName)) {
return null;
}
loadStationAndBaseCache();
String lowerCode = code != null ? code.trim().toLowerCase() : null;
String lowerName = baseName != null ? baseName.trim().toLowerCase() : null;
if (lowerCode != null && lowerName != null) {
String cachedName = BASE_CODE_TO_NAME_CACHE.get(lowerCode);
if (cachedName != null && cachedName.equals(lowerName)) {
return code.trim();
if (StringUtils.hasText(normalizedCode) && StringUtils.hasText(normalizedName)) {
SdHydrobase exact = findFirst(hydrobaseMapper.selectList(new LambdaQueryWrapper<SdHydrobase>()
.select(SdHydrobase::getBaseid, SdHydrobase::getBasename)
.eq(SdHydrobase::getBaseid, normalizedCode)
.eq(SdHydrobase::getBasename, normalizedName)));
if (exact != null) {
return exact.getBaseid();
}
}
String resultByName = resolveBaseCode(baseName);
if (resultByName != null && resultByName.equalsIgnoreCase(code)) {
if (StringUtils.hasText(normalizedCode)) {
SdHydrobase byCode = hydrobaseMapper.selectById(normalizedCode);
if (byCode != null && (!StringUtils.hasText(normalizedName) || normalizedName.equals(byCode.getBasename()))) {
return byCode.getBaseid();
}
}
if (StringUtils.hasText(normalizedName)) {
String resultByName = resolveBaseCode(normalizedName);
if (!StringUtils.hasText(normalizedCode) || normalizedCode.equalsIgnoreCase(resultByName)) {
return resultByName;
}
}
return null;
}
public String resolveRiverCode(String riverName) {
if (riverName == null) {
String normalizedName = normalizeInput(riverName);
if (!StringUtils.hasText(normalizedName)) {
return null;
}
String lowerName = riverName.toLowerCase().trim();
if (RIVER_NAME_CACHE.containsKey(lowerName)) {
return RIVER_NAME_CACHE.get(lowerName);
SdRvcdDic exactMatch = findFirst(rvcdDicMapper.selectList(new LambdaQueryWrapper<SdRvcdDic>()
.select(SdRvcdDic::getRvcd, SdRvcdDic::getRvnm)
.eq(SdRvcdDic::getRvnm, normalizedName)));
if (exactMatch != null) {
return exactMatch.getRvcd();
}
for (Map.Entry<String, String> entry : RIVER_NAME_CACHE.entrySet()) {
if (entry.getKey().contains(lowerName)) {
return entry.getValue();
}
}
return null;
SdRvcdDic fuzzyMatch = findFirst(rvcdDicMapper.selectList(new LambdaQueryWrapper<SdRvcdDic>()
.select(SdRvcdDic::getRvcd, SdRvcdDic::getRvnm)
.like(SdRvcdDic::getRvnm, normalizedName)));
return fuzzyMatch == null ? null : fuzzyMatch.getRvcd();
}
public String resolveHbrvcdCode(String riverName) {
if (riverName == null) {
String normalizedName = normalizeInput(riverName);
if (!StringUtils.hasText(normalizedName)) {
return null;
}
String lowerName = riverName.toLowerCase().trim();
if (HBRVCD_NAME_CACHE.containsKey(lowerName)) {
return HBRVCD_NAME_CACHE.get(lowerName);
SdHbrvDic exactMatch = findFirst(sdHbrvDicMapper.selectList(new LambdaQueryWrapper<SdHbrvDic>()
.select(SdHbrvDic::getHbrvcd, SdHbrvDic::getHbrvnm)
.eq(SdHbrvDic::getHbrvnm, normalizedName)));
if (exactMatch != null) {
return exactMatch.getHbrvcd();
}
for (Map.Entry<String, String> entry : HBRVCD_NAME_CACHE.entrySet()) {
if (entry.getKey().contains(lowerName)) {
return entry.getValue();
}
}
return null;
SdHbrvDic fuzzyMatch = findFirst(sdHbrvDicMapper.selectList(new LambdaQueryWrapper<SdHbrvDic>()
.select(SdHbrvDic::getHbrvcd, SdHbrvDic::getHbrvnm)
.like(SdHbrvDic::getHbrvnm, normalizedName)));
return fuzzyMatch == null ? null : fuzzyMatch.getHbrvcd();
}
@Override
public String resolveRiverCode(String code, String riverName) {
if (code == null && riverName == null) {
String normalizedCode = normalizeInput(code);
// String normalizedName = normalizeInput(riverName);
if (!StringUtils.hasText(normalizedCode)) {
return null;
}
loadStationAndBaseCache();
String lowerCode = code != null ? code.trim().toLowerCase() : null;
String lowerName = riverName != null ? riverName.trim().toLowerCase() : null;
if (lowerCode != null && lowerName != null) {
String cachedName = RIVER_CODE_TO_NAME_CACHE.get(lowerCode);
if (cachedName != null && cachedName.equals(lowerName)) {
return code.trim();
if (StringUtils.hasText(normalizedCode)) {
SdRvcdDic exact = findFirst(rvcdDicMapper.selectList(new LambdaQueryWrapper<SdRvcdDic>()
.select(SdRvcdDic::getRvcd, SdRvcdDic::getRvnm)
.eq(SdRvcdDic::getRvcd, normalizedCode)));
// .eq(SdRvcdDic::getRvnm, normalizedName)));
if (exact != null) {
return exact.getRvcd();
}
}
String resultByName = resolveRiverCode(riverName);
if (resultByName != null && resultByName.equalsIgnoreCase(code)) {
return resultByName;
}
// if (StringUtils.hasText(normalizedCode)) {
// SdRvcdDic byCode = rvcdDicMapper.selectById(normalizedCode);
// if (byCode != null && (!StringUtils.hasText(normalizedName) || normalizedName.equals(byCode.getRvnm()))) {
// return byCode.getRvcd();
// }
// }
// if (StringUtils.hasText(normalizedName)) {
// String resultByName = resolveRiverCode(normalizedName);
// if (!StringUtils.hasText(normalizedCode) || normalizedCode.equalsIgnoreCase(resultByName)) {
// return resultByName;
// }
// }
return null;
}
@Override
public String resolveHbrvcdCode(String code, String riverName) {
if (code == null && riverName == null) {
String normalizedCode = normalizeInput(code);
// String normalizedName = normalizeInput(riverName);
if (!StringUtils.hasText(normalizedCode)) {
return null;
}
loadStationAndBaseCache();
String lowerCode = code != null ? code.trim().toLowerCase() : null;
String lowerName = riverName != null ? riverName.trim().toLowerCase() : null;
if (lowerCode != null && lowerName != null) {
String cachedName = HBRVCD_CODE_TO_NAME_CACHE.get(lowerCode);
if (cachedName != null && cachedName.equals(lowerName)) {
return code.trim();
if (StringUtils.hasText(normalizedCode)) {
SdHbrvDic exact = findFirst(sdHbrvDicMapper.selectList(new LambdaQueryWrapper<SdHbrvDic>()
.select(SdHbrvDic::getHbrvcd, SdHbrvDic::getHbrvnm)
.eq(SdHbrvDic::getHbrvcd, normalizedCode)));
// .eq(SdHbrvDic::getHbrvnm, normalizedName)));
if (exact != null) {
return exact.getHbrvcd();
}
}
String resultByName = resolveHbrvcdCode(riverName);
if (resultByName != null && resultByName.equalsIgnoreCase(code)) {
return resultByName;
}
// if (StringUtils.hasText(normalizedCode)) {
// SdHbrvDic byCode = sdHbrvDicMapper.selectById(normalizedCode);
// if (byCode != null && (!StringUtils.hasText(normalizedName) || normalizedName.equals(byCode.getHbrvnm()))) {
// return byCode.getHbrvcd();
// }
// }
// if (StringUtils.hasText(normalizedName)) {
// String resultByName = resolveHbrvcdCode(normalizedName);
// if (!StringUtils.hasText(normalizedCode) || normalizedCode.equalsIgnoreCase(resultByName)) {
// return resultByName;
// }
// }
return null;
}
@Override
public boolean validateStationBelongsToBase(String stationCode, String baseId) {
if (stationCode == null || baseId == null) {
String normalizedStationCode = normalizeInput(stationCode);
String normalizedBaseId = normalizeInput(baseId);
if (!StringUtils.hasText(normalizedStationCode) || !StringUtils.hasText(normalizedBaseId)) {
return false;
}
loadStationAndBaseCache();
String stationLower = stationCode.trim().toLowerCase();
String cachedBaseId = STATION_TO_BASE_CACHE.get(stationLower);
return baseId.equalsIgnoreCase(cachedBaseId);
return findFirst(engInfoBHMapper.selectList(new LambdaQueryWrapper<SdEngInfoBH>()
.select(SdEngInfoBH::getStcd)
.eq(SdEngInfoBH::getStcd, normalizedStationCode)
.eq(SdEngInfoBH::getHbrvcd, normalizedBaseId))) != null;
}
@Override
public boolean validateStationBelongsToRiver(String stationCode, String rvcd) {
String normalizedStationCode = normalizeInput(stationCode);
String normalizedRvcd = normalizeInput(rvcd);
if (!StringUtils.hasText(normalizedStationCode) || !StringUtils.hasText(normalizedRvcd)) {
return false;
}
return findFirst(engInfoBHMapper.selectList(new LambdaQueryWrapper<SdEngInfoBH>()
.select(SdEngInfoBH::getStcd)
.eq(SdEngInfoBH::getStcd, normalizedStationCode)
.eq(SdEngInfoBH::getRvcd, normalizedRvcd))) != null;
}
@Override
public boolean validateFpssBelongsToStation(String fpssCode, String stationCode) {
if (fpssCode == null || stationCode == null) {
String normalizedFpssCode = normalizeInput(fpssCode);
String normalizedStationCode = normalizeInput(stationCode);
if (!StringUtils.hasText(normalizedFpssCode) || !StringUtils.hasText(normalizedStationCode)) {
return false;
}
loadStationAndBaseCache();
String fpssLower = fpssCode.trim().toLowerCase();
String cachedStationCode = FPSS_TO_STATION_CACHE.get(fpssLower);
return stationCode.equalsIgnoreCase(cachedStationCode);
return findFirst(fpssBHMapper.selectList(new LambdaQueryWrapper<SdFpssBH>()
.select(SdFpssBH::getStcd)
.eq(SdFpssBH::getStcd, normalizedFpssCode)
.eq(SdFpssBH::getRstcd, normalizedStationCode))) != null;
}
private String normalizeInput(String value) {
return StringUtils.hasText(value) ? value.trim() : null;
}
private <T> T findFirst(List<T> list) {
return list == null || list.isEmpty() ? null : list.get(0);
}
private String validateFishType(String fishName, FishImportResult.FishImportRow importRow) {