优化架构,获取设备注册时的设备相关信息
This commit is contained in:
@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import com.genersoft.iot.vmp.jt1078.session.SessionManager;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* 终端通用应答
|
||||
@@ -47,4 +48,9 @@ public class J0001 extends Re {
|
||||
public int getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvent getEvent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||
import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* 终端心跳
|
||||
@@ -29,4 +30,9 @@ public class J0002 extends Re {
|
||||
j8001.setResult(J8001.SUCCESS);
|
||||
return j8001;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvent getEvent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||
import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* 查询服务器时间
|
||||
@@ -24,4 +25,9 @@ public class J0004 extends Re {
|
||||
protected Rs handler(Header header, Session session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvent getEvent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.request;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.event.RegisterEvent;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.J8100;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||
import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* 终端注册
|
||||
@@ -35,13 +39,34 @@ public class J0100 extends Re {
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
Short version = header.getVersion();
|
||||
provinceId = buf.readUnsignedShort();
|
||||
if (version > 1) {
|
||||
if (version >= 1) {
|
||||
cityId = buf.readUnsignedShort();
|
||||
// decode as 2019
|
||||
byte[] bytes11 = new byte[11];
|
||||
buf.readBytes(bytes11);
|
||||
makerId = new String(bytes11).trim();
|
||||
|
||||
byte[] bytes30 = new byte[30];
|
||||
buf.readBytes(bytes30);
|
||||
deviceModel = new String(bytes30).trim();
|
||||
|
||||
buf.readBytes(bytes30);
|
||||
deviceId = new String(bytes30).trim();
|
||||
|
||||
plateColor = buf.readByte();
|
||||
byte[] plateColorBytes = new byte[buf.readableBytes()];
|
||||
buf.readBytes(plateColorBytes);
|
||||
try {
|
||||
plateNo = new String(plateColorBytes, "GBK").trim();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
int i = buf.readUnsignedShort();
|
||||
// decode as 2013
|
||||
}
|
||||
// 发送终端注册消息
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -53,4 +78,17 @@ public class J0100 extends Re {
|
||||
j8100.setCode("WVP_YYDS");
|
||||
return j8100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvent getEvent() {
|
||||
RegisterEvent registerEvent = new RegisterEvent(this);
|
||||
registerEvent.setProvinceId(provinceId);
|
||||
registerEvent.setCityId(cityId);
|
||||
registerEvent.setDeviceId(deviceId);
|
||||
registerEvent.setDeviceModel(deviceModel);
|
||||
registerEvent.setMakerId(makerId);
|
||||
registerEvent.setPlateColor(plateColor);
|
||||
registerEvent.setPlateNo(plateNo);
|
||||
return registerEvent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||
import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* 终端鉴权
|
||||
@@ -33,4 +34,9 @@ public class J0102 extends Re {
|
||||
return j8001;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvent getEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||
import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* 实时消息上报
|
||||
@@ -29,4 +30,9 @@ public class J0200 extends Re {
|
||||
j8001.setResult(J8001.SUCCESS);
|
||||
return j8001;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvent getEvent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import com.genersoft.iot.vmp.jt1078.session.SessionManager;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -187,4 +188,9 @@ public class J1205 extends Re {
|
||||
", recordList=" + recordList +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvent getEvent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -37,4 +38,6 @@ public abstract class Re {
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
public abstract ApplicationEvent getEvent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user