계획정보 API 호출 공통화 및 수정
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* 보편적으로 쓰는 store 공간
|
||||
====================================**/
|
||||
|
||||
import { getFetch } from "@/app/components/api";
|
||||
import { getFetch, getFetchAreaList } from "@/app/components/api";
|
||||
|
||||
/**
|
||||
* STORE - TYPE
|
||||
@@ -205,6 +205,28 @@ const selectMiddleRegionData: SelectDataType[] = [
|
||||
* STORE - API
|
||||
*/
|
||||
|
||||
// 처리시설 계획정보 호출 (알에스원)
|
||||
export const planInfoUrl = 'https://apigateway.apps.rsonesoft.com/dc-service/api/v1/nowDmgMtncGnsvy';
|
||||
|
||||
export const fetchPlanInfo = async (targetYear : string | undefined, ctpvNm : string | undefined, sggNm : string | undefined, fcltyCd : string | undefined) => {
|
||||
try {
|
||||
const baseUrl = planInfoUrl;
|
||||
const queryParams = new URLSearchParams();
|
||||
if (ctpvNm && ctpvNm !== '전체') queryParams.append('ctpvNm', ctpvNm);
|
||||
if (sggNm && sggNm !== '전체') queryParams.append('sggNm', sggNm);
|
||||
if (targetYear) queryParams.append('targetYear',targetYear);
|
||||
if (fcltyCd) queryParams.append('swtrmtFcltCd', fcltyCd);
|
||||
const queryString = queryParams.toString();
|
||||
const url = queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
||||
const res = await getFetchAreaList(url);
|
||||
return res;
|
||||
} catch (error) {
|
||||
console.error('처리시설 계획정보를 가져오는데 실패했습니다:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 시도 API 호출 함수 추가
|
||||
const fetchSidoData = async (): Promise<SelectDataType[]> => {
|
||||
try {
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
* Store - 타입
|
||||
*/
|
||||
|
||||
import { getFetch, getFetchAreaList } from "@/app/components/api";
|
||||
import { getFetch } from "@/app/components/api";
|
||||
import DataForm from "@/app/components/common/DataForm";
|
||||
import { fetchPlanInfo } from "../common";
|
||||
import type { FacilityWaterQltyProps } from "../facilityWaterQlty";
|
||||
import { calRainEffectDay, type ApiResponse, type FlowDataItem } from "../underWaterInput";
|
||||
|
||||
@@ -691,16 +692,8 @@ const drainageEquipmentList : DrainageEquipmentListProps[] = [
|
||||
/* 시설정보 및 운영현황 - 계획 */
|
||||
const fetchFacilityPlan = async (targetYear : string | undefined, fcltyCd : string | undefined, set : (fn: (state: DashBoardType) => DashBoardType) => void) => {
|
||||
try {
|
||||
targetYear = targetYear ? targetYear : "2024";
|
||||
const baseUrl = 'https://apigateway.rsonesoft.com/dc-service/api/v1/nowDmgMtncGnsvy';
|
||||
const queryParams = new URLSearchParams();
|
||||
|
||||
if (fcltyCd) queryParams.append('swtrmtFcltCd', fcltyCd);
|
||||
//if (targetYear) queryParams.append('targetYear',targetYear);
|
||||
const queryString = queryParams.toString();
|
||||
const url = queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
||||
const res = await getFetchAreaList(url);
|
||||
return res
|
||||
const res = await fetchPlanInfo(undefined, undefined, undefined, fcltyCd);
|
||||
return res;
|
||||
} catch (error) {
|
||||
console.error('시설계획정보를 가져오는데 실패했습니다:', error);
|
||||
set((state) => ({
|
||||
@@ -1121,6 +1114,16 @@ export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType)
|
||||
|
||||
// 임시시
|
||||
dataFormSettingPlan(el);
|
||||
console.log('planFcltyList', planFcltyList);
|
||||
console.log('rtnPlanData', rtnPlanData);
|
||||
set((state: DashBoardType) => ({
|
||||
...state,
|
||||
PlanFclty: {
|
||||
...state.PlanFclty,
|
||||
planFcltyList: planFcltyList,
|
||||
isLoadingPlanFclty: false,
|
||||
},
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1229,10 +1232,10 @@ export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType)
|
||||
}
|
||||
|
||||
if(operationalStatusList[0] && operationalStatusList[7]){
|
||||
operationalStatusList[7].groundWaterAvg = Math.round((Number(operationalStatusList[0].groundWaterAvg) / Number(data.yearData.AVG_INFL_AMNT) * 100) * 10) / 10+'%';
|
||||
operationalStatusList[7].groundWaterSummer = Math.round((Number(operationalStatusList[0].groundWaterSummer) / Number(data.summer.AVG_INFL_AMNT) * 100) * 10) / 10+'%';
|
||||
operationalStatusList[7].groundWaterWinter = Math.round((Number(operationalStatusList[0].groundWaterWinter) / Number(data.winter.AVG_INFL_AMNT) * 100) * 10) / 10+'%';
|
||||
operationalStatusList[7].rdi = operationalStatusList[0].rdi===null?0:Math.round((Number(operationalStatusList[0].rdi) / (data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0) * 100) * 10) / 10+'%';
|
||||
operationalStatusList[7].groundWaterAvg = operationalStatusList[0].groundWaterAvg === null ? '' : data.yearData.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterAvg) / Number(data.yearData.AVG_INFL_AMNT) * 100) * 10) / 10+'%';
|
||||
operationalStatusList[7].groundWaterSummer = operationalStatusList[0].groundWaterSummer === null ? '' : data.summer.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterSummer) / Number(data.summer.AVG_INFL_AMNT) * 100) * 10) / 10+'%';
|
||||
operationalStatusList[7].groundWaterWinter = operationalStatusList[0].groundWaterWinter === null ? '' : data.winter.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterWinter) / Number(data.winter.AVG_INFL_AMNT) * 100) * 10) / 10+'%';
|
||||
operationalStatusList[7].rdi = operationalStatusList[0].rdi === null ? '' : data.summerBod && data.summerBod.INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].rdi) / (data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0) * 100) * 10) / 10+'%';
|
||||
/* operationalStatusList[7].groundWaterAvg = operationalStatusList[0].groundWaterAvg === null ? '' : Number(Number(operationalStatusList[0].groundWaterAvg) / Number(data.yearData.AVG_INFL_AMNT)) * 100;
|
||||
operationalStatusList[7].groundWaterSummer = operationalStatusList[0].groundWaterSummer === null ? '' : Number(Number(operationalStatusList[0].groundWaterSummer) / Number(data.summer.AVG_INFL_AMNT)) * 100;
|
||||
operationalStatusList[7].groundWaterWinter = operationalStatusList[0].groundWaterWinter === null ? '' : Number(Number(operationalStatusList[0].groundWaterWinter) / Number(data.winter.AVG_INFL_AMNT)) * 100;*/
|
||||
@@ -1289,7 +1292,6 @@ export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType)
|
||||
operationalStatusList: operationalStatusList,
|
||||
operationalStatusCount: res.count,
|
||||
isLoadingOperationStatus : false,
|
||||
|
||||
},
|
||||
}))
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getFetchAreaList, postFetch } from "@/app/components/api";
|
||||
import type { TableUpperProps } from "../dashboard";
|
||||
import { postFetch } from "@/app/components/api";
|
||||
import DataForm from "@/app/components/common/DataForm";
|
||||
import { fetchPlanInfo } from "../common";
|
||||
import type { TableUpperProps } from "../dashboard";
|
||||
export type { TableUpperProps };
|
||||
/**====================================
|
||||
* Store - 타입
|
||||
@@ -229,19 +230,7 @@ const fetchFacilityDetailInfo = async (swtrmtFcltCd: string) => {
|
||||
// 시설정보 리스트 데이터 호출(구분 선택 후 시설명 있을 경우)
|
||||
const fetchProcessAreaList = async (pageNo : number, pageSize : number, ctpvNm : string | undefined, sggNm : string | undefined, targetYear : string | undefined, set : (fn: (state: ProcessAreaType) => ProcessAreaType) => void): Promise<{data:ProcessAreaProps[], count:number}> => {
|
||||
try {
|
||||
targetYear = targetYear ? targetYear : "2023";
|
||||
console.log('targetYear', targetYear);
|
||||
const baseUrl = 'https://apigateway.rsonesoft.com/dc-service/api/v1/nowDmgMtncGnsvy';
|
||||
const queryParams = new URLSearchParams();
|
||||
|
||||
if (ctpvNm && ctpvNm !== '전체') queryParams.append('ctpvNm', ctpvNm);
|
||||
if (sggNm && sggNm !== '전체') queryParams.append('sggNm', sggNm);
|
||||
if (targetYear) queryParams.append('targetYear',targetYear);
|
||||
|
||||
const queryString = queryParams.toString();
|
||||
const url = queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
||||
const res = await getFetchAreaList(url);
|
||||
|
||||
const res = await fetchPlanInfo(targetYear, ctpvNm, sggNm, undefined);
|
||||
if(res && res.length > 0){
|
||||
const enrichedData = await Promise.all(
|
||||
res.map(async (item: ProcessAreaProps) => {
|
||||
|
||||
Reference in New Issue
Block a user