parent
0e9503ac8a
commit
63ce6f845d
|
|
@ -6,7 +6,8 @@ public enum PushTypeEnum {
|
|||
qu_reply("qu_reply","问题反馈"),
|
||||
app_update("app_update","IOS更新推送"),
|
||||
remind_water("remind_water","换水提醒"),
|
||||
offline_push("offline_push","离线通知");
|
||||
offline_push("offline_push","离线通知"),
|
||||
ph_warn("ph_warn","水流量预警");
|
||||
|
||||
private PushTypeEnum(String key,String value){
|
||||
this.key = key;
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ public class MinaServerHandler extends IoHandlerAdapter {
|
|||
//离线时间
|
||||
jobGroup.setTimestamp(IfishUtil.format(new Date()));
|
||||
//10分钟后推送 update 30分钟
|
||||
// jobGroup.setStartTime(new Date(System.currentTimeMillis() + 600000L * 3));
|
||||
jobGroup.setStartTime(new Date(System.currentTimeMillis() + 60000L));
|
||||
jobGroup.setStartTime(new Date(System.currentTimeMillis() + 600000L * 3));
|
||||
// jobGroup.setStartTime(new Date(System.currentTimeMillis() + 60000L));
|
||||
scheduleJob.addJob(jobGroup);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ import org.springframework.jms.core.JmsTemplate;
|
|||
import javax.jms.Destination;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Session;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
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, IoSession> sessions_cz = new ConcurrentHashMap<String, 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 {
|
||||
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.setJobName(macAddress);
|
||||
|
|
@ -318,12 +328,58 @@ public class SomeServer {
|
|||
session.write(model);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 温度预警推送
|
||||
* 智能加热棒 水流量提醒
|
||||
* @param strSrc
|
||||
* @param title
|
||||
* @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
|
||||
|
|
|
|||
Loading…
Reference in New Issue