20260411:数据推送模板推送优化

This commit is contained in:
George 2026-04-11 17:17:17 +08:00
parent bb2bd720fb
commit a2049b0d60
3 changed files with 41 additions and 22 deletions

View File

@ -90,6 +90,25 @@ public class BackendController {
return AjaxResult.success(addressByCoordinate); 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 // getCoordinateByAddress
@ApiOperation("根据地址获取坐标(正地理编码)") @ApiOperation("根据地址获取坐标(正地理编码)")
@PreAuthorize("@ss.hasPermi('monitor:cache:remove')") @PreAuthorize("@ss.hasPermi('monitor:cache:remove')")

View File

@ -9,7 +9,6 @@ import com.fastbee.common.core.mq.message.DeviceMessage;
import com.fastbee.common.core.thingsModel.ThingsModelSimpleItem; import com.fastbee.common.core.thingsModel.ThingsModelSimpleItem;
import com.fastbee.common.enums.DeviceLogTypeEnum; import com.fastbee.common.enums.DeviceLogTypeEnum;
import com.fastbee.common.enums.TopicType; import com.fastbee.common.enums.TopicType;
import com.fastbee.common.utils.DateUtils;
import com.fastbee.common.utils.StringUtils; import com.fastbee.common.utils.StringUtils;
import com.fastbee.common.utils.dtu.ATCommandParserUtils; import com.fastbee.common.utils.dtu.ATCommandParserUtils;
import com.fastbee.common.utils.gateway.mq.TopicsUtils; import com.fastbee.common.utils.gateway.mq.TopicsUtils;
@ -350,7 +349,7 @@ public class DeviceDebugLogAspect {
} }
updateDevice.setDeviceId(device.getDeviceId()); updateDevice.setDeviceId(device.getDeviceId());
updateDevice.setUpdateBy("DTU"); updateDevice.setUpdateBy("DTU");
updateDevice.setUpdateTime(DateUtils.getNowDate()); //updateDevice.setUpdateTime(DateUtils.getNowDate());
deviceMapper.updateDevice(updateDevice); deviceMapper.updateDevice(updateDevice);
} }

View File

@ -184,6 +184,27 @@ public class GaodeLocationService implements ILocationService {
return info; 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 "[]"}。 * 高德部分字段在数据缺失时为 JSON 数组(含空数组 {@code []}),直接 {@link JSONObject#getString(String)} 会得到字面量 {@code "[]"}。
* 本方法仅返回有意义的非空文本,否则返回 {@code null}。 * 本方法仅返回有意义的非空文本,否则返回 {@code null}。
@ -271,24 +292,4 @@ public class GaodeLocationService implements ILocationService {
return sb.toString(); 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]));
}
} }