From 9aa39ddc1ccf4220b218edbda146aab4980385f5 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Mon, 6 Mar 2023 10:06:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FirePointServiceImpl.java | 4 -- .../straw/controller/SysUserController.java | 4 -- .../xkrs/straw/model/helper/SMSHelper.java | 51 ------------------- .../straw/utils/FirePointPushManager.java | 30 ++++++++--- 4 files changed, 24 insertions(+), 65 deletions(-) delete mode 100644 src/main/java/com/xkrs/straw/model/helper/SMSHelper.java diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index cffbbc8..b53238e 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -11,7 +11,6 @@ import com.xkrs.straw.model.bean.FirePointQueryResultBean; import com.xkrs.straw.model.entity.FirePointOrdinaryEntity; import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.straw.model.helper.PushHelper; -import com.xkrs.straw.model.helper.SMSHelper; import com.xkrs.straw.model.vo.AllFirePointVo; import com.xkrs.straw.utils.FirePointConvertUtils; import com.xkrs.straw.utils.FirePointQueryManager; @@ -58,9 +57,6 @@ public class FirePointServiceImpl implements FirePointService { @Resource private StreetService streetService; - @Resource - private SMSHelper smsHelper; - @Resource private PushHelper pushHelper; diff --git a/src/main/java/com/xkrs/straw/controller/SysUserController.java b/src/main/java/com/xkrs/straw/controller/SysUserController.java index aed48d4..12fc384 100644 --- a/src/main/java/com/xkrs/straw/controller/SysUserController.java +++ b/src/main/java/com/xkrs/straw/controller/SysUserController.java @@ -7,7 +7,6 @@ import com.xkrs.model.validation.SysUserQoUpdate; import com.xkrs.service.RedisService; import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.model.entity.SysUserEntity; -import com.xkrs.straw.model.helper.SMSHelper; import com.xkrs.straw.model.qo.SysUserQo; import com.xkrs.straw.model.qo.SysUserReceiveSmsQo; import com.xkrs.straw.model.qo.SysUserRemarkQo; @@ -56,9 +55,6 @@ public class SysUserController { @Resource private RedisService redisService; - @Resource - private SMSHelper smsHelper; - /** * 更新(批量)系统用户信息 * diff --git a/src/main/java/com/xkrs/straw/model/helper/SMSHelper.java b/src/main/java/com/xkrs/straw/model/helper/SMSHelper.java deleted file mode 100644 index 87ebf0e..0000000 --- a/src/main/java/com/xkrs/straw/model/helper/SMSHelper.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.xkrs.straw.model.helper; - -import com.xkrs.straw.model.entity.SysUserEntity; -import com.xkrs.straw.model.vo.AllFirePointVo; -import com.xkrs.utils.SMSUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.util.List; - -@Component -public class SMSHelper { - - public static Logger log = LoggerFactory.getLogger(SMSHelper.class); - - public SMSHelper() { - } - - public void dispatchSMSMessage(List smsReceiverList, String[] templateParamArray, AllFirePointVo[] detailParamArray) { - if (smsReceiverList != null && smsReceiverList.size() > 0) { - String[] telephoneArray = new String[smsReceiverList.size()]; - for (int i = 0; i < smsReceiverList.size(); i++) { - telephoneArray[i] = "86" + smsReceiverList.get(i).getUserName(); - } - xingkeSMSMessage(telephoneArray, templateParamArray, detailParamArray); - } - } - - /** - * 星科瑞升向用户发送短信 - */ - private void xingkeSMSMessage(String[] telephoneArray, String[] templateParamArray, AllFirePointVo[] detailParamArray) { - int resValue = SMSUtils.sendSmsToUser(telephoneArray, "1425995", templateParamArray); - String sendResult = resValue == 0 ? "短信通知发送成功!" : "短信通知发送失败!"; - //记录短信通知日志 - StringBuilder stringBuilder = new StringBuilder("发送人:青岛星科瑞升信息科技有限公司\n"); - for (String telephone : telephoneArray) { - stringBuilder.append("接收人:").append(telephone).append("\n"); - } - for (String templateParam : templateParamArray) { - stringBuilder.append("模板参数:").append(templateParam).append("\n"); - } - for (AllFirePointVo detailParam : detailParamArray) { - stringBuilder.append("超级详细的参数:").append(detailParam.toString()).append("\n"); - } - stringBuilder.append(sendResult); - log.info(stringBuilder.toString()); - } - -} diff --git a/src/main/java/com/xkrs/straw/utils/FirePointPushManager.java b/src/main/java/com/xkrs/straw/utils/FirePointPushManager.java index fbac7cc..a095cfd 100644 --- a/src/main/java/com/xkrs/straw/utils/FirePointPushManager.java +++ b/src/main/java/com/xkrs/straw/utils/FirePointPushManager.java @@ -7,9 +7,9 @@ import com.xkrs.straw.model.entity.FirePointOrdinaryEntity; import com.xkrs.straw.model.entity.FirePointPreciseEntity; import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.straw.model.helper.PushHelper; -import com.xkrs.straw.model.helper.SMSHelper; import com.xkrs.straw.model.vo.AllFirePointVo; import com.xkrs.utils.FirePointCodeUtils; +import com.xkrs.utils.SMSUtils; import com.xkrs.utils.WDWxSendMsgUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,9 +29,6 @@ public class FirePointPushManager { @Resource private CountyCodeWeiXinDao countyCodeWeiXinDao; - @Resource - private SMSHelper smsHelper; - @Resource private PushHelper pushHelper; @@ -58,8 +55,29 @@ public class FirePointPushManager { // } catch (Exception e) { // e.printStackTrace(); // } - //分发短信通知 - smsHelper.dispatchSMSMessage(smsReceiverList, new String[]{firePoint.getFirePointAddress()}, new AllFirePointVo[]{firePoint}); + String[] templateParamArray = new String[]{firePoint.getFirePointAddress()}; + AllFirePointVo[] detailParamArray = new AllFirePointVo[]{firePoint}; + if (smsReceiverList.size() > 0) { + String[] telephoneArray = new String[smsReceiverList.size()]; + for (int i = 0; i < smsReceiverList.size(); i++) { + telephoneArray[i] = "86" + smsReceiverList.get(i).getUserName(); + } + int resValue = SMSUtils.sendSmsToUser(telephoneArray, "1425995", templateParamArray); + String sendResult = resValue == 0 ? "短信通知发送成功!" : "短信通知发送失败!"; + //记录短信通知日志 + StringBuilder stringBuilder = new StringBuilder("发送人:青岛星科瑞升信息科技有限公司\n"); + for (String telephone : telephoneArray) { + stringBuilder.append("接收人:").append(telephone).append("\n"); + } + for (String templateParam : templateParamArray) { + stringBuilder.append("模板参数:").append(templateParam).append("\n"); + } + for (AllFirePointVo detailParam : detailParamArray) { + stringBuilder.append("超级详细的参数:").append(detailParam.toString()).append("\n"); + } + stringBuilder.append(sendResult); + log.info(stringBuilder.toString()); + } } }