程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Computer graduation design Python + djang village epidemic prevention and control system (source + + mysql database system + Lw document)

編輯:Python

項目介紹

隨著信息化時代的到來,管理系統都趨向於智能化、系統化,The epidemic prevention and control management system in residential areas is no exception,但目前國內的市場仍都使用人工管理,市場規模越來越大,同時信息量也越來越龐大,人工管理顯然已無法應對時代的變化,The residential community epidemic prevention and control management system can solve this problem well,Easily cope with the usual work of epidemic prevention and control in residential areas,既能提高人力物力財力,又能加快工作的效率,取代人工管理是必然趨勢.
近期,國內新冠肺炎疫情在各地再次反撲,各種變異毒株、境外輸入壓力讓疫情防控變的更加嚴峻.社區防控是第一道防線,進出小區人員登記,出示健康碼,測量體溫,居家隔離等是每個社區都要面臨的防控壓力.但是如果對社區內的居民不能精確管理,就會導致很多的防疫措施失去應有的作用.

功能介紹


The system is divided into two parts: administrator and user according to actual needs,具體功能如下
(1)管理員功能需求
管理員登陸後,主要模塊包括首頁,個人中心,新聞動態管理,用戶管理,地區信息管理,小區單元管理,疫苗種類管理,疫苗信息管理,疫苗研發管理,地區疫苗管理,外出申請管理,疫苗預約管理,接種登記管理,體溫申報管理,活動軌跡管理,物資信息管理,物資申請管理,單元消毒管理,電梯消毒管理,健康打卡管理,人員登記管理,確診統計管理,預約統計管理,地區追蹤管理,爬蟲管理,系統管理等功能.
(2)用戶功能需求
用戶登陸後,主要包括首頁,個人中心,外出申請管理,疫苗預約管理,接種登記管理,體溫申報管理,活動軌跡管理,物資申請管理,Health check-in management and other functions.

開發環境

計算機畢業設計Python+djangcommunity epidemic prevention and control system(源碼+系統+mysql數據庫+Lw文檔)
開發語言:Python
python框架:django
軟件版本:python3.7/python3.8
數據庫:mysql 5.7或更高版本
數據庫工具:Navicat11
開發軟件:PyCharm/vs code
前端框架:vue.js
可開發框架:ssm/Springboot/vue/python/PHP/小程序/安卓均可開發

系統截圖

This meeting is the main interface of the system. In the main interface of the system, we can see the specific functions of the system including news,疫苗研發,地區疫苗,Material information and dynamic personal content

This interface is for vaccine development,In this interface, you can see the content related to vaccine development, including the title vaccine name development stage of vaccine development,疫苗名稱,development stage, etc.
本界面為登錄界面,It mainly includes administrators and users.You can log in here.

The interface is mainly for the vaccination status of residents,Include the inoculation number,The name of the vaccination.用戶的姓名,手機號碼,Contents of inoculation time.

Vaccines are a very important part of the pandemic,So we also designed the vaccine management module,Include the vaccine number in the vaccine management interface,疫苗的名稱,Types of vaccines,批次,等級,The content of the number of pictures.

