|
|
|
@ -1,12 +1,20 @@
|
|
|
|
|
import axios from '../../../modules/utils/customAxiosUtil'; |
|
|
|
|
import qs from 'qs'; |
|
|
|
|
import { IStcsRq, IStcsSearchRq } from './statisticsState'; |
|
|
|
|
|
|
|
|
|
import { createAsyncThunk } from '@reduxjs/toolkit'; |
|
|
|
|
import { isError, isMessage } from '../comn/message/messageSlice'; |
|
|
|
|
import { |
|
|
|
|
ERROR_MESSAGE, |
|
|
|
|
DUPLATE_MESSAGE, |
|
|
|
|
SAVE_MESSAGE, |
|
|
|
|
DELETE_MESSAGE |
|
|
|
|
} from '@src/configs/constants'; |
|
|
|
|
|
|
|
|
|
// 비행 통계(총 비행시간, 총 비행 건수,총 비행거리)
|
|
|
|
|
export const getFlightStatistics = createAsyncThunk( |
|
|
|
|
'statistics/getFlightStatistics', |
|
|
|
|
async (rq: IStcsRq, thunkAPI) => { |
|
|
|
|
const { rejectWithValue } = thunkAPI; |
|
|
|
|
try { |
|
|
|
|
const { serviceType } = rq; |
|
|
|
|
const res = await axios.get( |
|
|
|
@ -16,14 +24,24 @@ export const getFlightStatistics = createAsyncThunk(
|
|
|
|
|
); |
|
|
|
|
return res.data; |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error(error); |
|
|
|
|
thunkAPI.dispatch( |
|
|
|
|
isError({ |
|
|
|
|
errorCode: ERROR_MESSAGE.code, |
|
|
|
|
errorMessage: ERROR_MESSAGE.message, |
|
|
|
|
isHistoryBack: false, |
|
|
|
|
isRefresh: false |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
return rejectWithValue(error); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 비행통계(비행시간, 비행 시간 top5)
|
|
|
|
|
export const getFlightSearch = createAsyncThunk( |
|
|
|
|
'statistics/getFlightSearch', |
|
|
|
|
async (rq: IStcsSearchRq, thunkAPI) => { |
|
|
|
|
const { rejectWithValue } = thunkAPI; |
|
|
|
|
try { |
|
|
|
|
const { type } = rq; |
|
|
|
|
const params = {}; |
|
|
|
@ -41,14 +59,24 @@ export const getFlightSearch = createAsyncThunk(
|
|
|
|
|
); |
|
|
|
|
return res.data; |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error(error); |
|
|
|
|
thunkAPI.dispatch( |
|
|
|
|
isError({ |
|
|
|
|
errorCode: ERROR_MESSAGE.code, |
|
|
|
|
errorMessage: ERROR_MESSAGE.message, |
|
|
|
|
isHistoryBack: false, |
|
|
|
|
isRefresh: false |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
return rejectWithValue(error); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 비정상 상황 통계(비행경로이탈, 비정상고도, 충돌위험)
|
|
|
|
|
export const getAbnormalStatistics = createAsyncThunk( |
|
|
|
|
'statistics/getAbnormalStatistics', |
|
|
|
|
async (rq: IStcsRq, thunkAPI) => { |
|
|
|
|
const { rejectWithValue } = thunkAPI; |
|
|
|
|
try { |
|
|
|
|
const { serviceType } = rq; |
|
|
|
|
const res = await axios.get( |
|
|
|
@ -58,14 +86,24 @@ export const getAbnormalStatistics = createAsyncThunk(
|
|
|
|
|
); |
|
|
|
|
return res.data; |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error(error); |
|
|
|
|
thunkAPI.dispatch( |
|
|
|
|
isError({ |
|
|
|
|
errorCode: ERROR_MESSAGE.code, |
|
|
|
|
errorMessage: ERROR_MESSAGE.message, |
|
|
|
|
isHistoryBack: false, |
|
|
|
|
isRefresh: false |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
return rejectWithValue(error); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 비정상상황 통계(비행시간, 비행시간 top5)
|
|
|
|
|
export const getAbnormalSearch = createAsyncThunk( |
|
|
|
|
'statistics/getAbnormalSearch', |
|
|
|
|
async (rq: IStcsSearchRq, thunkAPI) => { |
|
|
|
|
const { rejectWithValue } = thunkAPI; |
|
|
|
|
try { |
|
|
|
|
const { type } = rq; |
|
|
|
|
const params = {}; |
|
|
|
@ -83,14 +121,24 @@ export const getAbnormalSearch = createAsyncThunk(
|
|
|
|
|
); |
|
|
|
|
return res.data; |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error(error); |
|
|
|
|
thunkAPI.dispatch( |
|
|
|
|
isError({ |
|
|
|
|
errorCode: ERROR_MESSAGE.code, |
|
|
|
|
errorMessage: ERROR_MESSAGE.message, |
|
|
|
|
isHistoryBack: false, |
|
|
|
|
isRefresh: false |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
return rejectWithValue(error); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 비행 실적 통계(비행실적,비행계획,비행승인)
|
|
|
|
|
export const getResultStatistics = createAsyncThunk( |
|
|
|
|
'statistics/getResultStatistics', |
|
|
|
|
async (rq: IStcsRq, thunkAPI) => { |
|
|
|
|
const { rejectWithValue } = thunkAPI; |
|
|
|
|
try { |
|
|
|
|
const { serviceType } = rq; |
|
|
|
|
const res = await axios.get( |
|
|
|
@ -100,14 +148,24 @@ export const getResultStatistics = createAsyncThunk(
|
|
|
|
|
); |
|
|
|
|
return res.data; |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error(error); |
|
|
|
|
thunkAPI.dispatch( |
|
|
|
|
isError({ |
|
|
|
|
errorCode: ERROR_MESSAGE.code, |
|
|
|
|
errorMessage: ERROR_MESSAGE.message, |
|
|
|
|
isHistoryBack: false, |
|
|
|
|
isRefresh: false |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
return rejectWithValue(error); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
//비행 실적 통계(비행 실적 통계, 비행 실적 TOP5)
|
|
|
|
|
export const getResultSearch = createAsyncThunk( |
|
|
|
|
'statistics/getResultSearch', |
|
|
|
|
async (rq: IStcsSearchRq, thunkAPI) => { |
|
|
|
|
const { rejectWithValue } = thunkAPI; |
|
|
|
|
try { |
|
|
|
|
const { type } = rq; |
|
|
|
|
const params = {}; |
|
|
|
@ -125,7 +183,15 @@ export const getResultSearch = createAsyncThunk(
|
|
|
|
|
); |
|
|
|
|
return res.data; |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error(error); |
|
|
|
|
thunkAPI.dispatch( |
|
|
|
|
isError({ |
|
|
|
|
errorCode: ERROR_MESSAGE.code, |
|
|
|
|
errorMessage: ERROR_MESSAGE.message, |
|
|
|
|
isHistoryBack: false, |
|
|
|
|
isRefresh: false |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
return rejectWithValue(error); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|