Browse Source

无人机控制接口

develop
wangwei 1 year ago
parent
commit
01b6704686
3 changed files with 14 additions and 7 deletions
  1. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/enums/DroneControlEnum.java
  2. +6
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/enums/ServiceExceptionEnum.java
  3. +7
    -4
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/drone/impl/DroneControlServiceImpl.java

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/enums/DroneControlEnum.java View File

@@ -82,7 +82,7 @@ public enum DroneControlEnum {
* @param requestCode
* @return
*/
public static DroneControlEnum findEnumByValue(String requestCode) {
public static DroneControlEnum findEnumByRequestCode(String requestCode) {
for (DroneControlEnum statusEnum : DroneControlEnum.values()) {
if (statusEnum.getRequsetCode() == requestCode) {
return statusEnum;

+ 6
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/enums/ServiceExceptionEnum.java View File

@@ -19,9 +19,13 @@ public enum ServiceExceptionEnum implements ExceptionInterface {
*/
AIRPORT_ENVIORMENT_ERROR(5555, "机场环境检查异常!"),

HTTP_RETURN_EMPTY(5556,"请求返回空"),
FIND_NULL(5554,"查询为空"),

HTTP_RETURN_EMPTY(5553,"请求返回空"),

HTTP_RETURN_ERROR(5552,"请求返回错误"),


HTTP_RETURN_ERROR(5557,"请求返回错误"),
;

@Getter

+ 7
- 4
tuoheng-admin/src/main/java/com/tuoheng/admin/service/drone/impl/DroneControlServiceImpl.java View File

@@ -41,10 +41,11 @@ public class DroneControlServiceImpl implements IDroneControlService {
try {
Airport airport = airportService.getById(airportId);
if (airport==null){
return JsonResult.error(ServiceExceptionEnum.HTTP_RETURN_ERROR);
log.info("机场ID:{}查询为空",airportId);
return JsonResult.error(ServiceExceptionEnum.FIND_NULL.getCode(),ServiceExceptionEnum.FIND_NULL.getMessage());
}
JSONObject parm = new JSONObject();
DroneControlEnum droneControlEnum = DroneControlEnum.findEnumByValue(action);
DroneControlEnum droneControlEnum = DroneControlEnum.findEnumByRequestCode(action);
parm.put(droneControlEnum.getCode(), droneControlEnum.getValue());
String result = HTTPUtils.requestHTTPContent(airport.getGroundStationUrl(),"post",HTTPUtils.headers,parm);
return returnResult(result,airport.getGroundStationUrl(),JSONObject.toJSONString(parm));
@@ -65,7 +66,8 @@ public class DroneControlServiceImpl implements IDroneControlService {
public JsonResult toPiont(Point point, int airportId) {
Airport airport = airportService.getById(airportId);
if (airport==null){
return JsonResult.error(ServiceExceptionEnum.HTTP_RETURN_ERROR);
log.info("机场ID:{}查询为空",airportId);
return JsonResult.error(ServiceExceptionEnum.FIND_NULL.getCode(),ServiceExceptionEnum.FIND_NULL.getMessage());
}
JSONObject parm = (JSONObject)JSONObject.toJSON(point);
String result = null;
@@ -88,7 +90,8 @@ public class DroneControlServiceImpl implements IDroneControlService {
public JsonResult uploadFlyLine(String url, int airportId) {
Airport airport = airportService.getById(airportId);
if (airport==null){
return JsonResult.error(ServiceExceptionEnum.HTTP_RETURN_ERROR);
log.info("机场ID:{}查询为空",airportId);
return JsonResult.error(ServiceExceptionEnum.FIND_NULL.getCode(),ServiceExceptionEnum.FIND_NULL.getMessage());
}
JSONObject parm = new JSONObject();
parm.put("hangdian",url);

Loading…
Cancel
Save