From 4168a82f4cc7998686076ef3852ed7933bbc9ffa Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Mon, 24 Feb 2025 16:48:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E9=94=81=E8=BD=A6=E6=97=B6?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E5=9C=A8=E5=81=9C=E8=BD=A6?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AsDeviceServiceImpl.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index a0448db..43dc032 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -1553,6 +1553,8 @@ public class AsDeviceServiceImpl extends ServiceImpl i sn = order.getSn(); } AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn); + //判断是否在禁停区内,如果在禁停区内,不能还车。 noParkingArea 最新定位 + ServiceUtil.assertion(isNoParkingAreaLatest(asDevice, order.getAreaId()),"在禁停区内,不能锁车"); /** 1.获取token*/ String token = Token.getToken(); if(!"true".equals(isBluetooth)){ @@ -2499,6 +2501,39 @@ public class AsDeviceServiceImpl extends ServiceImpl i return inCircle; } + /** + * 是否禁停区内 + */ + public boolean isNoParkingAreaLatest(AsDevice device,Long areaId) { + boolean inCircle = false; + EtParkingArea parkingArea = new EtParkingArea(); + parkingArea.setAreaId(areaId); + parkingArea.setStatus("0"); + parkingArea.setType(ServiceConstants.PARKING_AREA_TYPE_NO_PARKFING); + List parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea); + if(ObjectUtil.isNull(parkingAreas) || parkingAreas.isEmpty()){ + log.info("【临时锁车】运营区【{}】没有禁停区,",areaId); + return false; + } + for (EtParkingArea etParkingArea : parkingAreas) { + double[] latestLocation = getLatestLocation(device.getMac()); + if(ObjectUtil.isNotNull(latestLocation)){ + BigDecimal latitude = BigDecimal.valueOf(latestLocation[1]).setScale(8, RoundingMode.HALF_UP); + BigDecimal longitude = BigDecimal.valueOf(latestLocation[0]).setScale(8, RoundingMode.HALF_UP); + log.info("【临时锁车】【判断是否在停车区】,lon:{},lat:{}",latitude,longitude); + Geometry geometry = GeoUtils.fromWkt(etParkingArea.getBoundary()); + inCircle = GeoUtils.isInCircle(longitude.toString(), latitude.toString(), geometry); + if(inCircle){ + log.info("【临时锁车】车辆【{}】在禁停区【{}】内",device.getSn(),etParkingArea.getParkingName()); + return inCircle; + }else{ + log.info("【临时锁车】车辆【{}】不在禁停区【{}】内",device.getSn(),etParkingArea.getParkingName()); + } + } + } + return inCircle; + } + /** * 是否禁行区内 */