From a2049b0d60bea813a1162657a898540de731515b Mon Sep 17 00:00:00 2001 From: George Date: Sat, 11 Apr 2026 17:17:17 +0800 Subject: [PATCH] =?UTF-8?q?20260411:=E6=95=B0=E6=8D=AE=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=8E=A8=E9=80=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/backend/BackendController.java | 19 +++++++++ .../iot/data/aspect/DeviceDebugLogAspect.java | 3 +- .../http/map/GaodeLocationService.java | 41 ++++++++++--------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/fastbee-admin/src/main/java/com/fastbee/web/controller/backend/BackendController.java b/fastbee-admin/src/main/java/com/fastbee/web/controller/backend/BackendController.java index c2e556d9..cbf52b6b 100644 --- a/fastbee-admin/src/main/java/com/fastbee/web/controller/backend/BackendController.java +++ b/fastbee-admin/src/main/java/com/fastbee/web/controller/backend/BackendController.java @@ -90,6 +90,25 @@ public class BackendController { return AjaxResult.success(addressByCoordinate); } + // convertPlatformCoordinateFromWgs84 + @ApiOperation("将WGS84转化为对应平台经纬度") + @PreAuthorize("@ss.hasPermi('monitor:cache:remove')") + @GetMapping("/convertPlatformCoordinateFromWgs84") + public AjaxResult convertPlatformCoordinateFromWgs84(@RequestParam("coordinate") String coordinate, @RequestParam("provider") String provider) { + if (StringUtils.isEmpty(coordinate)) { + return AjaxResult.error("coordinate不能为空"); + } + + String[] split = coordinate.split(","); + + // 工厂模式获取定位服务 + ILocationService service = locationServiceFactory.getLocationService(provider); + Coordinate c = new Coordinate(BigDecimal.valueOf(Double.parseDouble(split[0])), BigDecimal.valueOf(Double.parseDouble(split[1]))); + Coordinate platformCoordinate = service.convertPlatformCoordinateFromWgs84(c); + + return AjaxResult.success(platformCoordinate); + } + // getCoordinateByAddress @ApiOperation("根据地址获取坐标(正地理编码)") @PreAuthorize("@ss.hasPermi('monitor:cache:remove')") diff --git a/fastbee-iot-data/src/main/java/com/fastbee/iot/data/aspect/DeviceDebugLogAspect.java b/fastbee-iot-data/src/main/java/com/fastbee/iot/data/aspect/DeviceDebugLogAspect.java index 457f8278..f8d78640 100644 --- a/fastbee-iot-data/src/main/java/com/fastbee/iot/data/aspect/DeviceDebugLogAspect.java +++ b/fastbee-iot-data/src/main/java/com/fastbee/iot/data/aspect/DeviceDebugLogAspect.java @@ -9,7 +9,6 @@ import com.fastbee.common.core.mq.message.DeviceMessage; import com.fastbee.common.core.thingsModel.ThingsModelSimpleItem; import com.fastbee.common.enums.DeviceLogTypeEnum; import com.fastbee.common.enums.TopicType; -import com.fastbee.common.utils.DateUtils; import com.fastbee.common.utils.StringUtils; import com.fastbee.common.utils.dtu.ATCommandParserUtils; import com.fastbee.common.utils.gateway.mq.TopicsUtils; @@ -350,7 +349,7 @@ public class DeviceDebugLogAspect { } updateDevice.setDeviceId(device.getDeviceId()); updateDevice.setUpdateBy("DTU"); - updateDevice.setUpdateTime(DateUtils.getNowDate()); + //updateDevice.setUpdateTime(DateUtils.getNowDate()); deviceMapper.updateDevice(updateDevice); } diff --git a/fastbee-plugs/fastbee-http/src/main/java/com/fastbee/http/map/GaodeLocationService.java b/fastbee-plugs/fastbee-http/src/main/java/com/fastbee/http/map/GaodeLocationService.java index d4bcbdd2..077a60a8 100644 --- a/fastbee-plugs/fastbee-http/src/main/java/com/fastbee/http/map/GaodeLocationService.java +++ b/fastbee-plugs/fastbee-http/src/main/java/com/fastbee/http/map/GaodeLocationService.java @@ -184,6 +184,27 @@ public class GaodeLocationService implements ILocationService { return info; } + @Override + public Coordinate convertToWgs84(Coordinate marsCoordinate) { + // 将高德(火星)坐标 转化为 世界坐标 + double[] doubles = CoordinateTransformUtils.gcj02ToWgs84( + marsCoordinate.getLongitude().doubleValue(), + marsCoordinate.getLatitude().doubleValue() + ); + + return new Coordinate(BigDecimal.valueOf(doubles[0]), BigDecimal.valueOf(doubles[1])); + } + + @Override + public Coordinate convertPlatformCoordinateFromWgs84(Coordinate wgs84Coordinate) { + // 将世界坐标 转化为 高德(火星)坐标 + double[] doubles = CoordinateTransformUtils.wgs84ToGcj02( + wgs84Coordinate.getLongitude().doubleValue(), + wgs84Coordinate.getLatitude().doubleValue() + ); + return new Coordinate(BigDecimal.valueOf(doubles[0]), BigDecimal.valueOf(doubles[1])); + } + /** * 高德部分字段在数据缺失时为 JSON 数组(含空数组 {@code []}),直接 {@link JSONObject#getString(String)} 会得到字面量 {@code "[]"}。 * 本方法仅返回有意义的非空文本,否则返回 {@code null}。 @@ -271,24 +292,4 @@ public class GaodeLocationService implements ILocationService { return sb.toString(); } - @Override - public Coordinate convertToWgs84(Coordinate marsCoordinate) { - // 将高德(火星)坐标 转化为 世界坐标 - double[] doubles = CoordinateTransformUtils.gcj02ToWgs84( - marsCoordinate.getLongitude().doubleValue(), - marsCoordinate.getLatitude().doubleValue() - ); - - return new Coordinate(BigDecimal.valueOf(doubles[0]), BigDecimal.valueOf(doubles[1])); - } - - @Override - public Coordinate convertPlatformCoordinateFromWgs84(Coordinate wgs84Coordinate) { - // 将世界坐标 转化为 高德(火星)坐标 - double[] doubles = CoordinateTransformUtils.wgs84ToGcj02( - wgs84Coordinate.getLongitude().doubleValue(), - wgs84Coordinate.getLatitude().doubleValue() - ); - return new Coordinate(BigDecimal.valueOf(doubles[0]), BigDecimal.valueOf(doubles[1])); - } }