From 302eb98d515b1c693aa329f7c36a115e11726100 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sun, 7 Apr 2024 06:44:52 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/jt1078/cmd/JT1078Template.java | 18 ++ .../iot/vmp/jt1078/proc/response/J9206.java | 201 ++++++++++++++++++ 2 files changed, 219 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9206.java diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java b/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java index 98af47a9d..d6e8a424b 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java @@ -22,6 +22,7 @@ public class JT1078Template { private static final String H9201 = "9201"; private static final String H9202 = "9202"; private static final String H9205 = "9205"; + private static final String H9206 = "9206"; private static final String H0001 = "0001"; private static final String H1205 = "1205"; @@ -111,6 +112,23 @@ public class JT1078Template { return SessionManager.INSTANCE.request(cmd, timeOut); } + /** + * 文件上传 + * + * @param devId 设备号 + * @param j9206 文件上传参数 + */ + public String fileUpload(String devId, J9206 j9206, Integer timeOut) { + Cmd cmd = new Cmd.Builder() + .setDevId(devId) + .setPackageNo(randomInt()) + .setMsgId(H9206) + .setRespId(H0001) + .setRs(j9206) + .build(); + return SessionManager.INSTANCE.request(cmd, timeOut); + } + private Long randomInt() { return (long) random.nextInt(1000) + 1; } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9206.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9206.java new file mode 100644 index 000000000..f00f25b24 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9206.java @@ -0,0 +1,201 @@ +package com.genersoft.iot.vmp.jt1078.proc.response; + +import com.genersoft.iot.vmp.jt1078.annotation.MsgId; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; +import io.netty.util.CharsetUtil; + +/** + * 文件上传指令 + * + */ +@MsgId(id = "9206") +public class J9206 extends Rs { + + // 服务器地址 + private String serverIp; + // 服务器端口 + private int port; + // 用户名 + private String user; + // 密码 + private String password; + // 文件上传路径 + private String path; + // 逻辑通道号 + private int channelId; + + // 开始时间YYMMDDHHMMSS,全0表示无起始时间 + private String startTime; + + // 结束时间YYMMDDHHMMSS,全0表示无终止时间 + private String endTime; + + // 报警标志 + private final int warnType = 0; + + // 音视频资源类型:0.音视频 1.音频 2.视频 3.视频或音视频 + private int mediaType; + + // 码流类型:0.所有码流 1.主码流 2.子码流 + private int streamType = 0; + + // 存储器类型:0.所有存储器 1.主存储器 2.灾备存储器 + private int storageType = 0; + + // 任务执行条件, + // 1:仅WI-FI 下可下载, + // 2: 仅LAN 连接时可下载; + // 3: WI-FI + LAN 连接时可下载; + // 4: 仅3G/ 4G 连接时可下载 + // 5: WI-FI + 3G/ 4G 连接时可下载 + // 6: WI-FI + LAN 连接时可下载 + // 7: WI-FI + LAN + 3G/ 4G 连接时可下载 + private int taskConditions = 7; + + @Override + public ByteBuf encode() { + ByteBuf buffer = Unpooled.buffer(); + + buffer.writeByte(serverIp.getBytes().length); + buffer.writeCharSequence(serverIp, CharsetUtil.UTF_8); + buffer.writeByte(port); + buffer.writeByte(user.getBytes().length); + buffer.writeCharSequence(user, CharsetUtil.UTF_8); + buffer.writeByte(password.getBytes().length); + buffer.writeCharSequence(password, CharsetUtil.UTF_8); + buffer.writeByte(path.getBytes().length); + buffer.writeCharSequence(path, CharsetUtil.UTF_8); + buffer.writeByte(channelId); + buffer.writeBytes(ByteBufUtil.decodeHexDump(startTime)); + buffer.writeBytes(ByteBufUtil.decodeHexDump(endTime)); + buffer.writeLong(warnType); + buffer.writeByte(mediaType); + buffer.writeByte(streamType); + buffer.writeByte(storageType); + buffer.writeByte(taskConditions); + + return buffer; + } + + + public String getServerIp() { + return serverIp; + } + + public void setServerIp(String serverIp) { + this.serverIp = serverIp; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public int getChannelId() { + return channelId; + } + + public void setChannelId(int channelId) { + this.channelId = channelId; + } + + 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; + } + + public int getWarnType() { + return warnType; + } + + public int getMediaType() { + return mediaType; + } + + public void setMediaType(int mediaType) { + this.mediaType = mediaType; + } + + public int getStreamType() { + return streamType; + } + + public void setStreamType(int streamType) { + this.streamType = streamType; + } + + public int getStorageType() { + return storageType; + } + + public void setStorageType(int storageType) { + this.storageType = storageType; + } + + public int getTaskConditions() { + return taskConditions; + } + + public void setTaskConditions(int taskConditions) { + this.taskConditions = taskConditions; + } + + @Override + public String toString() { + return "J9206{" + + "serverIp='" + serverIp + '\'' + + ", port=" + port + + ", user='" + user + '\'' + + ", password='" + password + '\'' + + ", path='" + path + '\'' + + ", channelId=" + channelId + + ", startTime='" + startTime + '\'' + + ", endTime='" + endTime + '\'' + + ", warnType=" + warnType + + ", mediaType=" + mediaType + + ", streamType=" + streamType + + ", storageType=" + storageType + + ", taskConditions=" + taskConditions + + '}'; + } +}