Browse Source

根据机场id获取机场状态信息接口开发

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
4f1fa7c974
6 changed files with 94 additions and 8 deletions
  1. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/FlightDataMapper.java
  2. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/InspectionRequest.java
  3. +1
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFlightDataTrackService.java
  4. +39
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/GetDroneDataByIdService.java
  5. +33
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/DroneDataVo.java
  6. +14
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/FlightDataMapper.xml

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/FlightDataMapper.java View File





import java.util.List; import java.util.List;
import java.util.Map;


/** /**
* @Author ChengWang * @Author ChengWang
List<FlightData> selectListByInspectionId(String id); List<FlightData> selectListByInspectionId(String id);




List<FlightData> selectListByInspection(Map<String, Object> map);
} }

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/InspectionRequest.java View File

*/ */
private String ysingal; private String ysingal;


/**
* 距离机场距离
*/
private String distHome;





} }

+ 1
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/flightdata/query/QueryFlightDataTrackService.java View File

flightData.setUltrasonic(inspectionRequest.getAltitude()); flightData.setUltrasonic(inspectionRequest.getAltitude());
flightData.setSpeed(inspectionRequest.getHspeed()); flightData.setSpeed(inspectionRequest.getHspeed());
flightData.setYsingal(inspectionRequest.getYsingal()); flightData.setYsingal(inspectionRequest.getYsingal());
flightData.setDistHome(inspectionRequest.getDistHome());


//将最新一条数据放入缓存,并设置过期时间 //将最新一条数据放入缓存,并设置过期时间
redisUtils.set(String.valueOf(inspection.getId()), flightData, 10); redisUtils.set(String.valueOf(inspection.getId()), flightData, 10);

+ 39
- 7
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/GetDroneDataByIdService.java View File

package com.tuoheng.admin.service.third.airport; 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.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.FlightData;
import com.tuoheng.admin.entity.Inspection; import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.TaskStatusEnum; import com.tuoheng.admin.enums.TaskStatusEnum;
import com.tuoheng.admin.mapper.FlightDataMapper;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.DroneDataVo;
import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils; import com.tuoheng.common.core.utils.StringUtils;
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.stereotype.Service; 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 * @Author ChengWang
@Autowired @Autowired
private InspectionMapper inspectionMapper; private InspectionMapper inspectionMapper;


@Autowired
private FlightDataMapper flightDataMapper;



public JsonResult getDroneDataById(Integer airportId) { public JsonResult getDroneDataById(Integer airportId) {


if(airportId ==null){ if(airportId ==null){
throw new ServiceException("机场Id为空"); throw new ServiceException("机场Id为空");
} }
String tenantId = CurrentUserUtil.getTenantId();
//String tenantId = CurrentUserUtil.getTenantId();
String tenantId = "0";
if(StringUtils.isEmpty(tenantId)){ if(StringUtils.isEmpty(tenantId)){
throw new ServiceException("当前租户不存在"); throw new ServiceException("当前租户不存在");
} }
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery() Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getTenantId, tenantId) .eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getAirportId, airportId) .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)) { if (ObjectUtils.isNull(inspection)) {
log.info("获取无人机数据信息,没有正在飞行的任务"); log.info("获取无人机数据信息,没有正在飞行的任务");
throw new ServiceException("没有正在飞行的任务"); 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);
} }
} }

+ 33
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/DroneDataVo.java View File

package com.tuoheng.admin.vo;

import lombok.Data;

@Data
public class DroneDataVo {

/**
* 正在执飞的任务ID
*/
private String inspectionId;

/**
* 无人机电量
*/
private String UavPower;

/**
* 续航里程
*/
private String range;

/**
* 目标位置
*/
private String targetLocation;

/**
* 图传信号
*/
private String ysingal;

}

+ 14
- 1
tuoheng-service/tuoheng-admin/src/main/resources/mapper/FlightDataMapper.xml View File

<result column="velocity" jdbcType="VARCHAR" property="velocity" /> <result column="velocity" jdbcType="VARCHAR" property="velocity" />
<result column="timestamp" jdbcType="VARCHAR" property="timestamp" /> <result column="timestamp" jdbcType="VARCHAR" property="timestamp" />
<result column="is_srt" jdbcType="INTEGER" property="isSrt" /> <result column="is_srt" jdbcType="INTEGER" property="isSrt" />
<result column="dist_home" jdbcType="INTEGER" property="distHome" />
<result column="speed" jdbcType="INTEGER" property="speed" />
<result column="ysingal" jdbcType="INTEGER" property="ysingal" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" /> <result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_user" jdbcType="VARCHAR" property="updateUser" /> <result column="update_user" jdbcType="VARCHAR" property="updateUser" />


<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, tenant_id, inspection_id, box_sn, lng, lat, altitude, ultrasonic, pitch, roll, yaw, airspeed, id, tenant_id, inspection_id, box_sn, lng, lat, altitude, ultrasonic, pitch, roll, yaw, airspeed,
velocity, `timestamp`, is_srt, create_user, create_time, update_user, update_time, mark
velocity, `timestamp`, is_srt, dist_home, speed, ysingal, create_user, create_time, update_user, update_time, mark
</sql> </sql>


<select id="selectListByInspectionId" resultMap="BaseResultMap"> <select id="selectListByInspectionId" resultMap="BaseResultMap">
order by timestamp asc order by timestamp asc
</select> </select>



<select id="selectListByInspection" parameterType="java.util.Map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"></include>
from th_flight_data
where inspection_id = #{inspectionId} and tenant_id = #{tenantId}
and mark = 1
order by create_time desc
</select>

</mapper> </mapper>

Loading…
Cancel
Save