From 15ddeaf8523bc34c9078140ed175f41264ea6a24 Mon Sep 17 00:00:00 2001 From: yiming Date: Sat, 16 Apr 2022 17:55:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E8=A7=89=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=85=89=E6=BA=90tcp=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/hik/HikCameraControlModuleImpl.java | 3 ++- .../hikLightSource/HikControlSocket.java | 20 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/web/src/main/java/com/zhehekeji/web/lib/hik/HikCameraControlModuleImpl.java b/web/src/main/java/com/zhehekeji/web/lib/hik/HikCameraControlModuleImpl.java index 450d517..b95859f 100644 --- a/web/src/main/java/com/zhehekeji/web/lib/hik/HikCameraControlModuleImpl.java +++ b/web/src/main/java/com/zhehekeji/web/lib/hik/HikCameraControlModuleImpl.java @@ -257,7 +257,8 @@ public class HikCameraControlModuleImpl implements CameraControlModule { } public void downloadMp4(Integer cameraId, String path, LocalDateTime start, LocalDateTime end) { - + start = start.minusMinutes(1); + end = end.minusMinutes(1); PathUtil.checkDirc(path); Duration duration = Duration.between(start, end); Long seconds = duration.getSeconds(); diff --git a/web/src/main/java/com/zhehekeji/web/service/hikLightSource/HikControlSocket.java b/web/src/main/java/com/zhehekeji/web/service/hikLightSource/HikControlSocket.java index a31060e..784a665 100644 --- a/web/src/main/java/com/zhehekeji/web/service/hikLightSource/HikControlSocket.java +++ b/web/src/main/java/com/zhehekeji/web/service/hikLightSource/HikControlSocket.java @@ -19,13 +19,13 @@ public class HikControlSocket { * <${端口号},${开关状态(0:关 1:开)},${get\post}> */ public static void main(String[] args) { - String code = openLight("172.16.0.82", 9000,2,0); - System.out.println(code); + int code = openLight("172.16.0.72", 9000,2,0); + } - public static String openLight(String ip,int port,int index,int bool){ + public static int openLight(String ip,int port,int index,int bool){ Socket socket = new Socket(); - String code = null; + int status = 0; OutputStream os = null; InputStream is = null; try { @@ -59,8 +59,8 @@ public class HikControlSocket { } catch (IOException e) { e.printStackTrace(); } + return status; - return code; } } @@ -78,12 +78,6 @@ public class HikControlSocket { os.write(bytes); } - private static void getStatus(OutputStream os,int index) throws IOException { - String startCmd = "<"+index+","+0+","+"get>"; - byte [] bytes = startCmd.getBytes(StandardCharsets.UTF_8); - os.write(bytes); - } - private static String read(InputStream inStream) throws IOException { StringBuffer sb = new StringBuffer(); int start = -1; @@ -95,7 +89,7 @@ public class HikControlSocket { inStream.read(buffer); String s = new String(buffer, Charset.forName("utf-8")); sb.append(s); - System.out.println(s); + if(start < 0){ start = sb.indexOf("<"); } @@ -105,7 +99,7 @@ public class HikControlSocket { } }while (start <0 || end <= start); - return sb.substring(start,end); + return sb.substring(start,end+1); } }