|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import moment from 'moment'; |
|
|
|
|
import React from 'react'; |
|
|
|
|
import React, { useMemo } from 'react'; |
|
|
|
|
import { useState, useEffect } from 'react'; |
|
|
|
|
import { X } from 'react-feather'; |
|
|
|
|
import { useDispatch, useSelector } from 'react-redux'; |
|
|
|
@ -33,77 +33,94 @@ const ControlReportDetail = props => {
|
|
|
|
|
const { controlGpDetail, controlDetail } = useSelector( |
|
|
|
|
state => state.controlGpDtlState |
|
|
|
|
); |
|
|
|
|
const { controlWheather } = useSelector(state => state.ControlGpWeatherState); |
|
|
|
|
//const { controlWheather } = useSelector(state => state.ControlGpWeatherState);
|
|
|
|
|
const { controlGpWarnLog } = useSelector(state => state.controlGpLogState); |
|
|
|
|
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)); |
|
|
|
|
function a() { |
|
|
|
|
if (controlDetail) { |
|
|
|
|
let wheatherDetail = controlDetail.items.item; |
|
|
|
|
let skyDetail = wheatherDetail[6].fcstValue; |
|
|
|
|
if (skyDetail == 1 || skyDetail == 2 || skyDetail == 4) { |
|
|
|
|
return <CloudRain />; |
|
|
|
|
} else if (skyDetail == 4) { |
|
|
|
|
return <CloudSnow />; |
|
|
|
|
} else if (skyDetail == 0 || wheatherDetail[5].fcstValue == 1) { |
|
|
|
|
return <Sun />; |
|
|
|
|
} else |
|
|
|
|
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]) |
|
|
|
|
// }, [controlGpDetail])
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
|
|
if (historyModal) { |
|
|
|
@ -335,11 +352,11 @@ const ControlReportDetail = props => {
|
|
|
|
|
</thead> |
|
|
|
|
<tbody> |
|
|
|
|
<tr> |
|
|
|
|
<td>15시</td> |
|
|
|
|
<td><Sun /></td> |
|
|
|
|
<td>27℃</td> |
|
|
|
|
<td><Navigation2 className="rotate-45" /></td> |
|
|
|
|
<td>2m/s</td> |
|
|
|
|
<td>{controlDetail?.items.item[12].fcstTime.substring(0, 2)}시</td> |
|
|
|
|
<td>{a()}</td> |
|
|
|
|
<td>{controlDetail?.items.item[12].fcstValue}℃</td> |
|
|
|
|
<td><Navigation2 style={{ transform: `rotate(${controlDetail?.items.item[3].fcstValue}deg)` }} /></td> |
|
|
|
|
<td>{controlDetail?.items.item[4].fcstValue}m/s</td> |
|
|
|
|
</tr> |
|
|
|
|
</tbody> |
|
|
|
|
</Table> |
|
|
|
|