1078-查询区域或线路数据应答...
This commit is contained in:
@@ -80,6 +80,22 @@ public class JTAreaAttribute {
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public static JTAreaAttribute decode(int attributeInt) {
|
||||
JTAreaAttribute attribute = new JTAreaAttribute();
|
||||
attribute.setRuleForTimeLimit((attributeInt & 1) == 1);
|
||||
attribute.setRuleForSpeedLimit((attributeInt >> 1 & 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);
|
||||
attribute.setSouthLatitude((attributeInt >> 6 & 1) == 1);
|
||||
attribute.setWestLongitude((attributeInt >> 7 & 1) == 1);
|
||||
attribute.setProhibitOpeningDoors((attributeInt >> 8 & 1) == 1);
|
||||
attribute.setRuleForTurnOffCommunicationWhenEnter((attributeInt >> 9 & 1) == 1);
|
||||
attribute.setRuleForGnssWhenEnter((attributeInt >> 10 & 1) == 1);
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public boolean isRuleForTimeLimit() {
|
||||
return ruleForTimeLimit;
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ public class JTCircleArea implements JTAreaOrRoute{
|
||||
byteBuf.writeInt((int) (Math.round((latitude * 1000000)) & 0xffffffffL));
|
||||
byteBuf.writeInt((int) (Math.round((longitude * 1000000)) & 0xffffffffL));
|
||||
byteBuf.writeInt((int) (radius & 0xffffffffL));
|
||||
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.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime)));
|
||||
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime)));
|
||||
byteBuf.writeShort((short)(maxSpeed & 0xffff));
|
||||
byteBuf.writeByte(overSpeedDuration);
|
||||
byteBuf.writeShort((short)(nighttimeMaxSpeed & 0xffff));
|
||||
|
||||
@@ -43,8 +43,8 @@ public class JTPolygonArea implements JTAreaOrRoute{
|
||||
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.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime)));
|
||||
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime)));
|
||||
byteBuf.writeShort((short)(maxSpeed & 0xffff));
|
||||
byteBuf.writeByte(overSpeedDuration);
|
||||
|
||||
|
||||
@@ -47,16 +47,17 @@ public class JTRectangleArea 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());
|
||||
byteBuf.writeInt((int) (Math.round((latitudeForUpperLeft * 1000000)) & 0xffffffffL));
|
||||
byteBuf.writeInt((int) (Math.round((longitudeForLowerRight * 1000000)) & 0xffffffffL));
|
||||
byteBuf.writeInt((int) (Math.round((longitudeForUpperLeft * 1000000)) & 0xffffffffL));
|
||||
byteBuf.writeInt((int) (Math.round((latitudeForLowerRight * 1000000)) & 0xffffffffL));
|
||||
byteBuf.writeInt((int) (Math.round((longitudeForLowerRight * 1000000)) & 0xffffffffL));
|
||||
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.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime)));
|
||||
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime)));
|
||||
byteBuf.writeShort((short)(maxSpeed & 0xffff));
|
||||
byteBuf.writeByte(overSpeedDuration);
|
||||
byteBuf.writeShort((short)(nighttimeMaxSpeed & 0xffff));
|
||||
@@ -65,6 +66,30 @@ public class JTRectangleArea implements JTAreaOrRoute{
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public static JTRectangleArea decode(ByteBuf buf) {
|
||||
JTRectangleArea area = new JTRectangleArea();
|
||||
area.setId(buf.readUnsignedInt());
|
||||
int attributeInt = buf.readUnsignedShort();
|
||||
JTAreaAttribute areaAttribute = JTAreaAttribute.decode(attributeInt);
|
||||
area.setAttribute(areaAttribute);
|
||||
area.setLatitudeForUpperLeft(buf.readUnsignedInt()/1000000D);
|
||||
area.setLongitudeForUpperLeft(buf.readUnsignedInt()/1000000D);
|
||||
area.setLatitudeForLowerRight(buf.readUnsignedInt()/1000000D);
|
||||
area.setLongitudeForLowerRight(buf.readUnsignedInt()/1000000D);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class JT1078Template {
|
||||
private static final String H8605 = "8605";
|
||||
private static final String H8606 = "8606";
|
||||
private static final String H8607 = "8607";
|
||||
private static final String H8608 = "8608";
|
||||
private static final String H9101 = "9101";
|
||||
private static final String H9102 = "9102";
|
||||
private static final String H9201 = "9201";
|
||||
@@ -57,6 +58,7 @@ public class JT1078Template {
|
||||
private static final String H0107 = "0107";
|
||||
private static final String H0201 = "0201";
|
||||
private static final String H0500 = "0500";
|
||||
private static final String H0608 = "0608";
|
||||
private static final String H1205 = "1205";
|
||||
|
||||
/**
|
||||
@@ -536,9 +538,20 @@ public class JT1078Template {
|
||||
.setDevId(devId)
|
||||
.setPackageNo(randomInt())
|
||||
.setMsgId(H8607)
|
||||
.setRespId(H0001)
|
||||
.setRespId(H0608)
|
||||
.setRs(j8607)
|
||||
.build();
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
}
|
||||
|
||||
public Object queryAreaOrRoute(String devId, J8608 j8608, int timeOut) {
|
||||
Cmd cmd = new Cmd.Builder()
|
||||
.setDevId(devId)
|
||||
.setPackageNo(randomInt())
|
||||
.setMsgId(H8608)
|
||||
.setRespId(H0001)
|
||||
.setRs(j8608)
|
||||
.build();
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,5 +678,21 @@ public class JT1078Controller {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "1078-查询路线", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "deviceId", description = "设备编号", required = true)
|
||||
@GetMapping("/route/query")
|
||||
public WVPResult<Integer> queryRoute(String deviceId, @RequestParam(value = "ids", required = false) List<Long> ids){
|
||||
|
||||
logger.info("[1078-查询路线] deviceId: {}, ids:{}", deviceId, ids);
|
||||
int result = service.queryRoute(deviceId, ids);
|
||||
if (result == 0) {
|
||||
return WVPResult.success(result);
|
||||
}else {
|
||||
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
|
||||
fail.setData(result);
|
||||
return fail;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.request;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTAreaOrRoute;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTPositionBaseInfo;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.*;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||
@@ -38,29 +36,46 @@ public class J0608 extends Re {
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0608", null, areaOrRoutes);
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
switch (type) {
|
||||
case 1:
|
||||
switch (type) {
|
||||
case 1:
|
||||
List<JTCircleArea> jtCircleAreas = new ArrayList<>();
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
// 查询圆形区域数据
|
||||
break;
|
||||
case 2:
|
||||
// 查询矩形区域数据
|
||||
break;
|
||||
case 3:
|
||||
// 查询多 边形区域数据
|
||||
break;
|
||||
case 4:
|
||||
// 查询线路数据
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
JTCircleArea jtCircleArea = JTCircleArea.decode(buf);
|
||||
jtCircleAreas.add(jtCircleArea);
|
||||
}
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0608", null, jtCircleAreas);
|
||||
break;
|
||||
case 2:
|
||||
// 查询矩形区域数据
|
||||
List<JTRectangleArea> jtRectangleAreas = new ArrayList<>();
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
// 查询圆形区域数据
|
||||
JTRectangleArea jtRectangleArea = JTRectangleArea.decode(buf);
|
||||
jtRectangleAreas.add(jtRectangleArea);
|
||||
}
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0608", null, jtRectangleAreas);
|
||||
break;
|
||||
case 3:
|
||||
// 查询多 边形区域数据
|
||||
List<JTPolygonArea> jtPolygonAreas = new ArrayList<>();
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
// 查询圆形区域数据
|
||||
JTPolygonArea jtRectangleArea = JTPolygonArea.decode(buf);
|
||||
jtPolygonAreas.add(jtRectangleArea);
|
||||
}
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0608", null, jtPolygonAreas);
|
||||
break;
|
||||
case 4:
|
||||
// 查询线路数据
|
||||
// 查询多 边形区域数据
|
||||
JTPolygonArea jtPolygonArea = JTPolygonArea.decode(buf);
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0608", null, jtPolygonArea);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int respNo = buf.readUnsignedShort();
|
||||
positionInfo = J0200.getPositionInfo(buf);
|
||||
log.info("[JT-车辆控制应答]: {}", positionInfo.toString());
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0500", (long) respNo, positionInfo);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ public class J8608 extends Rs {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
buffer.writeByte(type);
|
||||
if (idList == null || idList.isEmpty()) {
|
||||
buffer.writeByte(0);
|
||||
buffer.writeInt(0);
|
||||
return buffer;
|
||||
}else {
|
||||
buffer.writeByte(idList.size());
|
||||
buffer.writeInt(idList.size());
|
||||
}
|
||||
for (Long id : idList) {
|
||||
buffer.writeInt((int) (id & 0xffffffffL));
|
||||
|
||||
@@ -74,15 +74,23 @@ public interface Ijt1078Service {
|
||||
|
||||
int deleteAreaForCircle(String deviceId, List<Long> ids);
|
||||
|
||||
int queryAreaForCircle(String deviceId, List<Long> ids);
|
||||
|
||||
int setAreaForRectangle(int i, String deviceId, List<JTRectangleArea> rectangleAreas);
|
||||
|
||||
int deleteAreaForRectangle(String deviceId, List<Long> ids);
|
||||
|
||||
int queryAreaForRectangle(String deviceId, List<Long> ids);
|
||||
|
||||
int setAreaForPolygon(String deviceId, JTPolygonArea polygonArea);
|
||||
|
||||
int deleteAreaForPolygon(String deviceId, List<Long> ids);
|
||||
|
||||
int queryAreaForPolygon(String deviceId, List<Long> ids);
|
||||
|
||||
int setRoute(String deviceId, JTRoute route);
|
||||
|
||||
int deleteRoute(String deviceId, List<Long> ids);
|
||||
|
||||
int queryRoute(String deviceId, List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -625,6 +625,14 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
return (int)jt1078Template.deleteAreaForCircle(deviceId, j8601, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queryAreaForCircle(String deviceId, List<Long> ids) {
|
||||
J8608 j8608 = new J8608();
|
||||
j8608.setType(1);
|
||||
j8608.setIdList(ids);
|
||||
return (int)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setAreaForRectangle(int attribute, String deviceId, List<JTRectangleArea> rectangleAreas) {
|
||||
J8602 j8602 = new J8602();
|
||||
@@ -640,6 +648,14 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
return (int)jt1078Template.deleteAreaForRectangle(deviceId, j8603, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queryAreaForRectangle(String deviceId, List<Long> ids) {
|
||||
J8608 j8608 = new J8608();
|
||||
j8608.setType(2);
|
||||
j8608.setIdList(ids);
|
||||
return (int)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setAreaForPolygon(String deviceId, JTPolygonArea polygonArea) {
|
||||
J8604 j8604 = new J8604();
|
||||
@@ -654,6 +670,14 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
return (int)jt1078Template.deleteAreaForPolygon(deviceId, j8605, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queryAreaForPolygon(String deviceId, List<Long> ids) {
|
||||
J8608 j8608 = new J8608();
|
||||
j8608.setType(3);
|
||||
j8608.setIdList(ids);
|
||||
return (int)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setRoute(String deviceId, JTRoute route) {
|
||||
J8606 j8606 = new J8606();
|
||||
@@ -667,4 +691,12 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
j8607.setIdList(ids);
|
||||
return (int)jt1078Template.deleteRoute(deviceId, j8607, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queryRoute(String deviceId, List<Long> ids) {
|
||||
J8608 j8608 = new J8608();
|
||||
j8608.setType(4);
|
||||
j8608.setIdList(ids);
|
||||
return (int)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,32 +69,4 @@ public class BCDUtil {
|
||||
}
|
||||
return bbt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间使用按照YY-MM-DD-hh-mm-ss,转换为byte数据
|
||||
*/
|
||||
public static ByteBuf transform(long time) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
int month = calendar.get(Calendar.MONTH) + 1 ;
|
||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
int second = calendar.get(Calendar.SECOND);
|
||||
System.out.println("year== " + year);
|
||||
System.out.println("month== " + month);
|
||||
System.out.println("day== " + day);
|
||||
System.out.println("hour== " + hour);
|
||||
System.out.println("minute== " + minute);
|
||||
System.out.println("second== " + second);
|
||||
byteBuf.writeByte(year);
|
||||
byteBuf.writeByte(month);
|
||||
byteBuf.writeByte(day);
|
||||
byteBuf.writeByte(hour);
|
||||
byteBuf.writeByte(minute);
|
||||
byteBuf.writeByte(second);
|
||||
return byteBuf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,9 @@ public class DateUtil {
|
||||
public static String yyyy_MM_dd_HH_mm_ssTo1078(String formatTime) {
|
||||
return formatter1078.format(formatter.parse(formatTime));
|
||||
}
|
||||
public static String jt1078Toyyyy_MM_dd_HH_mm_ss(String formatTime) {
|
||||
return formatter.format(formatter1078.parse(formatTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* yyyy_MM_dd_HH_mm_ss 转时间戳
|
||||
|
||||
Reference in New Issue
Block a user