Commit 9e896ed0 by 熊付

Merge branch 'develop' of http://192.168.9.26/platform/tx1_box_serv into develop

# Conflicts:
#	code/tx1_box_serv/apps/api/ws_serv.py
2 parents 53936aa9 4865325a
...@@ -5,12 +5,12 @@ from werkzeug import secure_filename ...@@ -5,12 +5,12 @@ from werkzeug import secure_filename
import json,re,time,io import json,re,time,io
import sys import sys
import os import os
from apps.commons.util import * from commons.util import *
import apps.gbvar.ws_serv_global as sv_global import gbvar.ws_serv_global as sv_global
import apps.gbvar.database_global as database import gbvar.database_global as database
import apps.gbvar.dict_properties as dict_p import gbvar.dict_properties as dict_p
import apps.commons.editXml as editXml import commons.editXml as editXml
import apps.commons.event_to_local as etl import commons.event_to_local as etl
tx1_box = Blueprint('tx1_box', __name__) tx1_box = Blueprint('tx1_box', __name__)
...@@ -25,11 +25,14 @@ def dataRecv(): ...@@ -25,11 +25,14 @@ def dataRecv():
print(res) print(res)
send_all_data(sv_global.get_value(),data) send_all_data(sv_global.get_value(),data)
#存入本地数据库 #存入本地数据库
push_dbs(data) #push_dbs(data)
else: else:
print('error: data to dict failed, data:{}'.format(data)) print('error: data to dict failed, data:{}'.format(data))
responseDict = {'enode':"OK", 'ecode':200};
response = json.dumps(responseDict)
return ''
return data
@tx1_box.route('/test', methods=["GET"]) @tx1_box.route('/test', methods=["GET"])
def test(): def test():
print 'test' print 'test'
...@@ -37,10 +40,14 @@ def test(): ...@@ -37,10 +40,14 @@ def test():
return "111" return "111"
# 给所有用户发送信息 # 给所有用户发送信息
def send_all_data(sv, data): def send_all_data(sv, data):
if sv.users is not None and len ( sv.users ) > 0: if sv is None:
for addr in sv.users: print('not ready')
print ('addr=%s' % addr) pass
sv.send_data (data, addr ) else:
if sv.users is not None and len ( sv.users ) > 0:
for addr in sv.users:
print ('addr=%s' % addr)
sv.send_data (data, addr )
...@@ -91,4 +98,4 @@ def post_test(): ...@@ -91,4 +98,4 @@ def post_test():
print data_1 print data_1
data = {} data = {}
data.setdefault('pic_base64','123123123123123123123123') data.setdefault('pic_base64','123123123123123123123123')
return json.dumps ( data, ensure_ascii=False )
\ No newline at end of file \ No newline at end of file
return json.dumps ( data, ensure_ascii=False )
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# coding=utf-8 # coding=utf-8
from flask import Blueprint, request from flask import Blueprint, request
import time,json import time,json
import apps.gbvar.dict_properties as dict_p import gbvar.dict_properties as dict_p
login = Blueprint('login', __name__) login = Blueprint('login', __name__)
register = Blueprint('register', __name__) register = Blueprint('register', __name__)
...@@ -31,4 +31,4 @@ def get_recv_url(): ...@@ -31,4 +31,4 @@ def get_recv_url():
url = 'http://{}:{}/api/v1/tx1_box/events'.format(dict_p.get_value()['tx1_host'],dict_p.get_value()['tx1_http_port']) url = 'http://{}:{}/api/v1/tx1_box/events'.format(dict_p.get_value()['tx1_host'],dict_p.get_value()['tx1_http_port'])
print(url) print(url)
result = {"http_url": url} result = {"http_url": url}
return json.dumps ( result, ensure_ascii=False )
\ No newline at end of file \ No newline at end of file
return json.dumps ( result, ensure_ascii=False )
...@@ -4,10 +4,10 @@ from flask import Blueprint, request ...@@ -4,10 +4,10 @@ from flask import Blueprint, request
import flask import flask
import json,re,time,io import json,re,time,io
import os import os
from apps.commons.util import * from commons.util import *
import apps.gbvar.ws_serv_global as sv_global import gbvar.ws_serv_global as sv_global
import apps.gbvar.dict_properties as dict_p import gbvar.dict_properties as dict_p
import apps.commons.editXml as editXml import commons.editXml as editXml
import requests import requests
import re import re
......
No preview for this file type
...@@ -13,7 +13,7 @@ import os ...@@ -13,7 +13,7 @@ import os
import json import json
import uuid import uuid
import base64 import base64
import apps.gbvar.dict_properties as dict_p import gbvar.dict_properties as dict_p
class EventToLocalUtil(object): class EventToLocalUtil(object):
...@@ -50,7 +50,7 @@ class EventToLocalUtil(object): ...@@ -50,7 +50,7 @@ class EventToLocalUtil(object):
if index == 0: if index == 0:
infoPath = (pic['ofilename'].split('.'))[0] infoPath = (pic['ofilename'].split('.'))[0]
# infoPath = pic['ofilename'] # infoPath = pic['ofilename']
picPath = basePath + '/' + pic['ofilename'] picPath = basePath + '/' + pic['ofilename']
elif 'event_refid' in dataDict: elif 'event_refid' in dataDict:
if(len(dataDict['event_refid'])<=0): if(len(dataDict['event_refid'])<=0):
dataDict['event_refid'] = str(uuid.uuid1()) dataDict['event_refid'] = str(uuid.uuid1())
...@@ -63,6 +63,7 @@ class EventToLocalUtil(object): ...@@ -63,6 +63,7 @@ class EventToLocalUtil(object):
if(len(picPath) >0): if(len(picPath) >0):
if 'pic_base64' in pic: if 'pic_base64' in pic:
try: try:
picPath= picPath.decode('utf8').encode('gb2312')
with open(picPath, 'wb') as f: with open(picPath, 'wb') as f:
f.write(base64.b64decode(pic['pic_base64'])) f.write(base64.b64decode(pic['pic_base64']))
outPicsPath.append(picPath) outPicsPath.append(picPath)
...@@ -87,6 +88,7 @@ class EventToLocalUtil(object): ...@@ -87,6 +88,7 @@ class EventToLocalUtil(object):
infoPath = basePath + '/' + infoPath + '.json' infoPath = basePath + '/' + infoPath + '.json'
try: try:
infoPath = infoPath.decode('utf8').encode('gb2312')
with open(infoPath, 'w') as f: with open(infoPath, 'w') as f:
json.dump(dataDict, f) json.dump(dataDict, f)
outInfoPath.append(infoPath) outInfoPath.append(infoPath)
...@@ -141,13 +143,16 @@ class EventToLocalUtil(object): ...@@ -141,13 +143,16 @@ class EventToLocalUtil(object):
eventCate = dataDict['event_cate'] eventCate = dataDict['event_cate']
if eventType == 'vehicle' : if eventType == 'vehicle' :
# 卡口 # 卡口
if 'illegal' not in dataDict: if 'illegal' not in dataDict['event_data'] or dataDict['event_data']['illegal']['state'] == 0:
genPath = '%s/kakou/%s/%04d%02d%02d/%02d/%02d'%(self.rootPath,vid,et.year, \ genPath = '%s/kakou/%s/%04d%02d%02d/%02d/%02d'%(self.rootPath,vid,et.year, \
et.month,et.day,et.hour, et.minute) et.month,et.day,et.hour, et.minute)
else: else:
#违法 #违法
illegalType = 'unknow'
if 'code' in dataDict['event_data']['illegal']:
illegalType = 'code' + str(dataDict['event_data']['illegal']['code'])
genPath = '%s/weifa/%s/%04d%02d%02d/%s/%02d'%(self.rootPath,vid,et.year, \ genPath = '%s/weifa/%s/%04d%02d%02d/%s/%02d'%(self.rootPath,vid,et.year, \
et.month,et.day,dataDict['event_type'], et.hour) et.month,et.day,illegalType, et.hour)
# 交通参数 # 交通参数
elif eventType == 'tflow' \ elif eventType == 'tflow' \
or eventType == 'pflow' or eventType == 'pdensity': or eventType == 'pflow' or eventType == 'pdensity':
...@@ -168,4 +173,4 @@ class EventToLocalUtil(object): ...@@ -168,4 +173,4 @@ class EventToLocalUtil(object):
print('[error][event_to_local]:{}'.format(logstr)) print('[error][event_to_local]:{}'.format(logstr))
eventToLocal = EventToLocalUtil()
\ No newline at end of file \ No newline at end of file
eventToLocal = EventToLocalUtil()
# coding: utf-8 # coding: utf-8
def _init():#初始化 def _init():#初始化
global dbs global database
database = None database = None
def set_value(value): def set_value(value):
""" 定义一个全局变量 """ """ 定义一个全局变量 """
global dbs global database
dbs = value database = value
def get_value(): def get_value():
global dbs global database
return dbs return database
...@@ -3,19 +3,21 @@ ...@@ -3,19 +3,21 @@
from flask import Flask,Blueprint from flask import Flask,Blueprint
import flask import flask
import threading import threading
from apps.api.http_serv import tx1_box from api.http_serv import tx1_box
from apps.api.task import task from api.task import task
from apps.api.ws_serv import Server from api.ws_serv import Server
import apps.gbvar.ws_serv_global as sv_global from api.login import login
import apps.gbvar.database_global as database from api.login import register
import apps.gbvar.dict_properties as dict_p import gbvar.ws_serv_global as sv_global
from apps.api.code_serv import code_sev import gbvar.database_global as database
import gbvar.dict_properties as dict_p
from api.code_serv import code_sev
import fdb import fdb
import sys import sys
import os import os
from commons.util import * from commons.util import *
import apps.commons.event_to_local as etl import commons.event_to_local as etl
app = Flask(__name__, static_folder='dist') app = Flask(__name__, static_folder='static')
# 获取本脚本所在的路径 # 获取本脚本所在的路径
pro_path = os.path.split(os.path.realpath(__file__))[0] pro_path = os.path.split(os.path.realpath(__file__))[0]
#配置文件路径 #配置文件路径
...@@ -38,7 +40,7 @@ app.register_blueprint(register, url_prefix='/api/v1') ...@@ -38,7 +40,7 @@ app.register_blueprint(register, url_prefix='/api/v1')
@app.route('/', methods=["GET"]) @app.route('/', methods=["GET"])
def index(): def index():
return flask.send_file ( "dist/index.html" ) return flask.send_file ( "index.html" )
def start_ws(host,port): def start_ws(host,port):
try: try:
......
...@@ -7,16 +7,17 @@ tx1_ws_port=20080 ...@@ -7,16 +7,17 @@ tx1_ws_port=20080
datasource_url=F:/ssss/TT.FDB datasource_url=F:/ssss/TT.FDB
#初始化任务列表(说明:路径@任务名称 #初始化任务列表(说明:路径@任务名称
task_1=F:\公司项目目录\mini_fanxin\config\TASK1\tasks.xml@F:\公司项目目录\mini_fanxin\config\TASK1\TASK1\@F:\公司项目目录\mini_fanxin\config\TASK1\TASK1\TASK1\@F:\公司项目目录\mini_fanxin\config\TrafficConfig.xml task_1=/root/UserApp/vioncfg/Device/TASK1/tasks.xml@/root/UserApp/vioncfg/Device/TASK1/TASK1/@/root/UserApp/vioncfg/Device/TASK1/TASK1/TASK1/@/root/UserApp/services/analysis_service/VAServer/TrafficConfig.xml
task_2= #task_1=/root/UserApp/vioncfg/Device/d8802881b1fa40a0bca979214acb78d7/tasks.xml@/root/UserApp/vioncfg/Device/d8802881b1fa40a0bca979214acb78d7/d1f69df819a0472bbbe2e5a34806d1a0/@/root/UserApp/vioncfg/Device/d8802881b1fa40a0bca979214acb78d7/d1f69df819a0472bbbe2e5a34806d1a0/ea3ade4d66d04cfa94c289285b05df96/@/root/UserApp/services/analysis_service/VAServer/TrafficConfig.xml
task_2=/root/UserApp/vioncfg/Device/TASK2/tasks.xml@/root/UserApp/vioncfg/Device/TASK2/TASK2/@/root/UserApp/vioncfg/Device/TASK2/TASK2/TASK2/@/root/UserApp/services/analysis_service/VAServer/TrafficConfig.xml
task_3= task_3=
task_4=/root/UserApp/vioncfg/Ops/ServerConfig.xml@运维服务@./start.sh task_4=
#截图接口地址 #截图接口地址
cut_pic_url=http://192.168.88.109:10088/apiv1/capture cut_pic_url=http://127.0.0.1:10088/apiv1/capture
#重启任务指令 #重启任务指令
start_task=./task_start.sh start_task=./task_start.sh
save_root_path=./datasave
\ No newline at end of file \ No newline at end of file
save_root_path=/root/Log/saveresult
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!