推送时长10改为30分钟

热流器水流量预警
This commit is contained in:
易焱 2019-09-24 23:37:06 +08:00
parent 0e9503ac8a
commit 63ce6f845d
3 changed files with 65 additions and 8 deletions

View File

@ -6,8 +6,9 @@ public enum PushTypeEnum {
qu_reply("qu_reply","问题反馈"), qu_reply("qu_reply","问题反馈"),
app_update("app_update","IOS更新推送"), app_update("app_update","IOS更新推送"),
remind_water("remind_water","换水提醒"), remind_water("remind_water","换水提醒"),
offline_push("offline_push","离线通知"); offline_push("offline_push","离线通知"),
ph_warn("ph_warn","水流量预警");
private PushTypeEnum(String key,String value){ private PushTypeEnum(String key,String value){
this.key = key; this.key = key;
this.value = value; this.value = value;

View File

@ -90,8 +90,8 @@ public class MinaServerHandler extends IoHandlerAdapter {
//离线时间 //离线时间
jobGroup.setTimestamp(IfishUtil.format(new Date())); jobGroup.setTimestamp(IfishUtil.format(new Date()));
//10分钟后推送 update 30分钟 //10分钟后推送 update 30分钟
// jobGroup.setStartTime(new Date(System.currentTimeMillis() + 600000L * 3)); jobGroup.setStartTime(new Date(System.currentTimeMillis() + 600000L * 3));
jobGroup.setStartTime(new Date(System.currentTimeMillis() + 60000L)); // jobGroup.setStartTime(new Date(System.currentTimeMillis() + 60000L));
scheduleJob.addJob(jobGroup); scheduleJob.addJob(jobGroup);
} }

View File

@ -30,9 +30,7 @@ import org.springframework.jms.core.JmsTemplate;
import javax.jms.Destination; import javax.jms.Destination;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.Session; import javax.jms.Session;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
@ -62,6 +60,7 @@ public class SomeServer {
public static final ConcurrentHashMap<String, String> remoteAddress = new ConcurrentHashMap<String, String>(); public static final ConcurrentHashMap<String, String> remoteAddress = new ConcurrentHashMap<String, String>();
public static final ConcurrentHashMap<String, IoSession> sessions_cz = new ConcurrentHashMap<String, IoSession>(); public static final ConcurrentHashMap<String, IoSession> sessions_cz = new ConcurrentHashMap<String, IoSession>();
private ConcurrentHashMap<String, CopyOnWriteArraySet<IoSession>> sessions_sjs = new ConcurrentHashMap<String, CopyOnWriteArraySet<IoSession>>(); private ConcurrentHashMap<String, CopyOnWriteArraySet<IoSession>> sessions_sjs = new ConcurrentHashMap<String, CopyOnWriteArraySet<IoSession>>();
private volatile Map<String,Integer> heaterPushStatus = new HashMap<>();
/** /**
* 过滤收到的数据 服务器收到数据进行协议类型匹配如果不匹配则不执行相应操作 * 过滤收到的数据 服务器收到数据进行协议类型匹配如果不匹配则不执行相应操作
@ -104,6 +103,17 @@ public class SomeServer {
} else { } else {
deviceService.save(heater); deviceService.save(heater);
} }
Integer status = heaterPushStatus.get(macAddress);
//当前水流量不正常 并且更新过正常水流标记 或者是第一次出现没有水流
if (heater.getPh() != 499 && ((status != null && status.intValue() == 2) || status == null)) {
//已推送标记
heaterPushStatus.put(macAddress, 1);
pushNotifcationByPh(macAddress,PushTypeEnum.ph_warn.getValue(),"没有水流, 请及时查看!");
} else {
if (heater.getPh() == 499) {
heaterPushStatus.put(macAddress, 2);
}
}
//设备重新连接上则移除延时推送的任务 //设备重新连接上则移除延时推送的任务
JobGroup jobGroup = new JobGroup(); JobGroup jobGroup = new JobGroup();
jobGroup.setJobName(macAddress); jobGroup.setJobName(macAddress);
@ -318,12 +328,58 @@ public class SomeServer {
session.write(model); session.write(model);
} }
} }
/** /**
* 温度预警推送 * 智能加热棒 水流量提醒
* @param strSrc * @param strSrc
* @param title * @param title
* @param contont * @param contont
*/ */
public void pushNotifcationByPh(String strSrc,String title,String contont) {
Device device = deviceService.getUniqueByProperty("macAddress", strSrc);
try {
if(device!=null) {
Integer deviceId = device.getDeviceId();
//绑定设备的用户
List<DeviceUser> list = deviceService.getListByProperty(device.getDeviceId());
for (DeviceUser deviceUser : list) {
Integer userId = deviceUser.getPriId().getUserId();
String showName = deviceUser.getShowName();
String msg = "" + title + "】你的水族箱“" + showName + "" + contont;
User user = userService.findById(userId);
if(user!=null){
//推送记录
PushList pushList = new PushList();
//记录推送
pushList.setUserId(userId);
pushList.setDeviceId(deviceId);
pushList.setPhoneType("ALL");
pushList.setShowName(showName);
pushList.setPushType(PushTypeEnum.ph_warn.getKey());
pushList.setPushTitle(title);
pushList.setPushContext(msg);
pushList.setNumber1(device.getNumber1());
pushList.setNumber2(device.getNumber2());
pushList.setNumber3(device.getNumber3());
pushList.setNumber4(device.getNumber4());
pushList.setNumber5(device.getNumber5());
JSONObject data = JSON.parseObject(JSON.toJSONString(pushList));
QueueEventEntity eventEntity = new QueueEventEntity();
eventEntity.setEventName("com.ifish7.mq.queues.event.PushNotifcationEvent");
eventEntity.setEventProcess("deviceNotifcationPlus");
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.user.entity.TblPushList",data);
eventEntity.setEventBody(eventBody);
//推送至消息推送队列
sendPushQueueMessage(JSONObject.toJSONString(eventEntity));
}
}
}
}catch (Exception e) {
log.error(e.getLocalizedMessage(), e);
}
}
/** /**
* 温度预警推送 * 温度预警推送
* @param strSrc * @param strSrc