动态 版块 发帖 消息 我的
xwylt
书山有路勤为径,学海无涯苦作舟
lytcreateLv5   
json进度     

def xcx(request):

    if request.method == 'GET':

        today = datetime.date.today()

        benyuestart = datetime.date(today.year,today.month,1)

        benyueend = datetime.date(today.year,today.month+1,1) - datetime.timedelta(1)

        

        conn = pymysql.connect(host=host, port=port, user=user, password=password, database=database, charset='utf8')

        cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)

        cursor.execute("select * from aqk_score where scoreintime between %s and %s",[benyuestart,benyueend,])

        byaqjf = cursor.fetchall()

        byaqjf_list = []

        for byjf in byaqjf:

            a = collections.OrderedDict()

            a["_id"] = byjf['xid']

            a["_openid"] = 'oySrZ5TjT4h_nbUV-RFJAG_3H3JY'

            a["note"] = byjf['areas']

            a["timee"] = str(byjf['scores'])

            byaqjf_list.append(a)


        for b in range(0,len(byaqjf_list)):

            c = json.dumps(byaqjf_list[b],ensure_ascii=False)

            with open('D:\wwwroot\Wechatdata\小程序-当月安全积分表(userlist).json','a',encoding='utf-8-sig') as d:

                d.write(c)

                d.write('\n')


