import operator import os import re import pandas as pd from fastapi import APIRouter, Depends, Request, File, UploadFile from motor.motor_asyncio import AsyncIOMotorDatabase from utils.dingding import get_redis_alluid, send_dates from utils.jianli import get_resume import crud, schemas from datetime import datetime from core.configuration import * from db import get_database from db.ckdb import get_ck_db, CKDrive from models.interview_zsgc import InterviewDo from utils import get_time, qujian_time, Download_xlsx, send_str_mail router = APIRouter() # 候选人质量报表 @router.post("/man_mass_form") async def interview_find( request: Request, interview: InterviewDo = Depends(InterviewDo), db: CKDrive = Depends(get_ck_db), ) -> schemas.Msg: """ interview面试数据查询 """ await interview.init() res = interview.get_man_mass_form_sql() sql = res['sql'] data = await db.execute(sql) school_985 = ['清华大学', '北京大学', '中国人民大学', '北京理工大学', '北京航空航天大学', '中央民族大学', '北京师范大学', '中国农业大学', '天津大学', '南开大学', '复旦大学', '上海交通大学', '同济大学', '华东师范大学', '重庆大学', '四川大学', '电子科技大学', '湖南大学', '国防科技大学', '中南大学', '厦门大学'] school_211 = ['上海外国语大学', '东华大学', '上海财经大学', '华东理工大学', '上海大学', '天津医科大学', '吉林大学', '东北师范大学', '延边大学', '哈尔滨工业大学', '哈尔滨工程大学', '东北农业大学', '东北林业大学', '南京大学', '东南大学', '苏州大学', '中国矿业大学', '中国药科大学', '河海大学', '南京航空航天大学', '江南大学', '南京农业大学', '南京理工大学', '浙江大学', '中国科技大学', '安徽大学', '合肥工业大学', '福州大学', '南昌大学', '山东大学', '中国海洋大学', '石油大学', '湖南师范大学', '广西大学', '中山大学', '暨南大学', '华南理工大学', '华南师范大学', '广州中医药大学', '武汉大学', '华中科技大学', '中国地质大学', '武汉理工大学', '华中师范大学', '华中农业大学', '中南财经政法大学'] # 性别 gander = { '男': [], '女': [] } # 年龄 age = { '20-29': [], '30-39': [], '40-49': [], '50-59': [], '60-100': [], } # 学历 education = { '大专': [], '本科': [], '研究生': [], '博士': [], '硕士': [] } # 工作经验 work_exp = { '0-2': [], '3-6': [], '6-10': [], '10-20': [], '20-40': [] } # 所在地 account = { } # 毕业院校 school = { } # 就职公司 work_for = { } # 渠道 owner_name = { '前程无忧': [], '人才库': [], '智联招聘': [], 'Boss直聘': [], '58同城': [] } # 职位 job_name = { } # 学校类型 school_type = { '985': [], '211': [], '其他': [], } if not data: return schemas.Msg(code=-9, msg='无数据', data=None) # 处理数据 for interview_data in data.values(): i_name = interview_data.get('name', '默认名字') i_gander = interview_data.get('gander', '男') if i_gander == '男': gander['男'].append(i_name) else: gander['女'].append(i_name) i_age = interview_data.get('age', 20) if i_age <= 29: age['20-29'].append(i_name) elif 30 <= i_age <= 39: age['30-39'].append(i_name) elif 40 <= i_age <= 49: age['40-49'].append(i_name) elif 50 <= i_age <= 59: age['50-59'].append(i_name) else: age['60-100'].append(i_name) i_education = interview_data.get('education', 1) if i_education == 1: education['大专'].append(i_name) elif i_education == 2: education['本科'].append(i_name) elif i_education == 3: education['研究生'].append(i_name) elif i_education == 4: education['博士'].append(i_name) else: education['硕士'].append(i_name) i_owner_name = interview_data.get('owner_name', 2) if i_owner_name == 1: owner_name['前程无忧'].append(i_name) elif i_owner_name == 2: owner_name['人才库'].append(i_name) elif i_owner_name == 3: owner_name['智联招聘'].append(i_name) elif i_owner_name == 4: owner_name['Boss直聘'].append(i_name) else: owner_name['58同城'].append(i_name) i_school = interview_data.get('school', '') if i_school: if i_school in school: school[i_school].append(i_name) else: school[i_school] = [i_name] if i_school in school_985: school_type['985'].append(i_name) school_type['211'].append(i_name) elif i_school in school_211: school_type['211'].append(i_name) else: school_type['其他'].append(i_name) i_work_exp = interview_data.get('work_exp', 1) if i_work_exp <= 2: work_exp['0-2'].append(i_name) elif 3 <= i_work_exp < 6: work_exp['3-6'].append(i_name) elif 6 <= i_work_exp < 10: work_exp['6-10'].append(i_name) elif 10 <= i_work_exp < 20: work_exp['10-20'].append(i_name) else: work_exp['20-40'].append(i_name) i_job_name = interview_data.get('job_name', '') if i_job_name: if i_job_name in account: job_name[i_job_name].append(i_name) else: job_name[i_job_name] = [i_name] i_account = interview_data.get('account', '') if i_account: if i_account in account: account[i_account].append(i_name) else: account[i_account] = [i_name] i_work_list = interview_data.get('work_list', '') res_msg = { 'gander': gander, 'age': age, 'education': education, 'work_exp': work_exp, 'account': account, 'school': school, 'work_for': work_for, 'owner_name': owner_name, 'job_name': job_name, 'school_type': school_type } return schemas.Msg(code=200, msg='ok', data=res_msg)