From 370117aecc3c5faded8ed6b27f19e06216c95337 Mon Sep 17 00:00:00 2001 From: guyuliang Date: Tue, 27 Aug 2024 15:49:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=B9=B3=E5=8F=B0=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../booter/controller/IndexDataController.java | 13 +++++++++++++ .../bocloud/sms/interfaces/IndexService.java | 2 ++ .../bocloud/sms/service/IndexServiceImpl.java | 17 +++++++++++++---- .../java/com/bocloud/sms/utils/WarnUtil.java | 5 +++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/IndexDataController.java b/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/IndexDataController.java index dfcb42a..958b16d 100644 --- a/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/IndexDataController.java +++ b/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/IndexDataController.java @@ -63,6 +63,7 @@ public class IndexDataController { public GeneralResult userStatic(@Value(Common.REQ_CONTEXT) RequestContext requestContext) { return indexService.userDataStatic(requestContext); } + /** * 当前用户授权应用列表 * @param pager @@ -74,4 +75,16 @@ public class IndexDataController { public GeneralResult userAppList(@Value(Common.REQ_CONTEXT) RequestContext requestContext) { return indexService.userAppList(requestContext); } + + /** + * 近7日告警趋势 + * @param pager + * @param requestContext + * @return + */ + @GetMapping("/sevenDayWarnTrend") + @Operation(summary = "近7日告警趋势") + public GeneralResult sevenDayWarnTrend(@Value(Common.REQ_CONTEXT) RequestContext requestContext) { + return indexService.sevenDayWarnTrend(requestContext); + } } diff --git a/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/IndexService.java b/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/IndexService.java index 5081def..18cc0ce 100644 --- a/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/IndexService.java +++ b/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/IndexService.java @@ -15,4 +15,6 @@ public interface IndexService { GeneralResult userDataStatic(RequestContext requestContext); GeneralResult userAppList(RequestContext requestContext); + + GeneralResult sevenDayWarnTrend(RequestContext requestContext); } diff --git a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/IndexServiceImpl.java b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/IndexServiceImpl.java index c8625da..fc8dc34 100644 --- a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/IndexServiceImpl.java +++ b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/IndexServiceImpl.java @@ -101,10 +101,6 @@ public class IndexServiceImpl implements IndexService { String data = ykUtil.call(YkInfo.getCountTaskByUser, userParam, JSONArray.class); List list = JSONObject.parseObject(data, List.class); - String result = warnUtil.call(WarnInfo.get1DayWarnCount.getUrl(), "GET"); - log.info("result:" + result); - -// log.info("resultMap:{}", JSON.toJSONString(resultMap)); return new GeneralResult(true, list, "查询成功"); } catch (Exception e) { @@ -144,6 +140,19 @@ public class IndexServiceImpl implements IndexService { } } + @Override + public GeneralResult sevenDayWarnTrend(RequestContext requestContext) { + + try { + String result = warnUtil.call(WarnInfo.get7DayWarnTrend.getUrl(), "GET"); + log.info("result:"+result); + return new GeneralResult(true, "查询成功"); + } catch (Exception e) { + log.info("查询失败", e); + return new GeneralResult(false, "查询失败"); + } + } + private List getUserAppList(RequestContext requestContext) throws Exception { //查询当前用户授权应用 JSONObject param = new JSONObject(); diff --git a/bocloud.sms.storage/src/main/java/com/bocloud/sms/utils/WarnUtil.java b/bocloud.sms.storage/src/main/java/com/bocloud/sms/utils/WarnUtil.java index c0ecaca..70df1cb 100644 --- a/bocloud.sms.storage/src/main/java/com/bocloud/sms/utils/WarnUtil.java +++ b/bocloud.sms.storage/src/main/java/com/bocloud/sms/utils/WarnUtil.java @@ -21,6 +21,11 @@ public class WarnUtil { @Value("${warn.password:alistarapi123}") private String password; + public static void main(String[] args) { + String user = "alistar:alistarapi123"; + System.out.println(Base64.getEncoder().encodeToString(user.getBytes())); + } + public String call(String urlSuffix, String method) throws Exception { URL obj = new URL(url + urlSuffix);