This commit is contained in:
2026-06-03 16:53:02 +08:00
parent f02329b2d0
commit 133a2bd223
31 changed files with 929 additions and 296 deletions

View File

@@ -4,6 +4,7 @@ import com.maibu.uav.entity.CameraInfo;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
public class UavDeviceStateResponseDetailDTO {
@@ -31,4 +32,8 @@ public class UavDeviceStateResponseDetailDTO {
private Long orgId;
private Long siteId;
private Long userId;
private Integer mode_code;
private Map<Integer,Integer> modeStatistics;
}

View File

@@ -126,6 +126,7 @@ public class UAVService {
return new ArrayList<>();
}
//todo 更新统计数据加内存不重复查
public List<UavDeviceStateResponseDetailDTO> transferData(List<IotUAVDevice> list) {
if (!CollectionUtils.isEmpty(list)) {
Map<String, IotUAVDevice> deviceMap = list.stream()
@@ -167,6 +168,7 @@ public class UAVService {
Map<String, Object> map = (Map<String, Object>) resultDTO.getData();
UavDeviceStateResponseDTO responseDTO = new UavDeviceStateResponseDTO();
if (!CollectionUtils.isEmpty(map)) {
Map<Integer, Integer> statistics = new HashMap<>();
List<Map<String, UavDevice>> l = (List<Map<String, UavDevice>>) map.get("list");
if (!CollectionUtils.isEmpty(l)) {
List<UavDeviceStateResponseDetailDTO> detail = new ArrayList<>();
@@ -182,6 +184,13 @@ public class UAVService {
UavDevice getway = up.getGateway();
UavDeviceStateResponseDetailDTO dto = new UavDeviceStateResponseDetailDTO();
if (getway != null) {
Integer c = statistics.get(getway.getMode_code());
if (c == null) {
c = 0;
}
c += 1;
statistics.put(getway.getMode_code(), c);
dto.setMode_code(getway.getMode_code());
dto.setGateway_sn(getway.getSn());
dto.setCallsign(getway.getCallsign());
dto.setOnlineStatus(getway.getDevice_online_status() ? 1 : 0);
@@ -195,6 +204,9 @@ public class UAVService {
detail.add(dto);
}
});
detail.forEach(y -> {
y.setModeStatistics(statistics);
});
}
}
return responseDTO;
@@ -363,8 +375,8 @@ public class UAVService {
public UavDeviceStateResponseDetailDTO getUAVState(String deviceSn, String droneSn) {
List<UavDeviceStateResponseDetailDTO> list = getCurrentState();
UavDeviceStateResponseDetailDTO dto = null;
if(!CollectionUtils.isEmpty(list)){
dto = list.stream().filter(x->x.getGateway_sn().equals(deviceSn)).findFirst().orElse(null);
if (!CollectionUtils.isEmpty(list)) {
dto = list.stream().filter(x -> x.getGateway_sn().equals(deviceSn)).findFirst().orElse(null);
if (!StringUtils.isEmpty(deviceSn)) {
String url = baseUrl + "/openapi/v0.1/device/" + deviceSn + "/state";
String deviceData = httpService.doGet(url, null);