大屏增加缓存机制
This commit is contained in:
parent
1cea027067
commit
e16802c364
|
|
@ -7,6 +7,7 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.constant.CacheConstants;
|
||||||
import org.jeecg.common.constant.IotConstants;
|
import org.jeecg.common.constant.IotConstants;
|
||||||
import org.jeecg.common.constant.PollutionConstants;
|
import org.jeecg.common.constant.PollutionConstants;
|
||||||
import org.jeecg.common.constant.enums.ScreenIndexSummaryEnum;
|
import org.jeecg.common.constant.enums.ScreenIndexSummaryEnum;
|
||||||
|
|
@ -39,6 +40,7 @@ import java.time.ZoneOffset;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.TemporalAdjusters;
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Api(tags="大屏接口")
|
@Api(tags="大屏接口")
|
||||||
|
|
@ -505,6 +507,14 @@ public class BigScreenController {
|
||||||
@ApiOperation("大屏首页统计")
|
@ApiOperation("大屏首页统计")
|
||||||
public Result<List<ScreenIndexSummaryDetailVo>> getIndexSummry (@RequestBody ScreenSummaryVo screenSummaryVo){
|
public Result<List<ScreenIndexSummaryDetailVo>> getIndexSummry (@RequestBody ScreenSummaryVo screenSummaryVo){
|
||||||
List<ScreenIndexSummaryDetailVo> results = new ArrayList<>();
|
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");
|
List<SurvStationInfo> stationList = survStationInfoService.getAllStationAndDevice(screenSummaryVo.getStationCode(),"","token");
|
||||||
|
|
||||||
Integer intYear = LocalDateTime.now().getYear();
|
Integer intYear = LocalDateTime.now().getYear();
|
||||||
|
|
@ -774,6 +784,7 @@ public class BigScreenController {
|
||||||
// JSONObject datajob = new JSONObject();
|
// JSONObject datajob = new JSONObject();
|
||||||
// datajob.put("dataStr",wholeTime);
|
// datajob.put("dataStr",wholeTime);
|
||||||
// returnArrs.add(datajob);
|
// returnArrs.add(datajob);
|
||||||
|
redisTemplate.opsForValue().set(CacheConstants.BS_INDEX_STATISTIC_CACHE,JSONArray.parseArray(JSONObject.toJSONString(results)),5, TimeUnit.MINUTES);//增加缓存机制
|
||||||
return Result.ok(results);
|
return Result.ok(results);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,4 +75,8 @@ public interface CacheConstants {
|
||||||
* 移动端主题配置缓存
|
* 移动端主题配置缓存
|
||||||
*/
|
*/
|
||||||
String MALL_THEME_MOBILE_CACHE = "mall:theme_mobile";
|
String MALL_THEME_MOBILE_CACHE = "mall:theme_mobile";
|
||||||
|
/**
|
||||||
|
* 大屏首页统计缓存
|
||||||
|
*/
|
||||||
|
String BS_INDEX_STATISTIC_CACHE="bs:indexstatistic:";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue