feat: 根据租户获取景区二维码内容
This commit is contained in:
+18
@@ -7,6 +7,7 @@ import com.central.common.model.PageResult;
|
|||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
import com.central.device.model.AgeDevice;
|
import com.central.device.model.AgeDevice;
|
||||||
import com.central.device.model.excel.AgeDeviceExcel;
|
import com.central.device.model.excel.AgeDeviceExcel;
|
||||||
|
import com.central.device.model.vo.AgeDeviceLocationVO;
|
||||||
import com.central.device.service.IAgeDeviceService;
|
import com.central.device.service.IAgeDeviceService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -90,6 +91,23 @@ public class AgeDeviceController {
|
|||||||
return Result.succeed("删除成功");
|
return Result.succeed("删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "根据设备SN获取设备经纬度")
|
||||||
|
@GetMapping("/location/{deviceSn}")
|
||||||
|
public Result<AgeDeviceLocationVO> getLocationByDeviceSn(@PathVariable String deviceSn) {
|
||||||
|
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||||
|
return Result.failed("deviceSn不能为空");
|
||||||
|
}
|
||||||
|
AgeDevice device = ageDeviceService.getByDeviceSn(deviceSn);
|
||||||
|
if (device == null) {
|
||||||
|
return Result.succeed(null, "暂无数据");
|
||||||
|
}
|
||||||
|
AgeDeviceLocationVO vo = new AgeDeviceLocationVO();
|
||||||
|
vo.setDeviceSn(deviceSn);
|
||||||
|
vo.setLongitude(device.getLongitude());
|
||||||
|
vo.setLatitude(device.getLatitude());
|
||||||
|
return Result.succeed(vo, "查询成功");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出设备信息
|
* 导出设备信息
|
||||||
*/
|
*/
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.central.device.model.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备经纬度信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "设备经纬度信息")
|
||||||
|
public class AgeDeviceLocationVO {
|
||||||
|
|
||||||
|
@Schema(description = "设备SN")
|
||||||
|
private String deviceSn;
|
||||||
|
|
||||||
|
@Schema(description = "经度")
|
||||||
|
private Double longitude;
|
||||||
|
|
||||||
|
@Schema(description = "纬度")
|
||||||
|
private Double latitude;
|
||||||
|
}
|
||||||
|
|
||||||
+24
-5
@@ -1,12 +1,11 @@
|
|||||||
package com.central.order.controller;
|
package com.central.order.controller;
|
||||||
|
|
||||||
import com.central.common.context.LoginUserContextHolder;
|
|
||||||
import com.central.common.context.TenantContextHolder;
|
import com.central.common.context.TenantContextHolder;
|
||||||
import com.central.common.model.LoginAppUser;
|
|
||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
import com.central.order.model.Tourism;
|
import com.central.order.model.Tourism;
|
||||||
import com.central.order.model.TourismWithDistance;
|
import com.central.order.model.TourismWithDistance;
|
||||||
|
import com.central.order.model.vo.TourismQrCodeDistanceVO;
|
||||||
import com.central.order.service.ITourismService;
|
import com.central.order.service.ITourismService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -16,11 +15,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -97,6 +93,29 @@ public class TourismController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据租户ID与经纬度查询二维码列表(包含距离)
|
||||||
|
*/
|
||||||
|
@Operation(summary = "根据租户ID与经纬度查询二维码列表")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = "tenantId", description = "租户ID(如:lsApp)", required = true, in = ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "longitude", description = "经度", required = true, in = ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "latitude", description = "纬度", required = true, in = ParameterIn.QUERY)
|
||||||
|
})
|
||||||
|
@GetMapping("/qrcodes/by-tenant")
|
||||||
|
public Result<List<TourismQrCodeDistanceVO>> listQrCodesByTenantWithDistance(
|
||||||
|
@RequestParam String tenantId,
|
||||||
|
@RequestParam BigDecimal longitude,
|
||||||
|
@RequestParam BigDecimal latitude) {
|
||||||
|
try {
|
||||||
|
log.info("根据租户ID与经纬度查询二维码列表: tenantId={}, longitude={}, latitude={}", tenantId, longitude, latitude);
|
||||||
|
return tourismService.listQrCodesByTenantWithDistance(tenantId, longitude, latitude);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("根据租户ID与经纬度查询二维码列表失败: tenantId={}", tenantId, e);
|
||||||
|
return Result.failed("查询失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询附近景区列表
|
* 查询附近景区列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
+30
@@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.central.common.constant.ServiceNameConstants;
|
import com.central.common.constant.ServiceNameConstants;
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
import com.central.order.feign.fallback.DeviceCenterServiceFallbackFactory;
|
import com.central.order.feign.fallback.DeviceCenterServiceFallbackFactory;
|
||||||
|
import com.central.order.model.dto.AgeDeviceLocationDTO;
|
||||||
|
import com.central.order.model.dto.BoatRealtimePositionDTO;
|
||||||
|
import com.central.order.model.dto.DroneLatestTrackPointDTO;
|
||||||
import com.central.order.mission.VO.TakeoffRequestVO;
|
import com.central.order.mission.VO.TakeoffRequestVO;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
@@ -103,4 +106,31 @@ public interface DeviceCenterService {
|
|||||||
@Operation(summary = "无人船紧急停止")
|
@Operation(summary = "无人船紧急停止")
|
||||||
@PostMapping("/device/boat/command/emergency-stop")
|
@PostMapping("/device/boat/command/emergency-stop")
|
||||||
Result<Void> emergencyStopBoat(@RequestParam("deviceSn") String deviceSn);
|
Result<Void> emergencyStopBoat(@RequestParam("deviceSn") String deviceSn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备SN获取设备经纬度(AgeDevice)
|
||||||
|
*
|
||||||
|
* @param deviceSn 设备SN
|
||||||
|
*/
|
||||||
|
@Operation(summary = "根据设备SN获取设备经纬度")
|
||||||
|
@GetMapping("/device/location/{deviceSn}")
|
||||||
|
Result<AgeDeviceLocationDTO> getAgeDeviceLocation(@PathVariable("deviceSn") String deviceSn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取无人船实时位置
|
||||||
|
*
|
||||||
|
* @param deviceSn 设备SN
|
||||||
|
*/
|
||||||
|
@Operation(summary = "获取无人船实时位置")
|
||||||
|
@GetMapping("/device/boat/track/realtime/{deviceSn}")
|
||||||
|
Result<BoatRealtimePositionDTO> getBoatRealtimePosition(@PathVariable("deviceSn") String deviceSn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取无人机最新轨迹点
|
||||||
|
*
|
||||||
|
* @param deviceSn 设备SN
|
||||||
|
*/
|
||||||
|
@Operation(summary = "获取无人机最新轨迹点")
|
||||||
|
@GetMapping("/api/device/drone/track/latest/{deviceSn}")
|
||||||
|
Result<DroneLatestTrackPointDTO> getDroneLatestTrackPoint(@PathVariable("deviceSn") String deviceSn);
|
||||||
}
|
}
|
||||||
|
|||||||
+21
@@ -3,6 +3,9 @@ package com.central.order.feign.fallback;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
import com.central.order.feign.DeviceCenterService;
|
import com.central.order.feign.DeviceCenterService;
|
||||||
|
import com.central.order.model.dto.AgeDeviceLocationDTO;
|
||||||
|
import com.central.order.model.dto.BoatRealtimePositionDTO;
|
||||||
|
import com.central.order.model.dto.DroneLatestTrackPointDTO;
|
||||||
import com.central.order.mission.VO.TakeoffRequestVO;
|
import com.central.order.mission.VO.TakeoffRequestVO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
@@ -77,6 +80,24 @@ public class DeviceCenterServiceFallbackFactory implements FallbackFactory<Devic
|
|||||||
log.error("调用设备中心emergencyStopBoat失败: deviceSn={}, error={}", deviceSn, cause.getMessage());
|
log.error("调用设备中心emergencyStopBoat失败: deviceSn={}, error={}", deviceSn, cause.getMessage());
|
||||||
return Result.failed("设备中心服务调用失败");
|
return Result.failed("设备中心服务调用失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<AgeDeviceLocationDTO> getAgeDeviceLocation(String deviceSn) {
|
||||||
|
log.error("调用设备中心getAgeDeviceLocation失败: deviceSn={}, error={}", deviceSn, cause.getMessage());
|
||||||
|
return Result.failed("设备中心服务调用失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<BoatRealtimePositionDTO> getBoatRealtimePosition(String deviceSn) {
|
||||||
|
log.error("调用设备中心getBoatRealtimePosition失败: deviceSn={}, error={}", deviceSn, cause.getMessage());
|
||||||
|
return Result.failed("设备中心服务调用失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<DroneLatestTrackPointDTO> getDroneLatestTrackPoint(String deviceSn) {
|
||||||
|
log.error("调用设备中心getDroneLatestTrackPoint失败: deviceSn={}, error={}", deviceSn, cause.getMessage());
|
||||||
|
return Result.failed("设备中心服务调用失败");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.central.order.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备经纬度信息(用于Feign反序列化)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AgeDeviceLocationDTO {
|
||||||
|
|
||||||
|
@Schema(description = "设备SN")
|
||||||
|
private String deviceSn;
|
||||||
|
|
||||||
|
@Schema(description = "经度")
|
||||||
|
private Double longitude;
|
||||||
|
|
||||||
|
@Schema(description = "纬度")
|
||||||
|
private Double latitude;
|
||||||
|
}
|
||||||
|
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package com.central.order.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备中心:无人船实时位置(用于Feign反序列化)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BoatRealtimePositionDTO {
|
||||||
|
|
||||||
|
@Schema(description = "设备SN")
|
||||||
|
private String deviceSn;
|
||||||
|
|
||||||
|
@Schema(description = "经度")
|
||||||
|
private BigDecimal longitude;
|
||||||
|
|
||||||
|
@Schema(description = "纬度")
|
||||||
|
private BigDecimal latitude;
|
||||||
|
}
|
||||||
|
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package com.central.order.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备中心:无人机最新轨迹点(用于Feign反序列化)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DroneLatestTrackPointDTO {
|
||||||
|
|
||||||
|
@Schema(description = "经度")
|
||||||
|
private Double lng;
|
||||||
|
|
||||||
|
@Schema(description = "纬度")
|
||||||
|
private Double lat;
|
||||||
|
}
|
||||||
|
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package com.central.order.model.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二维码距离信息返回对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "二维码距离信息")
|
||||||
|
public class TourismQrCodeDistanceVO {
|
||||||
|
|
||||||
|
@Schema(description = "二维码名称")
|
||||||
|
private String qrCodeName;
|
||||||
|
|
||||||
|
@Schema(description = "二维码code(codeId)")
|
||||||
|
private String qrCode;
|
||||||
|
|
||||||
|
@Schema(description = "二维码图片(景区展示图URL)")
|
||||||
|
private String qrCodeImage;
|
||||||
|
|
||||||
|
@Schema(description = "距离(公里)")
|
||||||
|
private BigDecimal distance;
|
||||||
|
|
||||||
|
@Schema(description = "距离描述(如:120m、1.2km)")
|
||||||
|
private String distanceDesc;
|
||||||
|
|
||||||
|
public String getDistanceDesc() {
|
||||||
|
if (distance == null) {
|
||||||
|
return "未知距离";
|
||||||
|
}
|
||||||
|
if (distance.compareTo(BigDecimal.ONE) < 0) {
|
||||||
|
int meters = distance.multiply(new BigDecimal("1000")).intValue();
|
||||||
|
return meters + "m";
|
||||||
|
}
|
||||||
|
return distance.setScale(1, BigDecimal.ROUND_HALF_UP) + "km";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+11
@@ -6,6 +6,7 @@ import com.central.common.service.ISuperService;
|
|||||||
import com.central.order.model.QrCode;
|
import com.central.order.model.QrCode;
|
||||||
import com.central.order.model.Tourism;
|
import com.central.order.model.Tourism;
|
||||||
import com.central.order.model.TourismWithDistance;
|
import com.central.order.model.TourismWithDistance;
|
||||||
|
import com.central.order.model.vo.TourismQrCodeDistanceVO;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -98,5 +99,15 @@ public interface ITourismService extends ISuperService<Tourism> {
|
|||||||
|
|
||||||
|
|
||||||
Result<Map<String, Object>> getTourismInfo(Long tourismId);
|
Result<Map<String, Object>> getTourismInfo(Long tourismId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据租户ID与经纬度查询二维码列表,并返回距离信息
|
||||||
|
*
|
||||||
|
* @param tenantId 租户ID(如:lsApp)
|
||||||
|
* @param longitude 入参经度
|
||||||
|
* @param latitude 入参纬度
|
||||||
|
* @return 二维码列表(二维码名称、二维码code、二维码图片、距离)
|
||||||
|
*/
|
||||||
|
Result<List<TourismQrCodeDistanceVO>> listQrCodesByTenantWithDistance(String tenantId, BigDecimal longitude, BigDecimal latitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+166
@@ -7,15 +7,21 @@ import com.central.common.feign.UserService;
|
|||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
import com.central.common.service.impl.SuperServiceImpl;
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
|
import com.central.order.feign.DeviceCenterService;
|
||||||
import com.central.order.mapper.QrCodeMapper;
|
import com.central.order.mapper.QrCodeMapper;
|
||||||
import com.central.order.mapper.TourismMapper;
|
import com.central.order.mapper.TourismMapper;
|
||||||
|
import com.central.order.model.PackagePlan;
|
||||||
import com.central.order.model.QrCode;
|
import com.central.order.model.QrCode;
|
||||||
import com.central.order.model.Tourism;
|
import com.central.order.model.Tourism;
|
||||||
import com.central.order.model.TourismWithDistance;
|
import com.central.order.model.TourismWithDistance;
|
||||||
import com.central.order.model.TourismFile;
|
import com.central.order.model.TourismFile;
|
||||||
|
import com.central.order.model.dto.AgeDeviceLocationDTO;
|
||||||
|
import com.central.order.model.vo.TourismQrCodeDistanceVO;
|
||||||
|
import com.central.order.service.IPackagePlanService;
|
||||||
import com.central.order.service.ITourismService;
|
import com.central.order.service.ITourismService;
|
||||||
import com.central.order.service.ITourismFileService;
|
import com.central.order.service.ITourismFileService;
|
||||||
import com.central.order.feign.FileCenterService;
|
import com.central.order.feign.FileCenterService;
|
||||||
|
import com.central.order.util.GeoDistanceUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -47,6 +53,12 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
|||||||
@Resource
|
@Resource
|
||||||
private QrCodeMapper qrCodeMapper;
|
private QrCodeMapper qrCodeMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPackagePlanService packagePlanService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceCenterService deviceCenterService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
* @param params
|
* @param params
|
||||||
@@ -299,4 +311,158 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
|||||||
return Result.succeed(map,"获取成功");
|
return Result.succeed(map,"获取成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@IgnoreTenantScope
|
||||||
|
public Result<List<TourismQrCodeDistanceVO>> listQrCodesByTenantWithDistance(String tenantId, BigDecimal longitude, BigDecimal latitude) {
|
||||||
|
if (tenantId == null || tenantId.trim().isEmpty()) {
|
||||||
|
return Result.failed("tenantId不能为空");
|
||||||
|
}
|
||||||
|
if (longitude == null || latitude == null) {
|
||||||
|
return Result.failed("经纬度不能为空");
|
||||||
|
}
|
||||||
|
if (longitude.compareTo(BigDecimal.valueOf(-180)) < 0 || longitude.compareTo(BigDecimal.valueOf(180)) > 0) {
|
||||||
|
return Result.failed("经度范围应在-180到180之间");
|
||||||
|
}
|
||||||
|
if (latitude.compareTo(BigDecimal.valueOf(-90)) < 0 || latitude.compareTo(BigDecimal.valueOf(90)) > 0) {
|
||||||
|
return Result.failed("纬度范围应在-90到90之间");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Tourism> tourisms = baseMapper.selectList(new LambdaQueryWrapper<Tourism>()
|
||||||
|
.eq(Tourism::getTenantId, tenantId)
|
||||||
|
.eq(Tourism::getIsDel, 0)
|
||||||
|
.eq(Tourism::getStatus, 1)
|
||||||
|
.orderByDesc(Tourism::getId));
|
||||||
|
|
||||||
|
if (tourisms == null || tourisms.isEmpty()) {
|
||||||
|
return Result.succeed(List.of(), "暂无数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> codeIdToImageUrl = new HashMap<>();
|
||||||
|
Map<String, BigDecimal[]> deviceSnToLngLat = new HashMap<>();
|
||||||
|
List<TourismQrCodeDistanceVO> resultList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Tourism tourism : tourisms) {
|
||||||
|
List<QrCode> qrCodes = getQrcodesByTourismId(tourism.getId());
|
||||||
|
if (qrCodes == null || qrCodes.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (QrCode qrCode : qrCodes) {
|
||||||
|
if (qrCode == null || qrCode.getCodeId() == null || qrCode.getCodeId().trim().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TourismQrCodeDistanceVO vo = new TourismQrCodeDistanceVO();
|
||||||
|
String qrName = qrCode.getName();
|
||||||
|
if (qrName == null || qrName.trim().isEmpty()) {
|
||||||
|
qrName = tourism.getTourismName();
|
||||||
|
}
|
||||||
|
vo.setQrCodeName(qrName);
|
||||||
|
vo.setQrCode(qrCode.getCodeId());
|
||||||
|
|
||||||
|
String imageUrl = resolveQrCodeImageUrl(qrCode.getCodeId(), codeIdToImageUrl);
|
||||||
|
vo.setQrCodeImage(imageUrl);
|
||||||
|
|
||||||
|
BigDecimal[] lngLat = resolveDeviceLngLat(qrCode.getDeviceSn(), deviceSnToLngLat);
|
||||||
|
if (lngLat != null && lngLat.length == 2) {
|
||||||
|
vo.setDistance(GeoDistanceUtils.distanceKm(longitude, latitude, lngLat[0], lngLat[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
resultList.add(vo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resultList.sort((a, b) -> {
|
||||||
|
BigDecimal da = a.getDistance();
|
||||||
|
BigDecimal db = b.getDistance();
|
||||||
|
if (da == null && db == null) return 0;
|
||||||
|
if (da == null) return 1;
|
||||||
|
if (db == null) return -1;
|
||||||
|
return da.compareTo(db);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Result.succeed(resultList, "获取成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveQrCodeImageUrl(String codeId, Map<String, String> cache) {
|
||||||
|
if (codeId == null || codeId.trim().isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (cache.containsKey(codeId)) {
|
||||||
|
return cache.get(codeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
String imageUrl = null;
|
||||||
|
try {
|
||||||
|
List<PackagePlan> plans = packagePlanService.getByCodeId(codeId);
|
||||||
|
if (plans != null && !plans.isEmpty()) {
|
||||||
|
PackagePlan plan = plans.get(0);
|
||||||
|
List<Long> fileIds = parseIdList(plan.getTourismFileIds());
|
||||||
|
if (!fileIds.isEmpty()) {
|
||||||
|
List<TourismFile> files = tourismFileService.findByIds(fileIds);
|
||||||
|
if (files != null) {
|
||||||
|
for (TourismFile file : files) {
|
||||||
|
if (file != null && file.getImageUrl() != null && !file.getImageUrl().trim().isEmpty()) {
|
||||||
|
imageUrl = fileCenterService.getViewUrlByPath(file.getImageUrl());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("解析二维码图片失败: codeId={}, error={}", codeId, e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
cache.put(codeId, imageUrl);
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal[] resolveDeviceLngLat(String deviceSn, Map<String, BigDecimal[]> cache) {
|
||||||
|
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (cache.containsKey(deviceSn)) {
|
||||||
|
return cache.get(deviceSn);
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal[] lngLat = null;
|
||||||
|
try {
|
||||||
|
Result<AgeDeviceLocationDTO> locationResult = deviceCenterService.getAgeDeviceLocation(deviceSn);
|
||||||
|
if (locationResult != null && locationResult.getResp_code() != null && locationResult.getResp_code() == 0) {
|
||||||
|
AgeDeviceLocationDTO data = locationResult.getData();
|
||||||
|
if (data != null && data.getLongitude() != null && data.getLatitude() != null) {
|
||||||
|
lngLat = new BigDecimal[]{BigDecimal.valueOf(data.getLongitude()), BigDecimal.valueOf(data.getLatitude())};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("获取设备经纬度失败: deviceSn={}, error={}", deviceSn, e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
cache.put(deviceSn, lngLat);
|
||||||
|
return lngLat;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Long> parseIdList(String ids) {
|
||||||
|
if (ids == null || ids.trim().isEmpty()) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
String[] parts = ids.split(",");
|
||||||
|
List<Long> list = new ArrayList<>();
|
||||||
|
for (String part : parts) {
|
||||||
|
if (part == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String v = part.trim();
|
||||||
|
if (v.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
list.add(Long.parseLong(v));
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.central.order.util;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经纬度距离计算工具类
|
||||||
|
*/
|
||||||
|
public final class GeoDistanceUtils {
|
||||||
|
|
||||||
|
private static final double EARTH_RADIUS_KM = 6371.0;
|
||||||
|
|
||||||
|
private GeoDistanceUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算两点间球面距离(公里)
|
||||||
|
*/
|
||||||
|
public static BigDecimal distanceKm(BigDecimal longitude1, BigDecimal latitude1,
|
||||||
|
BigDecimal longitude2, BigDecimal latitude2) {
|
||||||
|
if (longitude1 == null || latitude1 == null || longitude2 == null || latitude2 == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
double lng1 = longitude1.doubleValue();
|
||||||
|
double lat1 = latitude1.doubleValue();
|
||||||
|
double lng2 = longitude2.doubleValue();
|
||||||
|
double lat2 = latitude2.doubleValue();
|
||||||
|
|
||||||
|
double dLat = Math.toRadians(lat2 - lat1);
|
||||||
|
double dLng = Math.toRadians(lng2 - lng1);
|
||||||
|
|
||||||
|
double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
|
||||||
|
+ Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2))
|
||||||
|
* Math.sin(dLng / 2) * Math.sin(dLng / 2);
|
||||||
|
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||||
|
double distance = EARTH_RADIUS_KM * c;
|
||||||
|
|
||||||
|
return BigDecimal.valueOf(distance).setScale(3, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
# 无人机智慧城市管控平台重构计划 (Smart City UAV Platform Refactor Plan) - V2
|
||||||
|
|
||||||
|
## 1. 重构目标 (Objectives)
|
||||||
|
将现有的“通用大屏”彻底改造为**“无人机智慧城市管控平台”**。核心逻辑由“监控无人机”转变为**“无人机赋能智慧城市”**——即重点展示无人机采集到的城市数据(环境、交通、违规、基础设施),而非无人机本身的状态。
|
||||||
|
|
||||||
|
- **视觉升级**:采用“未来城市/数字孪生”风格,深蓝/黑底色,霓虹光效。
|
||||||
|
- **数据维度深化**:**去无人机化(运维层面),重城市治理化(业务层面)**。展示城市环境、网格治理、交通态势等业务指标。
|
||||||
|
- **交互优化**:采用 CSS Grid 布局彻底解决挤压/留白问题。
|
||||||
|
- **设备操控重构**:严格参考 `yingyan/src/pages/11.png` 的布局风格进行专业化重制。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. 视觉与布局重设计 (Visual & Layout Redesign)
|
||||||
|
|
||||||
|
### 2.1 全局视觉主题 (Theme)
|
||||||
|
- **色调**:#050b14 (背景) + #00f0ff (科技蓝) + #00ff9d (生态绿) + #ffaa00 (警示橙)。
|
||||||
|
- **质感**:玻璃拟态 (Glassmorphism) + 科技边框 (SVG Borders) + 动态扫描线。
|
||||||
|
|
||||||
|
### 2.2 首页大屏布局 (Smart City Dashboard Layout)
|
||||||
|
采用 **左-中-右 (L-C-R)** 布局,侧重城市业务数据的可视化。
|
||||||
|
|
||||||
|
#### **左侧 (25%) - 城市运行体征 (City Operations & Environment)**
|
||||||
|
*侧重:无人机采集的环境与基础设施数据*
|
||||||
|
- **顶部:城市网格化治理效能**
|
||||||
|
- 展示各行政网格的巡检覆盖率、问题发现率。
|
||||||
|
- 可视化:雷达图 (Radar) 或 多色进度条。
|
||||||
|
- **中部:空天地一体化环境监测**
|
||||||
|
- 展示无人机搭载传感器采集的空气质量 (PM2.5/PM10)、噪音热力分布。
|
||||||
|
- 可视化:动态波浪曲线图 (Wave Line) 或 仪表盘。
|
||||||
|
- **底部:交通拥堵与人流态势**
|
||||||
|
- 基于无人机视角的道路拥堵指数、重点区域人员密度。
|
||||||
|
- 可视化:热力柱状图 或 渐变面积图。
|
||||||
|
|
||||||
|
#### **中间 (50%) - 全域数字孪生 (Digital Twin Center)**
|
||||||
|
*侧重:实时态势与AI成果展示*
|
||||||
|
- **主体:3D 城市数字沙盘**
|
||||||
|
- 加载城市 3D 模型/倾斜摄影模型。
|
||||||
|
- 叠加数据层:AI 识别事件点位(火情、违停)、无人机实时轨迹、电子围栏。
|
||||||
|
- **顶部悬浮:城市智理核心 KPI**
|
||||||
|
- 城市安全指数、今日AI识别事件总数、应急响应平均时间。
|
||||||
|
- 样式:大型数字翻牌器 + 呼吸灯光效。
|
||||||
|
- **底部悬浮:AI 缺陷/违规抓拍轮播 (Defect Carousel)**
|
||||||
|
- **(重点修改)** 替换原视频轮播。
|
||||||
|
- 实时展示 AI 识别到的问题图片(如:路面破损、违章建筑、河道漂浮物)。
|
||||||
|
- 交互:点击图片弹出详情与处理进度。
|
||||||
|
|
||||||
|
#### **右侧 (25%) - 智能安防与事件处置 (Security & Response)**
|
||||||
|
*侧重:事件流转与处理*
|
||||||
|
- **顶部:AI 智能识别分类统计**
|
||||||
|
- 统计具体的违规类型:违停、乱堆物、未戴安全帽、明火烟雾等。
|
||||||
|
- 可视化:3D 饼图 (3D Pie) 或 胶囊柱图。
|
||||||
|
- **中部:实时预警事件流**
|
||||||
|
- 滚动展示最新的报警信息,按紧急程度(红/橙/黄)区分。
|
||||||
|
- 样式:列表项带进入动画。
|
||||||
|
- **底部:巡检任务/事件闭环率**
|
||||||
|
- 展示问题发现 -> 派单 -> 处置 -> 复核 的全流程数据。
|
||||||
|
- 可视化:漏斗图 (Funnel) 或 双折线趋势图。
|
||||||
|
|
||||||
|
### 2.3 设备操控页 (Control Page Refactor)
|
||||||
|
*参考目标:yingyan/src/pages/11.png*
|
||||||
|
- **布局核心**:**沉浸式第一视角 (FPV)**。
|
||||||
|
- **底层**:实时视频流铺满全屏。
|
||||||
|
- **顶层 UI (HUD 风格)**:
|
||||||
|
- **顶部栏**:透明底色,展示卫星数、信号强度、电池电压、飞行模式(定位/姿态)。
|
||||||
|
- **左侧边栏**:任务航线列表、一键起飞/降落/返航按钮组。
|
||||||
|
- **右侧边栏**:云台角度控制、变焦控制、AI 识别开关、拍照/录像。
|
||||||
|
- **底部仪表盘**:飞行高度 (H)、距离 (D)、水平速度 (H.S)、垂直速度 (V.S) 的数字化仪表。
|
||||||
|
- **左下角小窗**:地图/视频切换窗口。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. 技术实施步骤 (Implementation Steps)
|
||||||
|
|
||||||
|
### 第一阶段:布局重构与样式重置 (Layout & Style)
|
||||||
|
1. **Grid 布局落地**:在 `src/pages/dashboard/index.less` 中实现严格的 CSS Grid 布局,确保左中右三栏及内部卡片高度固定(例如 30%-35%-35% 分配),彻底消除挤压。
|
||||||
|
2. **组件库封装**:
|
||||||
|
- `GlassCard`: 带科技边框的玻璃容器。
|
||||||
|
- `NumberFlipper`: 数字翻牌器组件。
|
||||||
|
- `AutoFitChart`: 基于 G2Plot 封装的自动适配图表组件。
|
||||||
|
|
||||||
|
### 第二阶段:数据可视化开发 (Data Visualization)
|
||||||
|
1. **左侧栏**:实现“网格治理雷达图”、“环境监测波形图”、“交通态势热力图”。
|
||||||
|
2. **右侧栏**:实现“AI识别3D饼图”、“告警滚动列表”、“事件闭环漏斗图”。
|
||||||
|
3. **中间栏**:实现“底部缺陷图片轮播组件”,支持自动滚动和点击预览。
|
||||||
|
|
||||||
|
### 第三阶段:地图与 3D 交互 (Map & 3D)
|
||||||
|
1. 优化地图图层样式,使其符合深色科技主题(隐藏过多无关POI,高亮路网和水系)。
|
||||||
|
2. 添加模拟的 AI 识别点位和缺陷图片数据源。
|
||||||
|
|
||||||
|
### 第四阶段:设备操控页 (Device Control)
|
||||||
|
1. 重写 `src/pages/device/control`。
|
||||||
|
2. 实现视频流背景 + 绝对定位的 HUD UI 组件。
|
||||||
|
3. 复刻 `11.png` 中的关键交互元素(侧边工具栏、底部仪表数据)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. 数据模拟 (Mock Data)
|
||||||
|
由于涉及大量“智慧城市”新维度,需要重新生成 Mock 数据:
|
||||||
|
- **Mock_City_Grid**: 网格ID、覆盖率、得分。
|
||||||
|
- **Mock_Environment**: 时间点、PM2.5、噪音dB。
|
||||||
|
- **Mock_Traffic**: 道路名称、拥堵指数。
|
||||||
|
- **Mock_AI_Events**: 事件类型、图片URL、置信度、坐标。
|
||||||
Reference in New Issue
Block a user