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 39456d2..14cd4ed 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 @@ -1558,6 +1558,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)){ @@ -2501,6 +2503,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; + } + /** * 是否禁行区内 */