加热器设备接口

This commit is contained in:
yiyan 2018-09-29 19:15:09 +08:00
parent ceb4f20e3f
commit 0442f77b63
12 changed files with 406 additions and 29 deletions

View File

@ -1,5 +1,6 @@
package com.ifish.action;
import com.ifish.entity.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -8,12 +9,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ifish.entity.CameraUserId;
import com.ifish.entity.Device;
import com.ifish.entity.DeviceUser;
import com.ifish.entity.QuestionsFeedback;
import com.ifish.entity.ShopsInfo;
import com.ifish.entity.User;
import com.ifish.enums.ResultEnum;
import com.ifish.helper.UserHelperI;
import com.ifish.service.BaseService;
@ -171,23 +166,65 @@ public class UserAction {
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 新增智能加热棒信息
* @return
*/
@RequestMapping("/saveOrUpdateDeviceHeaterInfo.do")
public Object saveOrUpdateDeviceHeaterInfo(DeviceHeaterDetail heaterDetail) {
try {
return baseService.saveOrUpdateDeviceHeaterInfo(heaterDetail);
} catch (Exception e) {
log.error("saveOrUpdateDeviceHeaterInfo macAddress:{},error message:{}",heaterDetail.getHeaterMacAddress(), e.toString());
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 获取智能加热棒信息
* @return
*/
@RequestMapping("/getDeviceHeaterInfo.do")
public Object getDeviceHeaterInfo(String heaterMacAddress) {
try {
return baseService.getDeviceHeaterInfo(heaterMacAddress);
} catch (Exception e) {
log.error("getDeviceHeaterInfo macAddress:{},error message:{}",heaterMacAddress, e.toString());
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 删除智能加热棒信息
* @return
*/
@RequestMapping("/deleteDeviceHeaterInfo.do")
public Object deleteDeviceHeaterInfo(String heaterMacAddress) {
try {
return baseService.deleteDeviceHeaterInfo(heaterMacAddress);
} catch (Exception e) {
log.error("deleteDeviceHeaterInfo macAddress:{},error message:{}",heaterMacAddress, e.toString());
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
}
/**
* 绑定摄像头
*
* @param user
* @param macAddress
* @param userId
* @param cameraId
* @return
*/
@RequestMapping("/bindCamera.do")
public Object bindCamera(Integer userId, String cameraId) {
return baseService.bindCamera(userId, cameraId);
}
} /**
/**
* 关联设备和摄像头
*
* @param user
* @param macAddress
* @param deviceId
* @param cameraId
* @return
*/
@RequestMapping("/deviceBindCamera.do")
@ -203,8 +240,9 @@ public class UserAction {
/**
* 关联设备和摄像头1
*
* @param user
* @param macAddress
* @param userId
* @param deviceId
* @param cameraId
* @return
*/
@RequestMapping("/deviceBindCamera1.do")

View File

@ -0,0 +1,13 @@
package com.ifish.dao;
import com.ifish.entity.DeviceHeater;
/**
* @ClassName: DeviceDao
* @Description: TODO
* @author ggw
*
*/
public interface DeviceHeaterDao extends BaseDao<DeviceHeater, Integer>{
}

View File

@ -0,0 +1,12 @@
package com.ifish.dao;
import com.ifish.entity.DeviceHeaterDetail;
/**
* @ClassName: DeviceDao
* @Description: TODO
* @author ggw
*
*/
public interface DeviceHeaterDetailDao extends BaseDao<DeviceHeaterDetail, Integer> {
}

View File

@ -0,0 +1,25 @@
package com.ifish.daoImpl;
import com.ifish.dao.DeviceHeaterDao;
import com.ifish.dao.DeviceHeaterDetailDao;
import com.ifish.entity.DeviceHeater;
import com.ifish.entity.DeviceHeaterDetail;
import com.ifish.hibernate.HibernateBaseDao;
import org.springframework.stereotype.Repository;
/**
* @ClassName: DeviceDaoImpl
* @Description: TODO
* @author ggw
*
*/
@Repository
public class DeviceHeaterDaoImpl extends HibernateBaseDao<DeviceHeater, Integer> implements DeviceHeaterDao {
@Override
protected Class<DeviceHeater> getEntityClass() {
return DeviceHeater.class;
}
}

View File

@ -0,0 +1,26 @@
package com.ifish.daoImpl;
import com.ifish.dao.DeviceDao;
import com.ifish.dao.DeviceHeaterDetailDao;
import com.ifish.entity.Device;
import com.ifish.entity.DeviceHeater;
import com.ifish.entity.DeviceHeaterDetail;
import com.ifish.hibernate.HibernateBaseDao;
import org.springframework.stereotype.Repository;
/**
* @ClassName: DeviceDaoImpl
* @Description: TODO
* @author ggw
*
*/
@Repository
public class DeviceHeaterDetailDaoImpl extends HibernateBaseDao<DeviceHeaterDetail, Integer> implements DeviceHeaterDetailDao {
@Override
protected Class<DeviceHeaterDetail> getEntityClass() {
return DeviceHeaterDetail.class;
}
}

View File

@ -0,0 +1,73 @@
package com.ifish.entity;
import javax.annotation.Generated;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author: yan.y
* @Description:
* @Date: Created in 21:00 2018/9/17
* @Modified by:
*/
@Entity
@Table(name = "tbl_device_heater")
public class DeviceHeater implements Serializable{
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name = "heater_id")
private String heaterId;
@Column(name = "heater_mac_address")
private String heaterMacAddress;
@Column(name = "heater_water_temperature")
private String heaterWaterTemperature;
@Column(name = "heater_ph")
private String heaterPh;
@Column(name = "heater_gathering_time")
private String heaterGatheringTime;
public String getHeaterId() {
return heaterId;
}
public void setHeaterId(String heaterId) {
this.heaterId = heaterId;
}
public String getHeaterMacAddress() {
return heaterMacAddress;
}
public void setHeaterMacAddress(String heaterMacAddress) {
this.heaterMacAddress = heaterMacAddress;
}
public String getHeaterWaterTemperature() {
return heaterWaterTemperature;
}
public void setHeaterWaterTemperature(String heaterWaterTemperature) {
this.heaterWaterTemperature = heaterWaterTemperature;
}
public String getHeaterPh() {
return heaterPh;
}
public void setHeaterPh(String heaterPh) {
this.heaterPh = heaterPh;
}
public String getHeaterGatheringTime() {
return heaterGatheringTime;
}
public void setHeaterGatheringTime(String heaterGatheringTime) {
this.heaterGatheringTime = heaterGatheringTime;
}
}

View File

@ -0,0 +1,133 @@
package com.ifish.entity;
import javax.annotation.Generated;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author: yan.y
* @Description:
* @Date: Created in 20:58 2018/9/17
* @Modified by:
*/
@Entity
@Table(name = "tbl_device_heater_detail")
public class DeviceHeaterDetail implements Serializable{
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name = "heater_id")
private Integer heaterId;
@Column(name = "heater_mac_address")
private String heaterMacAddress;
@Column(name = "heater_volume")
private String heaterVolume;
@Column(name = "heater_long")
private String heaterLong;
@Column(name = "heater_width")
private String heaterWidth;
@Column(name = "heater_height")
private String heaterHeight;
@Column(name = "heater_cycle")
private String heaterCycle;
@Column(name = "heater_reminder_time")
private String heaterReminderTime;
@Column(name = "herter_remind_date")
private String heaterRemindDate;
public Integer getHeaterId() {
return heaterId;
}
public void setHeaterId(Integer heaterId) {
this.heaterId = heaterId;
}
public String getHeaterMacAddress() {
return heaterMacAddress;
}
public void setHeaterMacAddress(String heaterMacAddress) {
this.heaterMacAddress = heaterMacAddress;
}
public String getHeaterVolume() {
return heaterVolume;
}
public void setHeaterVolume(String heaterVolume) {
this.heaterVolume = heaterVolume;
}
public String getHeaterLong() {
return heaterLong;
}
public void setHeaterLong(String heaterLong) {
this.heaterLong = heaterLong;
}
public String getHeaterWidth() {
return heaterWidth;
}
public void setHeaterWidth(String heaterWidth) {
this.heaterWidth = heaterWidth;
}
public String getHeaterHeight() {
return heaterHeight;
}
public void setHeaterHeight(String heaterHeight) {
this.heaterHeight = heaterHeight;
}
public String getHeaterCycle() {
return heaterCycle;
}
public void setHeaterCycle(String heaterCycle) {
this.heaterCycle = heaterCycle;
}
public String getHeaterReminderTime() {
return heaterReminderTime;
}
public void setHeaterReminderTime(String heaterReminderTime) {
this.heaterReminderTime = heaterReminderTime;
}
public String getHeaterRemindDate() {
return heaterRemindDate;
}
public void setHeaterRemindDate(String heaterRemindDate) {
this.heaterRemindDate = heaterRemindDate;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("DeviceHeaterDetail{");
sb.append("heaterId=").append(heaterId);
sb.append(", heaterMacAddress='").append(heaterMacAddress).append('\'');
sb.append(", heaterVolume='").append(heaterVolume).append('\'');
sb.append(", heaterLong='").append(heaterLong).append('\'');
sb.append(", heaterWidth='").append(heaterWidth).append('\'');
sb.append(", heaterHeight='").append(heaterHeight).append('\'');
sb.append(", heaterCycle='").append(heaterCycle).append('\'');
sb.append(", heaterReminderTime='").append(heaterReminderTime).append('\'');
sb.append(", heaterRemindDate='").append(heaterRemindDate).append('\'');
sb.append('}');
return sb.toString();
}
}

View File

@ -1,14 +1,8 @@
package com.ifish.service;
import com.ifish.entity.*;
import org.springframework.web.multipart.MultipartFile;
import com.ifish.entity.CameraUserId;
import com.ifish.entity.Device;
import com.ifish.entity.DeviceUser;
import com.ifish.entity.QuestionsFeedback;
import com.ifish.entity.ShopsInfo;
import com.ifish.entity.User;
/**
* @ClassName: BaseService
* @Description: TODO
@ -49,7 +43,14 @@ public interface BaseService {
//绑定设备
@Deprecated
public Object bindDevice(User user,String madAddress);
public Object getDeviceHeaterInfo(String madAddress);
public Object deleteDeviceHeaterInfo(String madAddress);
//绑定设备
public Object saveOrUpdateDeviceHeaterInfo(DeviceHeaterDetail heaterDetail);
//绑定摄像头
public Object bindCamera(Integer userId,String cameraId);

View File

@ -11,7 +11,9 @@ import java.util.Random;
import com.ifish.dao.*;
import com.ifish.entity.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -85,7 +87,12 @@ public class BaseServiceImpl implements BaseService {
private QuestionsFeedbackDao questionsFeedbackDao;
@Autowired
private PushRemindDao pushRemindDao;
@Autowired
private DeviceHeaterDetailDao deviceHeaterDetailDao;
@Autowired
private DeviceHeaterDao deviceHeaterDao;
private static final Logger log = Logger.getLogger(BaseServiceImpl.class);
/**
* 获取验证码
*/
@ -571,7 +578,11 @@ public class BaseServiceImpl implements BaseService {
//需要新增
if (bln) {
//新增关联关系
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));
}
deviceUser.setIsMaster(BooleanEnum.YES.getKey());
Date date = new Date();
deviceUser.setUpdateTime(date);
@ -585,6 +596,50 @@ public class BaseServiceImpl implements BaseService {
}
}
@Override
public Object saveOrUpdateDeviceHeaterInfo(DeviceHeaterDetail heaterDetail) {
log.info("加热器保存或修改 : " + heaterDetail.toString());
//提醒周期 设置提醒日期
String heaterCycle = heaterDetail.getHeaterCycle();
if (StringUtils.isNotBlank(heaterCycle)) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_YEAR,calendar.get(Calendar.DAY_OF_YEAR) + Integer.parseInt(heaterCycle));
heaterDetail.setHeaterRemindDate(IfishUtil.format1(calendar.getTime()));
}
this.deviceHeaterDetailDao.saveOrUpdate(heaterDetail);
return IfishUtil.returnJson(ResultEnum.success.getKey(),"");
}
@Override
public Object deleteDeviceHeaterInfo(String heaterMacAddress) {
DeviceHeaterDetail heaterDetail = this.deviceHeaterDetailDao.findUniqueByProperty(Restrictions.eq("heaterMacAddress", heaterMacAddress));
if (heaterDetail != null) {
this.deviceHeaterDetailDao.delete(heaterDetail);
return IfishUtil.returnJson(ResultEnum.success.getKey(),"");
}
return IfishUtil.returnJson(ResultEnum.fail101.getKey(),"");
}
@Override
public Object getDeviceHeaterInfo(String macAddress) {
try {
Map<String,Object> data = new HashMap<String,Object>(24);
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));
data.put("phs",phs);
return IfishUtil.returnJson(ResultEnum.success.getKey(),data);
}
} catch (Exception e) {
e.printStackTrace();
}
return IfishUtil.returnJson(ResultEnum.success.getKey(),"");
}
/**
* 绑定摄像头
*/

View File

@ -226,6 +226,7 @@ public class IfishUtil {
} else {
map.put("data", value);
}
System.out.println("响应 : " + map.toString());
return map;
}

View File

@ -1,10 +1,10 @@
jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
jdbc.url=jdbc\:mysql\://139.196.24.156\:3306/myfishdb?characterEncoding\=UTF-8
#jdbc.username=ifish
#jdbc.password=ifish7pwd
jdbc.username=root
jdbc.password=ifish7mysql
jdbc.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
#jdbc.url=jdbc\:mysql\://139.196.24.156\:3306/myfishdb?characterEncoding\=UTF-8
jdbc.username=ifish
jdbc.password=ifish7pwd
#jdbc.username=root
#jdbc.password=ifish7mysql
#jdbc.testWhileIdle=true
jdbc.validationQuery=SELECT * FROM DUAL
initialSize=1

View File

@ -33,5 +33,5 @@ log4j.appender.ROLLING_FILE.layout.ConversionPattern=[Ifish7][%-5p]%d - %c.%t(%F
log4j.logger.org.springframework=INFO
log4j.logger.com.hibernate=INFO
log4j.logger.java.sql=INFO
log4j.logger.java.sql=ERROR