15 changed files with 291 additions and 33 deletions
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
package com.cloud.kicc.commonbiz.api.enums; |
||||
|
||||
/** |
||||
*<p> |
||||
* 地图任务状态枚举 |
||||
*</p> |
||||
* |
||||
* @Author: entfrm开发团队-王翔 |
||||
* @since: 2022/11/15 |
||||
*/ |
||||
public enum MapTaskStatusEnum { |
||||
|
||||
RUNNING("0","正在运行中"), |
||||
|
||||
END("9","结束"); |
||||
|
||||
private String status; |
||||
|
||||
private String description; |
||||
|
||||
MapTaskStatusEnum(String status, String description) { |
||||
this.status = status; |
||||
this.description = description; |
||||
} |
||||
|
||||
public String getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(String status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public void setDescription(String description) { |
||||
this.description = description; |
||||
} |
||||
} |
@ -0,0 +1,72 @@
@@ -0,0 +1,72 @@
|
||||
package com.cloud.kicc.commonbiz.util; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import okhttp3.MediaType; |
||||
import okhttp3.OkHttpClient; |
||||
import okhttp3.RequestBody; |
||||
import okhttp3.Response; |
||||
import org.apache.commons.codec.digest.DigestUtils; |
||||
|
||||
import java.io.BufferedReader; |
||||
import java.io.InputStreamReader; |
||||
|
||||
/** |
||||
*<p> |
||||
* 友盟推送客户端 |
||||
*</p> |
||||
* |
||||
* @Author: entfrm开发团队-王翔 |
||||
* @since: 2022/11/15 |
||||
*/ |
||||
public class PushClientUtil { |
||||
|
||||
private OkHttpClient okHttpClient; |
||||
|
||||
protected final String USER_AGENT = "Mozilla/5.0"; |
||||
|
||||
protected static final String host = "http://msg.umeng.com"; |
||||
|
||||
protected static final String postPath = "/api/send"; |
||||
|
||||
private static final String appMasterSecret = "kiv3ka9idqvqgiq7w3sudlp7azslty1r"; |
||||
|
||||
public PushClientUtil(OkHttpClient okHttpClient) { |
||||
this.okHttpClient = okHttpClient; |
||||
} |
||||
|
||||
public boolean send(JSONObject jsonObject) throws Exception { |
||||
String timestamp = Integer.toString((int)(System.currentTimeMillis() / 1000)); |
||||
jsonObject.put("timestamp", timestamp); |
||||
String url = host + postPath; |
||||
String postBody = jsonObject.toString(); |
||||
String sign = DigestUtils.md5Hex(("POST" + url + postBody + appMasterSecret).getBytes("utf8")); |
||||
url = url + "?sign=" + sign; |
||||
|
||||
// 发送post请求并获得响应
|
||||
okhttp3.Request request = new okhttp3.Request |
||||
.Builder() |
||||
.url(url) |
||||
.addHeader("User-Agent", USER_AGENT) |
||||
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postBody)) |
||||
.build(); |
||||
|
||||
Response response = okHttpClient.newCall(request).execute(); |
||||
int status = response.code(); |
||||
System.out.println("Response Code : " + status); |
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(response.body().byteStream())); |
||||
StringBuffer result = new StringBuffer(); |
||||
String line; |
||||
while ((line = rd.readLine()) != null) { |
||||
result.append(line); |
||||
} |
||||
System.out.println(result); |
||||
if (status == 200) { |
||||
System.out.println("Notification sent successfully."); |
||||
} else { |
||||
System.out.println("Failed to send the notification!"); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue