Browse Source

[Redux] /analysis 작업중

master
junh_eee(이준희) 8 months ago
parent
commit
bdd36daec5
  1. 2
      src/components/analysis/history/AnalysisHistoryDetailSearch.js
  2. 11
      src/containers/analysis/history/AnalysisHistoryContainer.js
  3. 2
      src/containers/analysis/history/AnalysisHistoryDetailContainer.js
  4. 13
      src/containers/analysis/simulator/AnalysisSimulationContainer.js
  5. 2
      src/modules/NAMING.md
  6. 80
      src/modules/analysis/history/actions/index.ts
  7. 13
      src/modules/analysis/history/apis/index.ts
  8. 81
      src/modules/analysis/history/models/index.ts
  9. 29
      src/modules/analysis/history/reducers/index.ts
  10. 46
      src/modules/analysis/history/sagas/index.ts
  11. 67
      src/modules/analysis/simulation/actions/analysisSimulatorAction.ts
  12. 75
      src/modules/analysis/simulation/actions/index.ts
  13. 28
      src/modules/analysis/simulation/apis/annalysisSimulatorApi.ts
  14. 8
      src/modules/analysis/simulation/apis/index.ts
  15. 78
      src/modules/analysis/simulation/models/analysisSimulatorModel.ts
  16. 59
      src/modules/analysis/simulation/reducers/analysisSimulatorReducer.ts
  17. 10
      src/modules/analysis/simulation/reducers/index.ts
  18. 82
      src/modules/analysis/simulation/sagas/analysisSimulatorSaga.ts
  19. 48
      src/modules/analysis/simulation/sagas/index.ts
  20. 1
      src/modules/basis/drone/apis/index.ts

2
src/components/analysis/history/AnalysisHistoryDetailSearch.js

