From 58401b14447cca0f5593aec7af5e3a41361ba342 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sat, 4 May 2024 14:57:48 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E8=AE=BE=E7=BD=AE=E5=A4=9A=E8=BE=B9?= =?UTF-8?q?=E5=BD=A2=E5=8C=BA=E5=9F=9F...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/jt1078/bean/JTPolygonArea.java | 134 ++++++++++++++++++ .../iot/vmp/jt1078/bean/JTPolygonPoint.java | 38 +++++ .../jt1078/controller/bean/SetAreaParam.java | 13 ++ .../iot/vmp/jt1078/proc/response/J8604.java | 37 +++++ .../iot/vmp/jt1078/proc/response/J8605.java | 44 ++++++ 5 files changed, 266 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPolygonArea.java create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPolygonPoint.java create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8604.java create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8605.java diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPolygonArea.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPolygonArea.java new file mode 100644 index 000000000..ad1535b6a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPolygonArea.java @@ -0,0 +1,134 @@ +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; +import java.util.List; + +@Schema(description = "多边形区域") +public class JTPolygonArea { + + @Schema(description = "区域 ID") + private long id; + + @Schema(description = "") + private JTAreaAttribute attribute; + + @Schema(description = "起始时间, yyyy-MM-dd HH:mm:ss") + private String startTime; + + @Schema(description = "结束时间, yyyy-MM-dd HH:mm:ss") + private String endTime; + + @Schema(description = "最高速度, 单位为千米每小时(km/h)") + private int maxSpeed; + + @Schema(description = "超速持续时间, 单位为秒(s)") + private int overSpeedDuration; + + @Schema(description = "区域顶点") + private List polygonPoints; + + @Schema(description = "夜间最高速度, 单位为千米每小时(km/h)") + private int nighttimeMaxSpeed; + + @Schema(description = "区域的名称") + private String name; + + public ByteBuf encode(){ + ByteBuf byteBuf = Unpooled.buffer(); + byteBuf.writeInt((int) (id & 0xffffffffL)); + byteBuf.writeBytes(attribute.encode()); + byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime))); + byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime))); + byteBuf.writeShort((short)(maxSpeed & 0xffff)); + byteBuf.writeByte(overSpeedDuration); + + byteBuf.writeShort((short)(polygonPoints.size() & 0xffff)); + if (!polygonPoints.isEmpty()) { + for (JTPolygonPoint polygonPoint : polygonPoints) { + byteBuf.writeBytes(polygonPoint.encode()); + } + } + byteBuf.writeShort((short)(nighttimeMaxSpeed & 0xffff)); + byteBuf.writeShort((short)(name.getBytes(Charset.forName("GBK")).length & 0xffff)); + byteBuf.writeCharSequence(name, Charset.forName("GBK")); + return byteBuf; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public JTAreaAttribute getAttribute() { + return attribute; + } + + public void setAttribute(JTAreaAttribute attribute) { + this.attribute = attribute; + } + + public List getPolygonPoints() { + return polygonPoints; + } + + public void setPolygonPoints(List polygonPoints) { + this.polygonPoints = polygonPoints; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public int getMaxSpeed() { + return maxSpeed; + } + + public void setMaxSpeed(int maxSpeed) { + this.maxSpeed = maxSpeed; + } + + public int getOverSpeedDuration() { + return overSpeedDuration; + } + + public void setOverSpeedDuration(int overSpeedDuration) { + this.overSpeedDuration = overSpeedDuration; + } + + public int getNighttimeMaxSpeed() { + return nighttimeMaxSpeed; + } + + public void setNighttimeMaxSpeed(int nighttimeMaxSpeed) { + this.nighttimeMaxSpeed = nighttimeMaxSpeed; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPolygonPoint.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPolygonPoint.java new file mode 100644 index 000000000..ee9c0f715 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPolygonPoint.java @@ -0,0 +1,38 @@ +package com.genersoft.iot.vmp.jt1078.bean; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "多边形区域的顶点") +public class JTPolygonPoint { + + @Schema(description = "顶点纬度") + private Double latitude; + + @Schema(description = "顶点经度") + private Double longitude; + + public ByteBuf encode(){ + ByteBuf byteBuf = Unpooled.buffer(); + byteBuf.writeInt((int) (Math.round((latitude * 1000000)) & 0xffffffffL)); + byteBuf.writeInt((int) (Math.round((longitude * 1000000)) & 0xffffffffL)); + return byteBuf; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/SetAreaParam.java b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/SetAreaParam.java index fe19ab944..8a40ec080 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/SetAreaParam.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/SetAreaParam.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.jt1078.controller.bean; import com.genersoft.iot.vmp.jt1078.bean.JTCircleArea; import com.genersoft.iot.vmp.jt1078.bean.JTPhoneBookContact; +import com.genersoft.iot.vmp.jt1078.bean.JTPolygonArea; import com.genersoft.iot.vmp.jt1078.bean.JTRectangleArea; import io.swagger.v3.oas.annotations.media.Schema; @@ -19,6 +20,9 @@ public class SetAreaParam { @Schema(description = "矩形区域项") private List rectangleAreas; + @Schema(description = "多边形区域") + private JTPolygonArea polygonArea; + public String getDeviceId() { return deviceId; @@ -44,12 +48,21 @@ public class SetAreaParam { this.rectangleAreas = rectangleAreas; } + public JTPolygonArea getPolygonArea() { + return polygonArea; + } + + public void setPolygonArea(JTPolygonArea polygonArea) { + this.polygonArea = polygonArea; + } + @Override public String toString() { return "SetAreaParam{" + "deviceId='" + deviceId + '\'' + ", circleAreaList=" + circleAreaList + ", rectangleAreas=" + rectangleAreas + + ", polygonArea=" + polygonArea + '}'; } } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8604.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8604.java new file mode 100644 index 000000000..f95b4934b --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8604.java @@ -0,0 +1,37 @@ +package com.genersoft.iot.vmp.jt1078.proc.response; + +import com.genersoft.iot.vmp.jt1078.annotation.MsgId; +import com.genersoft.iot.vmp.jt1078.bean.JTPolygonArea; +import com.genersoft.iot.vmp.jt1078.bean.JTRectangleArea; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +import java.util.List; + +/** + * 设置多边形区域 + */ +@MsgId(id = "8604") +public class J8604 extends Rs { + + /** + * 多边形区域 + */ + private JTPolygonArea polygonArea; + + + @Override + public ByteBuf encode() { + ByteBuf buffer = Unpooled.buffer(); + buffer.writeBytes(polygonArea.encode()); + return buffer; + } + + public JTPolygonArea getPolygonArea() { + return polygonArea; + } + + public void setPolygonArea(JTPolygonArea polygonArea) { + this.polygonArea = polygonArea; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8605.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8605.java new file mode 100644 index 000000000..2bcf3cefc --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8605.java @@ -0,0 +1,44 @@ +package com.genersoft.iot.vmp.jt1078.proc.response; + +import com.genersoft.iot.vmp.jt1078.annotation.MsgId; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +import java.util.List; + +/** + * 删除多边形区域 + */ +@MsgId(id = "8605") +public class J8605 extends Rs { + + + /** + * 待删除的区域ID + */ + private List idList; + + + @Override + public ByteBuf encode() { + ByteBuf buffer = Unpooled.buffer(); + if (idList == null || idList.isEmpty()) { + buffer.writeByte(0); + return buffer; + }else { + buffer.writeByte(idList.size()); + } + for (Long id : idList) { + buffer.writeInt((int) (id & 0xffffffffL)); + } + return buffer; + } + + public List getIdList() { + return idList; + } + + public void setIdList(List idList) { + this.idList = idList; + } +}