mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-23 21:47:49 +08:00
1078-查询区域或线路数据
This commit is contained in:
parent
2112fffc26
commit
ad67155d73
@ -45,7 +45,7 @@ public class JTCircleArea implements JTAreaOrRoute{
|
|||||||
@Schema(description = "区域的名称")
|
@Schema(description = "区域的名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public ByteBuf encode(){
|
public ByteBuf encode(){
|
||||||
ByteBuf byteBuf = Unpooled.buffer();
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
byteBuf.writeInt((int) (id & 0xffffffffL));
|
byteBuf.writeInt((int) (id & 0xffffffffL));
|
||||||
byteBuf.writeBytes(attribute.encode());
|
byteBuf.writeBytes(attribute.encode());
|
||||||
@ -62,6 +62,31 @@ public class JTCircleArea implements JTAreaOrRoute{
|
|||||||
return byteBuf;
|
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() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import io.netty.buffer.Unpooled;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "多边形区域")
|
@Schema(description = "多边形区域")
|
||||||
@ -39,7 +40,7 @@ public class JTPolygonArea implements JTAreaOrRoute{
|
|||||||
@Schema(description = "区域的名称")
|
@Schema(description = "区域的名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public ByteBuf encode(){
|
public ByteBuf encode(){
|
||||||
ByteBuf byteBuf = Unpooled.buffer();
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
byteBuf.writeInt((int) (id & 0xffffffffL));
|
byteBuf.writeInt((int) (id & 0xffffffffL));
|
||||||
byteBuf.writeBytes(attribute.encode());
|
byteBuf.writeBytes(attribute.encode());
|
||||||
@ -60,6 +61,35 @@ public class JTPolygonArea implements JTAreaOrRoute{
|
|||||||
return byteBuf;
|
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() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import io.netty.buffer.Unpooled;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "路线")
|
@Schema(description = "路线")
|
||||||
@ -30,7 +31,7 @@ public class JTRoute implements JTAreaOrRoute{
|
|||||||
@Schema(description = "区域的名称")
|
@Schema(description = "区域的名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public ByteBuf encode(){
|
public ByteBuf encode(){
|
||||||
ByteBuf byteBuf = Unpooled.buffer();
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
byteBuf.writeInt((int) (id & 0xffffffffL));
|
byteBuf.writeInt((int) (id & 0xffffffffL));
|
||||||
byteBuf.writeBytes(attribute.encode());
|
byteBuf.writeBytes(attribute.encode());
|
||||||
@ -47,6 +48,30 @@ public class JTRoute implements JTAreaOrRoute{
|
|||||||
return byteBuf;
|
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() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,17 @@ public class JTRouteAttribute {
|
|||||||
byteBuf.writeShort((short)(content & 0xffff));
|
byteBuf.writeShort((short)(content & 0xffff));
|
||||||
return byteBuf;
|
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() {
|
public boolean isRuleForTimeLimit() {
|
||||||
return ruleForTimeLimit;
|
return ruleForTimeLimit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,21 @@
|
|||||||
package com.genersoft.iot.vmp.jt1078.bean;
|
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.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
@Schema(description = "路线拐点")
|
@Schema(description = "路线拐点")
|
||||||
public class JTRoutePoint {
|
public class JTRoutePoint {
|
||||||
|
|
||||||
@Schema(description = "拐点 ID")
|
@Schema(description = "拐点 ID")
|
||||||
private int id;
|
private long id;
|
||||||
|
|
||||||
@Schema(description = "路段 ID")
|
@Schema(description = "路段 ID")
|
||||||
private int routeSectionId;
|
private long routeSectionId;
|
||||||
|
|
||||||
@Schema(description = "拐点纬度")
|
@Schema(description = "拐点纬度")
|
||||||
private Double latitude;
|
private Double latitude;
|
||||||
@ -56,6 +60,25 @@ public class JTRoutePoint {
|
|||||||
return byteBuf;
|
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() {
|
public Double getLatitude() {
|
||||||
return latitude;
|
return latitude;
|
||||||
}
|
}
|
||||||
@ -72,19 +95,19 @@ public class JTRoutePoint {
|
|||||||
this.longitude = longitude;
|
this.longitude = longitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRouteSectionId() {
|
public long getRouteSectionId() {
|
||||||
return routeSectionId;
|
return routeSectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRouteSectionId(int routeSectionId) {
|
public void setRouteSectionId(long routeSectionId) {
|
||||||
this.routeSectionId = routeSectionId;
|
this.routeSectionId = routeSectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ public class JTRouteSectionAttribute {
|
|||||||
|
|
||||||
@Schema(description = "false:东经;true:西经")
|
@Schema(description = "false:东经;true:西经")
|
||||||
private boolean westLongitude;
|
private boolean westLongitude;
|
||||||
|
|
||||||
public byte encode(){
|
public byte encode(){
|
||||||
byte attributeByte = 0;
|
byte attributeByte = 0;
|
||||||
if (ruleForTimeLimit) {
|
if (ruleForTimeLimit) {
|
||||||
@ -36,6 +36,15 @@ public class JTRouteSectionAttribute {
|
|||||||
return attributeByte;
|
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() {
|
public boolean isRuleForTimeLimit() {
|
||||||
return ruleForTimeLimit;
|
return ruleForTimeLimit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -538,7 +538,7 @@ public class JT1078Template {
|
|||||||
.setDevId(devId)
|
.setDevId(devId)
|
||||||
.setPackageNo(randomInt())
|
.setPackageNo(randomInt())
|
||||||
.setMsgId(H8607)
|
.setMsgId(H8607)
|
||||||
.setRespId(H0608)
|
.setRespId(H0001)
|
||||||
.setRs(j8607)
|
.setRs(j8607)
|
||||||
.build();
|
.build();
|
||||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||||
@ -549,7 +549,7 @@ public class JT1078Template {
|
|||||||
.setDevId(devId)
|
.setDevId(devId)
|
||||||
.setPackageNo(randomInt())
|
.setPackageNo(randomInt())
|
||||||
.setMsgId(H8608)
|
.setMsgId(H8608)
|
||||||
.setRespId(H0001)
|
.setRespId(H0608)
|
||||||
.setRs(j8608)
|
.setRs(j8608)
|
||||||
.build();
|
.build();
|
||||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||||
|
|||||||
@ -546,6 +546,20 @@ public class JT1078Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "1078-查询圆形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
|
@Parameter(name = "deviceId", description = "设备编号", required = true)
|
||||||
|
@GetMapping("/area/circle/query")
|
||||||
|
public WVPResult<List<JTAreaOrRoute>> queryAreaForCircle(String deviceId, @RequestParam(value = "ids", required = false) List<Long> ids){
|
||||||
|
|
||||||
|
logger.info("[1078-查询圆形区域] deviceId: {}, ids:{}", deviceId, ids);
|
||||||
|
List<JTAreaOrRoute> result = service.queryAreaForCircle(deviceId, ids);
|
||||||
|
if (result != null) {
|
||||||
|
return WVPResult.success(result);
|
||||||
|
}else {
|
||||||
|
return WVPResult.fail(ErrorCode.ERROR100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "1078-更新矩形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "1078-更新矩形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
||||||
@ -612,6 +626,20 @@ public class JT1078Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "1078-查询矩形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
|
@Parameter(name = "deviceId", description = "设备编号", required = true)
|
||||||
|
@GetMapping("/area/rectangle/query")
|
||||||
|
public WVPResult<List<JTAreaOrRoute>> queryAreaForRectangle(String deviceId, @RequestParam(value = "ids", required = false) List<Long> ids){
|
||||||
|
|
||||||
|
logger.info("[1078-查询矩形区域] deviceId: {}, ids:{}", deviceId, ids);
|
||||||
|
List<JTAreaOrRoute> result = service.queryAreaForRectangle(deviceId, ids);
|
||||||
|
if (result != null) {
|
||||||
|
return WVPResult.success(result);
|
||||||
|
}else {
|
||||||
|
return WVPResult.fail(ErrorCode.ERROR100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "1078-设置多边形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "1078-设置多边形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
||||||
@PostMapping("/area/polygon/set")
|
@PostMapping("/area/polygon/set")
|
||||||
@ -645,6 +673,20 @@ public class JT1078Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "1078-查询多边形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
|
@Parameter(name = "deviceId", description = "设备编号", required = true)
|
||||||
|
@GetMapping("/area/polygon/query")
|
||||||
|
public WVPResult<List<JTAreaOrRoute>> queryAreaForPolygon(String deviceId, @RequestParam(value = "ids", required = false) List<Long> ids){
|
||||||
|
|
||||||
|
logger.info("[1078-查询多边形区域] deviceId: {}, ids:{}", deviceId, ids);
|
||||||
|
List<JTAreaOrRoute> result = service.queryAreaForPolygon(deviceId, ids);
|
||||||
|
if (result != null) {
|
||||||
|
return WVPResult.success(result);
|
||||||
|
}else {
|
||||||
|
return WVPResult.fail(ErrorCode.ERROR100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "1078-设置路线", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "1078-设置路线", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
||||||
@PostMapping("/route/set")
|
@PostMapping("/route/set")
|
||||||
@ -681,18 +723,15 @@ public class JT1078Controller {
|
|||||||
@Operation(summary = "1078-查询路线", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "1078-查询路线", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备编号", required = true)
|
@Parameter(name = "deviceId", description = "设备编号", required = true)
|
||||||
@GetMapping("/route/query")
|
@GetMapping("/route/query")
|
||||||
public WVPResult<Integer> queryRoute(String deviceId, @RequestParam(value = "ids", required = false) List<Long> ids){
|
public WVPResult<List<JTAreaOrRoute>> queryRoute(String deviceId, @RequestParam(value = "ids", required = false) List<Long> ids){
|
||||||
|
|
||||||
logger.info("[1078-查询路线] deviceId: {}, ids:{}", deviceId, ids);
|
logger.info("[1078-查询路线] deviceId: {}, ids:{}", deviceId, ids);
|
||||||
int result = service.queryRoute(deviceId, ids);
|
List<JTAreaOrRoute> result = service.queryRoute(deviceId, ids);
|
||||||
if (result == 0) {
|
if (result != null) {
|
||||||
return WVPResult.success(result);
|
return WVPResult.success(result);
|
||||||
}else {
|
}else {
|
||||||
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
|
return WVPResult.fail(ErrorCode.ERROR100);
|
||||||
fail.setData(result);
|
|
||||||
return fail;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,8 +38,10 @@ public class J0608 extends Re {
|
|||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 1:
|
case 1:
|
||||||
|
buf.readUnsignedByte();
|
||||||
|
int areaLengthForCircleArea = buf.readUnsignedByte();
|
||||||
List<JTCircleArea> jtCircleAreas = new ArrayList<>();
|
List<JTCircleArea> jtCircleAreas = new ArrayList<>();
|
||||||
for (int i = 0; i < dataLength; i++) {
|
for (int i = 0; i < areaLengthForCircleArea; i++) {
|
||||||
// 查询圆形区域数据
|
// 查询圆形区域数据
|
||||||
JTCircleArea jtCircleArea = JTCircleArea.decode(buf);
|
JTCircleArea jtCircleArea = JTCircleArea.decode(buf);
|
||||||
jtCircleAreas.add(jtCircleArea);
|
jtCircleAreas.add(jtCircleArea);
|
||||||
@ -47,9 +49,11 @@ public class J0608 extends Re {
|
|||||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0608", null, jtCircleAreas);
|
SessionManager.INSTANCE.response(header.getTerminalId(), "0608", null, jtCircleAreas);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
buf.readUnsignedByte();
|
||||||
|
int areaLengthForRectangleArea = buf.readUnsignedByte();
|
||||||
// 查询矩形区域数据
|
// 查询矩形区域数据
|
||||||
List<JTRectangleArea> jtRectangleAreas = new ArrayList<>();
|
List<JTRectangleArea> jtRectangleAreas = new ArrayList<>();
|
||||||
for (int i = 0; i < dataLength; i++) {
|
for (int i = 0; i < areaLengthForRectangleArea; i++) {
|
||||||
// 查询圆形区域数据
|
// 查询圆形区域数据
|
||||||
JTRectangleArea jtRectangleArea = JTRectangleArea.decode(buf);
|
JTRectangleArea jtRectangleArea = JTRectangleArea.decode(buf);
|
||||||
jtRectangleAreas.add(jtRectangleArea);
|
jtRectangleAreas.add(jtRectangleArea);
|
||||||
@ -68,9 +72,13 @@ public class J0608 extends Re {
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
// 查询线路数据
|
// 查询线路数据
|
||||||
// 查询多 边形区域数据
|
List<JTRoute> jtRoutes = new ArrayList<>();
|
||||||
JTPolygonArea jtPolygonArea = JTPolygonArea.decode(buf);
|
for (int i = 0; i < dataLength; i++) {
|
||||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0608", null, jtPolygonArea);
|
// 查询圆形区域数据
|
||||||
|
JTRoute jtRoute = JTRoute.decode(buf);
|
||||||
|
jtRoutes.add(jtRoute);
|
||||||
|
}
|
||||||
|
SessionManager.INSTANCE.response(header.getTerminalId(), "0608", null, jtRoutes);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -81,19 +89,9 @@ public class J0608 extends Re {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
||||||
JTDevice deviceInDb = service.getDevice(header.getTerminalId());
|
|
||||||
J8001 j8001 = new J8001();
|
J8001 j8001 = new J8001();
|
||||||
j8001.setRespNo(header.getSn());
|
j8001.setRespNo(header.getSn());
|
||||||
j8001.setRespId(header.getMsgId());
|
j8001.setRespId(header.getMsgId());
|
||||||
if (deviceInDb == null) {
|
|
||||||
j8001.setResult(J8001.FAIL);
|
|
||||||
}else {
|
|
||||||
// TODO 优化为发送异步事件,定时读取队列写入数据库
|
|
||||||
deviceInDb.setLongitude(positionInfo.getLongitude());
|
|
||||||
deviceInDb.setLatitude(positionInfo.getLatitude());
|
|
||||||
service.updateDevice(deviceInDb);
|
|
||||||
j8001.setResult(J8001.SUCCESS);
|
|
||||||
}
|
|
||||||
return j8001;
|
return j8001;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -74,23 +74,23 @@ public interface Ijt1078Service {
|
|||||||
|
|
||||||
int deleteAreaForCircle(String deviceId, List<Long> ids);
|
int deleteAreaForCircle(String deviceId, List<Long> ids);
|
||||||
|
|
||||||
int queryAreaForCircle(String deviceId, List<Long> ids);
|
List<JTAreaOrRoute> queryAreaForCircle(String deviceId, List<Long> ids);
|
||||||
|
|
||||||
int setAreaForRectangle(int i, String deviceId, List<JTRectangleArea> rectangleAreas);
|
int setAreaForRectangle(int i, String deviceId, List<JTRectangleArea> rectangleAreas);
|
||||||
|
|
||||||
int deleteAreaForRectangle(String deviceId, List<Long> ids);
|
int deleteAreaForRectangle(String deviceId, List<Long> ids);
|
||||||
|
|
||||||
int queryAreaForRectangle(String deviceId, List<Long> ids);
|
List<JTAreaOrRoute> queryAreaForRectangle(String deviceId, List<Long> ids);
|
||||||
|
|
||||||
int setAreaForPolygon(String deviceId, JTPolygonArea polygonArea);
|
int setAreaForPolygon(String deviceId, JTPolygonArea polygonArea);
|
||||||
|
|
||||||
int deleteAreaForPolygon(String deviceId, List<Long> ids);
|
int deleteAreaForPolygon(String deviceId, List<Long> ids);
|
||||||
|
|
||||||
int queryAreaForPolygon(String deviceId, List<Long> ids);
|
List<JTAreaOrRoute> queryAreaForPolygon(String deviceId, List<Long> ids);
|
||||||
|
|
||||||
int setRoute(String deviceId, JTRoute route);
|
int setRoute(String deviceId, JTRoute route);
|
||||||
|
|
||||||
int deleteRoute(String deviceId, List<Long> ids);
|
int deleteRoute(String deviceId, List<Long> ids);
|
||||||
|
|
||||||
int queryRoute(String deviceId, List<Long> ids);
|
List<JTAreaOrRoute> queryRoute(String deviceId, List<Long> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -626,11 +626,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int queryAreaForCircle(String deviceId, List<Long> ids) {
|
public List<JTAreaOrRoute> queryAreaForCircle(String deviceId, List<Long> ids) {
|
||||||
J8608 j8608 = new J8608();
|
J8608 j8608 = new J8608();
|
||||||
j8608.setType(1);
|
j8608.setType(1);
|
||||||
j8608.setIdList(ids);
|
j8608.setIdList(ids);
|
||||||
return (int)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
return (List<JTAreaOrRoute>)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -649,11 +649,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int queryAreaForRectangle(String deviceId, List<Long> ids) {
|
public List<JTAreaOrRoute> queryAreaForRectangle(String deviceId, List<Long> ids) {
|
||||||
J8608 j8608 = new J8608();
|
J8608 j8608 = new J8608();
|
||||||
j8608.setType(2);
|
j8608.setType(2);
|
||||||
j8608.setIdList(ids);
|
j8608.setIdList(ids);
|
||||||
return (int)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
return (List<JTAreaOrRoute>)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -671,11 +671,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int queryAreaForPolygon(String deviceId, List<Long> ids) {
|
public List<JTAreaOrRoute> queryAreaForPolygon(String deviceId, List<Long> ids) {
|
||||||
J8608 j8608 = new J8608();
|
J8608 j8608 = new J8608();
|
||||||
j8608.setType(3);
|
j8608.setType(3);
|
||||||
j8608.setIdList(ids);
|
j8608.setIdList(ids);
|
||||||
return (int)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
return (List<JTAreaOrRoute>)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -693,10 +693,10 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int queryRoute(String deviceId, List<Long> ids) {
|
public List<JTAreaOrRoute> queryRoute(String deviceId, List<Long> ids) {
|
||||||
J8608 j8608 = new J8608();
|
J8608 j8608 = new J8608();
|
||||||
j8608.setType(4);
|
j8608.setType(4);
|
||||||
j8608.setIdList(ids);
|
j8608.setIdList(ids);
|
||||||
return (int)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
return (List<JTAreaOrRoute>)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user