#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import huodongguiji
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def huodongguiji_register(request):
if request.method in ["POST", "GET"]:
msg = {
'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = huodongguiji.createbyreq(huodongguiji, huodongguiji, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用戶已存在,請勿重復注冊!"
return JsonResponse(msg)
def huodongguiji_login(request):
if request.method in ["POST", "GET"]:
msg = {
'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = huodongguiji.getbyparams(huodongguiji, huodongguiji, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= huodongguiji.__sfsh__
except:
__sfsh__=None
if __sfsh__=='是':
if datas[0].get('sfsh')=='否':
msg['code']=other_code
msg['msg'] = "賬號已鎖定,請聯系管理員審核!"
return JsonResponse(msg)
req_dict['id'] = datas[0].get('id')
return Auth.authenticate(Auth, huodongguiji, req_dict)
def huodongguiji_logout(request):
if request.method in ["POST", "GET"]:
msg = {

"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def huodongguiji_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= huodongguiji.getallcolumn( huodongguiji, huodongguiji)
try:
__loginUserColumn__= huodongguiji.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''huodongguiji.objects.filter({
}='{}').update({
}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def huodongguiji_session(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code,"msg": mes.normal_code, "data": {
}}
req_dict={
"id":request.session.get('params').get("id")}
msg['data'] = huodongguiji.getbyparams(huodongguiji, huodongguiji, req_dict)[0]
return JsonResponse(msg)
def huodongguiji_default(request):
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code,"msg": mes.normal_code, "data": {
}}
req_dict = request.session.get("req_dict")
req_dict.update({
"isdefault":"是"})
data=huodongguiji.getbyparams(huodongguiji, huodongguiji, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {
}
return JsonResponse(msg)
def huodongguiji_page(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data":{
"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
#獲取全部列名
columns= huodongguiji.getallcolumn( huodongguiji, huodongguiji)
#當前登錄用戶所在表
tablename = request.session.get("tablename")
#authColumn=list(__authTables__.keys())[0]
#authTable=__authTables__.get(authColumn)
# if authTable==tablename:
#params = request.session.get("params")
#req_dict[authColumn]=params.get(authColumn)
'''__authSeparate__此屬性為真,params添加userid,後台只查詢個人數據'''
try:
__authSeparate__=huodongguiji.__authSeparate__
except:
__authSeparate__=None
if __authSeparate__=="是":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#當項目屬性hasMessage為”是”,生成系統自動生成留言板的表messages,同時該表的表屬性hasMessage也被設置為”是”,字段包括userid(用戶id),username(用戶名),content(留言內容),reply(回復)
#接口page需要區分權限,普通用戶查看自己的留言和回復記錄,管理員查看所有的留言和回復記錄
try:
__hasMessage__=huodongguiji.__hasMessage__
except:
__hasMessage__=None
if __hasMessage__=="是":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict["userid"]=request.session.get("params").get("id")
# 判斷當前表的表屬性isAdmin,為真則是管理員表
# 當表屬性isAdmin=”是”,刷出來的用戶表也是管理員,即page和list可以查看所有人的考試記錄(同時應用於其他表)
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
# 當前表也是有管理員權限的表
if __isAdmin__ == "是":
if req_dict.get("userid"):
del req_dict["userid"]
else:
#非管理員權限的表,判斷當前表字段名是否有userid
if tablename!="users" and 'huodongguiji'[:7]!='discuss'and "userid" in huodongguiji.getallcolumn(huodongguiji,huodongguiji):
req_dict["userid"] = request.session.get("params").get("id")
#當列屬性authTable有值(某個用戶表)[該列的列名必須和該用戶表的登陸字段名一致],則對應的表有個隱藏屬性authTable為”是”,那麼該用戶查看該表信息時,只能查看自己的
try:
__authTables__=huodongguiji.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={
}:
try:
del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
break
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] =huodongguiji.page(huodongguiji, huodongguiji, req_dict)
return JsonResponse(msg)
def huodongguiji_autoSort(request):
'''
.智能推薦功能(表屬性:[intelRecom(是/否)],新增clicktime[前端不顯示該字段]字段(調用info/detail接口的時候更新),按clicktime排序查詢)
主要信息列表(如商品列表,新聞列表)中使用,顯示最近點擊的或最新添加的5條記錄就行
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data":{
"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
if "clicknum" in huodongguiji.getallcolumn(huodongguiji,huodongguiji):
req_dict['sort']='clicknum'
else:
req_dict['sort']='clicktime'
req_dict['order']='desc'
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = huodongguiji.page(huodongguiji,huodongguiji, req_dict)
return JsonResponse(msg)
def huodongguiji_list(request):
'''
前台分頁
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data":{
"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
#獲取全部列名
columns= huodongguiji.getallcolumn( huodongguiji, huodongguiji)
#表屬性[foreEndList]前台list:和後台默認的list列表頁相似,只是擺在前台,否:指沒有此頁,是:表示有此頁(不需要登陸即可查看),前要登:表示有此頁且需要登陸後才能查看
try:
__foreEndList__=huodongguiji.__foreEndList__
except:
__foreEndList__=None
if __foreEndList__=="前要登":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#forrEndListAuth
try:
__foreEndListAuth__=huodongguiji.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=huodongguiji.__authSeparate__
except:
__authSeparate__=None
if __foreEndListAuth__ =="是" and __authSeparate__=="是":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict['userid']=request.session.get("params",{
"id":0}).get("id")
tablename = request.session.get("tablename")
if tablename == "users" and req_dict.get("userid") != None:#判斷是否存在userid列名
del req_dict["userid"]
else:
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
if __isAdmin__ == "是":
if req_dict.get("userid"):
del req_dict["userid"]
else:
#非管理員權限的表,判斷當前表字段名是否有userid
if "userid" in columns:
try:
# 本接口可以匿名訪問,所以try判斷是否為匿名
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#當列屬性authTable有值(某個用戶表)[該列的列名必須和該用戶表的登陸字段名一致],則對應的表有個隱藏屬性authTable為”是”,那麼該用戶查看該表信息時,只能查看自己的
try:
__authTables__=huodongguiji.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={
} and __foreEndListAuth__=="是":
try:
del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
break
if huodongguiji.__tablename__[:7]=="discuss":
try:
del req_dict['userid']
except:
pass
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = huodongguiji.page(huodongguiji, huodongguiji, req_dict)
return JsonResponse(msg)
def huodongguiji_save(request):
'''
後台新增
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data": {
}}
req_dict = request.session.get("req_dict")
tablename=request.session.get("tablename")
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
#獲取全部列名
columns= huodongguiji.getallcolumn( huodongguiji, huodongguiji)
if tablename!='users' and req_dict.get("userid")!=None and 'userid' in columns and __isAdmin__!='是':
params=request.session.get("params")
req_dict['userid']=params.get('id')
error= huodongguiji.createbyreq(huodongguiji,huodongguiji, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def huodongguiji_add(request):
'''
前台新增
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data": {
}}
req_dict = request.session.get("req_dict")
#獲取全部列名
columns= huodongguiji.getallcolumn( huodongguiji, huodongguiji)
try:
__authSeparate__=huodongguiji.__authSeparate__
except:
__authSeparate__=None
if __authSeparate__=="是":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
try:
__foreEndListAuth__=huodongguiji.__foreEndListAuth__
except:
__foreEndListAuth__=None
if __foreEndListAuth__ and __foreEndListAuth__!="否":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict['userid']=request.session.get("params").get("id")
error= huodongguiji.createbyreq(huodongguiji,huodongguiji, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def huodongguiji_thumbsup(request,id_):
'''
點贊:表屬性thumbsUp[是/否],刷表新增thumbsupnum贊和crazilynum踩字段,
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data": {
}}
req_dict = request.session.get("req_dict")
id_=int(id_)
type_=int(req_dict.get("type",0))
rets=huodongguiji.getbyid(huodongguiji,huodongguiji,id_)
update_dict={

"id":id_,
}
if type_==1:#贊
update_dict["thumbsupnum"]=int(rets[0].get('thumbsupnum'))+1
elif type_==2:#踩
update_dict["crazilynum"]=int(rets[0].get('crazilynum'))+1
error = huodongguiji.updatebyparams(huodongguiji,huodongguiji, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def huodongguiji_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data": {
}}
data = huodongguiji.getbyid(huodongguiji,huodongguiji, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏覽點擊次數
try:
__browseClick__= huodongguiji.__browseClick__
except:
__browseClick__=None
if __browseClick__=="是" and "clicknum" in huodongguiji.getallcolumn(huodongguiji,huodongguiji):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={
"id":int(id_),"clicknum":clicknum}
ret=huodongguiji.updatebyparams(huodongguiji,huodongguiji,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def huodongguiji_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data": {
}}
data =huodongguiji.getbyid(huodongguiji,huodongguiji, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏覽點擊次數
try:
__browseClick__= huodongguiji.__browseClick__
except:
__browseClick__=None
if __browseClick__=="是" and "clicknum" in huodongguiji.getallcolumn(huodongguiji,huodongguiji):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={
"id":int(id_),"clicknum":clicknum}
ret=huodongguiji.updatebyparams(huodongguiji,huodongguiji,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def huodongguiji_update(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data": {
}}
req_dict = request.session.get("req_dict")
if req_dict.get("mima") and req_dict.get("password"):
if "mima" not in huodongguiji.getallcolumn(huodongguiji,huodongguiji) :
del req_dict["mima"]
if "password" not in huodongguiji.getallcolumn(huodongguiji,huodongguiji) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = huodongguiji.updatebyparams(huodongguiji, huodongguiji, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def huodongguiji_delete(request):
'''
批量刪除
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code, "data": {
}}
req_dict = request.session.get("req_dict")
error=huodongguiji.deletes(huodongguiji,
huodongguiji,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def huodongguiji_vote(request,id_):
'''
浏覽點擊次數(表屬性[browseClick:是/否],點擊字段(clicknum),調用info/detail接口的時候後端自動+1)、投票功能(表屬性[vote:是/否],投票字段(votenum),調用vote接口後端votenum+1)
統計商品或新聞的點擊次數;提供新聞的投票功能
'''
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": mes.normal_code}
data= huodongguiji.getbyid(huodongguiji, huodongguiji, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={
"id":int(id_),"votenum":votenum+1}
error=huodongguiji.updatebyparams(huodongguiji,huodongguiji,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def huodongguiji_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": "成功", "data": {
}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {
}
huodongguiji.createbyreq(huodongguiji, huodongguiji, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件類型錯誤"
return JsonResponse(msg)
def huodongguiji_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用戶注冊', '您的注冊驗證碼是【'+''.join(code)+'】,請不要把驗證碼洩漏給其他人,如非本人請勿操作.', '[email protected]', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用戶','"+''.join(code)+"')")
msg = {

"msg": "發送成功",
"code": 0
}
return JsonResponse(msg)
def huodongguiji_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select inteltype from storeup where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'huodongguiji' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from huodongguiji where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from huodongguiji where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({
"code": 0, "msg": '', "data":{
"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def huodongguiji_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": "成功", "data": {
}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
sql = ''
if timeStatType == '日':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM huodongguiji {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '月':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM huodongguiji {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '年':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM huodongguiji {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def huodongguiji_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {
"code": normal_code, "msg": "成功", "data": {
}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
sql = "SELECT {0}, sum({1}) AS total FROM huodongguiji {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def huodongguiji_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/djangowtf35/huodongguiji/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" ></form>'.format(pay_url)
return JsonResponse({
'code': 0, "data": pay_url})
def huodongguiji_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/djangowtf35/admin/dist/index.html#/huodongguiji')

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved