From 1cab86dcc12de5263b7dbb20a2cddb592773a9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= <250213850@qq.com> Date: Wed, 19 Oct 2022 10:44:44 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E8=81=8C=E4=BD=8D=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E7=9A=84=E9=80=BB=E8=BE=91=202.=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E8=AE=B0=E5=BD=95=203.=E5=A2=9E=E5=88=A0?= =?UTF-8?q?=E6=94=B9=E6=8E=A8=E8=8D=90=E8=AE=B0=E5=BD=95=204.=E5=B5=8C?= =?UTF-8?q?=E5=A5=97=E6=8F=90=E9=86=92=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/interview.py | 50 ++++++++++++++++++++----------- crud/__init__.py | 1 + crud/crud_department.py | 28 +++++++++++++++++ schemas/__init__.py | 1 + schemas/department.py | 17 +++++++++++ schemas/user.py | 20 ++++++------- script/__init__.py | 0 script/send_interviewee.py | 32 ++++++++++++++++++++ script/settings.py | 12 ++++++++ 9 files changed, 133 insertions(+), 28 deletions(-) create mode 100644 crud/crud_department.py create mode 100644 schemas/department.py create mode 100644 script/__init__.py create mode 100644 script/send_interviewee.py create mode 100644 script/settings.py diff --git a/api/api_v1/endpoints/interview.py b/api/api_v1/endpoints/interview.py index bf9ef43..992e7e6 100644 --- a/api/api_v1/endpoints/interview.py +++ b/api/api_v1/endpoints/interview.py @@ -422,9 +422,12 @@ async def interview_update( content = f"""【淘汰通知】\n姓名:{interview_id[0]['name']}\n求职岗位:{interview_id[0]['job_names']}\n淘汰原因:{why}\n具体淘汰原因:{interview.data_in.get('pass_text')}\n简历阶段:{interview_stage}\n操作人:{current_user.nickname}""" if current_user.name != 'root': # send_dates(content, userid_list)# 工作通知 - res=await crud.user.get_users(db,userid_list) - unionid_list=[i['unionid'] for i in res] + res = await crud.user.get_users(db, userid_list) + unionid_list = [i['unionid'] for i in res] Sample.create_task('淘汰通知', current_user.unionid, content, unionid_list) # 待办通知 + if interview.data_in.get('hr_manner', 10) in [0, 1]: + # 更新推荐记录 + await crud.department.update(db, {'types': True}, interview.where.get('uid')) return schemas.Msg(code=200, msg='ok', data=data) @@ -1219,13 +1222,13 @@ async def get_job( ress = await crud.jobs.all_fields(db, schemas.Jobs(state=True)) nums = len(ress) job = [] - job_list=[i['job_id'] for i in res] + job_list = [i['job_id'] for i in res] sql1 = f""" select job_id,count(*) as nu from HR.resumes where job_id in {job_list} and interview_stage < 6 group by job_id """ - #获取各个职位的候选人总数 + # 获取各个职位的候选人总数 df = await ckdb.query_dataframe(sql1) - job_dict=dict(zip(df['job_id'],df['nu'])) + job_dict = dict(zip(df['job_id'], df['nu'])) for i in res: job_list = {} job_list['key'] = i['job_id'] # 职位id @@ -1234,7 +1237,7 @@ async def get_job( job_list['job_sector'] = i['job_sector'] # 部门 job_list['job_num'] = i['job_num'] # 目标招聘人数 job_list['now_job_num'] = i['now_job_num'] # 对应职位的入职人数 - job_list['hou_num'] = job_dict.get(i['job_id'],0) # 候选人总数 + job_list['hou_num'] = job_dict.get(i['job_id'], 0) # 候选人总数 job_list['creat_time'] = i['creat_time'] # 创建职位的时间 job.append(job_list) # 按创建职位的最新时间排序 @@ -1539,10 +1542,10 @@ async def teacher_state( now_time = str(datetime.now()).split('.')[0] if current_user.name != 'root': content = f"【催促反馈】\n请面试官尽快给{data_in.name}做面试反馈\n提醒时间:{now_time}" - #send_dates(content, data_in.user_id)#工作通知 - res=await crud.user.get_users(db,data_in.user_id) - unionid_list=[i['unionid'] for i in res] - Sample.create_task('催促反馈',current_user.unionid,content,unionid_list) # 待办通知 + # send_dates(content, data_in.user_id)#工作通知 + res = await crud.user.get_users(db, data_in.user_id) + unionid_list = [i['unionid'] for i in res] + Sample.create_task('催促反馈', current_user.unionid, content, unionid_list) # 待办通知 return schemas.Msg(code=200, msg='发送成功', data='') except Exception: return schemas.Msg(code=-9, msg='发送失败', data='') @@ -1951,17 +1954,17 @@ async def login( 'email': user.email, # 邮箱 'tel': user.tel, # 电话 'user_id': user.user_id, # 钉钉id - 'unionid':user.unionid, #钉钉unionid + 'unionid': user.unionid, # 钉钉unionid 'id': user.id, # 账号的唯一标识 'rank': user.rank, # 区分hr和面试官 'nickname': user.nickname, # 显示名 'token': security.create_access_token( expires_delta=access_token_expires, user_id=user.user_id, email=user.email, - tel=user.tel, name=user.name, rank=user.rank,unionid=user.unionid), + tel=user.tel, name=user.name, rank=user.rank, unionid=user.unionid), "token_type": "bearer"}, 'access_token': security.create_access_token( expires_delta=access_token_expires, user_id=user.user_id, email=user.email, - tel=user.tel, name=user.name, rank=user.rank,unionid=user.unionid + tel=user.tel, name=user.name, rank=user.rank, unionid=user.unionid ), "token_type": "bearer", 'code': 200, @@ -2392,9 +2395,22 @@ async def send_interviewee( user_list = [i['user_id'] for i in user['hr_name']] if current_user.name != 'root': send = f"""【推荐通知】\n{current_user.nickname}给你推荐了一位面试者\n面试者姓名:{res[0]['name']}\n岗位:{res[0]['job_names']}""" - unionid_list=[i['unionid'] for i in user['hr_name']] + unionid_list = [i['unionid'] for i in user['hr_name']] # send_dates(send, user_list) #工作通知 - Sample.create_task('推荐通知', current_user.unionid, send, unionid_list) # 待办通知 + # Sample.create_task('推荐通知', current_user.unionid, send, unionid_list) # 待办通知 + # 存一份推荐,如到一定时间没有处理推荐,则返回通知推荐人处理 + datas = {'uid': data_in.uid, 'name': res[0]['name'], 'job_name': res[0]['job_names'], + 'hr_name': user['hr_name'], + 'referrer_name': current_user.nickname, 'referrer_id': current_user.unionid, 'types': False, + 'create': str(datetime.now()).split('.')[0]} + # 先查有没有推荐记录 + res = await crud.department.where_dep(db, {'uid': data_in.uid}) + if res == []: # 没有则创建 + await crud.department.create(db, datas) + else: # 有就更新 + datas.pop('uid') + await crud.department.update(db, datas, data_in.uid) + department = ','.join(user_list) up_sql = f"""ALTER TABLE HR.resumes update department = '{department}' where uid = '{data_in.uid}'""" print(up_sql) @@ -2435,8 +2451,8 @@ async def add_interviewee( hr_user.extend(data_in.user_id) if current_user.name != 'root': # send_dates(send, hr_user)#工作通知 - res=await crud.user.get_users(db,hr_user) - unionid_list=[i['unionid'] for i in res] + res = await crud.user.get_users(db, hr_user) + unionid_list = [i['unionid'] for i in res] Sample.create_task('面试通知', current_user.unionid, send, unionid_list) # 待办通知 find_sql = f""" select uid,name,interview_name,hr_name,star_time,interview_sign,interview_id,job_id,job_names,mail from HR.resumes where uid = '{data_in.uid}' diff --git a/crud/__init__.py b/crud/__init__.py index cab9c60..d4f7202 100644 --- a/crud/__init__.py +++ b/crud/__init__.py @@ -36,3 +36,4 @@ from .crud_basic_data import basic_data from .crud_section import section from .crud_feedback import feedback from .crud_find_column import api_find_column +from .crud_department import department diff --git a/crud/crud_department.py b/crud/crud_department.py new file mode 100644 index 0000000..df54140 --- /dev/null +++ b/crud/crud_department.py @@ -0,0 +1,28 @@ +from motor.motor_asyncio import AsyncIOMotorDatabase +import schemas +from crud.base import CRUDBase + +__all__ = 'department', + +from utils import get_uid + + +class CRUDProjectNumber(CRUDBase): + # 获取所有数据 + async def all_dep(self, db: AsyncIOMotorDatabase): + return await self.find_many(db, {}) + + # 获取对应条件数据 + async def where_dep(self, db: AsyncIOMotorDatabase, where): + return await self.find_many(db, where,{'_id':0}) + + # 修改数据 + async def update(self, db: AsyncIOMotorDatabase, up,where): + await self.update_one(db, {'uid': where}, {'$set': up}) + + # 插入数据 + async def create(self, db: AsyncIOMotorDatabase, data_in: dict): + return await self.insert_one(db, data_in) + + +department = CRUDProjectNumber('department') diff --git a/schemas/__init__.py b/schemas/__init__.py index 1a2715b..0b0eba0 100644 --- a/schemas/__init__.py +++ b/schemas/__init__.py @@ -41,3 +41,4 @@ from .count_in_worker import * from .basic_data import * from .section import * from .feedback import * +from .department import * diff --git a/schemas/department.py b/schemas/department.py new file mode 100644 index 0000000..bbbd3a8 --- /dev/null +++ b/schemas/department.py @@ -0,0 +1,17 @@ +from datetime import datetime + +from pydantic import BaseModel +from typing import List + + +class Department(BaseModel): + uid: str # 求职者id + name: str # 求职者姓名 + job_name: str # 应聘职位 + hr_name: list # 推荐给谁-用人经理 + referrer_name: str # 推荐人 + referrer_id: str # 推荐人unionid + types: bool = False # 推荐人是否已处理 + create: str = str(datetime.now()).split('.')[0] # 创建时间 + # 'hr_name': [{"_id": "3af3ac42bf13fd","nickname": "张三","user_id": "16371426094531014","unionid": "wWR9K0iPGyzy1SGIO78fBUgiEiE"}] + diff --git a/schemas/user.py b/schemas/user.py index 8627c09..9e25e17 100644 --- a/schemas/user.py +++ b/schemas/user.py @@ -40,15 +40,14 @@ class UserLogin(BaseModel): class UserRestPassword(BaseModel): user_id: str = ... password: str = ... - nickname: str # 用户名 - tel: str # 电话 + nickname:str # 用户名 + tel:str # 电话 email: str # 邮箱 - class UserRestMyPassword(BaseModel): password: str = ... - nickname: str # 用户名 - tel: str # 电话 + nickname:str # 用户名 + tel:str # 电话 email: str # 邮箱 @@ -59,7 +58,7 @@ class UserCreate(UserBase): rank: int # 判断是hr还是面试官 email: str # 邮箱 tel: str # 手机号 - user_id: str # 钉钉的用户id + user_id: str # 钉钉的用户id # **************************************************************************** @@ -67,18 +66,17 @@ class UserCreate(UserBase): class UserDB(DBBase): - # email: EmailStr = None # 邮箱 + #email: EmailStr = None # 邮箱 is_superuser: bool = False - name: str # 姓名 + name: str # 姓名 nickname: str = '' tel: Any = '' last_login_ts: str = '尚未登录' data_where: dict = dict() user_id: str # 钉钉id - unionid: str # 钉钉unionid + unionid: str rank: int # 区分hr和面试官 - class UserDBRW(DBBase): hashed_password: str # 密码 unionid: str # 通过钉钉扫码获取的unionid @@ -90,4 +88,4 @@ class UserDBRW(DBBase): last_login_ts: str = '尚未登录' # 登录时间 create_date: datetime = datetime.now() # 创建账号的时间 state: int = 0 # 默认刚创账号是不锁定的 - user_id: str # 钉钉里面的用户id + user_id:str # 钉钉里面的用户id diff --git a/script/__init__.py b/script/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/script/send_interviewee.py b/script/send_interviewee.py new file mode 100644 index 0000000..b0875bc --- /dev/null +++ b/script/send_interviewee.py @@ -0,0 +1,32 @@ + + + + + + +def send_interviewee(): + + ... + + + + + + + + + + + + + + + + + + + + + + + diff --git a/script/settings.py b/script/settings.py new file mode 100644 index 0000000..d1ff979 --- /dev/null +++ b/script/settings.py @@ -0,0 +1,12 @@ +import pymongo +from clickhouse_driver import Client + +# 线上 +ckdb = Client(host='139.159.159.3', port='9654', user='legu', password='gncPASUwpYrc') + +mdb = pymongo.MongoClient(host='139.159.159.3', port=27017, username='root', password='iamciniao') +db = mdb['hr_system'] +mdb = db.userinfo +# 本地 +# ckdb = Client(host='139.159.159.3', port='9654', user='legu', password='gncPASUwpYrc') +# mdb = pymongo.MongoClient(host='10.0.0.240', port=27017)