• 计算机毕业设计Python+djang的小区疫情防控系统(源码+系统+mysql数据库+Lw文档)


    项目介绍

    随着信息化时代的到来,管理系统都趋向于智能化、系统化,居民小区疫情防控管理系统也不例外,但目前国内的市场仍都使用人工管理,市场规模越来越大,同时信息量也越来越庞大,人工管理显然已无法应对时代的变化,而居民小区疫情防控管理系统能很好地解决这一问题,轻松应对居民小区疫情防控平时的工作,既能提高人力物力财力,又能加快工作的效率,取代人工管理是必然趋势。
    近期,国内新冠肺炎疫情在各地再次反扑,各种变异毒株、境外输入压力让疫情防控变的更加严峻。社区防控是第一道防线,进出小区人员登记,出示健康码,测量体温,居家隔离等是每个社区都要面临的防控压力。但是如果对社区内的居民不能精确管理,就会导致很多的防疫措施失去应有的作用。

    功能介绍

    请添加图片描述
    本系统根据实际需要分为管理员和用户两部分,具体功能如下
    (1)管理员功能需求
    管理员登陆后,主要模块包括首页,个人中心,新闻动态管理,用户管理,地区信息管理,小区单元管理,疫苗种类管理,疫苗信息管理,疫苗研发管理,地区疫苗管理,外出申请管理,疫苗预约管理,接种登记管理,体温申报管理,活动轨迹管理,物资信息管理,物资申请管理,单元消毒管理,电梯消毒管理,健康打卡管理,人员登记管理,确诊统计管理,预约统计管理,地区追踪管理,爬虫管理,系统管理等功能。
    (2)用户功能需求
    用户登陆后,主要包括首页,个人中心,外出申请管理,疫苗预约管理,接种登记管理,体温申报管理,活动轨迹管理,物资申请管理,健康打卡管理等功能。

    开发环境

    计算机毕业设计Python+djang的小区疫情防控系统(源码+系统+mysql数据库+Lw文档)
    开发语言:Python
    python框架:django
    软件版本:python3.7/python3.8
    数据库:mysql 5.7或更高版本
    数据库工具:Navicat11
    开发软件:PyCharm/vs code
    前端框架:vue.js
    可开发框架:ssm/Springboot/vue/python/PHP/小程序/安卓均可开发

    系统截图

    本见面为系统主界面在系统主界面中我们可以看到系统具体功能包括新闻动态,疫苗研发,地区疫苗,物资信息以及动态个人等内容
    请添加图片描述

    本界面为疫苗研发,在本界面中可以看到疫苗研发相关的内容包括疫苗研发的标题疫苗名称研发阶段,疫苗名称,研发阶段等内容。请添加图片描述
    本界面为登录界面,主要包括管理人员和用户。都可以在这里面进行登录。
    请添加图片描述
    版界面主要为居民的疫苗接种情况,包括接种单号,接种疫苗的名称。用户的姓名,手机号码,接种时间的内容。
    请添加图片描述
    在疫情期间疫苗是一个非常重要的环节,所以我们也设计了疫苗管理模块,在疫苗管理界面中包括疫苗的编号,疫苗的名称,疫苗的种类,批次,等级,图片数量的内容。
    请添加图片描述

    #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)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', 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="立即支付" style="display: none"></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
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308
    • 309
    • 310
    • 311
    • 312
    • 313
    • 314
    • 315
    • 316
    • 317
    • 318
    • 319
    • 320
    • 321
    • 322
    • 323
    • 324
    • 325
    • 326
    • 327
    • 328
    • 329
    • 330
    • 331
    • 332
    • 333
    • 334
    • 335
    • 336
    • 337
    • 338
    • 339
    • 340
    • 341
    • 342
    • 343
    • 344
    • 345
    • 346
    • 347
    • 348
    • 349
    • 350
    • 351
    • 352
    • 353
    • 354
    • 355
    • 356
    • 357
    • 358
    • 359
    • 360
    • 361
    • 362
    • 363
    • 364
    • 365
    • 366
    • 367
    • 368
    • 369
    • 370
    • 371
    • 372
    • 373
    • 374
    • 375
    • 376
    • 377
    • 378
    • 379
    • 380
    • 381
    • 382
    • 383
    • 384
    • 385
    • 386
    • 387
    • 388
    • 389
    • 390
    • 391
    • 392
    • 393
    • 394
    • 395
    • 396
    • 397
    • 398
    • 399
    • 400
    • 401
    • 402
    • 403
    • 404
    • 405
    • 406
    • 407
    • 408
    • 409
    • 410
    • 411
    • 412
    • 413
    • 414
    • 415
    • 416
    • 417
    • 418
    • 419
    • 420
    • 421
    • 422
    • 423
    • 424
    • 425
    • 426
    • 427
    • 428
    • 429
    • 430
    • 431
    • 432
    • 433
    • 434
    • 435
    • 436
    • 437
    • 438
    • 439
    • 440
    • 441
    • 442
    • 443
    • 444
    • 445
    • 446
    • 447
    • 448
    • 449
    • 450
    • 451
    • 452
    • 453
    • 454
    • 455
    • 456
    • 457
    • 458
    • 459
    • 460
    • 461
    • 462
    • 463
    • 464
    • 465
    • 466
    • 467
    • 468
    • 469
    • 470
    • 471
    • 472
    • 473
    • 474
    • 475
    • 476
    • 477
    • 478
    • 479
    • 480
    • 481
    • 482
    • 483
    • 484
    • 485
    • 486
    • 487
    • 488
    • 489
    • 490
    • 491
    • 492
    • 493
    • 494
    • 495
    • 496
    • 497
    • 498
    • 499
    • 500
    • 501
    • 502
    • 503
    • 504
    • 505
    • 506
    • 507
    • 508
    • 509
    • 510
    • 511
    • 512
    • 513
    • 514
    • 515
    • 516
    • 517
    • 518
    • 519
    • 520
    • 521
    • 522
    • 523
    • 524
    • 525
    • 526
    • 527
    • 528
    • 529
    • 530
    • 531
    • 532
    • 533
    • 534
    • 535
    • 536
    • 537
    • 538
    • 539
    • 540
    • 541
    • 542
    • 543
    • 544
    • 545
    • 546
    • 547
    • 548
    • 549
    • 550
    • 551
    • 552
    • 553
    • 554
    • 555
    • 556
    • 557
    • 558
    • 559
    • 560
    • 561
    • 562
    • 563
    • 564
    • 565
    • 566
    • 567
    • 568
    • 569
    • 570
    • 571
    • 572
    • 573
    • 574
    • 575
    • 576
    • 577
    • 578
    • 579
    • 580
    • 581
    • 582
    • 583
    • 584
    • 585
    • 586
    • 587
    • 588
    • 589
    • 590
    • 591
    • 592
    • 593
    • 594
    • 595
    • 596
    • 597
    • 598
    • 599
    • 600
    • 601
    • 602
    • 603
    • 604
    • 605
    • 606
    • 607
    • 608
    • 609
    • 610
    • 611
    • 612
    • 613
    • 614
    • 615
    • 616
    • 617
    • 618
    • 619
    • 620
    • 621
    • 622
    • 623
    • 624
    • 625
    • 626
    • 627
    • 628
    • 629
    • 630
    • 631
    • 632
    • 633
    • 634
    • 635
    • 636
    • 637
    • 638
    • 639
    • 640
    • 641
    • 642
    • 643
    • 644
    • 645
    • 646
    • 647
    • 648
    • 649
    • 650
    • 651
    • 652
    • 653
    • 654
    • 655
    • 656
    • 657
    • 658
    • 659
    • 660
    • 661
    • 662
    • 663
    • 664
    • 665
    • 666
    • 667
    • 668
    • 669
    • 670
    • 671
    • 672
    • 673
    • 674
    • 675
    • 676
    • 677
    • 678
    • 679
    • 680
    • 681
    • 682
    • 683
    • 684
    • 685
    • 686
    • 687
    • 688
    • 689
    • 690
    • 691
    • 692
    • 693
    • 694
    • 695
    • 696
    • 697
    • 698
    • 699
    • 700
    • 701
    • 702
    • 703
    • 704
    • 705
    • 706
    • 707
    • 708
    • 709
    • 710
    • 711
    • 712
    • 713
    • 714
    • 715
    • 716
    • 717
    • 718
    • 719
    • 720
    • 721
    • 722
    • 723
    • 724
    • 725
    • 726
  • 相关阅读:
    【数独问题】递归+回溯算法求解数独问题
    论文解读(GraphSMOTE)《GraphSMOTE: Imbalanced Node Classification on Graphs with Graph Neural Networks》
    华东师范大学 2017 计算机系暑期夏令营机考
    【教学类-08-01】20221010《门牌号(6层*3间 黑色版)》(大班主题《我们的城市》)
    【老生谈算法】matlab实现蚁群算法源码——蚁群算法
    ChatGPT如何助力DevOps|用例解读
    c++编程实例
    Linux 文件读写
    前端框架的发展史&介绍框架特点
    Windows Server 2012 R2 安装 OpenSSH
  • 原文地址:https://blog.csdn.net/QQ860234001/article/details/126064099