宠物笼设备高温低温预警推送
This commit is contained in:
parent
b44ca6e533
commit
28e634b761
|
|
@ -0,0 +1,18 @@
|
|||
package com.ifish.dao;
|
||||
|
||||
import com.ifish.entity.DevicePetUser;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceUserDao
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
public interface DevicePetUserDao{
|
||||
|
||||
List<DevicePetUser> getListByProperty(Criterion... criterions);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.ifish.daoImpl;
|
||||
|
||||
import com.ifish.dao.DevicePetUserDao;
|
||||
import com.ifish.entity.DevicePetUser;
|
||||
import com.ifish.entity.DeviceUser;
|
||||
import com.ifish.entity.PriId;
|
||||
import com.ifish.hibernate.HibernateBaseDao;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: DeviceUserDaoImpl
|
||||
* @Description: TODO
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("devicePetUserDao")
|
||||
public class DevicePetUserDaoImpl extends HibernateBaseDao<DevicePetUser, PriId> implements DevicePetUserDao {
|
||||
|
||||
@Override
|
||||
protected Class<DevicePetUser> getEntityClass() {
|
||||
return DevicePetUser.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevicePetUser> getListByProperty(Criterion... criterions) {
|
||||
return this.findByProperty(criterions);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package com.ifish.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName: tbl_device_user
|
||||
* @date 2015年7月2日 下午16:40:00
|
||||
*
|
||||
*/
|
||||
public class DevicePetUser implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -6056043883433438749L;
|
||||
//ID
|
||||
private PriId priId = new PriId();
|
||||
//显示名称
|
||||
private String showName;
|
||||
private String storeName;
|
||||
private Integer isMaster;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
|
||||
//用户
|
||||
private User user = new User();
|
||||
//设备
|
||||
private Device device = new Device();
|
||||
public DevicePetUser() {}
|
||||
|
||||
public DevicePetUser(PriId priId, String showName, String storeName) {
|
||||
this.priId = priId;
|
||||
this.showName = showName;
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public PriId getPriId() {
|
||||
return priId;
|
||||
}
|
||||
public void setPriId(PriId priId) {
|
||||
this.priId = priId;
|
||||
}
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public Integer getIsMaster() {
|
||||
return isMaster;
|
||||
}
|
||||
|
||||
public void setIsMaster(Integer isMaster) {
|
||||
this.isMaster = isMaster;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Device getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
public void setDevice(Device device) {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping package="com.ifish.entity">
|
||||
<class name="DevicePetUser" table="tbl_pet_list" dynamic-insert="true" dynamic-update="true">
|
||||
<meta attribute="sync-DAO">false</meta>
|
||||
<composite-id name="priId" class="com.ifish.entity.PriId">
|
||||
<key-property name="userId" column="user_id" type="java.lang.Integer" />
|
||||
<key-property name="deviceId" column="device_id" type="java.lang.Integer" />
|
||||
</composite-id>
|
||||
<property name="showName" column="device_name" type="string" length="255" />
|
||||
<property name="storeName" column="store_name" type="string" length="255" />
|
||||
<property name="isMaster" column="is_master" type="java.lang.Integer" length="10" />
|
||||
<property name="createTime" column="create_time" type="java.util.Date" />
|
||||
<many-to-one name="user" column="user_id" class="com.ifish.entity.User" update="false" insert="false" lazy="false"/>
|
||||
<many-to-one name="device" column="device_id" class="com.ifish.entity.Device" update="false" insert="false" lazy="false"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
|
@ -33,6 +33,8 @@ public interface DeviceService {
|
|||
|
||||
List<DeviceUser> getListByProperty(Integer deviceId);
|
||||
|
||||
List<DevicePetUser> getPetListByProperty(Integer deviceId);
|
||||
|
||||
LoginRecord save(LoginRecord loginRecord);
|
||||
|
||||
FactoryList getFactoryListById(String factoryCode);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
@Autowired
|
||||
private DeviceUserDao deviceUserDao;
|
||||
@Autowired
|
||||
private DevicePetUserDao devicePetUserDao;
|
||||
@Autowired
|
||||
private FactoryListDao factoryListDao;
|
||||
@Autowired
|
||||
private HardwareTypeDao hardwareTypeDao;
|
||||
|
|
@ -145,6 +147,11 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
return deviceUserDao.getListByProperty(Restrictions.eq("priId.deviceId", deviceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevicePetUser> getPetListByProperty(Integer deviceId) {
|
||||
return devicePetUserDao.getListByProperty(Restrictions.eq("priId.deviceId", deviceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWarnOnoff(String macAddress,String onOff) {
|
||||
Device device = this.deviceDao.getUniqueByProperty("macAddress", macAddress);
|
||||
|
|
|
|||
|
|
@ -364,32 +364,7 @@ public class SomeServer {
|
|||
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));
|
||||
}
|
||||
setPushMsg(title, device, deviceId, userId, showName, msg, PushTypeEnum.ph_warn);
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
|
|
@ -412,38 +387,25 @@ public class SomeServer {
|
|||
//是否开启预警
|
||||
String onOff = device.getOnOff();
|
||||
if(onOff!=null && onOff.equals(BooleanEnum.YES.getKey())){
|
||||
//绑定设备的用户
|
||||
List<DeviceUser> list = deviceService.getListByProperty(device.getDeviceId());
|
||||
for (DeviceUser deviceUser : list) {
|
||||
Integer userId = deviceUser.getPriId().getUserId();
|
||||
String showName = deviceUser.getShowName();
|
||||
String timestamp = IfishUtil.format(new Date());
|
||||
String msg = "【"+title+"】你的水族箱“"+showName+"”在"+timestamp+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.wendu_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));
|
||||
//宠物笼设备
|
||||
if (device.getHardwareType().equals("3f")) {
|
||||
List<DevicePetUser> petUserList = deviceService.getPetListByProperty(deviceId);
|
||||
for (DevicePetUser deviceUser : petUserList) {
|
||||
Integer userId = deviceUser.getPriId().getUserId();
|
||||
String showName = deviceUser.getShowName();
|
||||
String timestamp = IfishUtil.format(new Date());
|
||||
String msg = "【"+title+"】你的宠物笼“"+showName+"”在"+timestamp+contont;
|
||||
setPushMsg(title, device, deviceId, userId, showName, msg, PushTypeEnum.wendu_warn);
|
||||
}
|
||||
} else {
|
||||
//绑定设备的用户
|
||||
List<DeviceUser> list = deviceService.getListByProperty(device.getDeviceId());
|
||||
for (DeviceUser deviceUser : list) {
|
||||
Integer userId = deviceUser.getPriId().getUserId();
|
||||
String showName = deviceUser.getShowName();
|
||||
String timestamp = IfishUtil.format(new Date());
|
||||
String msg = "【"+title+"】你的水族箱“"+showName+"”在"+timestamp+contont;
|
||||
setPushMsg(title, device, deviceId, userId, showName, msg, PushTypeEnum.wendu_warn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -453,6 +415,35 @@ public class SomeServer {
|
|||
}
|
||||
}
|
||||
|
||||
private void setPushMsg(String title, Device device, Integer deviceId, Integer userId, String showName, String msg, PushTypeEnum wendu_warn) throws JMSException {
|
||||
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(wendu_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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送Push消息队列
|
||||
|
|
|
|||
Loading…
Reference in New Issue