fix: 优化下拉菜单权限

This commit is contained in:
tangwei 2026-05-06 18:44:49 +08:00
parent 7932b8dc7a
commit a623c90f21
6 changed files with 175 additions and 24 deletions

View File

@ -85,7 +85,9 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
String STRDT = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "strdt"); String STRDT = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "strdt");
String startTime=null; String startTime=null;
String endTime=null; String endTime=null;
String userId = (SecurityUtils.hasPermission("sjtb:edit-review") || "admin".equals(SecurityUtils.getCurrentUsername())) ?null:SecurityUtils.getUserId(); // String userId = (SecurityUtils.hasPermission("sjtb:edit-review") || "admin".equals(SecurityUtils.getCurrentUsername())) ?null:SecurityUtils.getUserId();
String userId = SecurityUtils.getUserId();
// 如果 startTime endTime 为空尝试从 TM 字段解析 // 如果 startTime endTime 为空尝试从 TM 字段解析
if (StrUtil.isNotBlank(STRDT)&& STRDT.split( ",").length==2) { if (StrUtil.isNotBlank(STRDT)&& STRDT.split( ",").length==2) {
startTime=STRDT.split(",")[0]; startTime=STRDT.split(",")[0];
@ -256,6 +258,7 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
approvalMain.setApplyUserId(operatorId); approvalMain.setApplyUserId(operatorId);
approvalMain.setApplyTime(new Date()); approvalMain.setApplyTime(new Date());
approvalMain.setStatus("PENDING"); approvalMain.setStatus("PENDING");
setUserDataScope(approvalMain);
approvalMainService.save(approvalMain); approvalMainService.save(approvalMain);
fishDraftData.setApprovalId(approvalMain.getId()); fishDraftData.setApprovalId(approvalMain.getId());

View File

@ -85,6 +85,14 @@ public class FishImportServiceImpl implements IFishImportService {
private static final Map<String, String> FPSS_TO_STATION_CACHE = new LinkedHashMap<>(); private static final Map<String, String> FPSS_TO_STATION_CACHE = new LinkedHashMap<>();
private static final Map<String, String> ISFS_DICT_CACHE = new LinkedHashMap<>(); private static final Map<String, String> ISFS_DICT_CACHE = new LinkedHashMap<>();
private static final long CACHE_EXPIRE_MILLIS = 10 * 60 * 1000;
private static long stationCacheTimestamp = 0;
private static long baseCacheTimestamp = 0;
private static long riverCacheTimestamp = 0;
private static long hbrvcdCacheTimestamp = 0;
private static long fishDictCacheTimestamp = 0;
private static long fpssCacheTimestamp = 0;
private static final String DICT_CODE_FISH = "FISH_TYPE"; private static final String DICT_CODE_FISH = "FISH_TYPE";
private static final String DICT_CODE_DIRECTION = "FISH_DIRECTION"; private static final String DICT_CODE_DIRECTION = "FISH_DIRECTION";
private static final String DICT_CODE_ISFS = "YES_NO"; private static final String DICT_CODE_ISFS = "YES_NO";
@ -524,7 +532,14 @@ public class FishImportServiceImpl implements IFishImportService {
} }
} }
if (STATION_NAME_CACHE.isEmpty()&&!allStcdSet.isEmpty()) { boolean stationCacheExpired = isCacheExpired(stationCacheTimestamp);
if (STATION_NAME_CACHE.isEmpty() || stationCacheExpired) {
if (stationCacheExpired) {
STATION_NAME_CACHE.clear();
STATION_CODE_TO_NAME_CACHE.clear();
STATION_TO_BASE_CACHE.clear();
}
List<SdEngInfoBH> stationList; List<SdEngInfoBH> stationList;
if (!allStcdSet.isEmpty()) { if (!allStcdSet.isEmpty()) {
stationList = engInfoBHMapper.selectBatchIds(new ArrayList<>(allStcdSet)); stationList = engInfoBHMapper.selectBatchIds(new ArrayList<>(allStcdSet));
@ -545,9 +560,16 @@ public class FishImportServiceImpl implements IFishImportService {
} }
} }
} }
stationCacheTimestamp = System.currentTimeMillis();
}
boolean baseCacheExpired = isCacheExpired(baseCacheTimestamp);
if (BASE_NAME_CACHE.isEmpty() || baseCacheExpired) {
if (baseCacheExpired) {
BASE_NAME_CACHE.clear();
BASE_CODE_TO_NAME_CACHE.clear();
} }
if (BASE_NAME_CACHE.isEmpty()) {
List<SdHydrobase> baseList = hydrobaseMapper.selectList(null); List<SdHydrobase> baseList = hydrobaseMapper.selectList(null);
for (SdHydrobase base : baseList) { for (SdHydrobase base : baseList) {
if (StringUtils.hasText(base.getBasename())) { if (StringUtils.hasText(base.getBasename())) {
@ -559,9 +581,16 @@ public class FishImportServiceImpl implements IFishImportService {
} }
} }
} }
baseCacheTimestamp = System.currentTimeMillis();
}
boolean riverCacheExpired = isCacheExpired(riverCacheTimestamp);
if (RIVER_NAME_CACHE.isEmpty() || riverCacheExpired) {
if (riverCacheExpired) {
RIVER_NAME_CACHE.clear();
RIVER_CODE_TO_NAME_CACHE.clear();
} }
if (RIVER_NAME_CACHE.isEmpty()) {
List<SdRvcdDic> riverList = rvcdDicMapper.selectList(null); List<SdRvcdDic> riverList = rvcdDicMapper.selectList(null);
for (SdRvcdDic river : riverList) { for (SdRvcdDic river : riverList) {
if (StringUtils.hasText(river.getRvnm())) { if (StringUtils.hasText(river.getRvnm())) {
@ -573,13 +602,24 @@ public class FishImportServiceImpl implements IFishImportService {
} }
} }
} }
riverCacheTimestamp = System.currentTimeMillis();
}
boolean hbrvcdCacheExpired = isCacheExpired(hbrvcdCacheTimestamp);
if (HBRVCD_NAME_CACHE.isEmpty() || hbrvcdCacheExpired) {
if (hbrvcdCacheExpired) {
HBRVCD_NAME_CACHE.clear();
HBRVCD_CODE_TO_NAME_CACHE.clear();
} }
if (HBRVCD_NAME_CACHE.isEmpty()&&!allowedHbrvcdSet.isEmpty()) {
List<SdHbrvDic> riverList; List<SdHbrvDic> riverList;
if (!allowedHbrvcdSet.isEmpty()) {
LambdaQueryWrapper<SdHbrvDic> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SdHbrvDic> wrapper = new LambdaQueryWrapper<>();
wrapper.in(SdHbrvDic::getHbrvcd, allowedHbrvcdSet); wrapper.in(SdHbrvDic::getHbrvcd, allowedHbrvcdSet);
riverList = sdHbrvDicMapper.selectList(wrapper); riverList = sdHbrvDicMapper.selectList(wrapper);
} else {
riverList = sdHbrvDicMapper.selectList(null);
}
for (SdHbrvDic river : riverList) { for (SdHbrvDic river : riverList) {
if (StringUtils.hasText(river.getHbrvnm())) { if (StringUtils.hasText(river.getHbrvnm())) {
HBRVCD_NAME_CACHE.put(river.getHbrvnm().trim().toLowerCase(), river.getHbrvcd()); HBRVCD_NAME_CACHE.put(river.getHbrvnm().trim().toLowerCase(), river.getHbrvcd());
@ -590,9 +630,16 @@ public class FishImportServiceImpl implements IFishImportService {
} }
} }
} }
hbrvcdCacheTimestamp = System.currentTimeMillis();
}
boolean fishDictCacheExpired = isCacheExpired(fishDictCacheTimestamp);
if (FISH_DICT_CACHE.isEmpty() || fishDictCacheExpired) {
if (fishDictCacheExpired) {
FISH_DICT_CACHE.clear();
FISH_CODE_TO_NAME_CACHE.clear();
} }
if (FISH_DICT_CACHE.isEmpty()) {
List<SdFishDictoryB> sdFishDictoryBS = fishDictoryBMapper.selectList(null); List<SdFishDictoryB> sdFishDictoryBS = fishDictoryBMapper.selectList(null);
for (SdFishDictoryB fishDictoryB : sdFishDictoryBS) { for (SdFishDictoryB fishDictoryB : sdFishDictoryBS) {
if (StringUtils.hasText(fishDictoryB.getName())) { if (StringUtils.hasText(fishDictoryB.getName())) {
@ -604,10 +651,23 @@ public class FishImportServiceImpl implements IFishImportService {
} }
} }
} }
fishDictCacheTimestamp = System.currentTimeMillis();
} }
if (FPSS_BH_CACHE.isEmpty()&&!directStcdSet.isEmpty()) { boolean fpssCacheExpired = isCacheExpired(fpssCacheTimestamp);
List<SdFpssBH> sdFpssBHS = fpssBHMapper.selectList(new LambdaQueryWrapper<SdFpssBH>().in(SdFpssBH::getStcd, directStcdSet)); if (FPSS_BH_CACHE.isEmpty() || fpssCacheExpired) {
if (fpssCacheExpired) {
FPSS_BH_CACHE.clear();
FPSS_CODE_TO_NAME_CACHE.clear();
FPSS_TO_STATION_CACHE.clear();
}
List<SdFpssBH> sdFpssBHS;
if (!allStcdSet.isEmpty()) {
sdFpssBHS = fpssBHMapper.selectList(new LambdaQueryWrapper<SdFpssBH>().in(SdFpssBH::getStcd, allStcdSet));
} else {
sdFpssBHS = fpssBHMapper.selectList(null);
}
for (SdFpssBH sdFpssBH : sdFpssBHS) { for (SdFpssBH sdFpssBH : sdFpssBHS) {
if (StringUtils.hasText(sdFpssBH.getStnm())) { if (StringUtils.hasText(sdFpssBH.getStnm())) {
FPSS_BH_CACHE.put(sdFpssBH.getStnm().trim().toLowerCase(), sdFpssBH.getStcd()); FPSS_BH_CACHE.put(sdFpssBH.getStnm().trim().toLowerCase(), sdFpssBH.getStcd());
@ -621,9 +681,14 @@ public class FishImportServiceImpl implements IFishImportService {
} }
} }
} }
fpssCacheTimestamp = System.currentTimeMillis();
} }
} }
private boolean isCacheExpired(long timestamp) {
return System.currentTimeMillis() - timestamp > CACHE_EXPIRE_MILLIS;
}
public String resolveStationCode(String stationName) { public String resolveStationCode(String stationName) {
if (stationName == null) { if (stationName == null) {

View File

@ -104,17 +104,38 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
return new HashSet<>(); return new HashSet<>();
} }
Set<String> stationCodes = new HashSet<>(); Set<String> stationCodes = new HashSet<>();
List<String> basinCodes = new ArrayList<>(); Set<String> basinCodes = new HashSet<>();
for (SysUserDataScope scope : sysUserDataScopes) { for (SysUserDataScope scope : sysUserDataScopes) {
String orgType = scope.getOrgType(); String orgType = scope.getOrgType();
String orgId = scope.getOrgId(); String orgId = scope.getOrgId();
if ("STATION".equals(orgType)) { if ("STATION".equals(orgType)) {
stationCodes.add(orgId); SdEngInfoBH station = engInfoBHMapper.selectById(orgId);
if (station != null) {
if (station.getHbrvcd() != null) {
basinCodes.add(station.getHbrvcd());
}
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
}
} else if ("HBRVCD".equals(orgType)) { } else if ("HBRVCD".equals(orgType)) {
basinCodes.add(orgId); List<SdEngInfoBH> stationList = engInfoBHMapper.selectByHbrvcd(orgId);
if (stationList != null) {
for (SdEngInfoBH station : stationList) {
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
if (station.getEnnm() != null) {
basinCodes.add(station.getHbrvcd());
}
}
}
} }
} }

View File

@ -102,20 +102,40 @@ public class SdFpssBHServiceImpl extends ServiceImpl<SdFpssBHMapper, SdFpssBH> i
return new HashSet<>(); return new HashSet<>();
} }
Set<String> stationCodes = new HashSet<>(); Set<String> stationCodes = new HashSet<>();
List<String> basinCodes = new ArrayList<>(); Set<String> basinCodes = new HashSet<>();
for (SysUserDataScope scope : sysUserDataScopes) { for (SysUserDataScope scope : sysUserDataScopes) {
String orgType = scope.getOrgType(); String orgType = scope.getOrgType();
String orgId = scope.getOrgId(); String orgId = scope.getOrgId();
if ("STATION".equals(orgType)) { if ("STATION".equals(orgType)) {
stationCodes.add(orgId); SdEngInfoBH station = sdEngInfoBHMapper.selectById(orgId);
if (station != null) {
if (station.getHbrvcd() != null) {
basinCodes.add(station.getHbrvcd());
}
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
}
} else if ("HBRVCD".equals(orgType)) { } else if ("HBRVCD".equals(orgType)) {
basinCodes.add(orgId); List<SdEngInfoBH> stationList = sdEngInfoBHMapper.selectByHbrvcd(orgId);
if (stationList != null) {
for (SdEngInfoBH station : stationList) {
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
if (station.getEnnm() != null) {
basinCodes.add(station.getHbrvcd());
}
} }
} }
}
}
if (!stationCodes.isEmpty()) { if (!stationCodes.isEmpty()) {
return stationCodes; return stationCodes;
} }

