Browse Source

날씨 api 검색기능-미기능

ctrlDraw
sanguu(박상현) 2 years ago
parent
commit
64b0225019
  1. 319
      src/components/basis/flight/plan/FlightPlanAreaDetailForm.js
  2. 420
      src/components/basis/flight/plan/TodayWeather.js
  3. 18
      src/modules/basis/flight/actions/basisFlightAction.ts
  4. 11
      src/modules/basis/flight/apis/basisFlightApi.ts
  5. 37
      src/modules/basis/flight/models/basisFlightModel.ts
  6. 10
      src/modules/basis/flight/reducers/basisFlightReducer.ts
  7. 31
      src/modules/basis/flight/sagas/basisFlightSaga.ts
  8. 2
      src/modules/control/gp/actions/controlGpAction.ts
  9. 76
      src/views/control/report/ControlReportDetail.js

319
src/components/basis/flight/plan/FlightPlanAreaDetailForm.js

@ -1,4 +1,6 @@
import React, { useEffect, useState } from 'react'; 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 { import {
Card, Card,
CardBody, CardBody,
@ -12,6 +14,10 @@ import {
Input, Input,
Table Table
} from 'reactstrap'; } from 'reactstrap';
import dfsxyconv from '../../../../utility/dfsxyconv';
import { useDispatch, useSelector } from 'react-redux';
import moment from 'moment';
import { import {
Search, Search,
Compass, Compass,
@ -23,7 +29,7 @@ import {
CloudSnow, CloudSnow,
Navigation2 Navigation2
} from 'react-feather'; } from 'react-feather';
import { object } from 'prop-types';
const FlightPlanAreaDetailForm = ({ const FlightPlanAreaDetailForm = ({
handleSave, handleSave,
handleClose, handleClose,
@ -34,7 +40,141 @@ const FlightPlanAreaDetailForm = ({
isDone, isDone,
isDisabled isDisabled
}) => { }) => {
const [dayData, setdayData] = useState({});
const coordList = data ? data[0].coordList : null; 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');
useEffect(() => {
if (weather) {
let wheatherobj = {};
const weatherData = weather?.item;
//오늘 날씨 필터링
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 }
}
});
//내일 날씨 필터링todayres.category == ("TMP" || "SKY" || "VEC" || "WSD" || "PTY")
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 }
}
});
//모레 날씨 필터링
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 }
}
});
wheatherobj = {
todayData,
tomorrowData,
afterData,
}
setdayData({ ...wheatherobj });
}
}, [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);
let now = new Date();
let hours = now.getHours();
let minutes = now.getMinutes();
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 = "2000";
}
else if ((hours >= 20 && minutes > 9) && hours < 23) {
basetime = "2000";
}
else if (hours <= 23 && minutes < 10) {
basetime = "2300";
}
else if (hours >= 23 && minutes > 9) {
basetime = "2300";
}
const apidata = {
serviceKey: "r6RMUsk3Vtama7D6uq7MiWV9dTC9MwfIIr4%2F45y0uVNw6BaYbgpKmL%2BLUDFVTfIYUmEe4K%2FaniEjdV9mg5t82Q%3D%3D",
numOfRows: 1000,
pageNo: 1,
dataType: "JSON",
base_date: date,
base_time: basetime,
nx: rs.x,
ny: rs.y,
}
dispatch(FlightweatherAction.request(apidata));
}
}, [data])
const [active, setActive] = useState('active');
const [activeTab, setActiveTab] = useState('1');
const toggle = tab => {
return setActiveTab(tab);
};
return ( return (
<Card className='mb-0'> <Card className='mb-0'>
@ -261,6 +401,9 @@ const FlightPlanAreaDetailForm = ({
닫기 닫기
</Button.Ripple> </Button.Ripple>
</div> </div>
{Object.keys(dayData).length != 0 && data[0]?.coordList[0].lat != 0 ? (
<div className='layer-content'> <div className='layer-content'>
<div className='layer-weather-box'> <div className='layer-weather-box'>
<div className='layer-weather-info'> <div className='layer-weather-info'>
@ -271,167 +414,41 @@ const FlightPlanAreaDetailForm = ({
<Compass size={20} /> 인천광역시 부평구 안남로 272 <Compass size={20} /> 인천광역시 부평구 안남로 272
</span> </span>
</div> </div>
{/* 탭메뉴or탭내용 활성화 active */}
<div className='tab-menu'> <div className='tab-menu'>
<ul> <ul>
<li className=''>오늘</li> <li className={activeTab == 1 ? `active` : ''} onClick={() => toggle('1')} >오늘</li>
<li className='active'>주간</li> <li className={activeTab == 2 ? `active` : ''} onClick={() => toggle('2')} >내일</li>
<li className={activeTab == 3 ? `active` : ''} onClick={() => toggle('3')} >모레</li>
</ul> </ul>
</div> </div>
<div className='tab-content'> {activeTab == 1 ?
<Table responsive> <div className='tab-content active'>
<thead> <TodayWeather todayData={dayData.todayData} />
<tr>
<th>시각</th>
<th>날씨</th>
<th>기온</th>
<th>풍향</th>
<th>풍속</th>
</tr>
</thead>
<tbody>
<tr>
<td>10</td>
<td>
<Sun />
</td>
<td>27</td>
<td>
<Navigation2 className='rotate-45' />
</td>
<td>2m/s</td>
</tr>
<tr>
<td>12</td>
<td>
<CloudLightning />
</td>
<td>30</td>
<td>
<Navigation2 className='rotate-75' />
</td>
<td>3m/s</td>
</tr>
<tr>
<td>14</td>
<td>
<Cloud />
</td>
<td>28</td>
<td>
<Navigation2 className='rotate-90' />
</td>
<td>4m/s</td>
</tr>
<tr>
<td>16</td>
<td>
<CloudRain />
</td>
<td>27</td>
<td>
<Navigation2 className='rotate-135' />
</td>
<td>7m/s</td>
</tr>
<tr>
<td>18</td>
<td>
<CloudSnow />
</td>
<td>25</td>
<td>
<Navigation2 className='rotate-180' />
</td>
<td>2m/s</td>
</tr>
<tr>
<td>20</td>
<td>
<CloudDrizzle />
</td>
<td>26</td>
<td>
<Navigation2 className='rotate-225' />
</td>
<td>2m/s</td>
</tr>
</tbody>
</Table>
</div> </div>
:
<></>
}
{activeTab == 2 ?
<div className='tab-content active'> <div className='tab-content active'>
<Table responsive> <TomorrowWeahter tomorrowData={dayData.tomorrowData} />
<thead>
<tr>
<th>날짜</th>
<th>날씨</th>
<th>기온</th>
</tr>
</thead>
<tbody>
<tr>
<td>06.19.() 오전</td>
<td>
<Sun />
</td>
<td>최저 27</td>
</tr>
<tr>
<td>06.19.() 오후</td>
<td>
<CloudLightning />
</td>
<td>30</td>
</tr>
<tr>
<td>06.20.() 오전</td>
<td>
<CloudLightning />
</td>
<td>30</td>
</tr>
<tr>
<td>06.20.() 오후</td>
<td>
<CloudLightning />
</td>
<td>30</td>
</tr>
<tr>
<td>06.21.() 오전</td>
<td>
<CloudLightning />
</td>
<td>30</td>
</tr>
<tr>
<td>06.21.() 오후</td>
<td>
<CloudLightning />
</td>
<td>30</td>
</tr>
<tr>
<td>06.22.() 오전</td>
<td>
<CloudLightning />
</td>
<td>30</td>
</tr>
<tr>
<td>06.2.() 오후</td>
<td>
<CloudLightning />
</td>
<td>30</td>
</tr>
</tbody>
</Table>
</div> </div>
:
<></>
}
{activeTab == 3 ?
<div className='tab-content active'>
<AfterTomorrowWeahter afterData={dayData.afterData} />
</div>
:
<></>
}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
) :
null}
</CardBody> </CardBody>
</Card> </Card>
</Col> </Col>

420
src/components/basis/flight/plan/TodayWeather.js

@ -0,0 +1,420 @@
import {
Card,
CardBody,
Col,
FormGroup,
Label,
Row,
Button,
InputGroupAddon,
InputGroup,
Input,
Table
} from 'reactstrap';
import {
Search,
Compass,
Sun,
CloudLightning,
Cloud,
CloudRain,
CloudDrizzle,
CloudSnow,
Navigation2
} from 'react-feather';
import { mapTypeChangeAction } from '../../../../modules/control/map/actions/controlMapActions';
export function TodayWeather({ todayData }) {
todayData?.fcstTime?.sort([compareFunction]);
const dayres = todayData?.filter(dayData => {
switch (dayData?.fcstTime) {
case "0200":
case "0500":
case "0500":
case "0800":
case "1100":
case "1400":
case "1700":
case "2000":
case "2300":
return { ...dayData?.todayData }
}
});
// 배열.reduce((누적값, 현잿값, 인덱스, 요소) => { return 결과 }, 초깃값);
const groupValues = dayres.reduce((acc, current) => {
acc[current.fcstTime] = acc[current.fcstTime] || [];
acc[current.fcstTime].push({ category: current.category, fcstValue: current.fcstValue });
return acc;
}, {});
// 위에서 만든 객체를 key로 돌려서 새로운 객체 return
const groups = Object.keys(groupValues).map((key) => {
return { fcstTime: key, category: groupValues[key] };
});
return (
<>
{dayres.length > 0 ? (
<Table responsive>
<thead>
<tr>
<th>시각</th>
<th>날씨</th>
<th>기온</th>
<th>풍향</th>
<th>풍속</th>
</tr>
</thead>
<tbody>
{groups.map((i) => {
return (
<tr>
<td>{i.fcstTime.substring(0, 2)}</td>
{i.category[4].fcstValue == "0" ?
<td>
{i.category[3].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{i.category[4].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{i.category[0].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${i.category[1]?.fcstValue}deg)` }} />
</td>
<td>{i.category[2].fcstValue}</td>
</tr>
)
})}
</tbody>
</Table>
) :
null}
</>
)
}
export function TomorrowWeahter({ tomorrowData }) {
tomorrowData?.fcstTime?.sort([compareFunction]);
const dayres = tomorrowData?.filter(dayData => {
switch (dayData?.fcstTime) {
case "0200":
case "0500":
case "0500":
case "0800":
case "1100":
case "1400":
case "1700":
case "2000":
case "2300":
return { ...dayData?.tomorrowData }
}
});
return (
<Table responsive>
<thead>
<tr>
<th>시각</th>
<th>날씨</th>
<th>기온</th>
<th>풍향</th>
<th>풍속</th>
</tr>
</thead>
<tbody>
<tr>
<td>{dayres[0]?.fcstTime.substring(0, 2)}</td>
{dayres[3].fcstValue != "0" ?
<td>
{dayres[3].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[4].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[0].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[1]?.fcstValue}deg)` }} />
</td>
<td>{dayres[2].fcstValue}</td>
</tr>
<tr>
<td>{dayres[5].fcstTime.substring(0, 2)}</td>
{dayres[8].fcstValue != "0" ?
<td>
{dayres[8].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[9].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[5].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[6]?.fcstValue}deg)` }} />
</td>
<td>{dayres[7].fcstValue}</td>
</tr>
<tr>
<td>{dayres[10].fcstTime.substring(0, 2)}</td>
{dayres[13].fcstValue != "0" ?
<td>
{dayres[13].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[14].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[10].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[11]?.fcstValue}deg)` }} />
</td>
<td>{dayres[12].fcstValue}</td>
</tr>
<tr>
<td>{dayres[15].fcstTime.substring(0, 2)}</td>
{dayres[18].fcstValue != "0" ?
<td>
{dayres[18].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[19].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[15].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[16]?.fcstValue}deg)` }} />
</td>
<td>{dayres[17].fcstValue}</td>
</tr>
<tr>
<td>{dayres[20].fcstTime.substring(0, 2)}</td>
{dayres[23].fcstValue != "0" ?
<td>
{dayres[23].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[24].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[20].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[21]?.fcstValue}deg)` }} />
</td>
<td>{dayres[22].fcstValue}</td>
</tr>
<tr>
<td>{dayres[25].fcstTime.substring(0, 2)}</td>
{dayres[28].fcstValue != "0" ?
<td>
{dayres[28].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[29].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[25].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[26]?.fcstValue}deg)` }} />
</td>
<td>{dayres[27].fcstValue}</td>
</tr>
<tr>
<td>{dayres[30].fcstTime.substring(0, 2)}</td>
{dayres[33].fcstValue != "0" ?
<td>
{dayres[33].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[34].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[30].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[31]?.fcstValue}deg)` }} />
</td>
<td>{dayres[32].fcstValue}</td>
</tr>
<tr>
<td>{dayres[35].fcstTime.substring(0, 2)}</td>
{dayres[38].fcstValue != "0" ?
<td>
{dayres[38].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[39].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[35].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[36]?.fcstValue}deg)` }} />
</td>
<td>{dayres[37].fcstValue}</td>
</tr>
</tbody>
</Table>
)
}
export function AfterTomorrowWeahter({ afterData }) {
afterData?.fcstTime?.sort([compareFunction]);
const dayres = afterData?.filter(dayData => {
switch (dayData?.fcstTime) {
case "0200":
case "0500":
case "0500":
case "0800":
case "1100":
case "1400":
case "1700":
case "2000":
case "2300":
return { ...dayData?.afterData }
}
});
console.log(dayres);
return (
<Table responsive>
<thead>
<tr>
<th>시각</th>
<th>날씨</th>
<th>기온</th>
<th>풍향</th>
<th>풍속</th>
</tr>
</thead>
<tbody>
<tr>
<td>{dayres[0].fcstTime.substring(0, 2)}</td>
{dayres[3].fcstValue != "0" ?
<td>
{dayres[3].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[4].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[0].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[1]?.fcstValue}deg)` }} />
</td>
<td>{dayres[2].fcstValue}</td>
</tr>
<tr>
<td>{dayres[5].fcstTime.substring(0, 2)}</td>
{dayres[8].fcstValue != "0" ?
<td>
{dayres[8].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[9].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[5].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[6]?.fcstValue}deg)` }} />
</td>
<td>{dayres[7].fcstValue}</td>
</tr>
<tr>
<td>{dayres[10].fcstTime.substring(0, 2)}</td>
{dayres[13].fcstValue != "0" ?
<td>
{dayres[13].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[14].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[10].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[11]?.fcstValue}deg)` }} />
</td>
<td>{dayres[12].fcstValue}</td>
</tr>
<tr>
<td>{dayres[15].fcstTime.substring(0, 2)}</td>
{dayres[18].fcstValue != "0" ?
<td>
{dayres[18].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[19].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[15].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[16]?.fcstValue}deg)` }} />
</td>
<td>{dayres[17].fcstValue}</td>
</tr>
<tr>
<td>{dayres[20].fcstTime.substring(0, 2)}</td>
{dayres[23].fcstValue != "0" ?
<td>
{dayres[23].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[24].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[20].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[21]?.fcstValue}deg)` }} />
</td>
<td>{dayres[22].fcstValue}</td>
</tr>
<tr>
<td>{dayres[25].fcstTime.substring(0, 2)}</td>
{dayres[28].fcstValue != "0" ?
<td>
{dayres[28].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[29].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[25].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[26]?.fcstValue}deg)` }} />
</td>
<td>{dayres[27].fcstValue}</td>
</tr>
<tr>
<td>{dayres[30].fcstTime.substring(0, 2)}</td>
{dayres[33].fcstValue != "0" ?
<td>
{dayres[33].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[34].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[30].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[31]?.fcstValue}deg)` }} />
</td>
<td>{dayres[32].fcstValue}</td>
</tr>
<tr>
<td>{dayres[35].fcstTime.substring(0, 2)}</td>
{dayres[38].fcstValue != "0" ?
<td>
{dayres[38].fcstValue == "1" ? <Sun /> : <Cloud />}
</td>
: <td>
{dayres[39].fcstValue == "3" ? <CloudSnow /> : <CloudRain />}
</td>
}
<td>{dayres[35].fcstValue}</td>
<td>
<Navigation2 style={{ transform: `rotate(${dayres[36]?.fcstValue}deg)` }} />
</td>
<td>{dayres[37].fcstValue}</td>
</tr>
</tbody>
</Table>
)
}

