|
@@ -189,8 +189,7 @@ def _validate_files_by_task_type(files, task_type):
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': f'第{i+1}个文件缺少文件名',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': f'第{i+1}个文件缺少文件名'
|
|
}
|
|
}
|
|
|
|
|
|
# 杂项类型不验证文件格式
|
|
# 杂项类型不验证文件格式
|
|
@@ -207,8 +206,7 @@ def _validate_files_by_task_type(files, task_type):
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': f'第{i+1}个文件格式不支持,{task_type}任务只支持{format_desc[task_type]}',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': f'第{i+1}个文件格式不支持,{task_type}任务只支持{format_desc[task_type]}'
|
|
}
|
|
}
|
|
|
|
|
|
return {'success': True}
|
|
return {'success': True}
|
|
@@ -280,8 +278,7 @@ def _handle_recruitment_task(created_by, data=None):
|
|
return {
|
|
return {
|
|
'code': 200,
|
|
'code': 200,
|
|
'success': True,
|
|
'success': True,
|
|
- 'message': '招聘任务创建成功',
|
|
|
|
- 'data': parse_task.to_dict()
|
|
|
|
|
|
+ 'message': '招聘任务创建成功'
|
|
}
|
|
}
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -292,8 +289,7 @@ def _handle_recruitment_task(created_by, data=None):
|
|
return {
|
|
return {
|
|
'code': 500,
|
|
'code': 500,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': error_msg,
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': error_msg
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -386,8 +382,7 @@ def add_parse_task(files, task_type, created_by='system', data=None, publish_tim
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': 'task_type参数必须是以下值之一:名片、简历、新任命、招聘、杂项',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': 'task_type参数必须是以下值之一:名片、简历、新任命、招聘、杂项'
|
|
}
|
|
}
|
|
|
|
|
|
# 对于招聘类型,不需要文件,直接处理数据库记录
|
|
# 对于招聘类型,不需要文件,直接处理数据库记录
|
|
@@ -396,8 +391,7 @@ def add_parse_task(files, task_type, created_by='system', data=None, publish_tim
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '招聘类型任务不需要上传文件',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '招聘类型任务不需要上传文件'
|
|
}
|
|
}
|
|
# 招聘任务处理逻辑
|
|
# 招聘任务处理逻辑
|
|
return _handle_recruitment_task(created_by, data)
|
|
return _handle_recruitment_task(created_by, data)
|
|
@@ -407,16 +401,14 @@ def add_parse_task(files, task_type, created_by='system', data=None, publish_tim
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': 'files参数必须是非空数组',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': 'files参数必须是非空数组'
|
|
}
|
|
}
|
|
|
|
|
|
if len(files) == 0:
|
|
if len(files) == 0:
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '文件数组不能为空',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '文件数组不能为空'
|
|
}
|
|
}
|
|
|
|
|
|
# 根据任务类型验证文件格式
|
|
# 根据任务类型验证文件格式
|
|
@@ -430,8 +422,7 @@ def add_parse_task(files, task_type, created_by='system', data=None, publish_tim
|
|
return {
|
|
return {
|
|
'code': 500,
|
|
'code': 500,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '无法连接到MinIO服务器',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '无法连接到MinIO服务器'
|
|
}
|
|
}
|
|
|
|
|
|
# 存储上传结果
|
|
# 存储上传结果
|
|
@@ -504,8 +495,7 @@ def add_parse_task(files, task_type, created_by='system', data=None, publish_tim
|
|
return {
|
|
return {
|
|
'code': 500,
|
|
'code': 500,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '所有文件上传失败',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '所有文件上传失败'
|
|
}
|
|
}
|
|
|
|
|
|
# 生成任务名称
|
|
# 生成任务名称
|
|
@@ -580,15 +570,13 @@ def add_parse_task(files, task_type, created_by='system', data=None, publish_tim
|
|
return {
|
|
return {
|
|
'code': 206, # Partial Content
|
|
'code': 206, # Partial Content
|
|
'success': True,
|
|
'success': True,
|
|
- 'message': f'解析任务创建成功,但有{len(failed_uploads)}个文件上传失败',
|
|
|
|
- 'data': result_data
|
|
|
|
|
|
+ 'message': f'解析任务创建成功,但有{len(failed_uploads)}个文件上传失败'
|
|
}
|
|
}
|
|
else:
|
|
else:
|
|
return {
|
|
return {
|
|
'code': 200,
|
|
'code': 200,
|
|
'success': True,
|
|
'success': True,
|
|
- 'message': '解析任务创建成功,所有文件上传完成',
|
|
|
|
- 'data': result_data
|
|
|
|
|
|
+ 'message': '解析任务创建成功,所有文件上传完成'
|
|
}
|
|
}
|
|
|
|
|
|
except Exception as db_error:
|
|
except Exception as db_error:
|
|
@@ -599,8 +587,7 @@ def add_parse_task(files, task_type, created_by='system', data=None, publish_tim
|
|
return {
|
|
return {
|
|
'code': 500,
|
|
'code': 500,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': error_msg,
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': error_msg
|
|
}
|
|
}
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -610,8 +597,7 @@ def add_parse_task(files, task_type, created_by='system', data=None, publish_tim
|
|
return {
|
|
return {
|
|
'code': 500,
|
|
'code': 500,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': error_msg,
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': error_msg
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -624,52 +610,91 @@ def _update_origin_source_with_minio_path(existing_origin_source, talent_data=No
|
|
talent_data: 人才数据,包含origin_source字段
|
|
talent_data: 人才数据,包含origin_source字段
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
- str: 更新后的origin_source JSON字符串
|
|
|
|
|
|
+ list: 更新后的origin_source JSON数组,格式为:
|
|
|
|
+ [
|
|
|
|
+ {"task_type": "名片", "minio_path": "path1", "source_date": "2025-01-01"},
|
|
|
|
+ {"task_type": "简历", "minio_path": "path2", "source_date": "2025-01-02"}
|
|
|
|
+ ]
|
|
"""
|
|
"""
|
|
import json
|
|
import json
|
|
|
|
|
|
try:
|
|
try:
|
|
# 解析现有的origin_source
|
|
# 解析现有的origin_source
|
|
|
|
+ origin_list = []
|
|
if existing_origin_source:
|
|
if existing_origin_source:
|
|
- try:
|
|
|
|
- origin_list = json.loads(existing_origin_source)
|
|
|
|
- if not isinstance(origin_list, list):
|
|
|
|
- origin_list = [origin_list]
|
|
|
|
- except (json.JSONDecodeError, TypeError):
|
|
|
|
- # 如果解析失败,将现有内容作为单个元素
|
|
|
|
- origin_list = [existing_origin_source] if existing_origin_source else []
|
|
|
|
- else:
|
|
|
|
|
|
+ if isinstance(existing_origin_source, str):
|
|
|
|
+ try:
|
|
|
|
+ parsed = json.loads(existing_origin_source)
|
|
|
|
+ if isinstance(parsed, list):
|
|
|
|
+ origin_list = parsed
|
|
|
|
+ elif isinstance(parsed, dict):
|
|
|
|
+ origin_list = [parsed]
|
|
|
|
+ else:
|
|
|
|
+ origin_list = []
|
|
|
|
+ except (json.JSONDecodeError, TypeError):
|
|
|
|
+ origin_list = []
|
|
|
|
+ elif isinstance(existing_origin_source, list):
|
|
|
|
+ origin_list = existing_origin_source
|
|
|
|
+ elif isinstance(existing_origin_source, dict):
|
|
|
|
+ origin_list = [existing_origin_source]
|
|
|
|
+ else:
|
|
|
|
+ origin_list = []
|
|
|
|
+
|
|
|
|
+ # 确保origin_list是列表
|
|
|
|
+ if not isinstance(origin_list, list):
|
|
origin_list = []
|
|
origin_list = []
|
|
|
|
|
|
# 处理talent_data提供的origin_source
|
|
# 处理talent_data提供的origin_source
|
|
if talent_data and talent_data.get('origin_source'):
|
|
if talent_data and talent_data.get('origin_source'):
|
|
talent_origin_source = talent_data.get('origin_source')
|
|
talent_origin_source = talent_data.get('origin_source')
|
|
|
|
+
|
|
if isinstance(talent_origin_source, list):
|
|
if isinstance(talent_origin_source, list):
|
|
- # 如果是列表,直接合并
|
|
|
|
|
|
+ # 如果是列表,验证每个元素是否符合格式要求
|
|
for entry in talent_origin_source:
|
|
for entry in talent_origin_source:
|
|
- if isinstance(entry, dict) and entry not in origin_list:
|
|
|
|
- origin_list.append(entry)
|
|
|
|
|
|
+ if isinstance(entry, dict) and 'task_type' in entry and 'minio_path' in entry:
|
|
|
|
+ # 检查是否已存在相同的minio_path记录
|
|
|
|
+ existing_paths = [item.get('minio_path') for item in origin_list if isinstance(item, dict)]
|
|
|
|
+ if entry.get('minio_path') not in existing_paths:
|
|
|
|
+ origin_list.append(entry)
|
|
elif isinstance(talent_origin_source, str):
|
|
elif isinstance(talent_origin_source, str):
|
|
# 如果是字符串,尝试解析为JSON
|
|
# 如果是字符串,尝试解析为JSON
|
|
try:
|
|
try:
|
|
parsed_talent_origin = json.loads(talent_origin_source)
|
|
parsed_talent_origin = json.loads(talent_origin_source)
|
|
if isinstance(parsed_talent_origin, list):
|
|
if isinstance(parsed_talent_origin, list):
|
|
for entry in parsed_talent_origin:
|
|
for entry in parsed_talent_origin:
|
|
- if isinstance(entry, dict) and entry not in origin_list:
|
|
|
|
- origin_list.append(entry)
|
|
|
|
- elif isinstance(parsed_talent_origin, dict) and parsed_talent_origin not in origin_list:
|
|
|
|
- origin_list.append(parsed_talent_origin)
|
|
|
|
|
|
+ if isinstance(entry, dict) and 'task_type' in entry and 'minio_path' in entry:
|
|
|
|
+ existing_paths = [item.get('minio_path') for item in origin_list if isinstance(item, dict)]
|
|
|
|
+ if entry.get('minio_path') not in existing_paths:
|
|
|
|
+ origin_list.append(entry)
|
|
|
|
+ elif isinstance(parsed_talent_origin, dict) and 'task_type' in parsed_talent_origin and 'minio_path' in parsed_talent_origin:
|
|
|
|
+ existing_paths = [item.get('minio_path') for item in origin_list if isinstance(item, dict)]
|
|
|
|
+ if parsed_talent_origin.get('minio_path') not in existing_paths:
|
|
|
|
+ origin_list.append(parsed_talent_origin)
|
|
except (json.JSONDecodeError, TypeError):
|
|
except (json.JSONDecodeError, TypeError):
|
|
# 如果解析失败,忽略talent_data的origin_source
|
|
# 如果解析失败,忽略talent_data的origin_source
|
|
pass
|
|
pass
|
|
-
|
|
|
|
- # 返回JSON字符串
|
|
|
|
- return json.dumps(origin_list, ensure_ascii=False)
|
|
|
|
|
|
+ elif isinstance(talent_origin_source, dict) and 'task_type' in talent_origin_source and 'minio_path' in talent_origin_source:
|
|
|
|
+ # 如果是字典,检查是否符合格式要求
|
|
|
|
+ existing_paths = [item.get('minio_path') for item in origin_list if isinstance(item, dict)]
|
|
|
|
+ if talent_origin_source.get('minio_path') not in existing_paths:
|
|
|
|
+ origin_list.append(talent_origin_source)
|
|
|
|
+
|
|
|
|
+ # 验证最终结果,确保每个元素都符合格式要求
|
|
|
|
+ validated_list = []
|
|
|
|
+ for item in origin_list:
|
|
|
|
+ if isinstance(item, dict) and 'task_type' in item and 'minio_path' in item:
|
|
|
|
+ # 确保有source_date字段,如果没有则添加当前日期
|
|
|
|
+ if 'source_date' not in item:
|
|
|
|
+ from datetime import datetime
|
|
|
|
+ item['source_date'] = datetime.now().strftime('%Y-%m-%d')
|
|
|
|
+ validated_list.append(item)
|
|
|
|
+
|
|
|
|
+ return validated_list
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logging.error(f"更新origin_source失败: {str(e)}")
|
|
logging.error(f"更新origin_source失败: {str(e)}")
|
|
- # 如果处理失败,返回原始的origin_source
|
|
|
|
- return existing_origin_source
|
|
|
|
|
|
+ # 如果处理失败,返回空数组
|
|
|
|
+ return []
|
|
|
|
|
|
|
|
|
|
def add_single_talent(talent_data, minio_path=None, task_type=None):
|
|
def add_single_talent(talent_data, minio_path=None, task_type=None):
|
|
@@ -690,8 +715,7 @@ def add_single_talent(talent_data, minio_path=None, task_type=None):
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '人才数据不能为空',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '人才数据不能为空'
|
|
}
|
|
}
|
|
|
|
|
|
# 检查重复记录
|
|
# 检查重复记录
|
|
@@ -824,8 +848,7 @@ def add_single_talent(talent_data, minio_path=None, task_type=None):
|
|
return {
|
|
return {
|
|
'code': 200,
|
|
'code': 200,
|
|
'success': True,
|
|
'success': True,
|
|
- 'message': f'人才信息已更新。{duplicate_check["reason"]}',
|
|
|
|
- 'data': existing_card.to_dict()
|
|
|
|
|
|
+ 'message': f'人才信息已更新。{duplicate_check["reason"]}'
|
|
}
|
|
}
|
|
|
|
|
|
elif duplicate_check['action'] == 'create_with_duplicates':
|
|
elif duplicate_check['action'] == 'create_with_duplicates':
|
|
@@ -880,15 +903,7 @@ def add_single_talent(talent_data, minio_path=None, task_type=None):
|
|
return {
|
|
return {
|
|
'code': 202, # Accepted,表示已接受但需要进一步处理
|
|
'code': 202, # Accepted,表示已接受但需要进一步处理
|
|
'success': True,
|
|
'success': True,
|
|
- 'message': f'创建新记录成功,发现疑似重复记录待处理。{duplicate_check["reason"]}',
|
|
|
|
- 'data': {
|
|
|
|
- 'main_card': main_card.to_dict(),
|
|
|
|
- 'duplicate_record_id': duplicate_record.id,
|
|
|
|
- 'suspected_duplicates_count': len(duplicate_check['suspected_duplicates']),
|
|
|
|
- 'processing_status': 'pending',
|
|
|
|
- 'duplicate_reason': duplicate_record.duplicate_reason,
|
|
|
|
- 'created_at': duplicate_record.created_at.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
|
- }
|
|
|
|
|
|
+ 'message': f'创建新记录成功,发现疑似重复记录待处理。{duplicate_check["reason"]}'
|
|
}
|
|
}
|
|
|
|
|
|
else:
|
|
else:
|
|
@@ -986,8 +1001,7 @@ def add_single_talent(talent_data, minio_path=None, task_type=None):
|
|
return {
|
|
return {
|
|
'code': 200,
|
|
'code': 200,
|
|
'success': True,
|
|
'success': True,
|
|
- 'message': f'人才信息保存成功。{duplicate_check["reason"]}',
|
|
|
|
- 'data': business_card.to_dict()
|
|
|
|
|
|
+ 'message': f'人才信息保存成功。{duplicate_check["reason"]}'
|
|
}
|
|
}
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -998,8 +1012,7 @@ def add_single_talent(talent_data, minio_path=None, task_type=None):
|
|
return {
|
|
return {
|
|
'code': 500,
|
|
'code': 500,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': error_msg,
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': error_msg
|
|
}
|
|
}
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -1010,8 +1023,7 @@ def add_single_talent(talent_data, minio_path=None, task_type=None):
|
|
return {
|
|
return {
|
|
'code': 500,
|
|
'code': 500,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': error_msg,
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': error_msg
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1032,8 +1044,7 @@ def add_parsed_talents(api_response_data):
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': 'api_response_data参数必须是非空字典',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': 'api_response_data参数必须是非空字典'
|
|
}
|
|
}
|
|
|
|
|
|
# 获取data字段
|
|
# 获取data字段
|
|
@@ -1042,8 +1053,7 @@ def add_parsed_talents(api_response_data):
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '请求中缺少有效的data字段',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '请求中缺少有效的data字段'
|
|
}
|
|
}
|
|
|
|
|
|
# 获取results数组
|
|
# 获取results数组
|
|
@@ -1052,16 +1062,14 @@ def add_parsed_talents(api_response_data):
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '请求中的results字段必须是数组',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '请求中的results字段必须是数组'
|
|
}
|
|
}
|
|
|
|
|
|
if len(results) == 0:
|
|
if len(results) == 0:
|
|
return {
|
|
return {
|
|
'code': 400,
|
|
'code': 400,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '请求中的results数组为空,没有人才数据需要处理',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '请求中的results数组为空,没有人才数据需要处理'
|
|
}
|
|
}
|
|
|
|
|
|
# 从api_response_data中提取task_type
|
|
# 从api_response_data中提取task_type
|
|
@@ -1084,8 +1092,7 @@ def add_parsed_talents(api_response_data):
|
|
processed_results.append({
|
|
processed_results.append({
|
|
'index': i,
|
|
'index': i,
|
|
'success': False,
|
|
'success': False,
|
|
- 'error': '人才数据格式无效,必须是字典格式',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '人才数据格式无效,必须是字典格式'
|
|
})
|
|
})
|
|
logging.warning(f"第 {i+1} 条记录人才数据格式无效")
|
|
logging.warning(f"第 {i+1} 条记录人才数据格式无效")
|
|
continue
|
|
continue
|
|
@@ -1096,8 +1103,7 @@ def add_parsed_talents(api_response_data):
|
|
processed_results.append({
|
|
processed_results.append({
|
|
'index': i,
|
|
'index': i,
|
|
'success': False,
|
|
'success': False,
|
|
- 'error': '人才数据缺少必要字段name_zh',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '人才数据缺少必要字段name_zh'
|
|
})
|
|
})
|
|
logging.warning(f"第 {i+1} 条记录缺少name_zh字段")
|
|
logging.warning(f"第 {i+1} 条记录缺少name_zh字段")
|
|
continue
|
|
continue
|
|
@@ -1132,7 +1138,6 @@ def add_parsed_talents(api_response_data):
|
|
'index': i,
|
|
'index': i,
|
|
'success': True,
|
|
'success': True,
|
|
'error': None,
|
|
'error': None,
|
|
- 'data': talent_result.get('data'),
|
|
|
|
'message': f'成功处理人员: {talent_data.get("name_zh", "未知")}'
|
|
'message': f'成功处理人员: {talent_data.get("name_zh", "未知")}'
|
|
})
|
|
})
|
|
logging.debug(f"成功处理第 {i+1} 条记录")
|
|
logging.debug(f"成功处理第 {i+1} 条记录")
|
|
@@ -1141,8 +1146,7 @@ def add_parsed_talents(api_response_data):
|
|
processed_results.append({
|
|
processed_results.append({
|
|
'index': i,
|
|
'index': i,
|
|
'success': False,
|
|
'success': False,
|
|
- 'error': talent_result.get('message', '处理失败'),
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': talent_result.get('message', '处理失败')
|
|
})
|
|
})
|
|
logging.error(f"处理第 {i+1} 条记录失败: {talent_result.get('message', '未知错误')}")
|
|
logging.error(f"处理第 {i+1} 条记录失败: {talent_result.get('message', '未知错误')}")
|
|
except Exception as talent_error:
|
|
except Exception as talent_error:
|
|
@@ -1151,8 +1155,7 @@ def add_parsed_talents(api_response_data):
|
|
processed_results.append({
|
|
processed_results.append({
|
|
'index': i,
|
|
'index': i,
|
|
'success': False,
|
|
'success': False,
|
|
- 'error': error_msg,
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': error_msg
|
|
})
|
|
})
|
|
logging.error(error_msg, exc_info=True)
|
|
logging.error(error_msg, exc_info=True)
|
|
|
|
|
|
@@ -1162,8 +1165,7 @@ def add_parsed_talents(api_response_data):
|
|
processed_results.append({
|
|
processed_results.append({
|
|
'index': i,
|
|
'index': i,
|
|
'success': False,
|
|
'success': False,
|
|
- 'error': error_msg,
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': error_msg
|
|
})
|
|
})
|
|
logging.error(error_msg, exc_info=True)
|
|
logging.error(error_msg, exc_info=True)
|
|
|
|
|
|
@@ -1184,22 +1186,19 @@ def add_parsed_talents(api_response_data):
|
|
return {
|
|
return {
|
|
'code': 200,
|
|
'code': 200,
|
|
'success': True,
|
|
'success': True,
|
|
- 'message': f'批量处理完成,全部 {success_count} 条记录处理成功',
|
|
|
|
- 'data': batch_result
|
|
|
|
|
|
+ 'message': f'批量处理完成,全部 {success_count} 条记录处理成功'
|
|
}
|
|
}
|
|
elif success_count == 0:
|
|
elif success_count == 0:
|
|
return {
|
|
return {
|
|
'code': 500,
|
|
'code': 500,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': f'批量处理失败,全部 {failed_count} 条记录处理失败',
|
|
|
|
- 'data': batch_result
|
|
|
|
|
|
+ 'message': f'批量处理失败,全部 {failed_count} 条记录处理失败'
|
|
}
|
|
}
|
|
else:
|
|
else:
|
|
return {
|
|
return {
|
|
'code': 206, # Partial Content
|
|
'code': 206, # Partial Content
|
|
'success': True,
|
|
'success': True,
|
|
- 'message': f'批量处理部分成功,成功 {success_count} 条,失败 {failed_count} 条',
|
|
|
|
- 'data': batch_result
|
|
|
|
|
|
+ 'message': f'批量处理部分成功,成功 {success_count} 条,失败 {failed_count} 条'
|
|
}
|
|
}
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -1209,8 +1208,7 @@ def add_parsed_talents(api_response_data):
|
|
return {
|
|
return {
|
|
'code': 500,
|
|
'code': 500,
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': error_msg,
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': error_msg
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1276,16 +1274,14 @@ def record_parsed_talent(talent_data, task_id=None, task_type=None):
|
|
if not talent_data or not isinstance(talent_data, dict):
|
|
if not talent_data or not isinstance(talent_data, dict):
|
|
return {
|
|
return {
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '人才数据不能为空且必须是字典格式',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '人才数据不能为空且必须是字典格式'
|
|
}
|
|
}
|
|
|
|
|
|
# 检查必要字段
|
|
# 检查必要字段
|
|
if not talent_data.get('name_zh'):
|
|
if not talent_data.get('name_zh'):
|
|
return {
|
|
return {
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': '人才数据必须包含name_zh字段',
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': '人才数据必须包含name_zh字段'
|
|
}
|
|
}
|
|
|
|
|
|
# 创建ParsedTalent记录
|
|
# 创建ParsedTalent记录
|
|
@@ -1331,8 +1327,7 @@ def record_parsed_talent(talent_data, task_id=None, task_type=None):
|
|
|
|
|
|
return {
|
|
return {
|
|
'success': True,
|
|
'success': True,
|
|
- 'message': '成功记录人才信息',
|
|
|
|
- 'data': parsed_talent.to_dict()
|
|
|
|
|
|
+ 'message': '成功记录人才信息'
|
|
}
|
|
}
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -1342,8 +1337,7 @@ def record_parsed_talent(talent_data, task_id=None, task_type=None):
|
|
|
|
|
|
return {
|
|
return {
|
|
'success': False,
|
|
'success': False,
|
|
- 'message': error_msg,
|
|
|
|
- 'data': None
|
|
|
|
|
|
+ 'message': error_msg
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|