Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
platform
/
tx1_box_serv
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 57a2af4d
authored
Dec 15, 2018
by
潘建波
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加code服务
1 parent
37a56c8b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
1 deletions
code/tx1_box_serv/apps/api/code_serv.py
code/tx1_box_serv/apps/api/http_serv.py
code/tx1_box_serv/apps/dao/firebird_dao.py
code/tx1_box_serv/apps/api/code_serv.py
0 → 100644
View file @
57a2af4
#!/usr/bin/evn python
# coding=utf-8
from
flask
import
Blueprint
,
request
,
redirect
,
url_for
import
flask
import
apps.gbvar.database_global
as
dbs
import
json
,
re
,
time
,
io
code_sev
=
Blueprint
(
'code_sev'
,
__name__
)
# event_types
@code_sev.route
(
'/codes/event_types'
,
methods
=
[
"GET"
])
def
geteventtypes
():
con
=
dbs
.
get_value
()
cur
=
con
.
cursor
()
sql_select
=
'select * from tb_event_types'
cur
.
execute
(
sql_select
)
result
=
[]
for
item
in
cur
:
dict
=
{
'event_type_unid'
:
item
[
0
],
'event_cate_unid'
:
item
[
1
],
'code'
:
item
[
2
],
'name'
:
item
[
3
]
}
result
.
append
(
dict
)
res
=
flask
.
make_response
(
json
.
dumps
(
result
,
encoding
=
"UTF-8"
,
ensure_ascii
=
False
,
sort_keys
=
False
,
indent
=
4
)
.
encode
(
'utf-8'
))
res
.
headers
[
'Access-Control-Allow-Origin'
]
=
'*'
res
.
headers
[
'Access-Control-Allow-Methods'
]
=
'POST,GET,OPTIONS'
res
.
headers
[
'Access-Control-Allow-Headers'
]
=
'x-requested-with,content-type'
return
res
#traffic_cates
@code_sev.route
(
'/traffic/cates'
,
methods
=
[
"GET"
])
def
gettrafficcate
():
con
=
dbs
.
get_value
()
cur
=
con
.
cursor
()
sql_select
=
'select * from tb_traffic_cate'
cur
.
execute
(
sql_select
)
result
=
[]
for
item
in
cur
:
dict
=
{
'cate_unid'
:
item
[
0
],
'cate_code'
:
item
[
1
],
'name'
:
item
[
2
],
'note'
:
item
[
3
]
}
result
.
append
(
dict
)
res
=
flask
.
make_response
(
json
.
dumps
(
result
,
encoding
=
"UTF-8"
,
ensure_ascii
=
False
,
sort_keys
=
False
,
indent
=
4
)
.
encode
(
'utf-8'
))
res
.
headers
[
'Access-Control-Allow-Origin'
]
=
'*'
res
.
headers
[
'Access-Control-Allow-Methods'
]
=
'POST,GET,OPTIONS'
res
.
headers
[
'Access-Control-Allow-Headers'
]
=
'x-requested-with,content-type'
return
res
#traffic_types
@code_sev.route
(
'/traffic/cates/<string:cate_unid>/codes'
,
methods
=
[
"GET"
])
def
gettrafficcodes
(
cate_unid
):
con
=
dbs
.
get_value
()
cur
=
con
.
cursor
()
sql_select
=
"select * from tb_traffic_type where cate = '
%
s'"
%
(
cate_unid
)
print
(
sql_select
)
cur
.
execute
(
sql_select
)
result
=
[]
for
item
in
cur
:
dict
=
{
'cate_unid'
:
item
[
0
],
'code'
:
item
[
2
],
'name'
:
item
[
3
]
}
result
.
append
(
dict
)
res
=
flask
.
make_response
(
json
.
dumps
(
result
,
encoding
=
"UTF-8"
,
ensure_ascii
=
False
,
sort_keys
=
False
,
indent
=
4
)
.
encode
(
'utf-8'
))
res
.
headers
[
'Access-Control-Allow-Origin'
]
=
'*'
res
.
headers
[
'Access-Control-Allow-Methods'
]
=
'POST,GET,OPTIONS'
res
.
headers
[
'Access-Control-Allow-Headers'
]
=
'x-requested-with,content-type'
return
res
code/tx1_box_serv/apps/api/http_serv.py
View file @
57a2af4
...
@@ -24,7 +24,8 @@ def dataRecv():
...
@@ -24,7 +24,8 @@ def dataRecv():
res
=
etl
.
eventToLocal
.
saveEventToLocal
(
dataDic
)
res
=
etl
.
eventToLocal
.
saveEventToLocal
(
dataDic
)
print
(
res
)
print
(
res
)
send_all_data
(
sv_global
.
get_value
(),
data
)
send_all_data
(
sv_global
.
get_value
(),
data
)
#存入本地数据库
push_dbs
(
data
)
else
:
else
:
print
(
'error: data to dict failed, data:{}'
.
format
(
data
))
print
(
'error: data to dict failed, data:{}'
.
format
(
data
))
...
...
code/tx1_box_serv/apps/dao/firebird_dao.py
View file @
57a2af4
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment