@ -1,7 +1,17 @@
package com.palnet.biz.api.main.statistics.controller ;
import java.util.List ;
import com.palnet.biz.api.comn.response.BasicResponse ;
import com.palnet.biz.api.comn.response.ErrorResponse ;
import com.palnet.biz.api.comn.response.SuccessResponse ;
import com.palnet.biz.api.main.statistics.model.* ;
import com.palnet.biz.api.main.statistics.service.MainStatisticsService ;
import com.palnet.comn.exception.CustomException ;
import io.swagger.v3.oas.annotations.Operation ;
import io.swagger.v3.oas.annotations.Parameter ;
import io.swagger.v3.oas.annotations.responses.ApiResponse ;
import io.swagger.v3.oas.annotations.tags.Tag ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import org.springframework.http.HttpStatus ;
import org.springframework.http.MediaType ;
import org.springframework.http.ResponseEntity ;
@ -10,80 +20,82 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.RestController ;
import com.palnet.biz.api.comn.response.BasicResponse ;
import com.palnet.biz.api.comn.response.ErrorResponse ;
import com.palnet.biz.api.comn.response.SuccessResponse ;
import com.palnet.biz.api.main.statistics.model.FlightStcsValueModel ;
import com.palnet.biz.api.main.statistics.model.FlightStcsModel ;
import com.palnet.biz.api.main.statistics.model.FlightStcsRQ ;
import com.palnet.biz.api.main.statistics.service.MainStatisticsService ;
import io.swagger.annotations.ApiImplicitParam ;
import io.swagger.annotations.ApiImplicitParams ;
import io.swagger.annotations.ApiOperation ;
import io.swagger.v3.oas.annotations.tags.Tag ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.log4j.Log4j2 ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
@Log4j2
@Slf4j
@Tag ( name = "통계 컨트롤러" , description = "통계 관련 API" )
@RestController
@RequiredArgsConstructor
@RequestMapping ( value = "/api/main/statistics" , produces = { MediaType . APPLICATION_JSON_VALUE } )
@Tag ( name = "통계 컨트롤러" , description = "통계 관련 API" )
public class MainStatisticsController {
private final MainStatisticsService service ;
/ * *
* 비행통계 상단데이터 통계 조회기능 .
*
* @param serviceType
* @return
* /
@Operation ( summary = "비행 통계(총 비행시간, 총 비행거리, 총 비행횟수)" , description = "비행 통계(총 비행시간, 총 비행거리, 총 비행횟수) - 상단 통계" )
@ApiResponse ( responseCode = "200" , description = "OK" )
@Parameter ( name = "serviceType" , description = "서비스 타입(관할기관코드)" , example = "F0002" )
@GetMapping ( "/flight-static" )
@ApiOperation ( value = "비행통계 상단 데이터[DB전체 통계데이터]" )
@Tag ( name = "통계 컨트롤러" , description = "통계 관련 API" )
public ResponseEntity < ? extends BasicResponse > fltStcsStatic ( String serviceType ) {
List < FlightStcsValueModel > result = null ;
try {
result = service . getFlightStaticStcs ( serviceType ) ; // 비행관련 고정 통계, 항상 DB 전체값에서 통계조회 하는기능.
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : {}" , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < List < FlightStcsValueModel > > ( result ) ) ;
}
/ * *
* 날짜별 , 타입별 비행통계 조회 기능 .
* @param rq
* @param type
* @return
* /
@GetMapping ( "/flight/{type}" )
@ApiOperation ( value = "비행통계 cate = ['TIME', 'DISTANCE','FLT_COUNT'], type=['year','month','day','one-day']" )
@Tag ( name = "통계 컨트롤러" , description = "통계 관련 API" )
@ApiImplicitParams ( {
@ApiImplicitParam ( name = "date" , value = "날짜[2023]" , dataTypeClass = String . class ) ,
@ApiImplicitParam ( name = "cate" , value = "비행시간,거리,횟수[TIME]" , dataTypeClass = String . class ) ,
@ApiImplicitParam ( name = "type" , value = "날짜형식[month]" , dataTypeClass = String . class )
} )
public ResponseEntity < ? extends BasicResponse > fltStcs ( FlightStcsRQ rq , @PathVariable String type ) {
FlightStcsModel result = new FlightStcsModel ( ) ;
try {
String [ ] formatParam = null ;
public ResponseEntity < ? extends BasicResponse > fltStcsStatic ( String serviceType ) {
List < FlightStcsValueModel > result = null ;
try {
result = service . getFlightStaticStcs ( serviceType ) ; // 비행관련 고정 통계, 항상 DB 전체값에서 통계조회 하는기능.
} catch ( CustomException e ) {
Map < String , Object > resultMap = new HashMap < > ( ) ;
log . error ( "IGNORE : " , e ) ;
resultMap . put ( "result" , false ) ;
resultMap . put ( "errorCode" , e . getErrorCode ( ) ) ;
resultMap . put ( "errorMessage" , e . getMessage ( ) ) ;
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( resultMap ) ) ;
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : " , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( result ) ) ;
}
/ * *
* 날짜별 , 타입별 비행통계 조회 기능 .
* @param rq
* @param type
* @return
* /
@Operation ( summary = "비행통계(비행시간, 비행시간 TOP5)" , description = "비행통계(비행시간, 비행시간 TOP5)<br />" +
" cate = 'TIME'(시간), 'DISTANCE'(거리), 'FLT_COUNT'(횟수)<br />" +
" type=['year','month','day','one-day']<br />" +
" **type=year => date=, type=month => date=2023, type=day => date=2023-10, type=one-day => date=2023-10-01**" )
@ApiResponse ( responseCode = "200" , description = "OK" )
@GetMapping ( "/flight/{type}" )
public ResponseEntity < ? extends BasicResponse > fltStcs (
FlightStcsByFlightRQ rq ,
@Parameter ( description = "년/월/일 구분값 - ['year','month','day','one-day']" , example = "month" )
@PathVariable String type
) {
log . warn ( "type => {}" , type ) ;
FlightStcsModel result = new FlightStcsModel ( ) ;
try {
String [ ] formatParam = null ;
if ( rq . getDate ( ) = = null ) rq . setDate ( "" ) ;
formatParam = service . paramCheck ( rq . getDate ( ) , type ) ; // 파라미터 체크
@ -91,158 +103,15 @@ public class MainStatisticsController {
List < FlightStcsValueModel > graphData = service . fltStatics ( rq , formatParam ) ; // 비행통계 기능
List < FlightStcsValueModel > topData = service . fltTopStatics ( rq , formatParam ) ; // 비행통계 카테고리 별 Top 5 데이터 조회하기 기능
result . setGraphData ( graphData ) ;
result . setTopData ( topData ) ;
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : {}" , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < FlightStcsModel > ( result ) ) ;
}
/ * *
* 비정상 상황 상단 데이터 조회기능 .
* @param serviceType
* @return
* /
@GetMapping ( "/warn-static" )
@ApiOperation ( value = "비정상 상황 상단 데이터[DB전체 통계데이터]" )
@Tag ( name = "통계 컨트롤러" , description = "통계 관련 API" )
public ResponseEntity < ? extends BasicResponse > warnStcsStatic ( String serviceType ) {
List < FlightStcsValueModel > result = null ;
try {
result = service . getWarnStaticStcs ( serviceType ) ;
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : {}" , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < List < FlightStcsValueModel > > ( result ) ) ;
}
/ * *
* 날짜별 , 카테고리별 비정상 상황에 대한 통계 조회 기능
* @param rq
* @param type
* @return
* /
@GetMapping ( "/warn/{type}" )
@ApiOperation ( value = "비정상상황 cate = ['PLAN' ,'ALTITUDE', 'CRASH'], type=['year','month','day','one-day']" )
@Tag ( name = "통계 컨트롤러" , description = "통계 관련 API" )
@ApiImplicitParams ( {
@ApiImplicitParam ( name = "date" , value = "날짜[2023]" , dataTypeClass = String . class ) ,
@ApiImplicitParam ( name = "cate" , value = "비행시간,거리,횟수[TIME]" , dataTypeClass = String . class ) ,
@ApiImplicitParam ( name = "type" , value = "날짜형식[month]" , dataTypeClass = String . class )
} )
public ResponseEntity < ? extends BasicResponse > warnStcs ( FlightStcsRQ rq , @PathVariable String type ) {
FlightStcsModel result = new FlightStcsModel ( ) ;
try {
String [ ] formatParam = null ;
if ( rq . getDate ( ) = = null ) rq . setDate ( "" ) ;
formatParam = service . paramCheck ( rq . getDate ( ) , type ) ;
List < FlightStcsValueModel > graphData = service . warnStatics ( rq , formatParam ) ;
List < FlightStcsValueModel > topData = service . warnTopStatics ( rq , formatParam ) ;
result . setGraphData ( graphData ) ;
result . setTopData ( topData ) ;
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : {}" , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < FlightStcsModel > ( result ) ) ;
}
/ * *
* 비행실적 상단데이터 통계 기능 .
* @param serviceType
* @return
* /
@GetMapping ( "/flight/result-static" )
@ApiOperation ( value = "비행실적 상단데이터 통계 [DB전체 통계데이터]" )
@Tag ( name = "통계 컨트롤러" , description = "통계 관련 API" )
public ResponseEntity < ? extends BasicResponse > fltResultStcs ( String serviceType ) {
List < FlightStcsValueModel > result = null ;
try {
result = service . getFltResultStaticStcs ( serviceType ) ;
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : {}" , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < List < FlightStcsValueModel > > ( result ) ) ;
}
/ * *
* 날짜별 , 카테고리별 비행실적 통계
* @param rq
* @param type
* @return
* /
@GetMapping ( "/flight/result/{type}" )
@ApiOperation ( value = "비행실적 cate = ['FLT_RESULT' ,'FLT_PLAN', 'FLT_PLAN_APRVN'], type=['year','month','day','one-day']" )
@Tag ( name = "통계 컨트롤러" , description = "통계 관련 API" )
@ApiImplicitParams ( {
@ApiImplicitParam ( name = "date" , value = "날짜[2023]" , dataTypeClass = String . class ) ,
@ApiImplicitParam ( name = "cate" , value = "비행실적,비행계획서,비행계획승인[FLT_PLAN_APRVN]" , dataTypeClass = String . class ) ,
@ApiImplicitParam ( name = "type" , value = "날짜형식[month]" , dataTypeClass = String . class )
} )
public ResponseEntity < ? extends BasicResponse > fltResultStcs ( FlightStcsRQ rq , @PathVariable String type ) {
FlightStcsModel result = new FlightStcsModel ( ) ;
try {
String [ ] formatParam = null ;
if ( rq . getDate ( ) = = null ) rq . setDate ( "" ) ;
formatParam = service . paramCheck ( rq . getDate ( ) , type ) ;
List < FlightStcsValueModel > graphData = service . getFltResultStcs ( rq , formatParam ) ;
List < FlightStcsValueModel > topData = service . getFltTopResultStcs ( rq , formatParam ) ;
result . setGraphData ( graphData ) ;
result . setTopData ( topData ) ;
} catch ( CustomException e ) {
Map < String , Object > resultMap = new HashMap < > ( ) ;
log . error ( "IGNORE : " , e ) ;
resultMap . put ( "result" , false ) ;
resultMap . put ( "errorCode" , e . getErrorCode ( ) ) ;
resultMap . put ( "errorMessage" , e . getMessage ( ) ) ;
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( resultMap ) ) ;
} catch ( Exception e ) {
/ * *
* try {
@ -256,7 +125,191 @@ public class MainStatisticsController {
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < FlightStcsModel > ( result ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( result ) ) ;
}
/ * *
* 비정상 상황 상단 데이터 조회기능 .
* @param serviceType
* @return
* /
@Operation ( summary = "비정상 상황 통계(비행경로이탈,비정상고도,충돌위험)" , description = "비정상 상황 통계(비행경로이탈,비정상고도,충돌위험) - 상단 통계" )
@Parameter ( name = "serviceType" , description = "서비스 타입(관할기관코드)" , example = "F0002" )
@ApiResponse ( responseCode = "200" , description = "OK" )
@GetMapping ( "/warn-static" )
public ResponseEntity < ? extends BasicResponse > warnStcsStatic ( String serviceType ) {
List < FlightStcsValueModel > result = null ;
try {
result = service . getWarnStaticStcs ( serviceType ) ;
} catch ( CustomException e ) {
Map < String , Object > resultMap = new HashMap < > ( ) ;
log . error ( "IGNORE : " , e ) ;
resultMap . put ( "result" , false ) ;
resultMap . put ( "errorCode" , e . getErrorCode ( ) ) ;
resultMap . put ( "errorMessage" , e . getMessage ( ) ) ;
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( resultMap ) ) ;
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : " , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( result ) ) ;
}
/ * *
* 날짜별 , 카테고리별 비정상 상황에 대한 통계 조회 기능
* @param rq
* @param type
* @return
* /
@Operation ( summary = "비정상상황 통계(비행시간, 비행시간 TOP5)" , description = "비정상상황 통계(비행경로이탈 통계, 비행경로이탈 TOP5)<br />" +
" cate = 'PLAN'(비행경로이탈), 'ALTITUDE'(비정상고도), 'CRASH'(충돌위험)<br />" +
" type=['year','month','day','one-day']<br />" +
" **type=year => date=, type=month => date=2023, type=day => date=2023-10, type=one-day => date=2023-10-01**" )
@ApiResponse ( responseCode = "200" , description = "OK" )
@GetMapping ( "/warn/{type}" )
public ResponseEntity < ? extends BasicResponse > warnStcs (
FlightStcsByWarnRQ rq ,
@Parameter ( description = "년/월/일 구분값 - ['year','month','day','one-day']" , example = "month" )
@PathVariable String type
) {
FlightStcsModel result = new FlightStcsModel ( ) ;
try {
String [ ] formatParam = null ;
if ( rq . getDate ( ) = = null ) rq . setDate ( "" ) ;
formatParam = service . paramCheck ( rq . getDate ( ) , type ) ;
List < FlightStcsValueModel > graphData = service . warnStatics ( rq , formatParam ) ;
List < FlightStcsValueModel > topData = service . warnTopStatics ( rq , formatParam ) ;
result . setGraphData ( graphData ) ;
result . setTopData ( topData ) ;
} catch ( CustomException e ) {
Map < String , Object > resultMap = new HashMap < > ( ) ;
log . error ( "IGNORE : " , e ) ;
resultMap . put ( "result" , false ) ;
resultMap . put ( "errorCode" , e . getErrorCode ( ) ) ;
resultMap . put ( "errorMessage" , e . getMessage ( ) ) ;
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( resultMap ) ) ;
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : " , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( result ) ) ;
}
/ * *
* 비행실적 상단데이터 통계 기능 .
* @param serviceType
* @return
* /
@Operation ( summary = "비행 실적 통계(비행실적,비행계획,비행승인)" , description = "비행 실적 통계(비행실적,비행계획,비행승인) - 상단 통계" )
@Parameter ( name = "serviceType" , description = "서비스 타입(관할기관코드)" , example = "F0002" )
@ApiResponse ( responseCode = "200" , description = "OK" )
@GetMapping ( "/flight/result-static" )
public ResponseEntity < ? extends BasicResponse > fltResultStcs ( String serviceType ) {
List < FlightStcsValueModel > result = null ;
try {
result = service . getFltResultStaticStcs ( serviceType ) ;
} catch ( CustomException e ) {
Map < String , Object > resultMap = new HashMap < > ( ) ;
log . error ( "IGNORE : " , e ) ;
resultMap . put ( "result" , false ) ;
resultMap . put ( "errorCode" , e . getErrorCode ( ) ) ;
resultMap . put ( "errorMessage" , e . getMessage ( ) ) ;
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( resultMap ) ) ;
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : " , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( result ) ) ;
}
/ * *
* 날짜별 , 카테고리별 비행실적 통계
* @param rq
* @param type
* @return
* /
@Operation ( summary = "비행 실적 통계(비행 실적 통계, 비행 실적 TOP5)" , description = "비행 실적 통계(비행 실적 통계, 비행 실적 TOP5)<br />" +
" cate = 'FLT_RESULT'(실적), 'FLT_PLAN'(계획),'FLT_PLAN_APRVN'(승인)<br />" +
" type=['year','month','day','one-day']<br />" +
" **type=year => date=, type=month => date=2023, type=day => date=2023-10, type=one-day => date=2023-10-01**" )
@ApiResponse ( responseCode = "200" , description = "OK" )
@GetMapping ( "/flight/result/{type}" )
public ResponseEntity < ? extends BasicResponse > fltResultStcs (
FlightStcsByResultRQ rq ,
@Parameter ( description = "년/월/일 구분값 - ['year','month','day','one-day']" , example = "month" )
@PathVariable String type
) {
FlightStcsModel result = new FlightStcsModel ( ) ;
try {
String [ ] formatParam = null ;
if ( rq . getDate ( ) = = null ) rq . setDate ( "" ) ;
formatParam = service . paramCheck ( rq . getDate ( ) , type ) ;
List < FlightStcsValueModel > graphData = service . getFltResultStcs ( rq , formatParam ) ;
List < FlightStcsValueModel > topData = service . getFltTopResultStcs ( rq , formatParam ) ;
result . setGraphData ( graphData ) ;
result . setTopData ( topData ) ;
} catch ( CustomException e ) {
Map < String , Object > resultMap = new HashMap < > ( ) ;
log . error ( "IGNORE : " , e ) ;
resultMap . put ( "result" , false ) ;
resultMap . put ( "errorCode" , e . getErrorCode ( ) ) ;
resultMap . put ( "errorMessage" , e . getMessage ( ) ) ;
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( resultMap ) ) ;
} catch ( Exception e ) {
/ * *
* try {
. . .
}
* try 영역 안 코드들중 문제가 생기면 오는 곳 .
* log . error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
* /
log . error ( "IGNORE : " , e ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( new ErrorResponse ( "Server Error" , "-1" ) ) ;
}
return ResponseEntity . ok ( ) . body ( new SuccessResponse < > ( result ) ) ;
}
}