@ -7,7 +7,7 @@ export const AnalysisHistoryDetailSearch = props => {
// const { log } = useSelector(state => state.analysisHistoryState);
// const dispatch = useDispatch();
// useEffect(() => {
// dispatch(Actions.detail.request(props.id));
// dispatch(Actions.getHstryDetail.request(props.id));
// }, []);
return (
<div className='pal-card-box'>

11
src/containers/analysis/history/AnalysisHistoryContainer.js

@ -113,9 +113,12 @@ export const AnalysisHistoryContainer = props => {
sessionStorage.setItem('cstmrSno', user.cstmrSno);
setParams(prevState => ({ ...prevState, groupId }));
dispatch(Actions.LIST_INITAL());
dispatch(Actions.clientSelectHstryGroup());
dispatch(
Actions.list.request({ searchParams: { ...params, groupId }, page: 1 })
Actions.getHstryList.request({
searchParams: { ...params, groupId },
page: 1
})
);
};
@ -221,7 +224,7 @@ export const AnalysisHistoryContainer = props => {
});
} else {
dispatch(LaancAction.clientRoupSelect({ ...params }));
dispatch(Actions.list.request({ searchParams: params, page: 1 }));
dispatch(Actions.getHstryList.request({ searchParams: params, page: 1 }));
}
};
@ -252,7 +255,7 @@ export const AnalysisHistoryContainer = props => {
// 페이지 이동 handler
const handlerPageChange = page => {
dispatch(Actions.list.request({ searchParams: params, page }));
dispatch(Actions.getHstryList.request({ searchParams: params, page }));
};
return (

2
src/containers/analysis/history/AnalysisHistoryDetailContainer.js

@ -22,7 +22,7 @@ export const AnalysisHistoryDetailContainer = () => {
// 비행이력 목록 불러오는 handler
const handlerSearch = () => {
dispatch(Actions.detail.request(id));
dispatch(Actions.getHstryDetail.request(id));
};
const excelHeaders = [

13
src/containers/analysis/simulator/AnalysisSimulationContainer.js

@ -190,7 +190,7 @@ export const AnalysisSimulationContainer = props => {
const handlerSearch = search1 => {
setParams({ ...params, search1 });
dispatch(
SmltActions.list.request({
SmltActions.getSmltList.request({
searchParams: { ...params, search1 },
page: 1
})
@ -198,16 +198,16 @@ export const AnalysisSimulationContainer = props => {
};
const handlerDetailSearch = id => {
dispatch(SmltActions.detail.request(id));
dispatch(SmltActions.getSmltDetail.request(id));
};
const handlerLogSearch = id => {
dispatch(SmltActions.log.request(id));
dispatch(SmltActions.getSmltLog.request(id));
};
//
const handlerStcsSearch = id => {
dispatch(SmltActions.stcs.request(id));
dispatch(SmltActions.getSmltStcs.request(id));
};
// 검색
@ -250,7 +250,10 @@ export const AnalysisSimulationContainer = props => {
// 비행 시물레이션 데이터 호출
const handlerPageList = useCallback(() => {
dispatch(
SmltActions.list.request({ searchParams: { ...params }, page: page + 1 })
SmltActions.getSmltList.request({
searchParams: { ...params },
page: page + 1
})
);
}, [params, list, page]);

2
src/modules/NAMING.md

@ -9,6 +9,8 @@
┃ ┣ 📂 reducers Reducer 함수
┃ ┣ 📂 sagas Saga 함수
┃ ┣ 📜 index.ts
// 폴더에는 index.ts 파일 하나만 작성한다.
```
<br>

80
src/modules/analysis/history/actions/index.ts

@ -1,60 +1,66 @@
import { AxiosError } from 'axios';
import { createAsyncAction, ActionType, createAction } from 'typesafe-actions';
import {
AnalysisHistoryData,
AnalysisHistoryLogData,
AnalysisHistoryState
IGetHstryDetailRs,
IGetHstryListRs,
IGetHstryLogRs,
IHistoryState
} from '../models';
// 비행 이력 현황 목록
const LIST_REQUEST = 'anls/hstry/LIST_REQUEST';
const LIST_SUCCESS = 'anls/hstry/LIST_SUCCESS';
const LIST_FAILURE = 'anls/hstry/LIST_FAILURE';
const GET_HSTRY_LIST_REQUEST = 'anls/hstry/GET_HSTRY_LIST_REQUEST';
const GET_HSTRY_LIST_SUCCESS = 'anls/hstry/GET_HSTRY_LIST_SUCCESS';
const GET_HSTRY_LIST_FAILURE = 'anls/hstry/GET_HSTRY_LIST_FAILURE';
// 비행 이력 로그
const LOG_REQUEST = 'anls/hstry/LOG_REQUEST';
const LOG_SUCCESS = 'anls/hstry/LOG_SUCCESS';
const LOG_FAILURE = 'anls/hstry/LOG_FAILURE';
const GET_HSTRY_LOG_REQUEST = 'anls/hstry/GET_HSTRY_LOG_REQUEST';
const GET_HSTRY_LOG_SUCCESS = 'anls/hstry/GET_HSTRY_LOG_SUCCESS';
const GET_HSTRY_LOG_FAILURE = 'anls/hstry/GET_HSTRY_LOG_FAILURE';
// 비행 이력 상세
const DETAIL_REQUEST = 'anls/hstry/DETAIL_REQUEST';
const DETAIL_SUCCESS = 'anls/hstry/DETAIL_SUCCESS';
const DETAIL_FAILURE = 'anls/hstry/DETAIL_FAILURE';
const GET_HSTRY_DETAIL_REQUEST = 'anls/hstry/GET_HSTRY_DETAIL_REQUEST';
const GET_HSTRY_DETAIL_SUCCESS = 'anls/hstry/GET_HSTRY_DETAIL_SUCCESS';
const GET_HSTRY_DETAIL_FAILURE = 'anls/hstry/GET_HSTRY_DETAIL_FAILURE';
// 검색
const DISPATCH_SEARCH = 'anls/hstry/DISPATCH_SEARCH';
// 검색 조건 저장
const CLIENT_SEARCH_PARAM = 'anls/hstry/CLIENT_SEARCH_PARAM';
const LIST_INIT = 'anls/hstry/LIST_INIT';
// 그룹 선택 시 검색 데이터 저장
const CLIENT_SELECT_HSTRY_GROUP = 'anls/hstry/CLIENT_SELECT_HSTRY_GROUP';
export const dispatchSearch =
createAction(DISPATCH_SEARCH)<{ searchParams: string }>();
export const list = createAsyncAction(LIST_REQUEST, LIST_SUCCESS, LIST_FAILURE)<
AnalysisHistoryState,
{ data: AnalysisHistoryData[]; count: number; total: number },
export const getHstryList = createAsyncAction(
GET_HSTRY_LIST_REQUEST,
GET_HSTRY_LIST_SUCCESS,
GET_HSTRY_LIST_FAILURE
)<
IHistoryState,
{ data: IGetHstryListRs[]; count: number; total: number },
AxiosError
>();
export const log = createAsyncAction(LOG_REQUEST, LOG_SUCCESS, LOG_FAILURE)<
string,
{ log: AnalysisHistoryLogData[] },
AxiosError
>();
export const getHstryLog = createAsyncAction(
GET_HSTRY_LOG_REQUEST,
GET_HSTRY_LOG_SUCCESS,
GET_HSTRY_LOG_FAILURE
)<string, { log: IGetHstryLogRs[] }, AxiosError>();
export const getHstryDetail = createAsyncAction(
GET_HSTRY_DETAIL_REQUEST,
GET_HSTRY_DETAIL_SUCCESS,
GET_HSTRY_DETAIL_FAILURE
)<string, { detail: IGetHstryDetailRs }, AxiosError>();
export const detail = createAsyncAction(
DETAIL_REQUEST,
DETAIL_SUCCESS,
DETAIL_FAILURE
)<string, { detail: AnalysisHistoryData }, AxiosError>();
export const clientSearchParam =
createAction(CLIENT_SEARCH_PARAM)<{ searchParams: string }>();
export const LIST_INITAL = createAction(LIST_INIT)();
export const clientSelectHstryGroup = createAction(CLIENT_SELECT_HSTRY_GROUP)();
const actions = {
list,
detail,
log,
dispatchSearch,
LIST_INITAL
getHstryList,
getHstryLog,
getHstryDetail,
clientSearchParam,
clientSelectHstryGroup
};
export type AnalysisHistoryAction = ActionType<typeof actions>;

13
src/modules/analysis/history/apis/index.ts

@ -1,8 +1,8 @@
import axios from '../../../utils/customAxiosUtil';
import qs from 'qs';
export const analysisHistory = {
list: async (data: string, page: number) => {
export const historyAPI = {
getHstryList: async (data: string, page: number) => {
const queryString = qs.stringify(data, {
addQueryPrefix: true,
arrayFormat: 'repeat'
@ -10,11 +10,10 @@ export const analysisHistory = {
return await axios.get(`/api/anls/hstry/list${queryString}&page=${page}`);
},
detail: async (id: string) => {
return await axios.get(`/api/anls/hstry/detail/${id}`);
},
log: async (id: string) => {
getHstryLog: async (id: string) => {
return await axios.get(`/api/anls/hstry/log/${id}`);
},
getHstryDetail: async (id: string) => {
return await axios.get(`/api/anls/hstry/detail/${id}`);
}
};

81
src/modules/analysis/history/models/index.ts

@ -1,7 +1,20 @@
export interface AnalysisHistoryState {
data: AnalysisHistoryData[] | undefined;
detail: AnalysisHistoryData | undefined;
log: AnalysisHistoryLogData[] | undefined;
export const initHistory: IHistoryState = {
data: undefined,
detail: undefined,
log: undefined,
count: 0,
searchParams: '',
arrSpeed: undefined,
arrElev: undefined,
page: 1,
total: 0,
id: undefined
};
export interface IHistoryState {
data: IGetHstryListRs[] | undefined;
detail: IGetHstryDetailRs | undefined;
log: IGetHstryLogRs[] | undefined;
count: number | 0;
searchParams: string;
arrSpeed: number[] | undefined;
@ -11,37 +24,45 @@ export interface AnalysisHistoryState {
id: string | undefined;
}
export interface AnalysisHistoryDetailState {
analysisHistoryDetail: AnalysisHistoryData | undefined;
export interface IGetHstryListRs {
cntrlId: string;
idntfNum: string;
cntrlStDt: Date;
cntrlEndDt: Date;
ttlTime: number;
ttlDstnc: number;
avrgSpeed: number;
bttrCnsmptn: number;
area1: string;
area2: string;
area3: string;
landNm?: string;
landNum: string;
stArea: string;
}
export interface AnalysisHistoryData {
export interface IGetHstryDetailRs {
cntrlId: string;
idntfNum: string;
statusCd: string;
objectTypeCd: string;
flghtStDt: string;
flghtEndDt: string;
cntrlStDt: Date;
cntrlEndDt: string;
cntrlEndDt: Date;
ttlTime: number;
ttlTimeType: string;
ttlDstnc: number;
ttlDstncType: string;
avrgSpeed: number;
avrgSpeedType: string;
avrgSpped: number;
bttrCnsmptn: number;
stArea: string;
endArea: string;
createDt: string;
updateDt: string;
endTypeCd: string;
createDt: Date;
updateDt: Date;
}
export interface AnalysisHistoryLogData {
export interface IGetHstryLogRs {
hstrySno: number;
cntrlId: string;
idntfNum: string;
trmnlId: string;
mssgTypeCd: string;
statusCd: string;
lat: number;
@ -54,24 +75,6 @@ export interface AnalysisHistoryLogData {
mvDstnc: number;
bttrLvl: number;
bttrVltg: number;
trmnlRcvDt: string;
srvrRcvDt: string;
trmnlRcvDt: Date;
srvrRcvDt: Date;
}
export interface ReponseAnalysisHistoryData {
data: AnalysisHistoryData[];
count: number;
}
export const initResponseAnalysisHistoryData: AnalysisHistoryState = {
data: undefined,
detail: undefined,
log: undefined,
count: 0,
searchParams: '',
arrSpeed: undefined,
arrElev: undefined,
page: 1,
total: 0,
id: undefined
};

29
src/modules/analysis/history/reducers/index.ts

@ -2,29 +2,26 @@ import { createReducer } from 'typesafe-actions';
import produce from 'immer';
import * as Actions from '../actions';
import {
initResponseAnalysisHistoryData,
AnalysisHistoryState
} from '../models';
import { initHistory, IHistoryState } from '../models';
export const analysisHistoryReducer = createReducer<
AnalysisHistoryState,
export const historyReducer = createReducer<
IHistoryState,
Actions.AnalysisHistoryAction
>(initResponseAnalysisHistoryData)
.handleAction(Actions.dispatchSearch, (state, action) =>
>(initHistory)
.handleAction(Actions.clientSearchParam, (state, action) =>
produce(state, draft => {
const { searchParams } = action.payload;
draft.searchParams = searchParams;
})
)
.handleAction(Actions.list.request, (state, action) =>
.handleAction(Actions.getHstryList.request, (state, action) =>
produce(state, draft => {
const { searchParams, page } = action.payload;
draft.searchParams = searchParams;
draft.page = page;
})
)
.handleAction(Actions.list.success, (state, action) =>
.handleAction(Actions.getHstryList.success, (state, action) =>
produce(state, draft => {
const { data, count, total } = action.payload;
@ -33,22 +30,22 @@ export const analysisHistoryReducer = createReducer<
draft.total = total;
})
)
.handleAction(Actions.detail.success, (state, action) =>
.handleAction(Actions.getHstryDetail.success, (state, action) =>
produce(state, draft => {
const { detail } = action.payload;
draft.detail = detail;
})
)
.handleAction(Actions.log.success, (state, action) =>
.handleAction(Actions.getHstryLog.success, (state, action) =>
produce(state, draft => {
const { log } = action.payload;
draft.log = log;
})
)
.handleAction(Actions.LIST_INITAL, (state, action) =>
.handleAction(Actions.clientSelectHstryGroup, (state, action) =>
produce(state, draft => {
draft.data = initResponseAnalysisHistoryData.data;
draft.count = initResponseAnalysisHistoryData.count;
draft.total = initResponseAnalysisHistoryData.total;
draft.data = initHistory.data;
draft.count = initHistory.count;
draft.total = initHistory.total;
})
);

46
src/modules/analysis/history/sagas/index.ts

@ -2,64 +2,70 @@ import { call, put, takeEvery } from '@redux-saga/core/effects';
import { ActionType } from 'typesafe-actions';
import * as Actions from '../actions';
import * as Apis from '../apis';
import { historyAPI } from '../apis';
function* listSaga(action: ActionType<typeof Actions.list.request>) {
function* getHstryListSaga(
action: ActionType<typeof Actions.getHstryList.request>
) {
try {
const { searchParams, page } = action.payload;
const res = yield call(Apis.analysisHistory.list, searchParams, page);
const res = yield call(historyAPI.getHstryList, searchParams, page);
const {
data: { items, total },
count
} = res;
yield put(
Actions.list.success({
Actions.getHstryList.success({
data: items,
count,
total
})
);
} catch (error: any) {
yield put(Actions.list.failure(error));
yield put(Actions.getHstryList.failure(error));
}
}
function* detailSaga(action: ActionType<typeof Actions.detail.request>) {
function* getHstryLogSaga(
action: ActionType<typeof Actions.getHstryLog.request>
) {
try {
const id = action.payload;
const res = yield call(Apis.analysisHistory.detail, id);
yield put(Actions.log.request(id));
const res = yield call(historyAPI.getHstryLog, id);
const { data } = res;
yield put(
Actions.detail.success({
detail: data
Actions.getHstryLog.success({
log: data
})
);
} catch (error: any) {
yield put(Actions.detail.failure(error));
yield put(Actions.getHstryLog.failure(error));
}
}
function* logSaga(action: ActionType<typeof Actions.log.request>) {
function* getHstryDetailSaga(
action: ActionType<typeof Actions.getHstryDetail.request>
) {
try {
const id = action.payload;
const res = yield call(Apis.analysisHistory.log, id);
const res = yield call(historyAPI.getHstryDetail, id);
yield put(Actions.getHstryLog.request(id));
const { data } = res;
yield put(
Actions.log.success({
log: data
Actions.getHstryDetail.success({
detail: data
})
);
} catch (error: any) {
yield put(Actions.log.failure(error));
yield put(Actions.getHstryDetail.failure(error));
}
}
export function* analysisHistorySaga() {
yield takeEvery(Actions.list.request, listSaga);
yield takeEvery(Actions.detail.request, detailSaga);
yield takeEvery(Actions.log.request, logSaga);
yield takeEvery(Actions.getHstryList.request, getHstryListSaga);
yield takeEvery(Actions.getHstryDetail.request, getHstryDetailSaga);
yield takeEvery(Actions.getHstryLog.request, getHstryLogSaga);
}

67
src/modules/analysis/simulation/actions/analysisSimulatorAction.ts

@ -1,67 +0,0 @@
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>;

75
src/modules/analysis/simulation/actions/index.ts

@ -8,60 +8,65 @@ import {
} from '../models';
// 시뮬레이션 목록
const LIST_REQUEST = 'anls/smlt/LIST_REQUEST';
const LIST_SUCCESS = 'anls/smlt/LIST_SUCCESS';
const LIST_FAILURE = 'anls/smlt/LIST_FAILURE';
const GET_SMLT_LIST_REQUEST = 'anls/smlt/GET_SMLT_LIST_REQUEST';
const GET_SMLT_LIST_SUCCESS = 'anls/smlt/GET_SMLT_LIST_SUCCESS';
const GET_SMLT_LIST_FAILURE = 'anls/smlt/GET_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 GET_SMLT_LOG_REQUEST = 'anls/smlt/GET_SMLT_LOG_REQUEST';
const GET_SMLT_LOG_SUCCESS = 'anls/smlt/GET_SMLT_LOG_SUCCESS';
const GET_SMLT_LOG_FAILURE = 'anls/smlt/GET_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 GET_SMLT_DETAIL_REQUEST = 'anls/smlt/GET_SMLT_DETAIL_REQUEST';
const GET_SMLT_DETAIL_SUCCESS = 'anls/smlt/GET_SMLT_DETAIL_SUCCESS';
const GET_SMLT_DETAIL_FAILURE = 'anls/smlt/GET_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 GET_SMLT_STCS_REQUEST = 'anls/smlt/GET_SMLT_STCS_REQUEST';
const GET_SMLT_STCS_SUCCESS = 'anls/smlt/GET_SMLT_STCS_SUCCESS';
const GET_SMLT_STCS_FAILURE = 'anls/smlt/GET_SMLT_STCS_FAILURE';
const DISPATCH_SEARCH = 'anls/smlt/DISPATCH_SEARCH';
// 검색 조건 저장
const CLIENT_SEARCH_PARAM = 'anls/smlt/CLIENT_SEARCH_PARAM';
export const dispatchSearch =
createAction(DISPATCH_SEARCH)<{ searchParams: string }>();
export const list = createAsyncAction(LIST_REQUEST, LIST_SUCCESS, LIST_FAILURE)<
export const getSmltList = createAsyncAction(
GET_SMLT_LIST_REQUEST,
GET_SMLT_LIST_SUCCESS,
GET_SMLT_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 getSmltLog = createAsyncAction(
GET_SMLT_LOG_REQUEST,
GET_SMLT_LOG_SUCCESS,
GET_SMLT_LOG_FAILURE
)<string, { log: AnalysisSimulatorLogData[] }, AxiosError>();
export const detail = createAsyncAction(
DETAIL_REQUEST,
DETAIL_SUCCESS,
DETAIL_FAILURE
export const getSmltDetail = createAsyncAction(
GET_SMLT_DETAIL_REQUEST,
GET_SMLT_DETAIL_SUCCESS,
GET_SMLT_DETAIL_FAILURE
)<string, { data: AnalysisSimulatorData }, AxiosError>();
export const stcs = createAsyncAction(
STATICS_REQUEST,
STATICS_SUCCESS,
STATICS_FAILURE
export const getSmltStcs = createAsyncAction(
GET_SMLT_STCS_REQUEST,
GET_SMLT_STCS_SUCCESS,
GET_SMLT_STCS_FAILURE
)<string, { data: AnalysisSimulatorStcsData[]; count: number }, AxiosError>();
export const clientSearchParam =
createAction(CLIENT_SEARCH_PARAM)<{ searchParams: string }>();
const actions = {
list,
detail,
log,
stcs,
dispatchSearch
getSmltList,
getSmltDetail,
getSmltLog,
getSmltStcs,
clientSearchParam
};
export type AnalysisSimulatorAction = ActionType<typeof actions>;

28
src/modules/analysis/simulation/apis/annalysisSimulatorApi.ts

@ -1,28 +0,0 @@
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}`);
}
};

8
src/modules/analysis/simulation/apis/index.ts

@ -3,7 +3,7 @@ import axios from '../../../utils/customAxiosUtil';
export const analysisSimulator = {
//비행 현황 목록
list: async (data: string, page: number) => {
getSmltList: async (data: string, page: number) => {
const queryString = qs.stringify(data, {
addQueryPrefix: true,
arrayFormat: 'repeat'
@ -12,17 +12,17 @@ export const analysisSimulator = {
return await axios.get(`/api/anls/smlt/list${queryString}&page=${page}`);
},
// 비행 이력 데이터 조회
logList: async (id: string) => {
getSmltLog: async (id: string) => {
return await axios.get(`/api/anls/smlt/hist/${id}`);
},
//비행 상세 데이터 조회
detail: async (id: string) => {
getSmltDetail: async (id: string) => {
return await axios.get(`/api/anls/smlt/detail/${id}`);
},
//비행 통계 데이터 조회
stcsList: async (id: string) => {
getSmltStcs: async (id: string) => {
return await axios.get(`/api/anls/smlt/stcs/${id}`);
}
};

78
src/modules/analysis/simulation/models/analysisSimulatorModel.ts

@ -1,78 +0,0 @@
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
};

59
src/modules/analysis/simulation/reducers/analysisSimulatorReducer.ts

@ -1,59 +0,0 @@
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;
})
);

10
src/modules/analysis/simulation/reducers/index.ts

@ -7,13 +7,13 @@ export const analysisSimulatorReducer = createReducer<
AnalysisSimulatorState,
Actions.AnalysisSimulatorAction
>(initialState)
.handleAction(Actions.dispatchSearch, (state, action) =>
.handleAction(Actions.clientSearchParam, (state, action) =>
produce(state, draft => {
const { searchParams } = action.payload;
draft.searchParams = searchParams;
})
)
.handleAction(Actions.list.success, (state, action) =>
.handleAction(Actions.getSmltList.success, (state, action) =>
produce(state, draft => {
const { data, count, total, page } = action.payload;
if (!state.list) {
@ -32,13 +32,13 @@ export const analysisSimulatorReducer = createReducer<
draft.total = total;
})
)
.handleAction(Actions.detail.success, (state, action) =>
.handleAction(Actions.getSmltDetail.success, (state, action) =>
produce(state, draft => {
const { data } = action.payload;
draft.detail = data;
})
)
.handleAction(Actions.stcs.success, (state, action) =>
.handleAction(Actions.getSmltStcs.success, (state, action) =>
produce(state, draft => {
const { data, count } = action.payload;
draft.stcsList = data;
@ -46,7 +46,7 @@ export const analysisSimulatorReducer = createReducer<
})
)
.handleAction(Actions.log.success, (state, action) =>
.handleAction(Actions.getSmltLog.success, (state, action) =>
produce(state, draft => {
const { log } = action.payload;
const data = log.sort((p: any, n: any): any => {

82
src/modules/analysis/simulation/sagas/analysisSimulatorSaga.ts

@ -1,82 +0,0 @@
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);
}

48
src/modules/analysis/simulation/sagas/index.ts

@ -3,17 +3,21 @@ import { ActionType } from 'typesafe-actions';
import * as Actions from '../actions';
import * as Apis from '../apis';
function* listSaga(action: ActionType<typeof Actions.list.request>) {
function* listSaga(action: ActionType<typeof Actions.getSmltList.request>) {
try {
const { searchParams, page } = action.payload;
const res = yield call(Apis.analysisSimulator.list, searchParams, page);
const res = yield call(
Apis.analysisSimulator.getSmltList,
searchParams,
page
);
const {
data: { items, total },
count
} = res;
yield put(
Actions.list.success({
Actions.getSmltList.success({
data: items,
count: count,
total,
@ -21,62 +25,62 @@ function* listSaga(action: ActionType<typeof Actions.list.request>) {
})
);
} catch (error: any) {
yield put(Actions.list.failure(error));
yield put(Actions.getSmltList.failure(error));
}
}
function* detailSaga(action: ActionType<typeof Actions.detail.request>) {
function* detailSaga(action: ActionType<typeof Actions.getSmltDetail.request>) {
try {
const id = action.payload;
const res = yield call(Apis.analysisSimulator.detail, id);
// yield put(Actions.log.request(id));
const res = yield call(Apis.analysisSimulator.getSmltDetail, id);
// yield put(Actions.getSmltLog.request(id));
const { data } = res;
yield put(
Actions.detail.success({
Actions.getSmltDetail.success({
data: data
})
);
} catch (error: any) {
yield put(Actions.detail.failure(error));
yield put(Actions.getSmltDetail.failure(error));
}
}
function* stcsSaga(action: ActionType<typeof Actions.stcs.request>) {
function* stcsSaga(action: ActionType<typeof Actions.getSmltStcs.request>) {
try {
const id = action.payload;
const res = yield call(Apis.analysisSimulator.stcsList, id);
// yield put(Actions.log.request(id));
const res = yield call(Apis.analysisSimulator.getSmltStcs, id);
// yield put(Actions.getSmltLog.request(id));
const { data, count } = res;
yield put(
Actions.stcs.success({
Actions.getSmltStcs.success({
data: data,
count: count
})
);
} catch (error: any) {
yield put(Actions.detail.failure(error));
yield put(Actions.getSmltDetail.failure(error));
}
}
function* logSaga(action: ActionType<typeof Actions.log.request>) {
function* logSaga(action: ActionType<typeof Actions.getSmltLog.request>) {
try {
const id = action.payload;
const res = yield call(Apis.analysisSimulator.logList, id);
const res = yield call(Apis.analysisSimulator.getSmltLog, id);
const { data } = res;
yield put(
Actions.log.success({
Actions.getSmltLog.success({
log: data
})
);
} catch (error: any) {
yield put(Actions.log.failure(error));
yield put(Actions.getSmltLog.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);
yield takeEvery(Actions.getSmltList.request, listSaga);
yield takeEvery(Actions.getSmltDetail.request, detailSaga);
yield takeEvery(Actions.getSmltStcs.request, stcsSaga);
yield takeEvery(Actions.getSmltLog.request, logSaga);
}

1
src/modules/basis/drone/apis/index.ts

@ -3,7 +3,6 @@ import qs from 'qs';
import {
ICreateDroneRq,
ICreateIdntfRq,
IDrone,
IUpdateDroneRq,
IUpdateIdntfRq
} from '../models';

Loading…
Cancel
Save