|
|
package com.monitor.common.service.impl;
|
|
|
|
|
|
//import com.esms.MessageData;
|
|
|
//import com.esms.PostMsg;
|
|
|
//import com.esms.common.entity.Account;
|
|
|
//import com.esms.common.entity.GsmsResponse;
|
|
|
//import com.esms.common.entity.MTPack;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.monitor.common.service.HttpRestClientService;
|
|
|
import com.monitor.common.service.VoiceMsgService;
|
|
|
import com.monitor.common.util.MD5Util;
|
|
|
import com.monitor.influxdb.contants.InfluxDBContants;
|
|
|
import com.monitor.influxdb.mapper.MonitorAlarmMapper;
|
|
|
import com.monitor.model.domain.VoiceSms;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
* Created by zhengyouwei on 2016/12/16.
|
...
|
...
|
@@ -37,40 +32,21 @@ public class VoiceMsgServiceImpl implements VoiceMsgService { |
|
|
public void sendVoide(String mobile) throws UnsupportedEncodingException {
|
|
|
|
|
|
try {
|
|
|
// Account account = new Account("yoho@yoho", "yoho@9646");//
|
|
|
// PostMsg pm = new PostMsg();
|
|
|
// pm.getCmHost().setHost("211.147.239.62", 9050);//设置网关的IP和port,用于发送信息
|
|
|
// MTPack pack = new MTPack();
|
|
|
// pack.setBatchID(UUID.randomUUID());
|
|
|
// pack.setBatchName("语音短信");
|
|
|
// pack.setMsgType(MTPack.MsgType.VOICE_CODE);//设置语音发送类型
|
|
|
// pack.setBizType(0);//设置UMP配置的语音专用业务类型
|
|
|
// pack.setDistinctFlag(false);
|
|
|
// ArrayList<MessageData> msgs = new ArrayList<MessageData>();
|
|
|
//
|
|
|
// /** 群发,多号码一内容 */
|
|
|
// pack.setSendType(MTPack.SendType.MASS);
|
|
|
// String content = "ABCDEFG";//设置语音验证码内容
|
|
|
// msgs.add(MessageData.getInstance("15905144483", content));
|
|
|
//
|
|
|
// GsmsResponse resp = pm.post(account, pack);
|
|
|
|
|
|
VoiceSms voiceSms = new VoiceSms();
|
|
|
voiceSms.setMsg("YOHO");
|
|
|
voiceSms.setExt("nothing");
|
|
|
String[] mobiles = mobile.split(",");
|
|
|
for (String str : mobiles) {
|
|
|
VoiceSms.Tel tel = new VoiceSms.Tel();
|
|
|
tel.setNationcode("86");
|
|
|
tel.setPhone(str);
|
|
|
voiceSms.setSig(MD5Util.encryption("6e56f948f6f1c0a1bc359e23f7acc140"+str));
|
|
|
voiceSms.setTel(tel);
|
|
|
DEBUG.info("send voice msg,content:{}",JSON.toJSONString(voiceSms));
|
|
|
String result = httpRestClientService.doPostStringJson("https://yun.tim.qq.com/v3/tlsvoicesvr/sendvoice?sdkappid=1400021400&random=123", JSON.toJSONString(voiceSms));
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// StringBuilder smsUrl = new StringBuilder();
|
|
|
// smsUrl.append("http://211.147.239.62:20510/cgi-bin/sendsms");
|
|
|
// smsUrl.append("?username=yoho@yoho");
|
|
|
// smsUrl.append("&password=yoho@9646");
|
|
|
// smsUrl.append("&to=");
|
|
|
// String[] mobiles = mobile.split(",");
|
|
|
// for (String str : mobiles) {
|
|
|
// smsUrl.append(str + " ");
|
|
|
// }
|
|
|
// smsUrl.append("&text=" + URLEncoder.encode("yoho", "GBK"));
|
|
|
// smsUrl.append("&subid=");
|
|
|
// smsUrl.append("&msgtype=9"); //msgtype:1 短信
|
|
|
// String result = httpRestClientService.doGet(smsUrl.toString(), null);
|
|
|
monitorAlarmMapper.insertAlarmMsg(InfluxDBContants.AWS, "voice", "yh", null, "");
|
|
|
} catch (Exception e) {
|
|
|
DEBUG.error("sendVoide error ", e);
|
...
|
...
|
|