Showing
1 changed file
with
2 additions
and
25 deletions
1 | -//const db = require('./db.js'); | ||
2 | -//const db_traffic = require('./db_traffic.js'); | ||
3 | const db_total = require('./db_total.js'); //DB 합침 | 1 | const db_total = require('./db_total.js'); //DB 합침 |
4 | const secret_key = require('../keys/api_option').key; | 2 | const secret_key = require('../keys/api_option').key; |
5 | const secret_key_traffic = require('../keys/api_option_traffic').key; | 3 | const secret_key_traffic = require('../keys/api_option_traffic').key; |
... | @@ -33,13 +31,6 @@ module.exports = (server, app) => { | ... | @@ -33,13 +31,6 @@ module.exports = (server, app) => { |
33 | let info = {} //;? | 31 | let info = {} //;? |
34 | 32 | ||
35 | let Current_TrafficAcc = {}; | 33 | let Current_TrafficAcc = {}; |
36 | - //let sql_traffic; | ||
37 | - //let DeathNum_index = {}; //사망자 | ||
38 | - //let M_HurtNum_index = {}; //중상자 | ||
39 | - //let L_HurtNum_index = {}; //경상자 | ||
40 | - //let LocalName_index = {}; //지역 이름 | ||
41 | - //let OccurNum_index = {}; //발생 건수 | ||
42 | - //afos_fid: 다발지역 FID, bjd_cd: 법정동 코드, spot_cd:지점코드 | ||
43 | 34 | ||
44 | //API 호출_Weather | 35 | //API 호출_Weather |
45 | const req_API = (when, what) => { | 36 | const req_API = (when, what) => { |
... | @@ -57,7 +48,7 @@ module.exports = (server, app) => { | ... | @@ -57,7 +48,7 @@ module.exports = (server, app) => { |
57 | 48 | ||
58 | // api의 response이 있을경우 promise resolve 호출 | 49 | // api의 response이 있을경우 promise resolve 호출 |
59 | if (api_res) { | 50 | if (api_res) { |
60 | - console.log("calling weather & trafffic api"); | 51 | + console.log("calling weather api"); |
61 | resolve(api_body); | 52 | resolve(api_body); |
62 | } | 53 | } |
63 | }); | 54 | }); |
... | @@ -104,11 +95,6 @@ module.exports = (server, app) => { | ... | @@ -104,11 +95,6 @@ module.exports = (server, app) => { |
104 | Ultra_Violet_index = await req_API("index", "uv"); //자외선지수 | 95 | Ultra_Violet_index = await req_API("index", "uv"); //자외선지수 |
105 | 96 | ||
106 | Current_TrafficAcc = await req_API_traffic("frequentzoneLg", "getRestFrequentzoneLg"); //cate1, cate2 | 97 | Current_TrafficAcc = await req_API_traffic("frequentzoneLg", "getRestFrequentzoneLg"); //cate1, cate2 |
107 | - /*DeathNum_index = await req_API_traffic("frequentzoneLg", "getRestFrequentzoneLg"); | ||
108 | - M_HurtNum_index = await req_API_traffic("frequentzoneLg", "getRestFrequentzoneLg"); | ||
109 | - L_HurtNum_index = await req_API_traffic("frequentzoneLg", "getRestFrequentzoneLg"); | ||
110 | - LocalName_index = await req_API_traffic("frequentzoneLg", "getRestFrequentzoneLg"); | ||
111 | - OccurNum_index = await req_API_traffic("frequentzoneLg", "getRestFrequentzoneLg");*/ | ||
112 | 98 | ||
113 | info = { | 99 | info = { |
114 | heat: Heat_index.weather.wIndex.heatIndex[0].current.index, //열지수 | 100 | heat: Heat_index.weather.wIndex.heatIndex[0].current.index, //열지수 |
... | @@ -147,7 +133,7 @@ module.exports = (server, app) => { | ... | @@ -147,7 +133,7 @@ module.exports = (server, app) => { |
147 | info.death_prob = ( | 133 | info.death_prob = ( |
148 | (info.heat / 50) + (Math.abs(info.sensible_temperature - 15) / 10) + (info.discomport / 10) + (info.UV / 10) | 134 | (info.heat / 50) + (Math.abs(info.sensible_temperature - 15) / 10) + (info.discomport / 10) + (info.UV / 10) |
149 | + info.windspd * 1 + (info.rain / 10) + (Math.abs(info.current_temperature - 15) / 10) | 135 | + info.windspd * 1 + (info.rain / 10) + (Math.abs(info.current_temperature - 15) / 10) |
150 | - + (info.death_number / 50) + (info.midhurt_number / 80) + (info.lighthurt_number / 90) + (info.occur_number / 90) | 136 | + + (info.death_number / 60) + (info.midhurt_number / 80) + (info.lighthurt_number / 90) + (info.occur_number / 90) |
151 | ); | 137 | ); |
152 | 138 | ||
153 | //이벤트 기반으로 일정 시간 간격으로 클라이언트에게 보낼 정보, 홈페이지 그래프에 나타날 정보 | 139 | //이벤트 기반으로 일정 시간 간격으로 클라이언트에게 보낼 정보, 홈페이지 그래프에 나타날 정보 |
... | @@ -190,15 +176,6 @@ module.exports = (server, app) => { | ... | @@ -190,15 +176,6 @@ module.exports = (server, app) => { |
190 | console.log("emit"); | 176 | console.log("emit"); |
191 | 177 | ||
192 | //db에 저장 | 178 | //db에 저장 |
193 | - /*sql = "INSERT INTO weatherInfo (time,wind,temperature,rain,prob) VALUES (?,?,?,?,?)"; | ||
194 | - db.query(sql, [client_send.time, client_send.wind, client_send.temperature, client_send.rain, client_send.death], (err, result) => { | ||
195 | - if (err) console.log(err); | ||
196 | - }) | ||
197 | - | ||
198 | - sql_traffic = "INSERT INTO trafficInfo (tdeath,mhurt,lhurt,occurence,prob) VALUES (?,?,?,?,?)"; | ||
199 | - db_traffic.query(sql_traffic, [client_send.trafficdeath, client_send.mhurt, client_send.lhurt, client_send.occurence, client_send.death], (err, result) => { | ||
200 | - if (err) console.log(err); | ||
201 | - })*/ | ||
202 | sql = "INSERT INTO apisInfo (time,wind,temperature,rain,prob,tdeath,mhurt,lhurt,occurence) VALUES (?,?,?,?,?,?,?,?,?)"; | 179 | sql = "INSERT INTO apisInfo (time,wind,temperature,rain,prob,tdeath,mhurt,lhurt,occurence) VALUES (?,?,?,?,?,?,?,?,?)"; |
203 | db_total.query(sql, [client_send.time, client_send.wind, client_send.temperature, client_send.rain, client_send.death, client_send.trafficdeath, client_send.mhurt, client_send.lhurt, client_send.occurence], (err, result) => { | 180 | db_total.query(sql, [client_send.time, client_send.wind, client_send.temperature, client_send.rain, client_send.death, client_send.trafficdeath, client_send.mhurt, client_send.lhurt, client_send.occurence], (err, result) => { |
204 | if (err) console.log(err); | 181 | if (err) console.log(err); | ... | ... |
-
Please register or login to post a comment