1078-存储多媒体数据上传命令
This commit is contained in:
@@ -24,6 +24,9 @@ public class JTQueryMediaDataCommand {
|
||||
@Schema(description = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
@Schema(description = "删除标志, 0:保留;1:删除, 存储多媒体数据上传命令中使用")
|
||||
private Integer delete;
|
||||
|
||||
|
||||
public ByteBuf decode() {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
@@ -32,6 +35,9 @@ public class JTQueryMediaDataCommand {
|
||||
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)));
|
||||
if (delete != null) {
|
||||
byteBuf.writeByte(delete);
|
||||
}
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
@@ -75,6 +81,14 @@ public class JTQueryMediaDataCommand {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Integer getDelete() {
|
||||
return delete;
|
||||
}
|
||||
|
||||
public void setDelete(Integer delete) {
|
||||
this.delete = delete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTQueryMediaDataCommand{" +
|
||||
@@ -83,6 +97,7 @@ public class JTQueryMediaDataCommand {
|
||||
", event=" + event +
|
||||
", startTime='" + startTime + '\'' +
|
||||
", endTime='" + endTime + '\'' +
|
||||
", delete='" + delete + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class JT1078Template {
|
||||
private static final String H8702 = "8702";
|
||||
private static final String H8801 = "8801";
|
||||
private static final String H8802 = "8802";
|
||||
private static final String H8803 = "8803";
|
||||
private static final String H9101 = "9101";
|
||||
private static final String H9102 = "9102";
|
||||
private static final String H9201 = "9201";
|
||||
@@ -593,4 +594,15 @@ public class JT1078Template {
|
||||
.build();
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
}
|
||||
|
||||
public Object updateMediaData(String devId, J8803 j8803, int timeOut) {
|
||||
Cmd cmd = new Cmd.Builder()
|
||||
.setDevId(devId)
|
||||
.setPackageNo(randomInt())
|
||||
.setMsgId(H8803)
|
||||
.setRespId(H0802)
|
||||
.setRs(j8803)
|
||||
.build();
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -777,5 +777,19 @@ public class JT1078Controller {
|
||||
return WVPResult.fail(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "1078-存储多媒体数据上传命令", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "param", description = "存储多媒体数据参数", required = true)
|
||||
@PostMapping("/media-data-update")
|
||||
public WVPResult<List<JTMediaDataInfo>> updateMediaData(@RequestBody QueryMediaDataParam param){
|
||||
|
||||
logger.info("[1078-存储多媒体数据上传命令] param: {}", param );
|
||||
List<JTMediaDataInfo> ids = service.updateMediaData(param.getDeviceId(), param.getQueryMediaDataCommand());
|
||||
if (ids != null) {
|
||||
return WVPResult.success(ids);
|
||||
}else {
|
||||
return WVPResult.fail(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -35,6 +36,10 @@ public class J0801 extends Re {
|
||||
ByteBuf byteBuf = buf.readSlice(28);
|
||||
positionBaseInfo = JTPositionBaseInfo.decode(byteBuf);
|
||||
String fileName = "mediaEvent/" + mediaEventInfo.getId() + ".";
|
||||
File mediaEventFile = new File("mediaEvent");
|
||||
if (!mediaEventFile.exists()) {
|
||||
mediaEventFile.mkdirs();
|
||||
}
|
||||
switch (mediaEventInfo.getCode()){
|
||||
case 0:
|
||||
fileName += "jpg";
|
||||
@@ -54,6 +59,10 @@ public class J0801 extends Re {
|
||||
}
|
||||
try {
|
||||
ByteBuf dst = buf.readBytes(buf.readableBytes());
|
||||
File file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(fileName);
|
||||
fileOutputStream.write(dst.array());
|
||||
fileOutputStream.close();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* 存储多媒体数据上传命令
|
||||
*/
|
||||
@MsgId(id = "8803")
|
||||
public class J8803 extends Rs {
|
||||
|
||||
JTQueryMediaDataCommand command;
|
||||
|
||||
@Override
|
||||
public ByteBuf encode() {
|
||||
return command.decode();
|
||||
}
|
||||
|
||||
public JTQueryMediaDataCommand getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(JTQueryMediaDataCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
/**
|
||||
* 录音开始/停止命令
|
||||
*/
|
||||
@MsgId(id = "8804")
|
||||
public class J8804 extends Rs {
|
||||
|
||||
/**
|
||||
* 录音命令, 0:停止录音;0X01:开始录音
|
||||
*/
|
||||
private int commond;
|
||||
|
||||
/**
|
||||
* 录音时长,单位为秒(s) ,0 表示一直录音
|
||||
*/
|
||||
private int duration;
|
||||
|
||||
/**
|
||||
* 保存标志, 0:实时上传;1:保存
|
||||
*/
|
||||
private int save;
|
||||
|
||||
/**
|
||||
* 音频采样率, 0:8K;1:11K;2:23K;3:32K;其他保留
|
||||
*/
|
||||
private int samplingRate;
|
||||
|
||||
@Override
|
||||
public ByteBuf encode() {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeByte(commond);
|
||||
byteBuf.writeShort((short)(duration & 0xffff));
|
||||
byteBuf.writeByte(save);
|
||||
byteBuf.writeByte(samplingRate);
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public int getCommond() {
|
||||
return commond;
|
||||
}
|
||||
|
||||
public void setCommond(int commond) {
|
||||
this.commond = commond;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public int getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public void setSave(int save) {
|
||||
this.save = save;
|
||||
}
|
||||
|
||||
public int getSamplingRate() {
|
||||
return samplingRate;
|
||||
}
|
||||
|
||||
public void setSamplingRate(int samplingRate) {
|
||||
this.samplingRate = samplingRate;
|
||||
}
|
||||
}
|
||||
@@ -99,4 +99,7 @@ public interface Ijt1078Service {
|
||||
List<Long> shooting(String deviceId, JTShootingCommand shootingCommand);
|
||||
|
||||
List<JTMediaDataInfo> queryMediaData(String deviceId, JTQueryMediaDataCommand queryMediaDataCommand);
|
||||
|
||||
List<JTMediaDataInfo> updateMediaData(String deviceId, JTQueryMediaDataCommand queryMediaDataCommand);
|
||||
|
||||
}
|
||||
|
||||
@@ -720,4 +720,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
j8802.setCommand(queryMediaDataCommand);
|
||||
return (List<JTMediaDataInfo>)jt1078Template.queryMediaData(deviceId, j8802, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JTMediaDataInfo> updateMediaData(String deviceId, JTQueryMediaDataCommand queryMediaDataCommand) {
|
||||
J8803 j8803 = new J8803();
|
||||
j8803.setCommand(queryMediaDataCommand);
|
||||
return (List<JTMediaDataInfo>)jt1078Template.updateMediaData(deviceId, j8803, 300);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user