#各区域每月积分雷达图--文件制度管理
cursor.execute("select documents from aqk_score where scoreintime between %s and %s order by id",[benyuestart,benyueend,])
wjzdgl = cursor.fetchall()
# print(wjzdgl)
# print(wjzdgl[0]['documents'])
wjzd_list = []
e = collections.OrderedDict()
e["_id"] = '8f29e52a5f6464ee00001e47666bb8a5'
e["序号"] = '1'
e["leibie"] = '文件制度管理'
e["_openid"] = 'oySrZ5TjT4h_nbUV-RFJAG_3H3JY'
e["chongya"] = str(wjzdgl[0]['documents'])
e["cheshen"] = str(wjzdgl[1]['documents'])
e["tuzhuang"] = str(wjzdgl[2]['documents'])
e["zongzhuang"] = str(wjzdgl[3]['documents'])
e["weixiu"] = str(wjzdgl[4]['documents'])
e["fadongji"] = str(wjzdgl[5]['documents'])
e["caigouwuliu"] = str(wjzdgl[6]['documents'])
e["jishuzhiliang"] = str(wjzdgl[7]['documents'])
wjzd_list.append(e)
# print(wjzd_list)
# print(wjzd_list[0])
for h in range(0, len(wjzd_list)):
f = json.dumps(wjzd_list[h], ensure_ascii=False)
with open('F:\小程序-部门安全积分细表(雷达图)(dangyueanquanxiaofen', 'a') as g:
g.write(f)
g.write('\n')
# 各区域每月积分雷达图--安全改进
cursor.execute("select improvement from aqk_score where scoreintime between %s and %s order by id",
[benyuestart, benyueend, ])
aqgj = cursor.fetchall()
# print(wjzdgl)
# print(wjzdgl[0]['documents'])
aqgj_list = []
i = collections.OrderedDict()
i["_id"] = '112557505f6465ca0000222c5a94c400'
i["序号"] = '2'
i["leibie"] = '安全改进'
i["_openid"] = 'oySrZ5TjT4h_nbUV-RFJAG_3H3JY'
i["chongya"] = str(aqgj[0]['improvement'])
i["cheshen"] = str(aqgj[1]['improvement'])
i["tuzhuang"] = str(aqgj[2]['improvement'])
i["zongzhuang"] = str(aqgj[3]['improvement'])
i["weixiu"] = str(aqgj[4]['improvement'])
i["fadongji"] = str(aqgj[5]['improvement'])
i["caigouwuliu"] = str(aqgj[6]['improvement'])
i["jishuzhiliang"] = str(aqgj[7]['improvement'])
aqgj_list.append(i)
# print(wjzd_list)
# print(wjzd_list[0])
for j in range(0, len(aqgj_list)):
k = json.dumps(aqgj_list[j], ensure_ascii=False)
with open('F:\小程序-部门安全积分细表(雷达图)(dangyueanquanxiaofen', 'a') as l:
l.write(k)
l.write('\n')
# 各区域每月积分雷达图--安全检查
cursor.execute("select safety from aqk_score where scoreintime between %s and %s order by id",
[benyuestart, benyueend, ])
aqjc = cursor.fetchall()
# print(wjzdgl)
# print(wjzdgl[0]['documents'])
aqjc_list = []
n = collections.OrderedDict()
n["_id"] = '2c9645925f64666400002100174fccd4'
n["序号"] = '3'
n["leibie"] = '安全检查(绩效评价)'
n["_openid"] = 'oySrZ5TjT4h_nbUV-RFJAG_3H3JY'
n["chongya"] = str(aqjc[0]['safety'])
n["cheshen"] = str(aqjc[1]['safety'])
n["tuzhuang"] = str(aqjc[2]['safety'])
n["zongzhuang"] = str(aqjc[3]['safety'])
n["weixiu"] = str(aqjc[4]['safety'])
n["fadongji"] = str(aqjc[5]['safety'])
n["caigouwuliu"] = str(aqjc[6]['safety'])
n["jishuzhiliang"] = str(aqjc[7]['safety'])
aqjc_list.append(n)
# print(wjzd_list)
# print(wjzd_list[0])
for m in range(0, len(aqjc_list)):
o = json.dumps(aqjc_list[m], ensure_ascii=False)
with open('F:\小程序-部门安全积分细表(雷达图)(dangyueanquanxiaofen', 'a') as p:
p.write(o)
p.write('\n')
# 各区域每月积分雷达图--其他专项
cursor.execute("select otherobject from aqk_score where scoreintime between %s and %s order by id",
[benyuestart, benyueend, ])
qtzxgz = cursor.fetchall()
# print(wjzdgl)
# print(wjzdgl[0]['documents'])
qtzx_list = []
q = collections.OrderedDict()
q["_id"] = '8f29e52a5f64673500001e657769063f'
q["序号"] = '4'
q["leibie"] = '其他专项工作'
q["_openid"] = 'oySrZ5TjT4h_nbUV-RFJAG_3H3JY'
q["chongya"] = str(qtzxgz[0]['otherobject'])
q["cheshen"] = str(qtzxgz[1]['otherobject'])
q["tuzhuang"] = str(qtzxgz[2]['otherobject'])
q["zongzhuang"] = str(qtzxgz[3]['otherobject'])
q["weixiu"] = str(qtzxgz[4]['otherobject'])
q["fadongji"] = str(qtzxgz[5]['otherobject'])
q["caigouwuliu"] = str(qtzxgz[6]['otherobject'])
q["jishuzhiliang"] = str(qtzxgz[7]['otherobject'])
qtzx_list.append(q)
# print(wjzd_list)
# print(wjzd_list[0])
for r in range(0, len(qtzx_list)):
s = json.dumps(qtzx_list[r], ensure_ascii=False)
with open('F:\小程序-部门安全积分细表(雷达图)(dangyueanquanxiaofen', 'a') as t:
t.write(s)
t.write('\n')
# 各区域每月积分雷达图--6sp
cursor.execute("select psobject from aqk_score where scoreintime between %s and %s order by id",
[benyuestart, benyueend, ])
psobject = cursor.fetchall()
# print(wjzdgl)
# print(wjzdgl[0]['documents'])
ps_list = []
u = collections.OrderedDict()
u["_id"] = '8f29e52a5f64679600001e682062b8a3'
u["序号"] = '5'
u["leibie"] = '6ps相关工作'
u["_openid"] = 'oySrZ5TjT4h_nbUV-RFJAG_3H3JY'
u["chongya"] = str(psobject[0]['psobject'])
u["cheshen"] = str(psobject[1]['psobject'])
u["tuzhuang"] = str(psobject[2]['psobject'])
u["zongzhuang"] = str(psobject[3]['psobject'])
u["weixiu"] = str(psobject[4]['psobject'])
u["fadongji"] = str(psobject[5]['psobject'])
u["caigouwuliu"] = str(psobject[6]['psobject'])
u["jishuzhiliang"] = str(psobject[7]['psobject'])
ps_list.append(u)
# print(wjzd_list)
# print(wjzd_list[0])
for v in range(0, len(ps_list)):
w = json.dumps(ps_list[v], ensure_ascii=False)
with open('F:\小程序-部门安全积分细表(雷达图)(dangyueanquanxiaofen', 'a') as x:
x.write(w)
x.write('\n')
# 各区域每月积分雷达图-消防及应急
cursor.execute("select emergency from aqk_score where scoreintime between %s and %s order by id",
[benyuestart, benyueend, ])
xfjyjgl = cursor.fetchall()
# print(wjzdgl)
# print(wjzdgl[0]['documents'])
xf_list = []
aa = collections.OrderedDict()
aa["_id"] = '112557505f64684a000022562733325d'
aa["序号"] = '6'
aa["leibie"] = '消防及应急管理'
aa["_openid"] = 'oySrZ5TjT4h_nbUV-RFJAG_3H3JY'
aa["chongya"] = str(xfjyjgl[0]['emergency'])
aa["cheshen"] = str(xfjyjgl[1]['emergency'])
aa["tuzhuang"] = str(xfjyjgl[2]['emergency'])
aa["zongzhuang"] = str(xfjyjgl[3]['emergency'])
aa["weixiu"] = str(xfjyjgl[4]['emergency'])
aa["fadongji"] = str(xfjyjgl[5]['emergency'])
aa["caigouwuliu"] = str(xfjyjgl[6]['emergency'])
aa["jishuzhiliang"] = str(xfjyjgl[7]['emergency'])
xf_list.append(aa)
# print(wjzd_list)
# print(wjzd_list[0])
for ab in range(0, len(xf_list)):
ac = json.dumps(xf_list[ab], ensure_ascii=False)
with open('F:\小程序-部门安全积分细表(雷达图)(dangyueanquanxiaofen', 'a') as ad:
ad.write(ac)
ad.write('\n')
# 各区域每月积分雷达图-培训、沟通
cursor.execute("select practise from aqk_score where scoreintime between %s and %s order by id",
[benyuestart, benyueend, ])
pxgt = cursor.fetchall()
# print(wjzdgl)
# print(wjzdgl[0]['documents'])
px_list = []
ae = collections.OrderedDict()
ae["_id"] = 'c4747cd45f6468b000001a6a702e9863'
ae["序号"] = '7'
ae["leibie"] = '培训、沟通'
ae["_openid"] = 'oySrZ5TjT4h_nbUV-RFJAG_3H3JY'
ae["chongya"] = str(pxgt[0]['practise'])
ae["cheshen"] = str(pxgt[1]['practise'])
ae["tuzhuang"] = str(pxgt[2]['practise'])
ae["zongzhuang"] = str(pxgt[3]['practise'])
ae["weixiu"] = str(pxgt[4]['practise'])
ae["fadongji"] = str(pxgt[5]['practise'])
ae["caigouwuliu"] = str(pxgt[6]['practise'])
ae["jishuzhiliang"] = str(pxgt[7]['practise'])
px_list.append(ae)
# print(wjzd_list)
# print(wjzd_list[0])
for af in range(0, len(px_list)):
ag = json.dumps(px_list[af], ensure_ascii=False)
with open('F:\小程序-部门安全积分细表(雷达图)(dangyueanquanxiaofen', 'a') as ah:
ah.write(ag)
ah.write('\n')
# 各区域每月积分雷达图-工作策划及资源保障
cursor.execute("select plan from aqk_score where scoreintime between %s and %s order by id",
[benyuestart, benyueend, ])
gzch = cursor.fetchall()
# print(wjzdgl)
# print(wjzdgl[0]['documents'])
ch_list = []
aj = collections.OrderedDict()
aj["_id"] = '2c9645925f646917000021291010802b'
aj["序号"] = '8'
aj["leibie"] = '工作策划及资源保障'
aj["_openid"] = 'oySrZ5TjT4h_nbUV-RFJAG_3H3JY'
aj["chongya"] = str(gzch[0]['plan'])
aj["cheshen"] = str(gzch[1]['plan'])
aj["tuzhuang"] = str(gzch[2]['plan'])
aj["zongzhuang"] = str(gzch[3]['plan'])
aj["weixiu"] = str(gzch[4]['plan'])
aj["fadongji"] = str(gzch[5]['plan'])
aj["caigouwuliu"] = str(gzch[6]['plan'])
aj["jishuzhiliang"] = str(gzch[7]['plan'])
ch_list.append(aj)
# print(wjzd_list)
# print(wjzd_list[0])
for ak in range(0, len(ch_list)):
am = json.dumps(ch_list[ak], ensure_ascii=False)
with open('F:\小程序-部门安全积分细表(雷达图)(dangyueanquanxiaofen', 'a') as an:
an.write(am)
an.write('\n')


        conn.close()

        return redirect("/home/")

        

    else:

        return redirect("/home/")

 0  已被阅读了105次  楼主 2020-10-12 02:46:00
回复列表

回复:json进度

Powered by Xwylt.com
© 2020-2020 lytcreate
您的IP:54.236.35.159,2020-10-31 03:56:37,Processed in 0.0086 second(s).
Powered by HadSky
书山有路勤为径,学海无涯苦作舟
已有0次打赏