| | |
| | | package com.yssh.controller; |
| | | |
| | | import com.yssh.utils.CacheUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Api(tags="告警分析") |
| | | @Api(tags = "告警分析") |
| | | @RequestMapping("/warning") |
| | | @RestController |
| | | @SuppressWarnings("rawtypes") |
| | |
| | | @Autowired |
| | | private IWarningAnalyseService warningService; |
| | | |
| | | private static ConcurrentHashMap<String, Object> cache = new ConcurrentHashMap<>(5); |
| | | |
| | | private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); |
| | | |
| | | public static final long CACHE_HOLD_TIME_24H = 24 * 60 * 60 * 1000L; |
| | | |
| | | /** |
| | | * 1.查询当前时间的所有点位value值(以47.dat查询即可) |
| | |
| | | //return Result.OK(warningService.selectEachLocationDataChange()); |
| | | |
| | | String key = dateFormat.format(new Date()) + "_local"; |
| | | Object obj = CacheUtils.get(key); |
| | | Map<String, List<Double>> map; |
| | | if (cache.containsKey(key)) { |
| | | map = (Map<String, List<Double>>) cache.get(key); |
| | | |
| | | if (null != obj) { |
| | | map = (Map<String, List<Double>>) obj; |
| | | } else { |
| | | map = warningService.selectEachLocationDataChange(); |
| | | if (null != map && map.size() > 0) { |
| | | cache.put(key, map); |
| | | CacheUtils.put(key, map); |
| | | } |
| | | } |
| | | |
| | |
| | | //return Result.OK(warningService.selectThisMonthLocationValueDataTop10()); |
| | | |
| | | String key = dateFormat.format(new Date()) + "_top10"; |
| | | Object obj = CacheUtils.get(key); |
| | | List<Map<String, Object>> list; |
| | | if (cache.containsKey(key)) { |
| | | list = (List<Map<String, Object>>) cache.get(key); |
| | | |
| | | if (null != obj) { |
| | | list = (List<Map<String, Object>>) obj; |
| | | } else { |
| | | list = warningService.selectThisMonthLocationValueDataTop10(); |
| | | if (null != list && list.size() > 0) { |
| | | cache.put(key, list); |
| | | CacheUtils.put(key, list); |
| | | } |
| | | } |
| | | |
| | | return Result.OK(list); |
| | | return Result.ok(list); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 5) |