18
src/modules/basis/flight/actions/basisFlightAction.ts

@ -11,7 +11,9 @@ import {
PilotSelectData, PilotSelectData,
SelectGroupData, SelectGroupData,
BasFlightAprovData, BasFlightAprovData,
BasFlightScheduleList BasFlightScheduleList,
weatherData,
resweatherData
} from '../models/basisFlightModel'; } from '../models/basisFlightModel';
// 공역 조회 // 공역 조회
@ -86,6 +88,10 @@ const AREA_DETAIL_INITIAL = 'basis/flight/plan/detail/AREA_DETAIL_INIT';
const AREA_BUFFER_LIST_REQUEST = 'basis/flight/plan/area/BUFFER_LIST_REQUEST'; const AREA_BUFFER_LIST_REQUEST = 'basis/flight/plan/area/BUFFER_LIST_REQUEST';
const AREA_BUFFER_LIST_SUCCESS = 'basis/flight/plan/area/BUFFER_LIST_SUCCESS'; const AREA_BUFFER_LIST_SUCCESS = 'basis/flight/plan/area/BUFFER_LIST_SUCCESS';
const AREA_BUFFER_LIST_FAILURE = 'basis/flight/plan/area/BUFFER_LIST_FAILURE'; const AREA_BUFFER_LIST_FAILURE = 'basis/flight/plan/area/BUFFER_LIST_FAILURE';
// 날씨
const FLIGHT_WEATHER_REQUEST = 'control/gp/FLIGHT_WEATHER_REQUEST';
const FLIGHT_WEATHER_SUCCESS = 'control/gp/FLIGHT_WEATHER_SUCCESS';
const FLIGHT_WEATHER_FAILURE = 'control/gp/FLIGHT_WEATHER_FAILURE';
// 비행계획서 조회(승인) // 비행계획서 조회(승인)
const FLIGHT_APRV_LIST_REQUEST = const FLIGHT_APRV_LIST_REQUEST =
@ -255,6 +261,13 @@ export const FLIGHT_SCHEDULE_LIST = createAsyncAction(
FLIGHT_SCHEDULE_FAILURE FLIGHT_SCHEDULE_FAILURE
)<string, [BasFlightScheduleList], AxiosError>(); )<string, [BasFlightScheduleList], AxiosError>();
//비행구역 설정 날씨 API
export const FlightweatherAction = createAsyncAction(
FLIGHT_WEATHER_REQUEST,
FLIGHT_WEATHER_SUCCESS,
FLIGHT_WEATHER_FAILURE
)<weatherData, resweatherData, AxiosError>();
const actions = { const actions = {
PUBLIC_AREA_LIST, PUBLIC_AREA_LIST,
// FLIGHT_PLAN_AREA, // FLIGHT_PLAN_AREA,
@ -277,7 +290,8 @@ const actions = {
FLIGHT_APRV_LIST, FLIGHT_APRV_LIST,
FLIGHT_APRV_PROC, FLIGHT_APRV_PROC,
SEARCH_AREA, SEARCH_AREA,
FLIGHT_SCHEDULE_LIST FLIGHT_SCHEDULE_LIST,
FlightweatherAction
}; };
export type FlightAction = ActionType<typeof actions>; export type FlightAction = ActionType<typeof actions>;

11
src/modules/basis/flight/apis/basisFlightApi.ts

@ -5,7 +5,8 @@ import {
FlightPlanAreaData, FlightPlanAreaData,
FlightPlanAreaDataList, FlightPlanAreaDataList,
FlightPlanData, FlightPlanData,
FlightPlanListRqData FlightPlanListRqData,
weatherData
} from '../models/basisFlightModel'; } from '../models/basisFlightModel';
export const flightPlanAPI = { export const flightPlanAPI = {
@ -53,6 +54,14 @@ export const flightPlanAPI = {
const res = await axios.post(`api/bas/flight/plan/area/buffer`, data); const res = await axios.post(`api/bas/flight/plan/area/buffer`, data);
return res; return res;
}, },
apiweather: async (rq: weatherData) => {
const { data } = await axios.get(`api/bas/flight/plan/api/weather`, {
params: {
...rq
}
});
return data;
},
aprvList: async (data: FlightPlanListRqData) => { aprvList: async (data: FlightPlanListRqData) => {
const queryString = qs.stringify(data, { const queryString = qs.stringify(data, {
addQueryPrefix: true, addQueryPrefix: true,

37
src/modules/basis/flight/models/basisFlightModel.ts

@ -18,6 +18,42 @@ export interface FlightState {
page: number | 1; page: number | 1;
total: number | 0; total: number | 0;
conut: number | 0; conut: number | 0;
weather: resweatherData | undefined;
}
export interface weatherData {
serviceKey: string;
numOfRows: string;
pageNo: string;
dataType: string;
base_date: string;
base_time: string;
nx: string;
ny: string;
}
export interface resweatherData {
resultCode: string;
resultMsg: string;
numOfRows: string;
pageNo: string;
totalCount: string;
dataType: string;
baseDate: string;
baseTime: string;
fcstDate: string;
fcstTime: string;
category: string;
fcstValue: string;
nx: string;
ny: string;
hstryAreaSno: string;
area1: string;
area2: string;
area3: string;
zipCd: string;
landNm: string;
landNum: string;
areaType: string;
areaNm: string;
} }
export interface SelectGroupData { export interface SelectGroupData {
@ -197,6 +233,7 @@ export interface BasFlightScheduleData {
} }
export const initFlight = { export const initFlight = {
weather: undefined,
page: 1, page: 1,
total: 0, total: 0,
conut: 0, conut: 0,

10
src/modules/basis/flight/reducers/basisFlightReducer.ts

@ -5,7 +5,8 @@ import * as Actions from '../actions/basisFlightAction';
import { import {
FlightState, FlightState,
initFlight, initFlight,
initFlightBas initFlightBas,
resweatherData
} from '../models/basisFlightModel'; } from '../models/basisFlightModel';
import { any } from 'prop-types'; import { any } from 'prop-types';
@ -111,6 +112,13 @@ export const flightReducer = createReducer<FlightState, Actions.FlightAction>(
draft.areaCoordList = data; draft.areaCoordList = data;
}) })
) )
//비행구역설정 날씨 API
.handleAction(Actions.FlightweatherAction.success, (state, action) =>
produce(state, draft => {
const data: resweatherData = action.payload;
draft.weather = data;
})
)
// 조종사, 기체 선택 초기화 // 조종사, 기체 선택 초기화
.handleAction(Actions.AREA_DETAIL_INIT, (state, action) => .handleAction(Actions.AREA_DETAIL_INIT, (state, action) =>
produce(state, draft => { produce(state, draft => {

31
src/modules/basis/flight/sagas/basisFlightSaga.ts

@ -47,23 +47,6 @@ function* listAreaSaga(
} }
} }
// function* createFlightPlanArea(action: ActionType<typeof Actions.FLIGHT_PLAN_AREA.request>) {
// try {
// const data = action.payload;
//
// yield put(
// Actions.FLIGHT_PLAN_AREA.success({
// data: data
// })
// )
//
// } catch (error: any) {
// yield put(
// Actions.FLIGHT_PLAN_AREA.failure(error)
// )
// }
// }
// 비행계획서 목록 // 비행계획서 목록
function* listPlanSaga( function* listPlanSaga(
action: ActionType<typeof Actions.FLIGHT_PLAN_LIST.request> action: ActionType<typeof Actions.FLIGHT_PLAN_LIST.request>
@ -113,7 +96,18 @@ function* detailPlanSaga(
yield put(Actions.FLIGHT_PLAN_DETAIL.failure(error)); yield put(Actions.FLIGHT_PLAN_DETAIL.failure(error));
} }
} }
//비행 구역 설정 날씨 API
function* WeatherSaga(
action: ActionType<typeof Actions.FlightweatherAction.request>
) {
try {
const rq = action.payload;
const data = yield call(Apis.flightPlanAPI.apiweather, rq);
yield put(Actions.FlightweatherAction.success(data.response.body.items));
} catch (error) {
yield put(Actions.FlightweatherAction.failure(error));
}
}
// 비행계획서 등록 // 비행계획서 등록
function* createPlanSaga( function* createPlanSaga(
action: ActionType<typeof Actions.FLIGHT_PLAN_CREATE.request> action: ActionType<typeof Actions.FLIGHT_PLAN_CREATE.request>
@ -454,4 +448,5 @@ export function* flightSaga() {
yield takeEvery(Actions.FLIGHT_APRV_PROC.request, aprvProcSaga); yield takeEvery(Actions.FLIGHT_APRV_PROC.request, aprvProcSaga);
yield takeEvery(Actions.SEARCH_AREA.request, searchAreaSaga); yield takeEvery(Actions.SEARCH_AREA.request, searchAreaSaga);
yield takeEvery(Actions.FLIGHT_SCHEDULE_LIST.request, scheduleListSaga); yield takeEvery(Actions.FLIGHT_SCHEDULE_LIST.request, scheduleListSaga);
yield takeEvery(Actions.FlightweatherAction.request, WeatherSaga);
} }

2
src/modules/control/gp/actions/controlGpAction.ts

@ -54,7 +54,7 @@ const CONTROL_GP_LOG_REQIEST = 'control/gp/CONTROL_GP_LOG_REQUEST';
const CONTROL_GP_LOG_SUCCESS = 'control/gp/CONTROL_GP_LOG_SUCCESS'; const CONTROL_GP_LOG_SUCCESS = 'control/gp/CONTROL_GP_LOG_SUCCESS';
const CONTROL_GP_LOG_FAILURE = 'control/gp/CONTROL_GP_LOG_FAILURE'; const CONTROL_GP_LOG_FAILURE = 'control/gp/CONTROL_GP_LOG_FAILURE';
//로그 리스트 조회 //날씨 API
const CONTROL_WEATHER_REQUEST = 'control/gp/CONTROL_WEATHER_REQUEST'; const CONTROL_WEATHER_REQUEST = 'control/gp/CONTROL_WEATHER_REQUEST';
const CONTROL_WEATHER_SUCCESS = 'control/gp/CONTROL_WEATHER_SUCCESS'; const CONTROL_WEATHER_SUCCESS = 'control/gp/CONTROL_WEATHER_SUCCESS';
const CONTROL_WEATHER_FAILURE = 'control/gp/CONTROL_WEATHER_FAILURE'; const CONTROL_WEATHER_FAILURE = 'control/gp/CONTROL_WEATHER_FAILURE';

76
src/views/control/report/ControlReportDetail.js

@ -11,7 +11,6 @@ import {
GET_ARCTFT_TYPE_CD, GET_ARCTFT_TYPE_CD,
GET_WGHT_TYPE_CD GET_WGHT_TYPE_CD
} from '../../../utility/CondeUtil'; } from '../../../utility/CondeUtil';
import dfsxyconv from '../../../utility/dfsxyconv';
import { controlGpLogAction, controlweatherAction } from '../../../modules/control/gp'; import { controlGpLogAction, controlweatherAction } from '../../../modules/control/gp';
import ControlAlarmDetail from '../alarm/ControlAlarmDetail'; import ControlAlarmDetail from '../alarm/ControlAlarmDetail';
import axios from '../../../modules/utils/customAxiosUtil'; import axios from '../../../modules/utils/customAxiosUtil';
@ -37,7 +36,7 @@ const ControlReportDetail = props => {
const { controlGpWarnLog } = useSelector(state => state.controlGpLogState); const { controlGpWarnLog } = useSelector(state => state.controlGpLogState);
function a() { function weathericon() {
if (controlDetail) { if (controlDetail) {
let wheatherDetail = controlDetail.items.item; let wheatherDetail = controlDetail.items.item;
let skyDetail = wheatherDetail[6].fcstValue; let skyDetail = wheatherDetail[6].fcstValue;
@ -51,76 +50,7 @@ const ControlReportDetail = props => {
return <Cloud />; return <Cloud />;
} }
} }
// console.log("time", time);
// useEffect(() => {
// if (controlGpDetail) {
// const rs = dfsxyconv("toXY", controlGpDetail?.lat, controlGpDetail?.lng);
// let now = new Date();
// let year = now.getFullYear(); // 년도
// let month = now.getMonth() + 1; // 월
// let day = ('0' + now.getDate()).slice(-2); // 날짜
// const today = `${year}${month}${day}`;
// let hours = now.getHours();
// let minutes = now.getMinutes();
// 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 && 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 = "2000";
// }
// else if ((hours >= 20 && minutes > 9) && hours < 23) {
// basetime = "2000";
// }
// else if (hours >= 23 && minutes < 10) {
// basetime = "2300";
// }
// else if (hours >= 23 && minutes > 9) {
// basetime = "2300";
// }
// const apidata = {
// serviceKey: "r6RMUsk3Vtama7D6uq7MiWV9dTC9MwfIIr4%2F45y0uVNw6BaYbgpKmL%2BLUDFVTfIYUmEe4K%2FaniEjdV9mg5t82Q%3D%3D",
// numOfRows: 14,
// pageNo: 1,
// dataType: "JSON",
// base_date: today,
// base_time: basetime,
// nx: rs.x,
// ny: rs.y,
// }
// dispatch(controlweatherAction.request(apidata));
// }
// }, [controlGpDetail])
useEffect(() => { useEffect(() => {
if (historyModal) { if (historyModal) {
@ -352,8 +282,8 @@ const ControlReportDetail = props => {
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>{controlDetail?.items.item[12].fcstTime.substring(0, 2)}</td> <td>{controlDetail?.items.item[0].baseTime.substring(0, 2)}</td>
<td>{a()}</td> <td>{weathericon()}</td>
<td>{controlDetail?.items.item[12].fcstValue}</td> <td>{controlDetail?.items.item[12].fcstValue}</td>
<td><Navigation2 style={{ transform: `rotate(${controlDetail?.items.item[3].fcstValue}deg)` }} /></td> <td><Navigation2 style={{ transform: `rotate(${controlDetail?.items.item[3].fcstValue}deg)` }} /></td>
<td>{controlDetail?.items.item[4].fcstValue}m/s</td> <td>{controlDetail?.items.item[4].fcstValue}m/s</td>

Loading…
Cancel
Save