View File

@ -33,6 +33,8 @@ public class SdHbrvDicServiceImpl extends ServiceImpl<SdHbrvDicMapper, SdHbrvDic
@Resource @Resource
private SdEngInfoBHMapper engInfoBHMapper; private SdEngInfoBHMapper engInfoBHMapper;
private SdHbrvDicMapper hbrvDicMapper;
@Override @Override
public Page<SdHbrvDic> queryPageList(Page<SdHbrvDic> page, String hbrvnm, String baseid) { public Page<SdHbrvDic> queryPageList(Page<SdHbrvDic> page, String hbrvnm, String baseid) {
return this.page(page, this.lambdaQuery() return this.page(page, this.lambdaQuery()
@ -133,16 +135,36 @@ public class SdHbrvDicServiceImpl extends ServiceImpl<SdHbrvDicMapper, SdHbrvDic
} }
Set<String> stationCodes = new HashSet<>(); Set<String> stationCodes = new HashSet<>();
List<String> basinCodes = new ArrayList<>(); Set<String> basinCodes = new HashSet<>();
for (SysUserDataScope scope : sysUserDataScopes) { for (SysUserDataScope scope : sysUserDataScopes) {
String orgType = scope.getOrgType(); String orgType = scope.getOrgType();
String orgId = scope.getOrgId(); String orgId = scope.getOrgId();
if ("STATION".equals(orgType)) { if ("STATION".equals(orgType)) {
stationCodes.add(orgId); SdEngInfoBH station = engInfoBHMapper.selectById(orgId);
if (station != null) {
if (station.getHbrvcd() != null) {
basinCodes.add(station.getHbrvcd());
}
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
}
} else if ("HBRVCD".equals(orgType)) { } else if ("HBRVCD".equals(orgType)) {
basinCodes.add(orgId); List<SdEngInfoBH> stationList = engInfoBHMapper.selectByHbrvcd(orgId);
if (stationList != null) {
for (SdEngInfoBH station : stationList) {
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
if (station.getEnnm() != null) {
basinCodes.add(station.getHbrvcd());
}
}
}
} }
} }

View File

@ -111,16 +111,36 @@ public class SdHydrobaseServiceImpl extends ServiceImpl<SdHydrobaseMapper, SdHyd
} }
Set<String> stationCodes = new HashSet<>(); Set<String> stationCodes = new HashSet<>();
List<String> basinCodes = new ArrayList<>(); Set<String> basinCodes = new HashSet<>();
for (SysUserDataScope scope : sysUserDataScopes) { for (SysUserDataScope scope : sysUserDataScopes) {
String orgType = scope.getOrgType(); String orgType = scope.getOrgType();
String orgId = scope.getOrgId(); String orgId = scope.getOrgId();
if ("STATION".equals(orgType)) { if ("STATION".equals(orgType)) {
stationCodes.add(orgId); SdEngInfoBH station = sdEngInfoBHMapper.selectById(orgId);
if (station != null) {
if (station.getHbrvcd() != null) {
basinCodes.add(station.getHbrvcd());
}
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
}
} else if ("HBRVCD".equals(orgType)) { } else if ("HBRVCD".equals(orgType)) {
basinCodes.add(orgId); List<SdEngInfoBH> stationList = sdEngInfoBHMapper.selectByHbrvcd(orgId);
if (stationList != null) {
for (SdEngInfoBH station : stationList) {
if (station.getStcd() != null) {
stationCodes.add(station.getStcd());
}
if (station.getEnnm() != null) {
basinCodes.add(station.getHbrvcd());
}
}
}
} }
} }