重构用户角色类

This commit is contained in:
liuchengqian 2023-02-06 12:00:10 +08:00
parent db87efb8fc
commit 642327f88f
10 changed files with 116 additions and 377 deletions

View File

@ -1,10 +1,10 @@
package com.xkrs.controller; package com.xkrs.controller;
import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.model.qo.SysUserPushAccountQo;
import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.dao.SysUserDao;
import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.straw.model.entity.SysUserEntity;
import com.xkrs.model.qo.SysUserPushAccountQo; import com.xkrs.straw.model.helper.PushHelper;
import com.xkrs.sms.PushHelper;
import org.apache.hc.core5.util.TextUtils; import org.apache.hc.core5.util.TextUtils;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;

View File

@ -1,9 +1,8 @@
package com.xkrs.controller; package com.xkrs.controller;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.common.tool.TokenUtil; 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.SysUserQo;
import com.xkrs.model.qo.SysUserReceiveSmsQo; import com.xkrs.model.qo.SysUserReceiveSmsQo;
import com.xkrs.model.qo.SysUserRemarkQo; 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.SysUserQoInsert;
import com.xkrs.model.validation.SysUserQoUpdate; import com.xkrs.model.validation.SysUserQoUpdate;
import com.xkrs.service.RedisService; import com.xkrs.service.RedisService;
import com.xkrs.sms.SMSHelper;
import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.dao.SysUserDao;
import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.straw.model.entity.SysUserEntity;
import com.xkrs.straw.model.helper.SMSHelper;
import com.xkrs.straw.service.SysUserService; 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.ListUtils;
import com.xkrs.utils.RandomUtil; import com.xkrs.utils.RandomUtil;
import org.apache.hc.core5.util.TextUtils; import org.apache.hc.core5.util.TextUtils;
@ -55,9 +54,6 @@ public class SysUserController {
@Resource @Resource
private RedisService redisService; private RedisService redisService;
@Resource
private AgentOrgDao agentOrgDao;
@Resource @Resource
private SMSHelper smsHelper; private SMSHelper smsHelper;
@ -193,12 +189,6 @@ public class SysUserController {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OK", locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OK", locale);
} }
@GetMapping("/selectAgentOrgList")
public String selectAgentOrgList() {
List<AgentOrgEntity> agentOrgList = agentOrgDao.findAll(Sort.by(Sort.Direction.ASC, "id"));
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, agentOrgList, locale);
}
/** /**
* 注册系统用户 * 注册系统用户
*/ */
@ -367,12 +357,9 @@ public class SysUserController {
*/ */
@GetMapping("/verificationCode") @GetMapping("/verificationCode")
public String verificationCode(@RequestParam("phone") String phone, @RequestParam(value = "agentOrgId", required = false) String agentOrgId) throws Exception { 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<AgentOrgEntity> agentOrgList = agentOrgDao.findAll();
String targetAgentOrgName = FirePointCodeUtils.getTargetAgentOrgName(finalAgentOrgId, agentOrgList);
String optCode = String.valueOf(RandomUtil.returnCode()); String optCode = String.valueOf(RandomUtil.returnCode());
redisService.set(phone, optCode, 10, TimeUnit.MINUTES); redisService.set(phone, optCode, 10, TimeUnit.MINUTES);
smsHelper.dispatchSMSCode(targetAgentOrgName, phone, optCode); SendSmsResponse response = AliYunSmsUtils.sendCode(phone, optCode);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
} }
@ -394,11 +381,9 @@ public class SysUserController {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "手机号错误,请使用您注册的手机号", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "手机号错误,请使用您注册的手机号", locale);
} }
SysUserEntity sysUserEntity = sysUserEntityList.get(0); SysUserEntity sysUserEntity = sysUserEntityList.get(0);
List<AgentOrgEntity> agentOrgList = agentOrgDao.findAll();
String targetAgentOrgName = FirePointCodeUtils.getTargetAgentOrgName(sysUserEntity.getAgentOrgId(), agentOrgList);
String optCode = String.valueOf(RandomUtil.returnCode()); String optCode = String.valueOf(RandomUtil.returnCode());
redisService.set(phone, optCode, 10, TimeUnit.MINUTES); redisService.set(phone, optCode, 10, TimeUnit.MINUTES);
smsHelper.dispatchSMSCode(targetAgentOrgName, phone, optCode); SendSmsResponse response = AliYunSmsUtils.sendCode(phone, optCode);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
} }

View File

@ -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<AgentOrgEntity, Long>, JpaSpecificationExecutor<AgentOrgEntity> {
}

