将火点消息通知用户
This commit is contained in:
parent
37607bcbc1
commit
c74f9ee503
@ -35,12 +35,14 @@ public class FirePointPushManager {
|
|||||||
private PushHelper pushHelper;
|
private PushHelper pushHelper;
|
||||||
|
|
||||||
public void pushNotification(FirePointOrdinaryEntity firePoint) {
|
public void pushNotification(FirePointOrdinaryEntity firePoint) {
|
||||||
|
|
||||||
//发送微信群聊消息
|
//发送微信群聊消息
|
||||||
sendWeChatGroupMessage(firePoint);
|
sendWeChatGroupMessage(firePoint);
|
||||||
|
|
||||||
//过滤短信通知收件人
|
try {
|
||||||
List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
//过滤短信通知收件人
|
||||||
List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList);
|
List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
||||||
|
List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList);
|
||||||
// //推送
|
// //推送
|
||||||
// try {
|
// try {
|
||||||
// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);
|
// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);
|
||||||
@ -48,84 +50,94 @@ public class FirePointPushManager {
|
|||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
if (smsReceiverList.size() > 0) {
|
if (smsReceiverList.size() > 0) {
|
||||||
String[] telephoneArray = new String[smsReceiverList.size()];
|
String[] telephoneArray = new String[smsReceiverList.size()];
|
||||||
for (int i = 0; i < smsReceiverList.size(); i++) {
|
for (int i = 0; i < smsReceiverList.size(); i++) {
|
||||||
telephoneArray[i] = "86" + smsReceiverList.get(i).getUserName();
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sysUserDao.saveAll(smsReceiverList);
|
int resValue = SMSUtils.sendSmsToUser(telephoneArray, "1425995", new String[]{firePoint.getFirePointAddress()});
|
||||||
sendResult = "短信通知发送成功!";
|
String sendResult;
|
||||||
} else {
|
if (resValue == 0) {
|
||||||
sendResult = "短信通知发送失败!";
|
//联系人列表发送短信成功,在数据库中的已发短信数量字段加一
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
//记录短信通知日志
|
} catch (Exception e) {
|
||||||
String nowTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());
|
e.printStackTrace();
|
||||||
StringBuilder builder = new StringBuilder();
|
log.info(e.getMessage());
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送微信消息
|
* 发送微信消息
|
||||||
*/
|
*/
|
||||||
private void sendWeChatGroupMessage(FirePointOrdinaryEntity firePoint) {
|
private void sendWeChatGroupMessage(FirePointOrdinaryEntity firePoint) {
|
||||||
List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll();
|
try {
|
||||||
if (countyCodeWeiXinList.isEmpty()) {
|
List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll();
|
||||||
return;
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
List<String> weixinIdList = new ArrayList<>();
|
||||||
if (weixinIdList.size() > 0) {
|
for (CountyCodeWeiXinEntity countyCodeWeiXin : countyCodeWeiXinList) {
|
||||||
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 {
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stringBuilder.append("火情信息:").append(messageContent);
|
if (weixinIdList.size() > 0) {
|
||||||
log.info(stringBuilder.toString());
|
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.setTownName(addressBean.getTownName());
|
||||||
firePointOrdinaryEntity.setFirePointAddress(addressBean.getFirePointAddress());
|
firePointOrdinaryEntity.setFirePointAddress(addressBean.getFirePointAddress());
|
||||||
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
||||||
|
firePointPushManager.pushNotification(firePointOrdinaryEntity);//将火点消息通知用户
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
|
||||||
}
|
}
|
||||||
ErrorInfoLogUtils.log("高德逆地理编码异常,出现问题的火点详情:" + firePointOrdinaryEntity.toString());
|
ErrorInfoLogUtils.log("高德逆地理编码异常,出现问题的火点详情:" + firePointOrdinaryEntity.toString());
|
||||||
@ -134,6 +135,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
|||||||
firePointOrdinaryEntity.setCountyName(countyName);
|
firePointOrdinaryEntity.setCountyName(countyName);
|
||||||
firePointOrdinaryEntity.setTownCode(townCode);
|
firePointOrdinaryEntity.setTownCode(townCode);
|
||||||
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
||||||
|
firePointPushManager.pushNotification(firePointOrdinaryEntity);//将火点消息通知用户
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +183,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
|||||||
FirePointOrdinaryEntity firePoint = firePointList.get(0);
|
FirePointOrdinaryEntity firePoint = firePointList.get(0);
|
||||||
firePoint.setFireStatus(status);//设置火点的研判标志属性
|
firePoint.setFireStatus(status);//设置火点的研判标志属性
|
||||||
firePointOrdinaryDao.save(firePoint);//数据库保存
|
firePointOrdinaryDao.save(firePoint);//数据库保存
|
||||||
firePointPushManager.pushNotification(firePoint);//将火点消息通知用户
|
|
||||||
} else {
|
} else {
|
||||||
ErrorInfoLogUtils.log("操作异常,审核系统发送的fireCode在秸秆系统中size() != 1:fireCode = " + fireCode + ",status = " + fireCode);
|
ErrorInfoLogUtils.log("操作异常,审核系统发送的fireCode在秸秆系统中size() != 1:fireCode = " + fireCode + ",status = " + fireCode);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user