Authored by qinchao

短信接口

package com.monitor.common.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.monitor.common.config.SendsmsConfig;
import com.monitor.common.service.AlarmMsgService;
import com.monitor.common.service.DingDingService;
... ... @@ -103,14 +104,23 @@ public class AlarmMsgServiceImpl implements AlarmMsgService {
if (StringUtils.isBlank(content)) {
return false;
}
String result = sendSingleSms(content, mobile);
boolean sendStatus = true;
if (result == null) {
sendStatus = false;
String resultJsonString = sendSingleSms(content, mobile);
//发送结果:result为0标识成功
boolean sendStatus = false;
if (resultJsonString !=null ) {
try{
JSONObject jo = JSON.parseObject(resultJsonString);
if(jo!=null&&jo.containsKey("result")&&jo.getIntValue("result")==0){
sendStatus = true;
}
}catch (Exception e){
}
}
try {
monitorAlarmMapper.insertAlarmMsg(InfluxDBContants.AWS, type, content, alarmInfo, sendStatus ? "successed" : "faild", result,mobile);
monitorAlarmMapper.insertAlarmMsg(InfluxDBContants.AWS, type, content, alarmInfo, sendStatus ? "successed" : "faild", resultJsonString,mobile);
} catch (Exception e) {
logger.error("insert sms into influxdb failed", e);
}
... ...
... ... @@ -45,13 +45,16 @@ public class MonitAlarmCtrl {
* @param mobiles 电话号码以逗号隔开 156xxxxx,187xxxxxx
*/
@RequestMapping("/recvMonitAlarmInfo")
public void recvMonitAlarmInfo(String info, String mobiles) {
public void recvMonitAlarmInfo(String info, String mobiles,String type ) {
DEBUG.info("mip monit alarm info: ", info);
DEBUG.info("mip monit alarm info {} ,type {}: ", info,type);
if (info == null) {
info = "";
}
alarmMsgService.sendSms("service_exception", info.toString(), mobiles);
if(type==null||type==""){
type= "service_exception";
}
alarmMsgService.sendSms(type, info.toString(), mobiles);
}
... ...