|
@ -1,7 +1,8 @@
|
|
|
package com.yihu.jw.sms.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.sms.dao.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.sms.dao.HospitalSysDictDao;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@ -20,19 +21,14 @@ import java.util.Map;
|
|
|
@Service
|
|
|
public class ZBSmsService {
|
|
|
private Logger logger= LoggerFactory.getLogger(ZBSmsService.class);
|
|
|
private String clientId;
|
|
|
private String resturl;
|
|
|
private String smsAPI;
|
|
|
private String smsHandlerId;
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao sysDictDao;
|
|
|
private String appId = "9000424";
|
|
|
// private String secret = "Q1ZCTGKMCTDYHGGQP9S4VJO6KUQRTIA39RKHJ57IIQ8";//测试参数
|
|
|
private String secret = "YM7WCB2LX32MCKFHWB64V4ARBGMQ36VOO8XOZ2TPP1B";//正式参数
|
|
|
private String prixUrl = "https://api.yihu.com/OpenPlatform/cgiBin/1.0/";//正式参数
|
|
|
// private String prixUrl = "https://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/";//测试参数
|
|
|
private HospitalSysDictDao sysDictDao;
|
|
|
private String appId;
|
|
|
private String secret;//正式参数
|
|
|
private String prixUrl;//正式参数
|
|
|
|
|
|
|
|
|
/**
|
|
@ -41,13 +37,7 @@ public class ZBSmsService {
|
|
|
private void init(){
|
|
|
List<WlyyHospitalSysDictDO> dictDOList = sysDictDao.findByDictName("zbSms");
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:dictDOList){
|
|
|
if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("clientId")){
|
|
|
clientId=wlyyHospitalSysDictDO.getDictValue();
|
|
|
}else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("resturl")){
|
|
|
resturl=wlyyHospitalSysDictDO.getDictValue();
|
|
|
}else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("smsAPI")){
|
|
|
smsAPI=wlyyHospitalSysDictDO.getDictValue();
|
|
|
}else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("smsHandlerId")){
|
|
|
if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("smsHandlerId")){
|
|
|
smsHandlerId=wlyyHospitalSysDictDO.getDictValue();
|
|
|
}else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("appId")){
|
|
|
appId=wlyyHospitalSysDictDO.getDictValue();
|
|
@ -64,7 +54,7 @@ public class ZBSmsService {
|
|
|
* 发送短信
|
|
|
* @return
|
|
|
*/
|
|
|
public Integer sendMessage(String mobile,String content) throws Exception {
|
|
|
public Integer sendMessage(String mobile,String code) throws Exception {
|
|
|
try{
|
|
|
//初始化参数
|
|
|
init();
|
|
@ -73,10 +63,10 @@ public class ZBSmsService {
|
|
|
Long.toString(System.currentTimeMillis());//timestamp必须与服务器时间相差在5分钟以内,否则调用将失败;
|
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>();
|
|
|
paramMap.put("provinceCode", "350000");
|
|
|
paramMap.put("cityCode", "350200");
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("code",code);
|
|
|
paramMap.put("mobile", mobile);
|
|
|
paramMap.put("content", content);
|
|
|
paramMap.put("templateParam", object.toJSONString());
|
|
|
paramMap.put("handlerId", smsHandlerId);
|
|
|
paramMap.put("timestamp", timestamp);
|
|
|
|