|
|
@ -1,10 +1,6 @@ |
|
|
|
package com.palnet.biz.api.bas.flight.controller; |
|
|
|
package com.palnet.biz.api.bas.flight.controller; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
import java.io.*; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.net.URLEncoder; |
|
|
@ -20,13 +16,16 @@ import com.palnet.biz.api.bas.flight.model.BasFlightPlanModel; |
|
|
|
import com.palnet.biz.api.bas.flight.model.BasFlightPlanPilotModel; |
|
|
|
import com.palnet.biz.api.bas.flight.model.BasFlightPlanPilotModel; |
|
|
|
import com.palnet.biz.api.bas.flight.model.BasFlightScheduleRs; |
|
|
|
import com.palnet.biz.api.bas.flight.model.BasFlightScheduleRs; |
|
|
|
import com.palnet.biz.api.bas.flight.model.BasFlightWeatherModel; |
|
|
|
import com.palnet.biz.api.bas.flight.model.BasFlightWeatherModel; |
|
|
|
|
|
|
|
import com.palnet.biz.api.ctr.cntrl.model.CtrCntrlWeatherModel; |
|
|
|
|
|
|
|
import com.palnet.biz.scheduler.ctr.model.CtrTrnsLctnModel; |
|
|
|
|
|
|
|
import com.palnet.biz.scheduler.ctr.service.CtrTrnsLctnService; |
|
|
|
import org.json.simple.JSONObject; |
|
|
|
import org.json.simple.JSONObject; |
|
|
|
import org.json.simple.parser.JSONParser; |
|
|
|
import org.json.simple.parser.JSONParser; |
|
|
|
import org.json.simple.parser.ParseException; |
|
|
|
import org.json.simple.parser.ParseException; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.core.io.ClassPathResource; |
|
|
|
import org.springframework.core.io.ClassPathResource; |
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
import org.springframework.data.domain.PageImpl; |
|
|
|
|
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
@ -60,10 +59,13 @@ public class BasFlightController { |
|
|
|
|
|
|
|
|
|
|
|
private final BasFlightService basFlightService; |
|
|
|
private final BasFlightService basFlightService; |
|
|
|
private final Environment env; |
|
|
|
private final Environment env; |
|
|
|
|
|
|
|
private final CtrTrnsLctnService ctrTrnsLctnService; |
|
|
|
|
|
|
|
|
|
|
|
public BasFlightController(BasFlightService basFlightService, Environment env) { |
|
|
|
@Autowired |
|
|
|
|
|
|
|
public BasFlightController(BasFlightService basFlightService, Environment env, CtrTrnsLctnService ctrTrnsLctnService) { |
|
|
|
this.basFlightService = basFlightService; |
|
|
|
this.basFlightService = basFlightService; |
|
|
|
this.env = env; |
|
|
|
this.env = env; |
|
|
|
|
|
|
|
this.ctrTrnsLctnService = ctrTrnsLctnService; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/area") |
|
|
|
@GetMapping("/area") |
|
|
@ -259,6 +261,8 @@ public class BasFlightController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/plan/api/weather") |
|
|
|
@GetMapping("/plan/api/weather") |
|
|
|
|
|
|
|
@ApiOperation(value = "날씨") |
|
|
|
|
|
|
|
@Tag(name = "비행계획서", description = "비행계획서 관련 API") |
|
|
|
public ResponseEntity<? extends BasicResponse> restApiGetWeather(BasFlightWeatherModel rs) throws IOException, ParseException { |
|
|
|
public ResponseEntity<? extends BasicResponse> restApiGetWeather(BasFlightWeatherModel rs) throws IOException, ParseException { |
|
|
|
StringBuilder urlBuilder = new StringBuilder("http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst"); |
|
|
|
StringBuilder urlBuilder = new StringBuilder("http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst"); |
|
|
|
urlBuilder.append("?" + URLEncoder.encode("serviceKey","UTF-8") + "=r6RMUsk3Vtama7D6uq7MiWV9dTC9MwfIIr4%2F45y0uVNw6BaYbgpKmL%2BLUDFVTfIYUmEe4K%2FaniEjdV9mg5t82Q%3D%3D"); |
|
|
|
urlBuilder.append("?" + URLEncoder.encode("serviceKey","UTF-8") + "=r6RMUsk3Vtama7D6uq7MiWV9dTC9MwfIIr4%2F45y0uVNw6BaYbgpKmL%2BLUDFVTfIYUmEe4K%2FaniEjdV9mg5t82Q%3D%3D"); |
|
|
@ -282,12 +286,26 @@ public class BasFlightController { |
|
|
|
} |
|
|
|
} |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
String line; |
|
|
|
String line; |
|
|
|
|
|
|
|
|
|
|
|
while ((line = rd.readLine()) != null) { |
|
|
|
while ((line = rd.readLine()) != null) { |
|
|
|
sb.append(line); |
|
|
|
sb.append(line); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
CtrTrnsLctnModel weatherResult = ctrTrnsLctnService.convertLatlonToAddress(rs.getNx2(),rs.getNy2()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("weatherResult >>>> : {}", weatherResult); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String str = sb.toString(); |
|
|
|
String str = sb.toString(); |
|
|
|
JSONParser parser = new JSONParser(); |
|
|
|
JSONParser parser = new JSONParser(); |
|
|
|
JSONObject jsonObject = (JSONObject) parser.parse(str); |
|
|
|
JSONObject jsonObject = (JSONObject) parser.parse(str); |
|
|
|
|
|
|
|
jsonObject.put("area1",weatherResult.getArea1()); |
|
|
|
|
|
|
|
jsonObject.put("area2",weatherResult.getArea2()); |
|
|
|
|
|
|
|
jsonObject.put("area3",weatherResult.getArea3()); |
|
|
|
|
|
|
|
// CtrCntrlWeatherModel areaResult = new CtrCntrlWeatherModel();
|
|
|
|
|
|
|
|
// areaResult.setArea1(weatherResult.getArea1());
|
|
|
|
|
|
|
|
// areaResult.setArea2(weatherResult.getArea2());
|
|
|
|
|
|
|
|
// areaResult.setArea3(weatherResult.getArea3());
|
|
|
|
rd.close(); |
|
|
|
rd.close(); |
|
|
|
conn.disconnect(); |
|
|
|
conn.disconnect(); |
|
|
|
log.info(sb.toString()); |
|
|
|
log.info(sb.toString()); |
|
|
|