perf: 调整typePoint缓存和非缓存的使用

dev
huangfeng 8 months ago
parent 84929f6b3f
commit 2c616d34fc

@ -8,6 +8,8 @@ public interface ModevTypePointService {
List<ModevTypePoint> listAll(Integer modevtypeId);
List<ModevTypePoint> listAllCache(Integer modevtypeId);
ModevTypePoint add(ModevTypePoint item) throws Exception;
void delete(Integer id) throws Exception;

@ -31,7 +31,6 @@ public class ModevTypePointServiceImpl implements ModevTypePointService {
WarnRuleRepository ruleRepository;
@Override
@Cacheable(value = "typePoint", key = "#modevtypeId")
public List<ModevTypePoint> listAll(Integer modevtypeId) {
List<ModevTypePoint> list = repository.findByModevtypeId(modevtypeId);
for (ModevTypePoint point : list) {
@ -42,6 +41,13 @@ public class ModevTypePointServiceImpl implements ModevTypePointService {
return list;
}
@Override
@Cacheable(value = "typePoint", key = "#modevtypeId")
public List<ModevTypePoint> listAllCache(Integer modevtypeId) {
List<ModevTypePoint> list = this.listAll(modevtypeId);
return list;
}
@Override
@CacheEvict(cacheNames = {"typePoint"}, allEntries = true)
public ModevTypePoint add(ModevTypePoint item) throws Exception {

@ -78,7 +78,7 @@ public class NSensorServiceImpl implements NSensorService {
if (type.getId().equals(sensor.getTypeId())) {
sensor.setTypeName(type.getMc());
sensor.setTableName(type.getTablename());
List<ModevTypePoint> points = modevTypePointService.listAll(sensor.getTypeId());
List<ModevTypePoint> points = modevTypePointService.listAllCache(sensor.getTypeId());
sensor.setTypePoints(points);
}
}

Loading…
Cancel
Save