1078-查询区域或线路数据
This commit is contained in:
@@ -45,7 +45,7 @@ public class JTCircleArea implements JTAreaOrRoute{
|
||||
@Schema(description = "区域的名称")
|
||||
private String name;
|
||||
|
||||
public ByteBuf encode(){
|
||||
public ByteBuf encode(){
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeInt((int) (id & 0xffffffffL));
|
||||
byteBuf.writeBytes(attribute.encode());
|
||||
@@ -62,6 +62,31 @@ public class JTCircleArea implements JTAreaOrRoute{
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public static JTCircleArea decode(ByteBuf buf) {
|
||||
|
||||
JTCircleArea area = new JTCircleArea();
|
||||
area.setId(buf.readUnsignedInt());
|
||||
int attributeInt = buf.readUnsignedShort();
|
||||
JTAreaAttribute areaAttribute = JTAreaAttribute.decode(attributeInt);
|
||||
area.setAttribute(areaAttribute);
|
||||
|
||||
area.setLatitude(buf.readUnsignedInt()/1000000D);
|
||||
area.setLongitude(buf.readUnsignedInt()/1000000D);
|
||||
area.setRadius(buf.readUnsignedInt());
|
||||
byte[] startTimeBytes = new byte[6];
|
||||
buf.readBytes(startTimeBytes);
|
||||
area.setStartTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(BCDUtil.transform(startTimeBytes)));
|
||||
byte[] endTimeBytes = new byte[6];
|
||||
buf.readBytes(endTimeBytes);
|
||||
area.setEndTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(BCDUtil.transform(endTimeBytes)));
|
||||
area.setMaxSpeed(buf.readUnsignedShort());
|
||||
area.setOverSpeedDuration(buf.readUnsignedByte());
|
||||
area.setNighttimeMaxSpeed(buf.readUnsignedShort());
|
||||
int nameLength = buf.readUnsignedShort();
|
||||
area.setName(buf.readCharSequence(nameLength, Charset.forName("GBK")).toString().trim());
|
||||
return area;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.netty.buffer.Unpooled;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "多边形区域")
|
||||
@@ -39,7 +40,7 @@ public class JTPolygonArea implements JTAreaOrRoute{
|
||||
@Schema(description = "区域的名称")
|
||||
private String name;
|
||||
|
||||
public ByteBuf encode(){
|
||||
public ByteBuf encode(){
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeInt((int) (id & 0xffffffffL));
|
||||
byteBuf.writeBytes(attribute.encode());
|
||||
@@ -60,6 +61,35 @@ public class JTPolygonArea implements JTAreaOrRoute{
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public static JTPolygonArea decode(ByteBuf buf) {
|
||||
JTPolygonArea area = new JTPolygonArea();
|
||||
area.setId(buf.readUnsignedInt());
|
||||
int attributeInt = buf.readUnsignedShort();
|
||||
JTAreaAttribute areaAttribute = JTAreaAttribute.decode(attributeInt);
|
||||
area.setAttribute(areaAttribute);
|
||||
byte[] startTimeBytes = new byte[6];
|
||||
buf.readBytes(startTimeBytes);
|
||||
area.setStartTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(BCDUtil.transform(startTimeBytes)));
|
||||
byte[] endTimeBytes = new byte[6];
|
||||
buf.readBytes(endTimeBytes);
|
||||
area.setEndTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(BCDUtil.transform(endTimeBytes)));
|
||||
area.setMaxSpeed(buf.readUnsignedShort());
|
||||
area.setOverSpeedDuration(buf.readUnsignedByte());
|
||||
int polygonPointsSize = buf.readUnsignedShort();
|
||||
List<JTPolygonPoint> polygonPointList = new ArrayList<>(polygonPointsSize);
|
||||
for (int i = 0; i < polygonPointsSize; i++) {
|
||||
JTPolygonPoint polygonPoint = new JTPolygonPoint();
|
||||
polygonPoint.setLatitude(buf.readUnsignedInt()/1000000D);
|
||||
polygonPoint.setLongitude(buf.readUnsignedInt()/1000000D);
|
||||
polygonPointList.add(polygonPoint);
|
||||
}
|
||||
area.setPolygonPoints(polygonPointList);
|
||||
area.setNighttimeMaxSpeed(buf.readUnsignedShort());
|
||||
int nameLength = buf.readUnsignedShort();
|
||||
area.setName(buf.readCharSequence(nameLength, Charset.forName("GBK")).toString().trim());
|
||||
return area;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.netty.buffer.Unpooled;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "路线")
|
||||
@@ -30,7 +31,7 @@ public class JTRoute implements JTAreaOrRoute{
|
||||
@Schema(description = "区域的名称")
|
||||
private String name;
|
||||
|
||||
public ByteBuf encode(){
|
||||
public ByteBuf encode(){
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeInt((int) (id & 0xffffffffL));
|
||||
byteBuf.writeBytes(attribute.encode());
|
||||
@@ -47,6 +48,30 @@ public class JTRoute implements JTAreaOrRoute{
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public static JTRoute decode(ByteBuf buf) {
|
||||
JTRoute route = new JTRoute();
|
||||
route.setId(buf.readUnsignedInt());
|
||||
int attributeInt = buf.readUnsignedShort();
|
||||
JTRouteAttribute routeAttribute = JTRouteAttribute.decode(attributeInt);
|
||||
route.setAttribute(routeAttribute);
|
||||
byte[] startTimeBytes = new byte[6];
|
||||
buf.readBytes(startTimeBytes);
|
||||
route.setStartTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(BCDUtil.transform(startTimeBytes)));
|
||||
byte[] endTimeBytes = new byte[6];
|
||||
buf.readBytes(endTimeBytes);
|
||||
route.setEndTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(BCDUtil.transform(endTimeBytes)));
|
||||
|
||||
int routePointsSize = buf.readUnsignedShort();
|
||||
List<JTRoutePoint> jtRoutePoints = new ArrayList<>(routePointsSize);
|
||||
for (int i = 0; i < routePointsSize; i++) {
|
||||
jtRoutePoints.add(JTRoutePoint.decode(buf));
|
||||
}
|
||||
route.setRoutePointList(jtRoutePoints);
|
||||
int nameLength = buf.readUnsignedShort();
|
||||
route.setName(buf.readCharSequence(nameLength, Charset.forName("GBK")).toString().trim());
|
||||
return route;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,17 @@ public class JTRouteAttribute {
|
||||
byteBuf.writeShort((short)(content & 0xffff));
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public static JTRouteAttribute decode(int attributeInt) {
|
||||
JTRouteAttribute attribute = new JTRouteAttribute();
|
||||
attribute.setRuleForTimeLimit((attributeInt & 1) == 1);
|
||||
attribute.setRuleForAlarmToDriverWhenEnter((attributeInt >> 2 & 1) == 1);
|
||||
attribute.setRuleForAlarmToPlatformWhenEnter((attributeInt >> 3 & 1) == 1);
|
||||
attribute.setRuleForAlarmToDriverWhenExit((attributeInt >> 4 & 1) == 1);
|
||||
attribute.setRuleForAlarmToPlatformWhenExit((attributeInt >> 5 & 1) == 1);
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public boolean isRuleForTimeLimit() {
|
||||
return ruleForTimeLimit;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
package com.genersoft.iot.vmp.jt1078.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.util.BCDUtil;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@Schema(description = "路线拐点")
|
||||
public class JTRoutePoint {
|
||||
|
||||
@Schema(description = "拐点 ID")
|
||||
private int id;
|
||||
private long id;
|
||||
|
||||
@Schema(description = "路段 ID")
|
||||
private int routeSectionId;
|
||||
private long routeSectionId;
|
||||
|
||||
@Schema(description = "拐点纬度")
|
||||
private Double latitude;
|
||||
@@ -56,6 +60,25 @@ public class JTRoutePoint {
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public static JTRoutePoint decode(ByteBuf buf) {
|
||||
JTRoutePoint point = new JTRoutePoint();
|
||||
point.setId(buf.readUnsignedInt());
|
||||
point.setRouteSectionId(buf.readUnsignedInt());
|
||||
point.setLatitude(buf.readUnsignedInt()/1000000D);
|
||||
point.setLongitude(buf.readUnsignedInt()/1000000D);
|
||||
point.setRouteSectionAttributeWidth(buf.readUnsignedByte());
|
||||
|
||||
JTRouteSectionAttribute areaAttribute = JTRouteSectionAttribute.decode(buf.readUnsignedByte());
|
||||
point.setRouteSectionAttribute(areaAttribute);
|
||||
|
||||
point.setRouteSectionMaxLength(buf.readUnsignedShort());
|
||||
point.setRouteSectionMinLength(buf.readUnsignedShort());
|
||||
point.setRouteSectionMaxSpeed(buf.readUnsignedShort());
|
||||
point.setRouteSectionOverSpeedDuration(buf.readUnsignedByte());
|
||||
point.setRouteSectionNighttimeMaxSpeed(buf.readUnsignedShort());
|
||||
return point;
|
||||
}
|
||||
|
||||
public Double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
@@ -72,19 +95,19 @@ public class JTRoutePoint {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getRouteSectionId() {
|
||||
public long getRouteSectionId() {
|
||||
return routeSectionId;
|
||||
}
|
||||
|
||||
public void setRouteSectionId(int routeSectionId) {
|
||||
public void setRouteSectionId(long routeSectionId) {
|
||||
this.routeSectionId = routeSectionId;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class JTRouteSectionAttribute {
|
||||
|
||||
@Schema(description = "false:东经;true:西经")
|
||||
private boolean westLongitude;
|
||||
|
||||
|
||||
public byte encode(){
|
||||
byte attributeByte = 0;
|
||||
if (ruleForTimeLimit) {
|
||||
@@ -36,6 +36,15 @@ public class JTRouteSectionAttribute {
|
||||
return attributeByte;
|
||||
}
|
||||
|
||||
public static JTRouteSectionAttribute decode(short attributeShort) {
|
||||
JTRouteSectionAttribute attribute = new JTRouteSectionAttribute();
|
||||
attribute.setRuleForTimeLimit((attributeShort & 1) == 1);
|
||||
attribute.setRuleForSpeedLimit((attributeShort >> 1 & 1) == 1);
|
||||
attribute.setSouthLatitude((attributeShort >> 2 & 1) == 1);
|
||||
attribute.setWestLongitude((attributeShort >> 3 & 1) == 1);
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public boolean isRuleForTimeLimit() {
|
||||
return ruleForTimeLimit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user