From 99d868bc9de741d10da94b34549b900ab38f2967 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Tue, 21 Mar 2023 15:07:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=90=AF=E6=AD=A3=E5=BC=8F=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E7=9F=AD=E4=BF=A1=E9=80=9A=E7=9F=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/helper/FirePointPushManager.java | 91 +++++++++---------- .../com/xkrs/model/entity/SysUserEntity.java | 16 +++- .../impl/DispatchFirePointServiceImpl.java | 2 +- .../com/xkrs/utilsnew/FirePointCodeUtils.java | 5 +- 4 files changed, 64 insertions(+), 50 deletions(-) diff --git a/src/main/java/com/xkrs/helper/FirePointPushManager.java b/src/main/java/com/xkrs/helper/FirePointPushManager.java index 12f74c4..71c225a 100644 --- a/src/main/java/com/xkrs/helper/FirePointPushManager.java +++ b/src/main/java/com/xkrs/helper/FirePointPushManager.java @@ -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 sysUserList = sysUserDao.findAll(); -// List smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList); -//// //推送 -//// try { -//// List 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 sysUserList = sysUserDao.findAll(); + List smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList); +// //推送 +// try { +// List 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()); + } } /** diff --git a/src/main/java/com/xkrs/model/entity/SysUserEntity.java b/src/main/java/com/xkrs/model/entity/SysUserEntity.java index 8b88fd0..468f2a3 100644 --- a/src/main/java/com/xkrs/model/entity/SysUserEntity.java +++ b/src/main/java/com/xkrs/model/entity/SysUserEntity.java @@ -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 + '\'' + '}'; } -} \ No newline at end of file +} diff --git a/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java index 3f76b11..8592f4d 100644 --- a/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/DispatchFirePointServiceImpl.java @@ -121,7 +121,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { } else { messageOrdinary = "普通火点添加成功"; firePointOrdinaryDao.save(firePointOrdinaryEntity); - firePointPushManager.pushNotification(firePointOrdinaryEntity); +// firePointPushManager.pushNotification(firePointOrdinaryEntity); } } List firePointChannelConfigEntityList = channelConfigDao.findAll(); diff --git a/src/main/java/com/xkrs/utilsnew/FirePointCodeUtils.java b/src/main/java/com/xkrs/utilsnew/FirePointCodeUtils.java index ef0e5ab..fc7236c 100644 --- a/src/main/java/com/xkrs/utilsnew/FirePointCodeUtils.java +++ b/src/main/java/com/xkrs/utilsnew/FirePointCodeUtils.java @@ -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; } }