diff --git "a/server/Data\353\252\205\354\204\270\354\204\234.md" "b/server/Data\353\252\205\354\204\270\354\204\234.md" index 3615953bf15e5796d89986a7d901498574fc5557..ed0b804fdef8bf789f96357f7b0330fd75dd8b35 100644 --- "a/server/Data\353\252\205\354\204\270\354\204\234.md" +++ "b/server/Data\353\252\205\354\204\270\354\204\234.md" @@ -8,16 +8,26 @@ �� Local Code (Do/��) �� Local Code (SGG/�쒓뎔援�) �� Local Code (EMD/�띾㈃��) - �� Year (��) - �� YYYYMMDD (��/��/��) - �� Outside - �� weather.csv - �� Users - �� ID (�ъ슜�� 媛쒖씤 ID) + �� Outside + �� YYYY (��) + �� YYYYMM (��/��) + �� YYYYMMDD (��/��/��) �� weather.csv - �� weights.csv + �� Users + �� ID (�ъ슜�� 媛쒖씤 ID) + �� YYYY (��) + �� YYYYMM (��/��) + �� YYYYMMDD (��/��/��) + �� weather.csv + �� weights.csv -�곗씠�곌� ���λ릺�� 寃쎈줈�� 援ъ“�낅땲��.<br><br> +�곗씠�곌� ���λ릺�� 寃쎈줈�� 援ъ“�낅땲��. + +- 1李� : 吏���퀎 ��遺꾨쪟 +- 2李� : �ъ슜�먯� �몃� �뺣낫 遺꾨쪟 +- 3李� : �� / �� / �� 遺꾨쪟 + +<br><br> # 2. Data Format @@ -37,9 +47,9 @@ �ъ슜�먭� �ㅼ젙�� �μ냼�� �곗씠�곕뒗 �ㅼ쓬怨� 媛숈� �뺤떇�쇰줈 ���λ맗�덈떎. -| Month | Date | Hour | Minute | Temperature | Humidity | Lights | Future Temperature | -| :---: | :--: | :--: | :----: | :---------: | :------: | :----: | :------------------: | -| �� | �� | �� | 遺� | �⑤룄(��) | �듬룄(%) | 愿묐룄 | �⑥쐞 �쒓컙 �� �⑤룄(��) | +| Month | Date | Hour | Minute | Temperature | Humidity | Lights | +| :---: | :--: | :--: | :----: | :---------: | :------: | :----: | +| �� | �� | �� | 遺� | �⑤룄(��) | �듬룄(%) | 愿묐룄 | <br><br> @@ -58,15 +68,15 @@ EUE媛� �쒖씪 以묒슂�섍쾶 �섑뻾�댁빞�� 遺�遺꾩엯�덈떎. �곗씠�곕� �숈뒿 - �몃� �곗씠�� - - �⑤룄 - - �듬룄 - - 湲곗븬 - - �띿냽 + - �⑤룄 ( Out Temperature ) + - �듬룄 ( Out Humidity ) + - 湲곗븬 ( Out Pressure ) + - �띿냽 ( Out Wind Speed ) - �ъ슜�� �곗씠�� - - �⑤룄 - - �듬룄 - - 愿묐룄 + - �⑤룄 ( Temperature ) + - �듬룄 ( Humidity ) + - 愿묐룄 ( Lights ) <br> diff --git a/server/src/controllers/dataController.js b/server/src/controllers/dataController.js index 06492a0ef53dcf5dcb7527e31e39b6ef4e5cae0b..2fc718a8a6be4f70045d07e2571d42d35a82e719 100644 --- a/server/src/controllers/dataController.js +++ b/server/src/controllers/dataController.js @@ -4,6 +4,9 @@ import fetch from "node-fetch"; const OUT = "Out"; const IN = "In"; +const OUTSIDE = "Outside"; +const USERS = "Users"; + // �곗씠�� �섏쭛 湲곕줈 遺��� 諛쏆븘�� 吏��� 肄붾뱶 �몃텇�� const locCodeSep = (code = "") => { const DO = code.slice(0, 2); @@ -40,12 +43,20 @@ const getTimeInfo = () => { return time; }; -const getDataDIR = (loc, time) => { - const repoDIR = `./data/${loc.DO}/${loc.SGG}/${loc.EMD}/${time.year}/${ - time.year - }${time.month < 10 ? "0" + time.month : time.month}${ - time.date < 10 ? "0" + time.date : time.date - }`; +const getDataDIR = (loc, time, id) => { + const year = time.year; + const month = time.month < 10 ? `0${time.month}` : time.month; + const date = time.date < 10 ? `0${time.date}` : time.date; + + const repoDIR = + "./data" + + `/${loc.DO}` + + `/${loc.SGG}` + + `/${loc.EMD}` + + `/${id}` + + `/${year}` + + `/${year}${month}` + + `/${year}${month}${date}`; return repoDIR; }; @@ -65,11 +76,6 @@ const storeData = (type, time, loc, fdir, data) => { }); console.log("Create directory."); - - if (type === IN) { - data = data.split("\n")[1]; - console.log("Split the user Data."); - } } // 洹� �몄쓽 �먮윭�� 異쒕젰 else console.log(err); @@ -81,7 +87,7 @@ const storeData = (type, time, loc, fdir, data) => { console.log( `${time.year}/${time.month}/${time.date} ${time.hour}:${ time.minute - } - ${loc.EMD} ${type === OUT ? "Outside" : "User"} data append.` + } - ${loc.EMD} ${type === OUT ? OUTSIDE : USERS} data append.` ); }); }); @@ -104,8 +110,8 @@ const handleOutData = (locCode, lat, lng) => { const loc = locCodeSep(locCode); const time = getTimeInfo(); - const fdir = getDataDIR(loc, time) + "/Outside"; - // �곗씠�� �뺤떇 - �� | �� | �� | 遺� | �⑤룄 | �듬룄 | 湲곗븬 | �띿냽 + const fdir = getDataDIR(loc, time, OUTSIDE); + // �곗씠�� �뺤떇 - [ �� | �� | �� | 遺� | �⑤룄 | �듬룄 | 湲곗븬 | �띿냽 ] const data = `${time.month},${time.date},${time.hour},${time.minute},${temp},${humi},${press},${wind_speed}\n`; storeData(OUT, time, loc, fdir, data); @@ -118,9 +124,9 @@ const handleInData = (id, locCode, temp, humi, lights) => { const loc = locCodeSep(locCode); const time = getTimeInfo(); - const fdir = getDataDIR(loc, time) + `/Users/${id}`; - // �곗씠�� �뺤떇 - [�댁쟾 以� : �꾩옱 �⑤룄 ( �댁쟾 湲곕줉 湲곗� �⑥쐞 �쒓컙 �� �⑤룄)] , [ �꾩옱 以� : �� | �� | �� | 遺� | �⑤룄 | �듬룄 | 愿묐룄 ] - const data = `${temp}\n${time.month},${time.date},${time.hour},${time.minute},${temp},${humi},${lights}`; + const fdir = getDataDIR(loc, time, `${USERS}/${id}`); + // �곗씠�� �뺤떇 - [ �� | �� | �� | 遺� | �⑤룄 | �듬룄 | 愿묐룄 ] + const data = `${time.month},${time.date},${time.hour},${time.minute},${temp},${humi},${lights}\n`; storeData(IN, time, loc, fdir, data); };