src/main/java/com/yssh/controller/AlertConfigController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/service/WarningAnalyseService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/QxshMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/yssh/controller/AlertConfigController.java
@@ -1,9 +1,11 @@ package com.yssh.controller; import com.yssh.utils.CacheUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import java.util.Date; import java.util.List; import org.springframework.web.bind.annotation.DeleteMapping; @@ -79,4 +81,13 @@ } return Result.OK("删除成功"); } @ApiOperationSupport(order = 6) @ApiOperation(value = "清除缓存", notes = "清除缓存") @GetMapping("/clearCache") public Result clearCache() { CacheUtils.clear(); return Result.OK("success."); } } src/main/java/com/yssh/service/WarningAnalyseService.java
@@ -89,6 +89,12 @@ Integer start = Integer.parseInt(DateUtils.getYyyyMmDdHh(startDate)); Integer end = Integer.parseInt(DateUtils.getYyyyMmDdHh(endDate)); String key = "WAS.monthCount." + start + "." + end; Object obj = CacheUtils.get(key); if (obj instanceof Map<?, ?>) { return (Map<String, Integer>) obj; } Map<String, Integer> result = new HashMap<>(); Integer warnNum = qxshMapper.countMonthForWarn(start, end); result.put("warningNumber", null == warnNum ? 0 : warnNum); @@ -96,6 +102,8 @@ Integer alarmNum = qxshMapper.countMonthForAlarm(start, end); result.put("alarmNumber", null == alarmNum ? 0 : alarmNum); CacheUtils.put(key, result); return result; } src/main/resources/mapper/QxshMapper.xml
@@ -65,10 +65,11 @@ </select> <select id="countMonthForWarn" resultType="java.lang.Integer"> with rs as (select jcyj, jcbj from alert_config limit 1) select count(*) from yssh_gcsj where time between #{start} and #{end} and name like 'AI-%' and value > (select jcyj from alert_config limit 1) and value <= (select jcbj from alert_config limit 1); and value > (select jcyj from rs) and value <= (select jcbj from rs); </select> <select id="countMonthForAlarm" resultType="java.lang.Integer">