fix: 优化电站基本信息缓存

This commit is contained in:
tangwei 2026-07-03 09:13:01 +08:00
parent 98afa05338
commit 115da13fcf
2 changed files with 9 additions and 0 deletions

View File

@ -63,6 +63,7 @@ public class RedisConfig {
Map<String, RedisCacheConfiguration> cacheConfigs = new HashMap<>(); Map<String, RedisCacheConfiguration> cacheConfigs = new HashMap<>();
cacheConfigs.put("dictCache", defaultConfig.entryTtl(Duration.ofHours(6))); cacheConfigs.put("dictCache", defaultConfig.entryTtl(Duration.ofHours(6)));
cacheConfigs.put("dataCache", defaultConfig.entryTtl(Duration.ofMinutes(5))); cacheConfigs.put("dataCache", defaultConfig.entryTtl(Duration.ofMinutes(5)));
cacheConfigs.put("engInfoCache", defaultConfig.entryTtl(Duration.ofHours(2)));
return RedisCacheManager.builder(redisConnectionFactory) return RedisCacheManager.builder(redisConnectionFactory)
.cacheDefaults(defaultConfig) .cacheDefaults(defaultConfig)

View File

@ -38,6 +38,8 @@ import com.yfd.platform.system.service.IAdminAuthService;
import com.yfd.platform.utils.QgcQueryWrapperUtil; import com.yfd.platform.utils.QgcQueryWrapperUtil;
import com.yfd.platform.utils.SecurityUtils; import com.yfd.platform.utils.SecurityUtils;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -104,16 +106,19 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
} }
@Override @Override
@Cacheable(cacheNames = "engInfoCache", key = "'eng:baseId:' + #baseId")
public List<SdEngInfoBH> getByBaseId(String baseId) { public List<SdEngInfoBH> getByBaseId(String baseId) {
return engInfoBHMapper.selectByBaseId(baseId); return engInfoBHMapper.selectByBaseId(baseId);
} }
@Override @Override
@Cacheable(cacheNames = "engInfoCache", key = "'eng:hycd:' + #hycd")
public List<SdEngInfoBH> getByHycd(String hycd) { public List<SdEngInfoBH> getByHycd(String hycd) {
return engInfoBHMapper.selectByHycd(hycd); return engInfoBHMapper.selectByHycd(hycd);
} }
@Override @Override
@Cacheable(cacheNames = "engInfoCache", key = "'eng:rvcd:' + #rvcd + ':' + #reachcd")
public List<SdEngInfoBH> getByRvcd(String rvcd,String reachcd) { public List<SdEngInfoBH> getByRvcd(String rvcd,String reachcd) {
return engInfoBHMapper.selectByRvcd(rvcd,reachcd); return engInfoBHMapper.selectByRvcd(rvcd,reachcd);
} }
@ -223,6 +228,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
} }
@Override @Override
@CacheEvict(cacheNames = "engInfoCache", allEntries = true)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean addEngInfo(SdEngInfoBH engInfo, String source) { public boolean addEngInfo(SdEngInfoBH engInfo, String source) {
fillRelatedNameFields(engInfo); fillRelatedNameFields(engInfo);
@ -239,6 +245,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
} }
@Override @Override
@CacheEvict(cacheNames = "engInfoCache", allEntries = true)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean updateEngInfo(SdEngInfoBH engInfo, String source) { public boolean updateEngInfo(SdEngInfoBH engInfo, String source) {
SdEngInfoBH before = engInfo == null ? null : this.getById(engInfo.getStcd()); SdEngInfoBH before = engInfo == null ? null : this.getById(engInfo.getStcd());
@ -509,6 +516,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
} }
@Override @Override
@CacheEvict(cacheNames = "engInfoCache", allEntries = true)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean deleteEngInfo(List<String> ids, String source) { public boolean deleteEngInfo(List<String> ids, String source) {
List<String> stcdList = ids == null ? new ArrayList<>() : ids.stream() List<String> stcdList = ids == null ? new ArrayList<>() : ids.stream()