parent
161c089635
commit
cfcfd992f8
|
|
@ -1,5 +1,6 @@
|
|||
package com.multictrl.modules.business.controller;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.multictrl.common.annotation.ApiOrder;
|
||||
import com.multictrl.common.annotation.LogOperation;
|
||||
import com.multictrl.common.constant.Constant;
|
||||
|
|
@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +40,7 @@ public class FlightTaskController {
|
|||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始"),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数")
|
||||
})
|
||||
@RequiresPermissions("business:task:page")
|
||||
@RequiresPermissions("bus:task:page")
|
||||
public Result<PageData<FlightTaskDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<FlightTaskDTO> page = flightTaskService.page(params);
|
||||
|
||||
|
|
@ -47,7 +49,7 @@ public class FlightTaskController {
|
|||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("business:task:info")
|
||||
@RequiresPermissions("bus:task:info")
|
||||
public Result<FlightTaskDTO> get(@PathVariable("id") Long id) {
|
||||
FlightTaskDTO data = flightTaskService.get(id);
|
||||
|
||||
|
|
@ -57,7 +59,7 @@ public class FlightTaskController {
|
|||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("business:task:delete")
|
||||
@RequiresPermissions("bus:task:delete")
|
||||
public Result<Object> delete(@RequestBody Long[] ids) {
|
||||
//效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
|
@ -65,4 +67,13 @@ public class FlightTaskController {
|
|||
|
||||
return new Result<>();
|
||||
}
|
||||
|
||||
@GetMapping("/getFlightTrack/{taskId}")
|
||||
@Operation(summary = "飞行轨迹")
|
||||
@RequiresPermissions("bus:task:flightTrack")
|
||||
public Result<List<JSONObject>> getFlightTrack(@PathVariable("taskId") String taskId) {
|
||||
List<JSONObject> data = flightTaskService.getFlightTrack(taskId);
|
||||
|
||||
return new Result<List<JSONObject>>().ok(data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.multictrl.common.constant.DockMode;
|
|||
import com.multictrl.common.utils.CacheUtils;
|
||||
import com.multictrl.common.utils.JsonUtils;
|
||||
import com.multictrl.modules.business.influxdb.UavReport;
|
||||
import com.multictrl.modules.business.service.DockService;
|
||||
import com.multictrl.modules.business.service.FlightTaskService;
|
||||
import com.multictrl.modules.business.service.InfluxService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -31,6 +32,7 @@ public class OsdHandler implements MessageHandler {
|
|||
private static final String GPS_ZERO = "0.000000";
|
||||
private final InfluxService influxService;
|
||||
private final FlightTaskService flightTaskService;
|
||||
private final DockService dockService;
|
||||
|
||||
@Override
|
||||
public void handleMessage(String topic, String payload, String gateway) {
|
||||
|
|
@ -50,6 +52,8 @@ public class OsdHandler implements MessageHandler {
|
|||
if (CacheUtils.get(BusinessConstant.DOCK_IN_WORK + dockSn) == null) {
|
||||
flightTaskService.updateTaskStart(dockSn);
|
||||
log.debug("{}机库架次开始,更新架次表", dockSn);
|
||||
//更新机库经纬度
|
||||
dockService.updateDockLocation(dockSn, data);
|
||||
}
|
||||
CacheUtils.set(BusinessConstant.DOCK_IN_WORK + dockSn, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.multictrl.modules.business.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.multictrl.common.service.CrudService;
|
||||
import com.multictrl.modules.business.dao.DockDao;
|
||||
import com.multictrl.modules.business.dto.DockDTO;
|
||||
|
|
@ -13,6 +14,9 @@ import com.multictrl.modules.business.entity.DockEntity;
|
|||
*/
|
||||
public interface DockService extends CrudService<DockEntity, DockDTO> {
|
||||
|
||||
//更新机库位置
|
||||
void updateDockLocation(String dockSn, JSONObject data);
|
||||
|
||||
//获取dao
|
||||
DockDao getDao();
|
||||
}
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
package com.multictrl.modules.business.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.multictrl.common.service.CrudService;
|
||||
import com.multictrl.modules.business.dto.FlightTaskDTO;
|
||||
import com.multictrl.modules.business.entity.FlightTaskEntity;
|
||||
import com.multictrl.modules.business.influxdb.UavReport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 飞行架次
|
||||
|
|
@ -22,4 +26,7 @@ public interface FlightTaskService extends CrudService<FlightTaskEntity, FlightT
|
|||
|
||||
//更新架次开始信息
|
||||
void updateTaskStart(String dockSn);
|
||||
|
||||
//获取飞行轨迹
|
||||
List<JSONObject> getFlightTrack(String taskId);
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.multictrl.modules.business.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.multictrl.common.service.impl.CrudServiceImpl;
|
||||
|
|
@ -34,6 +35,27 @@ public class DockServiceImpl extends CrudServiceImpl<DockDao, DockEntity, DockDT
|
|||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDockLocation(String dockSn, JSONObject data) {
|
||||
DockEntity dockEntity = baseDao.selectOne(new QueryWrapper<DockEntity>().eq("dock_sn", dockSn));
|
||||
if (dockEntity == null) {
|
||||
return;
|
||||
}
|
||||
Double latitude = data.getDouble("latitude");
|
||||
Double longitude = data.getDouble("longitude");
|
||||
Double height = data.getDouble("height");
|
||||
dockEntity.setDockLatitude(latitude);
|
||||
dockEntity.setDockLongitude(longitude);
|
||||
dockEntity.setDockHeight(height);
|
||||
JSONObject alternateLandPoint = data.getJSONObject("alternate_land_point");
|
||||
if (alternateLandPoint != null) {
|
||||
dockEntity.setDeputyLatitude(alternateLandPoint.getDouble("latitude"));
|
||||
dockEntity.setDeputyLongitude(alternateLandPoint.getDouble("longitude"));
|
||||
dockEntity.setDeputyHeight(alternateLandPoint.getDouble("height"));
|
||||
}
|
||||
baseDao.updateById(dockEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DockDao getDao() {
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,17 @@ package com.multictrl.modules.business.service.impl;
|
|||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.multictrl.common.constant.BusinessConstant;
|
||||
import com.multictrl.common.constant.FlightTaskStatus;
|
||||
import com.multictrl.common.exception.ErrorCode;
|
||||
import com.multictrl.common.exception.RenException;
|
||||
import com.multictrl.common.service.impl.CrudServiceImpl;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.multictrl.common.utils.CacheUtils;
|
||||
import com.multictrl.common.utils.ConvertUtils;
|
||||
import com.multictrl.common.utils.DateUtils;
|
||||
import com.multictrl.common.utils.Spatial4jUtils;
|
||||
import com.multictrl.modules.business.dao.DockDeviceDao;
|
||||
|
|
@ -25,10 +29,7 @@ import com.multictrl.modules.security.user.SecurityUser;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 飞行架次
|
||||
|
|
@ -155,6 +156,71 @@ public class FlightTaskServiceImpl extends CrudServiceImpl<FlightTaskDao, Flight
|
|||
updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getFlightTrack(String taskId) {
|
||||
FlightTaskEntity entity = selectById(taskId);
|
||||
if (entity == null) {
|
||||
throw new RenException(ErrorCode.ROUTE_TASK_NOT_EXIST);
|
||||
}
|
||||
Date outboundDate = entity.getOutboundDate();
|
||||
Date inboundDate = entity.getInboundDate();
|
||||
String dockSn = entity.getDockSn();
|
||||
if (outboundDate == null || inboundDate == null || StrUtil.isBlank(dockSn)) {
|
||||
return List.of();
|
||||
}
|
||||
HashMap<String, Object> condition = Maps.newHashMap();
|
||||
condition.put("dockSn", dockSn);
|
||||
List<JSONObject> uavReportList = influxService.queryData(DateUtils.format(outboundDate, DateUtils.DATE_TIME_PATTERN),
|
||||
DateUtils.format(inboundDate, DateUtils.DATE_TIME_PATTERN), "uav_osd", condition, JSONObject.class,
|
||||
"dockSn", "_time", "obstacle_avoidance_horizon", "obstacle_avoidance_upside", "obstacle_avoidance_downside", "is_near_area_limit",
|
||||
"is_near_height_limit", "gimbal_pitch", "gimbal_roll", "gimbal_yaw", "payload_index", "zoom_factor",
|
||||
"track_id", "position_state_is_fixed", "position_state_is_quality", "position_state_is_gps_number", "position_state_is_rtk_number",
|
||||
"battery_capacity_percent", "battery_remain_flight_time", "battery_return_home_power",
|
||||
"battery_landing_power", "battery_capacity_percent_a", "battery_capacity_percent_b", "wind_direction", "wind_speed", "home_distance",
|
||||
"attitude_head", "attitude_roll", "attitude_pitch", "elevation", "height", "latitude", "longitude", "vertical_speed", "horizontal_speed");
|
||||
//去重
|
||||
Set<String> seenTimes = new LinkedHashSet<>();
|
||||
List<JSONObject> deduplicated = new ArrayList<>(uavReportList.size());
|
||||
for (JSONObject obj : uavReportList) {
|
||||
String time = obj.getStr("_time");
|
||||
if (seenTimes.add(time)) {
|
||||
deduplicated.add(obj);
|
||||
}
|
||||
}
|
||||
//补点
|
||||
List<JSONObject> filledList = new ArrayList<>();
|
||||
for (int i = 0; i < deduplicated.size(); i++) {
|
||||
JSONObject current = deduplicated.get(i);
|
||||
String currentTime = current.getStr("time");
|
||||
filledList.add(current);
|
||||
// 检查是否是最后一个点
|
||||
if (i == deduplicated.size() - 1) break;
|
||||
// 获取下一个时间点
|
||||
JSONObject next = deduplicated.get(i + 1);
|
||||
String nextTime = next.getStr("time");
|
||||
// 计算时间间隔(秒)
|
||||
long timeDiff = DateUtils.calculateTimeDifference(currentTime, nextTime);
|
||||
// 间隔 > 1 秒时,插入缺失的点
|
||||
if (timeDiff > 1) {
|
||||
for (int j = 1; j < timeDiff; j++) {
|
||||
String missingTime = DateUtils.addSeconds(currentTime, j);
|
||||
JSONObject missingReport = new JSONObject(current.toString());
|
||||
missingReport.set("time", missingTime);
|
||||
filledList.add(missingReport);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//去点
|
||||
for (int i = filledList.size() - 1; i > 0; i--) {
|
||||
if (i % 2 == 1) {
|
||||
filledList.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
return filledList;
|
||||
}
|
||||
|
||||
//添加dock信息
|
||||
private void addDockInfo(FlightTaskEntity entity, String dockSn) {
|
||||
entity.setDockSn(dockSn);
|
||||
|
|
|
|||
Loading…
Reference in New Issue