开启正式服务的短信通知功能

This commit is contained in:
liuchengqian 2023-03-21 15:07:38 +08:00
parent dd150b1d22
commit 99d868bc9d
4 changed files with 64 additions and 50 deletions

View File

@ -3,7 +3,6 @@ package com.xkrs.helper;
import com.xkrs.dao.CountyCodeWeiXinDao; import com.xkrs.dao.CountyCodeWeiXinDao;
import com.xkrs.dao.SysUserDao; import com.xkrs.dao.SysUserDao;
import com.xkrs.model.entity.CountyCodeWeiXinEntity; import com.xkrs.model.entity.CountyCodeWeiXinEntity;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.entity.FirePointPreciseEntity; import com.xkrs.model.entity.FirePointPreciseEntity;
import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.helper.PushHelper; import com.xkrs.model.helper.PushHelper;
@ -35,57 +34,55 @@ public class FirePointPushManager {
@Resource @Resource
private PushHelper pushHelper; private PushHelper pushHelper;
public void pushNotification(FirePointOrdinaryEntity firePointOrdinaryEntity) { // public void pushNotification(FirePointOrdinaryEntity firePointOrdinaryEntity) {
pushNotification(FirePointConvertUtils.convert(firePointOrdinaryEntity), false); //// pushNotification(FirePointConvertUtils.convert(firePointOrdinaryEntity), false);
} // }
public void pushNotification(FirePointPreciseEntity firePointPreciseEntity) { public void pushNotification(FirePointPreciseEntity firePointPreciseEntity) {
pushNotification(FirePointConvertUtils.convert(firePointPreciseEntity), true); pushNotification(FirePointConvertUtils.convert(firePointPreciseEntity));
} }
private void pushNotification(AllFirePointVo firePoint, boolean precise) { private void pushNotification(AllFirePointVo firePoint) {
// //发送微信群聊消息 //发送微信群聊消息
// sendWeChatGroupMessage(firePoint); sendWeChatGroupMessage(firePoint);
//
// if (precise) { //过滤短信通知收件人
// //过滤短信通知收件人 List<SysUserEntity> sysUserList = sysUserDao.findAll();
// List<SysUserEntity> sysUserList = sysUserDao.findAll(); List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList);
// List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList); // //推送
//// //推送 // try {
//// try { // List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);
//// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList); // pushHelper.dispatchPushMessage(userAccountList, firePointEntity);
//// pushHelper.dispatchPushMessage(userAccountList, firePointEntity); // } catch (Exception e) {
//// } catch (Exception e) { // e.printStackTrace();
//// 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());
// }
// } // }
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());
}
} }
/** /**

View File

@ -98,6 +98,11 @@ public class SysUserEntity implements Serializable {
*/ */
private String pushId; private String pushId;
/**
* 占位符
*/
private String placeHolder;
/** /**
* VIP时间范围列表Json * VIP时间范围列表Json
*/ */
@ -259,6 +264,14 @@ public class SysUserEntity implements Serializable {
this.pushId = pushId; this.pushId = pushId;
} }
public String getPlaceHolder() {
return placeHolder;
}
public void setPlaceHolder(String placeHolder) {
this.placeHolder = placeHolder;
}
public String getVipTimeRangeJson() { public String getVipTimeRangeJson() {
return vipTimeRangeJson; return vipTimeRangeJson;
} }
@ -289,6 +302,7 @@ public class SysUserEntity implements Serializable {
", receiveSmsCount=" + receiveSmsCount + ", receiveSmsCount=" + receiveSmsCount +
", remark='" + remark + '\'' + ", remark='" + remark + '\'' +
", pushId='" + pushId + '\'' + ", pushId='" + pushId + '\'' +
", placeHolder='" + placeHolder + '\'' +
", vipTimeRangeJson='" + vipTimeRangeJson + '\'' + ", vipTimeRangeJson='" + vipTimeRangeJson + '\'' +
'}'; '}';
} }

View File

@ -121,7 +121,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
} else { } else {
messageOrdinary = "普通火点添加成功"; messageOrdinary = "普通火点添加成功";
firePointOrdinaryDao.save(firePointOrdinaryEntity); firePointOrdinaryDao.save(firePointOrdinaryEntity);
firePointPushManager.pushNotification(firePointOrdinaryEntity); // firePointPushManager.pushNotification(firePointOrdinaryEntity);
} }
} }
List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll(); List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll();

View File

@ -42,6 +42,9 @@ public class FirePointCodeUtils {
try { try {
String formatCutCode = FirePointCodeUtils.getFormatCutCode(sysUser.getCountyCode()); String formatCutCode = FirePointCodeUtils.getFormatCutCode(sysUser.getCountyCode());
if (firePointStreetCode.startsWith(formatCutCode)) { if (firePointStreetCode.startsWith(formatCutCode)) {
if (TextUtils.isEmpty(sysUser.getPlaceHolder())) {//不是超级用户不发短信
continue;
}
if (sysUser.getActiveFlag() != 0) {//被禁用的用户不发短信 if (sysUser.getActiveFlag() != 0) {//被禁用的用户不发短信
continue; continue;
} }