aijinhui
2023-09-05 e42d5134188b4e93ebb0580ef60034976c987f0f
Merge remote-tracking branch 'origin/master'
已修改9个文件
155 ■■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/wall/domain/ArdAlarmWall.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/wall/service/impl/ArdAlarmWallServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/media/controller/MediaController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/media/service/impl/MediaServiceImpl.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumer.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/mapper/alarmpoints/ArdWallMapper.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/templates/preview.html 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/global/service/impl/GlobalAlarmServiceImpl.java
@@ -592,6 +592,7 @@
    @Override
    public Object updateAlarmViewTime(GlobalAlarmCondition condition) {
        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat fmtms = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        switch (condition.getCommand()) {
            case 1001:
                ArdAlarmStealelec ardAlarmStealelec = ardAlarmStealelecMapper.selectByPrimaryKey(condition.getId());
@@ -662,7 +663,7 @@
                ArdAlarmWall ardAlarmWall = ardAlarmWallMapper.selectArdAlarmWallById(condition.getId());
                if (StringUtils.isNotNull(ardAlarmWall)) {
                    String userId = ardAlarmWall.getUserId();
                    String alarmTime = fmt.format(ardAlarmWall.getCreateTime());
                    String alarmTime = fmtms.format(ardAlarmWall.getAlarmTime());
                    ardAlarmWallMapper.updateViewTimeByUserId(userId, alarmTime, DateUtils.getTime());
                    return ardAlarmWall;
                }
ard-work/src/main/java/com/ruoyi/alarm/wall/domain/ArdAlarmWall.java
@@ -6,6 +6,7 @@
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
/**
 * 电子围栏报警对象 ard_alarm_wall
ard-work/src/main/java/com/ruoyi/alarm/wall/service/impl/ArdAlarmWallServiceImpl.java
@@ -50,7 +50,6 @@
     */
    @Override
    public int insertArdAlarmWall(ArdAlarmWall ardAlarmWall) {
                ardAlarmWall.setCreateBy(SecurityUtils.getUsername());
                ardAlarmWall.setCreateTime(DateUtils.getNowDate());
            return ardAlarmWallMapper.insertArdAlarmWall(ardAlarmWall);
ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
@@ -21,6 +21,7 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -228,14 +229,15 @@
    ArdWallMapper ardWallMapper;
    @Resource
    IArdAlarmWallService ardAlarmWallService;
    Map<String, String> userLastAlarm = new HashMap<>();
    Map<String, String> userInLastAlarm = new HashMap<>();
    Map<String, String> userOutLastAlarm = new HashMap<>();
    /**
     * 实时位置检测围栏报警
     * 刘苏义
     * 2023/8/31 8:54:06
     */
    public List<ArdAlarmWall> DetectionWallAlarm(ArdAppPosition ardAppPosition) {
        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<ArdAlarmWall> ardAlarmWalls=new ArrayList<>();
        //获取当前用户的部门
        String userId = ardAppPosition.getUserId();
@@ -248,6 +250,7 @@
        if (ardWalls.size() > 0) {
            for (ArdWall wall : ardWalls) {
                String wallPoi = wall.getWallPoi();
                String wallType = wall.getType();
                //处理多边形的每个点的经纬度
                String[] parts = wallPoi.split(",");
                List<Point> pointList = new ArrayList<>();
@@ -257,42 +260,68 @@
                    point.setLatitude(Double.valueOf(parts[i + 1]));
                    pointList.add(point);
                }
                //判断当前用户位置是否在围栏内
                Point userPoint=new Point();
                userPoint.setLongitude(ardAppPosition.getLongitude());
                userPoint.setLatitude(ardAppPosition.getLatitude());
                Point userPoint=new Point(ardAppPosition.getLongitude(),ardAppPosition.getLatitude());
                boolean inPolygon = GisUtil.isInPolygon(userPoint, pointList);
                if (inPolygon) {
                    String lastAlarmId = userLastAlarm.get(userId);
                    ArdAlarmWall ardAlarmWall = new ArdAlarmWall();
                    ardAlarmWall.setWallId(wall.getId());
                    ardAlarmWall.setWallName(wall.getWallName());
                    ardAlarmWall.setUserId(userId);
                    ardAlarmWall.setAlarmTime(new Date());
                    ardAlarmWall.setAlarmType(wall.getType());
                    ardAlarmWall.setLongitude(ardAppPosition.getLongitude());
                    ardAlarmWall.setLatitude(ardAppPosition.getLatitude());
                    ardAlarmWall.setAltitude(ardAppPosition.getAltitude());
                    if (lastAlarmId == null) {
                        String uuid = IdUtils.simpleUUID();
                        //    当前用户上一次状态未进入,生成报警
                        ardAlarmWall.setId(uuid);
                        ardAlarmWallService.insertArdAlarmWall(ardAlarmWall);
                        //更新最后报警id
                        userLastAlarm.put(userId, uuid);
                    } else {
                        //    上一次用户状态已进入,更新最后报警
                        ardAlarmWall.setId(lastAlarmId);
                        ardAlarmWallService.updateArdAlarmWall(ardAlarmWall);
                ArdAlarmWall ardAlarmWall = new ArdAlarmWall();
                ardAlarmWall.setWallId(wall.getId());
                ardAlarmWall.setWallName(wall.getWallName());
                ardAlarmWall.setUserId(userId);
                ardAlarmWall.setAlarmTime(DateUtils.getNowDate());
                ardAlarmWall.setAlarmType(wall.getType());
                ardAlarmWall.setLongitude(ardAppPosition.getLongitude());
                ardAlarmWall.setLatitude(ardAppPosition.getLatitude());
                ardAlarmWall.setAltitude(ardAppPosition.getAltitude());
                //禁入
                if("1".equals(wallType)) {
                    //判断当前用户位置是否在围栏内
                    if (inPolygon) {
                        String lastInAlarmId = userInLastAlarm.get(userId);
                        if (lastInAlarmId == null) {
                            String uuid = IdUtils.simpleUUID();
                            //当前用户上一次状态未进入,生成报警
                            ardAlarmWall.setId(uuid);
                            ardAlarmWallService.insertArdAlarmWall(ardAlarmWall);
                            //更新最后报警id
                            userInLastAlarm.put(userId, uuid);
                        } else {
                            //上一次用户状态已进入,更新最后报警
                            ardAlarmWall.setId(lastInAlarmId);
                            ardAlarmWallService.updateArdAlarmWall(ardAlarmWall);
                        }
                        ardAlarmWalls.add(ardAlarmWall);
                    }
                    ardAlarmWalls.add(ardAlarmWall);
                    else
                    {
                        //移除最后报警id
                        userInLastAlarm.remove(userId);
                    }
                }
                else
                else//禁出
                {
                    //移除最后报警id
                    userLastAlarm.remove(userId);
                    //判断当前用户位置是否在围栏外
                    if (!inPolygon) {
                        String lastAlarmId = userOutLastAlarm.get(userId);
                        if (lastAlarmId == null) {
                            String uuid = IdUtils.simpleUUID();
                            //当前用户上一次状态未进入,生成报警
                            ardAlarmWall.setId(uuid);
                            ardAlarmWallService.insertArdAlarmWall(ardAlarmWall);
                            //更新最后报警id
                            userOutLastAlarm.put(userId, uuid);
                        } else {
                            //上一次用户状态已进入,更新最后报警
                            ardAlarmWall.setId(lastAlarmId);
                            ardAlarmWallService.updateArdAlarmWall(ardAlarmWall);
                        }
                        ardAlarmWalls.add(ardAlarmWall);
                    }
                    else
                    {
                        //移除最后报警id
                        userOutLastAlarm.remove(userId);
                    }
                }
            }
        }
        return ardAlarmWalls;
ard-work/src/main/java/com/ruoyi/media/controller/MediaController.java
@@ -101,7 +101,7 @@
    @ApiOperation("移除拉流")
    @ApiOperationSupport(order =4 )
    @PreAuthorize("@ss.hasPermi('media:stream:remove')")
    @DeleteMapping("/{id}")
    @DeleteMapping("/{sessionId}")
    public AjaxResult removePullStreamSession(@PathVariable String sessionId) {
        List<StreamInfo> pullStreamList = mediaService.getPullStreamList();
        StreamInfo streamInfo = pullStreamList.stream()
ard-work/src/main/java/com/ruoyi/media/service/impl/MediaServiceImpl.java
@@ -11,6 +11,9 @@
import com.sun.jna.Platform;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@@ -33,7 +36,8 @@
 **/
@Service
@Slf4j(topic = "cmd")
public class MediaServiceImpl implements IMediaService {
@Order(1)
public class MediaServiceImpl implements IMediaService, ApplicationRunner {
    @Resource
    VtduMapper vtduMapper;
    @Resource
@@ -47,12 +51,24 @@
    String processName = "mediamtx.exe";
    static{
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("开始加载流媒体列表");
        List<StreamInfo> paths = paths();
        for(StreamInfo path:paths)
        {
            mediaClient.removePath(path.getName());
        }
        List<Vtdu> vtduList = vtduMapper.selectVtduList(new Vtdu());
        for (Vtdu v : vtduList) {
            addPath(v.getName(), v.getRtspUrl(), v.getCodeType(), v.getIsCode());
        }
    }
    @PostConstruct
    public void initMediaMtx() {
        if (mediamtxEnabled) {
            log.info("初始化启动mediaMTX");
            if (Platform.isWindows()) {
                String exePath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "mediamtx" + File.separator + "mediamtx.exe";
                String ymlPath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "mediamtx" + File.separator + "mediamtx.yml";
@@ -70,20 +86,6 @@
//            String[] command = {"cmd","/c","start",exePath,ymlPath};
//            CmdUtils.commandStart(command);
            }
        }
        try {
            Thread.sleep(2000); // 等待5秒
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        List<StreamInfo> paths = paths();
        for(StreamInfo path:paths)
        {
            mediaClient.removePath(path.getName());
        }
        List<Vtdu> vtduList = vtduMapper.selectVtduList(new Vtdu());
        for (Vtdu v : vtduList) {
            addPath(v.getName(), v.getRtspUrl(), v.getCodeType(), v.getIsCode());
        }
    }
@@ -456,4 +458,5 @@
            return false;
        }
    }
}
ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumer.java
@@ -6,6 +6,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
/**
@@ -17,6 +18,7 @@
 **/
@Component
@Slf4j(topic = "mqtt")
@Order(2)
public class MqttConsumer implements ApplicationRunner {
    @Value("${mqtt.enabled}")
ard-work/src/main/resources/mapper/alarmpoints/ArdWallMapper.xml
@@ -42,8 +42,10 @@
            <if test="wallPoi != null  and wallPoi != ''"> and wall_poi = #{wallPoi}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="color != null  and color != ''"> and color = #{color}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="deptId != null ">and (dept_id = #{deptId} OR dept_id IN ( SELECT t.dept_id FROM sys_dept t
                WHERE cast(#{deptId} as varchar) = any(string_to_array(ancestors,',')) ))
            </if>
        </where>
    </select>
    
ard-work/src/main/resources/templates/preview.html
@@ -151,11 +151,15 @@
    var chanMap = new Map();
    window.onload = function () {
        changeGrid(2, 2);
        chanMap.set("video1", "http://127.0.0.1:8889/245/");
        chanMap.set("video2", "http://127.0.0.1:8889/164/");
        chanMap.set("video3", "http://127.0.0.1:8889/164/");
        chanMap.set("video4", "http://127.0.0.1:8889/165/");
        chanMap.set("video1", "http://127.0.0.1:8889/164/");
        chanMap.set("video2", "http://127.0.0.1:8889/165/");
        chanMap.set("video3", "http://127.0.0.1:8889/245/");
        chanMap.set("video4", "http://127.0.0.1:8889/164/");
        chanMap.set("video5", "http://127.0.0.1:8889/165/");
        chanMap.set("video6", "http://127.0.0.1:8889/245/");
        chanMap.set("video7", "http://127.0.0.1:8889/164/");
        chanMap.set("video8", "http://127.0.0.1:8889/165/");
        chanMap.set("video9", "http://127.0.0.1:8889/245/");
        console.log(chanMap);
    }
    const linkToIceServers = (links) => (