Showing
10 changed files
with
74 additions
and
81 deletions
@@ -144,27 +144,6 @@ | @@ -144,27 +144,6 @@ | ||
144 | <artifactId>fastjson</artifactId> | 144 | <artifactId>fastjson</artifactId> |
145 | </dependency> | 145 | </dependency> |
146 | 146 | ||
147 | - <!--<dependency>--> | ||
148 | - <!--<groupId>com.xuanwu</groupId>--> | ||
149 | - <!--<artifactId>postmsg-ump</artifactId>--> | ||
150 | - <!--<version>2.4.1</version>--> | ||
151 | - <!--</dependency>--> | ||
152 | - <!--<dependency>--> | ||
153 | - <!--<groupId>com.google.protobuf</groupId>--> | ||
154 | - <!--<artifactId>protobuf-java</artifactId>--> | ||
155 | - <!--<version>2.4.1</version>--> | ||
156 | - <!--</dependency>--> | ||
157 | - <!--<dependency>--> | ||
158 | - <!--<groupId>xpp3</groupId>--> | ||
159 | - <!--<artifactId>xpp3_min</artifactId>--> | ||
160 | - <!--<version>1.1.4c</version>--> | ||
161 | - <!--</dependency>--> | ||
162 | - <!--<dependency>--> | ||
163 | - <!--<groupId>com.thoughtworks.xstream</groupId>--> | ||
164 | - <!--<artifactId>xstream</artifactId>--> | ||
165 | - <!--<version>1.3.1</version>--> | ||
166 | - <!--</dependency>--> | ||
167 | - | ||
168 | </dependencies> | 147 | </dependencies> |
169 | 148 | ||
170 | </project> | 149 | </project> |
1 | package com.monitor.common.service.impl; | 1 | package com.monitor.common.service.impl; |
2 | 2 | ||
3 | -//import com.esms.MessageData; | ||
4 | -//import com.esms.PostMsg; | ||
5 | -//import com.esms.common.entity.Account; | ||
6 | -//import com.esms.common.entity.GsmsResponse; | ||
7 | -//import com.esms.common.entity.MTPack; | 3 | +import com.alibaba.fastjson.JSON; |
8 | import com.monitor.common.service.HttpRestClientService; | 4 | import com.monitor.common.service.HttpRestClientService; |
9 | import com.monitor.common.service.VoiceMsgService; | 5 | import com.monitor.common.service.VoiceMsgService; |
6 | +import com.monitor.common.util.MD5Util; | ||
10 | import com.monitor.influxdb.contants.InfluxDBContants; | 7 | import com.monitor.influxdb.contants.InfluxDBContants; |
11 | import com.monitor.influxdb.mapper.MonitorAlarmMapper; | 8 | import com.monitor.influxdb.mapper.MonitorAlarmMapper; |
9 | +import com.monitor.model.domain.VoiceSms; | ||
12 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
13 | import org.slf4j.LoggerFactory; | 11 | import org.slf4j.LoggerFactory; |
14 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
15 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
16 | 14 | ||
17 | import java.io.UnsupportedEncodingException; | 15 | import java.io.UnsupportedEncodingException; |
18 | -import java.net.URLEncoder; | ||
19 | -import java.util.ArrayList; | ||
20 | -import java.util.UUID; | ||
21 | 16 | ||
22 | /** | 17 | /** |
23 | * Created by zhengyouwei on 2016/12/16. | 18 | * Created by zhengyouwei on 2016/12/16. |
@@ -37,40 +32,21 @@ public class VoiceMsgServiceImpl implements VoiceMsgService { | @@ -37,40 +32,21 @@ public class VoiceMsgServiceImpl implements VoiceMsgService { | ||
37 | public void sendVoide(String mobile) throws UnsupportedEncodingException { | 32 | public void sendVoide(String mobile) throws UnsupportedEncodingException { |
38 | 33 | ||
39 | try { | 34 | try { |
40 | -// Account account = new Account("yoho@yoho", "yoho@9646");// | ||
41 | -// PostMsg pm = new PostMsg(); | ||
42 | -// pm.getCmHost().setHost("211.147.239.62", 9050);//设置网关的IP和port,用于发送信息 | ||
43 | -// MTPack pack = new MTPack(); | ||
44 | -// pack.setBatchID(UUID.randomUUID()); | ||
45 | -// pack.setBatchName("语音短信"); | ||
46 | -// pack.setMsgType(MTPack.MsgType.VOICE_CODE);//设置语音发送类型 | ||
47 | -// pack.setBizType(0);//设置UMP配置的语音专用业务类型 | ||
48 | -// pack.setDistinctFlag(false); | ||
49 | -// ArrayList<MessageData> msgs = new ArrayList<MessageData>(); | ||
50 | -// | ||
51 | -// /** 群发,多号码一内容 */ | ||
52 | -// pack.setSendType(MTPack.SendType.MASS); | ||
53 | -// String content = "ABCDEFG";//设置语音验证码内容 | ||
54 | -// msgs.add(MessageData.getInstance("15905144483", content)); | ||
55 | -// | ||
56 | -// GsmsResponse resp = pm.post(account, pack); | ||
57 | 35 | ||
36 | + VoiceSms voiceSms = new VoiceSms(); | ||
37 | + voiceSms.setMsg("YOHO"); | ||
38 | + voiceSms.setExt("nothing"); | ||
39 | + String[] mobiles = mobile.split(","); | ||
40 | + for (String str : mobiles) { | ||
41 | + VoiceSms.Tel tel = new VoiceSms.Tel(); | ||
42 | + tel.setNationcode("86"); | ||
43 | + tel.setPhone(str); | ||
44 | + voiceSms.setSig(MD5Util.encryption("6e56f948f6f1c0a1bc359e23f7acc140"+str)); | ||
45 | + voiceSms.setTel(tel); | ||
46 | + DEBUG.info("send voice msg,content:{}",JSON.toJSONString(voiceSms)); | ||
47 | + String result = httpRestClientService.doPostStringJson("https://yun.tim.qq.com/v3/tlsvoicesvr/sendvoice?sdkappid=1400021400&random=123", JSON.toJSONString(voiceSms)); | ||
48 | + } | ||
58 | 49 | ||
59 | - | ||
60 | - | ||
61 | -// StringBuilder smsUrl = new StringBuilder(); | ||
62 | -// smsUrl.append("http://211.147.239.62:20510/cgi-bin/sendsms"); | ||
63 | -// smsUrl.append("?username=yoho@yoho"); | ||
64 | -// smsUrl.append("&password=yoho@9646"); | ||
65 | -// smsUrl.append("&to="); | ||
66 | -// String[] mobiles = mobile.split(","); | ||
67 | -// for (String str : mobiles) { | ||
68 | -// smsUrl.append(str + " "); | ||
69 | -// } | ||
70 | -// smsUrl.append("&text=" + URLEncoder.encode("yoho", "GBK")); | ||
71 | -// smsUrl.append("&subid="); | ||
72 | -// smsUrl.append("&msgtype=9"); //msgtype:1 短信 | ||
73 | -// String result = httpRestClientService.doGet(smsUrl.toString(), null); | ||
74 | monitorAlarmMapper.insertAlarmMsg(InfluxDBContants.AWS, "voice", "yh", null, ""); | 50 | monitorAlarmMapper.insertAlarmMsg(InfluxDBContants.AWS, "voice", "yh", null, ""); |
75 | } catch (Exception e) { | 51 | } catch (Exception e) { |
76 | DEBUG.error("sendVoide error ", e); | 52 | DEBUG.error("sendVoide error ", e); |
1 | package com.monitor.influxdb.mapper; | 1 | package com.monitor.influxdb.mapper; |
2 | 2 | ||
3 | +import com.monitor.model.domain.QcloudSmsUpBody; | ||
3 | import com.monitor.model.request.SmsUp; | 4 | import com.monitor.model.request.SmsUp; |
4 | import org.influxdb.dto.QueryResult; | 5 | import org.influxdb.dto.QueryResult; |
5 | 6 | ||
@@ -8,7 +9,7 @@ import org.influxdb.dto.QueryResult; | @@ -8,7 +9,7 @@ import org.influxdb.dto.QueryResult; | ||
8 | */ | 9 | */ |
9 | public interface SmsUpMapper { | 10 | public interface SmsUpMapper { |
10 | 11 | ||
11 | - void insert(SmsUp smsUp); | 12 | + void insert(QcloudSmsUpBody qcloudSmsUpBody); |
12 | 13 | ||
13 | QueryResult select(int min); | 14 | QueryResult select(int min); |
14 | } | 15 | } |
@@ -100,8 +100,8 @@ public class MonitorAlarmMapperImpl extends InfluxDBQuery implements MonitorAlar | @@ -100,8 +100,8 @@ public class MonitorAlarmMapperImpl extends InfluxDBQuery implements MonitorAlar | ||
100 | 100 | ||
101 | @Override | 101 | @Override |
102 | public QueryResult selectVoiceAlarm(String influxDBName, int min) { | 102 | public QueryResult selectVoiceAlarm(String influxDBName, int min) { |
103 | - // String command = "SELECT count(sms_content) FROM monitor_alarm where time > now() - "+ min+"m and type != 'work_system'"; | ||
104 | - String command = "SELECT count(sms_content) FROM monitor_alarm where time > now() - "+ min+"m"; | 103 | + String command = "SELECT count(sms_content) FROM monitor_alarm where time > now() - "+ min+"m and type != 'work_system'"; |
104 | + // String command = "SELECT count(sms_content) FROM monitor_alarm where time > now() - "+ min+"m"; | ||
105 | return query(influxDBName, command, InfluxDBContants.YOMO_MONITOR); | 105 | return query(influxDBName, command, InfluxDBContants.YOMO_MONITOR); |
106 | 106 | ||
107 | } | 107 | } |
@@ -3,6 +3,7 @@ package com.monitor.influxdb.mapper.impl; | @@ -3,6 +3,7 @@ package com.monitor.influxdb.mapper.impl; | ||
3 | import com.monitor.influxdb.InfluxDBQuery; | 3 | import com.monitor.influxdb.InfluxDBQuery; |
4 | import com.monitor.influxdb.contants.InfluxDBContants; | 4 | import com.monitor.influxdb.contants.InfluxDBContants; |
5 | import com.monitor.influxdb.mapper.SmsUpMapper; | 5 | import com.monitor.influxdb.mapper.SmsUpMapper; |
6 | +import com.monitor.model.domain.QcloudSmsUpBody; | ||
6 | import com.monitor.model.request.SmsUp; | 7 | import com.monitor.model.request.SmsUp; |
7 | import org.apache.commons.lang.StringUtils; | 8 | import org.apache.commons.lang.StringUtils; |
8 | import org.influxdb.dto.BatchPoints; | 9 | import org.influxdb.dto.BatchPoints; |
@@ -17,18 +18,19 @@ import org.springframework.stereotype.Component; | @@ -17,18 +18,19 @@ import org.springframework.stereotype.Component; | ||
17 | public class SmsUpMapperImpl extends InfluxDBQuery implements SmsUpMapper { | 18 | public class SmsUpMapperImpl extends InfluxDBQuery implements SmsUpMapper { |
18 | 19 | ||
19 | @Override | 20 | @Override |
20 | - public void insert(SmsUp smsUp) { | 21 | + public void insert(QcloudSmsUpBody qcloudSmsUpBody) { |
21 | BatchPoints batchPoints = BatchPoints | 22 | BatchPoints batchPoints = BatchPoints |
22 | .database(InfluxDBContants.YOMO_MONITOR).retentionPolicy("default") | 23 | .database(InfluxDBContants.YOMO_MONITOR).retentionPolicy("default") |
23 | .build(); | 24 | .build(); |
24 | Point point = Point.measurement("sms_up") | 25 | Point point = Point.measurement("sms_up") |
25 | - .addField("SmsType", smsUp.getSmsType()) | ||
26 | - .addField("SrcMobile", StringUtils.isBlank(smsUp.getSrcMobile())?" ":smsUp.getSrcMobile()) | ||
27 | - .addField("AppendID", StringUtils.isBlank(smsUp.getAppendID())?" ":smsUp.getAppendID()) | ||
28 | - .addField("Content", StringUtils.isBlank(smsUp.getContent())?" ":smsUp.getContent()) | ||
29 | - .addField("RecvTime", StringUtils.isBlank(smsUp.getRecvTime())?" ":smsUp.getRecvTime()) | ||
30 | - .addField("SendTime", StringUtils.isBlank(smsUp.getSendTime())?" ":smsUp.getSendTime()) | ||
31 | - .addField("Status", StringUtils.isBlank(smsUp.getStatus()) ? " " : smsUp.getStatus()).build(); | 26 | + .addField("result", qcloudSmsUpBody.getResult()) |
27 | + .addField("callid", StringUtils.isBlank(qcloudSmsUpBody.getCallid()) ? " " : qcloudSmsUpBody.getCallid()) | ||
28 | + .addField("mobile", StringUtils.isBlank(qcloudSmsUpBody.getMobile())?" ":qcloudSmsUpBody.getMobile()) | ||
29 | + .addField("nationcode", StringUtils.isBlank(qcloudSmsUpBody.getNationcode())?" ":qcloudSmsUpBody.getNationcode()) | ||
30 | + .addField("call_from", StringUtils.isBlank(qcloudSmsUpBody.getCall_from())?" ":qcloudSmsUpBody.getCall_from()) | ||
31 | + .addField("start_calltime", StringUtils.isBlank(qcloudSmsUpBody.getStart_calltime())?" ":qcloudSmsUpBody.getStart_calltime()) | ||
32 | + .addField("accept_time", StringUtils.isBlank(qcloudSmsUpBody.getAccept_time()) ? " " : qcloudSmsUpBody.getAccept_time()) | ||
33 | + .addField("fee", StringUtils.isBlank(qcloudSmsUpBody.getFee()) ? " " : qcloudSmsUpBody.getFee()).build(); | ||
32 | batchPoints.point(point); | 34 | batchPoints.point(point); |
33 | inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB() | 35 | inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB() |
34 | .write(batchPoints); | 36 | .write(batchPoints); |
@@ -37,7 +39,7 @@ public class SmsUpMapperImpl extends InfluxDBQuery implements SmsUpMapper { | @@ -37,7 +39,7 @@ public class SmsUpMapperImpl extends InfluxDBQuery implements SmsUpMapper { | ||
37 | @Override | 39 | @Override |
38 | public QueryResult select(int min) { | 40 | public QueryResult select(int min) { |
39 | 41 | ||
40 | - String command = "SELECT count(SrcMobile) FROM sms_up where time > now() - "+ min+"m"; | 42 | + String command = "SELECT count(SrcMobile) FROM sms_up where time > now() - "+ min+"m and result = '0'"; |
41 | return query(InfluxDBContants.AWS, command, InfluxDBContants.YOMO_MONITOR); | 43 | return query(InfluxDBContants.AWS, command, InfluxDBContants.YOMO_MONITOR); |
42 | 44 | ||
43 | 45 |
1 | +package com.monitor.model.domain; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by zhengyouwei on 2016/12/16. | ||
7 | + */ | ||
8 | +@Data | ||
9 | +public class QcloudSmsUpBody { | ||
10 | + | ||
11 | + private String result; | ||
12 | + private String callid; | ||
13 | + private String mobile; | ||
14 | + private String nationcode; | ||
15 | + private String call_from; | ||
16 | + private String start_calltime; | ||
17 | + private String end_calltime; | ||
18 | + private String accept_time; | ||
19 | + private String fee; | ||
20 | + | ||
21 | + | ||
22 | +} |
@@ -10,15 +10,13 @@ public class VoiceSms { | @@ -10,15 +10,13 @@ public class VoiceSms { | ||
10 | 10 | ||
11 | private Tel tel; | 11 | private Tel tel; |
12 | 12 | ||
13 | - private int prompttype; | ||
14 | - | ||
15 | - private String promptfile; | 13 | + private String msg; |
16 | 14 | ||
17 | private String sig ; | 15 | private String sig ; |
18 | 16 | ||
19 | private String ext; | 17 | private String ext; |
20 | 18 | ||
21 | - static class Tel{ | 19 | + public static class Tel{ |
22 | private String nationcode; | 20 | private String nationcode; |
23 | 21 | ||
24 | private String phone; | 22 | private String phone; |
@@ -2,6 +2,7 @@ package com.monitor.other.smsUp; | @@ -2,6 +2,7 @@ package com.monitor.other.smsUp; | ||
2 | 2 | ||
3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
4 | import com.monitor.influxdb.mapper.SmsUpMapper; | 4 | import com.monitor.influxdb.mapper.SmsUpMapper; |
5 | +import com.monitor.model.domain.QcloudSmsUp; | ||
5 | import com.monitor.model.request.SmsUp; | 6 | import com.monitor.model.request.SmsUp; |
6 | import com.monitor.model.response.BaseResponse; | 7 | import com.monitor.model.response.BaseResponse; |
7 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
@@ -29,10 +30,10 @@ public class SmsUpctrl { | @@ -29,10 +30,10 @@ public class SmsUpctrl { | ||
29 | */ | 30 | */ |
30 | @RequestMapping("/smsup") | 31 | @RequestMapping("/smsup") |
31 | @ResponseBody | 32 | @ResponseBody |
32 | - public BaseResponse smsup(@RequestBody SmsUp smsUp) { | ||
33 | - logger.info("smsup req :{}", JSON.toJSONString(smsUp)); | 33 | + public BaseResponse smsup(@RequestBody QcloudSmsUp qcloudSmsUp) { |
34 | + logger.info("smsup req :{}", JSON.toJSONString(qcloudSmsUp)); | ||
34 | try { | 35 | try { |
35 | - smsUpMapper.insert(smsUp); | 36 | + smsUpMapper.insert(qcloudSmsUp.getVoicecode_callback()); |
36 | }catch (Exception e){ | 37 | }catch (Exception e){ |
37 | logger.error("smsup",e); | 38 | logger.error("smsup",e); |
38 | } | 39 | } |
@@ -37,7 +37,7 @@ public class AlarmSendVoiceTask { | @@ -37,7 +37,7 @@ public class AlarmSendVoiceTask { | ||
37 | try { | 37 | try { |
38 | long now = System.currentTimeMillis(); | 38 | long now = System.currentTimeMillis(); |
39 | 39 | ||
40 | - QueryResult queryResult = monitorAlarmMapper.selectVoiceAlarm(InfluxDBContants.AWS, 120); | 40 | + QueryResult queryResult = monitorAlarmMapper.selectVoiceAlarm(InfluxDBContants.AWS, 30); |
41 | int count = QueryResultUtil.getCount(queryResult); | 41 | int count = QueryResultUtil.getCount(queryResult); |
42 | if (count > 5){//大于无 | 42 | if (count > 5){//大于无 |
43 | //todo 查询是否需要语音通知 | 43 | //todo 查询是否需要语音通知 |
-
Please register or login to post a comment