大屏增加缓存机制

This commit is contained in:
zy 2026-01-17 10:46:47 +08:00
parent 1cea027067
commit e16802c364
2 changed files with 15 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CacheConstants;
import org.jeecg.common.constant.IotConstants;
import org.jeecg.common.constant.PollutionConstants;
import org.jeecg.common.constant.enums.ScreenIndexSummaryEnum;
@ -39,6 +40,7 @@ import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Api(tags="大屏接口")
@ -505,6 +507,14 @@ public class BigScreenController {
@ApiOperation("大屏首页统计")
public Result<List<ScreenIndexSummaryDetailVo>> getIndexSummry (@RequestBody ScreenSummaryVo screenSummaryVo){
List<ScreenIndexSummaryDetailVo> results = new ArrayList<>();
if(StringUtils.isBlank(screenSummaryVo.getSummrayMode())){//不传模式默认为天数据
screenSummaryVo.setSummrayMode(IotConstants.month_days);
}
String cache = oConvertUtils.getString(redisTemplate.opsForValue().get(CacheConstants.BS_INDEX_STATISTIC_CACHE));
if(StringUtils.isNotBlank(cache)){
results = JSONArray.parseArray(cache,ScreenIndexSummaryDetailVo.class);
return Result.ok(results);
}
List<SurvStationInfo> stationList = survStationInfoService.getAllStationAndDevice(screenSummaryVo.getStationCode(),"","token");
Integer intYear = LocalDateTime.now().getYear();
@ -774,6 +784,7 @@ public class BigScreenController {
// JSONObject datajob = new JSONObject();
// datajob.put("dataStr",wholeTime);
// returnArrs.add(datajob);
redisTemplate.opsForValue().set(CacheConstants.BS_INDEX_STATISTIC_CACHE,JSONArray.parseArray(JSONObject.toJSONString(results)),5, TimeUnit.MINUTES);//增加缓存机制
return Result.ok(results);
}

View File

@ -75,4 +75,8 @@ public interface CacheConstants {
* 移动端主题配置缓存
*/
String MALL_THEME_MOBILE_CACHE = "mall:theme_mobile";
/**
* 大屏首页统计缓存
*/
String BS_INDEX_STATISTIC_CACHE="bs:indexstatistic:";
}