View File

@ -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;
}
}

View File

@ -2,17 +2,20 @@ package com.xkrs.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.*; import com.xkrs.dao.CountyCodeWeiXinDao;
import com.xkrs.model.entity.*; 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.qo.FirePointQo;
import com.xkrs.model.vo.GaoDeIgGeocodeVo; import com.xkrs.model.vo.GaoDeIgGeocodeVo;
import com.xkrs.service.FirePointService; import com.xkrs.service.FirePointService;
import com.xkrs.service.GlobalConfigService; import com.xkrs.service.GlobalConfigService;
import com.xkrs.service.StreetService; 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.dao.SysUserDao;
import com.xkrs.straw.model.entity.SysUserEntity; 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 com.xkrs.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -69,9 +72,6 @@ public class FirePointServiceImpl implements FirePointService {
@Resource @Resource
private StreetService streetService; private StreetService streetService;
@Resource
private AgentOrgDao agentOrgDao;
@Resource @Resource
private SMSHelper smsHelper; private SMSHelper smsHelper;
@ -190,11 +190,8 @@ public class FirePointServiceImpl implements FirePointService {
// } catch (Exception e) { // } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
// } // }
//对短信通知收件人进行分组
List<AgentOrgEntity> agentOrgList = agentOrgDao.findAll();
Map<String, List<SysUserEntity>> 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});
} }
} }

View File

@ -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<String, List<SysUserEntity>> agentOrgNameGroupMap, String[] templateParamArray, FirePointEntity[] detailParamArray) {
for (Map.Entry<String, List<SysUserEntity>> entry : agentOrgNameGroupMap.entrySet()) {
String targetAgentOrgName = entry.getKey();
List<SysUserEntity> 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<String, Object> 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<String, Object> 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);
}
}

View File

@ -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<SysUserEntity> sysUserList, FirePointEntity firePointEntity) throws Exception {
if (sysUserList == null || sysUserList.isEmpty() || firePointEntity == null) {
return;
}
//获取微信硬件设备消息通知组名
final String belongGroupWeChat = globalConfigurationDao.findAll((root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> 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<GlobalConfigurationEntity> weChatConfigurationList = globalConfigurationDao.findAll((root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> 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<KeyValueBean> 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<GlobalConfigurationEntity> configurationList, String key) {
for (GlobalConfigurationEntity configuration : configurationList) {
if (configuration.getKey().equals(key)) {
return configuration;
}
}
return null;
}
}

View File

@ -1,4 +1,4 @@
package com.xkrs.sms; package com.xkrs.straw.model.helper;
import com.xiaomi.push.sdk.ErrorCode; import com.xiaomi.push.sdk.ErrorCode;
import com.xiaomi.xmpush.server.Constants; import com.xiaomi.xmpush.server.Constants;

View File

@ -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<SysUserEntity> 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<String, Object> 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<String, Object> 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);
// }
}

View File

@ -1,14 +1,11 @@
package com.xkrs.utils; package com.xkrs.utils;
import com.xkrs.model.entity.AgentOrgEntity;
import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.straw.model.entity.SysUserEntity;
import org.apache.hc.core5.util.TextUtils; import org.apache.hc.core5.util.TextUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class FirePointCodeUtils { public class FirePointCodeUtils {
@ -82,45 +79,4 @@ public class FirePointCodeUtils {
return smsReceiverList; return smsReceiverList;
} }
/**
* 对短信通知收信人进行分组
*/
public static Map<String, List<SysUserEntity>> groupSmsReceiver(List<SysUserEntity> smsReceiverList, List<AgentOrgEntity> agentOrgList) {
Map<String, List<SysUserEntity>> 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<SysUserEntity> groupSmsReceiverList = groupMap.get(targetAgentOrgName);
groupSmsReceiverList.add(smsReceiver);
} else {
List<SysUserEntity> groupSmsReceiverList = new ArrayList<>();
groupSmsReceiverList.add(smsReceiver);
groupMap.put(targetAgentOrgName, groupSmsReceiverList);
}
}
return groupMap;
}
/**
* 获取系统用户的代理组织名称
*/
public static String getTargetAgentOrgName(Long agentOrgId, List<AgentOrgEntity> agentOrgList) {
for (AgentOrgEntity agentOrg : agentOrgList) {
try {
if (agentOrgId.longValue() == agentOrg.getId().longValue()) {
return agentOrg.getOrgName();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return "青岛星科瑞升信息科技有限公司";
}
} }