|
|
from flask import Flask, jsonify, redirect, request
|
|
|
|
|
|
import json
|
|
|
from Util import GlobalManager as gm
|
|
|
|
|
|
# 初始化全局配置
|
|
|
from Util.MysqlClient import MysqlClient
|
|
|
from Web.LxRec import LxRec
|
|
|
|
|
|
gm._init_()
|
|
|
|
|
|
from Web.LxPie import LxPie
|
|
|
from Web.LxBar import LxBar
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
@app.route('/', methods=['GET', 'POST'])
|
|
|
def index():
|
|
|
return redirect('/static/index.html')
|
|
|
|
|
|
|
|
|
@app.route('/report/LxPie', methods=['GET'])
|
|
|
def pie():
|
|
|
y = request.args.get("y")
|
|
|
p = LxPie()
|
|
|
data = p.getOptions(y)
|
|
|
return jsonify(json.loads(data))
|
|
|
|
|
|
|
|
|
@app.route('/report/LxBar', methods=['GET'])
|
|
|
def bar():
|
|
|
y = request.args.get("y")
|
|
|
p = LxBar()
|
|
|
data = p.getOptions(y)
|
|
|
return jsonify(json.loads(data))
|
|
|
|
|
|
|
|
|
@app.route('/report/LxRec', methods=['GET'])
|
|
|
def rec():
|
|
|
y = request.args.get("y")
|
|
|
p = LxRec()
|
|
|
data = p.getOptions(y)
|
|
|
return jsonify(json.loads(data))
|
|
|
|
|
|
|
|
|
# 完成进度
|
|
|
@app.route('/report/LxWcjd', methods=['GET'])
|
|
|
def wcjd():
|
|
|
y = request.args.get("y")
|
|
|
if y is None:
|
|
|
res = {"success": False, "message": "参数y没有正确输入!"}
|
|
|
return jsonify(json.loads(res))
|
|
|
# 声明数据库连接
|
|
|
db = MysqlClient()
|
|
|
# 项目总量,项目立项
|
|
|
sql = "select count(1) as c from t_gtzz_subject where sbnd='%s'" % y
|
|
|
xmlx = db.find(sql)[1]['c']
|
|
|
|
|
|
# 招标采购
|
|
|
sql = "select count(1) as c from t_gtzz_progress where year='%s' and step_code = '0204' and is_current=0 and is_back_log=0" % y
|
|
|
zbcg = db.find(sql)[1]['c']
|
|
|
|
|
|
# 实施验收
|
|
|
sql = "select count(1) as c from t_gtzz_progress where year='%s' and step_code = '0305' and is_current=0 and is_back_log=0" % y
|
|
|
ssys = db.find(sql)[1]['c']
|
|
|
|
|
|
# 项目拨付
|
|
|
sql = "select count(1) as c from t_pro_message as t1 inner join t_pro_task as t2 on t1.task_sn=t2.sn where t1.handle_node_name ='财政执行拨付' and t2.task_year='%s'" % y
|
|
|
xmbf = db.find(sql)[1]['c']
|
|
|
|
|
|
# 项目关闭
|
|
|
sql = "select count(1) as c from t_gtzz_progress where year='%s' and is_current=1 and is_finish_flag=2" % y
|
|
|
xmgb = db.find(sql)[1]['c']
|
|
|
# 关闭数据库
|
|
|
db.close()
|
|
|
# 组装数据
|
|
|
res = {"succes": True, "xmzl": xmlx, "xmlx": xmlx, "zbcg": zbcg, "ssys": ssys, "xmbf": xmbf, "xmgb": xmgb}
|
|
|
return jsonify(res)
|
|
|
|
|
|
|
|
|
# 趋势分布
|
|
|
@app.route('/report/LxQsfb', methods=['GET'])
|
|
|
def qsfb():
|
|
|
y = request.args.get("y")
|
|
|
if y is None:
|
|
|
res = {"success": False, "message": "参数y没有正确输入!"}
|
|
|
return jsonify(json.loads(res))
|
|
|
# 声明数据库连接
|
|
|
db = MysqlClient()
|
|
|
db.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
# 生产环境配置方法
|
|
|
# server = pywsgi.WSGIServer(('0.0.0.0', 8888), app)
|
|
|
# server.serve_forever()
|
|
|
|
|
|
# 调试环境配置方法
|
|
|
app.run(host='0.0.0.0', port=8888, debug=True)
|