栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

【Django-CI系统】by部门展示人均建议数-20220525

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【Django-CI系统】by部门展示人均建议数-20220525

效果:by部门展示人均建议数

views.py
    # 将所有模型都查出来
    suggestion_all = suggestion.objects.all()
    dept_review_all = dept_review.objects.all()
    headcount_all = headcount.objects.all()
    User_all = User.objects.all()



    # main24参数提取(by各部门人均建议提出条数)
    # 读取编制的数值(需要每个月都维护编制,否则可能报错)(headcount_item不存在则需要追认这一年最后一笔编制)
    headcount_item = headcount_all.filter(Q(headcount_datetime__range=(start_date3, end_date3))).order_by('headcount_datetime').last()
    print('headcount_item',headcount_item)
    if headcount_item:
        pass
    else:
        headcount_item = headcount_all.filter(Q(headcount_datetime__range=(this_year_start, this_year_end))).order_by('headcount_datetime').last()
    headcount_ttl_count = headcount_item.headcount_ttl
 
    print('headcount_item',headcount_item)
    headcount_dict = {'总体':headcount_item.headcount_ttl,
                      '生产部':headcount_item.headcount_shengchanbu,
                      '物流部':headcount_item.headcount_wuliubu,
                      '人事综合管理部':headcount_item.headcount_renshizonghebu,
                      '工艺质量部':headcount_item.headcount_gongyizhiliangbu,
                      '项目部':headcount_item.headcount_xiangmubu,
                      '总经办':headcount_item.headcount_zongjingban,
                      '财务部':headcount_item.headcount_caiwubu,
                      '研发部':headcount_item.headcount_yanfabu,
                    }
    person_average_suggestion = suggestion_count/headcount_ttl_count
    # 计算平均数
    suggestion_count = suggestion_all.filter(Q(suggestion_date__range=(start_date3, end_date3))).count()
    # 人均建议条数
    #print('headcount_datetime',headcount_all.filter(Q(headcount_datetime__range=(start_date3, end_date3))).order_by('headcount_datetime').last().headcount_datetime)
    list_of_suggestion_dept_count = []
    dict_of_sum_suggestion_dept_count = {'总体':round(suggestion_count/headcount_ttl_count,1),
                                        '生产部':0,
                                        '物流部':0,
                                        '人事综合管理部':0,
                                        '工艺质量部':0,
                                        '项目部':0,
                                        '总经办':0,
                                        '财务部':0,
                                        '研发部':0,
                                        }
    for su in suggestion_all:
        list_of_suggestion_dept_count.append(su.suggestion_employee_dept)
    for suggestion_employee_dept in list_of_suggestion_dept_count:
        dept_sum = suggestion_all.filter(Q(suggestion_employee_dept=suggestion_employee_dept) & Q(suggestion_date__range=(start_date1, end_date1))).aggregate(suggestion_employee_dept=Count('suggestion_employee_id'))
        process_dict = {suggestion_employee_dept : round(dept_sum['suggestion_employee_dept']/headcount_dict[suggestion_employee_dept],1)}
        dict_of_sum_suggestion_dept_count.update(process_dict)
    #print('dict_of_sum_suggestion_dept_count',dict_of_sum_suggestion_dept_count)
    value24A = []
    value24B = []
    for key,value in dict_of_sum_suggestion_dept_count.items():
        value24A.append(key)
        value24B.append(value)

dashboard.html
          
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/928227.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号