|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.platform.cac;
|
|
|
|
package com.platform.cac;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
import com.platform.info.GlobalData;
|
|
|
|
import com.platform.info.GlobalData;
|
|
|
|
import com.platform.model.DirectControlUavParam;
|
|
|
|
import com.platform.model.DirectControlUavParam;
|
|
|
|
import com.platform.model.Result;
|
|
|
|
import com.platform.model.Result;
|
|
|
@ -45,12 +46,13 @@ public class CacHpApi {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private static Result postRequestAndGetResult(String api, String body) {
|
|
|
|
private static Result<String> postRequestAndGetResult(String api, String body) {
|
|
|
|
String path = "http://" + HOST + api;
|
|
|
|
String path = "http://" + HOST + api;
|
|
|
|
HashMap<String, String> header = new HashMap<>(3);
|
|
|
|
HashMap<String, String> header = new HashMap<>(3);
|
|
|
|
generateAuthAndDateHeader(header, "POST", GlobalData.GCS_ID, GlobalData.GCS_TOKEN, api);
|
|
|
|
generateAuthAndDateHeader(header, "POST", GlobalData.GCS_ID, GlobalData.GCS_TOKEN, api);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return HttpClientUtils.sendPost(path, body, header, Result.class);
|
|
|
|
String responseStr = HttpClientUtils.sendPost(path, body, header);
|
|
|
|
|
|
|
|
return JSONUtils.json2obj(responseStr, new TypeReference<Result<String>>() {});
|
|
|
|
} catch (ConnectException e) {
|
|
|
|
} catch (ConnectException e) {
|
|
|
|
log.error("[cac] http请求超时: {}", e.getMessage());
|
|
|
|
log.error("[cac] http请求超时: {}", e.getMessage());
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
@ -85,12 +87,12 @@ public class CacHpApi {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static String gcsSignIn(String body) {
|
|
|
|
public static String gcsSignIn(String body) {
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/signIn";
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/signIn";
|
|
|
|
Result result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
Result<String> result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
log.error("[cac] 地面站上线失败: {}", result);
|
|
|
|
log.error("[cac] 地面站上线失败: {}", result);
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result.getData().toString();
|
|
|
|
return result.getData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -108,7 +110,7 @@ public class CacHpApi {
|
|
|
|
body.put("uavId", uavId);
|
|
|
|
body.put("uavId", uavId);
|
|
|
|
body.put("gcsId", GlobalData.GCS_ID);
|
|
|
|
body.put("gcsId", GlobalData.GCS_ID);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Result result = postRequestAndGetResult(gcsSignApi, JSONUtils.obj2json(body));
|
|
|
|
Result<String> result = postRequestAndGetResult(gcsSignApi, JSONUtils.obj2json(body));
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
log.error("[cac] 无人机上线失败: {}", result);
|
|
|
|
log.error("[cac] 无人机上线失败: {}", result);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -128,7 +130,7 @@ public class CacHpApi {
|
|
|
|
body.put("uavId", uavId);
|
|
|
|
body.put("uavId", uavId);
|
|
|
|
body.put("gcsId", GlobalData.GCS_ID);
|
|
|
|
body.put("gcsId", GlobalData.GCS_ID);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Result result = postRequestAndGetResult(gcsSignApi, JSONUtils.obj2json(body));
|
|
|
|
Result<String> result = postRequestAndGetResult(gcsSignApi, JSONUtils.obj2json(body));
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
log.error("[cac] 无人机下线失败: {}", result);
|
|
|
|
log.error("[cac] 无人机下线失败: {}", result);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -154,7 +156,7 @@ public class CacHpApi {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static boolean commandNotify(String body) {
|
|
|
|
public static boolean commandNotify(String body) {
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/notifyUavCommand";
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/notifyUavCommand";
|
|
|
|
Result result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
Result<String> result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
log.error("[cac] 指令执行结果通知失败: {}", result);
|
|
|
|
log.error("[cac] 指令执行结果通知失败: {}", result);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -166,7 +168,7 @@ public class CacHpApi {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static boolean uavParamQueryResultNotify(String body) {
|
|
|
|
public static boolean uavParamQueryResultNotify(String body) {
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/uavParamQueryResultNotify";
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/uavParamQueryResultNotify";
|
|
|
|
Result result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
Result<String> result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
log.error("[cac] 参数查询结果通知失败: {}", result);
|
|
|
|
log.error("[cac] 参数查询结果通知失败: {}", result);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -179,7 +181,7 @@ public class CacHpApi {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static boolean uavParamBindResultNotify(String body) {
|
|
|
|
public static boolean uavParamBindResultNotify(String body) {
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/uavParamBindResultNotify";
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/uavParamBindResultNotify";
|
|
|
|
Result result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
Result<String> result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
if (result == null || !result.isSuccess()) {
|
|
|
|
log.error("[cac] 装订执行结果通知失败: {}", result);
|
|
|
|
log.error("[cac] 装订执行结果通知失败: {}", result);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -192,12 +194,12 @@ public class CacHpApi {
|
|
|
|
public static List<DirectControlUavParam> queryAllCacDirectControlUavList(String body) {
|
|
|
|
public static List<DirectControlUavParam> queryAllCacDirectControlUavList(String body) {
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/queryAllCacDirectControlUavList";
|
|
|
|
final String gcsSignApi = HTFP_PATH + "/queryAllCacDirectControlUavList";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Result result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
Result<String> result = postRequestAndGetResult(gcsSignApi, body);
|
|
|
|
if (result == null || !result.isSuccess()){
|
|
|
|
if (result == null || !result.isSuccess()){
|
|
|
|
log.error("查询全量无人机映射关系失败: {}", result);
|
|
|
|
log.error("查询全量无人机映射关系失败: {}", result);
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return JSONUtils.json2list(result.getData().toString(), DirectControlUavParam.class);
|
|
|
|
return JSONUtils.json2list(result.getData(), DirectControlUavParam.class);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("查询全量无人机映射关系失败: {}", e.getMessage());
|
|
|
|
log.error("查询全量无人机映射关系失败: {}", e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -209,12 +211,12 @@ public class CacHpApi {
|
|
|
|
Map<String, String> body = new HashMap<>();
|
|
|
|
Map<String, String> body = new HashMap<>();
|
|
|
|
body.put("haborSn", haborSn);
|
|
|
|
body.put("haborSn", haborSn);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Result result = postRequestAndGetResult(gcsSignApi, JSONUtils.obj2json(body));
|
|
|
|
Result<String> result = postRequestAndGetResult(gcsSignApi, JSONUtils.obj2json(body));
|
|
|
|
if (result == null || !result.isSuccess()){
|
|
|
|
if (result == null || !result.isSuccess()){
|
|
|
|
log.error("查询单个无人机映射关系失败,body={}, result={}", body, result);
|
|
|
|
log.error("查询单个无人机映射关系失败,body={}, result={}", body, result);
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return JSONUtils.json2obj(result.getData().toString(), DirectControlUavParam.class);
|
|
|
|
return JSONUtils.json2obj(result.getData(), DirectControlUavParam.class);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("查询全量无人机映射关系失败: {}", e.getMessage());
|
|
|
|
log.error("查询全量无人机映射关系失败: {}", e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|