修改APP换水提醒逻辑
This commit is contained in:
parent
564e5b03cb
commit
7b197f8cd0
|
|
@ -21,5 +21,11 @@ public interface DeviceUserDao extends BaseDao<DeviceUser, DeviceUserId>{
|
|||
* @return
|
||||
*/
|
||||
public int getDeviceNumById(Integer userId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据deviceId查询设备和用户对应数据
|
||||
* @param deviceId
|
||||
* @return
|
||||
*/
|
||||
List<DeviceUser> getUserIdByDeviceId(Integer deviceId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ifish.dao;
|
||||
|
||||
import com.ifish.entity.PushRemind;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 16:44 2018/1/28
|
||||
* @Modified by:
|
||||
*/
|
||||
public interface PushRemindDao extends BaseDao<PushRemind,Integer> {
|
||||
|
||||
List<PushRemind> getPushRemindByDeviceId(Integer deviceId);
|
||||
}
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
package com.ifish.daoImpl;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ifish.dao.DeviceUserDao;
|
||||
|
|
@ -43,5 +47,16 @@ public class DeviceUserDaoImpl extends HibernateBaseDao<DeviceUser, DeviceUserId
|
|||
int deviceNum = ((BigInteger)this.getSession().createSQLQuery(sql).setInteger(0, userId).uniqueResult()).intValue();
|
||||
return deviceNum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备ID查询设备用户对应关系表
|
||||
* @param deviceId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceUser> getUserIdByDeviceId(Integer deviceId) {
|
||||
Criterion criterion = Restrictions.eq("priId.deviceId",deviceId);
|
||||
List<DeviceUser> deviceUsers = this.findByProperty(criterion);
|
||||
return deviceUsers;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.ifish.daoImpl;
|
||||
|
||||
import com.ifish.dao.PushRemindDao;
|
||||
import com.ifish.entity.PushRemind;
|
||||
import com.ifish.hibernate.HibernateBaseDao;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description:
|
||||
* @Date: Created in 17:11 2018/1/28
|
||||
* @Modified by:
|
||||
*/
|
||||
@Repository
|
||||
public class PushRemindDaoImpl extends HibernateBaseDao<PushRemind ,Integer> implements PushRemindDao {
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备 查询出推送信息表
|
||||
* @param deviceId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PushRemind> getPushRemindByDeviceId(Integer deviceId) {
|
||||
Criterion criterion = Restrictions.eq("id.deviceId",deviceId);
|
||||
List<PushRemind> pushReminds = this.findByProperty(criterion);
|
||||
return pushReminds;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<PushRemind> getEntityClass() {
|
||||
return PushRemind.class;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
package com.ifish.dto;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description: tbl_tmp_push_remind DTO
|
||||
* @Date: Created in 16:45 2018/1/28
|
||||
* @Modified by:
|
||||
*/
|
||||
public class PushRemindDto {
|
||||
|
||||
private Integer deviceId;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private String phoneNumber;
|
||||
|
||||
private String macAddress;
|
||||
|
||||
private String showName;
|
||||
|
||||
private String loginType;
|
||||
|
||||
private Date remindDate;
|
||||
|
||||
private Integer remindCycle;
|
||||
|
||||
private String isPush;
|
||||
|
||||
public Integer getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(Integer deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public String getMacAddress() {
|
||||
return macAddress;
|
||||
}
|
||||
|
||||
public void setMacAddress(String macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
|
||||
public String getLoginType() {
|
||||
return loginType;
|
||||
}
|
||||
|
||||
public void setLoginType(String loginType) {
|
||||
this.loginType = loginType;
|
||||
}
|
||||
|
||||
public Date getRemindDate() {
|
||||
return remindDate;
|
||||
}
|
||||
|
||||
public void setRemindDate(Date remindDate) {
|
||||
this.remindDate = remindDate;
|
||||
}
|
||||
|
||||
public Integer getRemindCycle() {
|
||||
return remindCycle;
|
||||
}
|
||||
|
||||
public void setRemindCycle(Integer remindCycle) {
|
||||
this.remindCycle = remindCycle;
|
||||
}
|
||||
|
||||
public String getIsPush() {
|
||||
return isPush;
|
||||
}
|
||||
|
||||
public void setIsPush(String isPush) {
|
||||
this.isPush = isPush;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package com.ifish.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description: tbl_tmp_push_remind
|
||||
* @Date: Created in 16:45 2018/1/28
|
||||
* @Modified by:
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "tbl_tmp_push_remind")
|
||||
public class PushRemind implements Serializable{
|
||||
|
||||
@Id
|
||||
private PushRemindId id;
|
||||
|
||||
@Column(name = "phone_number")
|
||||
private String phoneNumber;
|
||||
|
||||
@Column(name = "mac_address")
|
||||
private String macAddress;
|
||||
|
||||
@Column(name = "show_name")
|
||||
private String showName;
|
||||
|
||||
@Column(name = "login_type")
|
||||
private String loginType;
|
||||
|
||||
@Column(name = "remind_date")
|
||||
private Date remindDate;
|
||||
|
||||
@Column(name = "remind_cycle")
|
||||
private Integer remindCycle;
|
||||
|
||||
@Column(name = "is_push")
|
||||
private String isPush;
|
||||
|
||||
public PushRemindId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(PushRemindId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public String getMacAddress() {
|
||||
return macAddress;
|
||||
}
|
||||
|
||||
public void setMacAddress(String macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
|
||||
public String getLoginType() {
|
||||
return loginType;
|
||||
}
|
||||
|
||||
public void setLoginType(String loginType) {
|
||||
this.loginType = loginType;
|
||||
}
|
||||
|
||||
public Date getRemindDate() {
|
||||
return remindDate;
|
||||
}
|
||||
|
||||
public void setRemindDate(Date remindDate) {
|
||||
this.remindDate = remindDate;
|
||||
}
|
||||
|
||||
public Integer getRemindCycle() {
|
||||
return remindCycle;
|
||||
}
|
||||
|
||||
public void setRemindCycle(Integer remindCycle) {
|
||||
this.remindCycle = remindCycle;
|
||||
}
|
||||
|
||||
public String getIsPush() {
|
||||
return isPush;
|
||||
}
|
||||
|
||||
public void setIsPush(String isPush) {
|
||||
this.isPush = isPush;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.ifish.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: yan.y
|
||||
* @Description: tbl_tmp_push_remind 联合主键ID
|
||||
* @Date: Created in 16:45 2018/1/28
|
||||
* @Modified by:
|
||||
*/
|
||||
@Embeddable
|
||||
public class PushRemindId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private Integer userId;
|
||||
|
||||
@Column(name = "device_id")
|
||||
private Integer deviceId;
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public Integer getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
public void setDeviceId(Integer deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof PushRemindId){
|
||||
PushRemindId pk=(PushRemindId)obj;
|
||||
if(this.userId.equals(pk.userId)&&this.deviceId.equals(pk.deviceId)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.ifish.dao.*;
|
||||
import com.ifish.entity.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -16,37 +19,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ifish.dao.CameraActiveDao;
|
||||
import com.ifish.dao.CameraDao;
|
||||
import com.ifish.dao.CameraUserDao;
|
||||
import com.ifish.dao.DeviceCameraDao;
|
||||
import com.ifish.dao.DeviceDao;
|
||||
import com.ifish.dao.DeviceUserDao;
|
||||
import com.ifish.dao.HardwareTypeDao;
|
||||
import com.ifish.dao.LookReportDao;
|
||||
import com.ifish.dao.PushListDao;
|
||||
import com.ifish.dao.QuestionsFeedbackDao;
|
||||
import com.ifish.dao.ShopsInfoDao;
|
||||
import com.ifish.dao.UserDao;
|
||||
import com.ifish.dao.VenderListDao;
|
||||
import com.ifish.dao.VersionDao;
|
||||
import com.ifish.entity.Camera;
|
||||
import com.ifish.entity.CameraActive;
|
||||
import com.ifish.entity.CameraUser;
|
||||
import com.ifish.entity.CameraUserId;
|
||||
import com.ifish.entity.Device;
|
||||
import com.ifish.entity.DeviceCamera;
|
||||
import com.ifish.entity.DeviceCameraId;
|
||||
import com.ifish.entity.DeviceUser;
|
||||
import com.ifish.entity.HardwareType;
|
||||
import com.ifish.entity.LookReport;
|
||||
import com.ifish.entity.DeviceUserId;
|
||||
import com.ifish.entity.PushList;
|
||||
import com.ifish.entity.QuestionsFeedback;
|
||||
import com.ifish.entity.ShopsInfo;
|
||||
import com.ifish.entity.User;
|
||||
import com.ifish.entity.VenderList;
|
||||
import com.ifish.entity.Version;
|
||||
import com.ifish.enums.BooleanEnum;
|
||||
import com.ifish.enums.GwellEnum;
|
||||
import com.ifish.enums.Index1Enum;
|
||||
|
|
@ -111,6 +83,8 @@ public class BaseServiceImpl implements BaseService {
|
|||
private HardwareTypeDao hardwareTypeDao;
|
||||
@Autowired
|
||||
private QuestionsFeedbackDao questionsFeedbackDao;
|
||||
@Autowired
|
||||
private PushRemindDao pushRemindDao;
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
|
|
@ -704,8 +678,6 @@ public class BaseServiceImpl implements BaseService {
|
|||
/**
|
||||
* 封装摄像头返回信息
|
||||
*
|
||||
* @param device
|
||||
* @param deviceUser
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getCameraInfo(Camera camera, CameraUser cameraUser) {
|
||||
|
|
@ -1011,7 +983,6 @@ public class BaseServiceImpl implements BaseService {
|
|||
/**
|
||||
* 极光推送
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
public boolean jPushNotifcation(Map<String, String> baseMap, Map<String, String> pushMap) {
|
||||
try {
|
||||
|
|
@ -1096,6 +1067,8 @@ public class BaseServiceImpl implements BaseService {
|
|||
|
||||
@Override
|
||||
public Object setRemindWaterInf(Device device) {
|
||||
Logger log = Logger.getLogger(BaseServiceImpl.class);
|
||||
log.info("setRemindWaterInf begin");
|
||||
Device tmpDevice = this.deviceDao.get(device.getDeviceId());
|
||||
if (tmpDevice != null) {
|
||||
//设置换水提醒
|
||||
|
|
@ -1108,6 +1081,69 @@ public class BaseServiceImpl implements BaseService {
|
|||
calendar.add(Calendar.DATE, device.getRemindCycle());
|
||||
tmpDevice.setRemindDate(calendar.getTime());
|
||||
this.deviceDao.update(tmpDevice);
|
||||
//-----------------------------modify by yan.y begin------------------------------------
|
||||
//换水提醒打开状态
|
||||
if ("1".equals(device.getWaterRemind())) {
|
||||
//对于已存在的数据做修改的操作
|
||||
Map<Integer,PushRemind> pushRemindMap = new HashMap<Integer, PushRemind>();
|
||||
//新增逻辑对tbl_tmp_push_remind表操作
|
||||
List<PushRemind> pushReminds = pushRemindDao.getPushRemindByDeviceId(device.getDeviceId());
|
||||
for (PushRemind pushRemind : pushReminds) {
|
||||
pushRemindMap.put(pushRemind.getId().getUserId(),pushRemind);
|
||||
}
|
||||
//查询出所有的设备和用户对应表
|
||||
List<DeviceUser> users = deviceUserDao.getUserIdByDeviceId(device.getDeviceId());
|
||||
//修改或创建
|
||||
if (pushReminds.size() != 0 && users.size() == pushReminds.size()) {
|
||||
for (PushRemind pushRemind : pushReminds) {
|
||||
pushRemind.setRemindCycle(tmpDevice.getRemindCycle());
|
||||
pushRemind.setRemindDate(tmpDevice.getRemindDate());
|
||||
pushRemind.setIsPush("0");
|
||||
this.pushRemindDao.update(pushRemind);
|
||||
}
|
||||
} else {
|
||||
|
||||
//添加设备所绑定的用户
|
||||
for (DeviceUser deviceUser : users) {
|
||||
//根据userID获取已存在的推送对象
|
||||
PushRemind pr = pushRemindMap.get(deviceUser.getPriId().getUserId());
|
||||
//如果对象存在 作修改操作
|
||||
if (pr != null) {
|
||||
pr.setRemindCycle(tmpDevice.getRemindCycle());
|
||||
pr.setRemindDate(tmpDevice.getRemindDate());
|
||||
this.pushRemindDao.update(pr);
|
||||
} else {
|
||||
//推送表ID
|
||||
PushRemindId id = new PushRemindId();
|
||||
//新增对象
|
||||
PushRemind pushRemind = new PushRemind();
|
||||
pushRemind.setRemindCycle(tmpDevice.getRemindCycle());
|
||||
pushRemind.setRemindDate(tmpDevice.getRemindDate());
|
||||
id.setDeviceId(tmpDevice.getDeviceId());
|
||||
pushRemind.setMacAddress(tmpDevice.getMacAddress());
|
||||
//新增操作
|
||||
//查询用户信息
|
||||
User user = this.userDao.get(deviceUser.getPriId().getUserId());
|
||||
id.setUserId(deviceUser.getPriId().getUserId());
|
||||
pushRemind.setId(id);
|
||||
pushRemind.setPhoneNumber(user.getPhoneNumber());
|
||||
pushRemind.setShowName(deviceUser.getShowName());
|
||||
pushRemind.setLoginType(user.getLoginType());
|
||||
pushRemind.setIsPush("0");
|
||||
this.pushRemindDao.save(pushRemind);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//换水提醒关闭状态
|
||||
//查询推送表中当前设备的所有数据
|
||||
List<PushRemind> pushReminds = this.pushRemindDao.getPushRemindByDeviceId(device.getDeviceId());
|
||||
for (PushRemind pushRemind : pushReminds) {
|
||||
this.pushRemindDao.delete(pushRemind);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------modify by yan.y end------------------------------------
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("todayRemind", tmpDevice.getTodayRemind());
|
||||
map.put("waterRemind", tmpDevice.getWaterRemind());
|
||||
|
|
|
|||
Loading…
Reference in New Issue