Browse Source

根据任务id获取无人机实时数据信息接口代码优化

tags/v1.3.1
chengwang 1 year ago
parent
commit
2d3aaf6658
2 changed files with 21 additions and 54 deletions
  1. +10
    -33
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryAirportMsgByIdService.java
  2. +11
    -21
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/AirportMsgVo.java

+ 10
- 33
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryAirportMsgByIdService.java View File

@@ -3,6 +3,7 @@ package com.tuoheng.admin.service.inspection.query;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.FlightData;
import com.tuoheng.admin.entity.FlightDataHl;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionInfoByIdCodeEnum;
@@ -57,44 +58,20 @@ public class QueryAirportMsgByIdService {
}
//获取遥测信号最新的一条数据
Object obj = redisUtils.get(inspectionId);
FlightData flightData = null;
FlightDataHl flightDataHl = null;
if (ObjectUtil.isNull(obj)) {
return JsonResult.success();
} else {
flightData = (FlightData) obj;
flightDataHl = (FlightDataHl) obj;
}
AirportMsgVo vo = new AirportMsgVo();
BeanUtils.copyProperties(flightData,vo);
//高度
Double.parseDouble(flightData.getAlt());
double round = CommonNumberTypeUtils.round(Double.parseDouble(flightData.getAlt()), 2);
vo.setAlt(round + "m");
//gps
vo.setGpssingal(flightData.getGpssingal() + "%");
//电量
Double Umax = 26.1;
Double Umin = 22.2;
if(StringUtils.isNotEmpty(flightData.getVoltage())){
double temp = Double.parseDouble(flightData.getVoltage());
if(temp>=Umin){
//实时电压值大于现在电压最小值
double vol = (temp - Umin) / (Umax - Umin);
String percent = CommonNumberTypeUtils.getPercentFormat(vol, Integer.MAX_VALUE, 2);
vo.setVoltage(percent);
}else {
vo.setVoltage(0 + "%");
}
}
//速度
double hSpeed = CommonNumberTypeUtils.round(Double.parseDouble(flightData.getHspeed()), 2);
vo.setHspeed(hSpeed+ "m/s");
//里程
double mileageTemp = Double.parseDouble(flightData.getMileage()) / 1000;
double mileage = CommonNumberTypeUtils.round(mileageTemp, 2);
vo.setMileage(mileage+ "km");
//机场距离
double distToHome = CommonNumberTypeUtils.round(Double.parseDouble(flightData.getDistToHome()), 2);
vo.setDistToHome(distToHome + "m");

vo.setHt(flightDataHl.getHt());
vo.setDuration(flightDataHl.getDuration());
vo.setAbsp(flightDataHl.getAbsp());
vo.setRemainingFlightTime(flightDataHl.getRemainingFlightTime());
vo.setSatellite(flightDataHl.getSatellite());
vo.setGps(flightDataHl.getGps());
return JsonResult.success(vo);
}
}

+ 11
- 21
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/AirportMsgVo.java View File

@@ -9,44 +9,34 @@ import lombok.Data;
@Data
public class AirportMsgVo {

/**
* 直播url
*/
//private String aipullUrl;

/**
* 高度
*/
private String alt;

/**
* gps
*/
private String gpssingal;
private String ht;

/**
* 无人机水平速度
* 电池电量
*/
private String hspeed;
private String duration;

/**
*遥感信号
* 速度
*/
private String ysingal;
private String absp;

/**
* 电压
*剩余飞行时间
*/
private String voltage;
private String remainingFlightTime;

/**
* 机场距离
* 卫星数量
*/
private String distToHome;
private String satellite;

/**
* 总里程
* GPS信号
*/
private String mileage;
private String gps;

}

Loading…
Cancel
Save