绚多7控新增水位预警推送
This commit is contained in:
parent
63ce6f845d
commit
9039f2196e
|
|
@ -7,6 +7,7 @@ public enum PushTypeEnum {
|
||||||
app_update("app_update","IOS更新推送"),
|
app_update("app_update","IOS更新推送"),
|
||||||
remind_water("remind_water","换水提醒"),
|
remind_water("remind_water","换水提醒"),
|
||||||
offline_push("offline_push","离线通知"),
|
offline_push("offline_push","离线通知"),
|
||||||
|
water_warn("water_warn","水位预警"),
|
||||||
ph_warn("ph_warn","水流量预警");
|
ph_warn("ph_warn","水流量预警");
|
||||||
|
|
||||||
private PushTypeEnum(String key,String value){
|
private PushTypeEnum(String key,String value){
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,7 @@ import com.ifish.quartz.JobGroup;
|
||||||
import com.ifish.quartz.ScheduleJob;
|
import com.ifish.quartz.ScheduleJob;
|
||||||
import com.ifish.service.DeviceService;
|
import com.ifish.service.DeviceService;
|
||||||
import com.ifish.service.UserService;
|
import com.ifish.service.UserService;
|
||||||
import com.ifish.socketNew.model.receive.BackFunctionCode0;
|
import com.ifish.socketNew.model.receive.*;
|
||||||
import com.ifish.socketNew.model.receive.BackFunctionCode1;
|
|
||||||
import com.ifish.socketNew.model.receive.BackFunctionCode8;
|
|
||||||
import com.ifish.socketNew.model.receive.BackFunctionCodeHeater;
|
|
||||||
import com.ifish.socketNew.model.send.*;
|
import com.ifish.socketNew.model.send.*;
|
||||||
import com.ifish.socketNew.util.OrderModel;
|
import com.ifish.socketNew.util.OrderModel;
|
||||||
import com.ifish.util.ByteUtil;
|
import com.ifish.util.ByteUtil;
|
||||||
|
|
@ -120,6 +117,15 @@ public class SomeServer {
|
||||||
jobGroup.setTriggerName(macAddress);
|
jobGroup.setTriggerName(macAddress);
|
||||||
scheduleJob.deleteJob(jobGroup);
|
scheduleJob.deleteJob(jobGroup);
|
||||||
sendToApp(session,macAddress,heater.getByteMessage());
|
sendToApp(session,macAddress,heater.getByteMessage());
|
||||||
|
} else if (message instanceof BackBytes45) {
|
||||||
|
BackBytes45 backBytes45 = (BackBytes45) message;
|
||||||
|
String macAddress = ByteUtil.bytesToHexString(backBytes45.getSrc());
|
||||||
|
//需要推送预警
|
||||||
|
if (backBytes45.getHumidity() == 2) {
|
||||||
|
pushNotifcationByPh(macAddress,PushTypeEnum.water_warn.getValue(),"水位预警, 请及时查看!");
|
||||||
|
System.out.println("macAddress : " + macAddress + ", 水位预警 : " + backBytes45);
|
||||||
|
}
|
||||||
|
sendToApp(session, macAddress, backBytes45.getByteMessage());
|
||||||
}
|
}
|
||||||
//设置设备温度报警
|
//设置设备温度报警
|
||||||
else if(message instanceof OrderFunctionCode5) {
|
else if(message instanceof OrderFunctionCode5) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package com.ifish.socketNew.codeFactory;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
import com.ifish.socketNew.model.receive.BackBytes45;
|
||||||
|
import com.ifish.socketNew.model.receive.BackBytes57;
|
||||||
import com.ifish.socketNew.model.receive.BackFunctionCodeHeater;
|
import com.ifish.socketNew.model.receive.BackFunctionCodeHeater;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.mina.core.buffer.IoBuffer;
|
import org.apache.mina.core.buffer.IoBuffer;
|
||||||
|
|
@ -105,7 +107,12 @@ public class ServerDecode implements ProtocolDecoder {
|
||||||
case 31: {
|
case 31: {
|
||||||
functionBackHeater(bytes,buf, out);
|
functionBackHeater(bytes,buf, out);
|
||||||
break;
|
break;
|
||||||
}//长度为22
|
}
|
||||||
|
case 45: {
|
||||||
|
functionBack2f(bytes, buf, out);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//长度为22
|
||||||
case 22:{
|
case 22:{
|
||||||
//设置报警温度
|
//设置报警温度
|
||||||
if(check_code==5){
|
if(check_code==5){
|
||||||
|
|
@ -407,6 +414,53 @@ public class ServerDecode implements ProtocolDecoder {
|
||||||
}
|
}
|
||||||
out.write(model);
|
out.write(model);
|
||||||
}
|
}
|
||||||
|
private void functionBack2f(byte[] bytes, IoBuffer buf, ProtocolDecoderOutput out){
|
||||||
|
BackBytes45 model = new BackBytes45();
|
||||||
|
model.setByteMessage(bytes);
|
||||||
|
//15字节头
|
||||||
|
model.setType(buf.get());
|
||||||
|
model.setCheck_code(buf.get());
|
||||||
|
byte[] src = model.getSrc();
|
||||||
|
for (int i = 0; i < src.length; i++) {
|
||||||
|
src[i] = buf.get();
|
||||||
|
}
|
||||||
|
model.setSrc(src);
|
||||||
|
byte[] dest = model.getDest();
|
||||||
|
for (int i = 0; i < dest.length; i++) {
|
||||||
|
dest[i] = buf.get();
|
||||||
|
}
|
||||||
|
model.setDest(dest);
|
||||||
|
model.setRemote_len(buf.get());
|
||||||
|
model.setNumber1(buf.get());
|
||||||
|
model.setNumber2(buf.get());
|
||||||
|
model.setNumber3(buf.get());
|
||||||
|
model.setNumber4(buf.get());
|
||||||
|
model.setNumber5(buf.get());
|
||||||
|
model.setNumber6(buf.get());
|
||||||
|
model.setNumber7(buf.get());
|
||||||
|
model.setOnoff1(buf.get());
|
||||||
|
model.setOnoff2(buf.get());
|
||||||
|
model.setOnoff3(buf.get());
|
||||||
|
model.setOnoff4(buf.get());
|
||||||
|
model.setOnoff5(buf.get());
|
||||||
|
model.setOnoff6(buf.get());
|
||||||
|
model.setOnoff7(buf.get());
|
||||||
|
model.setHeatStatus(buf.get());
|
||||||
|
model.setWendu(buf.getShort());
|
||||||
|
model.setHeatWendu(buf.getShort());
|
||||||
|
model.setSarkLamp(buf.get());
|
||||||
|
model.setDianliang(buf.getShort());
|
||||||
|
model.setWarn_onoff(buf.get());
|
||||||
|
model.setLow_wendu(buf.getShort());
|
||||||
|
model.setHigh_wendu(buf.getShort());
|
||||||
|
model.setHumidity(buf.get());
|
||||||
|
|
||||||
|
byte[] crc16_code = model.getCrc16_code();
|
||||||
|
for (int i = 0; i < crc16_code.length; i++) {
|
||||||
|
crc16_code[i] = buf.get();
|
||||||
|
}
|
||||||
|
out.write(model);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void dispose(IoSession session) throws Exception {
|
public void dispose(IoSession session) throws Exception {
|
||||||
Context ctx = (Context) session.getAttribute(CONTEXT);
|
Context ctx = (Context) session.getAttribute(CONTEXT);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,285 @@
|
||||||
|
package com.ifish.socketNew.model.receive;
|
||||||
|
|
||||||
|
import com.ifish.socketNew.model.HeadModel;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询反馈信息45字节(15字节协议头+42字节结果)
|
||||||
|
* @author guogw
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class BackBytes45 extends HeadModel implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2740442296642889777L;
|
||||||
|
/*********灯和开关(4字节)**********/
|
||||||
|
//气泵
|
||||||
|
private byte number1;
|
||||||
|
//灯1
|
||||||
|
private byte number2;
|
||||||
|
//灯2
|
||||||
|
private byte number3;
|
||||||
|
//水泵
|
||||||
|
private byte number4;
|
||||||
|
//UV
|
||||||
|
private byte number5;
|
||||||
|
//造浪
|
||||||
|
private byte number6;
|
||||||
|
//加热制冷
|
||||||
|
private byte number7;
|
||||||
|
//气泵开关
|
||||||
|
private byte onoff1;
|
||||||
|
//灯1开关
|
||||||
|
private byte onoff2;
|
||||||
|
//灯2开关
|
||||||
|
private byte onoff3;
|
||||||
|
//水泵开关
|
||||||
|
private byte onoff4;
|
||||||
|
//UV开关
|
||||||
|
private byte onoff5;
|
||||||
|
//造浪开关
|
||||||
|
private byte onoff6;
|
||||||
|
//造浪开关
|
||||||
|
private byte onoff7;
|
||||||
|
//加热状态
|
||||||
|
private byte heatStatus;
|
||||||
|
//温度
|
||||||
|
private short wendu;
|
||||||
|
//加热温度
|
||||||
|
private short heatWendu;
|
||||||
|
//护理灯
|
||||||
|
private byte sarkLamp;
|
||||||
|
//电量
|
||||||
|
private short dianliang;
|
||||||
|
//报警开关,0关,1开
|
||||||
|
private byte warn_onoff;
|
||||||
|
//最低报警温度
|
||||||
|
private short low_wendu;
|
||||||
|
//最高报警温度
|
||||||
|
private short high_wendu;
|
||||||
|
//湿度(水位报警)。0关,1开(默认为0)
|
||||||
|
private byte humidity;
|
||||||
|
|
||||||
|
private byte[] byteMessage;
|
||||||
|
|
||||||
|
public byte getNumber1() {
|
||||||
|
return number1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber1(byte number1) {
|
||||||
|
this.number1 = number1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getNumber2() {
|
||||||
|
return number2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber2(byte number2) {
|
||||||
|
this.number2 = number2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getNumber3() {
|
||||||
|
return number3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber3(byte number3) {
|
||||||
|
this.number3 = number3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getNumber4() {
|
||||||
|
return number4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber4(byte number4) {
|
||||||
|
this.number4 = number4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getNumber5() {
|
||||||
|
return number5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber5(byte number5) {
|
||||||
|
this.number5 = number5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getNumber6() {
|
||||||
|
return number6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber6(byte number6) {
|
||||||
|
this.number6 = number6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getNumber7() {
|
||||||
|
return number7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber7(byte number7) {
|
||||||
|
this.number7 = number7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getOnoff1() {
|
||||||
|
return onoff1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnoff1(byte onoff1) {
|
||||||
|
this.onoff1 = onoff1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getOnoff2() {
|
||||||
|
return onoff2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnoff2(byte onoff2) {
|
||||||
|
this.onoff2 = onoff2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getOnoff3() {
|
||||||
|
return onoff3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnoff3(byte onoff3) {
|
||||||
|
this.onoff3 = onoff3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getOnoff4() {
|
||||||
|
return onoff4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnoff4(byte onoff4) {
|
||||||
|
this.onoff4 = onoff4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getOnoff5() {
|
||||||
|
return onoff5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnoff5(byte onoff5) {
|
||||||
|
this.onoff5 = onoff5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getOnoff6() {
|
||||||
|
return onoff6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnoff6(byte onoff6) {
|
||||||
|
this.onoff6 = onoff6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getOnoff7() {
|
||||||
|
return onoff7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnoff7(byte onoff7) {
|
||||||
|
this.onoff7 = onoff7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getHeatStatus() {
|
||||||
|
return heatStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeatStatus(byte heatStatus) {
|
||||||
|
this.heatStatus = heatStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getWendu() {
|
||||||
|
return wendu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWendu(short wendu) {
|
||||||
|
this.wendu = wendu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getHeatWendu() {
|
||||||
|
return heatWendu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeatWendu(short heatWendu) {
|
||||||
|
this.heatWendu = heatWendu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getSarkLamp() {
|
||||||
|
return sarkLamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSarkLamp(byte sarkLamp) {
|
||||||
|
this.sarkLamp = sarkLamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getDianliang() {
|
||||||
|
return dianliang;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDianliang(short dianliang) {
|
||||||
|
this.dianliang = dianliang;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getWarn_onoff() {
|
||||||
|
return warn_onoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWarn_onoff(byte warn_onoff) {
|
||||||
|
this.warn_onoff = warn_onoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getLow_wendu() {
|
||||||
|
return low_wendu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLow_wendu(short low_wendu) {
|
||||||
|
this.low_wendu = low_wendu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getHigh_wendu() {
|
||||||
|
return high_wendu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHigh_wendu(short high_wendu) {
|
||||||
|
this.high_wendu = high_wendu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getHumidity() {
|
||||||
|
return humidity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHumidity(byte humidity) {
|
||||||
|
this.humidity = humidity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getByteMessage() {
|
||||||
|
return byteMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setByteMessage(byte[] byteMessage) {
|
||||||
|
this.byteMessage = byteMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "BackBytes45{" +
|
||||||
|
"number1=" + number1 +
|
||||||
|
", number2=" + number2 +
|
||||||
|
", number3=" + number3 +
|
||||||
|
", number4=" + number4 +
|
||||||
|
", number5=" + number5 +
|
||||||
|
", number6=" + number6 +
|
||||||
|
", number7=" + number7 +
|
||||||
|
", onoff1=" + onoff1 +
|
||||||
|
", onoff2=" + onoff2 +
|
||||||
|
", onoff3=" + onoff3 +
|
||||||
|
", onoff4=" + onoff4 +
|
||||||
|
", onoff5=" + onoff5 +
|
||||||
|
", onoff6=" + onoff6 +
|
||||||
|
", onoff7=" + onoff7 +
|
||||||
|
", heatStatus=" + heatStatus +
|
||||||
|
", wendu=" + wendu +
|
||||||
|
", heatWendu=" + heatWendu +
|
||||||
|
", sarkLamp=" + sarkLamp +
|
||||||
|
", dianliang=" + dianliang +
|
||||||
|
", warn_onoff=" + warn_onoff +
|
||||||
|
", low_wendu=" + low_wendu +
|
||||||
|
", high_wendu=" + high_wendu +
|
||||||
|
", humidity=" + humidity +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue