‘liusuyi’
2023-08-30 829eeaca0ad34b46eb832ca757bd2c86f6bb899b
增加获取所有app用户
已添加4个文件
已修改4个文件
163 ■■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/test/Geo/Geofence.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceCallback.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/test/Geo/GeofenceManager.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/test/Geo/main.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/utils/gis/GisUtil.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/mediamtx/mediamtx.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/app/position/controller/ArdAppPositionController.java
@@ -130,7 +130,17 @@
        return AjaxResult.success(list);
    }
    /**
     * èŽ·å–æ‰€æœ‰app用户
     */
    @ApiOperation("获取所有app用户")
    @GetMapping("/getAppUserList")
    public AjaxResult getAppUserList(Long deptId) {
        SysUser user = new SysUser();
        user.setDeptId(deptId);
        List<SysUser> list = sysUserService.selectAllAppUserList(user);
        return AjaxResult.success(list);
    }
    /**
     * èŽ·å–æ‰€æœ‰app用户
     */
@@ -186,6 +196,7 @@
        lists.add(offlineMap);
        return AjaxResult.success(lists);
    }
    /**
     * èŽ·å–ç”¨æˆ·è¯¦æƒ…
     */
ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
@@ -109,9 +109,9 @@
        //GPU硬解码编码 -hwaccel cuvid -c:v h264_cuvid  ä½¿ç”¨cuda解码   -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\"]+";
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);
        }
    }
}
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);
}
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);
        }
    }
}
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);
    }
}
ard-work/src/main/java/com/ruoyi/utils/gis/GisUtil.java
@@ -108,6 +108,7 @@
        }
        return IsPtInPoly(point,pointList);
    }
    /**
     * åˆ¤æ–­ç‚¹æ˜¯å¦åœ¨å¤šè¾¹å½¢å†…,如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true
     * @param point æ£€æµ‹ç‚¹
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.