From 11ef2d5e72eeef15942298df061bdccc431a784f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= <250213850@qq.com> Date: Thu, 15 Sep 2022 13:56:23 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/interview.py | 71 ++++++++++++++++++++++++++----- schemas/interview_plan.py | 12 ++++++ 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/api/api_v1/endpoints/interview.py b/api/api_v1/endpoints/interview.py index 35ba5a2..dea707b 100644 --- a/api/api_v1/endpoints/interview.py +++ b/api/api_v1/endpoints/interview.py @@ -555,15 +555,15 @@ async def condition( # 今天的面试 if data_in.time_type == 'now': # 查询返回的数据一共多少条 - len_sql = f"""select uid from HR.resumes where {where} and toDate(star_time) == '{times}' ORDER BY event_time""" + len_sql = f"""select uid from HR.resumes where {where} and toDate(star_time) == '{times}' and interview_stage = 3 ORDER BY event_time""" sql = f"""select interview_round,interview_type,star_time,end_time,name,phone,job_names,hr_name,uid,interview_id, - feedback,interview_name from HR.resumes where {where} and toDate(star_time) == '{times}' ORDER BY event_time + feedback,interview_name from HR.resumes where {where} and toDate(star_time) == '{times}' and interview_stage = 3 ORDER BY event_time LIMIT 10 OFFSET {(data_in.pages - 1) * 10}""" # 明天及之后的面试 elif data_in.time_type == 'tomorrow': - len_sql = f"""select uid from HR.resumes where {where} and toDate(star_time) > '{times}' ORDER BY event_time""" + len_sql = f"""select uid from HR.resumes where {where} and toDate(star_time) > '{times}' and interview_stage = 3 ORDER BY event_time""" sql = f"""select interview_round,interview_type,star_time,end_time,name,phone,job_names,hr_name,uid,interview_id, - feedback,interview_name from HR.resumes where {where} and toDate(star_time) > '{times}' ORDER BY event_time + feedback,interview_name from HR.resumes where {where} and toDate(star_time) > '{times}' and interview_stage = 3 ORDER BY event_time LIMIT 10 OFFSET {(data_in.pages - 1) * 10}""" # 昨天及以前的面试 else: @@ -625,8 +625,8 @@ async def get_job( if data_in != None: if data_in.state == True: nums = len(res) - ress=await crud.jobs.all_fields(db,schemas.Jobs(state=False)) - number=len(ress) + ress = await crud.jobs.all_fields(db, schemas.Jobs(state=False)) + number = len(ress) else: number = len(res) ress = await crud.jobs.all_fields(db, schemas.Jobs(state=True)) @@ -656,11 +656,11 @@ async def get_job( if data_in != None: data = { 'start_num': nums, - 'end_num':number, + 'end_num': number, 'job': job } else: - data={'job': job} + data = {'job': job} return schemas.Msg(code=200, msg='ok', data=data) @@ -1822,7 +1822,7 @@ async def find_like( "graduate_time", "job_name", "feedback", "interview_round", "interview_state", "interview_stage", "pass_why", "pass_text"] - find_columns=','.join(find_column) + find_columns = ','.join(find_column) if data_in.date != {}: strs = [] for k, v in data_in.date.items(): @@ -1840,5 +1840,56 @@ async def find_like( data = await ckdb.execute(sql) if not data: return schemas.Msg(code=-9, msg='无数据', data='') - res=chkData(data) + res = chkData(data) return schemas.Msg(code=200, msg='ok', data=res) + + +# 总览 +@router.post("/interview_stage_nu") +async def interview_stage_nu( + request: Request, + data_in: schemas.nterview, + ckdb: CKDrive = Depends(get_ck_db), + current_user: schemas.UserDB = Depends(deps.get_current_user) +) -> schemas.Msg: + res_data = {'0': 0, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0, '10': 0, '11': 0} + res = data_in.date + strs = [] + for k, v in res.items(): + if v != '': + if 'int' in str(type(v)): + str_s = f"{k} = {v}" + strs.append(str_s) + else: + if k in ['hr_id', 'interview_id'] and v != '': + str_s = f"{k} like '%{v}%'" + else: + str_s = f"{k} = '{v}'" + strs.append(str_s) + where = ' and '.join(strs) + # 当前日期 + times = get_time() + len_sql = f"""select uid from HR.resumes where {where} and toDate(star_time) == '{times}' and interview_stage = 3""" + if where == '': + len_sql = len_sql.replace('where and', 'where', 1) + # 面试人数 + df_len = await ckdb.query_dataframe(len_sql) + if df_len.empty: + len_date = 0 + else: + len_date = len(df_len) + res_data['now']=len_date + # 1:初筛 2:复筛 3:面试 4:沟通offer 5:待入职 6:放弃入职 7:已入职 8:转正 9:主动离职 10:被动离职 11:淘汰 + sql = """select interview_stage,count(*) as value from HR.resumes group by interview_stage""" + data = await ckdb.execute(sql) + for i in data.values(): + key = str(i['interview_stage']) + if key not in res_data: + continue + res_data[key] = i['value'] + # 待发送offer + off_sql="""select count(*) as value from HR.resumes where offer_state <= 2 and interview_stage = 4""" + res= await ckdb.execute(off_sql) + res_data['offer'] = res[0]['value'] + + return schemas.Msg(code=200, msg='ok', data=res_data) diff --git a/schemas/interview_plan.py b/schemas/interview_plan.py index 6246fe2..f8a0f74 100644 --- a/schemas/interview_plan.py +++ b/schemas/interview_plan.py @@ -157,3 +157,15 @@ class add_inter(BaseModel): class find_like(BaseModel): interview_stage: str # 简历阶段 date: dict # 查询条件 + + +class nterview(BaseModel): + date: dict # 要查询的条件 + # date包含如下参数,如选择全部的则传空字符串 + # job_name: str # 应聘职位 + # hr_name: str # 面试负责人 + # interview_name: str # 面试官 + # interview_type: int # 面试类型 + # interview_sign: int # 面试签到 + # feedback: int # 面试反馈 + # interview_round: int # 面试轮次 \ No newline at end of file