diff --git a/JSD-8493配置使用文档.docx b/JSD-8493配置使用文档.docx
new file mode 100644
index 0000000..2821ea7
Binary files /dev/null and b/JSD-8493配置使用文档.docx differ
diff --git a/README.md b/README.md
index 3cde29b..fc7e1ec 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
# open-JSD-8493
-JSD-8493 开源任务材料
\ No newline at end of file
+JSD-8493 短信推送\
+免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
+仅作为开发者学习参考使用!禁止用于任何商业用途!\
+为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。
\ No newline at end of file
diff --git a/lib/gson-2.8.6.jar b/lib/gson-2.8.6.jar
new file mode 100644
index 0000000..4765c4a
Binary files /dev/null and b/lib/gson-2.8.6.jar differ
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..b57c97b
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,28 @@
+
+ com.fr.plugin.ymrt.sms
+
+ yes
+ 1.1
+ 10.0
+ 2018-07-31
+ fr.open
+
+
+ [2021-09-14]【1.0】重新打包。
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/ymrt/sms/OutputPluginLifecycleMonitor.java b/src/main/java/com/fr/plugin/ymrt/sms/OutputPluginLifecycleMonitor.java
new file mode 100644
index 0000000..dd84386
--- /dev/null
+++ b/src/main/java/com/fr/plugin/ymrt/sms/OutputPluginLifecycleMonitor.java
@@ -0,0 +1,29 @@
+package com.fr.plugin.ymrt.sms;
+
+import com.fr.plugin.context.PluginContext;
+import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
+import com.fr.plugin.ymrt.sms.bean.OutputSmsAction;
+import com.fr.plugin.ymrt.sms.entity.SmsEntity;
+import com.fr.plugin.ymrt.sms.handle.SmsOutputActionHandler;
+import com.fr.schedule.feature.ScheduleOutputActionEntityRegister;
+import com.fr.schedule.feature.output.OutputActionHandler;
+
+/**
+ * @Author fr.open
+ * @Date 2020/9/15
+ * @Description
+ **/
+public class OutputPluginLifecycleMonitor extends AbstractPluginLifecycleMonitor {
+ @Override
+ public void afterRun(PluginContext pluginContext) {
+ OutputActionHandler.registerHandler(new SmsOutputActionHandler(), OutputSmsAction.class.getName());
+ ScheduleOutputActionEntityRegister.getInstance().addClass(SmsEntity.class);
+ }
+
+ @Override
+ public void beforeStop(PluginContext pluginContext) {
+
+ OutputActionHandler.removeOutputHandler(OutputSmsAction.class.getName());
+ ScheduleOutputActionEntityRegister.getInstance().removeClass(SmsEntity.class);
+ }
+}
diff --git a/src/main/java/com/fr/plugin/ymrt/sms/ResultModel.java b/src/main/java/com/fr/plugin/ymrt/sms/ResultModel.java
new file mode 100644
index 0000000..51d5703
--- /dev/null
+++ b/src/main/java/com/fr/plugin/ymrt/sms/ResultModel.java
@@ -0,0 +1,33 @@
+package com.fr.plugin.ymrt.sms;
+/**
+ * @Author fr.open
+ * @Date 2020/9/15
+ * @Description
+ **/
+public class ResultModel {
+
+ private String code;
+ private String result;
+
+ public ResultModel(String code, String result) {
+ this.code = code;
+ this.result = result;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/ymrt/sms/SimpleExample.java b/src/main/java/com/fr/plugin/ymrt/sms/SimpleExample.java
new file mode 100644
index 0000000..a8a0302
--- /dev/null
+++ b/src/main/java/com/fr/plugin/ymrt/sms/SimpleExample.java
@@ -0,0 +1,343 @@
+package com.fr.plugin.ymrt.sms;
+
+import com.fr.plugin.ymrt.sms.eucp.inter.http.v1.dto.request.SmsSingleRequest;
+import com.fr.plugin.ymrt.sms.eucp.inter.http.v1.dto.response.*;
+import com.fr.plugin.ymrt.sms.util.AES;
+import com.fr.plugin.ymrt.sms.util.GZIPUtils;
+import com.fr.plugin.ymrt.sms.util.JsonHelper;
+import com.fr.plugin.ymrt.sms.util.Md5;
+import com.fr.plugin.ymrt.sms.util.http.*;
+import com.google.gson.reflect.TypeToken;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * @Author fr.open
+ * @Date 2020/9/15
+ * @Description
+ **/
+public class SimpleExample {
+
+ public static void main(String[] args) {
+
+
+ // appId
+ String appId = "xxxx";// 请联系销售,或者在页面中 获取
+ // 密钥
+ String secretKey = "xxxx";// 请联系销售,或者在页面中 获取
+ // 接口地址
+ String host = "http://xxxx";// 请联系销售获取
+ // 时间戳
+ String timestamp = "xxxx";
+ // 签名
+ String sign = Md5.md5((appId + secretKey + timestamp).getBytes());
+ // 加密算法
+ String algorithm = "AES/ECB/PKCS5Padding";
+ // 编码
+ String encode = "UTF-8";
+ // 是否压缩
+ boolean isGizp = true;
+
+ // // 获取余额
+ // getBalance(appId, secretKey, host, algorithm, isGizp, encode);
+ // // 获取状态报告
+ // getReport(appId, secretKey, host, algorithm, isGizp, encode);
+ // // 获取上行
+ // getMo(appId, secretKey, host, algorithm, isGizp, encode);
+ // // 发送单条短信
+ setSingleSms(appId, secretKey, host, algorithm,
+ "【某某公司】asdfasdfasd111", null, null, "13026172889", isGizp,
+ encode);
+
+ }
+
+ private static void setSingleSms(String appId, String secretKey, String host, String algorithm, String content, String customSmsId, String extendCode, String mobile, boolean isGzip, String encode) {
+ System.out.println("=============begin setSingleSms==================");
+ SmsSingleRequest pamars = new SmsSingleRequest();
+ pamars.setContent(content);
+ pamars.setCustomSmsId(customSmsId);
+ pamars.setExtendedCode(extendCode);
+ pamars.setMobile(mobile);
+ ResultModel result = request(appId, secretKey, algorithm, pamars, host + "/inter/sendSingleSMS", isGzip, encode);
+ System.out.println("result code :" + result.getCode());
+ if ("SUCCESS".equals(result.getCode())) {
+ SmsResponse response = JsonHelper.fromJson(SmsResponse.class, result.getResult());
+ if (response != null) {
+ System.out.println("data : " + response.getMobile() + "," + response.getSmsId() + "," + response.getCustomSmsId());
+ }
+ }
+ System.out.println("=============end setSingleSms==================");
+ }
+
+ /**
+ * 公共请求方法
+ */
+ public static ResultModel request(String appId, String secretKey, String algorithm, Object content, String url, final boolean isGzip, String encode) {
+ Map headers = new HashMap();
+ HttpRequest request = null;
+ try {
+ headers.put("appId", appId);
+ headers.put("encode", encode);
+ String requestJson = JsonHelper.toJsonString(content);
+ System.out.println("result json: " + requestJson);
+ byte[] bytes = requestJson.getBytes(encode);
+ System.out.println("request data size : " + bytes.length);
+ if (isGzip) {
+ headers.put("gzip", "on");
+ bytes = GZIPUtils.compress(bytes);
+ System.out.println("request data size [com]: " + bytes.length);
+ }
+ byte[] parambytes = AES.encrypt(bytes, secretKey.getBytes(), algorithm);
+ System.out.println("request data size [en] : " + parambytes.length);
+ HttpRequestParams params = new HttpRequestParams();
+ params.setCharSet("UTF-8");
+ params.setMethod("POST");
+ params.setHeaders(headers);
+ params.setParams(parambytes);
+ params.setUrl(url);
+ if (url.startsWith("https://")) {
+ request = new HttpsRequestBytes(params, null);
+ } else {
+ request = new HttpRequestBytes(params);
+ }
+ } catch (Exception e) {
+ System.out.println("加密异常");
+ e.printStackTrace();
+ }
+ HttpClient client = new HttpClient();
+ String code = null;
+ String result = null;
+ try {
+ HttpResponseBytes res = client.service(request, new HttpResponseBytesPraser());
+ if (res == null) {
+ System.out.println("请求接口异常");
+ return new ResultModel(code, result);
+ }
+ if (res.getResultCode().equals(HttpResultCode.SUCCESS)) {
+ if (res.getHttpCode() == 200) {
+ code = res.getHeaders().get("result");
+ if (code.equals("SUCCESS")) {
+ byte[] data = res.getResult();
+ System.out.println("response data size [en and com] : " + data.length);
+ data = AES.decrypt(data, secretKey.getBytes(), algorithm);
+ if (isGzip) {
+ data = GZIPUtils.decompress(data);
+ }
+ System.out.println("response data size : " + data.length);
+ result = new String(data, encode);
+ System.out.println("response json: " + result);
+ }
+ } else {
+ System.out.println("请求接口异常,请求码:" + res.getHttpCode());
+ }
+ } else {
+ System.out.println("请求接口网络异常:" + res.getResultCode().getCode());
+ }
+ } catch (Exception e) {
+ System.out.println("解析失败");
+ e.printStackTrace();
+ }
+ ResultModel re = new ResultModel(code, result);
+ return re;
+ }
+
+
+ /**
+ * 获取余额
+ */
+ private static void getBalance(String appId, String sign, String timestamp, String host) {
+ System.out.println("=============begin getBalance==================");
+ Map params = new HashMap();
+ params.put("appId", appId);
+ params.put("sign", sign);
+ params.put("timestamp", timestamp);
+ String json = request(params, host + "/simpleinter/getBalance");
+ if (json != null) {
+ ResponseData data = JsonHelper.fromJson(new TypeToken>() {
+ }, json);
+ String code = data.getCode();
+ if ("SUCCESS".equals(code)) {
+ System.out.println("result data : " + data.getData().getBalance());
+ }
+ }
+ System.out.println("=============end getBalance==================");
+ }
+
+ /**
+ * 获取状态报告
+ */
+ private static void getReport(String appId, String sign, String timestamp, String host) {
+ System.out.println("=============begin getReport==================");
+ Map params = new HashMap();
+ params.put("appId", appId);
+ params.put("sign", sign);
+ params.put("timestamp", timestamp);
+ params.put("number", "500");
+ String json = request(params, host + "/simpleinter/getReport");
+ if (json != null) {
+ ResponseData data = JsonHelper.fromJson(new TypeToken>() {
+ }, json);
+ String code = data.getCode();
+ if ("SUCCESS".equals(code)) {
+ for (ReportResponse d : data.getData()) {
+ System.out.println("result data : " + d.getMobile() + "," + d.getExtendedCode() + "," + d.getMobile() + "," + d.getCustomSmsId() + "," + d.getSmsId() + "," + d.getState() + ","
+ + d.getDesc() + "," + d.getSubmitTime() + "," + d.getReceiveTime());
+ }
+ }
+ }
+ System.out.println("=============end getReport==================");
+ }
+
+ /**
+ * 获取上行
+ */
+ private static void getMo(String appId, String sign, String timestamp, String host) {
+ System.out.println("=============begin getMo==================");
+ Map params = new HashMap();
+ params.put("appId", appId);
+ params.put("sign", sign);
+ params.put("timestamp", timestamp);
+ params.put("number", "500");
+ String json = request(params, host + "/simpleinter/getMo");
+ if (json != null) {
+ ResponseData data = JsonHelper.fromJson(new TypeToken>() {
+ }, json);
+ String code = data.getCode();
+ if ("SUCCESS".equals(code)) {
+ for (MoResponse d : data.getData()) {
+ System.out.println("result data:" + d.getMobile() + "," + d.getExtendedCode() + "," + d.getMobile() + "," + d.getMoTime());
+ }
+ }
+ }
+ System.out.println("=============end getMo==================");
+ }
+
+ /**
+ * 发送批次短信
+ */
+ private static void setSms(String appId, String sign, String timestamp, String host, String content, String mobiles, String customSmsId, String extendedCode, String timerTime) {
+ System.out.println("============= setSms==================");
+ Map params = new HashMap();
+ try {
+ params.put("appId", appId);
+ params.put("sign", sign);
+ params.put("timestamp", timestamp);
+ params.put("mobiles", mobiles);
+ params.put("content", URLEncoder.encode(content, "utf-8"));
+ if (customSmsId != null) {
+ params.put("customSmsId", customSmsId);
+ }
+ if (timerTime != null) {
+ params.put("timerTime", timerTime);
+ }
+ if (extendedCode != null) {
+ params.put("extendedCode", extendedCode);
+ }
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ String json = request(params, host + "/simpleinter/sendSMS");
+ if (json != null) {
+ ResponseData data = JsonHelper.fromJson(new TypeToken>() {
+ }, json);
+ String code = data.getCode();
+ if ("SUCCESS".equals(code)) {
+ for (SmsResponse d : data.getData()) {
+ System.out.println("data:" + d.getMobile() + "," + d.getSmsId() + "," + d.getCustomSmsId());
+ }
+ }
+ }
+ System.out.println("=============end setSms==================");
+ }
+
+ /**
+ * 发送个性短信
+ */
+ private static void setPersonalitySms(String appId, String sign, String timestamp, String host, Map mobileAndContents, String customSmsId, String extendedCode, String timerTime) {
+ System.out.println("=============setPersonalitySms ==================");
+ Map params = new HashMap();
+ try {
+ params.put("appId", appId);
+ params.put("sign", sign);
+ params.put("timestamp", timestamp);
+ for (String mobile : mobileAndContents.keySet()) {
+ params.put(mobile, URLEncoder.encode(mobileAndContents.get(mobile), "utf-8"));
+ }
+ if (customSmsId != null) {
+ params.put("customSmsId", customSmsId);
+ }
+ if (timerTime != null) {
+ params.put("timerTime", timerTime);
+ }
+ if (extendedCode != null) {
+ params.put("extendedCode", extendedCode);
+ }
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ String json = request(params, host + "/simpleinter/sendPersonalitySMS");
+ if (json != null) {
+ ResponseData data = JsonHelper.fromJson(new TypeToken>() {
+ }, json);
+ String code = data.getCode();
+ if ("SUCCESS".equals(code)) {
+ for (SmsResponse d : data.getData()) {
+ System.out.println("data:" + d.getMobile() + "," + d.getSmsId() + "," + d.getCustomSmsId());
+ }
+ }
+ }
+ System.out.println("=============end setPersonalitySms==================");
+ }
+
+ /**
+ * 公共请求方法
+ */
+ public static String request(Map params, String url) {
+ HttpRequestParams