src/main/java/com/lf/server/entity/all/RedisCacheKey.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/service/all/PermsService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/service/all/RedisService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/service/sys/ReportService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/lf/server/entity/all/RedisCacheKey.java
@@ -83,9 +83,23 @@ } /** * 数据统计授权键 * 数据统计键 */ public static String dataCountKey(String key) { return "data:count:" + key; } /** * 数据目录键 */ public static String dataDirKey(String key) { return "data:dir:" + key; } /** * 数据单位键 */ public static String dataDepKey(String key) { return "data:dep:" + key; } } src/main/java/com/lf/server/service/all/PermsService.java
@@ -96,10 +96,6 @@ return permsMapper.selectMenuRecursive(id, uid); } public void clearResCache() { redisService.clearKeys(RedisCacheKey.permsResKey("")); } /** * 清除授权缓存 */ src/main/java/com/lf/server/service/all/RedisService.java
@@ -1,9 +1,13 @@ package com.lf.server.service.all; import com.lf.server.entity.all.SettingData; import com.lf.server.entity.ctrl.CountEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -13,7 +17,7 @@ */ @Service("redisService") public class RedisService { @Autowired @Resource private RedisTemplate<String, Object> redisTemplate; /** @@ -99,4 +103,34 @@ redisTemplate.delete(keys); } } /** * 根据Key获取List集合 */ public <T> List<T> getListByKey(String key) { Object obj = get(key); if (obj instanceof List<?>) { return (List<T>) obj; } return null; } /** * 根据Key保存数据 */ public <T> void saveListByKey(String key, List<T> list) { if (null != list && list.size() > 0) { put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); } } /** * 根据Key保存数据 */ public <T> void saveListByKey(String key, List<T> list, Integer minutes) { if (null != list && list.size() > 0) { put(key, list, minutes, TimeUnit.MINUTES); } } } src/main/java/com/lf/server/service/sys/ReportService.java
@@ -21,7 +21,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.util.*; import java.util.concurrent.TimeUnit; /** * 报告模板 @@ -131,15 +130,11 @@ @Override public List<CountEntity> countExplorationPoints() { String key = RedisCacheKey.dataCountKey("countExplorationPoints"); Object obj = redisService.get(key); if (obj instanceof List<?>) { return (List<CountEntity>) obj; } List<CountEntity> list = reportMapper.countExplorationPoints(); if (null != list && list.size() > 0) { List<CountEntity> list = redisService.getListByKey(key); if (null == list) { list = reportMapper.countExplorationPoints(); countExplorationArea(list); redisService.put(key, list, StaticData.I2, TimeUnit.MINUTES); redisService.saveListByKey(key, list, StaticData.I2); } return list; @@ -154,6 +149,9 @@ * 统计钻孔点面积 */ private void countExplorationArea(List<CountEntity> list) { if (null == list) { return; } for (CountEntity ce : list) { if (0 == ce.getCount()) { continue;