1078-存储多媒体数据检索 + 存储多媒体数据检索应答
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package com.genersoft.iot.vmp.jt1078.bean;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Schema(description = "多媒体检索项数据")
|
||||
public class JTMediaDataInfo {
|
||||
|
||||
@Schema(description = "多媒体数据 ID")
|
||||
private long id;
|
||||
|
||||
@Schema(description = "多媒体类型, 0:图像;1:音频;2:视频")
|
||||
private int type;
|
||||
|
||||
@Schema(description = "事件项编码: 0:平台下发指令;1:定时动作;2:抢劫报警触发;3:碰 撞侧翻报警触发;4:门开拍照;5:门关拍照;6:车门由开 变关 ,车速从小于20km到超过20km;7:定距拍照")
|
||||
private int eventCode;
|
||||
|
||||
@Schema(description = "通道 ID")
|
||||
private int channelId;
|
||||
|
||||
@Schema(description = "表示拍摄或录制的起始时刻的汇报消息")
|
||||
private JTPositionBaseInfo positionBaseInfo;
|
||||
|
||||
public static JTMediaDataInfo decode(ByteBuf buf) {
|
||||
JTMediaDataInfo jtMediaEventInfo = new JTMediaDataInfo();
|
||||
jtMediaEventInfo.setId(buf.readUnsignedInt());
|
||||
jtMediaEventInfo.setType(buf.readUnsignedByte());
|
||||
jtMediaEventInfo.setChannelId(buf.readUnsignedByte());
|
||||
jtMediaEventInfo.setEventCode(buf.readUnsignedByte());
|
||||
jtMediaEventInfo.setPositionBaseInfo(JTPositionBaseInfo.decode(buf));
|
||||
return jtMediaEventInfo;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getEventCode() {
|
||||
return eventCode;
|
||||
}
|
||||
|
||||
public void setEventCode(int eventCode) {
|
||||
this.eventCode = eventCode;
|
||||
}
|
||||
|
||||
public int getChannelId() {
|
||||
return channelId;
|
||||
}
|
||||
|
||||
public void setChannelId(int channelId) {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public JTPositionBaseInfo getPositionBaseInfo() {
|
||||
return positionBaseInfo;
|
||||
}
|
||||
|
||||
public void setPositionBaseInfo(JTPositionBaseInfo positionBaseInfo) {
|
||||
this.positionBaseInfo = positionBaseInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTMediaDataInfo{" +
|
||||
"id=" + id +
|
||||
", type=" + type +
|
||||
", eventCode=" + eventCode +
|
||||
", channelId=" + channelId +
|
||||
", positionBaseInfo=" + positionBaseInfo +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,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 java.nio.ByteBuffer;
|
||||
|
||||
@Schema(description = "位置基本信息")
|
||||
public class JTPositionBaseInfo {
|
||||
|
||||
@@ -59,6 +63,23 @@ public class JTPositionBaseInfo {
|
||||
@Schema(description = "视频报警")
|
||||
private JTVideoAlarm videoAlarm;
|
||||
|
||||
public static JTPositionBaseInfo decode(ByteBuf buf) {
|
||||
JTPositionBaseInfo positionInfo = new JTPositionBaseInfo();
|
||||
positionInfo.setAlarmSign(new JTAlarmSign(buf.readInt()));
|
||||
|
||||
positionInfo.setStatus(new JTStatus(buf.readInt()));
|
||||
|
||||
positionInfo.setLatitude(buf.readInt() * 0.000001D);
|
||||
positionInfo.setLongitude(buf.readInt() * 0.000001D);
|
||||
positionInfo.setAltitude(buf.readUnsignedShort());
|
||||
positionInfo.setSpeed(buf.readUnsignedShort());
|
||||
positionInfo.setDirection(buf.readUnsignedShort());
|
||||
byte[] timeBytes = new byte[6];
|
||||
buf.readBytes(timeBytes);
|
||||
positionInfo.setTime(BCDUtil.transform(timeBytes));
|
||||
return positionInfo;
|
||||
}
|
||||
|
||||
public JTAlarmSign getAlarmSign() {
|
||||
return alarmSign;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
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;
|
||||
|
||||
@Schema(description = "存储多媒体数据")
|
||||
public class JTQueryMediaDataCommand {
|
||||
|
||||
@Schema(description = "多媒体类型: 0:图像;1:音频;2:视频")
|
||||
private int type;
|
||||
|
||||
@Schema(description = "通道 ID, 0 表示检索该媒体类型的所有通道")
|
||||
private int chanelId;
|
||||
|
||||
@Schema(description = "事件项编码: 0:平台下发指令;1:定时动作;2:抢劫报警触发;3:碰 撞侧翻报警触发;其他保留")
|
||||
private int event;
|
||||
|
||||
@Schema(description = "开始时间")
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
|
||||
public ByteBuf decode() {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeByte(type);
|
||||
byteBuf.writeByte(chanelId);
|
||||
byteBuf.writeByte(event);
|
||||
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime)));
|
||||
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime)));
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getChanelId() {
|
||||
return chanelId;
|
||||
}
|
||||
|
||||
public void setChanelId(int chanelId) {
|
||||
this.chanelId = chanelId;
|
||||
}
|
||||
|
||||
public int getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void setEvent(int event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTQueryMediaDataCommand{" +
|
||||
"type=" + type +
|
||||
", chanelId=" + chanelId +
|
||||
", event=" + event +
|
||||
", startTime='" + startTime + '\'' +
|
||||
", endTime='" + endTime + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class J0200 extends Re {
|
||||
|
||||
@Override
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
positionInfo = J0200.getPositionInfo(buf);
|
||||
positionInfo = JTPositionBaseInfo.decode(buf);
|
||||
|
||||
// 读取附加信息
|
||||
// JTPositionAdditionalInfo positionAdditionalInfo = new JTPositionAdditionalInfo();
|
||||
@@ -39,23 +39,6 @@ public class J0200 extends Re {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JTPositionBaseInfo getPositionInfo(ByteBuf buf) {
|
||||
JTPositionBaseInfo positionInfo = new JTPositionBaseInfo();
|
||||
positionInfo.setAlarmSign(new JTAlarmSign(buf.readInt()));
|
||||
|
||||
positionInfo.setStatus(new JTStatus(buf.readInt()));
|
||||
|
||||
positionInfo.setLatitude(buf.readInt() * 0.000001D);
|
||||
positionInfo.setLongitude(buf.readInt() * 0.000001D);
|
||||
positionInfo.setAltitude(buf.readUnsignedShort());
|
||||
positionInfo.setSpeed(buf.readUnsignedShort());
|
||||
positionInfo.setDirection(buf.readUnsignedShort());
|
||||
byte[] timeBytes = new byte[6];
|
||||
buf.readBytes(timeBytes);
|
||||
positionInfo.setTime(BCDUtil.transform(timeBytes));
|
||||
return positionInfo;
|
||||
}
|
||||
|
||||
private void getAdditionalMsg(ByteBuf buf, JTPositionAdditionalInfo additionalInfo) {
|
||||
|
||||
if (buf.isReadable()) {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class J0201 extends Re {
|
||||
|
||||
int respNo = buf.readUnsignedShort();
|
||||
|
||||
positionInfo = J0200.getPositionInfo(buf);
|
||||
positionInfo = JTPositionBaseInfo.decode(buf);
|
||||
log.info("[JT-位置信息查询应答]: {}", positionInfo.toString());
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0201", (long) respNo, positionInfo);
|
||||
return null;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class J0500 extends Re {
|
||||
@Override
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
int respNo = buf.readUnsignedShort();
|
||||
positionInfo = J0200.getPositionInfo(buf);
|
||||
positionInfo = JTPositionBaseInfo.decode(buf);
|
||||
log.info("[JT-车辆控制应答]: {}", positionInfo.toString());
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0500", (long) respNo, positionInfo);
|
||||
return null;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class J0704 extends Re {
|
||||
for (int i = 0; i < length; i++) {
|
||||
int dateLength = buf.readUnsignedShort();
|
||||
ByteBuf byteBuf = buf.readBytes(dateLength);
|
||||
JTPositionBaseInfo positionInfo = J0200.getPositionInfo(byteBuf);
|
||||
JTPositionBaseInfo positionInfo = JTPositionBaseInfo.decode(byteBuf);
|
||||
positionBaseInfoList.add(positionInfo);
|
||||
}
|
||||
log.info("[JT-定位数据批量上传]: 共{}条", positionBaseInfoList.size());
|
||||
|
||||
@@ -33,7 +33,7 @@ public class J0801 extends Re {
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
mediaEventInfo = JTMediaEventInfo.decode(buf);
|
||||
ByteBuf byteBuf = buf.readSlice(28);
|
||||
positionBaseInfo = J0200.getPositionInfo(byteBuf);
|
||||
positionBaseInfo = JTPositionBaseInfo.decode(byteBuf);
|
||||
String fileName = "mediaEvent/" + mediaEventInfo.getId() + ".";
|
||||
switch (mediaEventInfo.getCode()){
|
||||
case 0:
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.request;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTMediaDataInfo;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTMediaEventInfo;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTPositionBaseInfo;
|
||||
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;
|
||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||
import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import com.genersoft.iot.vmp.jt1078.session.SessionManager;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 存储多媒体数据检索应答
|
||||
*
|
||||
*/
|
||||
@MsgId(id = "0802")
|
||||
public class J0802 extends Re {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(J0802.class);
|
||||
|
||||
private int respNo;
|
||||
private List<JTMediaDataInfo> mediaDataInfoList;
|
||||
|
||||
@Override
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
respNo = buf.readUnsignedShort();
|
||||
int length = buf.readUnsignedShort();
|
||||
for (int i = 0; i < length; i++) {
|
||||
mediaDataInfoList.add(JTMediaDataInfo.decode(buf));
|
||||
}
|
||||
log.info("[JT-存储多媒体数据检索应答]: {}", mediaDataInfoList.size());
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0802", (long) respNo, mediaDataInfoList);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
||||
J8001 j8001 = new J8001();
|
||||
j8001.setRespNo(header.getSn());
|
||||
j8001.setRespId(header.getMsgId());
|
||||
return j8001;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvent getEvent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.response;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTQueryMediaDataCommand;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTShootingCommand;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* 存储多媒体数据检索
|
||||
*/
|
||||
@MsgId(id = "8802")
|
||||
public class J8802 extends Rs {
|
||||
|
||||
JTQueryMediaDataCommand command;
|
||||
|
||||
@Override
|
||||
public ByteBuf encode() {
|
||||
return command.decode();
|
||||
}
|
||||
|
||||
public JTQueryMediaDataCommand getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(JTQueryMediaDataCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user