851 lines
32 KiB
TypeScript
851 lines
32 KiB
TypeScript
import { getFetch } from "@/app/components/api";
|
|
import DataForm from "@/app/components/common/DataForm";
|
|
import type { TableUpperProps } from "../dashboard";
|
|
export type { TableUpperProps };
|
|
|
|
/**====================================
|
|
* Store - 타입
|
|
====================================*/
|
|
|
|
/**
|
|
* (1) 메인페이지
|
|
*/
|
|
// 처리시설 리스트
|
|
export type facilityListProps = {
|
|
bscFctCd : string,
|
|
bscFctNm : string,
|
|
bscFctClsNm : string,
|
|
sido : string,
|
|
gugun : string,
|
|
daddr : string,
|
|
fctCpc : number | string | '',
|
|
plInflWqltBod : number | string | '',
|
|
dsInflWqltBod : number | string | '',
|
|
trtFrfNm : string,
|
|
rnDt : string,
|
|
cmplDt : string,
|
|
trstOprEtpNm : string,
|
|
rvbsn : string,
|
|
mdmbsn : string,
|
|
lgbsn : string,
|
|
rgnNm : string,
|
|
mnstr : string,
|
|
efflWtrrgn : string,
|
|
efflWqltStndrdNm : string
|
|
}
|
|
|
|
export interface ExcelType {
|
|
시설코드: string,
|
|
권역:string|'',
|
|
단위유역:string|'',
|
|
중권역:string|'',
|
|
환경청:string|'',
|
|
시도: string,
|
|
시군구: string,
|
|
시설이름: string,
|
|
주소: string,
|
|
시설용량: number | '',
|
|
계획유입수질: number | '',
|
|
설계유입수질: number | '',
|
|
공법: string,
|
|
가동개시일: string,
|
|
준공일: string,
|
|
관리대행업자: string,
|
|
}
|
|
|
|
// (2) 처리시설 팝업
|
|
// 시설 기본정보
|
|
export type BasicInfoProps = {
|
|
bscFctNm : string,
|
|
fctCpc : number | '',
|
|
sido : string,
|
|
gugun : string,
|
|
startDay : string,
|
|
addr : string,
|
|
cmplDt : string,
|
|
trtFrfNm : string,
|
|
trstOprEtpNm : string,
|
|
}
|
|
|
|
// 시설 계획정보
|
|
export type PlanInfoProps = {
|
|
plInflWqltBod? : string,
|
|
plInflWqltToc? : string,
|
|
plInflWqltCod? : string,
|
|
plInflWqltSs? : string,
|
|
plInflWqltTn? : string,
|
|
plInflWqltTp? : string,
|
|
dsInflWqltBod? : string,
|
|
dsInflWqltToc? : string,
|
|
dsInflWqltCod? : string,
|
|
dsInflWqltSs? : string,
|
|
dsInflWqltTn? : string,
|
|
dsInflWqltTp? : string,
|
|
sitArea? : string | number,
|
|
trtDstrArea? : string | number,
|
|
swrTrtPopl? : string | number
|
|
}
|
|
|
|
// 시설 계획정보
|
|
export type LegalWaterQltyProps = {
|
|
totClfgrpcnt : number,
|
|
bod : number,
|
|
cod : number,
|
|
ss : number,
|
|
tn : number,
|
|
tp : number
|
|
}
|
|
|
|
// 시설 수역 및 구역정보
|
|
export type fcltyAreaInfoProps = {
|
|
rvbsn : string,
|
|
efflWtrrgn : string,
|
|
lgbsn : string,
|
|
efflWqltStndrdNm : string,
|
|
rgnNm : string,
|
|
}
|
|
|
|
// 시설 이력관리
|
|
export type fcltyHistInfoProps = {
|
|
extnsSeqno : string,
|
|
extnsNm : string,
|
|
bzStrtYrMnth : string,
|
|
bzEdYrMnth : string,
|
|
eqpPrmsDt : string,
|
|
cmplDt : string,
|
|
trlrnCmplDt : string,
|
|
rnDt : string,
|
|
sitArea : number,
|
|
trtDstrArea : number,
|
|
swrTrtPopl : number
|
|
}
|
|
|
|
// 시설 수질정보
|
|
export type fcltyWaterQltyInfoProps = {
|
|
extnsSeqno : string,
|
|
plInflWqltBod : string,
|
|
plInflWqltToc : string,
|
|
plInflWqltCod : string,
|
|
plInflWqltSs : string,
|
|
plInflWqltTn : string,
|
|
plInflWqltTp : string,
|
|
dsInflWqltBod : string,
|
|
dsInflWqltToc : string,
|
|
dsInflWqltCod : string,
|
|
dsInflWqltSs : string,
|
|
dsInflWqltTn : string,
|
|
dsInflWqltTp : string,
|
|
plEfflWqltBod : string,
|
|
plEfflWqltToc : string,
|
|
plEfflWqltCod : string,
|
|
plEfflWqltSs : string,
|
|
plEfflWqltTn : string,
|
|
plEfflWqltTp : string,
|
|
bod : number,
|
|
cod : number,
|
|
ss : number,
|
|
tn : number,
|
|
tp : number,
|
|
totClfgrpcnt : number,
|
|
}
|
|
|
|
/**====================================
|
|
* Store - data
|
|
====================================*/
|
|
|
|
/**
|
|
* (1) 메인페이지
|
|
*/
|
|
// 검색단
|
|
const ProcessFacilityLabelArray:string[] = ['구분', '시도', '시군구','용량별', '시설명', '시설상태', '시설구분', '권역', '단위유역', '중권역', '환경청별'];
|
|
|
|
// 리스트 헤더
|
|
const upHeadList1:TableUpperProps[] = [
|
|
{ id: "bscFctCd", title: "시설코드"},
|
|
{ id: "sido", title: "시도", upName:"upChangeRe", upSequnce:1 },
|
|
{ id: "gugun", title: "시군구", upName:"upChangeRe",upSequnce:2 },
|
|
{ id: "bscFctNm", title: "시설명"},
|
|
{ id: "daddr", title: "주소"},
|
|
{ id: "fctCpc", title: "시설용량\n(m³/일)", align: 'right'},
|
|
{ id: "plInflWqltBod", title: "계획유입수질\n(mg/L)", align:"right"},
|
|
{ id: "dsInflWqltBod", title: "설계유입수질\n(mg/L)", align:"right"},
|
|
{ id: "trtFrfNm", title: '공법'},
|
|
{ id: "rnDt", title: '가동개시일'},
|
|
{ id: "cmplDt", title: '준공일' },
|
|
{ id: "trstOprEtpNm", title: '관리대행업자'}
|
|
];
|
|
|
|
// 처리시설 리스트 (유역)
|
|
const upHeadList2:TableUpperProps[] = [
|
|
{ id: "bscFctCd", title: "시설코드"},
|
|
{ id: "rvbsn", title: "권역", upName:"upChangeRe", upSequnce:1},
|
|
{ id: "lgbsn", title: "단위유역", upName:"upChangeRe", upSequnce:2},
|
|
{ id: "mdmbsn", title: "중권역", upName:"upChangeRe", upSequnce:3},
|
|
{ id: "bscFctNm", title: "시설명"},
|
|
{ id: "daddr", title: "주소"},
|
|
{ id: "fctCpc", title: "시설용량\n(m³/일)", align: 'right'},
|
|
{ id: "plInflWqltBod", title: "계획유입수질\n(mg/L)", align:'right'},
|
|
{ id: "dsInflWqltBod", title: "설계유입수질\n(mg/L)", align:'right'},
|
|
{ id: "trtFrfNm", title: '공법'},
|
|
{ id: "rnDt", title: '가동개시일'},
|
|
{ id: "cmplDt", title: '준공일' },
|
|
{ id: "trstOprEtpNm", title: '관리대행업자'}
|
|
];
|
|
|
|
// 처리시설 리스트 (환경청청)
|
|
const upHeadList3:TableUpperProps[] = [
|
|
{ id: "bscFctCd", title: "시설코드"},
|
|
{ id: "rvbsn", title: "권역", upName:"upChangeRe1", upSequnce:1},
|
|
{ id: "lgbsn", title: "단위유역", upName:"upChangeRe1", upSequnce:2},
|
|
{ id: "mdmbsn", title: "중권역", upName:"upChangeRe1", upSequnce:3},
|
|
{ id: "rgnNm", title: "환경청"},
|
|
{ id: "sido", title: "시도", upName:"upChangeRe2", upSequnce:1 },
|
|
{ id: "gugun", title: "시군구", upName:"upChangeRe2",upSequnce:2 },
|
|
{ id: "bscFctNm", title: "시설명"},
|
|
{ id: "daddr", title: "주소"},
|
|
{ id: "fctCpc", title: "시설용량\n(m³/일)", align: 'right'},
|
|
{ id: "plInflWqltBod", title: "계획유입수질\n(mg/L)", align:'right'},
|
|
{ id: "dsInflWqltBod", title: "설계유입수질\n(mg/L)", align:'right'},
|
|
{ id: "trtFrfNm", title: '공법'},
|
|
{ id: "rnDt", title: '가동개시일'},
|
|
{ id: "cmplDt", title: '준공일' },
|
|
{ id: "trstOprEtpNm", title: '관리대행업자'}
|
|
];
|
|
|
|
const processFacilityList:facilityListProps[] = [
|
|
]
|
|
|
|
/**
|
|
* 처리시설 상세팝업
|
|
*/
|
|
// 시설 기본정보 (헤더)
|
|
const upHeadListBasicInfo:TableUpperProps[] = [
|
|
{ id: "bscFctNm", title: "시설명" },
|
|
{ id: "fctCpc", title: "시설용량n(m³/일)", align: 'right'},
|
|
{ id: "sido", title: "시도"},
|
|
{ id: "gugun", title: "시군구"},
|
|
{ id: "rnDt", title: "가동개시일"},
|
|
{ id: "daddr", title: "주소"},
|
|
{ id: "cmplDt", title: "준공일"},
|
|
{ id: "trtFrfNm", title: "공법"},
|
|
{ id: "trstOprEtpNm", title: "관리대행업자"},
|
|
];
|
|
|
|
// 시설 기본정보 (리스트)
|
|
const gridListBasicInfo:BasicInfoProps[] = [
|
|
{
|
|
bscFctNm : "난지",
|
|
fctCpc : 860000,
|
|
sido : "서울특별시",
|
|
gugun : "",
|
|
startDay : "1987-06-30",
|
|
addr : "경기도 고양시 덕양구 대덕로 426 (현천동)",
|
|
cmplDt : "2013-04-30",
|
|
trtFrfNm : "MLE, A2O",
|
|
trstOprEtpNm : "자체",
|
|
}
|
|
];
|
|
|
|
// 시설 법적방류수질 (헤더)
|
|
const upHeadListLegalWaterQlty:TableUpperProps[] = [
|
|
{ id: "bod", title: "BOD(mg/L)", align: 'right'},
|
|
{ id: "cod", title: "TOC(COD)(mg/L)", align: 'right'},
|
|
{ id: "ss", title: "SS(mg/L)", align: 'right'},
|
|
{ id: "tn", title: "T-N(mg/L)", align: 'right'},
|
|
{ id: "tp", title: "T-P(mg/L) ", align: 'right'},
|
|
{ id: "totClfgrpcnt", title: "대장균군(개/100ml)"},
|
|
]
|
|
|
|
// 시설 법적방류수질 (리스트)
|
|
let gridListLegalWaterQlty:LegalWaterQltyProps[] = [
|
|
]
|
|
|
|
// 시설 계획정보 (헤더)
|
|
const upHeadListPlanInfo:TableUpperProps[] = [
|
|
{ id: "plInflWqltBod", title: "BOD", upName:"upChangeRe1", upSequnce:1, align: 'right' },
|
|
{ id: "plInflWqltToc", title: "TOC", upName:"upChangeRe1", upSequnce:2, align: 'right' },
|
|
{ id: "plInflWqltCod", title: "COD", upName:"upChangeRe1", upSequnce:3, align: 'right' },
|
|
{ id: "plInflWqltSs", title: "SS", upName:"upChangeRe1", upSequnce:4, align: 'right' },
|
|
{ id: "plInflWqltTn", title: "T-N", upName:"upChangeRe1", upSequnce:5, align: 'right' },
|
|
{ id: "plInflWqltTp", title: "T-P", upName:"upChangeRe1", upSequnce:6, align: 'right' },
|
|
{ id: "dsInflWqltBod", title: "BOD", upName:"upChangeRe2", upSequnce:1, align: 'right' },
|
|
{ id: "dsInflWqltToc", title: "TOC", upName:"upChangeRe2", upSequnce:2, align: 'right' },
|
|
{ id: "dsInflWqltCod", title: "COD", upName:"upChangeRe2", upSequnce:3, align: 'right' },
|
|
{ id: "dsInflWqltSs", title: "SS", upName:"upChangeRe2", upSequnce:4, align: 'right' },
|
|
{ id: "dsInflWqltTn", title: "T-N", upName:"upChangeRe2", upSequnce:5, align: 'right' },
|
|
{ id: "dsInflWqltTp", title: "T-P", upName:"upChangeRe2", upSequnce:6, align: 'right' },
|
|
{ id: "sitArea", title: "부지면적\n(m²)", align: 'right'},
|
|
{ id: "trtDstrArea", title: "처리구역면적\n(ha)", align: 'right'},
|
|
{ id: "swrTrtPopl", title: "하수처리인구\n(인)", align: 'right'},
|
|
];
|
|
|
|
// 시설 계획정보 (리스트)
|
|
const gridListPlanInfo:PlanInfoProps[] = [
|
|
{
|
|
plInflWqltBod : "179.0",
|
|
plInflWqltToc : "90.0",
|
|
plInflWqltCod : "0.0",
|
|
plInflWqltSs : "132.0",
|
|
plInflWqltTn : "38.000",
|
|
plInflWqltTp : "4.300",
|
|
dsInflWqltBod : "178.0",
|
|
dsInflWqltToc : "91.0",
|
|
dsInflWqltCod : "0.0",
|
|
dsInflWqltSs : "131.0",
|
|
dsInflWqltTn : "40.200",
|
|
dsInflWqltTp : "4.500",
|
|
sitArea : "928,574",
|
|
trtDstrArea : "7,994.0",
|
|
swrTrtPopl : "1,573,277",
|
|
}
|
|
];
|
|
|
|
// 시설 수역 및 구역정보 (헤더)
|
|
const upHeadListFcltyAreaInfo:TableUpperProps[] = [
|
|
{ id: "rvbsn", title: "하천명" },
|
|
{ id: "efflWtrrgn", title: "방류수역"},
|
|
{ id: "lgbsn", title: "단위유역"},
|
|
{ id: "efflWqltStndrdNm", title: "지역구분"},
|
|
{ id: "rgnNm", title: "관할 유역(지방) 환경청"}
|
|
];
|
|
|
|
// 시설 수역 및 구역정보 (리스트)
|
|
const gridListFcltyAreaInfo:fcltyAreaInfoProps[] = [
|
|
{
|
|
rvbsn : "한강",
|
|
efflWtrrgn : "한강수계",
|
|
lgbsn : "한강본류",
|
|
efflWqltStndrdNm : "500톤 이상\n(Ⅲ지역)",
|
|
rgnNm : "한강유역환경청"
|
|
}
|
|
];
|
|
|
|
// 시설 이력관리 (헤더)
|
|
const upHeadListFcltyHistInfo:TableUpperProps[] = [
|
|
{ id: "extnsSeqno", title: "차수", align: 'center' },
|
|
{ id: "extnsNm", title: "구분"},
|
|
{ id: "bzStrtYrMnth", title: "사업기간", upName:"upChangeRe1", upSequnce:1},
|
|
{ id: "bzEdYrMnth", title: "사업기간", upName:"upChangeRe1", upSequnce:2},
|
|
{ id: "eqpPrmsDt", title: "설치인가일"},
|
|
{ id: "cmplDt", title: "준공일"},
|
|
{ id: "trlrnCmplDt", title: "시운전완료일"},
|
|
{ id: "rnDt", title: "가동개시일"},
|
|
];
|
|
|
|
// 시설 이력관리 (리스트)
|
|
const gridListFcltyHistInfo:fcltyHistInfoProps[] = [
|
|
{
|
|
extnsSeqno : "최초",
|
|
extnsNm : "최초",
|
|
bzStrtYrMnth : "1984.12.01",
|
|
bzEdYrMnth : "1987.06.01",
|
|
eqpPrmsDt : "1985.09.13",
|
|
cmplDt : "1987.06.30",
|
|
trlrnCmplDt : "1987.06.30",
|
|
rnDt : "1987.06.30",
|
|
sitArea : 0,
|
|
trtDstrArea : 0,
|
|
swrTrtPopl : 0,
|
|
}
|
|
];
|
|
|
|
// 시설 수질정보 (헤더)
|
|
const upHeadListFcltyWaterQltyInfo:TableUpperProps[] = [
|
|
{ id: "extnsSeqno", title: "차수" },
|
|
{ id: "plInflWqltBod", title: "BOD", upName:"upChangeRe1", upSequnce:1, align: 'right' },
|
|
{ id: "plInflWqltToc", title: "TOC", upName:"upChangeRe1", upSequnce:2, align: 'right' },
|
|
{ id: "plInflWqltCod", title: "COD", upName:"upChangeRe1", upSequnce:3, align: 'right' },
|
|
{ id: "plInflWqltSs", title: "SS", upName:"upChangeRe1", upSequnce:4, align: 'right' },
|
|
{ id: "plInflWqltTn", title: "T-N", upName:"upChangeRe1", upSequnce:5, align: 'right' },
|
|
{ id: "plInflWqltTp", title: "T-P", upName:"upChangeRe1", upSequnce:6, align: 'right' },
|
|
{ id: "dsInflWqltBod", title: "BOD", upName:"upChangeRe2", upSequnce:1, align: 'right' },
|
|
{ id: "dsInflWqltToc", title: "TOC", upName:"upChangeRe2", upSequnce:2, align: 'right' },
|
|
{ id: "dsInflWqltCod", title: "COD", upName:"upChangeRe2", upSequnce:3, align: 'right' },
|
|
{ id: "dsInflWqltSs", title: "SS", upName:"upChangeRe2", upSequnce:4, align: 'right' },
|
|
{ id: "dsInflWqltTn", title: "T-N", upName:"upChangeRe2", upSequnce:5, align: 'right' },
|
|
{ id: "dsInflWqltTp", title: "T-P", upName:"upChangeRe2", upSequnce:6, align: 'right' },
|
|
{ id: "plEfflWqltBod", title: "BOD", upName:"upChangeRe3", upSequnce:1, align: 'right' },
|
|
{ id: "plEfflWqltToc", title: "TOC", upName:"upChangeRe3", upSequnce:2, align: 'right' },
|
|
{ id: "plEfflWqltCod", title: "COD", upName:"upChangeRe3", upSequnce:3, align: 'right' },
|
|
{ id: "plEfflWqltSs", title: "SS", upName:"upChangeRe3", upSequnce:4, align: 'right' },
|
|
{ id: "plEfflWqltTn", title: "T-N", upName:"upChangeRe3", upSequnce:5, align: 'right' },
|
|
{ id: "plEfflWqltTp", title: "T-P", upName:"upChangeRe3", upSequnce:6, align: 'right' },
|
|
];
|
|
|
|
// 시설 수질정보 (리스트)
|
|
const gridListFcltyWaterQltyInfo:fcltyWaterQltyInfoProps[] = [
|
|
{
|
|
extnsSeqno: "최초",
|
|
plInflWqltBod: "111.0",
|
|
plInflWqltToc: "(0.0)",
|
|
plInflWqltCod: "(0.0)",
|
|
plInflWqltSs: "122.0",
|
|
plInflWqltTn: "0.000",
|
|
plInflWqltTp: "0.000",
|
|
dsInflWqltBod: "111.0",
|
|
dsInflWqltToc: "(0.0)",
|
|
dsInflWqltCod: "(0.0)",
|
|
dsInflWqltSs: "122.0",
|
|
dsInflWqltTn: "0.000",
|
|
dsInflWqltTp: "0.000",
|
|
plEfflWqltBod: "20.0",
|
|
plEfflWqltCod: "(0.0)",
|
|
plEfflWqltToc: "(0.0)",
|
|
plEfflWqltSs: "12.0",
|
|
plEfflWqltTn: "0.000",
|
|
plEfflWqltTp: "0.000",
|
|
bod: 0,
|
|
cod: 0,
|
|
ss: 0,
|
|
tn: 0,
|
|
tp: 0,
|
|
totClfgrpcnt: 0
|
|
}
|
|
];
|
|
|
|
/**====================================
|
|
* Store - api (데이터 호출)
|
|
====================================*/
|
|
|
|
// 시설정보 리스트 데이터 호출(구분 선택 후 시설명 있을 경우)
|
|
const fetchFacilityList = async (pageNo:number, pageSize:number, partValue?:string, nameCd?:string, fcltCpct?:string, oprtngSttsCd?:string, facilityPartValue?:string, facilityName?:string ): Promise<{data:facilityListProps[], count:number}> => {
|
|
try {
|
|
const tailStr = partValue ? '/'+ (partValue==='G' ? 'A' : partValue) + '/' + nameCd + '/' + fcltCpct + '/' + oprtngSttsCd + '/' + facilityPartValue + (facilityName && facilityName !== '' ? '/' + facilityName : '') : '';
|
|
const url = '/prcsFclt/info/history/'+pageNo+'/'+pageSize+tailStr;
|
|
//const res = await getFetch('fo', '/prcsFclt/info/'+pageNo+'/'+pageSize+tailUrl);
|
|
const res = await getFetch('fo', url);
|
|
return res;
|
|
} catch (error) {
|
|
console.error('시설정보 데이터를 가져오는데 실패했습니다:', error);
|
|
return {data: [], count: 0};
|
|
}
|
|
};
|
|
|
|
// 시설정보 리스트 데이터 호출 (대시보드용)
|
|
const fetchFacilityListSearching = async (pageNo:number, pageSize:number, partValue?:string, nameCd?:string, fcltCpct?:string, oprtngSttsCd?:string, facilityPartValue?:string, facilityName?:string ): Promise<{data:facilityListProps[], count:number}> => {
|
|
try {
|
|
const tailStr = partValue ? '/'+ (partValue==='G' ? 'A' : partValue) + '/' + nameCd + '/' + fcltCpct + '/' + oprtngSttsCd + '/' + facilityPartValue + (facilityName && facilityName !== '' ? '/' + facilityName : '') : '';
|
|
const url = '/prcsFclt/searching/'+pageNo+'/'+pageSize+tailStr;
|
|
//const res = await getFetch('fo', '/prcsFclt/info/'+pageNo+'/'+pageSize+tailUrl);
|
|
const res = await getFetch('fo', url);
|
|
return res;
|
|
} catch (error) {
|
|
console.error('시설정보 데이터를 가져오는데 실패했습니다:', error);
|
|
return {data: [], count: 0};
|
|
}
|
|
};
|
|
|
|
// 모달
|
|
// 시설정보 이력정보 데이터 호출
|
|
const fetchFacilityHistInfo = async (facilityCd:string ): Promise<fcltyHistInfoProps[]> => {
|
|
try {
|
|
const res = await getFetch('fo', '/prcsFclt/hist/'+facilityCd);
|
|
const data = res.data;
|
|
DataForm({ type: 'date', column: 'trlrnCmplDt', item: data as unknown as Record<string, unknown> });
|
|
DataForm({ type: 'date', column: 'eqpPrmsDt', item: data as unknown as Record<string, unknown> });
|
|
DataForm({ type: 'date', column: 'cmplDt', item: data as unknown as Record<string, unknown> });
|
|
DataForm({ type: 'date', column: 'rnDt', item: data as unknown as Record<string, unknown> });
|
|
DataForm({ type: 'number', column: 'sitArea', item: data as unknown as Record<string, unknown> });
|
|
DataForm({ type: 'number', column: 'trtDstrArea', item: data as unknown as Record<string, unknown> });
|
|
DataForm({ type: 'number', column: 'swrTrtPopl', item: data as unknown as Record<string, unknown> });
|
|
return data;
|
|
} catch (error) {
|
|
console.error('시설정보 이력정보 데이터를 가져오는데 실패했습니다:', error);
|
|
return [];
|
|
}
|
|
};
|
|
|
|
// 시설정보 수질정보 데이터 호출
|
|
const fetchFacilityWaterQltyInfo = async (facilityCd:string ): Promise<fcltyWaterQltyInfoProps[]> => {
|
|
try {
|
|
const res = await getFetch('fo', '/prcsFclt/info/history/'+facilityCd);
|
|
const data = res.data;
|
|
return data;
|
|
} catch (error) {
|
|
console.error('시설정보 수질정보 데이터를 가져오는데 실패했습니다:', error);
|
|
return [];
|
|
}
|
|
};
|
|
|
|
/**====================================
|
|
* Store - expaort
|
|
====================================*/
|
|
export type ProcessFacilityActions = {
|
|
/**
|
|
* 시설정보 리스트 데이터 호출(구분 선택 후 시설명 있을 경우)
|
|
* @param pageNo : 페이지 번호
|
|
* @param pageSize : 페이지 크기
|
|
* @param partValue : 구분값(행정명, 대유역, 환경청)
|
|
* @param nameCd : 행정코드(시도명, 시군구명, 단위유역)
|
|
* @param fcltCpct : 시설용량
|
|
* @param oprtngSttsCd : 운영 상태 코드
|
|
* @param facilityName : 시설명
|
|
*/
|
|
searchProcessFacility : (pageNo:number, pageSize:number, partValue?:string, nameCd?:string, fcltCpct?:string, oprtngSttsCd?:string, facilityPartValue?:string, facilityName?:string) => void;
|
|
|
|
/**
|
|
* 시설정보 이력정보 데이터 호출
|
|
* @param facilityCd : 시설코드
|
|
*/
|
|
searchProcessFacilityHist : (facilityCd:string) => void;
|
|
|
|
/**
|
|
* 시설정보 수질정보 데이터 호출
|
|
* @param facilityCd : 시설코드
|
|
*/
|
|
searchProcessFacilityWaterQlty : (facilityCd:string) => void;
|
|
|
|
/**
|
|
* 시설정보 리스트 데이터 호출 (대시보드용)
|
|
* @param pageNo : 페이지 번호
|
|
* @param pageSize : 페이지 크기
|
|
*/
|
|
searchProcessFacilitySearching : (pageNo:number, pageSize:number, partValue?:string, nameCd?:string, fcltCpct?:string, oprtngSttsCd?:string, facilityPartValue?:string, facilityName?:string) => void;
|
|
}
|
|
|
|
export type ProcessFacilityType = {
|
|
ProcessFacility: {
|
|
isInit: boolean;
|
|
processFacilityLabelArray:string[];
|
|
},
|
|
|
|
ProcessFacilityList : {
|
|
isInit: boolean;
|
|
upHeadList1:TableUpperProps[];
|
|
upHeadList2:TableUpperProps[];
|
|
upHeadList3:TableUpperProps[];
|
|
processFacilityList:facilityListProps[];
|
|
processFacilityCount:number;
|
|
excelList : ExcelType[];
|
|
isLoading: boolean;
|
|
},
|
|
|
|
ProcessFacilityDetail : {
|
|
isInit : boolean;
|
|
upHeadListBasicInfo : TableUpperProps[];
|
|
gridListBasicInfo : BasicInfoProps[];
|
|
upHeadListPlanInfo : TableUpperProps[];
|
|
gridListPlanInfo : PlanInfoProps[];
|
|
upHeadListFcltyAreaInfo : TableUpperProps[];
|
|
gridListFcltyAreaInfo : fcltyAreaInfoProps[];
|
|
|
|
upHeadListFcltyHistInfo : TableUpperProps[];
|
|
gridListFcltyHistInfo : fcltyHistInfoProps[];
|
|
upHeadListFcltyWaterQltyInfo : TableUpperProps[];
|
|
gridListFcltyWaterQltyInfo : fcltyWaterQltyInfoProps[];
|
|
|
|
upHeadListLegalWaterQlty : TableUpperProps[];
|
|
gridListLegalWaterQlty : LegalWaterQltyProps[];
|
|
},
|
|
}
|
|
|
|
export const processFacilityInitState:ProcessFacilityType = {
|
|
ProcessFacility: {
|
|
isInit: false,
|
|
processFacilityLabelArray: ProcessFacilityLabelArray,
|
|
},
|
|
|
|
ProcessFacilityList : {
|
|
isInit : false,
|
|
upHeadList1 : upHeadList1,
|
|
upHeadList2 : upHeadList2,
|
|
upHeadList3 : upHeadList3,
|
|
processFacilityList : processFacilityList,
|
|
processFacilityCount:1,
|
|
excelList : [],
|
|
isLoading : true,
|
|
},
|
|
|
|
ProcessFacilityDetail : {
|
|
isInit : false,
|
|
upHeadListBasicInfo : upHeadListBasicInfo,
|
|
gridListBasicInfo : gridListBasicInfo,
|
|
upHeadListPlanInfo : upHeadListPlanInfo,
|
|
gridListPlanInfo : gridListPlanInfo,
|
|
upHeadListFcltyAreaInfo : upHeadListFcltyAreaInfo,
|
|
gridListFcltyAreaInfo : gridListFcltyAreaInfo,
|
|
|
|
upHeadListFcltyHistInfo : upHeadListFcltyHistInfo,
|
|
gridListFcltyHistInfo : gridListFcltyHistInfo,
|
|
upHeadListFcltyWaterQltyInfo : upHeadListFcltyWaterQltyInfo,
|
|
gridListFcltyWaterQltyInfo : gridListFcltyWaterQltyInfo,
|
|
|
|
upHeadListLegalWaterQlty : upHeadListLegalWaterQlty,
|
|
gridListLegalWaterQlty : gridListLegalWaterQlty,
|
|
}
|
|
}
|
|
|
|
// 상태 설정 함수 타입 정의
|
|
type SetStateFunction = (state: ProcessFacilityType | ((state: ProcessFacilityType) => ProcessFacilityType)) => void;
|
|
|
|
export type ProcessFacilityStore = ProcessFacilityType & ProcessFacilityActions;
|
|
|
|
export const processFacilityReducer:(set:SetStateFunction)=>ProcessFacilityActions=(set: SetStateFunction) => {
|
|
return{
|
|
// 메인페이지
|
|
|
|
/**
|
|
* 시설정보 리스트 데이터 호출
|
|
* @param pageNo : 페이지 번호
|
|
* @param pageSize : 페이지 크기
|
|
*/
|
|
searchProcessFacility: async (pageNo:number, pageSize:number, partValue?:string, nameCd?:string, fcltCpct?:string, oprtngSttsCd?:string, facilityPartValue?:string, facilityName?:string) => {
|
|
set((state: ProcessFacilityType) => ({
|
|
...state,
|
|
ProcessFacilityList: {
|
|
...state.ProcessFacilityList,
|
|
isLoading: true,
|
|
},
|
|
}));
|
|
const res = await fetchFacilityList(pageNo, pageSize, partValue, nameCd, fcltCpct, oprtngSttsCd, facilityPartValue, facilityName);
|
|
res.data.forEach((item:facilityListProps) => {
|
|
DataForm({ type: 'date', column: 'cmplDt', item:item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'date', column: 'rnDt', item:item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'fctCpc', item:item as unknown as Record<string, unknown>});
|
|
})
|
|
|
|
res.data.forEach(item => {
|
|
item.plInflWqltBod = item.plInflWqltBod ? Number(item.plInflWqltBod).toFixed(1) : '';
|
|
item.dsInflWqltBod = item.dsInflWqltBod ? Number(item.dsInflWqltBod).toFixed(1) : '';
|
|
})
|
|
|
|
const excelDownList: ExcelType[] = [];
|
|
|
|
if(pageSize>5000){
|
|
res.data.forEach(item => {
|
|
item.fctCpc = item.fctCpc ? parseFloat(item.fctCpc.toString().replace(/,/g, '')) : '';
|
|
excelDownList.push({
|
|
시설코드: item.bscFctCd,
|
|
권역: item.rvbsn,
|
|
단위유역: item.lgbsn,
|
|
중권역: item.mdmbsn,
|
|
환경청: item.rgnNm,
|
|
시도: item.sido,
|
|
시군구: item.gugun,
|
|
시설이름: item.bscFctNm,
|
|
주소: item.daddr,
|
|
시설용량: item.fctCpc ? Number(item.fctCpc) : '',
|
|
계획유입수질: item.plInflWqltBod ? Number(item.plInflWqltBod) : '',
|
|
설계유입수질: item.dsInflWqltBod ? Number(item.dsInflWqltBod) : '',
|
|
공법: item.trtFrfNm,
|
|
가동개시일: item.rnDt,
|
|
준공일: item.cmplDt,
|
|
관리대행업자: item.mnstr,
|
|
})
|
|
})
|
|
}else{
|
|
res.data.forEach(item => {
|
|
item.fctCpc = item.fctCpc ? parseFloat(item.fctCpc.toString().replace(/,/g, '')) : '';
|
|
})
|
|
}
|
|
set((state:ProcessFacilityType) => ({
|
|
...state,
|
|
ProcessFacilityList: pageSize<5000?{
|
|
...state.ProcessFacilityList,
|
|
processFacilityList: res.data,
|
|
processFacilityCount: res.count,
|
|
isLoading: false,
|
|
}:{
|
|
...state.ProcessFacilityList,
|
|
excelList: excelDownList,
|
|
isLoading: false,
|
|
},
|
|
}))
|
|
},
|
|
|
|
/**
|
|
* 시설정보 리스트 데이터 호출
|
|
* @param pageNo : 페이지 번호
|
|
* @param pageSize : 페이지 크기
|
|
*/
|
|
searchProcessFacilitySearching: async (pageNo:number, pageSize:number, partValue?:string, nameCd?:string, fcltCpct?:string, oprtngSttsCd?:string, facilityPartValue?:string, facilityName?:string) => {
|
|
set((state: ProcessFacilityType) => ({
|
|
...state,
|
|
ProcessFacilityList: {
|
|
...state.ProcessFacilityList,
|
|
isLoading: true,
|
|
},
|
|
}));
|
|
const res = await fetchFacilityListSearching(pageNo, pageSize, partValue, nameCd, fcltCpct, oprtngSttsCd, facilityPartValue, facilityName);
|
|
/* res.data.forEach((item:facilityListProps) => {
|
|
DataForm({ type: 'date', column: 'cmplDt', item:item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'date', column: 'rnDt', item:item as unknown as Record<string, unknown>});
|
|
})
|
|
|
|
res.data.forEach(item => {
|
|
item.plInflWqltBod = item.plInflWqltBod ? Number(item.plInflWqltBod).toFixed(1) : '';
|
|
item.dsInflWqltBod = item.dsInflWqltBod ? Number(item.dsInflWqltBod).toFixed(1) : '';
|
|
}) */
|
|
console.log(res.data);
|
|
set((state:ProcessFacilityType) => ({
|
|
...state,
|
|
ProcessFacilityList: {
|
|
...state.ProcessFacilityList,
|
|
processFacilityList: res.data,
|
|
processFacilityCount: res.count,
|
|
isLoading: false,
|
|
},
|
|
}))
|
|
},
|
|
|
|
|
|
// 모달 이력정보
|
|
/**
|
|
* 시설정보 이력정보 데이터 호출
|
|
* @param facilityCd : 시설코드
|
|
*/
|
|
searchProcessFacilityHist: async (facilityCd:string) => {
|
|
const promiseSet = await Promise.all([fetchFacilityHistInfo(facilityCd)]);
|
|
const [facilityHistInfo] = promiseSet;
|
|
// extnsSeqno를 기준으로 오름차순 정렬
|
|
const sortedHistInfo = [...facilityHistInfo].sort((a, b) => {
|
|
// 숫자로 변환하여 비교
|
|
const numA = Number(a.extnsSeqno);
|
|
const numB = Number(b.extnsSeqno);
|
|
if (!isNaN(numA) && !isNaN(numB)) {
|
|
return numA - numB;
|
|
}
|
|
// 숫자 변환이 실패하면 문자열로 비교
|
|
return String(a.extnsSeqno).localeCompare(String(b.extnsSeqno));
|
|
});
|
|
|
|
sortedHistInfo.forEach(item => {
|
|
if(item.extnsSeqno == '0'){
|
|
item.extnsSeqno = '최초';
|
|
item.extnsNm = '신설';
|
|
}
|
|
});
|
|
|
|
// yyyy-MM-dd로 변환
|
|
sortedHistInfo.forEach(item => {
|
|
item.eqpPrmsDt = item.eqpPrmsDt ? item.eqpPrmsDt.substring(0,4) + '-' + item.eqpPrmsDt.substring(4,6) + '-' + item.eqpPrmsDt.substring(6,8) : '';
|
|
item.trlrnCmplDt = item.trlrnCmplDt ? item.trlrnCmplDt.substring(0,4) + '-' + item.trlrnCmplDt.substring(4,6) + '-' + item.trlrnCmplDt.substring(6,8) : '';
|
|
item.cmplDt = item.cmplDt ? item.cmplDt.substring(0,4) + '-' + item.cmplDt.substring(4,6) + '-' + item.cmplDt.substring(6,8) : '';
|
|
item.rnDt = item.rnDt ? item.rnDt.substring(0,4) + '-' + item.rnDt.substring(4,6) + '-' + item.rnDt.substring(6,8) : '';
|
|
});
|
|
|
|
// 마지막 이력 데이터의 값을 gridListPlanInfo에 업데이트
|
|
if (sortedHistInfo.length > 0) {
|
|
const lastHistInfo = sortedHistInfo[sortedHistInfo.length - 1];
|
|
set((state: ProcessFacilityType) => ({
|
|
...state,
|
|
ProcessFacilityDetail: {
|
|
...state.ProcessFacilityDetail,
|
|
gridListFcltyHistInfo: sortedHistInfo,
|
|
gridListPlanInfo: [{
|
|
...state.ProcessFacilityDetail.gridListPlanInfo[0],
|
|
swrTrtPopl: lastHistInfo?.swrTrtPopl ?? state.ProcessFacilityDetail.gridListPlanInfo[0]?.swrTrtPopl,
|
|
trtDstrArea: lastHistInfo?.trtDstrArea ?? state.ProcessFacilityDetail.gridListPlanInfo[0]?.trtDstrArea,
|
|
sitArea: lastHistInfo?.sitArea ?? state.ProcessFacilityDetail.gridListPlanInfo[0]?.sitArea
|
|
}]
|
|
}
|
|
}));
|
|
} else {
|
|
set((state: ProcessFacilityType) => ({
|
|
...state,
|
|
ProcessFacilityDetail: {
|
|
...state.ProcessFacilityDetail,
|
|
gridListFcltyHistInfo: sortedHistInfo,
|
|
gridListPlanInfo: [{
|
|
...state.ProcessFacilityDetail.gridListPlanInfo[0],
|
|
swrTrtPopl: '',
|
|
trtDstrArea: '',
|
|
sitArea: ''
|
|
}]
|
|
}
|
|
}));
|
|
}
|
|
},
|
|
|
|
// 모달 수질정보
|
|
/**
|
|
* 시설정보 수질정보 데이터 호출
|
|
* @param facilityCd : 시설코드
|
|
*/
|
|
searchProcessFacilityWaterQlty: async (facilityCd:string) => {
|
|
const promiseSet = await Promise.all([fetchFacilityWaterQltyInfo(facilityCd)]);
|
|
const [facilityWaterQltyInfo] = promiseSet;
|
|
// extnsSeqno를 기준으로 오름차순 정렬
|
|
const sortedWaterQltyInfo = [...facilityWaterQltyInfo].sort((a, b) => {
|
|
// 숫자로 변환하여 비교
|
|
const numA = Number(a.extnsSeqno);
|
|
const numB = Number(b.extnsSeqno);
|
|
if (!isNaN(numA) && !isNaN(numB)) {
|
|
return numA - numB;
|
|
}
|
|
// 숫자 변환이 실패하면 문자열로 비교
|
|
return String(a.extnsSeqno).localeCompare(String(b.extnsSeqno));
|
|
});
|
|
|
|
sortedWaterQltyInfo.forEach(item => {
|
|
if(item.extnsSeqno == '0'){
|
|
item.extnsSeqno = '최초';
|
|
}
|
|
});
|
|
|
|
// 법적수질정보 초기화 및 push
|
|
gridListLegalWaterQlty = [];
|
|
|
|
gridListLegalWaterQlty.push({
|
|
bod: facilityWaterQltyInfo[0]?.bod ?? 0,
|
|
cod: Number(facilityWaterQltyInfo[0]?.cod ?? 0),
|
|
ss: Number(facilityWaterQltyInfo[0]?.ss ?? 0),
|
|
tn: Number(facilityWaterQltyInfo[0]?.tn ?? 0),
|
|
tp: Number(facilityWaterQltyInfo[0]?.tp ?? 0),
|
|
totClfgrpcnt : Number(facilityWaterQltyInfo[0]?.totClfgrpcnt ?? 0),
|
|
});
|
|
|
|
// 마지막 수질 데이터의 값을 gridListPlanInfo에 업데이트
|
|
if (sortedWaterQltyInfo.length > 0) {
|
|
const lastWaterQltyInfo = sortedWaterQltyInfo[sortedWaterQltyInfo.length - 1];
|
|
set((state: ProcessFacilityType) => ({
|
|
...state,
|
|
ProcessFacilityDetail: {
|
|
...state.ProcessFacilityDetail,
|
|
gridListFcltyWaterQltyInfo: sortedWaterQltyInfo,
|
|
gridListLegalWaterQlty: gridListLegalWaterQlty,
|
|
gridListPlanInfo: [{
|
|
...state.ProcessFacilityDetail.gridListPlanInfo[0],
|
|
dsInflWqltBod: lastWaterQltyInfo?.dsInflWqltBod === 'NULL' || lastWaterQltyInfo?.dsInflWqltBod === undefined ? '' : lastWaterQltyInfo.dsInflWqltBod,
|
|
dsInflWqltToc: lastWaterQltyInfo?.dsInflWqltToc === 'NULL' || lastWaterQltyInfo?.dsInflWqltToc === undefined ? '' : lastWaterQltyInfo.dsInflWqltToc,
|
|
dsInflWqltCod: lastWaterQltyInfo?.dsInflWqltCod === 'NULL' || lastWaterQltyInfo?.dsInflWqltCod === undefined ? '' : lastWaterQltyInfo.dsInflWqltCod,
|
|
dsInflWqltSs: lastWaterQltyInfo?.dsInflWqltSs === 'NULL' || lastWaterQltyInfo?.dsInflWqltSs === undefined ? '' : lastWaterQltyInfo.dsInflWqltSs,
|
|
dsInflWqltTn: lastWaterQltyInfo?.dsInflWqltTn === 'NULL' || lastWaterQltyInfo?.dsInflWqltTn === undefined ? '' : lastWaterQltyInfo.dsInflWqltTn,
|
|
dsInflWqltTp: lastWaterQltyInfo?.dsInflWqltTp === 'NULL' || lastWaterQltyInfo?.dsInflWqltTp === undefined ? '' : lastWaterQltyInfo.dsInflWqltTp,
|
|
plInflWqltBod: lastWaterQltyInfo?.plInflWqltBod === 'NULL' || lastWaterQltyInfo?.plInflWqltBod === undefined ? '' : lastWaterQltyInfo.plInflWqltBod,
|
|
plInflWqltToc: lastWaterQltyInfo?.plInflWqltToc === 'NULL' || lastWaterQltyInfo?.plInflWqltToc === undefined ? '' : lastWaterQltyInfo.plInflWqltToc,
|
|
plInflWqltCod: lastWaterQltyInfo?.plInflWqltCod === 'NULL' || lastWaterQltyInfo?.plInflWqltCod === undefined ? '' : lastWaterQltyInfo.plInflWqltCod,
|
|
plInflWqltSs: lastWaterQltyInfo?.plInflWqltSs === 'NULL' || lastWaterQltyInfo?.plInflWqltSs === undefined ? '' : lastWaterQltyInfo.plInflWqltSs,
|
|
plInflWqltTn: lastWaterQltyInfo?.plInflWqltTn === 'NULL' || lastWaterQltyInfo?.plInflWqltTn === undefined ? '' : lastWaterQltyInfo.plInflWqltTn,
|
|
plInflWqltTp: lastWaterQltyInfo?.plInflWqltTp === 'NULL' || lastWaterQltyInfo?.plInflWqltTp === undefined ? '' : lastWaterQltyInfo.plInflWqltTp
|
|
}]
|
|
}
|
|
}));
|
|
} else {
|
|
set((state: ProcessFacilityType) => ({
|
|
...state,
|
|
ProcessFacilityDetail: {
|
|
...state.ProcessFacilityDetail,
|
|
gridListFcltyWaterQltyInfo: sortedWaterQltyInfo,
|
|
gridListLegalWaterQlty: gridListLegalWaterQlty,
|
|
gridListPlanInfo: [{
|
|
...state.ProcessFacilityDetail.gridListPlanInfo[0],
|
|
dsInflWqltBod: '',
|
|
dsInflWqltToc: '',
|
|
dsInflWqltCod: '',
|
|
dsInflWqltSs: '',
|
|
dsInflWqltTn: '',
|
|
dsInflWqltTp: '',
|
|
plEfflWqltBod: '',
|
|
plEfflWqltToc: '',
|
|
plEfflWqltCod: '',
|
|
plEfflWqltSs: '',
|
|
plEfflWqltTn: '',
|
|
plEfflWqltTp: ''
|
|
}]
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
} |