From 2400238fd8ae34a2f10a4ea35db9b1739c534a7e Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期日, 08 十月 2023 13:34:04 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/cmd/startup.java | 5 +-
ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java | 41 +++++++++++++++-----
ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java | 4 ++
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/syncDeviceStateTask.java | 43 +++++++++++++++++++++
ard-work/src/main/java/com/ruoyi/device/hiksdk/sdk/LoginResultCallBack.java | 2 +
ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml | 5 ++
6 files changed, 86 insertions(+), 14 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/cmd/startup.java b/ard-work/src/main/java/com/ruoyi/cmd/startup.java
index 1f6c2c5..22a0ca0 100644
--- a/ard-work/src/main/java/com/ruoyi/cmd/startup.java
+++ b/ard-work/src/main/java/com/ruoyi/cmd/startup.java
@@ -73,7 +73,7 @@
@PostConstruct
public void init() {
if (minioEnabled) {
- log.debug("鍒濆鍖栧惎鍔╩inio");
+ log.info("鍒濆鍖栧惎鍔╩inio");
if (Platform.isWindows()) {
String exePath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "minio" + File.separator + minioName;
Map<String, String> env = new HashMap<>();
@@ -97,7 +97,7 @@
}
}
if (mediamtxEnabled) {
- log.debug("鍒濆鍖栧惎鍔╩ediaMTX");
+ log.info("鍒濆鍖栧惎鍔╩ediaMTX");
if (Platform.isWindows()) {
String exePath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "mediamtx" + File.separator + mediamtxName;
String ymlPath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "mediamtx" + File.separator + "mediamtx.yml";
@@ -117,6 +117,7 @@
}
}
if (webrtcEnabled) {
+ log.info("鍒濆鍖栧惎鍔╳ebrtc-streamer");
if (Platform.isWindows()) {
String exePath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "webrtc" + File.separator + webrtcName;
List<String> cmd = new ArrayList<>();
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java b/ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java
index 1c8ed55..aaec59e 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java
@@ -171,6 +171,10 @@
* 鐧诲綍ID
*/
private Integer loginId;
+ /**
+ * 鍦ㄧ嚎鐘舵�� 0-绂荤嚎 1-鍦ㄧ嚎
+ */
+ private String state;
private String operatorId;
private Date operatorExpired;
/**
diff --git a/ard-work/src/main/java/com/ruoyi/device/hiksdk/sdk/LoginResultCallBack.java b/ard-work/src/main/java/com/ruoyi/device/hiksdk/sdk/LoginResultCallBack.java
index 8f369f6..a665815 100644
--- a/ard-work/src/main/java/com/ruoyi/device/hiksdk/sdk/LoginResultCallBack.java
+++ b/ard-work/src/main/java/com/ruoyi/device/hiksdk/sdk/LoginResultCallBack.java
@@ -47,6 +47,7 @@
GlobalVariable.loginMap.put(camera.getId(), lUserID);
log.debug(camera.getIp() + ":" + camera.getPort() + "鐧诲綍鎴愬姛");
camera.setLoginId(lUserID);
+ camera.setState("1");
camera.setChanNum((int) lpDeviceinfo.byChanNum);
camera.setStartDChan((int) lpDeviceinfo.byStartDChan);
//鑾峰彇鏈�鏂伴�氶亾
@@ -68,6 +69,7 @@
log.debug(camera.getIp() + ":" + camera.getPort() + "鐧诲綍澶辫触");
camera.setChanNum(0);
camera.setLoginId(-1);
+ camera.setState("0");
}
ardCamerasService.updateArdCameras(camera);
return 1;
diff --git a/ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java b/ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java
index 2dcf2b0..e9d1151 100644
--- a/ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java
+++ b/ard-work/src/main/java/com/ruoyi/test/ReadAccessDatabase.java
@@ -10,6 +10,11 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
import java.sql.*;
@@ -18,18 +23,21 @@
public class ReadAccessDatabase {
public static void main(String[] args) {
+ Boolean aBoolean = IsConnectTcpServer("127.0.0.1", 1200, 100);
+ String message = aBoolean ? "success" : "fail";
+ log.info(message);
// 澶氫釜鏁版嵁搴撴枃浠惰矾寰�
- String[] dbPaths = {
- "D:\\Workspaces\\ard\\瀹夌憺杈惧伐浣滆祫鏂橽\mdb\\閬撹矾涓績绾�.mdb"
-// "D:\\Workspaces\\ard\\瀹夌憺杈惧伐浣滆祫鏂橽\mdb\\闃查鏋�-鐏屾湪.mdb",
- // 娣诲姞鏇村鐨勬暟鎹簱鏂囦欢璺緞
- };
-
- // 閬嶅巻姣忎釜鏁版嵁搴撴枃浠�
- for (String dbPath : dbPaths) {
- readDataFromAccessDatabase(dbPath);
- }
+// String[] dbPaths = {
+// "D:\\Workspaces\\ard\\瀹夌憺杈惧伐浣滆祫鏂橽\mdb\\閬撹矾涓績绾�.mdb"
+//// "D:\\Workspaces\\ard\\瀹夌憺杈惧伐浣滆祫鏂橽\mdb\\闃查鏋�-鐏屾湪.mdb",
+// // 娣诲姞鏇村鐨勬暟鎹簱鏂囦欢璺緞
+// };
+//
+// // 閬嶅巻姣忎釜鏁版嵁搴撴枃浠�
+// for (String dbPath : dbPaths) {
+// readDataFromAccessDatabase(dbPath);
+// }
}
public static void readDataFromAccessDatabase(String dbPath) {
@@ -73,7 +81,7 @@
// 鍙互鏍规嵁鍏蜂綋鐨勮〃缁撴瀯缁х画鑾峰彇鍏朵粬瀛楁鐨勬暟鎹�
// 鍦ㄨ繖閲屽鐞嗚幏鍙栧埌鐨勬暟鎹紝渚嬪杈撳嚭鍒版帶鍒跺彴鎴栦繚瀛樺埌闆嗗悎涓�
- log.info("ID: " + id + ", No: " + no+ ", Name: " + name);
+ log.info("ID: " + id + ", No: " + no + ", Name: " + name);
}
// 鍏抽棴杩炴帴
resultSet.close();
@@ -86,6 +94,17 @@
}
}
+ public static Boolean IsConnectTcpServer(String ip,Integer port,Integer timeOut) {
+ try {
+ Socket socket = new Socket();
+ socket.connect(new InetSocketAddress(ip, port), timeOut);
+ socket.close();
+ return true;
+ } catch (IOException e) {
+ // log.error(e.getMessage());
+ return false;
+ }
+ }
}
diff --git a/ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml b/ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml
index 4e17b31..c8fa4e0 100644
--- a/ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml
+++ b/ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml
@@ -32,6 +32,7 @@
<result property="operatorExpired" column="operator_expired"/>
<result property="camMaxVisibleDistance" column="cam_max_visible_distance"/>
<result property="camAlarmGuideEnable" column="cam_alarm_guide_enable"/>
+ <result property="state" column="state"/>
</resultMap>
<sql id="selectArdCamerasVo">
@@ -61,7 +62,8 @@
c.operator_id,
c.operator_expired,
c.cam_max_visible_distance,
- c.cam_alarm_guide_enable
+ c.cam_alarm_guide_enable,
+ c.state
from ard_cameras c
left join sys_dept d on d.dept_id = c.dept_id
left join sys_user u on u.user_id = c.user_id
@@ -236,6 +238,7 @@
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="operatorId != null">operator_id = #{operatorId},</if>
<if test="operatorExpired != null">operator_expired = #{operatorExpired},</if>
+ <if test="state != null">state = #{state},</if>
</trim>
where id = #{id}
</update>
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/syncDeviceStateTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/syncDeviceStateTask.java
new file mode 100644
index 0000000..4f13eaf
--- /dev/null
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/syncDeviceStateTask.java
@@ -0,0 +1,43 @@
+package com.ruoyi.quartz.task;
+
+import com.ruoyi.device.camera.domain.ArdCameras;
+import com.ruoyi.device.camera.domain.CameraCmd;
+import com.ruoyi.device.camera.service.IArdCamerasService;
+import com.ruoyi.device.hiksdk.service.IHikClientService;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @Description: 鍚屾璁惧鐘舵�佷换鍔�
+ * @ClassName: syncDeviceStateTask
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�10鏈�08鏃�11:06:42
+ **/
+@Component("syncTask")
+public class syncDeviceStateTask {
+ @Resource
+ IArdCamerasService iArdCamerasService;
+ @Resource
+ IHikClientService iHikClientService;
+
+ public void cameraState() {
+ List<ArdCameras> ardCameras = iArdCamerasService.selectArdCamerasListNoDataScope(new ArdCameras());
+ for (ArdCameras camera : ardCameras) {
+ CameraCmd cmd = new CameraCmd();
+ cmd.setCameraId(camera.getId());
+ boolean onLineNew = iHikClientService.isOnLine(cmd);//鐩告満瀹炴椂鐘舵��
+ boolean onLineOld = "1".equals(camera.getState());//鐩告満鍘嗗彶鐘舵��
+ //褰撶姸鎬佸彂鐢熷彉鍖栨椂锛屾洿鏂板疄鏃剁姸鎬�
+ if (onLineNew != onLineOld) {
+ if (onLineNew) {
+ camera.setState("1");
+ } else {
+ camera.setState("0");
+ }
+ iArdCamerasService.updateArdCameras(camera);
+ }
+ }
+ }
+}
--
Gitblit v1.9.3