[1078] 增加车辆控制
This commit is contained in:
@@ -3,9 +3,11 @@ package com.genersoft.iot.vmp.jt1078.bean;
|
||||
import com.genersoft.iot.vmp.jt1078.util.BCDUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@Slf4j
|
||||
@Schema(description = "位置基本信息")
|
||||
public class JTPositionBaseInfo {
|
||||
|
||||
@@ -65,6 +67,10 @@ public class JTPositionBaseInfo {
|
||||
|
||||
public static JTPositionBaseInfo decode(ByteBuf buf) {
|
||||
JTPositionBaseInfo positionInfo = new JTPositionBaseInfo();
|
||||
if (buf.readableBytes() < 17) {
|
||||
log.error("[位置基本信息] 解码失败,长度不足: {}", buf.readableBytes());
|
||||
return positionInfo;
|
||||
}
|
||||
positionInfo.setAlarmSign(new JTAlarmSign(buf.readInt()));
|
||||
|
||||
positionInfo.setStatus(new JTStatus(buf.readInt()));
|
||||
|
||||
@@ -570,11 +570,13 @@ public class JT1078Controller {
|
||||
|
||||
log.info("[JT-车门控制] phoneNumber: {}, open: {},", phoneNumber, open);
|
||||
JTPositionBaseInfo positionBaseInfo = service.controlDoor(phoneNumber, open);
|
||||
|
||||
if (positionBaseInfo == null || positionBaseInfo.getStatus() == null) {
|
||||
return WVPResult.fail(ErrorCode.ERROR100.getCode(), "控制失败");
|
||||
}
|
||||
if (open == !positionBaseInfo.getStatus().isDoorLocking()) {
|
||||
return WVPResult.success(null);
|
||||
}else {
|
||||
return WVPResult.fail(ErrorCode.ERROR100);
|
||||
return WVPResult.fail(ErrorCode.ERROR100.getCode(), "控制失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ public class J0500 extends Re {
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
int respNo = buf.readUnsignedShort();
|
||||
positionInfo = JTPositionBaseInfo.decode(buf);
|
||||
log.info("[JT-车辆控制应答]: {}", positionInfo.toString());
|
||||
SessionManager.INSTANCE.response(header.getPhoneNumber(), "0500", (long) respNo, positionInfo);
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user