From 933846091c0b8f06158fcab23cfa0b59e8514f9b Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 22 十月 2026 15:44:25 +0800
Subject: [PATCH] 【丽水】妇幼短信发送
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTelInfoController.java | 2
/dev/null | 98 ---------
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java | 89 ++++++--
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java | 4
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 2
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java | 4
ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java | 22 ++
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java | 27 ++
ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/SmsUtils.java | 336 +++++++++++++++++++++++++++++++++
9 files changed, 447 insertions(+), 137 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
index e4e98d3..5f4c09f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
@@ -16,7 +16,7 @@
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.sign.Md5Utils;
-import com.ruoyi.common.utils.sms.smsUtils;
+import com.ruoyi.common.utils.sms.SmsUtils;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.ISysConfigService;
@@ -691,7 +691,7 @@
}
String wxCode = "";
if (active.equals("hzszlyy")) {
- wxCode = smsUtils.sendChat(url, patArchive.getTelcode(), serviceSubtask.getSfzh());
+ wxCode = SmsUtils.sendChat(url, patArchive.getTelcode(), serviceSubtask.getSfzh());
log.info("wxCode鐨勫�间负:{}", wxCode);
} else {
wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskName(), patArchive.getTelcode(), patArchive.getName(), patArchive.getPatidHis(), wxqqxx);
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java
index fbbb261..8892d10 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java
@@ -3,13 +3,15 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
+import com.ruoyi.common.annotation.AddOrgId;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.dx.MessageSend;
import com.ruoyi.common.utils.HttpUtil;
import com.ruoyi.common.utils.RSAPublicKeyExample;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
-import com.ruoyi.common.utils.sms.smsUtils;
+import com.ruoyi.common.utils.sms.SmsUtils;
+import com.ruoyi.system.service.ISysConfigService;
import com.smartor.common.MtSubmitSmUtil;
import com.smartor.common.ShiyiSmsUtil;
import com.smartor.domain.*;
@@ -71,6 +73,8 @@
private IServiceOutPathService iServiceOutPathService;
@Autowired
private IServiceSubtaskService iServiceSubtaskService;
+ @Autowired
+ private ISysConfigService configService;
@Value("${spring.profiles.active}")
private String active;
@@ -82,7 +86,7 @@
@ApiOperation("鐭俊鍙戦��")
@PostMapping("/sendTest")
public AjaxResult send(@RequestBody smsVO vo) {
- String sendMsg = smsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, vo.getPhone(), vo.getContent());
+ String sendMsg = SmsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, vo.getPhone(), vo.getContent());
return AjaxResult.success(sendMsg);
}
@@ -138,7 +142,7 @@
String sendMsg = "false";
try {
if (active.equals("hzszlyy")) {
- sendMsg = smsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, vo.getPhone(), content);
+ sendMsg = SmsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, vo.getPhone(), content);
} else if (active.equals("nhfy")) {
Map<String, Object> smsResult = mtSubmitSmUtil.submitSm(vo.getPhone(), content);
if (smsResult != null && smsResult.get("result") != null && smsResult.get("result").toString().equals("0")) {
@@ -223,7 +227,7 @@
serviceOutPath.setOrgid(vo.getOrgid());
iServiceOutPathService.insertServiceOutPath(serviceOutPath);
String url = StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/wt?p=" + format : ip + "/wt?p=" + format;
- sendMsg = smsUtils.sendChat(url, vo.getPhone(), vo.getIdCard());
+ sendMsg = SmsUtils.sendChat(url, vo.getPhone(), vo.getIdCard());
}
return AjaxResult.success(sendMsg);
}
@@ -265,4 +269,19 @@
return AjaxResult.success(content);
}
+ /**
+ * @param
+ * @return
+ */
+ @ApiOperation("鐭俊鍙戦��")
+ @AddOrgId
+ @PostMapping("/sendYunMasSms")
+ public AjaxResult sendYunMasSms(@RequestBody smsVO vo) throws Exception {
+// String yunMasConfig = configService.selectConfigByKey("ls.msg.yunmas",vo.getOrgid());
+ SmsUtils.YunMasConfig yunMasConfig = new SmsUtils.YunMasConfig();
+ SmsUtils.SmsResult smsResult = SmsUtils.sendYunMasSms(yunMasConfig, vo.getPhone(), vo.getContent());
+ return AjaxResult.success(smsResult);
+ }
+
+
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTelInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTelInfoController.java
index dd17bab..9aa5950 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTelInfoController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTelInfoController.java
@@ -1,7 +1,7 @@
package com.ruoyi.web.controller.smartor;
import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.utils.sms.smsUtils;
+import com.ruoyi.common.utils.sms.SmsUtils;
import com.smartor.domain.smsVO;
import com.smartor.service.IServiceTaskoperService;
import com.smartor.service.IServiceTelInfoService;
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java
index b7c8ec7..4eb0214 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java
@@ -11,7 +11,7 @@
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.utils.sms.smsUtils;
+import com.ruoyi.common.utils.sms.SmsUtils;
import com.smartor.common.MtSubmitSmUtil;
import com.smartor.domain.BaseSmsRequest;
import com.smartor.domain.BaseSmsaccount;
@@ -135,7 +135,7 @@
try {
JSONObject jsTemp = JSON.parseObject(baseSmsRequest.getTemplateParam());
String content = jsTemp.getString("name");
- sendMsg = smsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, baseSmsRequest.getPhoneNumber(), content);
+ sendMsg = SmsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, baseSmsRequest.getPhoneNumber(), content);
} catch (Exception ex) {
return AjaxResult.error(ex.getMessage());
}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
index 0310368..3880900 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
@@ -95,7 +95,26 @@
return httpClient;
}
+ /**
+ * json鐨刾ost璇锋眰锛堝彧鍏冲績鏄惁鎴愬姛锛岄潪200鐩存帴鎶涘紓甯革級
+ *
+ * @param url 璇锋眰url
+ * @param request 璇锋眰鎶ユ枃
+ * @return 鍥哄畾杩斿洖true锛坔ttp鐘舵�侀潪200浼氭姏HttpRequestException锛�
+ */
public static Boolean postJsonRequest(String url, String request) throws HttpRequestException {
+ postJsonRequestForString(url, request);
+ return true;
+ }
+
+ /**
+ * json鐨刾ost璇锋眰锛岃繑鍥炲搷搴旀姤鏂囧唴瀹癸紙鐢ㄤ簬闇�瑕佽В鏋愯繑鍥炵爜鐨勫満鏅紝濡備簯MAS鐭俊锛�
+ *
+ * @param url 璇锋眰url
+ * @param request 璇锋眰鎶ユ枃
+ * @return 鍝嶅簲鎶ユ枃鍐呭
+ */
+ public static String postJsonRequestForString(String url, String request) throws HttpRequestException {
Assert.hasLength(url, "璇锋眰url涓嶈兘涓虹┖瀛楃涓层��");
EntityEnclosingMethod httpMethod = new PostMethod(url);
@@ -132,8 +151,9 @@
String respJson = stringBuffer.toString();
// String respJson = httpMethod.getResponseBodyAsString();
if (resultCode == OK) {
- return true;
+ return respJson;
} else {
+ log.warn("銆恜ostJsonRequestForString銆戣姹傚け璐ワ紝url锛歿}锛岀姸鎬佺爜锛歿}锛屽搷搴旓細{}", url, resultCode, respJson);
throw new HttpRequestException(resultCode, respJson);
}
} catch (UnsupportedEncodingException e) {
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/SmsUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/SmsUtils.java
new file mode 100644
index 0000000..ae2c286
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/SmsUtils.java
@@ -0,0 +1,336 @@
+package com.ruoyi.common.utils.sms;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.annotation.JSONField;
+import com.ruoyi.common.utils.HttpUtil;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.http.HttpUtils;
+import com.ruoyi.common.utils.sign.Md5Utils;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 鐭俊鍙戦�佸伐鍏风被
+ *
+ * @author ruoyi
+ */
+@Slf4j
+public final class SmsUtils {
+
+ private SmsUtils() {
+ }
+
+ /**
+ * 浜慚AS 姣忔壒娆℃渶澶氭墜鏈哄彿鏁伴噺
+ */
+ private static final int YUNMAS_MAX_MOBILES = 5000;
+
+ /**
+ * 浜慚AS 杩斿洖鐮佽鏄�
+ */
+ private static final Map<String, String> YUNMAS_RSPCOD_DESC = new HashMap<>();
+
+ static {
+ YUNMAS_RSPCOD_DESC.put("success", "鏁版嵁楠岃瘉閫氳繃");
+ YUNMAS_RSPCOD_DESC.put("IllegalMac", "mac鏍¢獙涓嶉�氳繃");
+ YUNMAS_RSPCOD_DESC.put("IllegalSignId", "鏃犳晥鐨勭鍚嶇紪鐮�");
+ YUNMAS_RSPCOD_DESC.put("InvalidMessage", "闈炴硶娑堟伅锛岃姹傛暟鎹В鏋愬け璐�");
+ YUNMAS_RSPCOD_DESC.put("InvalidUsrOrPwd", "闈炴硶鐢ㄦ埛鍚�/瀵嗙爜");
+ YUNMAS_RSPCOD_DESC.put("NoSignId", "鏈尮閰嶅埌瀵瑰簲鐨勭鍚嶄俊鎭�");
+ YUNMAS_RSPCOD_DESC.put("TooManyMobiles", "鎵嬫満鍙锋暟閲忚秴闄�(>5000)");
+ }
+
+ /**
+ * 浜慚AS 鎺ュ彛閰嶇疆銆�
+ * <p>
+ * 娉ㄦ剰锛歴ecretKey 鍙弬涓� mac 璁$畻锛屼笉鑳芥斁杩涜姹傛姤鏂囥��
+ */
+ @Data
+ public static class YunMasConfig {
+ /**
+ * 鎺ュ彛鍦板潃
+ */
+ private String url;
+ /**
+ * 浼佷笟鍚嶇О
+ */
+ private String ecName;
+ /**
+ * 鎺ュ彛璐﹀彿鐢ㄦ埛鍚�
+ */
+ private String apId;
+ /**
+ * 瀵嗛挜锛堜粎鍙備笌 mac 璁$畻锛�
+ */
+ private String secretKey;
+ /**
+ * 绛惧悕缂栫爜
+ */
+ private String sign;
+ /**
+ * 鎵╁睍鐮侊細绮剧‘鍖归厤濉┖瀛楃涓诧紱妯$硦鍖归厤鍙~绌哄瓧绗︿覆鎴栬嚜瀹氫箟鎵╁睍鐮侊紙涓庢湇鍔′唬鐮佸悎璁′笉瓒呰繃20浣嶏級
+ */
+ private String addSerial;
+
+ public String getAddSerial() {
+ return addSerial == null ? "" : addSerial;
+ }
+
+ /**
+ * 涓芥按濡囧辜榛樿閰嶇疆锛堟湭鍦� sys_config 涓厤缃椂浣跨敤锛�
+ */
+ public static YunMasConfig defaultLishui() {
+ YunMasConfig config = new YunMasConfig();
+ config.setUrl("http://9.208.5.35:1992/sms/norsubmit");
+ config.setEcName("涓芥按甯傚骞间繚鍋ラ櫌");
+ config.setApId("dxjkkf");
+ config.setSecretKey("1q2w3e4r5t6y");
+ config.setSign("D9gKbwdt7");
+ config.setAddSerial("");
+ return config;
+ }
+
+ /**
+ * 鏍规嵁閰嶇疆鍐呭锛坖son锛夋瀯寤猴紝鏈厤缃殑瀛楁娌跨敤榛樿鍊�
+ *
+ * @param configJson 褰㈠ {"url":"...","ecName":"...","apId":"...","secretKey":"...","sign":"...","addSerial":""}
+ */
+ public static YunMasConfig of(String configJson) {
+ YunMasConfig config = defaultLishui();
+ if (StringUtils.isEmpty(configJson)) {
+ return config;
+ }
+ JSONObject json;
+ try {
+ json = JSON.parseObject(configJson);
+ } catch (Exception e) {
+ log.error("銆愪簯MAS銆戦厤缃В鏋愬け璐ワ紝浣跨敤榛樿閰嶇疆锛岄厤缃唴瀹癸細{}", configJson, e);
+ return config;
+ }
+ if (json == null) {
+ return config;
+ }
+ if (StringUtils.isNotEmpty(json.getString("url"))) {
+ config.setUrl(json.getString("url"));
+ }
+ if (StringUtils.isNotEmpty(json.getString("ecName"))) {
+ config.setEcName(json.getString("ecName"));
+ }
+ if (StringUtils.isNotEmpty(json.getString("apId"))) {
+ config.setApId(json.getString("apId"));
+ }
+ if (StringUtils.isNotEmpty(json.getString("secretKey"))) {
+ config.setSecretKey(json.getString("secretKey"));
+ }
+ if (StringUtils.isNotEmpty(json.getString("sign"))) {
+ config.setSign(json.getString("sign"));
+ }
+ if (json.containsKey("addSerial")) {
+ config.setAddSerial(json.getString("addSerial"));
+ }
+ return config;
+ }
+
+ /**
+ * 鍏抽敭鍙傛暟鏄惁榻愬叏
+ */
+ public boolean isValid() {
+ return StringUtils.isNotEmpty(url) && StringUtils.isNotEmpty(ecName)
+ && StringUtils.isNotEmpty(apId) && StringUtils.isNotEmpty(secretKey)
+ && StringUtils.isNotEmpty(sign);
+ }
+ }
+
+ /**
+ * 鐭俊鍙戦�佺粨鏋�
+ */
+ @Data
+ public static class SmsResult {
+ /**
+ * 骞冲彴杩斿洖鐨勭姸鎬佺爜锛坰uccess 琛ㄧず鏍¢獙閫氳繃锛�
+ */
+ private String rspcod;
+ /**
+ * 娑堟伅鎵规鍙凤紝澶辫触鏃朵负绌�
+ */
+ private String msgGroup;
+ /**
+ * 骞冲彴杩斿洖鐨勬暟鎹牎楠岀粨鏋�
+ */
+ private boolean success;
+ /**
+ * 鏈湴寮傚父/澶辫触鎻忚堪锛屼究浜庢帓鏌�
+ */
+ private String message;
+
+ /**
+ * 鏄惁鍙戦�佹垚鍔燂紙骞冲彴鏍¢獙閫氳繃锛�
+ */
+ @JSONField(serialize = false, deserialize = false)
+ public boolean isOk() {
+ return success && "success".equals(rspcod);
+ }
+
+ public static SmsResult fail(String message) {
+ SmsResult result = new SmsResult();
+ result.setSuccess(false);
+ result.setMessage(message);
+ return result;
+ }
+ }
+
+ /**
+ * 鏉窞甯備竴鍖婚櫌鍚村北闄㈠尯鎴戠煭淇℃帴鍙�
+ *
+ * @param url 鐭俊URL
+ * @param userName 鐭俊甯愬彿
+ * @param passWord 鐭俊瀵嗙爜
+ * @param phone 鎵嬫満鍙风粍鍚堝 13500000001,13500000002
+ * @param content 鐭俊鍐呭
+ * @return 鍙戦�佺粨鏋�
+ */
+ public static String sendSms(String url, String userName, String passWord, String phone, String content) {
+ long timestamp = new Date().getTime();
+ String sign = Md5Utils.hash(userName + timestamp + Md5Utils.hash(passWord));
+ content = "銆愭澀宸炲競鑲跨槫鍖婚櫌銆�" + content;
+ String jsonMsg = "{" +
+ "\"userName\": \"" + userName + "\"," +
+ "\"content\": \"" + content + "\"," +
+ "\"phoneList\": [" + phone + "]," +
+ "\"timestamp\": " + timestamp + "," +
+ "\"sign\": \"" + sign + "\"" +
+ "}";
+ Boolean sendMsg = HttpUtil.postJsonRequest(url, jsonMsg);
+ return sendMsg.toString();
+
+ }
+
+
+ /**
+ * 鏉窞甯備竴鍖婚櫌婀栨花闄㈠尯鎴戠煭淇℃帴鍙�
+ *
+ * @param url 鐭俊URL
+ * @param userName 鐭俊甯愬彿
+ * @param passWord 鐭俊瀵嗙爜
+ * @param phone 鎵嬫満鍙风粍鍚堝 13500000001,13500000002
+ * @param content 鐭俊鍐呭
+ * @return 鍙戦�佺粨鏋�
+ */
+ public static String sendSms1(String url, String userName, String passWord, String phone, String content) {
+ long timestamp = new Date().getTime();
+ String sign = Md5Utils.hash(userName + timestamp + Md5Utils.hash(passWord));
+ content = "銆愭澀宸炲競绗竴浜烘皯鍖婚櫌銆�" + content;
+ String jsonMsg = "{" +
+ "\"userName\": \"" + userName + "\"," +
+ "\"content\": \"" + content + "\"," +
+ "\"phoneList\": [" + phone + "]," +
+ "\"timestamp\": " + timestamp + "," +
+ "\"sign\": \"" + sign + "\"" +
+ "}";
+ Boolean sendMsg = HttpUtil.postJsonRequest(url, jsonMsg);
+ return sendMsg.toString();
+
+ }
+
+ /**
+ * 涓浗绉诲姩浜慚AS 鏅�氱煭淇″彂閫侊紙涓�瀵逛竴/澶氬涓�妯″紡锛�
+ * <p>
+ * 鎺ュ彛锛歅OST {url}锛屾姤鏂囦负 json 鐨� base64 缂栫爜銆�
+ * <ul>
+ * <li>mac 鎸� ecName銆乤pId銆乻ecretKey銆乵obiles銆乧ontent銆乻ign銆乤ddSerial 椤哄簭鎷兼帴鍚庡彇 MD5锛�32浣嶅皬鍐欙級</li>
+ * <li>secretKey 鍙弬涓� mac 璁$畻锛屼笉鏀捐繘璇锋眰鎶ユ枃</li>
+ * <li>绛惧悕鐢卞钩鍙版牴鎹� sign 缂栫爜鑷姩杩藉姞锛宑ontent 涓笉瑕佸啀鎵嬪伐鎷笺�愮鍚嶃��</li>
+ * </ul>
+ *
+ * @param config 浜慚AS 閰嶇疆
+ * @param mobiles 鏀朵俊鎵嬫満鍙凤紝鑻辨枃閫楀彿鍒嗛殧锛屽 13800138000,13800138001锛屾瘡鎵逛笉瓒呰繃 5000 涓�
+ * @param content 鐭俊鍐呭锛坢ac 鐢ㄦ渶缁堝唴瀹硅绠楋紝璁$畻鍚庝笉寰楀啀淇敼锛�
+ * @return 鍙戦�佺粨鏋滐紝閫氳繃 {@link SmsResult#isOk()} 鍒ゆ柇鏄惁鎴愬姛
+ */
+ public static SmsResult sendYunMasSms(YunMasConfig config, String mobiles, String content) {
+ if (config == null || !config.isValid()) {
+ return SmsResult.fail("浜慚AS閰嶇疆涓嶅畬鏁�");
+ }
+ if (StringUtils.isEmpty(mobiles)) {
+ return SmsResult.fail("鏀朵俊鎵嬫満鍙蜂笉鑳戒负绌�");
+ }
+ if (StringUtils.isEmpty(content)) {
+ return SmsResult.fail("鐭俊鍐呭涓嶈兘涓虹┖");
+ }
+ if (mobiles.split(",").length > YUNMAS_MAX_MOBILES) {
+ return SmsResult.fail("鎵嬫満鍙锋暟閲忚秴闄�(>" + YUNMAS_MAX_MOBILES + ")");
+ }
+
+ String addSerial = config.getAddSerial();
+ // 1. mac 蹇呴』鐢ㄦ姤鏂囬噷鏈�缁堝彂閫佺殑鍐呭璁$畻
+ String mac = Md5Utils.hash(config.getEcName() + config.getApId() + config.getSecretKey()
+ + mobiles + content + config.getSign() + addSerial);
+
+ // 2. 鐢� json 缁勮鎶ユ枃锛岄伩鍏嶅唴瀹逛腑鐨勫紩鍙�/鍙嶆枩鏉犵牬鍧忔姤鏂囷紱secretKey 涓嶈惤鎶ユ枃
+ JSONObject body = new JSONObject(true);
+ body.put("ecName", config.getEcName());
+ body.put("apId", config.getApId());
+ body.put("mobiles", mobiles);
+ body.put("content", content);
+ body.put("sign", config.getSign());
+ body.put("addSerial", addSerial);
+ body.put("mac", mac);
+
+ String requestBody = Base64.getEncoder()
+ .encodeToString(body.toJSONString().getBytes(StandardCharsets.UTF_8));
+
+ try {
+ String resp = HttpUtil.postJsonRequestForString(config.getUrl(), requestBody);
+ log.info("銆愪簯MAS銆戝彂閫佺煭淇★紝鎵嬫満鍙凤細{}锛屽搷搴旓細{}", mobiles, resp);
+ if (StringUtils.isEmpty(resp)) {
+ return SmsResult.fail("浜慚AS鍝嶅簲涓虹┖");
+ }
+ SmsResult result = JSON.parseObject(resp, SmsResult.class);
+ if (result == null) {
+ return SmsResult.fail("浜慚AS鍝嶅簲瑙f瀽澶辫触锛�" + resp);
+ }
+ if (!result.isOk()) {
+ String desc = YUNMAS_RSPCOD_DESC.getOrDefault(result.getRspcod(), "鏈煡閿欒");
+ result.setMessage(desc);
+ log.error("銆愪簯MAS銆戝彂閫佸け璐ワ紝鎵嬫満鍙凤細{}锛宺spcod锛歿}锛坽}锛夛紝鍝嶅簲锛歿}",
+ mobiles, result.getRspcod(), desc, resp);
+ }
+ return result;
+ } catch (Exception e) {
+ log.error("銆愪簯MAS銆戝彂閫佸紓甯革紝鎵嬫満鍙凤細{}锛屽師鍥狅細{}", mobiles, e.getMessage(), e);
+ return SmsResult.fail("浜慚AS鍙戦�佸紓甯革細" + e.getMessage());
+ }
+ }
+
+ /**
+ * 鏉窞甯備竴鍖婚櫌鍚村北闄㈠尯寰俊鎺ュ彛
+ *
+ * @param url 寰俊URL
+ * @param phone 鎵嬫満鍙� 13500000001
+ * @param idCard 韬唤璇�
+ * @return 鍙戦�佺粨鏋�
+ */
+ public static String sendChat(String url, String phone, String idCard) {
+ String urlTemp = "http://192.200.54.14:5003/sfjk/SendMessage?sfzh="
+ + idCard
+ + "&title=鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑诲~鍐欍��&content=寰呴殢璁�&phone=" + phone
+ + "&url=" + url + "&key=ff76f8904f5f32b5ee1739e8ea46e60g";
+ String sendMsg = "";
+ try {
+ log.info("銆恠endChat銆戝競涓�寰俊鍏紬鍙疯姹傚弬鏁帮細{}", urlTemp);
+ sendMsg = HttpUtils.sendPost(urlTemp);
+ log.info("銆恠endChat銆戝競涓�寰俊鍏紬鍙疯繑鍥炲�硷細{}", sendMsg);
+ } catch (Exception ex) {
+ sendMsg = ex.getMessage();
+ log.error(ex.getMessage());
+ }
+ return sendMsg;
+ }
+}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/smsUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/smsUtils.java
deleted file mode 100644
index d650902..0000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sms/smsUtils.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package com.ruoyi.common.utils.sms;
-
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.ruoyi.common.utils.HttpUtil;
-import com.ruoyi.common.utils.http.HttpUtils;
-import com.ruoyi.common.utils.sign.Md5Utils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-@Slf4j
-public class smsUtils {
-
-
- /**
- * 鏉窞甯備竴鍖婚櫌鍚村北闄㈠尯鎴戠煭淇℃帴鍙�
- *
- * @param url 鐭俊URL
- * @param userName 鐭俊甯愬彿
- * @param content 鐭俊瀵嗙爜
- * @param phone 鎵嬫満鍙风粍鍚堝 13500000001,13500000002
- * @param content 鐭俊鍐呭
- * @return 涓や釜鍙傛暟鐨勫拰
- */
- public static String sendSms(String url, String userName, String passWord, String phone, String content) {
- long timestamp = new Date().getTime();
- String sign = Md5Utils.hash(userName + timestamp + Md5Utils.hash(passWord));
- content = "銆愭澀宸炲競鑲跨槫鍖婚櫌銆�" + content;
- String jsonMsg = "{" +
- "\"userName\": \"" + userName + "\"," +
- "\"content\": \"" + content + "\"," +
- "\"phoneList\": [" + phone + "]," +
- "\"timestamp\": " + timestamp + "," +
- "\"sign\": \"" + sign + "\"" +
- "}";
- Boolean sendMsg=HttpUtil.postJsonRequest(url, jsonMsg);
- return sendMsg.toString();
-
- }
-
-
- /**
- * 鏉窞甯備竴鍖婚櫌婀栨花闄㈠尯鎴戠煭淇℃帴鍙�
- *
- * @param url 鐭俊URL
- * @param userName 鐭俊甯愬彿
- * @param content 鐭俊瀵嗙爜
- * @param phone 鎵嬫満鍙风粍鍚堝 13500000001,13500000002
- * @param content 鐭俊鍐呭
- * @return 涓や釜鍙傛暟鐨勫拰
- */
- public static String sendSms1(String url, String userName, String passWord, String phone, String content) {
- long timestamp = new Date().getTime();
- String sign = Md5Utils.hash(userName + timestamp + Md5Utils.hash(passWord));
- content = "銆愭澀宸炲競绗竴浜烘皯鍖婚櫌銆�" + content;
- String jsonMsg = "{" +
- "\"userName\": \"" + userName + "\"," +
- "\"content\": \"" + content + "\"," +
- "\"phoneList\": [" + phone + "]," +
- "\"timestamp\": " + timestamp + "," +
- "\"sign\": \"" + sign + "\"" +
- "}";
- Boolean sendMsg=HttpUtil.postJsonRequest(url, jsonMsg);
- return sendMsg.toString();
-
- }
-
- /**
- * 鏉窞甯備竴鍖婚櫌鍚村北闄㈠尯寰俊鎺ュ彛
- *
- * @param url 寰俊URL
- * @param phone 鎵嬫満鍙� 13500000001
- * @param idCard 韬唤璇�
- * @return 涓や釜鍙傛暟鐨勫拰
- */
- public static String sendChat(String url,String phone,String idCard){
- String urlTemp = "http://192.200.54.14:5003/sfjk/SendMessage?sfzh="
- + idCard
- + "&title=鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑诲~鍐欍��&content=寰呴殢璁�&phone=" + phone
- + "&url=" + url + "&key=ff76f8904f5f32b5ee1739e8ea46e60g";
- String sendMsg = "";
- try {
- log.info("銆恠endChat銆戝競涓�寰俊鍏紬鍙疯姹傚弬鏁帮細{}", urlTemp);
- sendMsg = HttpUtils.sendPost(urlTemp);
- log.info("銆恠endChat銆戝競涓�寰俊鍏紬鍙疯繑鍥炲�硷細{}", sendMsg);
- } catch (Exception ex) {
- sendMsg=ex.getMessage();
- log.error(ex.getMessage());
- }
- return sendMsg;
- }
-}
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
index fae5ffb..fe49361 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -17,7 +17,7 @@
import com.ruoyi.common.enums.WxGZHEnum;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.http.HttpUtils;
-import com.ruoyi.common.utils.sms.smsUtils;
+import com.ruoyi.common.utils.sms.SmsUtils;
import com.ruoyi.quartz.service.ICollectHISService;
import com.ruoyi.quartz.util.CreateDataTable;
import com.ruoyi.system.domain.SysConfig;
@@ -1003,6 +1003,24 @@
}
/**
+ * 鎸夋満鏋勬煡璇㈤厤缃�硷紙鍚屼竴 key 鍦ㄤ笉鍚屾満鏋勪笅鍙厤缃笉鍚屽�硷級
+ *
+ * @param configKey 閰嶇疆key
+ * @param orgid 鏈烘瀯ID
+ * @return 閰嶇疆鍊硷紝鏈厤缃繑鍥� null
+ */
+ private String getConfigValue(String configKey, String orgid) {
+ SysConfig query = new SysConfig();
+ query.setConfigKey(configKey);
+ query.setOrgid(orgid);
+ List<SysConfig> sysConfigs = configService.selectConfigList(query);
+ if (CollectionUtils.isNotEmpty(sysConfigs)) {
+ return sysConfigs.get(0).getConfigValue();
+ }
+ return null;
+ }
+
+ /**
* 闅忚-琛ュ伩澶勭悊
*
* @param serviceSubtask
@@ -1210,33 +1228,48 @@
// String url = configService.selectConfigByKey("token.360", serviceSubtask.getOrgid());
// //涓芥按鐨勭煭淇″彂閫佹柟寮�
// Map<String, String> map = MsgLSEnum.getAddressByCode(serviceSubtask.getOrgid());
- SysConfig config = new SysConfig();
- config.setConfigKey("ls.msg.info");
- config.setOrgid(serviceSubtask.getOrgid());
- List<SysConfig> sysConfigs = configService.selectConfigList(config);
- Map<String, String> msgInfo = new HashMap<>();
- if (CollectionUtils.isNotEmpty(sysConfigs)) {
- String configValue = sysConfigs.get(0).getConfigValue();
+ if ("47226079133110211G1001".equals(serviceSubtask.getOrgid())) {
+ // 濡囧辜涓浗绉诲姩浜慚AS锛屼笉渚濊禆 ls.msg.info 涓� token
+ SmsUtils.YunMasConfig yunMasConfig = SmsUtils.YunMasConfig.of(getConfigValue("ls.msg.yunmas", serviceSubtask.getOrgid()));
+ SmsUtils.SmsResult smsResult = SmsUtils.sendYunMasSms(yunMasConfig, sendMagParam.getPhone(), sendMagParam.getContent());
+ log.info("銆恠fHandlle銆戜簯MAS鐭俊鍙戦�佺粨鏋滐細ok={}锛宺spcod={}锛宮sgGroup={}锛宮essage={}",
+ smsResult.isOk(), smsResult.getRspcod(), smsResult.getMsgGroup(), smsResult.getMessage());
+ if (smsResult.isOk()) {
+ isSuccess = "true";
+ } else {
+ log.error("銆恠fHandlle銆戜簯MAS鐭俊鍙戦�佸け璐ワ紝subid锛歿}锛屾墜鏈哄彿锛歿}锛屽師鍥狅細{}",
+ serviceSubtask.getId(), sendMagParam.getPhone(), smsResult.getMessage());
+ }
+ } else {
+ SysConfig config = new SysConfig();
+ config.setConfigKey("ls.msg.info");
+ config.setOrgid(serviceSubtask.getOrgid());
+ List<SysConfig> sysConfigs = configService.selectConfigList(config);
+ Map<String, String> msgInfo = new HashMap<>();
+ if (CollectionUtils.isNotEmpty(sysConfigs)) {
+ String configValue = sysConfigs.get(0).getConfigValue();
+ ObjectMapper objectMapper = new ObjectMapper();
+ if (StringUtils.isNotEmpty(configValue)) {
+ msgInfo = objectMapper.readValue(configValue, Map.class);
+ }
+ }
+ log.info("-----------map鐨勫�间负锛歿}", msgInfo);
+ if (ObjectUtils.isEmpty(msgInfo) || StringUtils.isEmpty(msgInfo.get("address"))) {
+ setSuccessPreachForm(serviceSubtask, sendPreachform, "鐭俊鍙戦�佸け璐�,璇ユ満鏋勬病鏈夐厤缃煭淇″湴鍧�, 鏃堕棿:" + now, "5");
+ return;
+ }
+ String token = LSHospTokenUtil.getToken(serviceSubtask.getOrgid(), msgInfo.get("tokenUrl"));
+ log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫侊紝鍦板潃锛歿}锛屽弬鏁帮細{}锛屾満鏋処D锛歿}", msgInfo.get("address"), sendMagParam, serviceSubtask.getOrgid());
+ String dxCode = getDXCode(msgInfo.get("address"), sendMagParam.getPhone(), sendMagParam.getContent(), msgInfo.get("sendPersonId"), msgInfo.get("sendPersonName"), MsgLSEnum.getHeaderByCode(msgInfo), token);
+ log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫佺粨鏋滐細{}", dxCode);
ObjectMapper objectMapper = new ObjectMapper();
- if (StringUtils.isNotEmpty(configValue)) {
- msgInfo = objectMapper.readValue(configValue, Map.class);
+ Map<String, Object> textParam = objectMapper.readValue(dxCode, Map.class);
+ String code = textParam.get("Code").toString();
+ if (code.equals("0")) {
+ isSuccess = "true";
}
}
- log.info("-----------map鐨勫�间负锛歿}", msgInfo);
- String token = LSHospTokenUtil.getToken(serviceSubtask.getOrgid(), msgInfo.get("tokenUrl"));
- if (ObjectUtils.isNotEmpty(msgInfo) && StringUtils.isEmpty(msgInfo.get("address"))) {
- setSuccessPreachForm(serviceSubtask, sendPreachform, "鐭俊鍙戦�佸け璐�,璇ユ満鏋勬病鏈夐厤缃煭淇″湴鍧�, 鏃堕棿:" + now, "5");
- return;
- }
- log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫侊紝鍦板潃锛歿}锛屽弬鏁帮細{}锛屾満鏋処D锛歿}", msgInfo.get("address"), sendMagParam, serviceSubtask.getOrgid());
- String dxCode = getDXCode(msgInfo.get("address"), sendMagParam.getPhone(), sendMagParam.getContent(), msgInfo.get("sendPersonId"), msgInfo.get("sendPersonName"), MsgLSEnum.getHeaderByCode(msgInfo), token);
- log.info("銆恠fHandlle銆戜附姘寸煭淇″彂閫佺粨鏋滐細{}", dxCode);
- ObjectMapper objectMapper = new ObjectMapper();
- Map<String, Object> textParam = objectMapper.readValue(dxCode, Map.class);
- String code = textParam.get("Code").toString();
- if (code.equals("0")) {
- isSuccess = "true";
- }
+
} else if (active.equals("sltd") || active.equals("nhfy")) {
log.info("sltd杩涙潵浜嗗悧锛焮} ,---sendMagParam.getContent()鐨勫弬鏁颁负锛歿}", active, sendMagParam.getContent());
if (active.equals("sltd")) {
@@ -1284,13 +1317,13 @@
String campusid = ObjectUtils.isNotEmpty(sysDept) ? sysDept.getCampusid() : "2";
//婀栨花鍗曠嫭鍙戦�佹柟寮�
if ("1".equals(campusid)) {
- String result = smsUtils.sendSms1(xhsmsPath, xhsmsAccount, xhsmsPwd, sendMagParam.getPhone(), content);
+ String result = SmsUtils.sendSms1(xhsmsPath, xhsmsAccount, xhsmsPwd, sendMagParam.getPhone(), content);
//杩欓噷闇�瑕佹牴鎹畆esult杩斿洖鐨勫�煎幓鍒ゆ柇锛屾槸鍚︽垚鍔燂紝鐒跺悗灏嗗�艰祴鍊肩粰isSuccess
if (StringUtils.isNotEmpty(result) && result.contains("澶勭悊鎴愬姛")) {
isSuccess = "true";
}
} else {
- String result = smsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, sendMagParam.getPhone(), content);
+ String result = SmsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, sendMagParam.getPhone(), content);
//杩欓噷闇�瑕佹牴鎹畆esult杩斿洖鐨勫�煎幓鍒ゆ柇锛屾槸鍚︽垚鍔燂紝鐒跺悗灏嗗�艰祴鍊肩粰isSuccess
if (StringUtils.isNotEmpty(result) && result.contains("澶勭悊鎴愬姛")) {
isSuccess = "true";
@@ -1372,7 +1405,7 @@
//甯備竴鍖婚櫌
if (active.equals("hzszlyy")) {
//澶勭悊涓枃涔辩爜闂
- wxCode = smsUtils.sendChat(url, patArchive.getTelcode(), serviceSubtask.getSfzh());
+ wxCode = SmsUtils.sendChat(url, patArchive.getTelcode(), serviceSubtask.getSfzh());
} else {
wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), patArchive.getTelcode(), serviceSubtask.getSendname(), patArchive.getPatidHis(), wxqqxx);
}
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index 3f9709d..d7c2f24 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -14,7 +14,7 @@
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.http.HttpUtils;
-import com.ruoyi.common.utils.sms.smsUtils;
+import com.ruoyi.common.utils.sms.SmsUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
--
Gitblit v1.9.3