feat: 增加大汉移动页面接口调用

dev
huangfeng 11 months ago
parent 926c9122cf
commit a7cbfcea70

@ -0,0 +1,85 @@
package com.shxy.xymanager_common.sms.dahan;
import com.shxy.xymanager_common.exception.ApiException;
import com.shxy.xymanager_common.util.HttpClient;
import com.shxy.xymanager_common.util.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class DahanWeb {
private String baseUrl = "http://iot.dahancloud.com/mySms";
public static String cookie = "";
private Map<String, String> buildHead() {
Map<String, String> map = new HashMap<>();
map.put("Cookie", cookie);
return map;
}
public Object listSms(String msisdn, String date) {
String url = "/smsPage";
Map<String, String> dataMap = new HashMap<>();
dataMap.put("filter", msisdn);
dataMap.put("smsType", "0");
dataMap.put("page", "340");
dataMap.put("rows", "10");
try {
HashMap<String, Object> result = null;
String json = HttpClient.get(baseUrl + url, dataMap, this.buildHead());
log.info("查询短信记录完成: " + json);
try {
result = JSONUtil.json2Object(json, HashMap.class);
} catch (Exception e) {
throw new ApiException(json);
}
if (result.get("rows") != null) {
return result.get("rows");
} else {
String error = String.valueOf(result.get("message"));
throw new ApiException(error);
}
} catch (Exception e) {
log.error("查询短信异常.", e);
throw new ApiException("查询短信异常," + e.getMessage());
}
}
public void sendSms(List<String> iccidList, String content) {
String url = "/cardSendMt";
try {
for (String iccid : iccidList) {
Map<String, String> dataMap = new HashMap<>();
dataMap.put("iccid", iccid);
dataMap.put("content", content);
String json = HttpClient.get(baseUrl + url, dataMap, this.buildHead());
log.info("发送短信完成:" + json);
HashMap<String, Object> result = null;
try {
result = JSONUtil.json2Object(json, HashMap.class);
} catch (Exception e) {
throw new ApiException(json);
}
if (result.get("code") != null && "200".equalsIgnoreCase(result.get("code").toString())) {
} else {
String error = String.valueOf(result.get("message"));
throw new ApiException(error);
}
}
} catch (ApiException e) {
throw e;
} catch (Exception e) {
log.error("发送短信异常.", e);
throw new ApiException("发送短信异常," + e.getMessage());
}
}
}

@ -33,6 +33,7 @@ public class LwwlkjWeb {
HashMap<String, Object> result = null; HashMap<String, Object> result = null;
String json = HttpClient.postUrlEncoded(baseUrl + url, dataMap, this.buildHead()); String json = HttpClient.postUrlEncoded(baseUrl + url, dataMap, this.buildHead());
log.info("查询短信记录完成: " + json); log.info("查询短信记录完成: " + json);
// 返回是个html
return json; return json;
} catch (Exception e) { } catch (Exception e) {
log.error("查询短信异常.", e); log.error("查询短信异常.", e);

@ -16,10 +16,15 @@ public class RabchaserWeb {
private String baseUrl = "http://www.rabchaser.com/api"; private String baseUrl = "http://www.rabchaser.com/api";
public static String authorization = ""; public static String authorization = "";
public Object selectMsgReceive(String iccid, String date) { private Map<String, String> buildHead() {
Map<String, String> map = new HashMap<>();
map.put("Authorization", authorization);
return map;
}
public Object listSms(String iccid, String date) {
String url = "/cardquery/selectMsgReceiveByPage"; String url = "/cardquery/selectMsgReceiveByPage";
Map<String, String> headMap = new HashMap<>();
headMap.put("Authorization", authorization);
Map<String, Object> dataMap = new HashMap<>(); Map<String, Object> dataMap = new HashMap<>();
dataMap.put("iccid", iccid); dataMap.put("iccid", iccid);
// dataMap.put("receiveTime", date); // dataMap.put("receiveTime", date);
@ -27,7 +32,7 @@ public class RabchaserWeb {
dataMap.put("pageSize", 10); dataMap.put("pageSize", 10);
try { try {
HashMap<String, Object> result = null; HashMap<String, Object> result = null;
String json = HttpClient.post(baseUrl + url, dataMap, headMap); String json = HttpClient.post(baseUrl + url, dataMap, this.buildHead());
log.info("查询短信记录完成: " + json); log.info("查询短信记录完成: " + json);
try { try {
result = JSONUtil.json2Object(json, HashMap.class); result = JSONUtil.json2Object(json, HashMap.class);

Loading…
Cancel
Save