|
@@ -53,7 +53,72 @@ public class AirRouteService implements Runnable {
|
|
|
String result = HttpProxy.http_get_json(URLs.air_detail_url, params);
|
|
|
// 没有数据
|
|
|
if (!StringUtils.hasText(result)) { return null; }
|
|
|
+ JSONObject obj = JSON.parseObject(result);System.out.println(result);
|
|
|
+ AirPlane air = new AirPlane();
|
|
|
+ air.setFlight(info.getF());
|
|
|
+ if (obj.containsKey("time")) {
|
|
|
+ JSONObject timeObj = (JSONObject) obj.get("time");
|
|
|
+ JSONObject scheduledObj = (JSONObject)timeObj.get("scheduled");
|
|
|
+ JSONObject realObj = (JSONObject)timeObj.get("real");
|
|
|
+
|
|
|
+ air.setDeparture(realObj.getLong("departure"));
|
|
|
+ air.setArrival(scheduledObj.getLong("arrival"));
|
|
|
+ air.setDepSchd(scheduledObj.getLong("departure"));
|
|
|
+ air.setArrSchd(scheduledObj.getLong("arrival"));
|
|
|
+ }
|
|
|
+ if (obj.containsKey("airport")) {
|
|
|
+ JSONObject airportObj = (JSONObject) obj.get("airport");
|
|
|
+
|
|
|
+ JSONObject originObj = (JSONObject) airportObj.get("origin");
|
|
|
+ JSONObject codeObj = (JSONObject) originObj.get("code");
|
|
|
+ air.setFromIata(codeObj.getString("iata"));
|
|
|
+
|
|
|
+ JSONObject destinationObj = (JSONObject) airportObj.get("destination");
|
|
|
+ JSONObject destcodeObj = (JSONObject) destinationObj.get("code");
|
|
|
+ air.setToIata(destcodeObj.getString("iata"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.containsKey("aircraft")) {
|
|
|
+ JSONObject aircraftObj = (JSONObject) obj.get("aircraft");
|
|
|
+ JSONObject imageObj = (JSONObject) aircraftObj.get("images");
|
|
|
+ JSONObject srcObj = (JSONObject)imageObj.getJSONArray("large").get(0);
|
|
|
+ air.setImage(srcObj.getString("src"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.containsKey("trail")) {
|
|
|
|
|
|
+ JSONArray trail = obj.getJSONArray("trail");
|
|
|
+ List<AirPosition> airPosList = new ArrayList<AirPosition>();
|
|
|
+ AirPosition airPos = null;
|
|
|
+ for (int i = 0; i < trail.size(); i++) {
|
|
|
+ JSONObject trailObj = (JSONObject)trail.get(i);
|
|
|
+ airPos = new AirPosition();
|
|
|
+ airPos.setSort(i);
|
|
|
+ airPos.setLat(trailObj.getDouble("lat"));
|
|
|
+ airPos.setLon(trailObj.getDouble("lng"));
|
|
|
+ airPos.setAlltitude(trailObj.getDouble("alt"));
|
|
|
+ airPosList.add(airPos);
|
|
|
+ }
|
|
|
+ air.setRoute(airPosList);
|
|
|
+ }
|
|
|
+ return air;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取航班详细信息
|
|
|
+ *
|
|
|
+ * @param info
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public AirPlane getAirDetailInfo2(AirDynamic info) throws IOException {
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("flight", info.getF());
|
|
|
+ params.put("altitude", info.getHigh());
|
|
|
+ params.put("equip_hint", info.getXingh());
|
|
|
+ String result = HttpProxy.http_get_json(URLs.air_detail_url, params);
|
|
|
+ // 没有数据
|
|
|
+ if (!StringUtils.hasText(result)) { return null; }
|
|
|
JSONObject obj = JSON.parseObject(result);
|
|
|
AirPlane air = new AirPlane();
|
|
|
if (obj.containsKey("flight")) {
|