1078-设置路线...

This commit is contained in:
648540858
2024-05-04 23:19:27 +08:00
parent a3149139e2
commit 9280b57974
11 changed files with 606 additions and 4 deletions

View File

@@ -0,0 +1,110 @@
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 JTRoute {
@Schema(description = "路线 ID")
private long id;
@Schema(description = "路线属性")
private JTRouteAttribute 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 = "路线拐点")
private List<JTRoutePoint> routePointList;
@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)(routePointList.size() & 0xffff));
byteBuf.writeShort((short)(0 & 0xffff));
// if (!routePointList.isEmpty()){
// for (JTRoutePoint jtRoutePoint : routePointList) {
// byteBuf.writeBytes(jtRoutePoint.encode());
// }
// }
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 JTRouteAttribute getAttribute() {
return attribute;
}
public void setAttribute(JTRouteAttribute attribute) {
this.attribute = attribute;
}
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 List<JTRoutePoint> getRoutePointList() {
return routePointList;
}
public void setRoutePointList(List<JTRoutePoint> routePointList) {
this.routePointList = routePointList;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "JTRoute{" +
"id=" + id +
", attribute=" + attribute +
", startTime='" + startTime + '\'' +
", endTime='" + endTime + '\'' +
", routePointList=" + routePointList +
", name='" + name + '\'' +
'}';
}
}

View File

@@ -0,0 +1,96 @@
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 JTRouteAttribute {
@Schema(description = "是否启用起始时间与结束时间的判断规则 ,falsetrue")
private boolean ruleForTimeLimit;
@Schema(description = "进区域是否报警给驾驶员,falsetrue")
private boolean ruleForAlarmToDriverWhenEnter;
@Schema(description = "进区域是否报警给平台 ,falsetrue")
private boolean ruleForAlarmToPlatformWhenEnter;
@Schema(description = "出区域是否报警给驾驶员,falsetrue")
private boolean ruleForAlarmToDriverWhenExit;
@Schema(description = "出区域是否报警给平台 ,falsetrue")
private boolean ruleForAlarmToPlatformWhenExit;
public ByteBuf encode(){
ByteBuf byteBuf = Unpooled.buffer();
byte[] bytes = new byte[2];
if (ruleForTimeLimit) {
bytes[0] |= 1;
}
if (ruleForAlarmToDriverWhenEnter) {
bytes[0] |= (1 << 2);
}
if (ruleForAlarmToPlatformWhenEnter) {
bytes[0] |= (1 << 3);
}
if (ruleForAlarmToDriverWhenExit) {
bytes[0] |= (1 << 4);
}
if (ruleForAlarmToPlatformWhenExit) {
bytes[0] |= (1 << 5);
}
byteBuf.writeBytes(bytes);
return byteBuf;
}
public boolean isRuleForTimeLimit() {
return ruleForTimeLimit;
}
public void setRuleForTimeLimit(boolean ruleForTimeLimit) {
this.ruleForTimeLimit = ruleForTimeLimit;
}
public boolean isRuleForAlarmToDriverWhenEnter() {
return ruleForAlarmToDriverWhenEnter;
}
public void setRuleForAlarmToDriverWhenEnter(boolean ruleForAlarmToDriverWhenEnter) {
this.ruleForAlarmToDriverWhenEnter = ruleForAlarmToDriverWhenEnter;
}
public boolean isRuleForAlarmToPlatformWhenEnter() {
return ruleForAlarmToPlatformWhenEnter;
}
public void setRuleForAlarmToPlatformWhenEnter(boolean ruleForAlarmToPlatformWhenEnter) {
this.ruleForAlarmToPlatformWhenEnter = ruleForAlarmToPlatformWhenEnter;
}
public boolean isRuleForAlarmToDriverWhenExit() {
return ruleForAlarmToDriverWhenExit;
}
public void setRuleForAlarmToDriverWhenExit(boolean ruleForAlarmToDriverWhenExit) {
this.ruleForAlarmToDriverWhenExit = ruleForAlarmToDriverWhenExit;
}
public boolean isRuleForAlarmToPlatformWhenExit() {
return ruleForAlarmToPlatformWhenExit;
}
public void setRuleForAlarmToPlatformWhenExit(boolean ruleForAlarmToPlatformWhenExit) {
this.ruleForAlarmToPlatformWhenExit = ruleForAlarmToPlatformWhenExit;
}
@Override
public String toString() {
return "JTRouteAttribute{" +
"ruleForTimeLimit=" + ruleForTimeLimit +
", ruleForAlarmToDriverWhenEnter=" + ruleForAlarmToDriverWhenEnter +
", ruleForAlarmToPlatformWhenEnter=" + ruleForAlarmToPlatformWhenEnter +
", ruleForAlarmToDriverWhenExit=" + ruleForAlarmToDriverWhenExit +
", ruleForAlarmToPlatformWhenExit=" + ruleForAlarmToPlatformWhenExit +
'}';
}
}

