fix: 优化过鱼逻辑

This commit is contained in:
tangwei 2026-06-05 13:00:19 +08:00
parent 62f50fd96b
commit de8409bde4
8 changed files with 50 additions and 42 deletions

View File

@ -59,8 +59,10 @@ public class SdFpssBHController {
@Operation(summary = "设施下拉列表(根据电站编码筛选 + 支持名称模糊搜索 + 支持基地编码筛选)")
public ResponseResult dropdown(@RequestParam(required = false) String rstcd,
@RequestParam(required = false) String stnm,
@RequestParam(required = false) String baseId) {
return ResponseResult.successData(sdFpssBHService.selectForDropdown(rstcd, stnm, baseId));
@RequestParam(required = false) String baseId,
@RequestParam(required = false) String rvcd,
@RequestParam(required = false) String reachcd) {
return ResponseResult.successData(sdFpssBHService.selectForDropdown(rstcd, stnm, baseId,rvcd,reachcd));
}
@Log(module = "过鱼设施管理", value = "新增过鱼设施")

View File

@ -17,10 +17,14 @@ public interface SdFpssBHMapper extends BaseMapper<SdFpssBH> {
"WHERE 1=1 " +
"<if test='baseId != null and baseId != \"\"'> AND E.BASE_ID = #{baseId} </if>" +
"<if test='rstcd != null and rstcd != \"\"'> AND F.RSTCD = #{rstcd} </if>" +
"<if test='rvcd != null and rvcd != \"\"'> AND E.REACHCD = #{rvcd} </if>" +
// "<if test='rstcd != null and rstcd != \"\"'> AND F.RSTCD = #{rstcd} </if>" +
"<if test='stnm != null and stnm != \"\"'> AND F.STNM LIKE '%' || #{stnm} || '%' </if>" +
"ORDER BY F.ORDER_INDEX DESC" +
"</script>")
List<SdFpssBH> selectForDropdownWithBaseId(@Param("rstcd") String rstcd,
@Param("stnm") String stnm,
@Param("baseId") String baseId);
@Param("baseId") String baseId,
@Param("rvcd") String rvcd,
@Param("reachcd") String reachcd);
}

View File

