优化过滤短信接收者的逻辑

This commit is contained in:
liuchengqian 2023-01-30 14:07:03 +08:00
parent 431d8aac0d
commit c9c7c6ccdf
2 changed files with 8 additions and 26 deletions

View File

@ -65,9 +65,6 @@ public class FirePointServiceImpl implements FirePointService {
@Resource @Resource
private CountyCodeWeiXinDao countyCodeWeiXinDao; private CountyCodeWeiXinDao countyCodeWeiXinDao;
@Resource
private RelRoleAuthorityDao relRoleAuthorityDao;
@Resource @Resource
private FirePointQueryHelper firePointQueryHelper; private FirePointQueryHelper firePointQueryHelper;
@ -279,10 +276,9 @@ public class FirePointServiceImpl implements FirePointService {
if ("耕地".equals(firePointEntity.getLandType())) { if ("耕地".equals(firePointEntity.getLandType())) {
//过滤短信通知收件人 //过滤短信通知收件人
List<SysUserEntity> sysUserList = sysUserDao.findAll(); List<SysUserEntity> sysUserList = sysUserDao.findAll();
List<RelRoleAuthorityEntity> adminList = relRoleAuthorityDao.selectByAuthorityId(1);
boolean normalSmsEnable = 1L == globalConfigService.selectGlobalConfigValue(9L); boolean normalSmsEnable = 1L == globalConfigService.selectGlobalConfigValue(9L);
boolean vipSmsEnable = 1L == globalConfigService.selectGlobalConfigValue(10L); boolean vipSmsEnable = 1L == globalConfigService.selectGlobalConfigValue(10L);
List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePointEntity.getStreetCode(), sysUserList, adminList, normalSmsEnable, vipSmsEnable); List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePointEntity.getStreetCode(), sysUserList, normalSmsEnable, vipSmsEnable);
// //推送 // //推送
// try { // try {
// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList); // List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);

View File

@ -1,7 +1,6 @@
package com.xkrs.utils; package com.xkrs.utils;
import com.xkrs.model.entity.AgentOrgEntity; import com.xkrs.model.entity.AgentOrgEntity;
import com.xkrs.model.entity.RelRoleAuthorityEntity;
import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.entity.SysUserEntity;
import org.apache.hc.core5.util.TextUtils; import org.apache.hc.core5.util.TextUtils;
@ -36,12 +35,11 @@ public class FirePointCodeUtils {
* *
* @param firePointStreetCode 火点的街道编号 * @param firePointStreetCode 火点的街道编号
* @param sysUserList 系统用户列表 * @param sysUserList 系统用户列表
* @param adminList 管理员列表
* @param normalSmsEnable 普通用户能否接收短信通知 * @param normalSmsEnable 普通用户能否接收短信通知
* @param vipSmsEnable VIP用户能否接收短信通知 * @param vipSmsEnable VIP用户能否接收短信通知
* @return 短信通知收信人列表 * @return 短信通知收信人列表
*/ */
public static List<SysUserEntity> filterSmsReceiver(String firePointStreetCode, List<SysUserEntity> sysUserList, List<RelRoleAuthorityEntity> adminList, boolean normalSmsEnable, boolean vipSmsEnable) { public static List<SysUserEntity> filterSmsReceiver(String firePointStreetCode, List<SysUserEntity> sysUserList, boolean normalSmsEnable, boolean vipSmsEnable) {
List<SysUserEntity> smsReceiverList = new ArrayList<>(); List<SysUserEntity> smsReceiverList = new ArrayList<>();
if (sysUserList == null || sysUserList.isEmpty()) { if (sysUserList == null || sysUserList.isEmpty()) {
return smsReceiverList; return smsReceiverList;
@ -59,6 +57,12 @@ public class FirePointCodeUtils {
if (sysUser.getReceiveSms() != 1) {//关掉开关的用户不发短信 if (sysUser.getReceiveSms() != 1) {//关掉开关的用户不发短信
continue; continue;
} }
if (sysUser.getStatusCode() != 0) {//状态不正常的用户不发短信
continue;
}
if ("管理员".equals(sysUser.getAccountType())) {//管理员用户不发短信
continue;
}
LocalDateTime sysUserOverDateTime = DateTimeUtil.stringToDateTimeFormatter(sysUser.getOverTime(), DateTimeUtil.COMMON_FORMATTER_DATETIME); LocalDateTime sysUserOverDateTime = DateTimeUtil.stringToDateTimeFormatter(sysUser.getOverTime(), DateTimeUtil.COMMON_FORMATTER_DATETIME);
if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) { if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) {
if (!normalSmsEnable) {//根据配置信息决定普通用户是否发送短信 if (!normalSmsEnable) {//根据配置信息决定普通用户是否发送短信
@ -69,9 +73,6 @@ public class FirePointCodeUtils {
continue; continue;
} }
} }
if (isAdmin(adminList, sysUser)) {//管理员用户不发短信
continue;
}
smsReceiverList.add(sysUser); smsReceiverList.add(sysUser);
} }
} catch (Exception e) { } catch (Exception e) {
@ -81,21 +82,6 @@ public class FirePointCodeUtils {
return smsReceiverList; return smsReceiverList;
} }
/**
* 判断是否是管理员
*/
private static boolean isAdmin(List<RelRoleAuthorityEntity> administratorList, SysUserEntity sysUser) {
if (administratorList == null || administratorList.size() == 0) {
return false;
}
for (RelRoleAuthorityEntity administrator : administratorList) {
if (administrator.getUserId().intValue() == sysUser.getId().intValue()) {
return true;
}
}
return false;
}
/** /**
* 对短信通知收信人进行分组 * 对短信通知收信人进行分组
*/ */