| | |
| | | import com.yssh.service.IWarningAnalyseService; |
| | | import com.yssh.utils.Result; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Api(tags="告警分析") |
| | | @RequestMapping("/warning") |
| | | @RestController |
| | |
| | | |
| | | @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; |
| | | |
| | | //报警分析 |
| | | /** |
| | |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "三小时监测站点数据变化趋势", notes = "返回值为三小时监测站点监测数据,返回值为map集合,其中key为站点名称,value为list集合,保存每天监测数值数据") |
| | | @GetMapping("/locationDataChange") |
| | | public Result locationDataChange(){ |
| | | return Result.OK(warningService.selectEachLocationDataChange()); |
| | | public Result locationDataChange() { |
| | | //return Result.OK(warningService.selectEachLocationDataChange()); |
| | | |
| | | String key = dateFormat.format(new Date()); |
| | | Map<String, List<Double>> map = null; |
| | | if (cache.containsKey(key)) { |
| | | map = (Map<String, List<Double>>) cache.get(key); |
| | | } else { |
| | | map = warningService.selectEachLocationDataChange(); |
| | | if (null != map && map.size() > 0) { |
| | | if (cache.size() > 0) { |
| | | cache.clear(); |
| | | } |
| | | cache.put(key, map); |
| | | } |
| | | } |
| | | |
| | | return Result.ok(map); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 4) |