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 JTMediaEventInfo {
|
||||
|
||||
@Schema(description = "多媒体数据 ID")
|
||||
private long id;
|
||||
|
||||
@Schema(description = "多媒体类型, 0:图像;1:音频;2:视频")
|
||||
private int type;
|
||||
|
||||
@Schema(description = "多媒体格式编码, 0:JPEG;1:TIF;2:MP3;3:WAV;4:WMV;其他保留")
|
||||
private int code;
|
||||
|
||||
@Schema(description = "事件项编码: 0:平台下发指令;1:定时动作;2:抢劫报警触发;3:碰 撞侧翻报警触发;4:门开拍照;5:门关拍照;6:车门由开 变关 ,车速从小于20km到超过20km;7:定距拍照")
|
||||
private int eventCode;
|
||||
|
||||
@Schema(description = "通道 ID")
|
||||
private int channelId;
|
||||
|
||||
public static JTMediaEventInfo decode(ByteBuf buf) {
|
||||
JTMediaEventInfo jtMediaEventInfo = new JTMediaEventInfo();
|
||||
jtMediaEventInfo.setId(buf.readUnsignedInt());
|
||||
jtMediaEventInfo.setType(buf.readUnsignedByte());
|
||||
jtMediaEventInfo.setCode(buf.readUnsignedByte());
|
||||
jtMediaEventInfo.setEventCode(buf.readUnsignedByte());
|
||||
jtMediaEventInfo.setChannelId(buf.readUnsignedByte());
|
||||
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 getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTMediaEventInfo{" +
|
||||
"id=" + id +
|
||||
", type=" + type +
|
||||
", code=" + code +
|
||||
", eventCode=" + eventCode +
|
||||
", channelId=" + channelId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -734,7 +734,7 @@ public class JT1078Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 待实现 行驶记录数据采集命令 行驶记录数据上传 行驶记录参数下传命令 电子运单上报
|
||||
// TODO 待实现 行驶记录数据采集命令 行驶记录数据上传 行驶记录参数下传命令 电子运单上报 CAN总线数据上传
|
||||
|
||||
@Operation(summary = "1078-上报驾驶员身份信息请求", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "deviceId", description = "设备编号", required = true)
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.request;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTDriverInformation;
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定位数据批量上传
|
||||
*
|
||||
*/
|
||||
@MsgId(id = "0704")
|
||||
public class J0704 extends Re {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(J0704.class);
|
||||
private List<JTPositionBaseInfo> positionBaseInfoList = new ArrayList<>();
|
||||
private int type;
|
||||
|
||||
@Override
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
int length = buf.readUnsignedShort();
|
||||
type = buf.readUnsignedByte();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int dateLength = buf.readUnsignedShort();
|
||||
ByteBuf byteBuf = buf.readBytes(dateLength);
|
||||
JTPositionBaseInfo positionInfo = J0200.getPositionInfo(byteBuf);
|
||||
positionBaseInfoList.add(positionInfo);
|
||||
}
|
||||
log.info("[JT-定位数据批量上传]: 共{}条", positionBaseInfoList.size());
|
||||
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,49 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.request;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 多媒体事件信息上传
|
||||
*
|
||||
*/
|
||||
@MsgId(id = "0800")
|
||||
public class J0800 extends Re {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(J0800.class);
|
||||
|
||||
private JTMediaEventInfo mediaEventInfo;
|
||||
|
||||
@Override
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
mediaEventInfo = JTMediaEventInfo.decode(buf);
|
||||
log.info("[JT-多媒体事件信息上传]: {}", mediaEventInfo);
|
||||
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,79 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.request;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 多媒体数据上传
|
||||
*
|
||||
*/
|
||||
@MsgId(id = "0801")
|
||||
public class J0801 extends Re {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(J0801.class);
|
||||
|
||||
private JTMediaEventInfo mediaEventInfo;
|
||||
private JTPositionBaseInfo positionBaseInfo;
|
||||
|
||||
@Override
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
mediaEventInfo = JTMediaEventInfo.decode(buf);
|
||||
ByteBuf byteBuf = buf.readSlice(28);
|
||||
positionBaseInfo = J0200.getPositionInfo(byteBuf);
|
||||
String fileName = "mediaEvent/" + mediaEventInfo.getId() + ".";
|
||||
switch (mediaEventInfo.getCode()){
|
||||
case 0:
|
||||
fileName += "jpg";
|
||||
break;
|
||||
case 1:
|
||||
fileName += "tif";
|
||||
break;
|
||||
case 2:
|
||||
fileName += "mp3";
|
||||
break;
|
||||
case 3:
|
||||
fileName += "wav";
|
||||
break;
|
||||
case 4:
|
||||
fileName += "wmv";
|
||||
break;
|
||||
}
|
||||
try {
|
||||
ByteBuf dst = buf.readBytes(buf.readableBytes());
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(fileName);
|
||||
fileOutputStream.write(dst.array());
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.info("[JT-多媒体数据上传] 写入文件失败", e);
|
||||
}
|
||||
log.info("[JT-多媒体数据上传]: {}", mediaEventInfo);
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user