From 829eeaca0ad34b46eb832ca757bd2c86f6bb899b Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期三, 30 八月 2023 15:23:04 +0800
Subject: [PATCH] 增加获取所有app用户
---
ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java | 13 ++++
ard-work/src/main/java/com/ruoyi/utils/gis/GisUtil.java | 1
ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceCallback.java | 14 ++++
ard-work/src/main/java/com/ruoyi/test/Geo/Geofence.java | 42 ++++++++++++++
ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceManager.java | 31 ++++++++++
lib/mediamtx/mediamtx.yml | 2
ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java | 8 +-
ard-work/src/main/java/com/ruoyi/test/Geo/main.java | 52 +++++++++++++++++
8 files changed, 157 insertions(+), 6 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java b/ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java
index c6a0d8c..1fa38bd 100644
--- a/ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java
+++ b/ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java
@@ -130,7 +130,17 @@
return AjaxResult.success(list);
}
-
+ /**
+ * 鑾峰彇鎵�鏈塧pp鐢ㄦ埛
+ */
+ @ApiOperation("鑾峰彇鎵�鏈塧pp鐢ㄦ埛")
+ @GetMapping("/getAppUserList")
+ public AjaxResult getAppUserList(Long deptId) {
+ SysUser user = new SysUser();
+ user.setDeptId(deptId);
+ List<SysUser> list = sysUserService.selectAllAppUserList(user);
+ return AjaxResult.success(list);
+ }
/**
* 鑾峰彇鎵�鏈塧pp鐢ㄦ埛
*/
@@ -186,6 +196,7 @@
lists.add(offlineMap);
return AjaxResult.success(lists);
}
+
/**
* 鑾峰彇鐢ㄦ埛璇︽儏
*/
diff --git a/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java b/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
index c9bc8b8..a122234 100644
--- a/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
+++ b/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
@@ -109,9 +109,9 @@
//GPU纭В鐮佺紪鐮� -hwaccel cuvid -c:v h264_cuvid 浣跨敤cuda瑙g爜 -c:v h264_nvenc 浣跨敤cuda缂栫爜
//String cmd = rootPath + "/lib/mediamtx/" + "ffmpeg -hwaccel cuvid -c:v h264_cuvid -rtsp_transport udp -i " + rtspPath + " -c:v h264_nvenc -r 25 -threads 4 -b:v 2048k -bf 0 -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
if (isCode.equals("1")) {
- String cmd = rootPath + "/lib/mediamtx/" + "ffmpeg -rtsp_transport tcp -i " + rtspPath + " -vcodec libx264 -preset:v ultrafast -r 25 -threads 4 -b:v 2048k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
+ String cmd = rootPath + "/lib/mediamtx/" + "ffmpeg -rtsp_transport tcp -i " + rtspPath + " -vcodec libx264 -preset:v ultrafast -r 25 -threads 6 -b:v 1024k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
if (!softwareDecoding) {
- cmd = rootPath + "/lib/mediamtx/" + "ffmpeg -hwaccel cuvid -c:v h264_cuvid -rtsp_transport udp -i " + rtspPath + " -c:v h264_nvenc -r 25 -threads 4 -b:v 2048k -bf 0 -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
+ cmd = rootPath + "/lib/mediamtx/" + "ffmpeg -hwaccel cuvid -c:v h264_cuvid -rtsp_transport tcp -i " + rtspPath + " -c:v h264_nvenc -r 25 -threads 6 -b:v 2048k -bf 0 -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
}
if (mode.equals("1")) {
mediaInfo.setRunondemand(cmd);
@@ -123,7 +123,7 @@
} else {
mediaInfo.setSource(rtspPath);
}
- mediaInfo.setSourceprotocol("udp");
+ mediaInfo.setSourceprotocol("tcp");
mediaClient.addPath(name, mediaInfo);
return rtspUrl;
}
@@ -141,7 +141,7 @@
info.setMode("1");
} else {
runoninit = item.getConf().getRunoninit();
- info.setMode("2");
+ info.setMode("0");
}
//RTSP婧愬湴鍧�
String regex = "rtsp://[^\\s\"]+";
diff --git a/ard-work/src/main/java/com/ruoyi/test/Geo/Geofence.java b/ard-work/src/main/java/com/ruoyi/test/Geo/Geofence.java
new file mode 100644
index 0000000..6e6435b
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/test/Geo/Geofence.java
@@ -0,0 +1,42 @@
+package com.ruoyi.test.Geo;
+
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.utils.gis.GisUtil;
+import com.ruoyi.utils.gis.Point;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @Description: 鐢靛瓙鏍呮爮
+ * @ClassName: Geofence
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�08鏈�30鏃�9:53:53
+ **/
+@Data
+public class Geofence {
+ private String id;
+ private List<Point> vertices;//椤剁偣鍧愭爣闆嗗悎
+ private GeofenceCallback callback;//鍥存爮鍥炶皟
+
+ public Geofence(String id,List<Point> vertices, GeofenceCallback callback) {
+ this.id=id;
+ this.vertices = vertices;
+ this.callback = callback;
+ }
+
+ public boolean isInside(Point point) {
+ // 瀹炵幇鍧愭爣鏄惁鍦ㄥ洿鏍忓唴鐨勬娴嬮�昏緫
+ // 杩斿洖 true 濡傛灉鍦ㄥ洿鏍忓唴锛屽惁鍒欒繑鍥� false
+ boolean inPolygon = GisUtil.isInPolygon(point, vertices);
+ return inPolygon ? true : false;
+ }
+
+ public void checkAndTrigger(String id,Point point, SysUser user) {
+ if (isInside(point)) {
+ callback.onEnter(id,user);
+ } else {
+ callback.onExit(id,user);
+ }
+ }
+}
diff --git a/ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceCallback.java b/ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceCallback.java
new file mode 100644
index 0000000..df9ede0
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceCallback.java
@@ -0,0 +1,14 @@
+package com.ruoyi.test.Geo;
+
+import com.ruoyi.common.core.domain.entity.SysUser;
+
+/**
+ * @Description: 鐢靛瓙鍥存爮鍥炶皟
+ * @ClassName: GeofenceCallback
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�08鏈�30鏃�9:53:14
+ **/
+public interface GeofenceCallback {
+ void onEnter(String id,SysUser user);
+ void onExit(String id,SysUser user);
+}
diff --git a/ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceManager.java b/ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceManager.java
new file mode 100644
index 0000000..2f79c26
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceManager.java
@@ -0,0 +1,31 @@
+package com.ruoyi.test.Geo;
+
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.utils.gis.Point;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description: 鐢靛瓙鍥存爮绠$悊鍣�
+ * @ClassName: GeofenceManager
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�08鏈�30鏃�9:54:34
+ **/
+class GeofenceManager {
+ private List<Geofence> geofences;
+
+ public GeofenceManager() {
+ geofences = new ArrayList<>();
+ }
+
+ public void addGeofence(Geofence geofence) {
+ geofences.add(geofence);
+ }
+
+ public void checkCoordinates(Point coordinates, SysUser user) {
+ for (Geofence geofence : geofences) {
+ geofence.checkAndTrigger(geofence.getId(),coordinates,user);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ard-work/src/main/java/com/ruoyi/test/Geo/main.java b/ard-work/src/main/java/com/ruoyi/test/Geo/main.java
new file mode 100644
index 0000000..3166f85
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/test/Geo/main.java
@@ -0,0 +1,52 @@
+package com.ruoyi.test.Geo;
+
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.utils.gis.Point;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description:
+ * @ClassName: main
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�08鏈�30鏃�9:55:12
+ **/
+class Main {
+ public static void main(String[] args) {
+ GeofenceManager geofenceManager = new GeofenceManager();
+
+ GeofenceCallback geofenceCallback= new GeofenceCallback() {
+ @Override
+ public void onEnter(String id,SysUser user) {
+ System.out.println("鐢ㄦ埛" + user.getUserId() + "杩涘叆鐢靛瓙鍥存爮" + id + "鍖哄煙锛岃Е鍙戞姤璀︼紒");
+ }
+
+ @Override
+ public void onExit(String id,SysUser user) {
+ System.out.println("鐢ㄦ埛" + user.getUserId() + "鏈湪鐢靛瓙鍥存爮" + id + "鍖哄煙銆�");
+ }
+ };
+
+ List<Point> polygonVertices = new ArrayList<>();
+ polygonVertices.add(new Point(126.6491, 45.739108));
+ polygonVertices.add(new Point(126.643458, 45.731584));
+ polygonVertices.add(new Point(126.654921, 45.726979));
+ polygonVertices.add(new Point(126.660742, 45.734956));
+ Geofence geofence = new Geofence("1",polygonVertices, geofenceCallback);
+ geofenceManager.addGeofence(geofence);
+
+ List<Point> polygonVertices1 = new ArrayList<>();
+ polygonVertices1.add(new Point(126.655244,45.726576));
+ polygonVertices1.add(new Point(126.67242,45.720586));
+ polygonVertices1.add(new Point(126.679606,45.729143));
+ polygonVertices1.add(new Point(126.660993,45.734881));
+ Geofence geofence1 = new Geofence("2",polygonVertices1,geofenceCallback);
+ geofenceManager.addGeofence(geofence1);
+
+ Point userCoordinates = new Point(126.666455,45.727986);
+ SysUser user = new SysUser();
+ user.setUserId("55555");
+ geofenceManager.checkCoordinates(userCoordinates, user);
+ }
+}
\ No newline at end of file
diff --git a/ard-work/src/main/java/com/ruoyi/utils/gis/GisUtil.java b/ard-work/src/main/java/com/ruoyi/utils/gis/GisUtil.java
index 3aafe29..8c669d5 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/gis/GisUtil.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/gis/GisUtil.java
@@ -108,6 +108,7 @@
}
return IsPtInPoly(point,pointList);
}
+
/**
* 鍒ゆ柇鐐规槸鍚﹀湪澶氳竟褰㈠唴锛屽鏋滅偣浣嶄簬澶氳竟褰㈢殑椤剁偣鎴栬竟涓婏紝涔熺畻鍋氱偣鍦ㄥ杈瑰舰鍐咃紝鐩存帴杩斿洖true
* @param point 妫�娴嬬偣
diff --git a/lib/mediamtx/mediamtx.yml b/lib/mediamtx/mediamtx.yml
index 50ec5fa..9598640 100644
--- a/lib/mediamtx/mediamtx.yml
+++ b/lib/mediamtx/mediamtx.yml
@@ -206,7 +206,7 @@
# STUN servers are used to obtain the public IP of server and clients. They are
# needed when server and clients are on different LANs.
# TURN/TURNS servers are needed when a direct connection between server and
- # clients is not possible. All traffic is routed through them.
+ # clients is not possible. All traffic is routed through them. stun:stun.l.google.com:19302
- url: stun:stun.l.google.com:19302
# if user is "AUTH_SECRET", then authentication is secret based.
# the secret must be inserted into the password field.
--
Gitblit v1.9.3