fo: 계획하수량 산정지표 현황 수정
This commit is contained in:
@@ -1,37 +1,33 @@
|
||||
import DataForm from "@/app/components/common/DataForm";
|
||||
import DataForm, { roundNumber } from "@/app/components/common/DataForm";
|
||||
import type { TableUpperProps } from "../dashboard";
|
||||
import { getFetch } from "@/app/components/api";
|
||||
import { type ApiResponse, type FlowDataItem } from "../underWaterInput";
|
||||
import CalcRainEffect from "@/app/components/common/CalcRainEffect";
|
||||
import { roundUp } from "../common";
|
||||
export type { TableUpperProps };
|
||||
/**====================================
|
||||
* Store - 타입
|
||||
====================================*/
|
||||
|
||||
/**
|
||||
* (1) 메인페이지
|
||||
* 처리시설 연간 운영현황 > 계획하수량 산정지표 현황
|
||||
*/
|
||||
// 시설별 강수현황
|
||||
type PlanSewageProps = {
|
||||
bscFctCd : string,
|
||||
sido : string,
|
||||
gugun : string,
|
||||
bscFctNm : string,
|
||||
daddr : string,
|
||||
fctCpc : number,
|
||||
spareCapacity : number,
|
||||
variableLoadPercent : number,
|
||||
classifiedSewerPercent : number,
|
||||
rgnNm : string,
|
||||
rvbsn : string,
|
||||
lgbsn : string,
|
||||
mdmbsn : string,
|
||||
sprtProcZoneAr : number,
|
||||
procZoneSm : number,
|
||||
avgInflAmnt : number,
|
||||
avgInflAmntSunny : number,
|
||||
maxInflAmntSunny : number,
|
||||
bscFctCd: string,
|
||||
sido: string,
|
||||
gugun: string,
|
||||
bscFctNm: string,
|
||||
daddr: string,
|
||||
fctCpc: number,
|
||||
spareCapacity: number,
|
||||
variableLoadPercent: number,
|
||||
classifiedSewerPercent: number,
|
||||
rgnNm: string,
|
||||
rvbsn: string,
|
||||
lgbsn: string,
|
||||
mdmbsn: string,
|
||||
sprtProcZoneAr: number,
|
||||
procZoneSm: number,
|
||||
avgInflAmnt: number,
|
||||
avgInflAmntSunny: number,
|
||||
maxInflAmntSunny: number,
|
||||
}
|
||||
|
||||
/**====================================
|
||||
@@ -40,90 +36,128 @@ type PlanSewageProps = {
|
||||
|
||||
/**
|
||||
* (1) 메인페이지
|
||||
*/
|
||||
*/
|
||||
// 검색단
|
||||
const LabelArray:string[] = ['구분', '시도', '시군구','용량별', '시설명', '조회기간', '시설상태', '권역', '단위유역', '중권역', '환경청별'];
|
||||
const LabelArray: string[] = ['구분', '시도', '시군구', '용량별', '시설명', '조회기간', '시설상태', '권역', '단위유역', '중권역', '환경청별'];
|
||||
|
||||
// 리스트 헤더
|
||||
const upHeadList1:TableUpperProps[] = [
|
||||
{ id: "A", title: "행정구역", upSequnce:1, row:0, colSpan:2 },
|
||||
{ id: "sido", title: "시도", upName:"upChangeRe", upSequnce:1, row:1, widthPercent: 10 },
|
||||
{ id: "gugun", title: "시군구", upName:"upChangeRe",upSequnce:2, row:1, widthPercent: 10 },
|
||||
{ id: "bscFctNm", title: "시설명", row:0, rowSpan:2, widthPercent: 10 },
|
||||
{ id: "daddr", title: "주소", row:0, rowSpan:2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
{ id: "spareCapacity", title: "여유용량(m³/일)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
{ id: "variableLoadPercent", title: "변동부하율(%)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
{ id: "classifiedSewerPercent", title: "분류식화율(%)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
const upHeadList1: TableUpperProps[] = [
|
||||
{ id: "A", title: "행정구역", upSequnce: 1, row: 0, colSpan: 2 },
|
||||
{ id: "sido", title: "시도", upName: "upChangeRe", upSequnce: 1, row: 1, widthPercent: 10 },
|
||||
{ id: "gugun", title: "시군구", upName: "upChangeRe", upSequnce: 2, row: 1, widthPercent: 10 },
|
||||
{ id: "bscFctNm", title: "시설명", row: 0, rowSpan: 2, widthPercent: 10 },
|
||||
{ id: "daddr", title: "주소", row: 0, rowSpan: 2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
{ id: "spareCapacity", title: "여유용량(m³/일)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
{ id: "variableLoadPercent", title: "변동부하율(%)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
{ id: "classifiedSewerPercent", title: "분류식화율(%)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
];
|
||||
|
||||
const upHeadList2:TableUpperProps[] = [
|
||||
{ id: "A", title: "유역", upName:"upChangeRe", upSequnce:1, row:0, colSpan:3 },
|
||||
{ id: "rvbsn", title: "권역", upName:"upChangeRe", upSequnce:1, row:1, widthPercent: 8 },
|
||||
{ id: "lgbsn", title: "단위유역", upName:"upChangeRe", upSequnce:2, row:1, widthPercent: 8},
|
||||
{ id: "mdmbsn", title: "중권역", upName:"upChangeRe", upSequnce:3, row:1, widthPercent: 8},
|
||||
{ id: "bscFctNm", title: "시설명", row:0, rowSpan:2, widthPercent: 10 },
|
||||
{ id: "daddr", title: "주소", row:0, rowSpan:2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
{ id: "spareCapacity", title: "여유용량(m³/일)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
{ id: "variableLoadPercent", title: "변동부하율(%)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
{ id: "classifiedSewerPercent", title: "분류식화율(%)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
const upHeadList2: TableUpperProps[] = [
|
||||
{ id: "A", title: "유역", upName: "upChangeRe", upSequnce: 1, row: 0, colSpan: 3 },
|
||||
{ id: "rvbsn", title: "권역", upName: "upChangeRe", upSequnce: 1, row: 1, widthPercent: 8 },
|
||||
{ id: "lgbsn", title: "단위유역", upName: "upChangeRe", upSequnce: 2, row: 1, widthPercent: 8 },
|
||||
{ id: "mdmbsn", title: "중권역", upName: "upChangeRe", upSequnce: 3, row: 1, widthPercent: 8 },
|
||||
{ id: "bscFctNm", title: "시설명", row: 0, rowSpan: 2, widthPercent: 10 },
|
||||
{ id: "daddr", title: "주소", row: 0, rowSpan: 2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
{ id: "spareCapacity", title: "여유용량(m³/일)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
{ id: "variableLoadPercent", title: "변동부하율(%)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
{ id: "classifiedSewerPercent", title: "분류식화율(%)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
];
|
||||
|
||||
const upHeadList3:TableUpperProps[] = [
|
||||
{ id: "A", title: "유역", upName:"upChangeRe", upSequnce:1, row:0, colSpan:3 },
|
||||
{ id: "rvbsn", title: "권역", upName:"upChangeRe1", upSequnce:1, row:1, widthPercent: 5 },
|
||||
{ id: "lgbsn", title: "단위유역", upName:"upChangeRe1", upSequnce:2, row:1, widthPercent: 5 },
|
||||
{ id: "mdmbsn", title: "중권역", upName:"upChangeRe1", upSequnce:3, row:1, widthPercent: 5},
|
||||
{ id: "rgnNm", title: "환경청", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "B", title: "행정구역", upName:"upChangeRe", upSequnce:1, row:0, colSpan:2 },
|
||||
{ id: "sido", title: "시도", upName:"upChangeRe2", upSequnce:1, row:1, widthPercent: 5 },
|
||||
{ id: "gugun", title: "시군구", upName:"upChangeRe2",upSequnce:2, row:1, widthPercent: 5 },
|
||||
{ id: "bscFctNm", title: "시설명", row:0, rowSpan:2, widthPercent: 10 },
|
||||
{ id: "daddr", title: "주소", row:0, rowSpan:2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
{ id: "spareCapacity", title: "여유용량(m³/일)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
{ id: "variableLoadPercent", title: "변동부하율(%)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
{ id: "classifiedSewerPercent", title: "분류식화율(%)", row:0, rowSpan:2, align:'right', widthPercent: 8 },
|
||||
const upHeadList3: TableUpperProps[] = [
|
||||
{ id: "A", title: "유역", upName: "upChangeRe", upSequnce: 1, row: 0, colSpan: 3 },
|
||||
{ id: "rvbsn", title: "권역", upName: "upChangeRe1", upSequnce: 1, row: 1, widthPercent: 5 },
|
||||
{ id: "lgbsn", title: "단위유역", upName: "upChangeRe1", upSequnce: 2, row: 1, widthPercent: 5 },
|
||||
{ id: "mdmbsn", title: "중권역", upName: "upChangeRe1", upSequnce: 3, row: 1, widthPercent: 5 },
|
||||
{ id: "rgnNm", title: "환경청", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "B", title: "행정구역", upName: "upChangeRe", upSequnce: 1, row: 0, colSpan: 2 },
|
||||
{ id: "sido", title: "시도", upName: "upChangeRe2", upSequnce: 1, row: 1, widthPercent: 5 },
|
||||
{ id: "gugun", title: "시군구", upName: "upChangeRe2", upSequnce: 2, row: 1, widthPercent: 5 },
|
||||
{ id: "bscFctNm", title: "시설명", row: 0, rowSpan: 2, widthPercent: 10 },
|
||||
{ id: "daddr", title: "주소", row: 0, rowSpan: 2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
{ id: "spareCapacity", title: "여유용량(m³/일)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
{ id: "variableLoadPercent", title: "변동부하율(%)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
{ id: "classifiedSewerPercent", title: "분류식화율(%)", row: 0, rowSpan: 2, align: 'right', widthPercent: 8 },
|
||||
];
|
||||
|
||||
const planSewageList:PlanSewageProps[] = [
|
||||
const planSewageList: PlanSewageProps[] = [
|
||||
]
|
||||
|
||||
/**====================================
|
||||
* Store - api
|
||||
====================================*/
|
||||
const fetchPlanSewageList = async (pageNo: number, pageSize: number, searchYear: string, partCd?: string, nameCd?: string, fcltCpct?: string, operationValue?: string, fcltyNm?: string) => {
|
||||
const tailStr = partCd ? '/'+ partCd + '/' + (nameCd || '0') + '/' + (fcltCpct || '0') + '/' + (operationValue || '0') +'/0'+ (fcltyNm && fcltyNm !== '' ? '/' + fcltyNm : '') : '';
|
||||
|
||||
/**
|
||||
* 계획시설정보 리스트 데이터 호출(구분 선택 후 시설명 있을 경우)
|
||||
* @param pageNo : 페이지 번호
|
||||
* @param pageSize : 페이지 크기
|
||||
* @param searchYear : 검색년도
|
||||
* @param partCd : 구분코드
|
||||
* @param nameCd : 행정코드(시도명, 시군구명, 단위유역)
|
||||
* @param fcltCpct : 시설용량
|
||||
* @param oprtngSttsCd : 운영 상태 코드
|
||||
* @param facilityName : 시설명
|
||||
*/
|
||||
const fetchPlanSewageList = async (pageNo: number, pageSize: number, searchYear: string, partCd?: string, nameCd?: string, fcltCpct?: string, operationValue?: string, fcltyNm?: string) => {
|
||||
const tailStr = partCd ? '/' + partCd + '/' + (nameCd || '0') + '/' + (fcltCpct || '0') + '/' + (operationValue || '0') + '/0' + (fcltyNm && fcltyNm !== '' ? '/' + fcltyNm : '') : '';
|
||||
const url = '/prcsFclt/info/plan/' + pageNo + '/' + pageSize + '/' + searchYear + tailStr;
|
||||
const res = await getFetch('fo', url);
|
||||
return { data: res.data, count: res.count }
|
||||
}
|
||||
}
|
||||
|
||||
// 시설들 유량 정보 조회
|
||||
export const fetchFlow = async (searchYear: string | undefined, fcltCdList: string[]): Promise<ApiResponse | null> => {
|
||||
try {
|
||||
const params = new URLSearchParams();
|
||||
fcltCdList.forEach(cd => params.append('fcltCds', cd));
|
||||
const res = await getFetch('fo', '/fclt/flow/' + searchYear + '?' + params.toString());
|
||||
return res;
|
||||
} catch (error) {
|
||||
console.error('시설정보 유량 데이터를 가져오는데 실패했습니다:', error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**====================================
|
||||
* Store - expaort
|
||||
====================================*/
|
||||
interface FlowDataItem {
|
||||
inflAmnt: number | string;
|
||||
infoRnDay: number;
|
||||
msrDt: string;
|
||||
rainEffectDay?: number;
|
||||
sumFlow?: number | string | '';
|
||||
}
|
||||
|
||||
interface ApiResponse {
|
||||
data: FlowDataItem[];
|
||||
count: number;
|
||||
}
|
||||
|
||||
export type ExcelType = {
|
||||
시설코드: string;
|
||||
권역:string|'',
|
||||
단위유역:string|'',
|
||||
중권역:string|'',
|
||||
환경청:string|'',
|
||||
권역: string | '',
|
||||
단위유역: string | '',
|
||||
중권역: string | '',
|
||||
환경청: string | '',
|
||||
시도: string;
|
||||
시군구: string;
|
||||
시설이름: string;
|
||||
주소: string;
|
||||
"시설용량(m³/일)": number;
|
||||
"여유용량(m³/일)": number;
|
||||
"변동부하율(%)" : number;
|
||||
"분류식화율(%)" : number;
|
||||
"변동부하율(%)": number;
|
||||
"분류식화율(%)": number;
|
||||
}
|
||||
|
||||
const dataFormSetting=(item : PlanSewageProps)=> {
|
||||
const dataFormSetting = (item: PlanSewageProps) => {
|
||||
DataForm({ type: 'float0', column: 'fctCpc', item: item as unknown as Record<string, unknown> });
|
||||
DataForm({ type: 'float0', column: 'spareCapacity', item: item as unknown as Record<string, unknown>});
|
||||
DataForm({ type: 'float2', column: 'variableLoadPercent', item: item as unknown as Record<string, unknown>});
|
||||
DataForm({ type: 'float1', column: 'classifiedSewerPercent', item: item as unknown as Record<string, unknown>});
|
||||
DataForm({ type: 'float0', column: 'spareCapacity', item: item as unknown as Record<string, unknown> });
|
||||
DataForm({ type: 'float2', column: 'variableLoadPercent', item: item as unknown as Record<string, unknown> });
|
||||
DataForm({ type: 'float1', column: 'classifiedSewerPercent', item: item as unknown as Record<string, unknown> });
|
||||
};
|
||||
|
||||
export type PlanSewageActions = {
|
||||
@@ -133,10 +167,10 @@ export type PlanSewageActions = {
|
||||
export type PlanSewageType = {
|
||||
PlanSewageSearch: {
|
||||
isInit: boolean;
|
||||
labelArray:string[];
|
||||
labelArray: string[];
|
||||
},
|
||||
|
||||
PlanSewage : {
|
||||
PlanSewage: {
|
||||
isInit: boolean;
|
||||
upHeadList1: TableUpperProps[];
|
||||
upHeadList2: TableUpperProps[];
|
||||
@@ -154,21 +188,21 @@ export const planSewageInitState: PlanSewageType = {
|
||||
labelArray: LabelArray,
|
||||
},
|
||||
|
||||
PlanSewage : {
|
||||
isInit : false,
|
||||
upHeadList1 : upHeadList1,
|
||||
upHeadList2 : upHeadList2,
|
||||
upHeadList3 : upHeadList3,
|
||||
planSewageList : planSewageList,
|
||||
planSewageCount : 0,
|
||||
excelList : [],
|
||||
isLoading : true,
|
||||
PlanSewage: {
|
||||
isInit: false,
|
||||
upHeadList1: upHeadList1,
|
||||
upHeadList2: upHeadList2,
|
||||
upHeadList3: upHeadList3,
|
||||
planSewageList: planSewageList,
|
||||
planSewageCount: 0,
|
||||
excelList: [],
|
||||
isLoading: true,
|
||||
},
|
||||
}
|
||||
|
||||
export type PlanSewageStore = PlanSewageType & PlanSewageActions;
|
||||
|
||||
export const planSewageReducer:(set:(fn: (state: PlanSewageType) => PlanSewageType) => void)=>PlanSewageActions=(set: (fn: (state: PlanSewageType) => PlanSewageType) => void) => {
|
||||
export const planSewageReducer: (set: (fn: (state: PlanSewageType) => PlanSewageType) => void) => PlanSewageActions = (set: (fn: (state: PlanSewageType) => PlanSewageType) => void) => {
|
||||
return {
|
||||
searchPlanSewageList: async (pageNo: number, pageSize: number, searchYear: string, partCd?: string, nameCd?: string, fcltCpct?: string, operationValue?: string, fcltyNm?: string) => {
|
||||
set((state: PlanSewageType) => ({
|
||||
@@ -179,48 +213,110 @@ export const planSewageReducer:(set:(fn: (state: PlanSewageType) => PlanSewageTy
|
||||
},
|
||||
}));
|
||||
const res = await fetchPlanSewageList(pageNo, pageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm);
|
||||
const fcltylist = res.data; // 시설목록
|
||||
const fcltCdList: string[] = []; // 시설코드목록
|
||||
const planSewageList: PlanSewageProps[] = []; // 오수발생량시설목록
|
||||
fcltylist.forEach(item => {
|
||||
fcltCdList.push(item.bscFctCd);
|
||||
planSewageList.push({
|
||||
bscFctCd: item.bscFctCd,
|
||||
sido: item.sido,
|
||||
gugun: item.gugun,
|
||||
bscFctNm: item.bscFctNm,
|
||||
daddr: item.daddr,
|
||||
fctCpc: parseFloat(item.fctCpc.toString().replace(/,/g, '')),
|
||||
spareCapacity: 0,
|
||||
variableLoadPercent: 0,
|
||||
classifiedSewerPercent: 0,
|
||||
rgnNm: item.rgnNm, //환경청
|
||||
rvbsn: item.rvbsn, //단위유역
|
||||
lgbsn: item.lgbsn, //권역
|
||||
mdmbsn: item.mdmbsn, //중권역
|
||||
sprtProcZoneAr: item.sprtProcZoneAr, // 분류식지역 면적(㎢)
|
||||
procZoneSm: item.procZoneSm, // 처리구역 면적합계(㎢)
|
||||
avgInflAmnt: 0,
|
||||
avgInflAmntSunny: 0,
|
||||
maxInflAmntSunny: 0,
|
||||
});
|
||||
});
|
||||
|
||||
const excelDownList: ExcelType[] = [];
|
||||
const data = res.data
|
||||
const processedData = await Promise.all(data.map(async (item:PlanSewageProps) => {
|
||||
const res2 = await getFetch('fo', '/fclt/flow/' + item.bscFctCd + '/' + searchYear) as ApiResponse;
|
||||
const calData = CalcRainEffect(res2.data, 'SUNNY');
|
||||
|
||||
const detailRes: any = await fetchFlow(searchYear, fcltCdList);
|
||||
for (const item of planSewageList) {
|
||||
const detailList = detailRes?.data[item.bscFctCd];
|
||||
|
||||
let avgInflAmnt = 0;
|
||||
let sumInflAmntSunny = 0;
|
||||
let avgInflAmntSunny = 0;
|
||||
let maxInflAmntSunny = 0;
|
||||
calData.forEach((flowItem:FlowDataItem) => {
|
||||
sumInflAmntSunny += Number(flowItem.inflAmnt);
|
||||
let cntSunny = 0;
|
||||
let rainEffectDay = 0;
|
||||
detailList?.forEach(item2 => {
|
||||
|
||||
if(Number(flowItem.inflAmnt) > maxInflAmntSunny){
|
||||
maxInflAmntSunny = Number(flowItem.inflAmnt);
|
||||
if (item2.infoRnDay == null || item2.infoRnDay == 'x') item2.infoRnDay = 0;
|
||||
if (item2.infoRnDay >= 3) { // 강우량이 3이상이면 그 후 2일이 강후영향일임.
|
||||
rainEffectDay = 2;
|
||||
} else {
|
||||
rainEffectDay--;
|
||||
}
|
||||
});
|
||||
if (rainEffectDay < 0) { //청천시
|
||||
sumInflAmntSunny += Number(item2.inflAmnt);
|
||||
cntSunny++;
|
||||
|
||||
avgInflAmntSunny = sumInflAmntSunny / calData.length;
|
||||
if (Number(item2.inflAmnt) > maxInflAmntSunny) {
|
||||
maxInflAmntSunny = Number(item2.inflAmnt);
|
||||
}
|
||||
}
|
||||
avgInflAmnt += Number(item2.inflAmnt);
|
||||
});
|
||||
avgInflAmntSunny = sumInflAmntSunny / cntSunny;
|
||||
item.avgInflAmnt = roundUp(avgInflAmnt, 0);
|
||||
item.avgInflAmntSunny = roundUp(avgInflAmntSunny, 0);
|
||||
item.maxInflAmntSunny = roundUp(maxInflAmntSunny, 0);
|
||||
return item;
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
// const processedData = await Promise.all(data.map(async (item: PlanSewageProps) => {
|
||||
// const res2 = await getFetch('fo', '/fclt/flow/' + item.bscFctCd + '/' + searchYear) as ApiResponse;
|
||||
// const calData = CalcRainEffect(res2.data, 'SUNNY');
|
||||
|
||||
// let sumInflAmntSunny = 0; // 청천시 유입량 합계
|
||||
// let avgInflAmntSunny = 0; // 청천시 유입량 평균
|
||||
// let maxInflAmntSunny = 0; // 청천시 유입량 최대값
|
||||
// calData.forEach((flowItem: FlowDataItem) => {
|
||||
// sumInflAmntSunny += Number(flowItem.inflAmnt);
|
||||
|
||||
// if (Number(flowItem.inflAmnt) > maxInflAmntSunny) {
|
||||
// maxInflAmntSunny = Number(flowItem.inflAmnt);
|
||||
// }
|
||||
// });
|
||||
|
||||
// avgInflAmntSunny = sumInflAmntSunny / calData.length;
|
||||
// item.avgInflAmntSunny = roundUp(avgInflAmntSunny, 0);
|
||||
// item.maxInflAmntSunny = roundUp(maxInflAmntSunny, 0);
|
||||
// return item;
|
||||
// }));
|
||||
|
||||
/**
|
||||
* 결과데이터 계산
|
||||
* (1) 여유용량 = 시설용량 - 건기시 평균유량
|
||||
* (2) 변동부하율 = 건기시 일최대 유량/일평균유량(기준 최근 3개년)
|
||||
* (3) 분류식화율 = 분류식지역 면적(㎢)/처리구역 면적합계(㎢) ×100
|
||||
*/
|
||||
const resultData = processedData.map((item:PlanSewageProps) => {
|
||||
const resultData = planSewageList.map((item: PlanSewageProps) => {
|
||||
item.spareCapacity = Number(item.fctCpc) - Number(item.avgInflAmntSunny);
|
||||
item.variableLoadPercent = item.maxInflAmntSunny && item.maxInflAmntSunny!==0 ? Number(item.maxInflAmntSunny) / Number(item.avgInflAmntSunny) : 0;
|
||||
item.classifiedSewerPercent = item.sprtProcZoneAr && item.sprtProcZoneAr!==0 ? Number(item.sprtProcZoneAr) / Number(item.procZoneSm) * 100 : 0;
|
||||
item.variableLoadPercent = item.maxInflAmntSunny && item.maxInflAmntSunny !== 0 ? Number(item.maxInflAmntSunny) / Number(item.avgInflAmntSunny) : 0;
|
||||
item.classifiedSewerPercent = item.sprtProcZoneAr && item.sprtProcZoneAr !== 0 ? Number(item.sprtProcZoneAr) / Number(item.procZoneSm) * 100 : 0; // 분류식화율
|
||||
return item;
|
||||
});
|
||||
|
||||
resultData.forEach((item:PlanSewageProps) => {
|
||||
resultData.forEach((item: PlanSewageProps) => {
|
||||
dataFormSetting(item)
|
||||
})
|
||||
|
||||
if(pageSize>5000){
|
||||
resultData.forEach((item:PlanSewageProps) => {
|
||||
if (pageSize > 5000) {
|
||||
resultData.forEach((item: PlanSewageProps) => {
|
||||
excelDownList.push({
|
||||
시설코드: item.bscFctCd,
|
||||
권역: item.lgbsn,
|
||||
@@ -238,18 +334,18 @@ export const planSewageReducer:(set:(fn: (state: PlanSewageType) => PlanSewageTy
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
set((state:PlanSewageType) => ({
|
||||
|
||||
set((state: PlanSewageType) => ({
|
||||
...state,
|
||||
PlanSewage: pageSize<5000?{
|
||||
PlanSewage: pageSize < 5000 ? {
|
||||
...state.PlanSewage,
|
||||
planSewageList: resultData,
|
||||
planSewageCount: res.count,
|
||||
isLoading : false,
|
||||
}:{
|
||||
isLoading: false,
|
||||
} : {
|
||||
...state.PlanSewage,
|
||||
excelList: excelDownList,
|
||||
isLoading : false,
|
||||
isLoading: false,
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,58 +5,55 @@ import { OSU_PERCENT } from "../common";
|
||||
import type { TableUpperProps } from "../dashboard";
|
||||
import { fetchFacilityListInit } from "../processFacility";
|
||||
export type { TableUpperProps };
|
||||
/**====================================
|
||||
* Store - 타입
|
||||
====================================*/
|
||||
|
||||
/**
|
||||
* (1) 메인페이지
|
||||
* 운영실태 >오수발생량 추정
|
||||
*/
|
||||
// 시설별 강수현황
|
||||
export type SewageOccurProps = {
|
||||
bscFctCd : string,
|
||||
sidoNm : string,
|
||||
sggNm : string,
|
||||
lclgvrnmntNm : string,
|
||||
bscFctNm : string,
|
||||
daddr : string,
|
||||
fctCpc : number,
|
||||
waterUsage : number,
|
||||
swageChangePercent : number,
|
||||
estimationSewage : number,
|
||||
sewageInputYear : number,
|
||||
sewageInputChungchun : number,
|
||||
rgnNm : string,
|
||||
rvbsn : string,
|
||||
lgbsn : string,
|
||||
mdmbsn : string,
|
||||
msrDt : string,
|
||||
bscFctCd: string,
|
||||
sidoNm: string,
|
||||
sggNm: string,
|
||||
lclgvrnmntNm: string,
|
||||
bscFctNm: string,
|
||||
daddr: string,
|
||||
fctCpc: number,
|
||||
waterUsage: number,
|
||||
swageChangePercent: number,
|
||||
estimationSewage: number,
|
||||
sewageInputYear: number,
|
||||
sewageInputChungchun: number,
|
||||
rgnNm: string,
|
||||
rvbsn: string,
|
||||
lgbsn: string,
|
||||
mdmbsn: string,
|
||||
msrDt: string,
|
||||
}
|
||||
export type modalTableType = { msrDt: string,waterUsage: number,swageChangePercent: number,estimationSewage: number};
|
||||
export type modalTableType = { msrDt: string, waterUsage: number, swageChangePercent: number, estimationSewage: number };
|
||||
export type SewageOccurDetailProps = {
|
||||
cnt : number,
|
||||
sum : number,
|
||||
yr:string,
|
||||
usage:number, // 일평균 유입량
|
||||
cntWtrUsg : number, // 물사용량 일자수
|
||||
sumWtrUsg : number, // 물사용량 합
|
||||
avgWtrUsg:number, // 일평균 물사용량
|
||||
monWtrUsg:number, // 월 물사용량
|
||||
cnt: number,
|
||||
sum: number,
|
||||
yr: string,
|
||||
usage: number, // 일평균 유입량
|
||||
cntWtrUsg: number, // 물사용량 일자수
|
||||
sumWtrUsg: number, // 물사용량 합
|
||||
avgWtrUsg: number, // 일평균 물사용량
|
||||
monWtrUsg: number, // 월 물사용량
|
||||
}
|
||||
export type WtrUsgYmProps = {
|
||||
bscFctCd : string, // 처리구역시설코드
|
||||
levyYm : string, // 부과년월
|
||||
wtrUsg : number, // 월별 물사용량(m³/월)
|
||||
bscFctCd: string, // 처리구역시설코드
|
||||
levyYm: string, // 부과년월
|
||||
wtrUsg: number, // 월별 물사용량(m³/월)
|
||||
}
|
||||
// 검색단
|
||||
const LabelArray:string[] = ['구분', '시도', '시군구','용량별', '시설명', '조회기간', '시설상태', '권역', '단위유역', '중권역', '환경청별'];
|
||||
const LabelArray: string[] = ['구분', '시도', '시군구', '용량별', '시설명', '조회기간', '시설상태', '권역', '단위유역', '중권역', '환경청별'];
|
||||
|
||||
export interface ExcelType {
|
||||
시설코드: string,
|
||||
권역:string|'',
|
||||
단위유역:string|'',
|
||||
중권역:string|'',
|
||||
환경청:string|'',
|
||||
권역: string | '',
|
||||
단위유역: string | '',
|
||||
중권역: string | '',
|
||||
환경청: string | '',
|
||||
시도: string,
|
||||
시군구: string,
|
||||
시설명: string,
|
||||
@@ -70,64 +67,64 @@ export interface ExcelType {
|
||||
}
|
||||
|
||||
// 리스트 헤더
|
||||
const upHeadList1:TableUpperProps[] = [
|
||||
{ id: "A", title: "행정구역", row:0, colSpan:2 },
|
||||
{ id: "sidoNm", title: "시도", row:1, widthPercent: 8 },
|
||||
{ id: "sggNm", title: "시군구", row:1, widthPercent: 8 },
|
||||
{ id: "bscFctNm", title: "시설명", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "daddr", title: "주소", row:0, rowSpan:2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "waterUsage", title: "물사용량(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "swageChangePercent", title: "오수전환율\n(%)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "estimationSewage", title: "오수발생량 추정\n(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "sewageInputYear", title: "연간 하수유입량\n(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "sewageInputChungchun", title: "청천시 하수유입량\n(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
const upHeadList1: TableUpperProps[] = [
|
||||
{ id: "A", title: "행정구역", row: 0, colSpan: 2 },
|
||||
{ id: "sidoNm", title: "시도", row: 1, widthPercent: 8 },
|
||||
{ id: "sggNm", title: "시군구", row: 1, widthPercent: 8 },
|
||||
{ id: "bscFctNm", title: "시설명", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "daddr", title: "주소", row: 0, rowSpan: 2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "waterUsage", title: "물사용량(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "swageChangePercent", title: "오수전환율\n(%)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "estimationSewage", title: "오수발생량 추정\n(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "sewageInputYear", title: "연간 하수유입량\n(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "sewageInputChungchun", title: "청천시 하수유입량\n(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
];
|
||||
|
||||
const upHeadList2:TableUpperProps[] = [
|
||||
{ id: "A", title: "유역", row:0, colSpan:3 },
|
||||
{ id: "rvbsn", title: "권역", row:1, widthPercent: 6 },
|
||||
{ id: "lgbsn", title: "단위유역", row:1, widthPercent: 6 },
|
||||
{ id: "mdmbsn", title: "중권역", row:1, widthPercent: 6 },
|
||||
{ id: "bscFctNm", title: "시설명", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "daddr", title: "주소", row:0, rowSpan:2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "waterUsage", title: "물사용량(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "swageChangePercent", title: "오수전환율", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "estimationSewage", title: "오수발생량 추정\n(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "sewageInputYear", title: "연간 하수유입량\n(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "sewageInputChungchun", title: "청천시 하수유입량\n(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 8 },
|
||||
const upHeadList2: TableUpperProps[] = [
|
||||
{ id: "A", title: "유역", row: 0, colSpan: 3 },
|
||||
{ id: "rvbsn", title: "권역", row: 1, widthPercent: 6 },
|
||||
{ id: "lgbsn", title: "단위유역", row: 1, widthPercent: 6 },
|
||||
{ id: "mdmbsn", title: "중권역", row: 1, widthPercent: 6 },
|
||||
{ id: "bscFctNm", title: "시설명", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "daddr", title: "주소", row: 0, rowSpan: 2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "waterUsage", title: "물사용량(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "swageChangePercent", title: "오수전환율", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "estimationSewage", title: "오수발생량 추정\n(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "sewageInputYear", title: "연간 하수유입량\n(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "sewageInputChungchun", title: "청천시 하수유입량\n(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
];
|
||||
|
||||
const upHeadList3:TableUpperProps[] = [
|
||||
{ id: "A", title: "유역", row:0, colSpan:3 },
|
||||
{ id: "rvbsn", title: "권역", row:1, widthPercent: 5 },
|
||||
{ id: "lgbsn", title: "단위유역", row:1, widthPercent: 5 },
|
||||
{ id: "mdmbsn", title: "중권역", row:1, widthPercent: 5 },
|
||||
{ id: "rgnNm", title: "환경청", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "B", title: "행정구역", row:0, colSpan:2 },
|
||||
{ id: "sidoNm", title: "시도", row:1, widthPercent: 6 },
|
||||
{ id: "sggNm", title: "시군구", row:1, widthPercent: 6 },
|
||||
{ id: "bscFctNm", title: "시설명", row:0, rowSpan:2, widthPercent: 8 },
|
||||
{ id: "daddr", title: "주소", row:0, rowSpan:2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 6 },
|
||||
{ id: "waterUsage", title: "물사용량(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 6 },
|
||||
{ id: "swageChangePercent", title: "오수전환율", align:"right", row:0, rowSpan:2, widthPercent: 6 },
|
||||
{ id: "estimationSewage", title: "오수발생량 추정\n(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 6 },
|
||||
{ id: "sewageInputYear", title: "연간 하수유입량\n(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 6 },
|
||||
{ id: "sewageInputChungchun", title: "청천시 하수유입량\n(m³/일)", align:"right", row:0, rowSpan:2, widthPercent: 6 },
|
||||
const upHeadList3: TableUpperProps[] = [
|
||||
{ id: "A", title: "유역", row: 0, colSpan: 3 },
|
||||
{ id: "rvbsn", title: "권역", row: 1, widthPercent: 5 },
|
||||
{ id: "lgbsn", title: "단위유역", row: 1, widthPercent: 5 },
|
||||
{ id: "mdmbsn", title: "중권역", row: 1, widthPercent: 5 },
|
||||
{ id: "rgnNm", title: "환경청", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "B", title: "행정구역", row: 0, colSpan: 2 },
|
||||
{ id: "sidoNm", title: "시도", row: 1, widthPercent: 6 },
|
||||
{ id: "sggNm", title: "시군구", row: 1, widthPercent: 6 },
|
||||
{ id: "bscFctNm", title: "시설명", row: 0, rowSpan: 2, widthPercent: 8 },
|
||||
{ id: "daddr", title: "주소", row: 0, rowSpan: 2 },
|
||||
{ id: "fctCpc", title: "시설용량(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 6 },
|
||||
{ id: "waterUsage", title: "물사용량(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 6 },
|
||||
{ id: "swageChangePercent", title: "오수전환율", align: "right", row: 0, rowSpan: 2, widthPercent: 6 },
|
||||
{ id: "estimationSewage", title: "오수발생량 추정\n(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 6 },
|
||||
{ id: "sewageInputYear", title: "연간 하수유입량\n(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 6 },
|
||||
{ id: "sewageInputChungchun", title: "청천시 하수유입량\n(m³/일)", align: "right", row: 0, rowSpan: 2, widthPercent: 6 },
|
||||
];
|
||||
|
||||
const upHeadListSewageOccurDetail:TableUpperProps[] = [
|
||||
const upHeadListSewageOccurDetail: TableUpperProps[] = [
|
||||
{ id: "msrDt", title: "년월" },
|
||||
{ id: "waterUsage", title: "물사용량(m³/일)", align:"right" },
|
||||
{ id: "swageChangePercent", title: "오수전환율(%)", align:"right" },
|
||||
{ id: "estimationSewage", title: "오수발생량 추정(m³/일)", row:0, rowSpan:2, align:"right" },
|
||||
{ id: "waterUsage", title: "물사용량(m³/일)", align: "right" },
|
||||
{ id: "swageChangePercent", title: "오수전환율(%)", align: "right" },
|
||||
{ id: "estimationSewage", title: "오수발생량 추정(m³/일)", row: 0, rowSpan: 2, align: "right" },
|
||||
];
|
||||
|
||||
const sewageOccurList:SewageOccurProps[] = []
|
||||
const sewageOccurList: SewageOccurProps[] = []
|
||||
|
||||
const tempSewageOccurList:modalTableType[] = []
|
||||
const tempSewageOccurList: modalTableType[] = []
|
||||
|
||||
/**
|
||||
* yyyymm 형태의 문자열을 받아 해당 월의 일수를 반환
|
||||
@@ -135,20 +132,20 @@ const tempSewageOccurList:modalTableType[] = []
|
||||
* @returns {number} 해당 월의 일수 (예: 28, 29, 30, 31)
|
||||
*/
|
||||
function getDaysInMonth(yyyymm) {
|
||||
if (typeof yyyymm !== 'string' || yyyymm.length !== 6) {
|
||||
throw new Error("입력은 'yyyymm' 형식의 문자열이어야 합니다. 예: '202502'");
|
||||
}
|
||||
if (typeof yyyymm !== 'string' || yyyymm.length !== 6) {
|
||||
throw new Error("입력은 'yyyymm' 형식의 문자열이어야 합니다. 예: '202502'");
|
||||
}
|
||||
|
||||
const year = parseInt(yyyymm.slice(0, 4), 10); // "2025" -> 2025
|
||||
const month = parseInt(yyyymm.slice(4, 6), 10); // "02" -> 2
|
||||
const year = parseInt(yyyymm.slice(0, 4), 10); // "2025" -> 2025
|
||||
const month = parseInt(yyyymm.slice(4, 6), 10); // "02" -> 2
|
||||
|
||||
if (isNaN(year) || isNaN(month) || month < 1 || month > 12) {
|
||||
throw new Error("유효한 년/월이 아닙니다.");
|
||||
}
|
||||
if (isNaN(year) || isNaN(month) || month < 1 || month > 12) {
|
||||
throw new Error("유효한 년/월이 아닙니다.");
|
||||
}
|
||||
|
||||
// Date(year, month, 0) -> 전달의 마지막 날
|
||||
// month에 '다음달'을 넣고, 일(day)에 0을 주면 해당 월의 마지막 날짜가 됨
|
||||
return new Date(year, month, 0).getDate();
|
||||
// Date(year, month, 0) -> 전달의 마지막 날
|
||||
// month에 '다음달'을 넣고, 일(day)에 0을 주면 해당 월의 마지막 날짜가 됨
|
||||
return new Date(year, month, 0).getDate();
|
||||
}
|
||||
/**====================================
|
||||
* Store - API
|
||||
@@ -174,9 +171,9 @@ function getDaysInMonth(yyyymm) {
|
||||
// }
|
||||
|
||||
// 시설들 유량 정보 조회
|
||||
export const fetchSweageOccurListFlow = async (searchYear: string|undefined, fcltCdList: string[]): Promise<SewageOccurProps | null> => {
|
||||
export const fetchSweageOccurListFlow = async (searchYear: string | undefined, fcltCdList: string[]): Promise<SewageOccurProps | null> => {
|
||||
try {
|
||||
const res = await postFetch('fo', '/fclt/flow/'+searchYear, fcltCdList);
|
||||
const res = await postFetch('fo', '/fclt/flow/' + searchYear, fcltCdList);
|
||||
return res;
|
||||
} catch (error) {
|
||||
console.error('시설정보 오수발생량 상세 데이터를 가져오는데 실패했습니다:', error);
|
||||
@@ -184,9 +181,9 @@ export const fetchSweageOccurListFlow = async (searchYear: string|undefined, fcl
|
||||
}
|
||||
};
|
||||
// 시설별 물사용량 정보 조회
|
||||
export const fetchWtrUsgYmList = async (searchYear: string|undefined, fcltCdList: string[]): Promise<WtrUsgYmProps | null> => {
|
||||
export const fetchWtrUsgYmList = async (searchYear: string | undefined, fcltCdList: string[]): Promise<WtrUsgYmProps | null> => {
|
||||
try {
|
||||
const res = await postFetch('fo', '/fclt/flow/wtrUsgYm/'+searchYear, fcltCdList);
|
||||
const res = await postFetch('fo', '/fclt/flow/wtrUsgYm/' + searchYear, fcltCdList);
|
||||
return res;
|
||||
} catch (error) {
|
||||
console.error('시설들 월별 물사용량 데이터를 가져오는데 실패했습니다:', error);
|
||||
@@ -205,10 +202,10 @@ export type SewageOccurActions = {
|
||||
export type SewageOccurType = {
|
||||
SewageOccurSearch: {
|
||||
isInit: boolean;
|
||||
labelArray:string[];
|
||||
labelArray: string[];
|
||||
},
|
||||
|
||||
SewageOccur : {
|
||||
SewageOccur: {
|
||||
isInit: boolean;
|
||||
upHeadList1: TableUpperProps[];
|
||||
upHeadList2: TableUpperProps[];
|
||||
@@ -219,7 +216,7 @@ export type SewageOccurType = {
|
||||
isLoading: boolean;
|
||||
},
|
||||
|
||||
SewageOccurDetail : {
|
||||
SewageOccurDetail: {
|
||||
isInit: boolean;
|
||||
upHeadListSewageOccurDetail: TableUpperProps[];
|
||||
gridListSewageOccurDetail: modalTableType[];
|
||||
@@ -232,18 +229,18 @@ export const sewageOccurInitState: SewageOccurType = {
|
||||
labelArray: LabelArray,
|
||||
},
|
||||
|
||||
SewageOccur : {
|
||||
isInit : false,
|
||||
upHeadList1 : upHeadList1,
|
||||
upHeadList2 : upHeadList2,
|
||||
upHeadList3 : upHeadList3,
|
||||
sewageOccurList : sewageOccurList,
|
||||
sewageOccurCount : 2,
|
||||
excelList : [],
|
||||
isLoading : true,
|
||||
SewageOccur: {
|
||||
isInit: false,
|
||||
upHeadList1: upHeadList1,
|
||||
upHeadList2: upHeadList2,
|
||||
upHeadList3: upHeadList3,
|
||||
sewageOccurList: sewageOccurList,
|
||||
sewageOccurCount: 2,
|
||||
excelList: [],
|
||||
isLoading: true,
|
||||
},
|
||||
|
||||
SewageOccurDetail : {
|
||||
SewageOccurDetail: {
|
||||
isInit: false,
|
||||
upHeadListSewageOccurDetail: upHeadListSewageOccurDetail,
|
||||
gridListSewageOccurDetail: tempSewageOccurList,
|
||||
@@ -277,69 +274,69 @@ export type FlowResponse = {
|
||||
count: number;
|
||||
}
|
||||
|
||||
export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) => {
|
||||
return {
|
||||
searchSewageOccurList: async (pageNo: number, pageSize: number, searchYear: string, part?: string, nameCd?: string, fcltCpct?: string, operationValue?: string, fcltyNm?: string) => {
|
||||
const facilityInitData = await fetchFacilityListInit(pageNo, pageSize, part, nameCd, fcltCpct, operationValue, fcltyNm);
|
||||
if(pageSize < 5000){
|
||||
if (pageSize < 5000) {
|
||||
set((state: SewageOccurType) => ({
|
||||
...state,
|
||||
SewageOccur: {
|
||||
...state.SewageOccur,
|
||||
sewageOccurList : [],
|
||||
sewageOccurCount : facilityInitData.count,
|
||||
excelList : [],
|
||||
sewageOccurList: [],
|
||||
sewageOccurCount: facilityInitData.count,
|
||||
excelList: [],
|
||||
isLoading: true
|
||||
},
|
||||
}));
|
||||
}else{
|
||||
} else {
|
||||
set((state: SewageOccurType) => ({
|
||||
...state,
|
||||
SewageOccur: {
|
||||
...state.SewageOccur,
|
||||
excelList : [],
|
||||
excelList: [],
|
||||
isLoading: true
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
const fcltylist = facilityInitData.data; // 시설목록
|
||||
const fcltCdList : string[] = []; // 시설코드목록
|
||||
const sewageOccurPropsList : SewageOccurProps[] = []; // 오수발생량시설목록
|
||||
const fcltCdList: string[] = []; // 시설코드목록
|
||||
const sewageOccurPropsList: SewageOccurProps[] = []; // 오수발생량시설목록
|
||||
fcltylist.forEach(item => {
|
||||
fcltCdList.push(item.bscFctCd);
|
||||
sewageOccurPropsList.push({
|
||||
bscFctCd : item.bscFctCd,
|
||||
sidoNm : item.sido,
|
||||
sggNm : item.gugun,
|
||||
lclgvrnmntNm : '',
|
||||
bscFctNm : item.bscFctNm,
|
||||
daddr : item.daddr,
|
||||
fctCpc : parseFloat(item.fctCpc.toString().replace(/,/g, '')),
|
||||
waterUsage : 0,
|
||||
swageChangePercent : 0,
|
||||
estimationSewage : 0,
|
||||
sewageInputYear : 0,
|
||||
sewageInputChungchun : 0,
|
||||
rgnNm : item.rgnNm,
|
||||
rvbsn : item.rvbsn,
|
||||
lgbsn : item.lgbsn,
|
||||
mdmbsn : item.mdmbsn,
|
||||
msrDt : '',
|
||||
bscFctCd: item.bscFctCd,
|
||||
sidoNm: item.sido,
|
||||
sggNm: item.gugun,
|
||||
lclgvrnmntNm: '',
|
||||
bscFctNm: item.bscFctNm,
|
||||
daddr: item.daddr,
|
||||
fctCpc: parseFloat(item.fctCpc.toString().replace(/,/g, '')),
|
||||
waterUsage: 0,
|
||||
swageChangePercent: 0,
|
||||
estimationSewage: 0,
|
||||
sewageInputYear: 0,
|
||||
sewageInputChungchun: 0,
|
||||
rgnNm: item.rgnNm,
|
||||
rvbsn: item.rvbsn,
|
||||
lgbsn: item.lgbsn,
|
||||
mdmbsn: item.mdmbsn,
|
||||
msrDt: '',
|
||||
});
|
||||
});
|
||||
|
||||
const soccurDetailRes : any = await fetchSweageOccurListFlow(searchYear, fcltCdList);
|
||||
const wtrUsgYmRes : any = await fetchWtrUsgYmList(searchYear, fcltCdList);
|
||||
|
||||
const soccurDetailRes: any = await fetchSweageOccurListFlow(searchYear, fcltCdList);
|
||||
const wtrUsgYmRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList);
|
||||
// const wtrUsgMap : Record<string, number> = {};
|
||||
// wtrUsgRes.data.forEach(fclt => {
|
||||
// wtrUsgMap[fclt.bscFctCd] = fclt.wtrUsg;
|
||||
// });
|
||||
for (const item of sewageOccurPropsList) {
|
||||
|
||||
|
||||
const detailList = soccurDetailRes?.data[item.bscFctCd];
|
||||
const wtrUsgYmList = wtrUsgYmRes?.data[item.bscFctCd];
|
||||
|
||||
|
||||
item.swageChangePercent = 90;
|
||||
let sumChungcunDay = 0; // 청천일수
|
||||
let chungcunSumFlow = 0;// 청천시 하수유입량
|
||||
@@ -348,18 +345,18 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
detailList?.forEach(item2 => {
|
||||
|
||||
if (item2.infoRnDay == null || item2.infoRnDay == 'x') item2.infoRnDay = 0;
|
||||
if(item2.infoRnDay >= 3) {
|
||||
if (item2.infoRnDay >= 3) {
|
||||
rainEffectDay = 2;
|
||||
}else{
|
||||
} else {
|
||||
rainEffectDay--;
|
||||
}
|
||||
if(rainEffectDay<0){ //청천시
|
||||
if (rainEffectDay < 0) { //청천시
|
||||
chungcunSumFlow += item2.inflAmnt && item2.inflAmnt !== 'x' ? Number(item2.inflAmnt.toString().trim()) : 0;//Number(item2.inflAmnt);
|
||||
sumChungcunDay += 1;
|
||||
}
|
||||
totWaterUsage += Number(item2.inflAmnt);
|
||||
});
|
||||
|
||||
|
||||
let wtrUsgYearTotal = 0; // 연간 물사용량
|
||||
let wtrUsgYearDays = 0; // 연간 물사용 일수
|
||||
wtrUsgYmList?.forEach(item3 => {
|
||||
@@ -372,13 +369,13 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
const count = detailList ? detailList.length : 0;
|
||||
const avg = count == 0 ? 0 : totWaterUsage / count; // 일평균 유입량
|
||||
item.waterUsage = parseFloat((avg * 0.65).toFixed(2)); // 물사용량 = 일평균 유입량 * 65%
|
||||
if(wtrUsgYearTotal > 0 && wtrUsgYearDays > 0) {
|
||||
item.waterUsage = wtrUsgYearDays>0? wtrUsgYearTotal / wtrUsgYearDays: 0; // 일평균 물사용량
|
||||
}
|
||||
if (wtrUsgYearTotal > 0 && wtrUsgYearDays > 0) {
|
||||
item.waterUsage = wtrUsgYearDays > 0 ? wtrUsgYearTotal / wtrUsgYearDays : 0; // 일평균 물사용량
|
||||
}
|
||||
item.sewageInputYear = parseFloat(avg.toFixed(2)); // 연간 하수유입량(m³/일)
|
||||
item.sewageInputChungchun = parseFloat((chungcunSumFlow===0?0:(chungcunSumFlow / sumChungcunDay)).toFixed(2)); // 청천시 하수유입량
|
||||
item.sewageInputChungchun = parseFloat((chungcunSumFlow === 0 ? 0 : (chungcunSumFlow / sumChungcunDay)).toFixed(2)); // 청천시 하수유입량
|
||||
item.estimationSewage = parseFloat((item.waterUsage * OSU_PERCENT).toFixed(2)); // 오수발생량 추정(m³/일)
|
||||
if ( item.bscFctCd === '11200PB001R' ) {
|
||||
if (item.bscFctCd === '11200PB001R') {
|
||||
console.log('chungcunSumFlow:', chungcunSumFlow);
|
||||
console.log('sumChungcunDay:', sumChungcunDay);
|
||||
}
|
||||
@@ -388,7 +385,7 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
);
|
||||
}
|
||||
|
||||
if(pageSize >= 5000){
|
||||
if (pageSize >= 5000) {
|
||||
const excelDownList: ExcelType[] = [];
|
||||
sewageOccurPropsList.forEach((item: SewageOccurProps) => {
|
||||
excelDownList.push({
|
||||
@@ -414,16 +411,16 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
SewageOccur: {
|
||||
...state.SewageOccur,
|
||||
excelList: excelDownList,
|
||||
isLoading : false,
|
||||
isLoading: false,
|
||||
},
|
||||
}));
|
||||
}else{
|
||||
} else {
|
||||
set((state: SewageOccurType) => ({
|
||||
...state,
|
||||
SewageOccur: {
|
||||
...state.SewageOccur,
|
||||
sewageOccurList : sewageOccurPropsList,
|
||||
sewageOccurCount : facilityInitData.count,
|
||||
sewageOccurList: sewageOccurPropsList,
|
||||
sewageOccurCount: facilityInitData.count,
|
||||
isLoading: false,
|
||||
excelList: [],
|
||||
},
|
||||
@@ -516,12 +513,12 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
|
||||
searchSewageOccurDetailList: async (bscFctCd: string, searchYear: string, startYm?: string, endYm?: string) => {
|
||||
const fcltCdList = [bscFctCd];
|
||||
const wtrUsgRes : any = await fetchWtrUsgYmList(searchYear, fcltCdList);
|
||||
const wtrUsgRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList);
|
||||
const res = await getFetch('fo', '/fclt/flow/' + bscFctCd + '/' + searchYear);
|
||||
const monthData: SewageOccurDetailProps[] = [];
|
||||
let tot = 0, cnt= 0;
|
||||
let tot = 0, cnt = 0;
|
||||
|
||||
if(startYm) {
|
||||
if (startYm) {
|
||||
res.data = res.data.filter((item: FlowDataItem) => {
|
||||
const month = item.msrDt?.substring(0, 6);
|
||||
return month >= startYm;
|
||||
@@ -533,7 +530,7 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
if(endYm) {
|
||||
if (endYm) {
|
||||
res.data = res.data.filter((item: FlowDataItem) => {
|
||||
const month = item.msrDt?.substring(0, 6);
|
||||
return month <= endYm;
|
||||
@@ -555,8 +552,10 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
monthData[monthIdx].sum += Number(item.inflAmnt);
|
||||
monthData[monthIdx].cnt++;
|
||||
} else {
|
||||
monthData[monthIdx] = {cnt:1, sum:Number(item.inflAmnt), yr:item.msrDt.substring(0,4)
|
||||
, usage:0, cntWtrUsg:0, sumWtrUsg:0, avgWtrUsg:0, monWtrUsg:0};
|
||||
monthData[monthIdx] = {
|
||||
cnt: 1, sum: Number(item.inflAmnt), yr: item.msrDt.substring(0, 4)
|
||||
, usage: 0, cntWtrUsg: 0, sumWtrUsg: 0, avgWtrUsg: 0, monWtrUsg: 0
|
||||
};
|
||||
}
|
||||
}
|
||||
tot += Number(item.inflAmnt)
|
||||
@@ -574,29 +573,29 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
if (typeof monthData[monthIdx] === 'object') {
|
||||
monthData[monthIdx].sumWtrUsg += Number(item.wtrUsg);
|
||||
monthData[monthIdx].cntWtrUsg += getDaysInMonth(item.levyYm);
|
||||
}
|
||||
}
|
||||
}
|
||||
totWtrUsg += Number(item.wtrUsg);
|
||||
cntWtrUsg += getDaysInMonth(item.levyYm);
|
||||
});
|
||||
}
|
||||
|
||||
const tableData:modalTableType[] = []
|
||||
|
||||
const tableData: modalTableType[] = []
|
||||
|
||||
let maxWaterUsage = 0;
|
||||
let minWaterUsage = 9999999999;
|
||||
let avgWaterUsage = 0;
|
||||
monthData.forEach((item, index) => {
|
||||
item.avgWtrUsg = item.sum/item.cnt *0.65; // 일평균 물사용량 = 일평균유입수 * 0.65
|
||||
item.avgWtrUsg = item.sum / item.cnt * 0.65; // 일평균 물사용량 = 일평균유입수 * 0.65
|
||||
if (item.sumWtrUsg > 0 && item.cntWtrUsg > 0) item.avgWtrUsg = item.sumWtrUsg / item.cntWtrUsg;
|
||||
tableData.push({
|
||||
msrDt: item.yr+'-'+(index+1>=10?String(index+1):'0'+(index+1)),
|
||||
waterUsage: Math.round(item.avgWtrUsg*1) /1,
|
||||
swageChangePercent: OSU_PERCENT*100,//(Math.round((item.usage/item.usage*OSU_PERCENT) * 100) / 100) * 100,
|
||||
estimationSewage: Math.round(item.avgWtrUsg*OSU_PERCENT * 1) / 1
|
||||
msrDt: item.yr + '-' + (index + 1 >= 10 ? String(index + 1) : '0' + (index + 1)),
|
||||
waterUsage: Math.round(item.avgWtrUsg * 1) / 1,
|
||||
swageChangePercent: OSU_PERCENT * 100,//(Math.round((item.usage/item.usage*OSU_PERCENT) * 100) / 100) * 100,
|
||||
estimationSewage: Math.round(item.avgWtrUsg * OSU_PERCENT * 1) / 1
|
||||
})
|
||||
if (item.avgWtrUsg > maxWaterUsage) {
|
||||
maxWaterUsage = item.avgWtrUsg;
|
||||
maxWaterUsage = item.avgWtrUsg;
|
||||
}
|
||||
|
||||
if (item.avgWtrUsg < minWaterUsage) {
|
||||
@@ -604,29 +603,29 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
|
||||
}
|
||||
|
||||
});
|
||||
avgWaterUsage = tot/cnt*0.65
|
||||
avgWaterUsage = tot / cnt * 0.65
|
||||
if (totWtrUsg > 0 && cntWtrUsg > 0) avgWaterUsage = totWtrUsg / cntWtrUsg;
|
||||
|
||||
const newData= [
|
||||
{
|
||||
msrDt: '평균',
|
||||
waterUsage: roundNumber(Math.round(avgWaterUsage*1) /1,0),
|
||||
swageChangePercent: OSU_PERCENT*100,
|
||||
estimationSewage: roundNumber(Math.round(avgWaterUsage*OSU_PERCENT*1) /1,0),
|
||||
},
|
||||
{
|
||||
msrDt: '최대',
|
||||
waterUsage: roundNumber(Math.round(maxWaterUsage*100) /100,0),
|
||||
swageChangePercent: OSU_PERCENT*100,
|
||||
estimationSewage: roundNumber(Math.round(maxWaterUsage*OSU_PERCENT*1) /1, 0),
|
||||
},
|
||||
{
|
||||
msrDt: '최소',
|
||||
waterUsage: roundNumber(Math.round(minWaterUsage*100) /100,0),
|
||||
swageChangePercent: OSU_PERCENT*100,
|
||||
estimationSewage: roundNumber(Math.round(minWaterUsage*OSU_PERCENT*1) /1,0),
|
||||
},
|
||||
...tableData
|
||||
const newData = [
|
||||
{
|
||||
msrDt: '평균',
|
||||
waterUsage: roundNumber(Math.round(avgWaterUsage * 1) / 1, 0),
|
||||
swageChangePercent: OSU_PERCENT * 100,
|
||||
estimationSewage: roundNumber(Math.round(avgWaterUsage * OSU_PERCENT * 1) / 1, 0),
|
||||
},
|
||||
{
|
||||
msrDt: '최대',
|
||||
waterUsage: roundNumber(Math.round(maxWaterUsage * 100) / 100, 0),
|
||||
swageChangePercent: OSU_PERCENT * 100,
|
||||
estimationSewage: roundNumber(Math.round(maxWaterUsage * OSU_PERCENT * 1) / 1, 0),
|
||||
},
|
||||
{
|
||||
msrDt: '최소',
|
||||
waterUsage: roundNumber(Math.round(minWaterUsage * 100) / 100, 0),
|
||||
swageChangePercent: OSU_PERCENT * 100,
|
||||
estimationSewage: roundNumber(Math.round(minWaterUsage * OSU_PERCENT * 1) / 1, 0),
|
||||
},
|
||||
...tableData
|
||||
]
|
||||
|
||||
set((state: SewageOccurType) => ({
|
||||
|
||||
Reference in New Issue
Block a user