加热器设备接口

This commit is contained in:
yiyan 2018-10-24 17:59:02 +08:00
parent 0442f77b63
commit 97082ce3f8
7 changed files with 86 additions and 17 deletions

View File

@ -184,6 +184,19 @@ public class UserAction {
* 获取智能加热棒信息
* @return
*/
@RequestMapping("/getDeviceHeaterPhsByDate.do")
public Object getDeviceHeaterPhsByDate(String heaterMacAddress,String date) {
try {
return baseService.getDeviceHeaterPhsByDate(heaterMacAddress,date);
} catch (Exception e) {
log.error("getDeviceHeaterInfo macAddress:{},error message:{}",heaterMacAddress, e.toString());
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 获取智能加热棒 水流量信息
* @return
*/
@RequestMapping("/getDeviceHeaterInfo.do")
public Object getDeviceHeaterInfo(String heaterMacAddress) {
try {

View File

@ -31,6 +31,9 @@ public class DeviceHeater implements Serializable{
@Column(name = "heater_gathering_time")
private String heaterGatheringTime;
@Column(name = "heater_gathering_date")
private String heaterGatheringDate;
public String getHeaterId() {
return heaterId;
}
@ -70,4 +73,12 @@ public class DeviceHeater implements Serializable{
public void setHeaterGatheringTime(String heaterGatheringTime) {
this.heaterGatheringTime = heaterGatheringTime;
}
public String getHeaterGatheringDate() {
return heaterGatheringDate;
}
public void setHeaterGatheringDate(String heaterGatheringDate) {
this.heaterGatheringDate = heaterGatheringDate;
}
}

View File

@ -6,30 +6,23 @@
package com.ifish.helper;
import com.ifish.bean.DeviceUserBean;
import com.ifish.entity.Camera;
import com.ifish.entity.CameraUser;
import com.ifish.entity.Device;
import com.ifish.entity.DeviceCamera;
import com.ifish.entity.HardwareType;
import com.ifish.entity.ShopsInfo;
import com.ifish.entity.User;
import com.ifish.entity.VenderList;
import com.ifish.dao.DeviceUserDao;
import com.ifish.entity.*;
import com.ifish.enums.BooleanEnum;
import com.ifish.enums.GwellEnum;
import com.ifish.enums.NeteaseEnum;
import com.ifish.enums.ResultEnum;
import com.ifish.enums.SubDirectoryEnum;
import com.ifish.gwell.GwellApi;
import com.ifish.mapper.Tbl_Device_User_Mapper;
import com.ifish.mapper.Tbl_User_Mapper;
import com.ifish.netease.NeteaseIM;
import com.ifish.util.IfishFilePath;
import com.ifish.util.IfishUtil;
import com.ifish.util.RedisKey;
import com.ifish.util.StringUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -73,6 +66,9 @@ public class UserHelper implements UserHelperI {
@Autowired
private CameraUserHelperI cameraUserHelperI;
@Autowired
private DeviceUserDao deviceUserDao;
/**
* 登陆接口
*
@ -384,6 +380,7 @@ public class UserHelper implements UserHelperI {
List<Integer> deviceIds = new ArrayList<Integer>();
for (DeviceUserBean deviceUser : deviceUserList) {
Device device = deviceUserHelperI.getDeviceById(deviceUser.getDeviceId());
deviceIds.add(device.getDeviceId());
//封装设备返回信息
list.add(getDeviceInfo(device, deviceUser));

View File

@ -11,6 +11,7 @@ import com.ifish.entity.DeviceUser;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;
/**
*
@ -35,4 +36,5 @@ public interface Tbl_Device_User_Mapper {
*/
@Select("select camera_id,device_id from tbl_device_camera where device_id=#{deviceId}")
List<DeviceCamera> getDeviceCameraListByDeviceId(@Param("deviceId") Integer deviceId);
}

View File

@ -46,6 +46,8 @@ public interface BaseService {
public Object getDeviceHeaterInfo(String madAddress);
public Object getDeviceHeaterPhsByDate(String macAddress,String date);
public Object deleteDeviceHeaterInfo(String madAddress);
//绑定设备

View File

@ -614,12 +614,31 @@ public class BaseServiceImpl implements BaseService {
@Override
public Object deleteDeviceHeaterInfo(String heaterMacAddress) {
DeviceHeaterDetail heaterDetail = this.deviceHeaterDetailDao.findUniqueByProperty(Restrictions.eq("heaterMacAddress", heaterMacAddress));
List<DeviceHeater> deviceHeaters = deviceHeaterDao.findByProperty(Restrictions.eq("heaterMacAddress", heaterMacAddress));
for (DeviceHeater deviceHeater : deviceHeaters) {
deviceHeaterDao.delete(deviceHeater);
}
if (heaterDetail != null) {
this.deviceHeaterDetailDao.delete(heaterDetail);
return IfishUtil.returnJson(ResultEnum.success.getKey(),"");
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(),"");
}
@Override
public Object getDeviceHeaterPhsByDate(String macAddress,String date) {
try {
Map<String,Object> data = new HashMap<String,Object>(24);
List<DeviceHeater> phs = this.deviceHeaterDao.findByProperty(Order.asc("heaterGatheringTime"), Restrictions.eq("heaterMacAddress", macAddress),Restrictions.eq("heaterGatheringDate",date));
data.put("phs",phs);
return IfishUtil.returnJson(ResultEnum.success.getKey(),data);
} catch (Exception e) {
e.printStackTrace();
}
return IfishUtil.returnJson(ResultEnum.success.getKey(),"");
}
@Override
@ -629,7 +648,7 @@ public class BaseServiceImpl implements BaseService {
DeviceHeaterDetail heaterDetail = this.deviceHeaterDetailDao.findUniqueByProperty(Restrictions.eq("heaterMacAddress", macAddress));
if (heaterDetail != null) {
data.put("heater",heaterDetail);
List<DeviceHeater> phs = this.deviceHeaterDao.findByProperty(Order.asc("heaterGatheringTime"), Restrictions.eq("heaterMacAddress", macAddress));
List<DeviceHeater> phs = this.deviceHeaterDao.findByProperty(Order.asc("heaterGatheringTime"), Restrictions.eq("heaterMacAddress", macAddress),Restrictions.eq("heaterGatheringDate",IfishUtil.format1(new Date())));
data.put("phs",phs);
return IfishUtil.returnJson(ResultEnum.success.getKey(),data);
}
@ -640,6 +659,8 @@ public class BaseServiceImpl implements BaseService {
return IfishUtil.returnJson(ResultEnum.success.getKey(),"");
}
/**
* 绑定摄像头
*/
@ -775,6 +796,11 @@ public class BaseServiceImpl implements BaseService {
String type = device.getHardwareType();
if (type != null) {
HardwareType hardwareType = this.hardwareTypeDao.get(type);
if (hardwareType.getHardwareType().equals("3a") && deviceUser.getShowName().contains("鱼缸")) {
deviceUser.setShowName("加热器" + (int) (Math.random() * 9000 + 1000));
deviceUserDao.update(deviceUser);
}
if (hardwareType != null) {
//设备类型
deviceMap.put("type", type);
@ -1042,11 +1068,16 @@ public class BaseServiceImpl implements BaseService {
deviceUser.getPriId().setDeviceId(device.getDeviceId());
DeviceUser tmpDeviceUser = deviceUserDao.get(deviceUser.getPriId());
if (tmpDeviceUser != null) {
//封装设备返回信息
return IfishUtil.returnJson(ResultEnum.success.getKey(), getDeviceInfo(device, tmpDeviceUser));
} else {
deviceUser.setIsMaster(BooleanEnum.NO.getKey());
deviceUser.setShowName("鱼缸" + (int) (Math.random() * 9000 + 1000));
if (device.getHardwareType() != null && device.getHardwareType().equals("3a")) {
deviceUser.setShowName("加热器" + (int) (Math.random() * 9000 + 1000));
} else {
deviceUser.setShowName("鱼缸" + (int) (Math.random() * 9000 + 1000));
}
Date date = new Date();
deviceUser.setUpdateTime(date);
deviceUser.setCreateTime(date);

View File

@ -345,8 +345,13 @@ public class UserServiceImpl implements UserService {
List<DeviceUser> deviceUserList = deviceUserDao.findByProperty(Restrictions.eq("priId.deviceId", deviceId));
//解除关联关系并发送推送
deleteDeviceAndPushMsg(deviceUserList, deviceId);
//新增关联关系
if (device.getHardwareType() != null && device.getHardwareType().equals("3a")) {
deviceUser = new DeviceUser(priId, BooleanEnum.YES.getKey(), "加热器"+(int)(Math.random()*9000+1000));
} else {
deviceUser = new DeviceUser(priId, BooleanEnum.YES.getKey(), "鱼缸"+(int)(Math.random()*9000+1000));
}
//关联设备
deviceUser = new DeviceUser(priId, BooleanEnum.YES.getKey(), "鱼缸"+(int)(Math.random()*9000+1000));
deviceUserDao.save(deviceUser);
}
else{
@ -383,8 +388,12 @@ public class UserServiceImpl implements UserService {
DeviceUserId priId = new DeviceUserId(userId, deviceId);
DeviceUser deviceUser = deviceUserDao.get(priId);
if(deviceUser==null){
//关联设备
deviceUser = new DeviceUser(priId, BooleanEnum.NO.getKey(), "鱼缸"+(int)(Math.random()*9000+1000));
//新增关联关系
if (device.getHardwareType() != null && device.getHardwareType().equals("3a")) {
deviceUser = new DeviceUser(priId, BooleanEnum.YES.getKey(), "加热器"+(int)(Math.random()*9000+1000));
} else {
deviceUser = new DeviceUser(priId, BooleanEnum.YES.getKey(), "鱼缸"+(int)(Math.random()*9000+1000));
}
deviceUserDao.save(deviceUser);
}
return new JsonResult<DeviceDto>(ResultEnum.success.getKey(), getDeviceDto(deviceUser, device));
@ -726,6 +735,10 @@ public class UserServiceImpl implements UserService {
//硬件类型
HardwareType hardwareType = cacheService.findHardwareTypeById(type);
if(hardwareType!=null){
if (hardwareType.getHardwareType().equals("3a") && deviceUser.getShowName().contains("鱼缸")) {
deviceUser.setShowName("加热器" + (int) (Math.random() * 9000 + 1000));
deviceUserDao.update(deviceUser);
}
//控制数和定时器数
dto.setControlAmount(hardwareType.getControlAmount());
dto.setTimerAmount(hardwareType.getTimerAmount());