开启正式服务的短信通知功能
This commit is contained in:
parent
dd150b1d22
commit
99d868bc9d
@ -3,7 +3,6 @@ package com.xkrs.helper;
|
||||
import com.xkrs.dao.CountyCodeWeiXinDao;
|
||||
import com.xkrs.dao.SysUserDao;
|
||||
import com.xkrs.model.entity.CountyCodeWeiXinEntity;
|
||||
import com.xkrs.model.entity.FirePointOrdinaryEntity;
|
||||
import com.xkrs.model.entity.FirePointPreciseEntity;
|
||||
import com.xkrs.model.entity.SysUserEntity;
|
||||
import com.xkrs.model.helper.PushHelper;
|
||||
@ -35,57 +34,55 @@ public class FirePointPushManager {
|
||||
@Resource
|
||||
private PushHelper pushHelper;
|
||||
|
||||
public void pushNotification(FirePointOrdinaryEntity firePointOrdinaryEntity) {
|
||||
pushNotification(FirePointConvertUtils.convert(firePointOrdinaryEntity), false);
|
||||
}
|
||||
// public void pushNotification(FirePointOrdinaryEntity firePointOrdinaryEntity) {
|
||||
//// pushNotification(FirePointConvertUtils.convert(firePointOrdinaryEntity), false);
|
||||
// }
|
||||
|
||||
public void pushNotification(FirePointPreciseEntity firePointPreciseEntity) {
|
||||
pushNotification(FirePointConvertUtils.convert(firePointPreciseEntity), true);
|
||||
pushNotification(FirePointConvertUtils.convert(firePointPreciseEntity));
|
||||
}
|
||||
|
||||
private void pushNotification(AllFirePointVo firePoint, boolean precise) {
|
||||
// //发送微信群聊消息
|
||||
// sendWeChatGroupMessage(firePoint);
|
||||
//
|
||||
// if (precise) {
|
||||
// //过滤短信通知收件人
|
||||
// List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
||||
// List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList);
|
||||
//// //推送
|
||||
//// try {
|
||||
//// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);
|
||||
//// pushHelper.dispatchPushMessage(userAccountList, firePointEntity);
|
||||
//// } catch (Exception e) {
|
||||
//// e.printStackTrace();
|
||||
//// }
|
||||
// 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", new String[]{firePoint.getFirePointAddress()});
|
||||
// String sendResult;
|
||||
// if (resValue == 0) {
|
||||
// //联系人列表发送短信成功,在数据库中的已发短信数量字段加一
|
||||
// for (SysUserEntity smsReceiver : smsReceiverList) {
|
||||
// smsReceiver.setReceiveSmsCount(smsReceiver.getReceiveSmsCount() + 1);
|
||||
// }
|
||||
// sysUserDao.saveAll(smsReceiverList);
|
||||
// sendResult = "短信通知发送成功!";
|
||||
// } else {
|
||||
// sendResult = "短信通知发送失败!";
|
||||
// }
|
||||
// //记录短信通知日志
|
||||
// StringBuilder stringBuilder = new StringBuilder("发送人:青岛星科瑞升信息科技有限公司\n");
|
||||
// for (String telephone : telephoneArray) {
|
||||
// stringBuilder.append("接收人:").append(telephone).append("\n");
|
||||
// }
|
||||
// stringBuilder.append("模板参数:").append(firePoint.getFirePointAddress()).append("\n");
|
||||
// stringBuilder.append("超级详细的参数:").append(firePoint.toString()).append("\n");
|
||||
// stringBuilder.append(sendResult);
|
||||
// log.info(stringBuilder.toString());
|
||||
private void pushNotification(AllFirePointVo firePoint) {
|
||||
//发送微信群聊消息
|
||||
sendWeChatGroupMessage(firePoint);
|
||||
|
||||
//过滤短信通知收件人
|
||||
List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
||||
List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList);
|
||||
// //推送
|
||||
// try {
|
||||
// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);
|
||||
// pushHelper.dispatchPushMessage(userAccountList, firePointEntity);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
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", new String[]{firePoint.getFirePointAddress()});
|
||||
String sendResult;
|
||||
if (resValue == 0) {
|
||||
//联系人列表发送短信成功,在数据库中的已发短信数量字段加一
|
||||
for (SysUserEntity smsReceiver : smsReceiverList) {
|
||||
smsReceiver.setReceiveSmsCount(smsReceiver.getReceiveSmsCount() + 1);
|
||||
}
|
||||
sysUserDao.saveAll(smsReceiverList);
|
||||
sendResult = "短信通知发送成功!";
|
||||
} else {
|
||||
sendResult = "短信通知发送失败!";
|
||||
}
|
||||
//记录短信通知日志
|
||||
StringBuilder stringBuilder = new StringBuilder("发送人:青岛星科瑞升信息科技有限公司\n");
|
||||
for (String telephone : telephoneArray) {
|
||||
stringBuilder.append("接收人:").append(telephone).append("\n");
|
||||
}
|
||||
stringBuilder.append("模板参数:").append(firePoint.getFirePointAddress()).append("\n");
|
||||
stringBuilder.append("超级详细的参数:").append(firePoint.toString()).append("\n");
|
||||
stringBuilder.append(sendResult);
|
||||
log.info(stringBuilder.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,6 +98,11 @@ public class SysUserEntity implements Serializable {
|
||||
*/
|
||||
private String pushId;
|
||||
|
||||
/**
|
||||
* 占位符
|
||||
*/
|
||||
private String placeHolder;
|
||||
|
||||
/**
|
||||
* VIP时间范围列表Json
|
||||
*/
|
||||
@ -259,6 +264,14 @@ public class SysUserEntity implements Serializable {
|
||||
this.pushId = pushId;
|
||||
}
|
||||
|
||||
public String getPlaceHolder() {
|
||||
return placeHolder;
|
||||
}
|
||||
|
||||
public void setPlaceHolder(String placeHolder) {
|
||||
this.placeHolder = placeHolder;
|
||||
}
|
||||
|
||||
public String getVipTimeRangeJson() {
|
||||
return vipTimeRangeJson;
|
||||
}
|
||||
@ -289,7 +302,8 @@ public class SysUserEntity implements Serializable {
|
||||
", receiveSmsCount=" + receiveSmsCount +
|
||||
", remark='" + remark + '\'' +
|
||||
", pushId='" + pushId + '\'' +
|
||||
", placeHolder='" + placeHolder + '\'' +
|
||||
", vipTimeRangeJson='" + vipTimeRangeJson + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
||||
} else {
|
||||
messageOrdinary = "普通火点添加成功";
|
||||
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
||||
firePointPushManager.pushNotification(firePointOrdinaryEntity);
|
||||
// firePointPushManager.pushNotification(firePointOrdinaryEntity);
|
||||
}
|
||||
}
|
||||
List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll();
|
||||
|
@ -42,6 +42,9 @@ public class FirePointCodeUtils {
|
||||
try {
|
||||
String formatCutCode = FirePointCodeUtils.getFormatCutCode(sysUser.getCountyCode());
|
||||
if (firePointStreetCode.startsWith(formatCutCode)) {
|
||||
if (TextUtils.isEmpty(sysUser.getPlaceHolder())) {//不是超级用户不发短信
|
||||
continue;
|
||||
}
|
||||
if (sysUser.getActiveFlag() != 0) {//被禁用的用户不发短信
|
||||
continue;
|
||||
}
|
||||
@ -57,7 +60,7 @@ public class FirePointCodeUtils {
|
||||
} else {
|
||||
//普通用户可以接收3条短信
|
||||
Long receiveSmsCount = sysUser.getReceiveSmsCount();
|
||||
if (receiveSmsCount != null && receiveSmsCount>=3) {
|
||||
if (receiveSmsCount != null && receiveSmsCount >= 3) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user