简历兼容1
This commit is contained in:
parent
2dbee1e6e2
commit
05bb7e1102
@ -461,252 +461,252 @@ async def file_to_hw(
|
||||
except:
|
||||
return schemas.Msg(code=400, msg='上传文件有误', data=None)
|
||||
|
||||
# try:
|
||||
fn = path_data + '/' + filename
|
||||
if not fn.endswith('pdf'): # pdf正常上传到华为云
|
||||
# res = obsClient.putFile('legu-cdn-source', 'hrms/' + filename, path_data + '/' + filename)
|
||||
# doc/docx则转化为pdf上传到华为云
|
||||
fn, fil = doc2pdf(fn, path_data, filename)
|
||||
filename = fil
|
||||
try:
|
||||
fn = path_data + '/' + filename
|
||||
if not fn.endswith('pdf'): # pdf正常上传到华为云
|
||||
# res = obsClient.putFile('legu-cdn-source', 'hrms/' + filename, path_data + '/' + filename)
|
||||
# doc/docx则转化为pdf上传到华为云
|
||||
fn, fil = doc2pdf(fn, path_data, filename)
|
||||
filename = fil
|
||||
|
||||
# 简历初始文档
|
||||
data_mode = {
|
||||
"interview_name": "",
|
||||
"interview_type": 1,
|
||||
"interview_sign": 0,
|
||||
"hope_money": "",
|
||||
"feedback": 0,
|
||||
"interview_round": 0,
|
||||
"event_time": datetime.now(),
|
||||
"name": "",
|
||||
"phone": "",
|
||||
"job_name": "",
|
||||
"hr_name": "",
|
||||
"work_exp": 0,
|
||||
"interview_stage": 1,
|
||||
"owner_name": 2,
|
||||
"education": 1,
|
||||
"work_undergo": [],
|
||||
"project_undergo": [],
|
||||
"work_list": [],
|
||||
"school": "",
|
||||
"at_school": "",
|
||||
"specialty": "",
|
||||
"specialty_do": [],
|
||||
"mmended_state": 0,
|
||||
"mail": "",
|
||||
"account": "",
|
||||
"id_card": "",
|
||||
"gender": "",
|
||||
"age": 0,
|
||||
"gam": "",
|
||||
"interview_state": 1,
|
||||
"counts": 1,
|
||||
"nation": "汉",
|
||||
"review": "",
|
||||
"upgrade": [],
|
||||
"come_time": "",
|
||||
"now_money": "",
|
||||
"men_state": 1,
|
||||
"teacher_state": 1,
|
||||
"teacher_back": 1,
|
||||
"offer_state": 1,
|
||||
"offer_exam_state": 1,
|
||||
"notice_state": 1,
|
||||
"pass_why": 0,
|
||||
"pass_text": "",
|
||||
"now_address": "",
|
||||
"language": [],
|
||||
"remembrance": [],
|
||||
"file_url": '',
|
||||
"hr_manner": 2,
|
||||
}
|
||||
uid = get_uid()
|
||||
data_mode['uid'] = uid
|
||||
# 存数据
|
||||
chk_txt = getText_pdf(path_data + '/' + filename)
|
||||
data = fmt_txt(chk_txt)
|
||||
education = data['education']
|
||||
# 学历int转化
|
||||
education_int = {
|
||||
'大专': 1,
|
||||
'本科': 2,
|
||||
'研究生': 3,
|
||||
'博士': 4,
|
||||
'硕士': 5,
|
||||
}
|
||||
if education and isinstance(education, str):
|
||||
data['education'] = education_int.get(education, 1)
|
||||
age = data['age']
|
||||
if not age:
|
||||
data['age'] = 20
|
||||
# 年龄int转化
|
||||
if age and isinstance(age, str):
|
||||
true_age = re.search(r"\d+\.?\d*", age)
|
||||
if len(true_age.group()) > 2:
|
||||
# 简历初始文档
|
||||
data_mode = {
|
||||
"interview_name": "",
|
||||
"interview_type": 1,
|
||||
"interview_sign": 0,
|
||||
"hope_money": "",
|
||||
"feedback": 0,
|
||||
"interview_round": 0,
|
||||
"event_time": datetime.now(),
|
||||
"name": "",
|
||||
"phone": "",
|
||||
"job_name": "",
|
||||
"hr_name": "",
|
||||
"work_exp": 0,
|
||||
"interview_stage": 1,
|
||||
"owner_name": 2,
|
||||
"education": 1,
|
||||
"work_undergo": [],
|
||||
"project_undergo": [],
|
||||
"work_list": [],
|
||||
"school": "",
|
||||
"at_school": "",
|
||||
"specialty": "",
|
||||
"specialty_do": [],
|
||||
"mmended_state": 0,
|
||||
"mail": "",
|
||||
"account": "",
|
||||
"id_card": "",
|
||||
"gender": "",
|
||||
"age": 0,
|
||||
"gam": "",
|
||||
"interview_state": 1,
|
||||
"counts": 1,
|
||||
"nation": "汉",
|
||||
"review": "",
|
||||
"upgrade": [],
|
||||
"come_time": "",
|
||||
"now_money": "",
|
||||
"men_state": 1,
|
||||
"teacher_state": 1,
|
||||
"teacher_back": 1,
|
||||
"offer_state": 1,
|
||||
"offer_exam_state": 1,
|
||||
"notice_state": 1,
|
||||
"pass_why": 0,
|
||||
"pass_text": "",
|
||||
"now_address": "",
|
||||
"language": [],
|
||||
"remembrance": [],
|
||||
"file_url": '',
|
||||
"hr_manner": 2,
|
||||
}
|
||||
uid = get_uid()
|
||||
data_mode['uid'] = uid
|
||||
# 存数据
|
||||
chk_txt = getText_pdf(path_data + '/' + filename)
|
||||
data = fmt_txt(chk_txt)
|
||||
education = data['education']
|
||||
# 学历int转化
|
||||
education_int = {
|
||||
'大专': 1,
|
||||
'本科': 2,
|
||||
'研究生': 3,
|
||||
'博士': 4,
|
||||
'硕士': 5,
|
||||
}
|
||||
if education and isinstance(education, str):
|
||||
data['education'] = education_int.get(education, 1)
|
||||
age = data['age']
|
||||
if not age:
|
||||
data['age'] = 20
|
||||
else:
|
||||
data['age'] = int(true_age.group())
|
||||
work_exp = data['work_exp']
|
||||
if not work_exp:
|
||||
data['work_exp'] = 0
|
||||
# 工作经验float转化
|
||||
if work_exp and isinstance(work_exp, str):
|
||||
true_work_exp = re.search(r"\d+\.?\d*", work_exp)
|
||||
if len(true_work_exp.group()) > 3:
|
||||
# 年龄int转化
|
||||
if age and isinstance(age, str):
|
||||
true_age = re.search(r"\d+\.?\d*", age)
|
||||
if len(true_age.group()) > 2:
|
||||
data['age'] = 20
|
||||
else:
|
||||
data['age'] = int(true_age.group())
|
||||
work_exp = data['work_exp']
|
||||
if not work_exp:
|
||||
data['work_exp'] = 0
|
||||
else:
|
||||
data['work_exp'] = float(true_work_exp.group())
|
||||
# 工作经验float转化
|
||||
if work_exp and isinstance(work_exp, str):
|
||||
true_work_exp = re.search(r"\d+\.?\d*", work_exp)
|
||||
if len(true_work_exp.group()) > 3:
|
||||
data['work_exp'] = 0
|
||||
else:
|
||||
data['work_exp'] = float(true_work_exp.group())
|
||||
|
||||
data_mode.update(data)
|
||||
# 转json字符串
|
||||
if 'remembrance_list' in data_mode:
|
||||
remembrance = data_mode.pop('remembrance_list')
|
||||
data_mode['remembrance'] = remembrance
|
||||
if 'language_list' in data_mode:
|
||||
language = data_mode.pop('language_list')
|
||||
data_mode['language'] = language
|
||||
# if 'project_undergo' in data_mode:
|
||||
# if data_mode.get('project_undergo', []):
|
||||
# data_mode['project_undergo'] = [json.dumps(i) for i in data_mode['project_undergo']]
|
||||
# else:
|
||||
# data_mode['project_undergo'] = []
|
||||
# if 'work_list' in data_mode:
|
||||
# if data_mode.get('work_list', []):
|
||||
# data_mode['work_list'] = [json.dumps(i) for i in data_mode['work_list']]
|
||||
# else:
|
||||
# data_mode['work_list'] = []
|
||||
# if 'language' in data_mode:
|
||||
# if data_mode.get('language', []):
|
||||
# data_mode['language'] = [json.dumps(i) for i in data_mode['language']]
|
||||
# else:
|
||||
# data_mode['language'] = []
|
||||
# if 'remembrance' in data_mode:
|
||||
# if data_mode.get('remembrance', []):
|
||||
# data_mode['remembrance'] = [json.dumps(i) for i in data_mode['remembrance']]
|
||||
# else:
|
||||
# data_mode['remembrance'] = []
|
||||
data_mode.update(data)
|
||||
# 转json字符串
|
||||
if 'remembrance_list' in data_mode:
|
||||
remembrance = data_mode.pop('remembrance_list')
|
||||
data_mode['remembrance'] = remembrance
|
||||
if 'language_list' in data_mode:
|
||||
language = data_mode.pop('language_list')
|
||||
data_mode['language'] = language
|
||||
if 'project_undergo' in data_mode:
|
||||
if data_mode.get('project_undergo', []):
|
||||
data_mode['project_undergo'] = [json.dumps(i) for i in data_mode['project_undergo']]
|
||||
else:
|
||||
data_mode['project_undergo'] = []
|
||||
if 'work_list' in data_mode:
|
||||
if data_mode.get('work_list', []):
|
||||
data_mode['work_list'] = [json.dumps(i) for i in data_mode['work_list']]
|
||||
else:
|
||||
data_mode['work_list'] = []
|
||||
if 'language' in data_mode:
|
||||
if data_mode.get('language', []):
|
||||
data_mode['language'] = [json.dumps(i) for i in data_mode['language']]
|
||||
else:
|
||||
data_mode['language'] = []
|
||||
if 'remembrance' in data_mode:
|
||||
if data_mode.get('remembrance', []):
|
||||
data_mode['remembrance'] = [json.dumps(i) for i in data_mode['remembrance']]
|
||||
else:
|
||||
data_mode['remembrance'] = []
|
||||
|
||||
# 字符串转datetime
|
||||
# 字符串转datetime
|
||||
if data_mode.get('in_time', ''):
|
||||
chk_in_time = data_mode['in_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_in_time.split('/')) == 2:
|
||||
data_mode['in_time'] = str(datetime.strptime(chk_in_time, "%Y/%m").date())
|
||||
if len(chk_in_time.split('/')) == 3:
|
||||
data_mode['in_time'] = str(datetime.strptime(chk_in_time, "%Y/%m/%d").date())
|
||||
|
||||
if data_mode.get('in_time', ''):
|
||||
chk_in_time = data_mode['in_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_in_time.split('/')) == 2:
|
||||
data_mode['in_time'] = str(datetime.strptime(chk_in_time, "%Y/%m").date())
|
||||
if len(chk_in_time.split('/')) == 3:
|
||||
data_mode['in_time'] = str(datetime.strptime(chk_in_time, "%Y/%m/%d").date())
|
||||
if data_mode.get('out_time', ''):
|
||||
chk_out_time = data_mode['out_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_out_time.split('/')) == 2:
|
||||
data_mode['out_time'] = str(datetime.strptime(chk_out_time, "%Y/%m").date())
|
||||
if len(chk_out_time.split('/')) == 3:
|
||||
data_mode['out_time'] = str(datetime.strptime(chk_out_time, "%Y/%m/%d").date())
|
||||
|
||||
if data_mode.get('out_time', ''):
|
||||
chk_out_time = data_mode['out_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_out_time.split('/')) == 2:
|
||||
data_mode['out_time'] = str(datetime.strptime(chk_out_time, "%Y/%m").date())
|
||||
if len(chk_out_time.split('/')) == 3:
|
||||
data_mode['out_time'] = str(datetime.strptime(chk_out_time, "%Y/%m/%d").date())
|
||||
if data_mode.get('birthday', ''):
|
||||
chk_birthday = data_mode['birthday'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_birthday.split('/')) == 2:
|
||||
data_mode['birthday'] = str(datetime.strptime(chk_birthday, "%Y/%m").date())
|
||||
if len(chk_birthday.split('/')) == 3:
|
||||
data_mode['birthday'] = str(datetime.strptime(chk_birthday, "%Y/%m/%d").date())
|
||||
|
||||
if data_mode.get('birthday', ''):
|
||||
chk_birthday = data_mode['birthday'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_birthday.split('/')) == 2:
|
||||
data_mode['birthday'] = str(datetime.strptime(chk_birthday, "%Y/%m").date())
|
||||
if len(chk_birthday.split('/')) == 3:
|
||||
data_mode['birthday'] = str(datetime.strptime(chk_birthday, "%Y/%m/%d").date())
|
||||
if data_mode.get('star_time', ''):
|
||||
chk_star_time = data_mode['star_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_star_time.split('/')) == 2:
|
||||
data_mode['star_time'] = str(datetime.strptime(chk_star_time, "%Y/%m").date())
|
||||
if len(chk_star_time.split('/')) == 3:
|
||||
data_mode['star_time'] = str(datetime.strptime(chk_star_time, "%Y/%m/%d").date())
|
||||
|
||||
if data_mode.get('star_time', ''):
|
||||
chk_star_time = data_mode['star_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_star_time.split('/')) == 2:
|
||||
data_mode['star_time'] = str(datetime.strptime(chk_star_time, "%Y/%m").date())
|
||||
if len(chk_star_time.split('/')) == 3:
|
||||
data_mode['star_time'] = str(datetime.strptime(chk_star_time, "%Y/%m/%d").date())
|
||||
if data_mode.get('end_time', ''):
|
||||
chk_end_time = data_mode['end_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_end_time.split('/')) == 2:
|
||||
data_mode['end_time'] = str(datetime.strptime(chk_end_time, "%Y/%m").date())
|
||||
if len(chk_end_time.split('/')) == 3:
|
||||
data_mode['end_time'] = str(datetime.strptime(chk_end_time, "%Y/%m/%d").date())
|
||||
|
||||
if data_mode.get('end_time', ''):
|
||||
chk_end_time = data_mode['end_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_end_time.split('/')) == 2:
|
||||
data_mode['end_time'] = str(datetime.strptime(chk_end_time, "%Y/%m").date())
|
||||
if len(chk_end_time.split('/')) == 3:
|
||||
data_mode['end_time'] = str(datetime.strptime(chk_end_time, "%Y/%m/%d").date())
|
||||
if data_mode.get('graduate_time', ''):
|
||||
chk_graduate = data_mode['graduate_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_graduate.split('/')) == 2:
|
||||
data_mode['graduate_time'] = str(datetime.strptime(chk_graduate, "%Y/%m").date())
|
||||
if len(chk_graduate.split('/')) == 3:
|
||||
data_mode['graduate_time'] = str(datetime.strptime(chk_graduate, "%Y/%m/%d").date())
|
||||
|
||||
if data_mode.get('graduate_time', ''):
|
||||
chk_graduate = data_mode['graduate_time'].replace('-', '/').replace('.', '/')
|
||||
if len(chk_graduate.split('/')) == 2:
|
||||
data_mode['graduate_time'] = str(datetime.strptime(chk_graduate, "%Y/%m").date())
|
||||
if len(chk_graduate.split('/')) == 3:
|
||||
data_mode['graduate_time'] = str(datetime.strptime(chk_graduate, "%Y/%m/%d").date())
|
||||
work_list = data['work_list']
|
||||
language = data['language']
|
||||
project_undergo = data['project_undergo']
|
||||
remembrance = data['remembrance']
|
||||
|
||||
work_list = data_mode['work_list']
|
||||
language = data_mode['language']
|
||||
project_undergo = data_mode['project_undergo']
|
||||
remembrance = data_mode['remembrance']
|
||||
|
||||
# 简历查重,姓名,手机号,性别name,phone,gender
|
||||
find_name = data_mode['name']
|
||||
find_phone = data_mode['phone']
|
||||
find_gender = data_mode['gender']
|
||||
where = {}
|
||||
if find_name:
|
||||
where.update({
|
||||
'name': find_name
|
||||
})
|
||||
if find_phone:
|
||||
where.update({
|
||||
'phone': find_phone
|
||||
})
|
||||
if find_gender:
|
||||
where.update({
|
||||
'gender': find_gender
|
||||
})
|
||||
whereStr = ''
|
||||
for key, value in where.items():
|
||||
if isinstance(value, str):
|
||||
if not value.strip():
|
||||
# 简历查重,姓名,手机号,性别name,phone,gender
|
||||
find_name = data['name']
|
||||
find_phone = data['phone']
|
||||
find_gender = data['gender']
|
||||
where = {}
|
||||
if find_name:
|
||||
where.update({
|
||||
'name': find_name
|
||||
})
|
||||
if find_phone:
|
||||
where.update({
|
||||
'phone': find_phone
|
||||
})
|
||||
if find_gender:
|
||||
where.update({
|
||||
'gender': find_gender
|
||||
})
|
||||
whereStr = ''
|
||||
for key, value in where.items():
|
||||
if isinstance(value, str):
|
||||
if not value.strip():
|
||||
continue
|
||||
if whereStr:
|
||||
whereStr += 'and ' + str(key) + ' = ' + "'" + value + "'" + ' '
|
||||
else:
|
||||
whereStr += str(key) + ' = ' + "'" + value + "'" + ' '
|
||||
continue
|
||||
if whereStr:
|
||||
whereStr += 'and ' + str(key) + ' = ' + "'" + value + "'" + ' '
|
||||
whereStr += 'and ' + str(key) + ' = ' + str(value) + ' '
|
||||
else:
|
||||
whereStr += str(key) + ' = ' + "'" + value + "'" + ' '
|
||||
continue
|
||||
if whereStr:
|
||||
whereStr += 'and ' + str(key) + ' = ' + str(value) + ' '
|
||||
else:
|
||||
whereStr += str(key) + ' = ' + str(value) + ' '
|
||||
whereStr = whereStr.strip()
|
||||
sql = f"select uid from HR.resumes where {whereStr}"
|
||||
is_in_data = await db.execute(sql)
|
||||
exist = 0
|
||||
if is_in_data:
|
||||
exist = 1
|
||||
uid = list(is_in_data.values())[0]['uid']
|
||||
# os.rename(path_data + '/' + filename, path_data + '/' + find_phone + '.pdf')
|
||||
res = obsClient.putFile('legu-cdn-source', 'hrms/' + uid + '.pdf', fn)
|
||||
if res.status < 300:
|
||||
# 地址
|
||||
url = res.body.objectUrl
|
||||
data_mode['file_url'] = url
|
||||
res_data = {
|
||||
'data': data_mode,
|
||||
'file_url': url,
|
||||
'uid': uid,
|
||||
'exist': exist,
|
||||
'project_undergo': project_undergo,
|
||||
'work_list': work_list,
|
||||
'language_list': language,
|
||||
'remembrance_list': remembrance
|
||||
}
|
||||
if exist:
|
||||
return schemas.Msg(code=0, msg='ok', data=res_data)
|
||||
sql = f"insert into HR.resumes(interview_name, interview_type, interview_sign, hope_money, feedback," \
|
||||
f" interview_round, event_time, uid, name, phone, job_name, hr_name, work_exp, interview_stage, owner_name," \
|
||||
f" education, work_undergo, project_undergo, work_list, school, at_school, specialty, specialty_do, " \
|
||||
f"mmended_state, mail, account, id_card, gender, age, gam, interview_state, counts, nation, come_time," \
|
||||
f" review, upgrade, now_money, men_state, teacher_state, teacher_back, offer_state, offer_exam_state," \
|
||||
f" notice_state, pass_why, pass_text, now_address,language,remembrance, file_url, hr_manner) values"
|
||||
whereStr += str(key) + ' = ' + str(value) + ' '
|
||||
whereStr = whereStr.strip()
|
||||
sql = f"select uid from HR.resumes where {whereStr}"
|
||||
is_in_data = await db.execute(sql)
|
||||
exist = 0
|
||||
if is_in_data:
|
||||
exist = 1
|
||||
uid = list(is_in_data.values())[0]['uid']
|
||||
# os.rename(path_data + '/' + filename, path_data + '/' + find_phone + '.pdf')
|
||||
res = obsClient.putFile('legu-cdn-source', 'hrms/' + uid + '.pdf', fn)
|
||||
if res.status < 300:
|
||||
# 地址
|
||||
url = res.body.objectUrl
|
||||
data_mode['file_url'] = url
|
||||
data['file_url'] = url
|
||||
res_data = {
|
||||
'data': data,
|
||||
'file_url': url,
|
||||
'uid': uid,
|
||||
'exist': exist,
|
||||
'project_undergo': project_undergo,
|
||||
'work_list': work_list,
|
||||
'language_list': language,
|
||||
'remembrance_list': remembrance
|
||||
}
|
||||
if exist:
|
||||
return schemas.Msg(code=0, msg='ok', data=res_data)
|
||||
sql = f"insert into HR.resumes(interview_name, interview_type, interview_sign, hope_money, feedback," \
|
||||
f" interview_round, event_time, uid, name, phone, job_name, hr_name, work_exp, interview_stage, owner_name," \
|
||||
f" education, work_undergo, project_undergo, work_list, school, at_school, specialty, specialty_do, " \
|
||||
f"mmended_state, mail, account, id_card, gender, age, gam, interview_state, counts, nation, come_time," \
|
||||
f" review, upgrade, now_money, men_state, teacher_state, teacher_back, offer_state, offer_exam_state," \
|
||||
f" notice_state, pass_why, pass_text, now_address,language,remembrance, file_url, hr_manner) values"
|
||||
|
||||
await db.execute_dict(sql, [data_mode])
|
||||
return schemas.Msg(code=0, msg='ok', data=res_data)
|
||||
else:
|
||||
print('errorCode:', res.errorCode)
|
||||
print('errorMessage:', res.errorMessage)
|
||||
return schemas.Msg(code=400, msg='上传华为云失败', data=None)
|
||||
# except:
|
||||
# return schemas.Msg(code=400, msg='上传华为云失败或者解析失败', data=None)
|
||||
await db.execute_dict(sql, [data_mode])
|
||||
return schemas.Msg(code=0, msg='ok', data=res_data)
|
||||
else:
|
||||
print('errorCode:', res.errorCode)
|
||||
print('errorMessage:', res.errorMessage)
|
||||
return schemas.Msg(code=400, msg='上传华为云失败', data=None)
|
||||
except:
|
||||
return schemas.Msg(code=400, msg='上传华为云失败或者解析失败', data=None)
|
||||
|
||||
|
||||
# 导入面试数据
|
||||
|
Loading…
Reference in New Issue
Block a user