From 7e28149acdcf0c7dd59171c0ec63807759c86c00 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期二, 05 九月 2023 10:41:35 +0800 Subject: [PATCH] 电子围栏报警区分禁入禁出 电子围栏报警查看标记增加毫秒 初始化程序增加启动顺序 --- ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java | 95 +++++++++++++++++++++++++++++++---------------- 1 files changed, 62 insertions(+), 33 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java b/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java index db67b30..614f958 100644 --- a/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java +++ b/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); - //鏇存柊鏈�鍚庢姤璀d - 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); + //鏇存柊鏈�鍚庢姤璀d + userInLastAlarm.put(userId, uuid); + } else { + //涓婁竴娆$敤鎴风姸鎬佸凡杩涘叆锛屾洿鏂版渶鍚庢姤璀� + ardAlarmWall.setId(lastInAlarmId); + ardAlarmWallService.updateArdAlarmWall(ardAlarmWall); + } + ardAlarmWalls.add(ardAlarmWall); } - ardAlarmWalls.add(ardAlarmWall); + else + { + //绉婚櫎鏈�鍚庢姤璀d + userInLastAlarm.remove(userId); + } } - else + else//绂佸嚭 { - //绉婚櫎鏈�鍚庢姤璀d - userLastAlarm.remove(userId); + //鍒ゆ柇褰撳墠鐢ㄦ埛浣嶇疆鏄惁鍦ㄥ洿鏍忓 + if (!inPolygon) { + String lastAlarmId = userOutLastAlarm.get(userId); + if (lastAlarmId == null) { + String uuid = IdUtils.simpleUUID(); + //褰撳墠鐢ㄦ埛涓婁竴娆$姸鎬佹湭杩涘叆锛岀敓鎴愭姤璀� + ardAlarmWall.setId(uuid); + ardAlarmWallService.insertArdAlarmWall(ardAlarmWall); + //鏇存柊鏈�鍚庢姤璀d + userOutLastAlarm.put(userId, uuid); + } else { + //涓婁竴娆$敤鎴风姸鎬佸凡杩涘叆锛屾洿鏂版渶鍚庢姤璀� + ardAlarmWall.setId(lastAlarmId); + ardAlarmWallService.updateArdAlarmWall(ardAlarmWall); + } + ardAlarmWalls.add(ardAlarmWall); + } + else + { + //绉婚櫎鏈�鍚庢姤璀d + userOutLastAlarm.remove(userId); + } } + } } return ardAlarmWalls; -- Gitblit v1.9.3