|
|
package com.monitor.common.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.qcloudsms.SmsVoicePromptSender;
|
|
|
import com.github.qcloudsms.SmsVoicePromptSenderResult;
|
|
|
import com.monitor.common.config.SendsmsConfig;
|
|
|
import com.monitor.common.contants.AlarmSystemConstant;
|
|
|
import com.monitor.common.service.DingDingService;
|
...
|
...
|
@@ -20,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* Created by zhengyouwei on 2016/12/16.
|
...
|
...
|
@@ -70,27 +74,55 @@ public class VoiceMsgServiceImpl implements VoiceMsgService { |
|
|
}
|
|
|
|
|
|
try {
|
|
|
VoiceSmsNotice voiceSms = new VoiceSmsNotice();
|
|
|
String[] mobiles = mobile.split(",");
|
|
|
for (String str : mobiles) {
|
|
|
if(StringUtils.isBlank(str)){
|
|
|
continue;
|
|
|
}
|
|
|
DEBUG.info("send voice notice msg phone {} ,content:{}",str, promptfile );
|
|
|
SmsVoicePromptSender vpSender = new SmsVoicePromptSender(sendsmsConfig.getQcloudSmsSdkAppId(), sendsmsConfig.getQcloudSmsKey());
|
|
|
SmsVoicePromptSenderResult result = vpSender.send("86", str,
|
|
|
2, 2, promptfile, "");
|
|
|
DEBUG.info("send voice notice msg,result:{}", result);
|
|
|
|
|
|
//发送结果:result为0标识成功
|
|
|
boolean sendStatus = false;
|
|
|
if (result !=null ) {
|
|
|
try{
|
|
|
if(result.result==0){
|
|
|
sendStatus = true;
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
monitorAlarmMapper.insertAlarmMsg(InfluxDBContants.Q_CLOUD, "voice", promptfile, "null", sendStatus ? "successed" : "faild", JSON.toJSONString(result),mobile, AlarmSystemConstant.SYSTEM_IDC);
|
|
|
}
|
|
|
|
|
|
/*VoiceSmsNotice voiceSms = new VoiceSmsNotice();
|
|
|
long time = new Date().getTime()/1000;
|
|
|
voiceSms.setPromptfile(promptfile);
|
|
|
voiceSms.setExt("nothing");
|
|
|
String[] mobiles = mobile.split(",");
|
|
|
voiceSms.setTime(time);
|
|
|
|
|
|
for (String str : mobiles) {
|
|
|
VoiceSmsNotice.Tel tel = new VoiceSmsNotice.Tel();
|
|
|
tel.setPhone(str);
|
|
|
tel.setMobile(str);
|
|
|
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));
|
|
|
DEBUG.info("send voice notice msg,result:{}", result);
|
|
|
monitorAlarmMapper.insertAlarmMsg(InfluxDBContants.Q_CLOUD, "voice", promptfile, "null", result!=null ? "successed" : "faild", result,mobile, AlarmSystemConstant.SYSTEM_IDC);
|
|
|
}
|
|
|
|
|
|
dingDingService.insertMsg("yhops语音告警:"+promptfile);
|
|
|
}*/
|
|
|
} catch (Exception e) {
|
|
|
DEBUG.error("sendVoide notice error ", e);
|
|
|
}
|
|
|
|
|
|
dingDingService.insertMsg("yhops语音告警:"+promptfile);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
} |
...
|
...
|
|