|
|
@@ -1,18 +1,29 @@ |
|
|
|
package com.tuoheng.admin.service.third.airport; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.tuoheng.admin.entity.FlightData; |
|
|
|
import com.tuoheng.admin.entity.Inspection; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.enums.TaskStatusEnum; |
|
|
|
import com.tuoheng.admin.mapper.FlightDataMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.admin.vo.DroneDataVo; |
|
|
|
import com.tuoheng.common.core.exception.ServiceException; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author ChengWang |
|
|
@@ -25,6 +36,9 @@ public class GetDroneDataByIdService { |
|
|
|
@Autowired |
|
|
|
private InspectionMapper inspectionMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FlightDataMapper flightDataMapper; |
|
|
|
|
|
|
|
|
|
|
|
public JsonResult getDroneDataById(Integer airportId) { |
|
|
|
|
|
|
@@ -33,7 +47,8 @@ public class GetDroneDataByIdService { |
|
|
|
if(airportId ==null){ |
|
|
|
throw new ServiceException("机场Id为空"); |
|
|
|
} |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
//String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
String tenantId = "0"; |
|
|
|
if(StringUtils.isEmpty(tenantId)){ |
|
|
|
throw new ServiceException("当前租户不存在"); |
|
|
|
} |
|
|
@@ -41,16 +56,33 @@ public class GetDroneDataByIdService { |
|
|
|
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery() |
|
|
|
.eq(Inspection::getTenantId, tenantId) |
|
|
|
.eq(Inspection::getAirportId, airportId) |
|
|
|
.eq(Inspection::getStatus, TaskStatusEnum.INFLIGHT.getCode()) |
|
|
|
.eq(Inspection::getMark, MarkEnum.VALID.getCode())); |
|
|
|
.eq(Inspection::getStatus,10) |
|
|
|
.eq(Inspection::getMark, 1)); |
|
|
|
if (ObjectUtils.isNull(inspection)) { |
|
|
|
log.info("获取无人机数据信息,没有正在飞行的任务"); |
|
|
|
throw new ServiceException("没有正在飞行的任务"); |
|
|
|
} |
|
|
|
//根据当前正在飞行的任务查询实时数据 |
|
|
|
|
|
|
|
|
|
|
|
//根据当前正在飞行的任务查询实时数据 flight_data表 |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("inspectionId",inspection.getId()); |
|
|
|
map.put("tenantId",tenantId); |
|
|
|
List<FlightData> flightDataList = flightDataMapper.selectListByInspection(map); |
|
|
|
if(CollectionUtils.isEmpty(flightDataList)){ |
|
|
|
log.info("获取无人机数据信息,数据为空"); |
|
|
|
JsonResult.success("数据为空"); |
|
|
|
} |
|
|
|
List<DroneDataVo> droneDataVoList = new ArrayList<>(); |
|
|
|
for (FlightData flightData : flightDataList) { |
|
|
|
DroneDataVo droneDataVo = new DroneDataVo(); |
|
|
|
droneDataVo.setInspectionId(flightData.getInspectionId()); |
|
|
|
droneDataVo.setUavPower(79 + "%"); |
|
|
|
droneDataVo.setRange(""); |
|
|
|
double dist = Integer.valueOf(flightData.getDistHome())/1000d; |
|
|
|
droneDataVo.setTargetLocation(dist+ "km"); |
|
|
|
droneDataVo.setYsingal(flightData.getYsingal() + "%"); |
|
|
|
droneDataVoList.add(droneDataVo); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
return JsonResult.success(droneDataVoList); |
|
|
|
} |
|
|
|
} |