告警平台对接

develop
guyuliang 2024-08-27 15:49:54 +08:00
parent 49501e1d1c
commit 370117aecc
4 changed files with 33 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -15,4 +15,6 @@ public interface IndexService {
GeneralResult userDataStatic(RequestContext requestContext);
GeneralResult userAppList(RequestContext requestContext);
GeneralResult sevenDayWarnTrend(RequestContext requestContext);
}

View File

@ -101,10 +101,6 @@ public class IndexServiceImpl implements IndexService {
String data = ykUtil.call(YkInfo.getCountTaskByUser, userParam, JSONArray.class);
List<JSONObject> 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<JSONObject> getUserAppList(RequestContext requestContext) throws Exception {
//查询当前用户授权应用
JSONObject param = new JSONObject();

View File

@ -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);