文旅相关逻辑集成

This commit is contained in:
2025-01-03 16:16:43 +08:00
parent d9aab272ff
commit 6dcc2800ae
425 changed files with 30633 additions and 1907 deletions
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
import com.central.common.model.Result;
import com.central.device.message.ControlEnum;
import com.central.device.message.ControlMessageConstant;
import com.central.device.util.MapUtil;
import com.central.device.util.RequestUtils;
@@ -61,33 +62,15 @@ public class ApiDeviceController {
@PostMapping("/setting/{deviceId}/property")
public Result writeProperties(@RequestBody Map<String,Object> param, @PathVariable("deviceId") String deviceId) throws IOException {
String url = baseUrl + "/device/instance/" + deviceId + "/property";
// JSONObject jsonObject = new JSONObject();
// for (Map.Entry entry : param.entrySet()){
// jsonObject.put(entry.getKey().toString(),entry.getValue());
// }
String json = "{\n" +
" \"data\": {\n" +
"\t \"flight_id\": flight_id,\n" +
"\t \"max_speed\": 5,\n" +
"\t \"rc_lost_action\": 2,\n" +
"\t \"rth_altitude\": 60.0,\n" +
"\t \"rth_mode\": 1,\n" +
"\t \"security_takeoff_height\": 60.0,\n" +
"\t \"target_height\": 70.0,\n" +
"\t \"target_latitude\": 39.102603,\n" +
"\t \"target_longitude\": 117.711972,\n" +
"\t \"commander_mode_lost_action\": 0,\n" +
"\t \"commander_flight_mode\": 1,\n" +
"\t \"commander_flight_height\": 70.0,\n" +
"\t \"simulate_mission\": {\n" +
"\t },\n" +
"\t \"flight_safety_advance_check\": 0\n" +
"\t},\n" +
"\t\"method\": \"takeoff_to_point\"\n" +
"}";
Gson gson = new Gson();
JsonObject jsonObject = gson.fromJson(json, JsonObject.class);
JsonObject jsonObject;
if (ControlEnum.TAKEOFF_TO_POINT.getName().equals(param.get("control"))) {
jsonObject = gson.fromJson(ControlMessageConstant.TAKEOFF_TO_POINT, JsonObject.class);
} else if (ControlEnum.RETURN_HOME.getName().equals(param.get("control"))) {
jsonObject = gson.fromJson(ControlMessageConstant.RETURN_HOME, JsonObject.class);
}else {
return Result.succeed("暂未开放控制权限");
}
Map<String, String> result = requestUtils.getPostRequestResultMap(url, jsonObject.toString());
return Result.succeed(result,"设置成功");
}