...
|
...
|
@@ -46,9 +46,9 @@ public class ResourcesSimplePiceAlarm { |
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
/**
|
|
|
* 十分钟监控一次
|
|
|
* 3分钟监控一次
|
|
|
*/
|
|
|
@Scheduled(cron = "0 2/10 * * * ?")
|
|
|
@Scheduled(cron = "0 2/3 * * * ?")
|
|
|
public void alarm() {
|
|
|
//发送拦截短信
|
|
|
String mobile_user = "13770338135";//耿超的电话//getUsersInfoUtil.getMobileByAlarmGroup(AlarmGroupContants.GROUP_NAME_USER_LOGIN);
|
...
|
...
|
@@ -56,33 +56,43 @@ public class ResourcesSimplePiceAlarm { |
|
|
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(WATCH_URL);
|
|
|
//WATCH_URL 包含了特殊字符,但不需要编码转义:build(true)
|
|
|
URI uri = builder.build(true).encode().toUri();
|
|
|
String alarmData = restTemplate.getForObject(uri, String.class);
|
|
|
|
|
|
if(alarmData==null||alarmData.length()==0){
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常:接口返回值为null异常",mobile_user);
|
|
|
return;
|
|
|
}
|
|
|
int failTimes=0;
|
|
|
for(int i=0;i<15;i++){
|
|
|
String alarmData = restTemplate.getForObject(uri, String.class);
|
|
|
|
|
|
JSONObject jsonObject=JSON.parseObject(alarmData);
|
|
|
if(jsonObject.get("code")==null||200!=(Integer)jsonObject.get("code")){
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常:code="+(String) jsonObject.get("code"),mobile_user);
|
|
|
return;
|
|
|
}
|
|
|
boolean correctData=false;
|
|
|
JSONObject dataJO=(JSONObject)jsonObject.get("data");
|
|
|
if(dataJO!=null){
|
|
|
if(dataJO.get("sk")!=null){
|
|
|
String sk=(String)dataJO.get("sk");
|
|
|
if(sk!=null&&sk.length()>0){
|
|
|
correctData=true;
|
|
|
if(alarmData==null||alarmData.length()==0){
|
|
|
failTimes++;
|
|
|
//alarm("RESOURCES.SIMPLE.PICE接口访问异常:接口返回值为null异常",mobile_user);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
JSONObject jsonObject=JSON.parseObject(alarmData);
|
|
|
if(jsonObject.get("code")==null||200!=(Integer)jsonObject.get("code")){
|
|
|
failTimes++;
|
|
|
//alarm("RESOURCES.SIMPLE.PICE接口访问异常:code="+(String) jsonObject.get("code"),mobile_user);
|
|
|
return;
|
|
|
}
|
|
|
boolean correctData=false;
|
|
|
JSONObject dataJO=(JSONObject)jsonObject.get("data");
|
|
|
if(dataJO!=null){
|
|
|
if(dataJO.get("sk")!=null){
|
|
|
String sk=(String)dataJO.get("sk");
|
|
|
if(sk!=null&&sk.length()>0){
|
|
|
correctData=true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(!correctData){
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常:data="+dataJO,mobile_user);
|
|
|
return;
|
|
|
if(!correctData){
|
|
|
failTimes++;
|
|
|
//alarm("RESOURCES.SIMPLE.PICE接口访问异常:data="+dataJO,mobile_user);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(failTimes>=10){
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常",mobile_user);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error("ResourcesSimplePiceAlarm watchurl RESOURCES.SIMPLE.PICE error",e);
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常,探测异常",mobile_user);
|
...
|
...
|
|