Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김원진
/
Expresswayinfo24
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
최현영
2020-06-08 00:53:11 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ed0d60af75922cd52c78716957c4ac803aa62bcf
ed0d60af
1 parent
7cb0289a
Highway fee infomation function added
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
5 deletions
whereur/public/Expressfee.json → whereur/Expressfee.json
whereur/app.js
whereur/
public/
Expressfee.json
→
whereur/Expressfee.json
View file @
ed0d60a
This file is too large to display.
whereur/app.js
View file @
ed0d60a
...
...
@@ -16,10 +16,13 @@ const TOKEN = 'sqNjA99TptppqvcoVFAnU7Kawsl+s7l+JgnZ7r2is97qrFQraIn0sLQ6mTsIPvXLG
const
domain
=
"www.chyoss.tk"
const
sslport
=
23023
;
// const buffer = fs.readFileSync('/public/Expressfee.json');
// const datafeejson = buffer.toString();
// const feedata = JSON.parse(datafeejson);
// console.log("Expressfee.json 파일 읽기");
const
buffer
=
fs
.
readFileSync
(
'./whereur/Expressfee.json'
);
const
datafeejson
=
buffer
.
toString
();
const
feedata
=
JSON
.
parse
(
datafeejson
);
console
.
log
(
"Expressfee.json 파일 읽기"
);
app
.
use
(
bodyParser
.
json
());
...
...
@@ -136,6 +139,9 @@ function firstforecast(isforecast){
else
if
(
isforecast
==
'3'
){
return
true
;
}
else
if
(
isforecast
==
'4'
){
return
true
;
}
else
{
return
false
;
}
...
...
@@ -229,6 +235,17 @@ function pushmsg(eventObj){
usercount
[
eventObj
.
source
.
userId
]
=
(
usercount
[
eventObj
.
source
.
userId
]
+
5
);
}
}
function
wanttokownfee
(
typetext
){
if
(
typetext
.
indexOf
(
"-"
)
>=
0
){
return
true
;
}
else
{
return
false
;
}
}
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
...
...
@@ -244,6 +261,7 @@ app.post('/hook', function (req, res) {
var
source
=
eventObj
.
source
;
var
message
=
eventObj
.
message
;
var
isnext
;
var
isfee
;
// request log
console
.
log
(
'======================'
,
new
Date
()
,
'======================'
);
console
.
log
(
'[request]'
,
req
.
body
);
...
...
@@ -280,6 +298,10 @@ app.post('/hook', function (req, res) {
console
.
log
(
'[request Order] '
,
message
);
tieupselect
(
eventObj
);
}
else
if
(
message
.
text
==
'4'
){
console
.
log
(
"[request Order] "
,
message
);
leadfee
(
eventObj
);
}
}
isselecttypeforecast
=
selecttypeforecast
(
message
.
text
);
...
...
@@ -326,6 +348,11 @@ app.post('/hook', function (req, res) {
//console.log(roadnumberstringLength);
}
isfee
=
wanttokownfee
(
message
.
text
);
if
(
isfee
==
true
){
feelead
(
eventObj
,
message
.
text
);
}
res
.
sendStatus
(
200
);
});
...
...
@@ -349,7 +376,11 @@ function helloworld(eventObj){
},
{
"type"
:
"text"
,
"text"
:
"현재 교통 예보가 궁금하시다면 1번을, 실시간 교통혼잡 상황을 보실려면 2번을, 실시간 정체상황을 알고 싶다면 3번을 눌러주세요. 노선정보는 '노선정보'를 입력해주세요."
"text"
:
"현재 교통 예보가 궁금하시다면 1번을, 실시간 교통혼잡 상황을 보실려면 2번을, 실시간 정체상황을 알고 싶다면 3번을, 교통요금이 궁금하시다면 4번을 눌러주세요."
},
{
"type"
:
"text"
,
"text"
:
"노선정보는 '노선정보'를 입력해주세요."
}
]
}
...
...
@@ -383,6 +414,38 @@ function viewhtml(eventObj){
});
}
function
leadfee
(
eventObj
){
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"요금안내를 시작합니다."
},
{
"type"
:
"text"
,
"text"
:
"출발하신 나들목(IC)의 이름과 도착하실 나들목(IC)의 이름을 순서대로 적어주세요."
},
{
"type"
:
"text"
,
"text"
:
"예)남안동-서안동"
},
{
"type"
:
"text"
,
"text"
:
"예) 예천-서안동"
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
function
findroad
(
eventObj
){
...
...
@@ -813,6 +876,78 @@ function roadcongest(eventObj, msg, userid){
}
});
}
function
feelead
(
eventObj
,
msg
){
var
isthat
=
false
;
var
feelist
=
new
Array
();
var
inputoutputIC
=
msg
.
split
(
'-'
);
var
ExpressfeeLength
=
feedata
.
Expressfee
.
length
;
for
(
var
i
=
0
;
i
<
ExpressfeeLength
;
i
++
){
if
(
inputoutputIC
[
0
]
==
feedata
.
Expressfee
[
i
].
출발지명
&&
inputoutputIC
[
1
]
==
feedata
.
Expressfee
[
i
].
도착지명
){
isthat
=
true
;
feelist
[
0
]
=
feedata
.
Expressfee
[
i
][
" 요금_1종 "
];
feelist
[
1
]
=
feedata
.
Expressfee
[
i
][
" 요금_2종 "
];
feelist
[
2
]
=
feedata
.
Expressfee
[
i
][
" 요금_3종 "
];
feelist
[
3
]
=
feedata
.
Expressfee
[
i
][
" 요금_4종 "
];
feelist
[
4
]
=
feedata
.
Expressfee
[
i
][
" 요금_5종 "
];
feelist
[
5
]
=
feedata
.
Expressfee
[
i
][
" 요금_경차 "
];
}
}
if
(
isthat
==
true
){
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"출발지점: "
+
inputoutputIC
[
0
]
+
", 도착지점: "
+
inputoutputIC
[
1
]
},
{
"type"
:
"text"
,
"text"
:
"1종 요금 : "
+
feelist
[
0
]
+
", 2종 요금 : "
+
feelist
[
1
]
},
{
"type"
:
"text"
,
"text"
:
"3종 요금 : "
+
feelist
[
2
]
+
", 4종 요금 : "
+
feelist
[
3
]
},
{
"type"
:
"text"
,
"text"
:
"5종 요금 : "
+
feelist
[
4
]
+
", 경차 요금 : "
+
feelist
[
5
]
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
else
{
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"발견된 지점이 없습니다. 다시 입력해 주세요"
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
}
// var url3 = 'http://data.ex.co.kr/openapi/trafficapi/trafficAll';
// var queryParams3 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/
// queryParams3 += '&' + encodeURIComponent('type') + '=' + encodeURIComponent('json'); /* */
...
...
Please
register
or
login
to post a comment