...
|
...
|
@@ -5,10 +5,12 @@ import com.monitor.common.config.SendsmsConfig; |
|
|
import com.monitor.common.service.HttpRestClientService;
|
|
|
import com.monitor.common.service.VoiceMsgService;
|
|
|
import com.monitor.common.util.MD5Util;
|
|
|
import com.monitor.common.util.ZkClientUtil;
|
|
|
import com.monitor.influxdb.contants.InfluxDBContants;
|
|
|
import com.monitor.influxdb.mapper.MonitorAlarmMapper;
|
|
|
import com.monitor.model.domain.VoiceSms;
|
|
|
import com.monitor.model.domain.VoiceSmsNotice;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -31,9 +33,15 @@ public class VoiceMsgServiceImpl implements VoiceMsgService { |
|
|
@Autowired
|
|
|
private SendsmsConfig sendsmsConfig;
|
|
|
|
|
|
@Autowired
|
|
|
private ZkClientUtil zkClient;
|
|
|
|
|
|
public final Logger DEBUG = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@Override
|
|
|
private String ZK_PATH = "/yh/config/";
|
|
|
private String smsSendVoiceSwitch="ops.sendvoicesms.open";
|
|
|
|
|
|
/* @Override
|
|
|
public void sendVoice(String mobile) throws UnsupportedEncodingException {
|
|
|
|
|
|
try {
|
...
|
...
|
@@ -57,11 +65,23 @@ public class VoiceMsgServiceImpl implements VoiceMsgService { |
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void sendVoiceAlarm(String mobile,String content) throws UnsupportedEncodingException {
|
|
|
//根据zk的开关判断是否需要发送数据
|
|
|
String open="";
|
|
|
try{
|
|
|
//zkClient.getCuratorFramework().setData().forPath(ZK_PATH + smsSendSwitch,"true".getBytes("UTF-8"));
|
|
|
open = new String(zkClient.getCuratorFramework().getData().forPath(ZK_PATH + smsSendVoiceSwitch));
|
|
|
} catch (Exception e) {
|
|
|
DEBUG.error("Send msg type get ZK_PATH smsVoiceSendSwitch error",e);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(open)&&"false".equals(open)){
|
|
|
return ;//开关关掉了,不再发送语音
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
VoiceSmsNotice voiceSms = new VoiceSmsNotice();
|
|
|
String promptfile = "请及时处理故障:紧急故障";
|
...
|
...
|
@@ -77,10 +97,9 @@ public class VoiceMsgServiceImpl implements VoiceMsgService { |
|
|
voiceSms.setSig(MD5Util.encryption(sendsmsConfig.getQcloudSmsKey() + str));
|
|
|
voiceSms.setTel(tel);
|
|
|
DEBUG.info("send voice notice msg,content:{}", JSON.toJSONString(voiceSms));
|
|
|
// String result = httpRestClientService.doPostStringJson(sendsmsConfig.getQcloudVoiceUrl(), JSON.toJSONString(voiceSms));
|
|
|
String result="stop";
|
|
|
String result = httpRestClientService.doPostStringJson(sendsmsConfig.getQcloudVoiceUrl(), JSON.toJSONString(voiceSms));
|
|
|
DEBUG.info("send voice notice msg,result:{}", result);
|
|
|
// monitorAlarmMapper.insertAlarmMsg(InfluxDBContants.AWS, "voice", promptfile, "null", result!=null ? "successed" : "faild", result,mobile);
|
|
|
monitorAlarmMapper.insertAlarmMsg(InfluxDBContants.AWS, "voice", promptfile, "null", result!=null ? "successed" : "faild", result,mobile);
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
...
|
...
|
|