@ -16,7 +16,7 @@ public interface ISdFpssBHService extends IService<SdFpssBH> {
/**
* 设施下拉列表根据电站编码筛选 + 支持名称模糊搜索 + 支持基地编码筛选
*/
List<SdFpssBH> selectForDropdown(String rstcd, String stnm, String baseId);
List<SdFpssBH> selectForDropdown(String rstcd, String stnm, String baseId,String rvcd,String reachcd);
Set<String> getUserAuthorizedStationCodes();

View File

@ -91,8 +91,8 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
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)
.eq(StrUtil.isNotBlank(rvcd), SdEngInfoBH::getReachcd, rvcd)
.in(rvcds != null && !rvcds.isEmpty(), SdEngInfoBH::getReachcd, rvcds)
.in(hbrvcds != null && !hbrvcds.isEmpty(), SdEngInfoBH::getHbrvcd, hbrvcds)
.like(StringUtils.hasText(ennm), SdEngInfoBH::getEnnm, ennm)
.select(SdEngInfoBH::getStcd, SdEngInfoBH::getEnnm, SdEngInfoBH::getBaseId)
@ -135,23 +135,23 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
if ("STATION".equals(orgType)) {
SdEngInfoBH station = engInfoBHMapper.selectById(orgId);
if (station != null) {
if (station.getHbrvcd() != null) {
basinCodes.add(station.getHbrvcd());
if (station.getReachcd() != null) {
basinCodes.add(station.getReachcd());
}
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
}
} else if ("HBRVCD".equals(orgType)) {
List<SdEngInfoBH> stationList = engInfoBHMapper.selectByHbrvcd(orgId);
} else if ("RVCD".equals(orgType)) {
List<SdEngInfoBH> stationList = engInfoBHMapper.selectByRvcd(null,orgId);
if (stationList != null) {
for (SdEngInfoBH station : stationList) {
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
if (station.getEnnm() != null) {
basinCodes.add(station.getHbrvcd());
basinCodes.add(station.getReachcd());
}
}
}
@ -166,7 +166,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
if (!basinCodes.isEmpty()) {
List<SdEngInfoBH> engInfos = this.lambdaQuery()
.select(SdEngInfoBH::getStcd)
.in(SdEngInfoBH::getHbrvcd, basinCodes)
.in(SdEngInfoBH::getReachcd, basinCodes)
.list();
return engInfos.stream()
.map(SdEngInfoBH::getStcd)
@ -201,7 +201,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
LambdaQueryWrapper<SdEngInfoBH> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.hasText(baseId), SdEngInfoBH::getBaseId, baseId)
.eq(StringUtils.hasText(hbrvcd), SdEngInfoBH::getHbrvcd, hbrvcd)
.in(rvcds != null && !rvcds.isEmpty(), SdEngInfoBH::getRvcd, rvcds)
.in(rvcds != null && !rvcds.isEmpty(), SdEngInfoBH::getReachcd, rvcds)
.in(hbrvcds != null && !hbrvcds.isEmpty(), SdEngInfoBH::getHbrvcd, hbrvcds)
.like(StringUtils.hasText(ennm), SdEngInfoBH::getEnnm, ennm)
.select(SdEngInfoBH::getStcd, SdEngInfoBH::getEnnm, SdEngInfoBH::getBaseId)

View File

@ -66,10 +66,10 @@ public class SdFpssBHServiceImpl extends ServiceImpl<SdFpssBHMapper, SdFpssBH> i
}
@Override
public List<SdFpssBH> selectForDropdown(String rstcd, String stnm, String baseId) {
public List<SdFpssBH> selectForDropdown(String rstcd, String stnm, String baseId,String rvcd,String reachcd) {
// 管理员直接查询无需权限过滤
if ("admin".equals(SecurityUtils.getCurrentUsername())) {
return queryFpssList(rstcd, stnm, baseId);
return queryFpssList(rstcd, stnm, baseId,rvcd,reachcd);
}
// 获取用户有权限的工程编码
@ -81,7 +81,7 @@ public class SdFpssBHServiceImpl extends ServiceImpl<SdFpssBHMapper, SdFpssBH> i
}
// 查询数据
List<SdFpssBH> result = queryFpssList(rstcd, stnm, baseId);
List<SdFpssBH> result = queryFpssList(rstcd, stnm, baseId,rvcd,reachcd);
// 权限过滤
return result.stream()
@ -92,9 +92,9 @@ public class SdFpssBHServiceImpl extends ServiceImpl<SdFpssBHMapper, SdFpssBH> i
/**
* 查询过鱼设施列表公共方法
*/
private List<SdFpssBH> queryFpssList(String rstcd, String stnm, String baseId) {
if (StringUtils.hasText(baseId)) {
return baseMapper.selectForDropdownWithBaseId(rstcd, stnm, baseId);
private List<SdFpssBH> queryFpssList(String rstcd, String stnm, String baseId,String rvcd,String reachcd) {
if (StringUtils.hasText(baseId)||StringUtils.hasText(rvcd)||StringUtils.hasText(reachcd)) {
return baseMapper.selectForDropdownWithBaseId(rstcd, stnm, baseId,rvcd,reachcd);
} else {
LambdaQueryWrapper<SdFpssBH> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.hasText(rstcd), SdFpssBH::getRstcd, rstcd)
@ -127,23 +127,23 @@ public class SdFpssBHServiceImpl extends ServiceImpl<SdFpssBHMapper, SdFpssBH> i
if ("STATION".equals(orgType)) {
SdEngInfoBH station = sdEngInfoBHMapper.selectById(orgId);
if (station != null) {
if (station.getHbrvcd() != null) {
basinCodes.add(station.getHbrvcd());
if (station.getReachcd() != null) {
basinCodes.add(station.getReachcd());
}
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
}
} else if ("HBRVCD".equals(orgType)) {
List<SdEngInfoBH> stationList = sdEngInfoBHMapper.selectByHbrvcd(orgId);
} else if ("RVCD".equals(orgType)) {
List<SdEngInfoBH> stationList = sdEngInfoBHMapper.selectByRvcd(null,orgId);
if (stationList != null) {
for (SdEngInfoBH station : stationList) {
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
if (station.getEnnm() != null) {
basinCodes.add(station.getHbrvcd());
basinCodes.add(station.getReachcd());
}
}
}
@ -158,7 +158,7 @@ public class SdFpssBHServiceImpl extends ServiceImpl<SdFpssBHMapper, SdFpssBH> i
List<SdEngInfoBH> engInfos = sdEngInfoBHMapper.selectList(
new LambdaQueryWrapper<SdEngInfoBH>()
.select(SdEngInfoBH::getStcd)
.in(SdEngInfoBH::getHbrvcd, basinCodes)
.in(SdEngInfoBH::getReachcd, basinCodes)
);
return engInfos.stream()
.map(SdEngInfoBH::getStcd)

View File

@ -149,15 +149,15 @@ public class SdHbrvDicServiceImpl extends ServiceImpl<SdHbrvDicMapper, SdHbrvDic
if ("STATION".equals(orgType)) {
SdEngInfoBH station = engInfoBHMapper.selectById(orgId);
if (station != null) {
if (station.getHbrvcd() != null) {
basinCodes.add(station.getHbrvcd());
if (station.getReachcd() != null) {
basinCodes.add(station.getReachcd());
}
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
}
} else if ("HBRVCD".equals(orgType)) {
} else if ("RVCD".equals(orgType)) {
List<SdEngInfoBH> stationList = engInfoBHMapper.selectByHbrvcd(orgId);
if (stationList != null) {
for (SdEngInfoBH station : stationList) {
@ -165,7 +165,7 @@ public class SdHbrvDicServiceImpl extends ServiceImpl<SdHbrvDicMapper, SdHbrvDic
stationCodes.add(station.getStcd());
}
if (station.getEnnm() != null) {
basinCodes.add(station.getHbrvcd());
basinCodes.add(station.getReachcd());
}
}
}

View File

@ -182,23 +182,23 @@ public class SdHydrobaseServiceImpl extends ServiceImpl<SdHydrobaseMapper, SdHyd
if ("STATION".equals(orgType)) {
SdEngInfoBH station = sdEngInfoBHMapper.selectById(orgId);
if (station != null) {
if (station.getHbrvcd() != null) {
basinCodes.add(station.getHbrvcd());
if (station.getReachcd() != null) {
basinCodes.add(station.getReachcd());
}
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
}
} else if ("HBRVCD".equals(orgType)) {
List<SdEngInfoBH> stationList = sdEngInfoBHMapper.selectByHbrvcd(orgId);
} else if ("RVCD".equals(orgType)) {
List<SdEngInfoBH> stationList = sdEngInfoBHMapper.selectByRvcd(null,orgId);
if (stationList != null) {
for (SdEngInfoBH station : stationList) {
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
if (station.getEnnm() != null) {
basinCodes.add(station.getHbrvcd());
basinCodes.add(station.getReachcd());
}
}
}
@ -214,7 +214,7 @@ public class SdHydrobaseServiceImpl extends ServiceImpl<SdHydrobaseMapper, SdHyd
List<SdEngInfoBH> engInfos = sdEngInfoBHMapper.selectList(
new LambdaQueryWrapper<SdEngInfoBH>()
.select(SdEngInfoBH::getStcd)
.in(SdEngInfoBH::getHbrvcd, basinCodes)
.in(SdEngInfoBH::getReachcd, basinCodes)
);
return engInfos.stream()
.map(SdEngInfoBH::getStcd)

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.qgc_base.domain.SdEngInfoBH;
import com.yfd.platform.qgc_base.domain.SdHbrvDic;
import com.yfd.platform.qgc_base.domain.SdRvcdDic;
import com.yfd.platform.qgc_base.mapper.SdEngInfoBHMapper;
import com.yfd.platform.qgc_base.mapper.SdRvcdDicMapper;
@ -126,18 +127,19 @@ public class SdRvcdDicServiceImpl extends ServiceImpl<SdRvcdDicMapper, SdRvcdDic
if (authorizedStations != null && !authorizedStations.isEmpty()) {
List<SdEngInfoBH> engInfos = engInfoBHMapper.selectList(
new LambdaQueryWrapper<SdEngInfoBH>()
.select(SdEngInfoBH::getRvcd)
.select(SdEngInfoBH::getReachcd)
.in(SdEngInfoBH::getStcd, authorizedStations)
);
List<String> rvcds = engInfos.stream()
.map(SdEngInfoBH::getRvcd)
.map(SdEngInfoBH::getReachcd)
.filter(id -> id != null && !id.isEmpty())
.distinct()
.toList();
if (!rvcds.isEmpty()) {
return dropdownList.stream()
.filter(rvcdDic -> rvcds.contains(rvcdDic.getRvcd()))
.filter(rvDic -> rvcds.contains(rvDic.getRvcd()))
.collect(Collectors.toList());
} else {
return new ArrayList<>();
@ -172,8 +174,8 @@ public class SdRvcdDicServiceImpl extends ServiceImpl<SdRvcdDicMapper, SdRvcdDic
if ("STATION".equals(orgType)) {
SdEngInfoBH station = engInfoBHMapper.selectById(orgId);
if (station != null) {
if (station.getRvcd() != null) {
basinCodes.add(station.getRvcd());
if (station.getReachcd() != null) {
basinCodes.add(station.getReachcd());
}
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
@ -188,7 +190,7 @@ public class SdRvcdDicServiceImpl extends ServiceImpl<SdRvcdDicMapper, SdRvcdDic
stationCodes.add(station.getStcd());
}
if (station.getEnnm() != null) {
basinCodes.add(station.getRvcd());
basinCodes.add(station.getReachcd());
}
}
}
@ -203,7 +205,7 @@ public class SdRvcdDicServiceImpl extends ServiceImpl<SdRvcdDicMapper, SdRvcdDic
List<SdEngInfoBH> engInfos = engInfoBHMapper.selectList(
new LambdaQueryWrapper<SdEngInfoBH>()
.select(SdEngInfoBH::getStcd)
.in(SdEngInfoBH::getRvcd, basinCodes)
.in(SdEngInfoBH::getReachcd, basinCodes)
);
return engInfos.stream()
.map(SdEngInfoBH::getStcd)