대시보드 수질현황 팝업과 데이터 맞추는 작업 완료
This commit is contained in:
@@ -734,115 +734,186 @@ const fetchMainGraph = async (searchYear: string|undefined, fcltyCd: string|unde
|
||||
}
|
||||
|
||||
// 수질 데이터 청천시, 강우시 재계산
|
||||
/* const calcWaterQltyData = async (data: any[], searchYear : string|undefined, fcltyCd : string|undefined) => {
|
||||
let orgData = data;
|
||||
console.log('orgData', orgData);
|
||||
await fetchMainGraph(searchYear, fcltyCd).then(res => {
|
||||
if(res.data.count > 0) {
|
||||
const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? [];
|
||||
const qltyData = res.data;
|
||||
const qltyChungchunData = CalcRainEffect(clone(qltyData), 'SUNNY', 'RAIN_DAY');
|
||||
const qltyRainData = CalcRainEffect(clone(qltyData), 'RAIN', 'RAIN_DAY');
|
||||
const calcWaterQltyData = async (data: any[], searchYear : string|undefined, fcltyCd : string|undefined) => {
|
||||
// 데이터 결과값 dataFormat 가공
|
||||
const qltyDataSetting = (value: number, day : number, digit: number) => {
|
||||
const toZero = digit === 1 ? '0.0' : digit === 2 ? '0.00' : '0.000';
|
||||
return value > 0 ? roundUp((value/day), digit).toFixed(digit) : toZero;
|
||||
};
|
||||
|
||||
// 청천시 변수
|
||||
let chungchunAllDay = 0;
|
||||
let chungchunSummerDay = 0;
|
||||
let chungchunWinterDay = 0;
|
||||
const orgData = data;
|
||||
const res = await fetchMainGraph(searchYear, fcltyCd);
|
||||
if(res.data.wqltObjs.length> 0) {
|
||||
const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? [];
|
||||
const qltyData = res.data.wqltObjs;
|
||||
const qltyChungchunData = CalcRainEffect(clone(qltyData), 'SUNNY', 'RAIN_DAY');
|
||||
const qltyRainData = CalcRainEffect(clone(qltyData), 'RAIN', 'RAIN_DAY');
|
||||
|
||||
let chungchunInflBodAvg = 0;
|
||||
let chungchunInflTnAvg = 0;
|
||||
let chungchunInflTpAvg = 0;
|
||||
let chungchunInflBodMax = 0;
|
||||
let chungchunInflTnMax= 0;
|
||||
let chungchunInflTpMax = 0;
|
||||
let chungchunInflBodMin = 99999999;
|
||||
let chungchunInflTnMin = 99999999;
|
||||
let chungchunInflTpMin = 99999999;
|
||||
// (1) 청천시 변수
|
||||
// (1-1) 날짜 count
|
||||
let chungchunSummerDay = 0;
|
||||
let chungchunWinterDay = 0;
|
||||
|
||||
let chungchunEfflBodAvg = 0;
|
||||
let chungchunEfflTnAvg = 0;
|
||||
let chungchunEfflTpAvg = 0;
|
||||
let chungchunEfflBodMax = 0;
|
||||
let chungchunEfflTnMax= 0;
|
||||
let chungchunEfflTpMax = 0;
|
||||
let chungchunEfflBodMin = 99999999;
|
||||
let chungchunEfflTnMin = 99999999;
|
||||
let chungchunEfflTpMin = 99999999;
|
||||
// (1-2) 하절기
|
||||
let chungchunInflBodAvgSummer = 0;
|
||||
let chungchunInflTnAvgSummer = 0;
|
||||
let chungchunInflTpAvgSummer = 0;
|
||||
let chungchunEfflBodAvgSummer = 0;
|
||||
let chungchunEfflTnAvgSummer = 0;
|
||||
let chungchunEfflTpAvgSummer = 0;
|
||||
|
||||
// 강우시 변수
|
||||
let rainAllDay = 0;
|
||||
let rainSummerDay = 0;
|
||||
let rainWinterDay = 0;
|
||||
// (1-3) 동절기 (최대, 최소, 평균 다 필요)
|
||||
let chungchunInflBodAvg = 0;
|
||||
let chungchunInflTnAvg = 0;
|
||||
let chungchunInflTpAvg = 0;
|
||||
let chungchunInflBodMax = 0;
|
||||
let chungchunInflTnMax= 0;
|
||||
let chungchunInflTpMax = 0;
|
||||
let chungchunInflBodMin = 99999999;
|
||||
let chungchunInflTnMin = 99999999;
|
||||
let chungchunInflTpMin = 99999999;
|
||||
|
||||
let rainInflBodAvg = 0;
|
||||
let rainInflTnAvg = 0;
|
||||
let rainInflTpAvg = 0;
|
||||
let rainInflBodMax = 0;
|
||||
let rainInflTnMax= 0;
|
||||
let rainInflTpMax = 0;
|
||||
let rainInflBodMin = 99999999;
|
||||
let rainInflTnMin = 99999999;
|
||||
let rainInflTpMin = 99999999;
|
||||
let chungchunEfflBodAvg = 0;
|
||||
let chungchunEfflTnAvg = 0;
|
||||
let chungchunEfflTpAvg = 0;
|
||||
let chungchunEfflBodMax = 0;
|
||||
let chungchunEfflTnMax= 0;
|
||||
let chungchunEfflTpMax = 0;
|
||||
let chungchunEfflBodMin = 99999999;
|
||||
let chungchunEfflTnMin = 99999999;
|
||||
let chungchunEfflTpMin = 99999999;
|
||||
|
||||
const nullToZero = (value: any) => {
|
||||
return value === null || value === undefined || value === '' ? 0 : Number(value);
|
||||
};
|
||||
const nullToZero = (value: any) => {
|
||||
return value === null || value === undefined || value === '' ? 0 : Number(value);
|
||||
};
|
||||
|
||||
// 청천시
|
||||
qltyChungchunData.forEach((item: any) => {
|
||||
chungchunAllDay += 1;
|
||||
const month = item.msrdt.substring(4, 6); // 월 추출
|
||||
if(month === '01' || month === '02'){
|
||||
chungchunWinterDay += 1;
|
||||
|
||||
const inflbod = nullToZero(item.inflAssctBfrWqltBod);
|
||||
const infltn = nullToZero(item.inflAssctBfrWqltTn);
|
||||
const infltp = nullToZero(item.inflAssctBfrWqltTp);
|
||||
const effbod = nullToZero(item.efflWqltBod);
|
||||
const efftn = nullToZero(item.efflWqltTn);
|
||||
const efftp = nullToZero(item.efflWqltTp);
|
||||
// 청천시
|
||||
qltyChungchunData.forEach((item: any) => {
|
||||
const month = item.msrDt.substring(4, 6); // 월 추출
|
||||
if(month === '01' || month === '02'){
|
||||
chungchunWinterDay += 1;
|
||||
|
||||
const inflbod = nullToZero(item.inflAssctBfrWqltBod);
|
||||
const infltn = nullToZero(item.inflAssctBfrWqltTn);
|
||||
const infltp = nullToZero(item.inflAssctBfrWqltTp);
|
||||
const effbod = nullToZero(item.efflWqltBod);
|
||||
const efftn = nullToZero(item.efflWqltTn);
|
||||
const efftp = nullToZero(item.efflWqltTp);
|
||||
|
||||
chungchunInflBodAvg += inflbod;
|
||||
chungchunInflTnAvg += infltn;
|
||||
chungchunInflTpAvg += infltp;
|
||||
chungchunEfflBodAvg += effbod;
|
||||
chungchunEfflTnAvg += efftn;
|
||||
chungchunEfflTpAvg += efftp;
|
||||
chungchunInflBodAvg += inflbod;
|
||||
chungchunInflTnAvg += infltn;
|
||||
chungchunInflTpAvg += infltp;
|
||||
chungchunEfflBodAvg += effbod;
|
||||
chungchunEfflTnAvg += efftn;
|
||||
chungchunEfflTpAvg += efftp;
|
||||
|
||||
if(chungchunInflBodMax < inflbod) chungchunInflBodMax = inflbod;
|
||||
if(chungchunInflTnMax < infltn) chungchunInflTnMax = infltn;
|
||||
if(chungchunInflTpMax < infltp) chungchunInflTpMax = infltp;
|
||||
if(chungchunEfflBodMax < effbod) chungchunEfflBodMax = effbod;
|
||||
if(chungchunEfflTnMax < efftn) chungchunEfflTnMax = efftn;
|
||||
if(chungchunEfflTpMax < efftp) chungchunEfflTpMax = efftp;
|
||||
if(chungchunInflBodMax < inflbod) chungchunInflBodMax = inflbod;
|
||||
if(chungchunInflTnMax < infltn) chungchunInflTnMax = infltn;
|
||||
if(chungchunInflTpMax < infltp) chungchunInflTpMax = infltp;
|
||||
if(chungchunEfflBodMax < effbod) chungchunEfflBodMax = effbod;
|
||||
if(chungchunEfflTnMax < efftn) chungchunEfflTnMax = efftn;
|
||||
if(chungchunEfflTpMax < efftp) chungchunEfflTpMax = efftp;
|
||||
|
||||
if(chungchunInflBodMin > inflbod) chungchunInflBodMin = inflbod;
|
||||
if(chungchunInflTnMin > infltn) chungchunInflTnMin = infltn;
|
||||
if(chungchunInflTpMin > infltp) chungchunInflTpMin = infltp;
|
||||
if(chungchunEfflBodMin > effbod) chungchunEfflBodMin = effbod;
|
||||
if(chungchunEfflTnMin > efftn) chungchunEfflTnMin = efftn;
|
||||
if(chungchunEfflTpMin > efftp) chungchunEfflTpMin = efftp;
|
||||
}else if(month === '06' || month === '07' || month === '08'){
|
||||
chungchunSummerDay += 1;
|
||||
}
|
||||
});
|
||||
if(chungchunInflBodMin > inflbod) chungchunInflBodMin = inflbod;
|
||||
if(chungchunInflTnMin > infltn) chungchunInflTnMin = infltn;
|
||||
if(chungchunInflTpMin > infltp) chungchunInflTpMin = infltp;
|
||||
if(chungchunEfflBodMin > effbod) chungchunEfflBodMin = effbod;
|
||||
if(chungchunEfflTnMin > efftn) chungchunEfflTnMin = efftn;
|
||||
if(chungchunEfflTpMin > efftp) chungchunEfflTpMin = efftp;
|
||||
}else if(month === '06' || month === '07' || month === '08'){
|
||||
chungchunSummerDay += 1;
|
||||
|
||||
const inflbod = nullToZero(item.inflAssctBfrWqltBod);
|
||||
const infltn = nullToZero(item.inflAssctBfrWqltTn);
|
||||
const infltp = nullToZero(item.inflAssctBfrWqltTp);
|
||||
const effbod = nullToZero(item.efflWqltBod);
|
||||
const efftn = nullToZero(item.efflWqltTn);
|
||||
const efftp = nullToZero(item.efflWqltTp);
|
||||
|
||||
orgData[5].winterSunnyAvg = chungchunAllDay > 0 ? '999' : 0;
|
||||
chungchunInflBodAvgSummer += inflbod;
|
||||
chungchunInflTnAvgSummer += infltn;
|
||||
chungchunInflTpAvgSummer += infltp;
|
||||
chungchunEfflBodAvgSummer += effbod;
|
||||
chungchunEfflTnAvgSummer += efftn;
|
||||
chungchunEfflTpAvgSummer += efftp;
|
||||
}
|
||||
});
|
||||
|
||||
// 강우시
|
||||
qltyRainData.forEach((item: any) => {
|
||||
const month = item.msrdt.substring(4, 6); // 월 추출
|
||||
if(month === '01' || month === '02'){
|
||||
}else if(month === '06' || month === '07' || month === '08'){
|
||||
}
|
||||
});
|
||||
// 청천시 수질 데이터 수정
|
||||
// 하절기
|
||||
orgData[5].summerRain = qltyDataSetting(chungchunInflBodAvgSummer, chungchunSummerDay, 1);
|
||||
orgData[6].summerRain = qltyDataSetting(chungchunEfflBodAvgSummer, chungchunSummerDay, 1);
|
||||
orgData[7].summerRain = qltyDataSetting(chungchunInflTnAvgSummer, chungchunSummerDay, 3);
|
||||
orgData[8].summerRain = qltyDataSetting(chungchunEfflTnAvgSummer, chungchunSummerDay, 3);
|
||||
orgData[9].summerRain = qltyDataSetting(chungchunInflTpAvgSummer, chungchunSummerDay, 3);
|
||||
orgData[10].summerRain = qltyDataSetting(chungchunEfflTpAvgSummer, chungchunSummerDay, 3);
|
||||
|
||||
return orgData;
|
||||
} else {
|
||||
return orgData;
|
||||
}
|
||||
});
|
||||
}; */
|
||||
// 동절기
|
||||
orgData[5].winterSunnyAvg = qltyDataSetting(chungchunInflBodAvg, chungchunWinterDay, 1);
|
||||
orgData[6].winterSunnyAvg = qltyDataSetting(chungchunEfflBodAvg, chungchunWinterDay, 1);
|
||||
orgData[7].winterSunnyAvg = qltyDataSetting(chungchunInflTnAvg, chungchunWinterDay, 3);
|
||||
orgData[8].winterSunnyAvg = qltyDataSetting(chungchunEfflTnAvg, chungchunWinterDay, 3);
|
||||
orgData[9].winterSunnyAvg = qltyDataSetting(chungchunInflTpAvg, chungchunWinterDay, 3);
|
||||
orgData[10].winterSunnyAvg = qltyDataSetting(chungchunEfflTpAvg, chungchunWinterDay, 3);
|
||||
|
||||
orgData[5].winterSunnyMax = roundUp(chungchunInflBodMax, 1).toFixed(1);
|
||||
orgData[6].winterSunnyMax = roundUp(chungchunEfflBodMax, 1).toFixed(1);
|
||||
orgData[7].winterSunnyMax = roundUp(chungchunInflTnMax, 3).toFixed(3);
|
||||
orgData[8].winterSunnyMax = roundUp(chungchunEfflTnMax, 3).toFixed(3);
|
||||
orgData[9].winterSunnyMax = roundUp(chungchunInflTpMax, 3).toFixed(3);
|
||||
orgData[10].winterSunnyMax = roundUp(chungchunEfflTpMax, 3).toFixed(3);
|
||||
|
||||
orgData[5].winterSunnyMin = chungchunInflBodMin === 99999999 ? '0.0' : roundUp(chungchunInflBodMin, 1).toFixed(1);
|
||||
orgData[6].winterSunnyMin = chungchunEfflBodMin === 99999999 ? '0.0' : roundUp(chungchunEfflBodMin, 1).toFixed(1);
|
||||
orgData[7].winterSunnyMin = chungchunInflTnMin === 99999999 ? '0.000' : roundUp(chungchunInflTnMin, 3).toFixed(3);
|
||||
orgData[8].winterSunnyMin = chungchunEfflTnMin === 99999999 ? '0.000' : roundUp(chungchunEfflTnMin, 3).toFixed(3);
|
||||
orgData[9].winterSunnyMin = chungchunInflTpMin === 99999999 ? '0.000' : roundUp(chungchunInflTpMin, 3).toFixed(3);
|
||||
orgData[10].winterSunnyMin = chungchunEfflTpMin === 99999999 ? '0.000' : roundUp(chungchunEfflTpMin, 3).toFixed(3);
|
||||
|
||||
// 강우시 변수
|
||||
let rainSummerDay = 0;
|
||||
|
||||
let rainInflBodAvg = 0;
|
||||
let rainInflTnAvg = 0;
|
||||
let rainInflTpAvg = 0;
|
||||
let rainEfflBodAvg = 0;
|
||||
let rainEfflTnAvg = 0;
|
||||
let rainEfflTpAvg = 0;
|
||||
|
||||
// 강우시
|
||||
qltyRainData.forEach((item: any) => {
|
||||
const month = item.msrDt.substring(4, 6); // 월 추출
|
||||
if(month === '06' || month === '07' || month === '08'){
|
||||
rainSummerDay += 1;
|
||||
|
||||
const inflbod = nullToZero(item.inflAssctBfrWqltBod);
|
||||
const infltn = nullToZero(item.inflAssctBfrWqltTn);
|
||||
const infltp = nullToZero(item.inflAssctBfrWqltTp);
|
||||
const effbod = nullToZero(item.efflWqltBod);
|
||||
const efftn = nullToZero(item.efflWqltTn);
|
||||
const efftp = nullToZero(item.efflWqltTp);
|
||||
|
||||
rainInflBodAvg += inflbod;
|
||||
rainInflTnAvg += infltn;
|
||||
rainInflTpAvg += infltp;
|
||||
rainEfflBodAvg += effbod;
|
||||
rainEfflTnAvg += efftn;
|
||||
rainEfflTpAvg += efftp;
|
||||
}
|
||||
});
|
||||
|
||||
// 강우시 수질 데이터 수정
|
||||
orgData[5].summerThree = qltyDataSetting(rainInflBodAvg, rainSummerDay, 1);
|
||||
orgData[6].summerThree = qltyDataSetting(rainEfflBodAvg, rainSummerDay, 1);
|
||||
orgData[7].summerThree = qltyDataSetting(rainInflTnAvg, rainSummerDay, 3);
|
||||
orgData[8].summerThree = qltyDataSetting(rainEfflTnAvg, rainSummerDay, 3);
|
||||
orgData[9].summerThree = qltyDataSetting(rainInflTpAvg, rainSummerDay, 3);
|
||||
orgData[10].summerThree = qltyDataSetting(rainEfflTpAvg, rainSummerDay, 3);
|
||||
return orgData;
|
||||
} else {
|
||||
return orgData;
|
||||
}
|
||||
};
|
||||
|
||||
/**====================================
|
||||
* Store - action
|
||||
@@ -1655,6 +1726,10 @@ export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType)
|
||||
dataFormSetting(operationalStatusList[0]);
|
||||
}
|
||||
}
|
||||
|
||||
const rtnData = await calcWaterQltyData(operationalStatusList, searchYear, fcltyCd);
|
||||
operationalStatusList = rtnData;
|
||||
|
||||
// 총인설비가 없을 경우 제외
|
||||
if(data.yearData.TP_INFL_WQLT_TP === null || data.yearData.TP_INFL_WQLT_TP === undefined || data.yearData.TP_INFL_WQLT_TP === 'null') {
|
||||
operationalStatusList = operationalStatusList.slice(0, 11);
|
||||
|
||||
Reference in New Issue
Block a user