1078-存储多媒体数据上传
This commit is contained in:
@@ -64,6 +64,7 @@ public class JT1078Template {
|
||||
private static final String H0500 = "0500";
|
||||
private static final String H0608 = "0608";
|
||||
private static final String H0702 = "0702";
|
||||
private static final String H0801 = "0801";
|
||||
private static final String H0802 = "0802";
|
||||
private static final String H0805 = "0805";
|
||||
private static final String H1205 = "1205";
|
||||
@@ -595,12 +596,12 @@ public class JT1078Template {
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
}
|
||||
|
||||
public Object updateMediaData(String devId, J8803 j8803, int timeOut) {
|
||||
public Object uploadMediaData(String devId, J8803 j8803, int timeOut) {
|
||||
Cmd cmd = new Cmd.Builder()
|
||||
.setDevId(devId)
|
||||
.setPackageNo(randomInt())
|
||||
.setMsgId(H8803)
|
||||
.setRespId(H0802)
|
||||
.setRespId(H0801)
|
||||
.setRs(j8803)
|
||||
.build();
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
|
||||
@@ -780,11 +780,11 @@ public class JT1078Controller {
|
||||
|
||||
@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){
|
||||
@PostMapping("/media-data-upload")
|
||||
public WVPResult<List<JTMediaEventInfo>> updateMediaData(@RequestBody QueryMediaDataParam param){
|
||||
|
||||
logger.info("[1078-存储多媒体数据上传命令] param: {}", param );
|
||||
List<JTMediaDataInfo> ids = service.updateMediaData(param.getDeviceId(), param.getQueryMediaDataCommand());
|
||||
List<JTMediaEventInfo> ids = service.uploadMediaData(param.getDeviceId(), param.getQueryMediaDataCommand());
|
||||
if (ids != null) {
|
||||
return WVPResult.success(ids);
|
||||
}else {
|
||||
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
@@ -33,6 +34,7 @@ public class J0801 extends Re {
|
||||
@Override
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
mediaEventInfo = JTMediaEventInfo.decode(buf);
|
||||
System.out.println(mediaEventInfo.getId());
|
||||
ByteBuf byteBuf = buf.readSlice(28);
|
||||
positionBaseInfo = JTPositionBaseInfo.decode(byteBuf);
|
||||
String fileName = "mediaEvent/" + mediaEventInfo.getId() + ".";
|
||||
@@ -58,18 +60,19 @@ public class J0801 extends Re {
|
||||
break;
|
||||
}
|
||||
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());
|
||||
file.deleteOnExit();
|
||||
file.createNewFile();
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
byte[] bytes = new byte[buf.readableBytes()];
|
||||
buf.readBytes(bytes);
|
||||
fileOutputStream.write(bytes);
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.info("[JT-多媒体数据上传] 写入文件失败", e);
|
||||
}
|
||||
log.info("[JT-多媒体数据上传]: {}", mediaEventInfo);
|
||||
// SessionManager.INSTANCE.response(header.getTerminalId(), "0801", null, mediaEventInfo);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,6 @@ public interface Ijt1078Service {
|
||||
|
||||
List<JTMediaDataInfo> queryMediaData(String deviceId, JTQueryMediaDataCommand queryMediaDataCommand);
|
||||
|
||||
List<JTMediaDataInfo> updateMediaData(String deviceId, JTQueryMediaDataCommand queryMediaDataCommand);
|
||||
List<JTMediaEventInfo> uploadMediaData(String deviceId, JTQueryMediaDataCommand queryMediaDataCommand);
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -722,9 +721,9 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JTMediaDataInfo> updateMediaData(String deviceId, JTQueryMediaDataCommand queryMediaDataCommand) {
|
||||
public List<JTMediaEventInfo> uploadMediaData(String deviceId, JTQueryMediaDataCommand queryMediaDataCommand) {
|
||||
J8803 j8803 = new J8803();
|
||||
j8803.setCommand(queryMediaDataCommand);
|
||||
return (List<JTMediaDataInfo>)jt1078Template.updateMediaData(deviceId, j8803, 300);
|
||||
return (List<JTMediaEventInfo>)jt1078Template.uploadMediaData(deviceId, j8803, 300);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user