From b5dae4ba85e805ec0f202ee3799823c93ba52e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?hagjoon=28=EC=9D=B4=ED=95=99=EC=A4=80=29?= Date: Tue, 8 Nov 2022 11:06:11 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=ED=96=89=EA=B3=84=ED=9A=8D=EC=84=9C?= =?UTF-8?q?=20-=20=EB=82=A0=EC=94=A8=20=EC=A2=8C=ED=91=9C=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flight/plan/FlightPlanAreaDetailForm.js | 221 +++++++++--------- 1 file changed, 117 insertions(+), 104 deletions(-) diff --git a/src/components/basis/flight/plan/FlightPlanAreaDetailForm.js b/src/components/basis/flight/plan/FlightPlanAreaDetailForm.js index 673ebc8..8aca695 100644 --- a/src/components/basis/flight/plan/FlightPlanAreaDetailForm.js +++ b/src/components/basis/flight/plan/FlightPlanAreaDetailForm.js @@ -1,6 +1,11 @@ import React, { useEffect, useState } from 'react'; -import { TodayWeather, TomorrowWeahter, AfterTomorrowWeahter, LastwWeahter } from '../../../basis/flight/plan/TodayWeather' -import { FlightweatherAction } from '../../../../modules/basis/flight/actions/basisFlightAction' +import { + TodayWeather, + TomorrowWeahter, + AfterTomorrowWeahter, + LastwWeahter +} from '../../../basis/flight/plan/TodayWeather'; +import { FlightweatherAction } from '../../../../modules/basis/flight/actions/basisFlightAction'; import { Card, CardBody, @@ -40,135 +45,126 @@ const FlightPlanAreaDetailForm = ({ isDone, isDisabled }) => { - const [dayData, setdayData] = useState({}); const coordList = data ? data[0].coordList : null; const dispatch = useDispatch(); const { weather } = useSelector(state => state.flightState); let now = moment(); - let date = moment().format('YYYYMMDD') - let time = moment().format('HHmm') - let plus_day1 = moment().add(1, "day").format('YYYYMMDD'); - let plus_day2 = moment().add(2, "day").format('YYYYMMDD'); + let date = moment().format('YYYYMMDD'); + let time = moment().format('HHmm'); + let plus_day1 = moment().add(1, 'day').format('YYYYMMDD'); + let plus_day2 = moment().add(2, 'day').format('YYYYMMDD'); useEffect(() => { if (weather) { let wheatherobj = {}; const weatherData = weather?.item; //오늘 날씨 필터링 - const todayres = weatherData.filter(weatherData => weatherData.fcstDate == date); + const todayres = weatherData.filter( + weatherData => weatherData.fcstDate == date + ); const todayData = todayres.filter(todayres => { switch (todayres.category) { - case "TMP": - case "SKY": - case "VEC": - case "WSD": - case "PTY": - return { ...todayres } + case 'TMP': + case 'SKY': + case 'VEC': + case 'WSD': + case 'PTY': + return { ...todayres }; } }); //내일 날씨 필터링todayres.category == ("TMP" || "SKY" || "VEC" || "WSD" || "PTY") - const tomorrowres = weatherData.filter(weatherData => weatherData.fcstDate == plus_day1); + const tomorrowres = weatherData.filter( + weatherData => weatherData.fcstDate == plus_day1 + ); const tomorrowData = tomorrowres.filter(tomorrowres => { switch (tomorrowres.category) { - case "TMP": - case "SKY": - case "VEC": - case "WSD": - case "PTY": - return { ...todayres } + case 'TMP': + case 'SKY': + case 'VEC': + case 'WSD': + case 'PTY': + return { ...todayres }; } }); //모레 날씨 필터링 - const afterres = weatherData.filter(weatherData => weatherData.fcstDate == plus_day2); + const afterres = weatherData.filter( + weatherData => weatherData.fcstDate == plus_day2 + ); const afterData = afterres.filter(afterres => { switch (afterres.category) { - case "TMP": - case "SKY": - case "VEC": - case "WSD": - case "PTY": - return { ...todayres } + case 'TMP': + case 'SKY': + case 'VEC': + case 'WSD': + case 'PTY': + return { ...todayres }; } }); wheatherobj = { todayData, tomorrowData, - afterData, - } + afterData + }; setdayData({ ...wheatherobj }); } - }, [weather]) + }, [weather]); useEffect(() => { - if (data[0]?.coordList[0].lat != 0 || data[0]?.coordList[0].lon != 0) { let nx = data[0]?.coordList[0].lat; let ny = data[0]?.coordList[0].lon; - const rs = dfsxyconv("toXY", nx, ny); + const rs = dfsxyconv('toXY', nx, ny); let now = new Date(); let hours = now.getHours(); let minutes = now.getMinutes(); - let basetime = "2300"; + let basetime = '2300'; - if ((hours >= 2 && minutes > 9) && hours <= 5) { - basetime = "0200"; - } - else if ((hours >= 5 && minutes > 9) && hours < 8) { - basetime = "0500"; - } - else if (hours <= 8 && minutes < 10) { - basetime = "0500"; - } - else if ((hours >= 8 && minutes > 9) && hours < 11) { - basetime = "0800"; - } - else if (hours <= 11 && minutes < 10) { - basetime = "0800"; - } - else if (((hours >= 11 && minutes > 9) && hours < 14)) { - basetime = "1100"; - } - else if (hours <= 14 && minutes < 10) { - basetime = "1100"; - } - else if ((hours >= 14 && minutes > 9) && hours < 17) { - basetime = "1400"; - } - else if (hours <= 17 && minutes < 10) { - basetime = "1400"; - } - else if ((hours >= 17 && minutes > 9) && hours < 20) { - basetime = "1700"; - } - else if (hours <= 20 && minutes < 10) { - basetime = "1700"; - } - else if ((hours >= 20 && minutes > 9) && hours < 23) { - basetime = "2000"; - } - else if (hours <= 23 && minutes < 10) { - basetime = "2000"; - } - else - basetime = "2300"; + if (hours >= 2 && minutes > 9 && hours <= 5) { + basetime = '0200'; + } else if (hours >= 5 && minutes > 9 && hours < 8) { + basetime = '0500'; + } else if (hours <= 8 && minutes < 10) { + basetime = '0500'; + } else if (hours >= 8 && minutes > 9 && hours < 11) { + basetime = '0800'; + } else if (hours <= 11 && minutes < 10) { + basetime = '0800'; + } else if (hours >= 11 && minutes > 9 && hours < 14) { + basetime = '1100'; + } else if (hours <= 14 && minutes < 10) { + basetime = '1100'; + } else if (hours >= 14 && minutes > 9 && hours < 17) { + basetime = '1400'; + } else if (hours <= 17 && minutes < 10) { + basetime = '1400'; + } else if (hours >= 17 && minutes > 9 && hours < 20) { + basetime = '1700'; + } else if (hours <= 20 && minutes < 10) { + basetime = '1700'; + } else if (hours >= 20 && minutes > 9 && hours < 23) { + basetime = '2000'; + } else if (hours <= 23 && minutes < 10) { + basetime = '2000'; + } else basetime = '2300'; const apidata = { - serviceKey: "r6RMUsk3Vtama7D6uq7MiWV9dTC9MwfIIr4%2F45y0uVNw6BaYbgpKmL%2BLUDFVTfIYUmEe4K%2FaniEjdV9mg5t82Q%3D%3D", + serviceKey: + 'r6RMUsk3Vtama7D6uq7MiWV9dTC9MwfIIr4%2F45y0uVNw6BaYbgpKmL%2BLUDFVTfIYUmEe4K%2FaniEjdV9mg5t82Q%3D%3D', numOfRows: 1000, pageNo: 1, - dataType: "JSON", + dataType: 'JSON', base_date: date, base_time: basetime, nx: rs.x, ny: rs.y, - - } + nx2: nx, + ny2: ny + }; dispatch(FlightweatherAction.request(apidata)); } - }, [data]) - + }, [data]); const [active, setActive] = useState('active'); const [activeTab, setActiveTab] = useState('1'); @@ -271,8 +267,8 @@ const FlightPlanAreaDetailForm = ({ : coordList[0].lat && data[0].areaType && data[0].areaType !== 'POLYGON' - ? false - : true + ? false + : true } placeholder='반경' value={ @@ -298,8 +294,8 @@ const FlightPlanAreaDetailForm = ({ : coordList[0].lat && data[0].areaType && data[0].areaType !== 'POLYGON' - ? false - : true + ? false + : true } onClick={() => handleBufferList()} > @@ -402,8 +398,8 @@ const FlightPlanAreaDetailForm = ({ - {Object.keys(dayData).length != 0 && data[0]?.coordList[0].lat != 0 ? ( - + {Object.keys(dayData).length != 0 && + data[0]?.coordList[0].lat != 0 ? (
@@ -416,39 +412,56 @@ const FlightPlanAreaDetailForm = ({
    -
  • toggle('1')} >오늘
  • -
  • toggle('2')} >내일
  • -
  • toggle('3')} >모레
  • +
  • toggle('1')} + > + 오늘 +
  • +
  • toggle('2')} + > + 내일 +
  • +
  • toggle('3')} + > + 모레 +
- {activeTab == 1 ? + {activeTab == 1 ? (
- : + ) : ( <> - } - {activeTab == 2 ? + )} + {activeTab == 2 ? (
- +
- : + ) : ( <> - } - {activeTab == 3 ? + )} + {activeTab == 3 ? (
- +
- : + ) : ( <> - } - + )}
- ) : - null} + ) : null}