|
@ -12,6 +12,8 @@ import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
|
|
import com.yihu.wlyy.web.third.jkzl.ZBSmsService;
|
|
|
|
import net.sf.json.JSON;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
@ -48,27 +50,30 @@ public class SMSService extends BaseService {
|
|
private StringRedisTemplate redisTemplate;
|
|
private StringRedisTemplate redisTemplate;
|
|
@Value("${pushMes.redis_prescription_title}")
|
|
@Value("${pushMes.redis_prescription_title}")
|
|
private String redisQueue;
|
|
private String redisQueue;
|
|
|
|
@Autowired
|
|
|
|
private ZBSmsService zbSmsService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 内网通过redis的队列发送
|
|
* 内网通过redis的队列发送
|
|
|
|
*
|
|
* @param mobile
|
|
* @param mobile
|
|
* @param ip
|
|
* @param ip
|
|
* @param type
|
|
* @param type
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public String sendToNeiWang(String mobile, String ip, int type){
|
|
|
|
|
|
public String sendToNeiWang(String mobile, String ip, int type) {
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
json.put("mobile",mobile);
|
|
|
|
json.put("ip",ip);
|
|
|
|
json.put("type",type);
|
|
|
|
json.put("time",DateUtil.getStringDate());
|
|
|
|
|
|
json.put("mobile", mobile);
|
|
|
|
json.put("ip", ip);
|
|
|
|
json.put("type", type);
|
|
|
|
json.put("time", DateUtil.getStringDate());
|
|
com.alibaba.fastjson.JSONObject mes = new com.alibaba.fastjson.JSONObject();
|
|
com.alibaba.fastjson.JSONObject mes = new com.alibaba.fastjson.JSONObject();
|
|
mes.put("title", "sendSms");
|
|
mes.put("title", "sendSms");
|
|
mes.put("value", json.toString());
|
|
mes.put("value", json.toString());
|
|
redisTemplate.opsForList().leftPush(redisQueue, mes.toString());
|
|
redisTemplate.opsForList().leftPush(redisQueue, mes.toString());
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
return "ok";
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -188,20 +193,18 @@ public class SMSService extends BaseService {
|
|
sms.setIp(ip);
|
|
sms.setIp(ip);
|
|
sms.setType(type);
|
|
sms.setType(type);
|
|
sms.setStatus(1);
|
|
sms.setStatus(1);
|
|
// 调用总部发送信息的接口
|
|
|
|
String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(sms.getContent(), mobile), "GBK");
|
|
|
|
JSONObject json = toJson(result);
|
|
|
|
if (json == null) {
|
|
|
|
// 发送失败
|
|
|
|
throw new Exception("短信发送失败!");
|
|
|
|
} else if (json.getInt("result") != 0) {
|
|
|
|
return json.getString("description");
|
|
|
|
} else {
|
|
|
|
//发送成功,保存到数据库
|
|
|
|
|
|
// 调用发送信息的接口
|
|
|
|
String responseMessage = zbSmsService.sendMessage(mobile, sms.getContent());
|
|
|
|
if (!StringUtils.isEmpty(responseMessage)&& (net.sf.json.JSONObject.fromObject(responseMessage).getInt("Code")==10000)) {
|
|
|
|
// 发送成功
|
|
smsDao.save(sms);
|
|
smsDao.save(sms);
|
|
|
|
} else {
|
|
|
|
throw new Exception("短信发送失败!");
|
|
}
|
|
}
|
|
return "ok";
|
|
return "ok";
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 外部短信调用 发送短信验证码接口
|
|
* 外部短信调用 发送短信验证码接口
|
|
*
|
|
*
|
|
@ -233,20 +236,19 @@ public class SMSService extends BaseService {
|
|
sms.setIp(ip);
|
|
sms.setIp(ip);
|
|
sms.setType(type);
|
|
sms.setType(type);
|
|
sms.setStatus(1);
|
|
sms.setStatus(1);
|
|
// 调用总部发送信息的接口
|
|
|
|
String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(sms.getContent(), mobile), "GBK");
|
|
|
|
JSONObject json = toJson(result);
|
|
|
|
if (json == null) {
|
|
|
|
// 发送失败
|
|
|
|
throw new Exception("短信发送失败!");
|
|
|
|
} else if (json.getInt("result") != 0) {
|
|
|
|
return json.getString("description");
|
|
|
|
} else {
|
|
|
|
//发送成功,保存到数据库
|
|
|
|
|
|
// 调用发送信息的接口
|
|
|
|
// 调用发送信息的接口
|
|
|
|
// 调用发送信息的接口
|
|
|
|
String responseMessage = zbSmsService.sendMessage(mobile, sms.getContent());
|
|
|
|
if (!StringUtils.isEmpty(responseMessage)&& (net.sf.json.JSONObject.fromObject(responseMessage).getInt("Code")==10000)) {
|
|
|
|
// 发送成功
|
|
smsDao.save(sms);
|
|
smsDao.save(sms);
|
|
|
|
} else {
|
|
|
|
throw new Exception("短信发送失败!");
|
|
}
|
|
}
|
|
return "ok";
|
|
return "ok";
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 发送短信
|
|
* 发送短信
|
|
*
|
|
*
|
|
@ -254,11 +256,10 @@ public class SMSService extends BaseService {
|
|
* @param content
|
|
* @param content
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONObject sendMsg(String mobile, String content) {
|
|
|
|
|
|
public String sendMsg(String mobile, String content) {
|
|
// 调用总部发送信息的接口
|
|
// 调用总部发送信息的接口
|
|
String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(content, mobile), "GBK");
|
|
|
|
JSONObject json = toJson(result);
|
|
|
|
return json;
|
|
|
|
|
|
// 调用发送信息的接口
|
|
|
|
return zbSmsService.sendMessage(mobile, content);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|