将火点消息通知用户
This commit is contained in:
parent
37607bcbc1
commit
c74f9ee503
@ -35,12 +35,14 @@ public class FirePointPushManager {
|
||||
private PushHelper pushHelper;
|
||||
|
||||
public void pushNotification(FirePointOrdinaryEntity firePoint) {
|
||||
|
||||
//发送微信群聊消息
|
||||
sendWeChatGroupMessage(firePoint);
|
||||
|
||||
//过滤短信通知收件人
|
||||
List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
||||
List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList);
|
||||
try {
|
||||
//过滤短信通知收件人
|
||||
List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
||||
List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList);
|
||||
// //推送
|
||||
// try {
|
||||
// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);
|
||||
@ -48,84 +50,94 @@ public class FirePointPushManager {
|
||||
// } 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) {
|
||||
Long oldReceiveSmsCount = smsReceiver.getReceiveSmsCount();
|
||||
if (oldReceiveSmsCount == null || oldReceiveSmsCount <= 0L) {
|
||||
smsReceiver.setReceiveSmsCount(1L);
|
||||
} else {
|
||||
smsReceiver.setReceiveSmsCount(oldReceiveSmsCount + 1L);
|
||||
}
|
||||
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();
|
||||
}
|
||||
sysUserDao.saveAll(smsReceiverList);
|
||||
sendResult = "短信通知发送成功!";
|
||||
} else {
|
||||
sendResult = "短信通知发送失败!";
|
||||
int resValue = SMSUtils.sendSmsToUser(telephoneArray, "1425995", new String[]{firePoint.getFirePointAddress()});
|
||||
String sendResult;
|
||||
if (resValue == 0) {
|
||||
//联系人列表发送短信成功,在数据库中的已发短信数量字段加一
|
||||
for (SysUserEntity smsReceiver : smsReceiverList) {
|
||||
Long oldReceiveSmsCount = smsReceiver.getReceiveSmsCount();
|
||||
if (oldReceiveSmsCount == null || oldReceiveSmsCount <= 0L) {
|
||||
smsReceiver.setReceiveSmsCount(1L);
|
||||
} else {
|
||||
smsReceiver.setReceiveSmsCount(oldReceiveSmsCount + 1L);
|
||||
}
|
||||
}
|
||||
sysUserDao.saveAll(smsReceiverList);
|
||||
sendResult = "短信通知发送成功!";
|
||||
} else {
|
||||
sendResult = "短信通知发送失败!";
|
||||
}
|
||||
//记录短信通知日志
|
||||
String nowTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("开始统计发送短信").append(nowTime).append("\n");
|
||||
builder.append("发送人:青岛星科瑞升信息科技有限公司").append("\n");
|
||||
builder.append("火点详情:").append(firePoint.toString()).append("\n");
|
||||
for (SysUserEntity smsReceiver : smsReceiverList) {
|
||||
builder.append("接收人姓名:").append(smsReceiver.getReallyName()).append(",手机号:").append(smsReceiver.getUserName()).append(",区划编码:").append(smsReceiver.getCountyCode()).append(",区划名称:").append(smsReceiver.getCountyName()).append("\n");
|
||||
}
|
||||
builder.append(sendResult).append("\n");
|
||||
builder.append("结束统计发送短信").append(nowTime).append("\n");
|
||||
log.info(builder.toString());
|
||||
}
|
||||
//记录短信通知日志
|
||||
String nowTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("开始统计发送短信").append(nowTime).append("\n");
|
||||
builder.append("发送人:青岛星科瑞升信息科技有限公司").append("\n");
|
||||
builder.append("火点详情:").append(firePoint.toString()).append("\n");
|
||||
for (SysUserEntity smsReceiver : smsReceiverList) {
|
||||
builder.append("接收人姓名:").append(smsReceiver.getReallyName()).append(",手机号:").append(smsReceiver.getUserName()).append(",区划编码:").append(smsReceiver.getCountyCode()).append(",区划名称:").append(smsReceiver.getCountyName()).append("\n");
|
||||
}
|
||||
builder.append(sendResult).append("\n");
|
||||
builder.append("结束统计发送短信").append(nowTime).append("\n");
|
||||
log.info(builder.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送微信消息
|
||||
*/
|
||||
private void sendWeChatGroupMessage(FirePointOrdinaryEntity firePoint) {
|
||||
List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll();
|
||||
if (countyCodeWeiXinList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<String> weixinIdList = new ArrayList<>();
|
||||
for (CountyCodeWeiXinEntity countyCodeWeiXin : countyCodeWeiXinList) {
|
||||
try {
|
||||
if ((countyCodeWeiXin.getSendState() != null) && (countyCodeWeiXin.getSendState() != 0)) {
|
||||
String formatCutCode = FirePointCodeUtils.getFormatCutCode(countyCodeWeiXin.getCountyCode());
|
||||
if (firePoint.getTownCode().startsWith(formatCutCode)) {
|
||||
weixinIdList.add(countyCodeWeiXin.getWeixinId());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll();
|
||||
if (countyCodeWeiXinList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (weixinIdList.size() > 0) {
|
||||
StringBuilder stringBuilder = new StringBuilder("发送微信消息通知:\n");
|
||||
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000");
|
||||
String satelliteTime = firePoint.getSatelliteTime();
|
||||
String formatLongitude = decimalFormat.format(firePoint.getLongitude());
|
||||
String formatLatitude = decimalFormat.format(firePoint.getLatitude());
|
||||
String countyName = firePoint.getCountyName();
|
||||
String streetName = firePoint.getTownName();
|
||||
String landType = firePoint.getLandType();
|
||||
String messageContent = "星巡-秸秆焚烧卫星监测系统\n" + firePoint.getSatelliteType() + "发现1个火点。\n卫星时间:" + satelliteTime + ";\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName + ";\nstreetName:" + streetName + ";\nlandType:" + landType;
|
||||
for (String weixinId : weixinIdList) {
|
||||
stringBuilder.append(weixinId).append("\n");
|
||||
List<String> weixinIdList = new ArrayList<>();
|
||||
for (CountyCodeWeiXinEntity countyCodeWeiXin : countyCodeWeiXinList) {
|
||||
try {
|
||||
WeiXinMessageUtils.sendMsg(weixinId, messageContent, 0);
|
||||
if ((countyCodeWeiXin.getSendState() != null) && (countyCodeWeiXin.getSendState() != 0)) {
|
||||
String formatCutCode = FirePointCodeUtils.getFormatCutCode(countyCodeWeiXin.getCountyCode());
|
||||
if (firePoint.getTownCode().startsWith(formatCutCode)) {
|
||||
weixinIdList.add(countyCodeWeiXin.getWeixinId());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
stringBuilder.append("火情信息:").append(messageContent);
|
||||
log.info(stringBuilder.toString());
|
||||
if (weixinIdList.size() > 0) {
|
||||
StringBuilder stringBuilder = new StringBuilder("发送微信消息通知:\n");
|
||||
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000");
|
||||
String satelliteTime = firePoint.getSatelliteTime();
|
||||
String formatLongitude = decimalFormat.format(firePoint.getLongitude());
|
||||
String formatLatitude = decimalFormat.format(firePoint.getLatitude());
|
||||
String countyName = firePoint.getCountyName();
|
||||
String streetName = firePoint.getTownName();
|
||||
String landType = firePoint.getLandType();
|
||||
String messageContent = "星巡-秸秆焚烧卫星监测系统\n" + firePoint.getSatelliteType() + "发现1个火点。\n卫星时间:" + satelliteTime + ";\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName + ";\nstreetName:" + streetName + ";\nlandType:" + landType;
|
||||
for (String weixinId : weixinIdList) {
|
||||
stringBuilder.append(weixinId).append("\n");
|
||||
try {
|
||||
WeiXinMessageUtils.sendMsg(weixinId, messageContent, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
stringBuilder.append("火情信息:").append(messageContent);
|
||||
log.info(stringBuilder.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
||||
firePointOrdinaryEntity.setTownName(addressBean.getTownName());
|
||||
firePointOrdinaryEntity.setFirePointAddress(addressBean.getFirePointAddress());
|
||||
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
||||
firePointPushManager.pushNotification(firePointOrdinaryEntity);//将火点消息通知用户
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
|
||||
}
|
||||
ErrorInfoLogUtils.log("高德逆地理编码异常,出现问题的火点详情:" + firePointOrdinaryEntity.toString());
|
||||
@ -134,6 +135,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
||||
firePointOrdinaryEntity.setCountyName(countyName);
|
||||
firePointOrdinaryEntity.setTownCode(townCode);
|
||||
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
||||
firePointPushManager.pushNotification(firePointOrdinaryEntity);//将火点消息通知用户
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
|
||||
}
|
||||
|
||||
@ -181,7 +183,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
||||
FirePointOrdinaryEntity firePoint = firePointList.get(0);
|
||||
firePoint.setFireStatus(status);//设置火点的研判标志属性
|
||||
firePointOrdinaryDao.save(firePoint);//数据库保存
|
||||
firePointPushManager.pushNotification(firePoint);//将火点消息通知用户
|
||||
} else {
|
||||
ErrorInfoLogUtils.log("操作异常,审核系统发送的fireCode在秸秆系统中size() != 1:fireCode = " + fireCode + ",status = " + fireCode);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user