77 lines
2.8 KiB
Java
77 lines
2.8 KiB
Java
package com.xkrs.utilsnew;
|
|
|
|
import com.xkrs.model.entity.SysUserEntity;
|
|
import org.apache.hc.core5.util.TextUtils;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class FirePointCodeUtils {
|
|
|
|
private FirePointCodeUtils() {
|
|
}
|
|
|
|
public static String getFormatCutCode(String code) {
|
|
String formatCutCode = code.trim();
|
|
while ((!TextUtils.isEmpty(formatCutCode)) && (formatCutCode.endsWith("0"))) {
|
|
formatCutCode = formatCutCode.substring(0, formatCutCode.length() - 1).trim();
|
|
}
|
|
int length = formatCutCode.length();
|
|
if (1 == length || 3 == length || 5 == length || 8 == length) {
|
|
return formatCutCode + "0";
|
|
}
|
|
if (7 == length) {
|
|
return length + "00";
|
|
}
|
|
return formatCutCode;
|
|
}
|
|
|
|
/**
|
|
* 过滤短信通知收信人
|
|
*
|
|
* @param firePointStreetCode 火点的街道编号
|
|
* @param sysUserList 系统用户列表
|
|
* @return 短信通知收信人列表
|
|
*/
|
|
public static List<SysUserEntity> filterSmsReceiver(String firePointStreetCode, List<SysUserEntity> sysUserList) {
|
|
List<SysUserEntity> smsReceiverList = new ArrayList<>();
|
|
if (sysUserList == null || sysUserList.isEmpty()) {
|
|
return smsReceiverList;
|
|
}
|
|
for (SysUserEntity sysUser : sysUserList) {
|
|
try {
|
|
String formatCutCode = FirePointCodeUtils.getFormatCutCode(sysUser.getCountyCode());
|
|
if (firePointStreetCode.startsWith(formatCutCode)) {
|
|
if (TextUtils.isEmpty(sysUser.getPlaceHolder())) {//不是超级用户不发短信
|
|
continue;
|
|
}
|
|
if (sysUser.getActiveFlag() != 0) {//被禁用的用户不发短信
|
|
continue;
|
|
}
|
|
if (sysUser.getReceiveSms() != 1) {//关掉开关的用户不发短信
|
|
continue;
|
|
}
|
|
if ("管理员".equals(sysUser.getAccountType())) {//管理员用户不发短信
|
|
continue;
|
|
}
|
|
boolean inVipTimeRange = VipTimeRangeUtils.checkIfInVipTimeRange(sysUser.getVipTimeRangeJson());
|
|
if (inVipTimeRange) {
|
|
//VIP用户可以接收短信
|
|
} else {
|
|
//普通用户可以接收3条短信
|
|
Long receiveSmsCount = sysUser.getReceiveSmsCount();
|
|
if (receiveSmsCount != null && receiveSmsCount >= 3) {
|
|
continue;
|
|
}
|
|
}
|
|
smsReceiverList.add(sysUser);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
return smsReceiverList;
|
|
}
|
|
|
|
}
|