박상현
8 months ago
37 changed files with 378 additions and 97 deletions
@ -1,4 +1,5 @@
|
||||
export * from './actions/analysisHistoryAction'; |
||||
export * from './models/analysisHitoryModel'; |
||||
export * from './reducers/analysisHitoryReducer'; |
||||
export * from './sagas/analysisHistorySaga'; |
||||
export * from './actions'; |
||||
export * from './apis'; |
||||
export * from './models'; |
||||
export * from './reducers'; |
||||
export * from './sagas'; |
||||
|
@ -1,13 +1,11 @@
|
||||
import { createReducer } from 'typesafe-actions'; |
||||
import produce from 'immer'; |
||||
|
||||
import * as Actions from '../actions/analysisHistoryAction'; |
||||
import * as Actions from '../actions'; |
||||
import { |
||||
initResponseAnalysisHistoryData, |
||||
AnalysisHistoryData, |
||||
AnalysisHistoryState |
||||
} from '../models/analysisHitoryModel'; |
||||
import { controlGpSaga } from '../../../control/gp'; |
||||
} from '../models'; |
||||
|
||||
export const analysisHistoryReducer = createReducer< |
||||
AnalysisHistoryState, |
@ -0,0 +1,67 @@
|
||||
import { AxiosError } from 'axios'; |
||||
import { ActionType, createAction, createAsyncAction } from 'typesafe-actions'; |
||||
import { |
||||
AnalysisSimulatorData, |
||||
AnalysisSimulatorLogData, |
||||
AnalysisSimulatorState, |
||||
AnalysisSimulatorStcsData |
||||
} from '../models'; |
||||
|
||||
// 시뮬레이션 목록
|
||||
const LIST_REQUEST = 'anls/smlt/LIST_REQUEST'; |
||||
const LIST_SUCCESS = 'anls/smlt/LIST_SUCCESS'; |
||||
const LIST_FAILURE = 'anls/smlt/LIST_FAILURE'; |
||||
|
||||
// 시뮬레이션 상세 로그 목록
|
||||
const LOG_REQUEST = 'anls/smlt/LOG_REQUEST'; |
||||
const LOG_SUCCESS = 'anls/smlt/LOG_SUCCESS'; |
||||
const LOG_FAILURE = 'anls/smlt/LOG_FAILURE'; |
||||
|
||||
// 시뮬레이션 상세 정보
|
||||
const DETAIL_REQUEST = 'anls/smlt/DETAIL_REQUEST'; |
||||
const DETAIL_SUCCESS = 'anls/smlt/DETAIL_SUCCESS'; |
||||
const DETAIL_FAILURE = 'anls/smlt/DETAIL_FAILURE'; |
||||
|
||||
// 시뮬레이션 분 단위 통계 정보
|
||||
const STATICS_REQUEST = 'anls/smlt/STATICS_REQUEST'; |
||||
const STATICS_SUCCESS = 'anls/smlt/STATICS_SUCCESS'; |
||||
const STATICS_FAILURE = 'anls/smlt/STATICS_FAILURE'; |
||||
|
||||
const DISPATCH_SEARCH = 'anls/smlt/DISPATCH_SEARCH'; |
||||
|
||||
export const dispatchSearch = |
||||
createAction(DISPATCH_SEARCH)<{ searchParams: string }>(); |
||||
|
||||
export const list = createAsyncAction(LIST_REQUEST, LIST_SUCCESS, LIST_FAILURE)< |
||||
AnalysisSimulatorState, |
||||
{ data: AnalysisSimulatorData[]; count: number; total: number; page: number }, |
||||
AxiosError |
||||
>(); |
||||
|
||||
export const log = createAsyncAction(LOG_REQUEST, LOG_SUCCESS, LOG_FAILURE)< |
||||
string, |
||||
{ log: AnalysisSimulatorLogData[] }, |
||||
AxiosError |
||||
>(); |
||||
|
||||
export const detail = createAsyncAction( |
||||
DETAIL_REQUEST, |
||||
DETAIL_SUCCESS, |
||||
DETAIL_FAILURE |
||||
)<string, { data: AnalysisSimulatorData }, AxiosError>(); |
||||
|
||||
export const stcs = createAsyncAction( |
||||
STATICS_REQUEST, |
||||
STATICS_SUCCESS, |
||||
STATICS_FAILURE |
||||
)<string, { data: AnalysisSimulatorStcsData[]; count: number }, AxiosError>(); |
||||
|
||||
const actions = { |
||||
list, |
||||
detail, |
||||
log, |
||||
stcs, |
||||
dispatchSearch |
||||
}; |
||||
|
||||
export type AnalysisSimulatorAction = ActionType<typeof actions>; |
@ -0,0 +1,28 @@
|
||||
import qs from 'qs'; |
||||
import axios from '../../../utils/customAxiosUtil'; |
||||
|
||||
export const analysisSimulator = { |
||||
//비행 현황 목록
|
||||
list: async (data: string, page: number) => { |
||||
const queryString = qs.stringify(data, { |
||||
addQueryPrefix: true, |
||||
arrayFormat: 'repeat' |
||||
}); |
||||
|
||||
return await axios.get(`/api/anls/smlt/list${queryString}&page=${page}`); |
||||
}, |
||||
// 비행 이력 데이터 조회
|
||||
logList: async (id: string) => { |
||||
return await axios.get(`/api/anls/smlt/hist/${id}`); |
||||
}, |
||||
|
||||
//비행 상세 데이터 조회
|
||||
detail: async (id: string) => { |
||||
return await axios.get(`/api/anls/smlt/detail/${id}`); |
||||
}, |
||||
|
||||
//비행 통계 데이터 조회
|
||||
stcsList: async (id: string) => { |
||||
return await axios.get(`/api/anls/smlt/stcs/${id}`); |
||||
} |
||||
}; |
@ -1,4 +1,5 @@
|
||||
export * from './actions/analysisSimulatorAction'; |
||||
export * from './models/analysisSimulatorModel'; |
||||
export * from './reducers/analysisSimulatorReducer'; |
||||
export * from './sagas/analysisSimulatorSaga'; |
||||
export * from './actions'; |
||||
export * from './apis'; |
||||
export * from './models'; |
||||
export * from './reducers'; |
||||
export * from './sagas'; |
||||
|
@ -0,0 +1,78 @@
|
||||
export interface AnalysisSimulatorState { |
||||
list: AnalysisSimulatorData[] | undefined; |
||||
detail: AnalysisSimulatorData | undefined; |
||||
count: number | 0; |
||||
log: AnalysisSimulatorLogData[] | undefined; |
||||
searchParams: string; |
||||
stcsList: AnalysisSimulatorStcsData[] | undefined; |
||||
stcsCount: number | 0; |
||||
page: number | 1; |
||||
total: number | 0; |
||||
} |
||||
|
||||
export interface AnalysisSimulatorData { |
||||
cntrlId: string; |
||||
idntfNum: string; |
||||
flghtStDt: Date; |
||||
flghtEndDt: Date; |
||||
cntrlStDt: Date; |
||||
cntrlEndDt: Date; |
||||
ttlTime: number; |
||||
ttlTimeType: string; |
||||
ttlDstnc: number; |
||||
ttlDstncType: string; |
||||
avrgSpeed: number; |
||||
avrgSpeedType: string; |
||||
bttrCnsmptn: number; |
||||
stArea: string; |
||||
endArea: string; |
||||
arcrftTypeCd: string; |
||||
prdctNum: string; |
||||
arcrftModelNm: string; |
||||
imageUrl: string; |
||||
} |
||||
|
||||
export interface AnalysisSimulatorLogData { |
||||
hstrySno: number; |
||||
cntrlId: string; |
||||
trmnlId: string; |
||||
mssgTypeCd: string; |
||||
statusCd: string; |
||||
lat: number; |
||||
lon: number; |
||||
speed: number; |
||||
speedType: string; |
||||
heading: number; |
||||
elev: number; |
||||
elevType: string; |
||||
mvDstnc: number; |
||||
bttrLvl: number; |
||||
bttrVltg: number; |
||||
trmnlRcvDt: string; |
||||
srvrRcvDt: string; |
||||
} |
||||
|
||||
export interface AnalysisSimulatorStcsData { |
||||
dateCd: string; |
||||
timeCd: string; |
||||
avrgSpeed: number; |
||||
speedType: string; |
||||
avrgElev: number; |
||||
elevType: string; |
||||
avrgMvDstnc: number; |
||||
mvDstncType: string; |
||||
minBttrLvl: number; |
||||
maxBttrLvl: number; |
||||
} |
||||
|
||||
export const initialState: AnalysisSimulatorState = { |
||||
list: undefined, |
||||
detail: undefined, |
||||
count: 0, |
||||
log: undefined, |
||||
searchParams: '', |
||||
stcsList: undefined, |
||||
stcsCount: 0, |
||||
page: 1, |
||||
total: 0 |
||||
}; |
@ -0,0 +1,59 @@
|
||||
import produce from 'immer'; |
||||
import { createReducer } from 'typesafe-actions'; |
||||
import * as Actions from '../actions'; |
||||
import { AnalysisSimulatorState, initialState } from '../models'; |
||||
|
||||
export const analysisSimulatorReducer = createReducer< |
||||
AnalysisSimulatorState, |
||||
Actions.AnalysisSimulatorAction |
||||
>(initialState) |
||||
.handleAction(Actions.dispatchSearch, (state, action) => |
||||
produce(state, draft => { |
||||
const { searchParams } = action.payload; |
||||
draft.searchParams = searchParams; |
||||
}) |
||||
) |
||||
.handleAction(Actions.list.success, (state, action) => |
||||
produce(state, draft => { |
||||
const { data, count, total, page } = action.payload; |
||||
if (!state.list) { |
||||
draft.list = data; |
||||
} else { |
||||
if (page === 1) { |
||||
draft.list = data; |
||||
draft.page = page; |
||||
return; |
||||
} |
||||
draft.list = state.list?.concat(data); |
||||
} |
||||
|
||||
draft.page = page; |
||||
draft.count = count; |
||||
draft.total = total; |
||||
}) |
||||
) |
||||
.handleAction(Actions.detail.success, (state, action) => |
||||
produce(state, draft => { |
||||
const { data } = action.payload; |
||||
draft.detail = data; |
||||
}) |
||||
) |
||||
.handleAction(Actions.stcs.success, (state, action) => |
||||
produce(state, draft => { |
||||
const { data, count } = action.payload; |
||||
draft.stcsList = data; |
||||
draft.stcsCount = count; |
||||
}) |
||||
) |
||||
|
||||
.handleAction(Actions.log.success, (state, action) => |
||||
produce(state, draft => { |
||||
const { log } = action.payload; |
||||
const data = log.sort((p: any, n: any): any => { |
||||
const a = p.srvrRcvDt.replace(/[^0-9\.]+/g, ''); |
||||
const b = n.srvrRcvDt.replace(/[^0-9\.]+/g, ''); |
||||
return a - b; |
||||
}); |
||||
draft.log = log; |
||||
}) |
||||
); |
@ -0,0 +1,82 @@
|
||||
import { call, put, takeEvery } from '@redux-saga/core/effects'; |
||||
import { ActionType } from 'typesafe-actions'; |
||||
import * as Actions from '../actions'; |
||||
import * as Apis from '../apis'; |
||||
|
||||
function* listSaga(action: ActionType<typeof Actions.list.request>) { |
||||
try { |
||||
const { searchParams, page } = action.payload; |
||||
const res = yield call(Apis.analysisSimulator.list, searchParams, page); |
||||
const { |
||||
data: { items, total }, |
||||
count |
||||
} = res; |
||||
|
||||
yield put( |
||||
Actions.list.success({ |
||||
data: items, |
||||
count: count, |
||||
total, |
||||
page: res.data.page |
||||
}) |
||||
); |
||||
} catch (error: any) { |
||||
yield put(Actions.list.failure(error)); |
||||
} |
||||
} |
||||
|
||||
function* detailSaga(action: ActionType<typeof Actions.detail.request>) { |
||||
try { |
||||
const id = action.payload; |
||||
const res = yield call(Apis.analysisSimulator.detail, id); |
||||
// yield put(Actions.log.request(id));
|
||||
const { data } = res; |
||||
yield put( |
||||
Actions.detail.success({ |
||||
data: data |
||||
}) |
||||
); |
||||
} catch (error: any) { |
||||
yield put(Actions.detail.failure(error)); |
||||
} |
||||
} |
||||
|
||||
function* stcsSaga(action: ActionType<typeof Actions.stcs.request>) { |
||||
try { |
||||
const id = action.payload; |
||||
const res = yield call(Apis.analysisSimulator.stcsList, id); |
||||
// yield put(Actions.log.request(id));
|
||||
const { data, count } = res; |
||||
yield put( |
||||
Actions.stcs.success({ |
||||
data: data, |
||||
count: count |
||||
}) |
||||
); |
||||
} catch (error: any) { |
||||
yield put(Actions.detail.failure(error)); |
||||
} |
||||
} |
||||
|
||||
function* logSaga(action: ActionType<typeof Actions.log.request>) { |
||||
try { |
||||
const id = action.payload; |
||||
const res = yield call(Apis.analysisSimulator.logList, id); |
||||
const { data } = res; |
||||
|
||||
yield put( |
||||
Actions.log.success({ |
||||
log: data |
||||
}) |
||||
); |
||||
} catch (error: any) { |
||||
yield put(Actions.log.failure(error)); |
||||
} |
||||
} |
||||
|
||||
export function* analysisSimulatorSaga() { |
||||
yield takeEvery(Actions.list.request, listSaga); |
||||
yield takeEvery(Actions.detail.request, detailSaga); |
||||
yield takeEvery(Actions.stcs.request, stcsSaga); |
||||
yield takeEvery(Actions.log.request, logSaga); |
||||
} |
Loading…
Reference in new issue