From 642327f88fd9689ba18cbb158e093d9d715a3b52 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Mon, 6 Feb 2023 12:00:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=94=A8=E6=88=B7=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/controller/PushController.java | 4 +- .../xkrs/controller/SysUserController.java | 25 +-- src/main/java/com/xkrs/dao/AgentOrgDao.java | 11 -- .../com/xkrs/model/entity/AgentOrgEntity.java | 56 ------- .../service/impl/FirePointServiceImpl.java | 19 +-- src/main/java/com/xkrs/sms/SMSHelper.java | 143 ------------------ .../com/xkrs/sms/WeChatMessageHelper.java | 89 ----------- .../model/helper}/PushHelper.java | 2 +- .../xkrs/straw/model/helper/SMSHelper.java | 100 ++++++++++++ .../com/xkrs/utils/FirePointCodeUtils.java | 44 ------ 10 files changed, 116 insertions(+), 377 deletions(-) delete mode 100644 src/main/java/com/xkrs/dao/AgentOrgDao.java delete mode 100644 src/main/java/com/xkrs/model/entity/AgentOrgEntity.java delete mode 100644 src/main/java/com/xkrs/sms/SMSHelper.java delete mode 100644 src/main/java/com/xkrs/sms/WeChatMessageHelper.java rename src/main/java/com/xkrs/{sms => straw/model/helper}/PushHelper.java (99%) create mode 100644 src/main/java/com/xkrs/straw/model/helper/SMSHelper.java diff --git a/src/main/java/com/xkrs/controller/PushController.java b/src/main/java/com/xkrs/controller/PushController.java index 67132cb..0a2f683 100644 --- a/src/main/java/com/xkrs/controller/PushController.java +++ b/src/main/java/com/xkrs/controller/PushController.java @@ -1,10 +1,10 @@ package com.xkrs.controller; import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.model.qo.SysUserPushAccountQo; import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.model.entity.SysUserEntity; -import com.xkrs.model.qo.SysUserPushAccountQo; -import com.xkrs.sms.PushHelper; +import com.xkrs.straw.model.helper.PushHelper; import org.apache.hc.core5.util.TextUtils; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 5d359ef..3b18655 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -1,9 +1,8 @@ package com.xkrs.controller; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.tool.TokenUtil; -import com.xkrs.dao.AgentOrgDao; -import com.xkrs.model.entity.AgentOrgEntity; import com.xkrs.model.qo.SysUserQo; import com.xkrs.model.qo.SysUserReceiveSmsQo; import com.xkrs.model.qo.SysUserRemarkQo; @@ -11,11 +10,11 @@ import com.xkrs.model.qo.SysUserVipLevelQo; import com.xkrs.model.validation.SysUserQoInsert; import com.xkrs.model.validation.SysUserQoUpdate; import com.xkrs.service.RedisService; -import com.xkrs.sms.SMSHelper; import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.model.entity.SysUserEntity; +import com.xkrs.straw.model.helper.SMSHelper; import com.xkrs.straw.service.SysUserService; -import com.xkrs.utils.FirePointCodeUtils; +import com.xkrs.utils.AliYunSmsUtils; import com.xkrs.utils.ListUtils; import com.xkrs.utils.RandomUtil; import org.apache.hc.core5.util.TextUtils; @@ -55,9 +54,6 @@ public class SysUserController { @Resource private RedisService redisService; - @Resource - private AgentOrgDao agentOrgDao; - @Resource private SMSHelper smsHelper; @@ -193,12 +189,6 @@ public class SysUserController { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OK", locale); } - @GetMapping("/selectAgentOrgList") - public String selectAgentOrgList() { - List agentOrgList = agentOrgDao.findAll(Sort.by(Sort.Direction.ASC, "id")); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, agentOrgList, locale); - } - /** * 注册系统用户 */ @@ -367,12 +357,9 @@ public class SysUserController { */ @GetMapping("/verificationCode") public String verificationCode(@RequestParam("phone") String phone, @RequestParam(value = "agentOrgId", required = false) String agentOrgId) throws Exception { - Long finalAgentOrgId = Long.parseLong(TextUtils.isEmpty(agentOrgId) ? "1" : agentOrgId); - List agentOrgList = agentOrgDao.findAll(); - String targetAgentOrgName = FirePointCodeUtils.getTargetAgentOrgName(finalAgentOrgId, agentOrgList); String optCode = String.valueOf(RandomUtil.returnCode()); redisService.set(phone, optCode, 10, TimeUnit.MINUTES); - smsHelper.dispatchSMSCode(targetAgentOrgName, phone, optCode); + SendSmsResponse response = AliYunSmsUtils.sendCode(phone, optCode); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); } @@ -394,11 +381,9 @@ public class SysUserController { return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "手机号错误,请使用您注册的手机号", locale); } SysUserEntity sysUserEntity = sysUserEntityList.get(0); - List agentOrgList = agentOrgDao.findAll(); - String targetAgentOrgName = FirePointCodeUtils.getTargetAgentOrgName(sysUserEntity.getAgentOrgId(), agentOrgList); String optCode = String.valueOf(RandomUtil.returnCode()); redisService.set(phone, optCode, 10, TimeUnit.MINUTES); - smsHelper.dispatchSMSCode(targetAgentOrgName, phone, optCode); + SendSmsResponse response = AliYunSmsUtils.sendCode(phone, optCode); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); } diff --git a/src/main/java/com/xkrs/dao/AgentOrgDao.java b/src/main/java/com/xkrs/dao/AgentOrgDao.java deleted file mode 100644 index a12b901..0000000 --- a/src/main/java/com/xkrs/dao/AgentOrgDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.AgentOrgEntity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.stereotype.Component; - -@Component -public interface AgentOrgDao extends JpaRepository, JpaSpecificationExecutor { - -} diff --git a/src/main/java/com/xkrs/model/entity/AgentOrgEntity.java b/src/main/java/com/xkrs/model/entity/AgentOrgEntity.java deleted file mode 100644 index 4ffa9c3..0000000 --- a/src/main/java/com/xkrs/model/entity/AgentOrgEntity.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.xkrs.model.entity; - -import javax.persistence.*; -import java.io.Serializable; - -@Entity -@Table(name = "agent_org") -public class AgentOrgEntity implements Serializable { - - /** - * 主键id - */ - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "agent_org_seq_gen") - @SequenceGenerator(name = "agent_org_seq_gen", sequenceName = "agent_org_id_seq", allocationSize = 1) - private Long id; - - /** - * 代理名称 - */ - @Column(length = 128, columnDefinition = "varchar(128)") - private String orgName; - - /** - * 截止日期 - */ - @Column(length = 128, columnDefinition = "varchar(128)") - private String deadLine; - - public AgentOrgEntity() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getOrgName() { - return orgName; - } - - public void setOrgName(String orgName) { - this.orgName = orgName; - } - - public String getDeadLine() { - return deadLine; - } - - public void setDeadLine(String deadLine) { - this.deadLine = deadLine; - } -} diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index f4014d2..e541c45 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -2,17 +2,20 @@ package com.xkrs.service.impl; import com.fasterxml.jackson.databind.ObjectMapper; import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.dao.*; -import com.xkrs.model.entity.*; +import com.xkrs.dao.CountyCodeWeiXinDao; +import com.xkrs.dao.FirePointDao; +import com.xkrs.dao.StreetDao; +import com.xkrs.model.entity.CountyCodeWeiXinEntity; +import com.xkrs.model.entity.FirePointEntity; import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.vo.GaoDeIgGeocodeVo; import com.xkrs.service.FirePointService; import com.xkrs.service.GlobalConfigService; import com.xkrs.service.StreetService; -import com.xkrs.sms.PushHelper; -import com.xkrs.sms.SMSHelper; import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.model.entity.SysUserEntity; +import com.xkrs.straw.model.helper.PushHelper; +import com.xkrs.straw.model.helper.SMSHelper; import com.xkrs.utils.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,9 +72,6 @@ public class FirePointServiceImpl implements FirePointService { @Resource private StreetService streetService; - @Resource - private AgentOrgDao agentOrgDao; - @Resource private SMSHelper smsHelper; @@ -190,11 +190,8 @@ public class FirePointServiceImpl implements FirePointService { // } catch (Exception e) { // e.printStackTrace(); // } - //对短信通知收件人进行分组 - List agentOrgList = agentOrgDao.findAll(); - Map> agentOrgNameGroupMap = FirePointCodeUtils.groupSmsReceiver(smsReceiverList, agentOrgList); //分发短信通知 - smsHelper.dispatchSMSMessage(agentOrgNameGroupMap, new String[]{firePointEntity.getFirePointAddress()}, new FirePointEntity[]{firePointEntity}); + smsHelper.dispatchSMSMessage(smsReceiverList, new String[]{firePointEntity.getFirePointAddress()}, new FirePointEntity[]{firePointEntity}); } } diff --git a/src/main/java/com/xkrs/sms/SMSHelper.java b/src/main/java/com/xkrs/sms/SMSHelper.java deleted file mode 100644 index cb5f62f..0000000 --- a/src/main/java/com/xkrs/sms/SMSHelper.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.xkrs.sms; - -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.xkrs.model.entity.FirePointEntity; -import com.xkrs.straw.model.entity.SysUserEntity; -import com.xkrs.utils.AliYunSmsUtils; -import com.xkrs.utils.HttpClientUtils; -import com.xkrs.utils.SMSUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Component -public class SMSHelper { - - public static Logger log = LoggerFactory.getLogger(SMSHelper.class); - - public SMSHelper() { - } - - public void dispatchSMSMessage(Map> agentOrgNameGroupMap, String[] templateParamArray, FirePointEntity[] detailParamArray) { - for (Map.Entry> entry : agentOrgNameGroupMap.entrySet()) { - String targetAgentOrgName = entry.getKey(); - List groupSmsReceiverList = entry.getValue(); - if (groupSmsReceiverList != null && groupSmsReceiverList.size() > 0) { - String[] telephoneArray = new String[groupSmsReceiverList.size()]; - for (int i = 0; i < groupSmsReceiverList.size(); i++) { - telephoneArray[i] = "86" + groupSmsReceiverList.get(i).getUserName(); - } - if ("青岛星科瑞升信息科技有限公司".equals(targetAgentOrgName)) { - - xingkeSMSMessage(telephoneArray, templateParamArray, detailParamArray); - - } else if ("青岛华正信息技术股份有限公司".equals(targetAgentOrgName)) { - - try { - huazhengSMSMessage(telephoneArray, templateParamArray, detailParamArray); - } catch (Exception e) { - e.printStackTrace(); - } - - } - } - } - } - - /** - * 星科瑞升向用户发送短信 - */ - private void xingkeSMSMessage(String[] telephoneArray, String[] templateParamArray, FirePointEntity[] 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 (FirePointEntity detailParam : detailParamArray) { - stringBuilder.append("超级详细的参数:").append(detailParam.toString()).append("\n"); - } - stringBuilder.append(sendResult); - log.info(stringBuilder.toString()); - } - - /** - * 华正信息向用户发送短信 - */ - private void huazhengSMSMessage(String[] telephoneArray, String[] templateParamArray, FirePointEntity[] detailParamArray) throws Exception { - StringBuilder telephoneBuilder = new StringBuilder(); - for (int i = 0; i < telephoneArray.length; i++) { - telephoneBuilder.append(telephoneArray[i]); - if (i < telephoneArray.length - 1) { - telephoneBuilder.append(","); - } - } - String telephoneContent = telephoneBuilder.toString(); - String url = "http://58.56.128.186:10144/msg/msgSend"; - Map map = new HashMap<>(); - map.put("receiver", telephoneContent); - map.put("msgContent", "{\"address\":\"" + templateParamArray[0] + "\"}"); - map.put("templateUid", "27dbffdf8b0a492e"); - HttpClientUtils.sendHttpPost(url, new ObjectMapper().writeValueAsString(map)); - - //记录短信通知日志 - 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 (FirePointEntity detailParam : detailParamArray) { - stringBuilder.append("超级详细的参数:").append(detailParam.toString()).append("\n"); - } - log.info(stringBuilder.toString()); - } - - public void dispatchSMSCode(String targetAgentOrgName, String telephone, String code) throws Exception { - - if ("青岛星科瑞升信息科技有限公司".equals(targetAgentOrgName)) { - - xingkeSMSCode(telephone, code); - - } else if ("青岛华正信息技术股份有限公司".equals(targetAgentOrgName)) { - - huazhengSMSCode(telephone, code); - - } - - } - - /** - * 星科瑞升向用户发送验证码 - */ - private void xingkeSMSCode(String telephone, String code) throws Exception { - SendSmsResponse response = AliYunSmsUtils.sendCode(telephone, code); - } - - /** - * 华正信息向用户发送验证码 - */ - private void huazhengSMSCode(String telephone, String code) throws Exception { - - String url = "http://58.56.128.186:10144/msg/msgSend"; - Map map = new HashMap<>(); - map.put("receiver", telephone); - map.put("msgContent", "{\"code\":\"" + code + "\"}"); - map.put("templateUid", "6f7672a4978542e2"); - HttpClientUtils.sendHttpPost(url, new ObjectMapper().writeValueAsString(map)); - //记录短信通知日志 - String stringBuilder = "发送人:青岛华正信息技术股份有限公司\n" + "接收人:" + telephone + "\n" + "验证码:" + code + "\n"; - log.info(stringBuilder); - } - -} diff --git a/src/main/java/com/xkrs/sms/WeChatMessageHelper.java b/src/main/java/com/xkrs/sms/WeChatMessageHelper.java deleted file mode 100644 index c6fe4cb..0000000 --- a/src/main/java/com/xkrs/sms/WeChatMessageHelper.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.xkrs.sms; - -import com.xkrs.dao.GlobalConfigurationDao; -import com.xkrs.model.entity.FirePointEntity; -import com.xkrs.model.entity.GlobalConfigurationEntity; -import com.xkrs.straw.model.entity.SysUserEntity; -import com.xkrs.service.GlobalConfigurationService; -import com.xkrs.straw.model.bean.KeyValueBean; -import com.xkrs.utils.HttpClientUtils; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import javax.persistence.criteria.Predicate; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -@Component -public class WeChatMessageHelper { - - @Resource - private GlobalConfigurationDao globalConfigurationDao; - - @Resource - private GlobalConfigurationService globalConfigurationService; - - public WeChatMessageHelper() { - } - - public void dispatchWeChatMessage(List sysUserList, FirePointEntity firePointEntity) throws Exception { - - if (sysUserList == null || sysUserList.isEmpty() || firePointEntity == null) { - return; - } - //获取微信硬件设备消息通知组名 - final String belongGroupWeChat = globalConfigurationDao.findAll((root, criteriaQuery, criteriaBuilder) -> { - List predicateList = new ArrayList<>(); - predicateList.add(criteriaBuilder.equal(root.get("belongGroup").as(String.class), "root")); - predicateList.add(criteriaBuilder.equal(root.get("key").as(String.class), "weixin_hardware_device_message_key")); - Predicate[] predicateArray = new Predicate[predicateList.size()]; - return criteriaBuilder.and(predicateList.toArray(predicateArray)); - }, Sort.by(Sort.Direction.ASC, "id")).get(0).getValue(); - //获取微信硬件设备消息通知参数实体集合 - List weChatConfigurationList = globalConfigurationDao.findAll((root, criteriaQuery, criteriaBuilder) -> { - List predicateList = new ArrayList<>(); - predicateList.add(criteriaBuilder.equal(root.get("belongGroup").as(String.class), belongGroupWeChat)); - Predicate[] predicateArray = new Predicate[predicateList.size()]; - return criteriaBuilder.and(predicateList.toArray(predicateArray)); - }, Sort.by(Sort.Direction.ASC, "id")); - //获取微信硬件设备消息通知参数 - String grantType = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "grant_type")).getValue(); - String appId = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "appid")).getValue(); - String secret = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "secret")).getValue(); - String to_openid_list = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "to_openid_list")).getValue(); - String template_id = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "template_id")).getValue(); - String sn = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "sn")).getValue(); - String model_id = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "model_id")).getValue(); - String page = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "page")).getValue(); - String miniprogram_state = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "miniprogram_state")).getValue(); - String lang = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "lang")).getValue(); - String template_param_count = Objects.requireNonNull(obtainValueByKey(weChatConfigurationList, "template_param_count")).getValue(); - //获取微信硬件设备消息通知参数模板参数 - List templateParamList = new ArrayList<>(); - DecimalFormat decimalFormat = new DecimalFormat("00"); - for (int i = 1; i <= Long.parseLong(template_param_count); i++) { - String formatParamIndex = decimalFormat.format(i); - GlobalConfigurationEntity templateParamKey = obtainValueByKey(weChatConfigurationList, "template_param_key_" + formatParamIndex); - GlobalConfigurationEntity templateParamValue = obtainValueByKey(weChatConfigurationList, "template_param_value_" + formatParamIndex); - templateParamList.add(new KeyValueBean(Objects.requireNonNull(templateParamKey).getValue(), Objects.requireNonNull(templateParamValue).getValue())); - } - //获取AccessToken - String getAccessTokenUrl = "https://api.weixin.qq.com/cgi-bin/token" + "?grant_type=" + grantType + "&appid=" + appId + "&secret=" + secret; - String result = HttpClientUtils.sendHttpsGet(getAccessTokenUrl); - System.out.println(result); - - } - - private GlobalConfigurationEntity obtainValueByKey(List configurationList, String key) { - for (GlobalConfigurationEntity configuration : configurationList) { - if (configuration.getKey().equals(key)) { - return configuration; - } - } - return null; - } - -} diff --git a/src/main/java/com/xkrs/sms/PushHelper.java b/src/main/java/com/xkrs/straw/model/helper/PushHelper.java similarity index 99% rename from src/main/java/com/xkrs/sms/PushHelper.java rename to src/main/java/com/xkrs/straw/model/helper/PushHelper.java index edcba7f..aa89118 100644 --- a/src/main/java/com/xkrs/sms/PushHelper.java +++ b/src/main/java/com/xkrs/straw/model/helper/PushHelper.java @@ -1,4 +1,4 @@ -package com.xkrs.sms; +package com.xkrs.straw.model.helper; import com.xiaomi.push.sdk.ErrorCode; import com.xiaomi.xmpush.server.Constants; diff --git a/src/main/java/com/xkrs/straw/model/helper/SMSHelper.java b/src/main/java/com/xkrs/straw/model/helper/SMSHelper.java new file mode 100644 index 0000000..3b4a794 --- /dev/null +++ b/src/main/java/com/xkrs/straw/model/helper/SMSHelper.java @@ -0,0 +1,100 @@ +package com.xkrs.straw.model.helper; + +import com.xkrs.model.entity.FirePointEntity; +import com.xkrs.straw.model.entity.SysUserEntity; +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, FirePointEntity[] 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, FirePointEntity[] 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 (FirePointEntity detailParam : detailParamArray) { + stringBuilder.append("超级详细的参数:").append(detailParam.toString()).append("\n"); + } + stringBuilder.append(sendResult); + log.info(stringBuilder.toString()); + } + +// /** +// * 华正信息向用户发送短信 +// */ +// private void huazhengSMSMessage(String[] telephoneArray, String[] templateParamArray, FirePointEntity[] detailParamArray) throws Exception { +// StringBuilder telephoneBuilder = new StringBuilder(); +// for (int i = 0; i < telephoneArray.length; i++) { +// telephoneBuilder.append(telephoneArray[i]); +// if (i < telephoneArray.length - 1) { +// telephoneBuilder.append(","); +// } +// } +// String telephoneContent = telephoneBuilder.toString(); +// String url = "http://58.56.128.186:10144/msg/msgSend"; +// Map map = new HashMap<>(); +// map.put("receiver", telephoneContent); +// map.put("msgContent", "{\"address\":\"" + templateParamArray[0] + "\"}"); +// map.put("templateUid", "27dbffdf8b0a492e"); +// HttpClientUtils.sendHttpPost(url, new ObjectMapper().writeValueAsString(map)); +// +// //记录短信通知日志 +// 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 (FirePointEntity detailParam : detailParamArray) { +// stringBuilder.append("超级详细的参数:").append(detailParam.toString()).append("\n"); +// } +// log.info(stringBuilder.toString()); +// } + +// /** +// * 华正信息向用户发送验证码 +// */ +// private void huazhengSMSCode(String telephone, String code) throws Exception { +// +// String url = "http://58.56.128.186:10144/msg/msgSend"; +// Map map = new HashMap<>(); +// map.put("receiver", telephone); +// map.put("msgContent", "{\"code\":\"" + code + "\"}"); +// map.put("templateUid", "6f7672a4978542e2"); +// HttpClientUtils.sendHttpPost(url, new ObjectMapper().writeValueAsString(map)); +// //记录短信通知日志 +// String stringBuilder = "发送人:青岛华正信息技术股份有限公司\n" + "接收人:" + telephone + "\n" + "验证码:" + code + "\n"; +// log.info(stringBuilder); +// } + +} diff --git a/src/main/java/com/xkrs/utils/FirePointCodeUtils.java b/src/main/java/com/xkrs/utils/FirePointCodeUtils.java index 1640647..cdf65d5 100644 --- a/src/main/java/com/xkrs/utils/FirePointCodeUtils.java +++ b/src/main/java/com/xkrs/utils/FirePointCodeUtils.java @@ -1,14 +1,11 @@ package com.xkrs.utils; -import com.xkrs.model.entity.AgentOrgEntity; import com.xkrs.straw.model.entity.SysUserEntity; import org.apache.hc.core5.util.TextUtils; import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class FirePointCodeUtils { @@ -82,45 +79,4 @@ public class FirePointCodeUtils { return smsReceiverList; } - /** - * 对短信通知收信人进行分组 - */ - public static Map> groupSmsReceiver(List smsReceiverList, List agentOrgList) { - Map> groupMap = new HashMap<>(); - if (smsReceiverList == null || smsReceiverList.isEmpty()) { - return groupMap; - } - if (agentOrgList == null || agentOrgList.isEmpty()) { - return groupMap; - } - for (SysUserEntity smsReceiver : smsReceiverList) { - String targetAgentOrgName = getTargetAgentOrgName(smsReceiver.getAgentOrgId(), agentOrgList); - if (groupMap.containsKey(targetAgentOrgName)) { - List groupSmsReceiverList = groupMap.get(targetAgentOrgName); - groupSmsReceiverList.add(smsReceiver); - } else { - List groupSmsReceiverList = new ArrayList<>(); - groupSmsReceiverList.add(smsReceiver); - groupMap.put(targetAgentOrgName, groupSmsReceiverList); - } - } - return groupMap; - } - - /** - * 获取系统用户的代理组织名称 - */ - public static String getTargetAgentOrgName(Long agentOrgId, List agentOrgList) { - for (AgentOrgEntity agentOrg : agentOrgList) { - try { - if (agentOrgId.longValue() == agentOrg.getId().longValue()) { - return agentOrg.getOrgName(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - return "青岛星科瑞升信息科技有限公司"; - } - }