View File

@@ -0,0 +1,163 @@
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 JTRoutePoint {
@Schema(description = "拐点 ID")
private int id;
@Schema(description = "路段 ID")
private int routeSectionId;
@Schema(description = "拐点纬度")
private Double latitude;
@Schema(description = "拐点经度")
private Double longitude;
@Schema(description = "路段宽度")
private int routeSectionAttributeWidth;
@Schema(description = "路段属性")
private JTRouteSectionAttribute routeSectionAttribute;
@Schema(description = "路段行驶过长國值")
private int routeSectionMaxLength;
@Schema(description = "路段行驶不足國值")
private int routeSectionMinLength;
@Schema(description = "路段最高速度")
private int routeSectionMaxSpeed;
@Schema(description = "路段超速持续时间")
private int routeSectionOverSpeedDuration;
@Schema(description = "路段夜间最高速度")
private int routeSectionNighttimeMaxSpeed;
public ByteBuf encode(){
ByteBuf byteBuf = Unpooled.buffer();
byteBuf.writeInt((int) (id & 0xffffffffL));
byteBuf.writeInt((int) (routeSectionId & 0xffffffffL));
byteBuf.writeInt((int) (Math.round((latitude * 1000000)) & 0xffffffffL));
byteBuf.writeInt((int) (Math.round((longitude * 1000000)) & 0xffffffffL));
byteBuf.writeByte(routeSectionAttributeWidth);
byteBuf.writeByte(routeSectionAttribute.encode());
byteBuf.writeShort((short)(routeSectionMaxLength & 0xffff));
byteBuf.writeShort((short)(routeSectionMinLength & 0xffff));
byteBuf.writeShort((short)(routeSectionMaxSpeed & 0xffff));
byteBuf.writeByte(routeSectionOverSpeedDuration);
byteBuf.writeShort((short)(routeSectionNighttimeMaxSpeed & 0xffff));
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;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getRouteSectionId() {
return routeSectionId;
}
public void setRouteSectionId(int routeSectionId) {
this.routeSectionId = routeSectionId;
}
public int getRouteSectionAttributeWidth() {
return routeSectionAttributeWidth;
}
public void setRouteSectionAttributeWidth(int routeSectionAttributeWidth) {
this.routeSectionAttributeWidth = routeSectionAttributeWidth;
}
public JTRouteSectionAttribute getRouteSectionAttribute() {
return routeSectionAttribute;
}
public void setRouteSectionAttribute(JTRouteSectionAttribute routeSectionAttribute) {
this.routeSectionAttribute = routeSectionAttribute;
}
public int getRouteSectionMaxLength() {
return routeSectionMaxLength;
}
public void setRouteSectionMaxLength(int routeSectionMaxLength) {
this.routeSectionMaxLength = routeSectionMaxLength;
}
public int getRouteSectionMinLength() {
return routeSectionMinLength;
}
public void setRouteSectionMinLength(int routeSectionMinLength) {
this.routeSectionMinLength = routeSectionMinLength;
}
public int getRouteSectionMaxSpeed() {
return routeSectionMaxSpeed;
}
public void setRouteSectionMaxSpeed(int routeSectionMaxSpeed) {
this.routeSectionMaxSpeed = routeSectionMaxSpeed;
}
public int getRouteSectionOverSpeedDuration() {
return routeSectionOverSpeedDuration;
}
public void setRouteSectionOverSpeedDuration(int routeSectionOverSpeedDuration) {
this.routeSectionOverSpeedDuration = routeSectionOverSpeedDuration;
}
public int getRouteSectionNighttimeMaxSpeed() {
return routeSectionNighttimeMaxSpeed;
}
public void setRouteSectionNighttimeMaxSpeed(int routeSectionNighttimeMaxSpeed) {
this.routeSectionNighttimeMaxSpeed = routeSectionNighttimeMaxSpeed;
}
@Override
public String toString() {
return "JTRoutePoint{" +
"id=" + id +
", routeSectionId=" + routeSectionId +
", latitude=" + latitude +
", longitude=" + longitude +
", routeSectionAttributeWidth=" + routeSectionAttributeWidth +
", routeSectionAttribute=" + routeSectionAttribute +
", routeSectionMaxLength=" + routeSectionMaxLength +
", routeSectionMinLength=" + routeSectionMinLength +
", routeSectionMaxSpeed=" + routeSectionMaxSpeed +
", routeSectionOverSpeedDuration=" + routeSectionOverSpeedDuration +
", routeSectionNighttimeMaxSpeed=" + routeSectionNighttimeMaxSpeed +
'}';
}
}

View File

@@ -0,0 +1,70 @@
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 JTRouteSectionAttribute {
@Schema(description = "行驶时间 ,falsetrue")
private boolean ruleForTimeLimit;
@Schema(description = "限速 ,falsetrue")
private boolean ruleForSpeedLimit;
@Schema(description = "false北纬true南纬")
private boolean southLatitude;
@Schema(description = "false东经true西经")
private boolean westLongitude;
public byte encode(){
byte attributeByte = 0;
if (ruleForTimeLimit) {
attributeByte |= 1;
}
if (ruleForSpeedLimit) {
attributeByte |= (1 << 1);
}
if (southLatitude) {
attributeByte |= (1 << 2);
}
if (westLongitude) {
attributeByte |= (1 << 3);
}
return attributeByte;
}
public boolean isRuleForTimeLimit() {
return ruleForTimeLimit;
}
public void setRuleForTimeLimit(boolean ruleForTimeLimit) {
this.ruleForTimeLimit = ruleForTimeLimit;
}
public boolean isRuleForSpeedLimit() {
return ruleForSpeedLimit;
}
public void setRuleForSpeedLimit(boolean ruleForSpeedLimit) {
this.ruleForSpeedLimit = ruleForSpeedLimit;
}
public boolean isSouthLatitude() {
return southLatitude;
}
public void setSouthLatitude(boolean southLatitude) {
this.southLatitude = southLatitude;
}
public boolean isWestLongitude() {
return westLongitude;
}
public void setWestLongitude(boolean westLongitude) {
this.westLongitude = westLongitude;
}
}

View File

@@ -36,6 +36,8 @@ public class JT1078Template {
private static final String H8603 = "8603";
private static final String H8604 = "8604";
private static final String H8605 = "8605";
private static final String H8606 = "8606";
private static final String H8607 = "8607";
private static final String H9101 = "9101";
private static final String H9102 = "9102";
private static final String H9201 = "9201";
@@ -517,4 +519,26 @@ public class JT1078Template {
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
public Object setRoute(String devId, J8606 j8606, int timeOut) {
Cmd cmd = new Cmd.Builder()
.setDevId(devId)
.setPackageNo(randomInt())
.setMsgId(H8606)
.setRespId(H0001)
.setRs(j8606)
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
public Object deleteRoute(String devId, J8607 j8607, int timeOut) {
Cmd cmd = new Cmd.Builder()
.setDevId(devId)
.setPackageNo(randomInt())
.setMsgId(H8607)
.setRespId(H0001)
.setRs(j8607)
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
}

View File

@@ -645,5 +645,38 @@ public class JT1078Controller {
}
}
@Operation(summary = "1078-设置路线", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
@PostMapping("/route/set")
public WVPResult<Integer> setRoute(@RequestBody SetAreaParam areaParam){
logger.info("[1078-设置路线] areaParam: {},", areaParam);
int result = service.setRoute(areaParam.getDeviceId(), areaParam.getRoute());
if (result == 0) {
return WVPResult.success(result);
}else {
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
fail.setData(result);
return fail;
}
}
@Operation(summary = "1078-删除路线", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备编号", required = true)
@Parameter(name = "ids", description = "待删除圆形区域的id例如1,2,3", required = true)
@GetMapping("/route/delete")
public WVPResult<Integer> deleteRoute(String deviceId, @RequestParam(value = "ids", required = false) List<Long> ids){
logger.info("[1078-删除路线] deviceId: {}, ids:{}", deviceId, ids);
int result = service.deleteRoute(deviceId, ids);
if (result == 0) {
return WVPResult.success(result);
}else {
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
fail.setData(result);
return fail;
}
}
}

View File

@@ -1,9 +1,6 @@
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 com.genersoft.iot.vmp.jt1078.bean.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
@@ -23,6 +20,9 @@ public class SetAreaParam {
@Schema(description = "多边形区域")
private JTPolygonArea polygonArea;
@Schema(description = "路线")
private JTRoute route;
public String getDeviceId() {
return deviceId;
@@ -56,6 +56,14 @@ public class SetAreaParam {
this.polygonArea = polygonArea;
}
public JTRoute getRoute() {
return route;
}
public void setRoute(JTRoute route) {
this.route = route;
}
@Override
public String toString() {
return "SetAreaParam{" +
@@ -63,6 +71,7 @@ public class SetAreaParam {
", circleAreaList=" + circleAreaList +
", rectangleAreas=" + rectangleAreas +
", polygonArea=" + polygonArea +
", route=" + route +
'}';
}
}

View File

@@ -0,0 +1,35 @@
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.JTRoute;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
/**
* 设置路线
*/
@MsgId(id = "8606")
public class J8606 extends Rs {
/**
* 路线
*/
private JTRoute route;
@Override
public ByteBuf encode() {
ByteBuf buffer = Unpooled.buffer();
buffer.writeBytes(route.encode());
return buffer;
}
public JTRoute getRoute() {
return route;
}
public void setRoute(JTRoute route) {
this.route = route;
}
}

View File

@@ -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 J8607 extends Rs {
/**
* 待删除的路线ID
*/
private List<Long> 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<Long> getIdList() {
return idList;
}
public void setIdList(List<Long> idList) {
this.idList = idList;
}
}

View File

@@ -81,4 +81,8 @@ public interface Ijt1078Service {
int setAreaForPolygon(String deviceId, JTPolygonArea polygonArea);
int deleteAreaForPolygon(String deviceId, List<Long> ids);
int setRoute(String deviceId, JTRoute route);
int deleteRoute(String deviceId, List<Long> ids);
}

View File

@@ -653,4 +653,18 @@ public class jt1078ServiceImpl implements Ijt1078Service {
j8605.setIdList(ids);
return (int)jt1078Template.deleteAreaForPolygon(deviceId, j8605, 20);
}
@Override
public int setRoute(String deviceId, JTRoute route) {
J8606 j8606 = new J8606();
j8606.setRoute(route);
return (int)jt1078Template.setRoute(deviceId, j8606, 20);
}
@Override
public int deleteRoute(String deviceId, List<Long> ids) {
J8607 j8607 = new J8607();
j8607.setIdList(ids);
return (int)jt1078Template.deleteRoute(deviceId, j8607, 20);
}
}