上传
This commit is contained in:
parent
11ef2d5e72
commit
4df830d117
@ -356,7 +356,8 @@ async def file_to_hw(
|
||||
res = obsClient.putFile('legu-cdn-source', 'hrms/' + filename, path_data + '/' + filename)
|
||||
else: # doc/docx则转化为pdf上传到华为云
|
||||
new_fn, fil = doc2pdf(fn, path_data, filename)
|
||||
res = obsClient.putFile('legu-cdn-source', 'hrms/' + fil, new_fn)
|
||||
filename = fil
|
||||
res = obsClient.putFile('legu-cdn-source', 'hrms/' + filename, new_fn)
|
||||
if res.status < 300:
|
||||
# 地址
|
||||
url = res.body.objectUrl
|
||||
@ -378,8 +379,8 @@ async def file_to_hw(
|
||||
"owner_name": 2,
|
||||
"education": 1,
|
||||
"work_undergo": [],
|
||||
"project_undergo": "",
|
||||
"work_list": "",
|
||||
"project_undergo": [],
|
||||
"work_list": [],
|
||||
"school": "",
|
||||
"at_school": "",
|
||||
"specialty": "",
|
||||
@ -407,8 +408,8 @@ async def file_to_hw(
|
||||
"pass_why": 0,
|
||||
"pass_text": "",
|
||||
"now_address": "",
|
||||
"language": "",
|
||||
"remembrance": "",
|
||||
"language": [],
|
||||
"remembrance": [],
|
||||
"file_url": url,
|
||||
}
|
||||
uid = get_uid()
|
||||
@ -420,17 +421,134 @@ async def file_to_hw(
|
||||
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) values"
|
||||
# 存数据
|
||||
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['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:
|
||||
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'] = []
|
||||
|
||||
# 字符串转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('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('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('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']
|
||||
|
||||
res_data = {
|
||||
'data': data,
|
||||
'file_url': url,
|
||||
'uid': uid,
|
||||
'project_undergo': project_undergo,
|
||||
'work_list': work_list,
|
||||
'language_list': language,
|
||||
'remembrance_list': remembrance
|
||||
}
|
||||
await db.execute_dict(sql, [data_mode])
|
||||
resData = {'file_url': url, 'filename': 'hrms/' + filename, 'uid': uid}
|
||||
return schemas.Msg(code=0, msg='ok', data=resData)
|
||||
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:
|
||||
import traceback
|
||||
print(traceback.format_exc())
|
||||
return schemas.Msg(code=400, msg='上传华为云失败', data=None)
|
||||
return schemas.Msg(code=400, msg='上传华为云失败或者解析失败', data=None)
|
||||
|
||||
|
||||
# 导入面试数据
|
||||
|
Loading…
Reference in New Issue
Block a user