新增加热器设备适配,及mina升级!
This commit is contained in:
parent
90de7d7808
commit
a7e8cb7884
|
|
@ -20,6 +20,8 @@ public class DeviceHeater implements Serializable{
|
||||||
|
|
||||||
private String heaterGatheringTime;
|
private String heaterGatheringTime;
|
||||||
|
|
||||||
|
private String heaterGatheringDate;
|
||||||
|
|
||||||
public Integer getHeaterId() {
|
public Integer getHeaterId() {
|
||||||
return heaterId;
|
return heaterId;
|
||||||
}
|
}
|
||||||
|
|
@ -59,4 +61,12 @@ public class DeviceHeater implements Serializable{
|
||||||
public void setHeaterGatheringTime(String heaterGatheringTime) {
|
public void setHeaterGatheringTime(String heaterGatheringTime) {
|
||||||
this.heaterGatheringTime = heaterGatheringTime;
|
this.heaterGatheringTime = heaterGatheringTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getHeaterGatheringDate() {
|
||||||
|
return heaterGatheringDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeaterGatheringDate(String heaterGatheringDate) {
|
||||||
|
this.heaterGatheringDate = heaterGatheringDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,6 @@
|
||||||
<property name="heaterWaterTemperature" column="heater_water_temperature" type="string" length="50"/>
|
<property name="heaterWaterTemperature" column="heater_water_temperature" type="string" length="50"/>
|
||||||
<property name="heaterPh" column="heater_ph" type="string" length="50"/>
|
<property name="heaterPh" column="heater_ph" type="string" length="50"/>
|
||||||
<property name="heaterGatheringTime" column="heater_gathering_time" type="string" length="50"/>
|
<property name="heaterGatheringTime" column="heater_gathering_time" type="string" length="50"/>
|
||||||
|
<property name="heaterGatheringDate" column="heater_gathering_date" type="string" length="50"/>
|
||||||
</class>
|
</class>
|
||||||
</hibernate-mapping>
|
</hibernate-mapping>
|
||||||
|
|
@ -27,7 +27,7 @@ public interface DeviceService {
|
||||||
|
|
||||||
List<Device> getByProperty(String property,Object value);
|
List<Device> getByProperty(String property,Object value);
|
||||||
|
|
||||||
List<DeviceHeater> getDeviceHeaterByProperty(String hour,String macAddress);
|
List<DeviceHeater> getDeviceHeaterByProperty(String hour,String macAddress,String date);
|
||||||
|
|
||||||
DeviceUser getUniqueByProperty(String macAddress);
|
DeviceUser getUniqueByProperty(String macAddress);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||||
import com.ifish.dao.*;
|
import com.ifish.dao.*;
|
||||||
import com.ifish.entity.*;
|
import com.ifish.entity.*;
|
||||||
import com.ifish.socketNew.model.receive.BackFunctionCodeHeater;
|
import com.ifish.socketNew.model.receive.BackFunctionCodeHeater;
|
||||||
|
import com.ifish.util.IfishUtil;
|
||||||
import org.hibernate.criterion.Criterion;
|
import org.hibernate.criterion.Criterion;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
@ -168,9 +169,10 @@ public class DeviceServiceImpl implements DeviceService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceHeater save(BackFunctionCodeHeater model) {
|
public DeviceHeater save(BackFunctionCodeHeater model) {
|
||||||
//保存加热棒数据 按天
|
//保存加热棒数据 按天 最近7天
|
||||||
DeviceHeater deviceHeater = new DeviceHeater();
|
DeviceHeater deviceHeater = new DeviceHeater();
|
||||||
deviceHeater.setHeaterGatheringTime(Calendar.getInstance().get(Calendar.HOUR_OF_DAY) + "");
|
deviceHeater.setHeaterGatheringTime(Calendar.getInstance().get(Calendar.HOUR_OF_DAY) + "");
|
||||||
|
deviceHeater.setHeaterGatheringDate(IfishUtil.format1(new Date()));
|
||||||
deviceHeater.setHeaterMacAddress(ByteUtil.bytesToHexString(model.getSrc()));
|
deviceHeater.setHeaterMacAddress(ByteUtil.bytesToHexString(model.getSrc()));
|
||||||
deviceHeater.setHeaterPh(String.valueOf(model.getPh()));
|
deviceHeater.setHeaterPh(String.valueOf(model.getPh()));
|
||||||
deviceHeater.setHeaterWaterTemperature(String.valueOf(model.getWaterTemperature()));
|
deviceHeater.setHeaterWaterTemperature(String.valueOf(model.getWaterTemperature()));
|
||||||
|
|
@ -183,9 +185,10 @@ public class DeviceServiceImpl implements DeviceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceHeater> getDeviceHeaterByProperty(String hour,String macAddress) {
|
public List<DeviceHeater> getDeviceHeaterByProperty(String hour,String macAddress,String date) {
|
||||||
List<Criterion> queryList = new ArrayList<Criterion>();
|
List<Criterion> queryList = new ArrayList<Criterion>();
|
||||||
queryList.add(Restrictions.eq("heaterMacAddress",macAddress));
|
queryList.add(Restrictions.eq("heaterMacAddress",macAddress));
|
||||||
|
queryList.add(Restrictions.eq("heaterGatheringDate",date));
|
||||||
queryList.add(Restrictions.eq("heaterGatheringTime",hour));
|
queryList.add(Restrictions.eq("heaterGatheringTime",hour));
|
||||||
List<DeviceHeater> list = this.deviceHeaterDao.getByCriterion(queryList.toArray(new Criterion[queryList.size()]));
|
List<DeviceHeater> list = this.deviceHeaterDao.getByCriterion(queryList.toArray(new Criterion[queryList.size()]));
|
||||||
return list;
|
return list;
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public class SomeServer {
|
||||||
BackFunctionCodeHeater heater = (BackFunctionCodeHeater) message;
|
BackFunctionCodeHeater heater = (BackFunctionCodeHeater) message;
|
||||||
String macAddress = ByteUtil.bytesToHexString(heater.getSrc());
|
String macAddress = ByteUtil.bytesToHexString(heater.getSrc());
|
||||||
String hour = String.valueOf(Calendar.getInstance().get(Calendar.HOUR_OF_DAY));
|
String hour = String.valueOf(Calendar.getInstance().get(Calendar.HOUR_OF_DAY));
|
||||||
List<DeviceHeater> deviceHeaters = deviceService.getDeviceHeaterByProperty(hour, macAddress);
|
List<DeviceHeater> deviceHeaters = deviceService.getDeviceHeaterByProperty(hour, macAddress,IfishUtil.format1(new Date()));
|
||||||
if (deviceHeaters.size() > 0) {
|
if (deviceHeaters.size() > 0) {
|
||||||
DeviceHeater deviceHeater = deviceHeaters.get(0);
|
DeviceHeater deviceHeater = deviceHeaters.get(0);
|
||||||
deviceHeater.setHeaterWaterTemperature(String.valueOf(heater.getWaterTemperature()));
|
deviceHeater.setHeaterWaterTemperature(String.valueOf(heater.getWaterTemperature()));
|
||||||
|
|
@ -92,6 +92,11 @@ public class SomeServer {
|
||||||
} else {
|
} else {
|
||||||
deviceService.save(heater);
|
deviceService.save(heater);
|
||||||
}
|
}
|
||||||
|
//设备重新连接上,则移除延时推送的任务
|
||||||
|
JobGroup jobGroup = new JobGroup();
|
||||||
|
jobGroup.setJobName(macAddress);
|
||||||
|
jobGroup.setTriggerName(macAddress);
|
||||||
|
scheduleJob.deleteJob(jobGroup);
|
||||||
sendToApp(session,macAddress,heater.getByteMessage());
|
sendToApp(session,macAddress,heater.getByteMessage());
|
||||||
}
|
}
|
||||||
//设置设备温度报警
|
//设置设备温度报警
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,16 @@ public class IfishUtil {
|
||||||
return format.format(date);
|
return format.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化日期yyyy-MM-dd
|
||||||
|
* @param date
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String format1(Date date){
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat(formatDate1);
|
||||||
|
return format.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串转换成日期
|
* 字符串转换成日期
|
||||||
* @param str
|
* @param str
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue