|
@@ -626,13 +626,14 @@ def add_parse_task(files, task_type, created_by='system', data=None, publish_tim
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-def _update_origin_source_with_minio_path(existing_origin_source, minio_path):
|
|
|
|
|
|
+def _update_origin_source_with_minio_path(existing_origin_source, minio_path, task_type=None):
|
|
"""
|
|
"""
|
|
- 更新origin_source字段,将minio_path添加到JSON数组中
|
|
|
|
|
|
+ 更新origin_source字段,将minio_path和task_type组成的JSON对象添加到JSON数组中
|
|
|
|
|
|
Args:
|
|
Args:
|
|
existing_origin_source: 现有的origin_source内容
|
|
existing_origin_source: 现有的origin_source内容
|
|
minio_path: 要添加的minio_path
|
|
minio_path: 要添加的minio_path
|
|
|
|
+ task_type: 任务类型
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
str: 更新后的origin_source JSON字符串
|
|
str: 更新后的origin_source JSON字符串
|
|
@@ -640,10 +641,6 @@ def _update_origin_source_with_minio_path(existing_origin_source, minio_path):
|
|
import json
|
|
import json
|
|
|
|
|
|
try:
|
|
try:
|
|
- # 如果minio_path为空,直接返回现有的origin_source
|
|
|
|
- if not minio_path:
|
|
|
|
- return existing_origin_source
|
|
|
|
-
|
|
|
|
# 解析现有的origin_source
|
|
# 解析现有的origin_source
|
|
if existing_origin_source:
|
|
if existing_origin_source:
|
|
try:
|
|
try:
|
|
@@ -656,9 +653,23 @@ def _update_origin_source_with_minio_path(existing_origin_source, minio_path):
|
|
else:
|
|
else:
|
|
origin_list = []
|
|
origin_list = []
|
|
|
|
|
|
- # 添加新的minio_path(如果不存在)
|
|
|
|
- if minio_path not in origin_list:
|
|
|
|
- origin_list.append(minio_path)
|
|
|
|
|
|
+ # 如果minio_path不为空,则创建新的JSON对象并添加到列表中
|
|
|
|
+ if minio_path:
|
|
|
|
+ # 创建新的JSON对象,格式为 {task_type: "任务类型", minio_path: "路径"}
|
|
|
|
+ new_entry = {
|
|
|
|
+ "task_type": task_type if task_type else "",
|
|
|
|
+ "minio_path": minio_path
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ # 检查是否已存在相同的条目
|
|
|
|
+ entry_exists = False
|
|
|
|
+ for existing_entry in origin_list:
|
|
|
|
+ if isinstance(existing_entry, dict) and existing_entry.get('minio_path') == minio_path:
|
|
|
|
+ entry_exists = True
|
|
|
|
+ break
|
|
|
|
+
|
|
|
|
+ if not entry_exists:
|
|
|
|
+ origin_list.append(new_entry)
|
|
|
|
|
|
# 返回JSON字符串
|
|
# 返回JSON字符串
|
|
return json.dumps(origin_list, ensure_ascii=False)
|
|
return json.dumps(origin_list, ensure_ascii=False)
|
|
@@ -669,12 +680,14 @@ def _update_origin_source_with_minio_path(existing_origin_source, minio_path):
|
|
return existing_origin_source
|
|
return existing_origin_source
|
|
|
|
|
|
|
|
|
|
-def add_single_talent(talent_data):
|
|
|
|
|
|
+def add_single_talent(talent_data, minio_path=None, task_type=None):
|
|
"""
|
|
"""
|
|
添加单个人才记录(基于add_business_card逻辑,去除MinIO图片上传)
|
|
添加单个人才记录(基于add_business_card逻辑,去除MinIO图片上传)
|
|
|
|
|
|
Args:
|
|
Args:
|
|
talent_data (dict): 人才信息数据
|
|
talent_data (dict): 人才信息数据
|
|
|
|
+ minio_path (str, optional): MinIO路径,用于更新origin_source字段
|
|
|
|
+ task_type (str, optional): 任务类型,用于更新origin_source字段
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
dict: 处理结果,包含保存的信息和状态
|
|
dict: 处理结果,包含保存的信息和状态
|
|
@@ -768,8 +781,9 @@ def add_single_talent(talent_data):
|
|
# 更新image_path字段,从talent_data中获取
|
|
# 更新image_path字段,从talent_data中获取
|
|
existing_card.image_path = talent_data.get('image_path', existing_card.image_path)
|
|
existing_card.image_path = talent_data.get('image_path', existing_card.image_path)
|
|
# 更新origin_source字段,将minio_path添加到JSON数组中
|
|
# 更新origin_source字段,将minio_path添加到JSON数组中
|
|
- minio_path = talent_data.get('minio_path', '')
|
|
|
|
- existing_card.origin_source = _update_origin_source_with_minio_path(existing_card.origin_source, minio_path)
|
|
|
|
|
|
+ # 只有当minio_path不为空时才更新origin_source
|
|
|
|
+ if minio_path:
|
|
|
|
+ existing_card.origin_source = _update_origin_source_with_minio_path(existing_card.origin_source, minio_path, task_type)
|
|
existing_card.talent_profile = talent_data.get('talent_profile', existing_card.talent_profile)
|
|
existing_card.talent_profile = talent_data.get('talent_profile', existing_card.talent_profile)
|
|
existing_card.updated_by = 'talent_system'
|
|
existing_card.updated_by = 'talent_system'
|
|
|
|
|
|
@@ -785,7 +799,6 @@ def add_single_talent(talent_data):
|
|
# 在Neo4j图数据库中更新Talent节点
|
|
# 在Neo4j图数据库中更新Talent节点
|
|
try:
|
|
try:
|
|
from app.core.graph.graph_operations import create_or_get_node
|
|
from app.core.graph.graph_operations import create_or_get_node
|
|
- from datetime import datetime
|
|
|
|
|
|
|
|
# 创建Talent节点属性
|
|
# 创建Talent节点属性
|
|
talent_properties = {
|
|
talent_properties = {
|
|
@@ -823,14 +836,14 @@ def add_single_talent(talent_data):
|
|
)
|
|
)
|
|
|
|
|
|
# 更新origin_source字段,将minio_path添加到JSON数组中
|
|
# 更新origin_source字段,将minio_path添加到JSON数组中
|
|
- minio_path = talent_data.get('minio_path', '')
|
|
|
|
- main_card.origin_source = _update_origin_source_with_minio_path(main_card.origin_source, minio_path)
|
|
|
|
|
|
+ # 只有当minio_path不为空时才更新origin_source
|
|
|
|
+ if minio_path:
|
|
|
|
+ main_card.origin_source = _update_origin_source_with_minio_path(main_card.origin_source, minio_path, task_type)
|
|
db.session.commit() # 提交origin_source的更新
|
|
db.session.commit() # 提交origin_source的更新
|
|
|
|
|
|
# 在Neo4j图数据库中创建Talent节点
|
|
# 在Neo4j图数据库中创建Talent节点
|
|
try:
|
|
try:
|
|
from app.core.graph.graph_operations import create_or_get_node
|
|
from app.core.graph.graph_operations import create_or_get_node
|
|
- from datetime import datetime
|
|
|
|
|
|
|
|
# 创建Talent节点属性
|
|
# 创建Talent节点属性
|
|
talent_properties = {
|
|
talent_properties = {
|
|
@@ -917,7 +930,7 @@ def add_single_talent(talent_data):
|
|
image_path=image_path, # 从talent_data获取图片路径
|
|
image_path=image_path, # 从talent_data获取图片路径
|
|
career_path=initial_career_path,
|
|
career_path=initial_career_path,
|
|
brand_group=talent_data.get('brand_group', ''),
|
|
brand_group=talent_data.get('brand_group', ''),
|
|
- origin_source=json.dumps([talent_data.get('minio_path', '')], ensure_ascii=False) if talent_data.get('minio_path') else None,
|
|
|
|
|
|
+ origin_source=_update_origin_source_with_minio_path(None, minio_path, task_type) if minio_path else None,
|
|
talent_profile=talent_data.get('talent_profile', ''),
|
|
talent_profile=talent_data.get('talent_profile', ''),
|
|
status='active',
|
|
status='active',
|
|
updated_by='talent_system'
|
|
updated_by='talent_system'
|
|
@@ -931,7 +944,6 @@ def add_single_talent(talent_data):
|
|
# 在Neo4j图数据库中创建Talent节点
|
|
# 在Neo4j图数据库中创建Talent节点
|
|
try:
|
|
try:
|
|
from app.core.graph.graph_operations import create_or_get_node
|
|
from app.core.graph.graph_operations import create_or_get_node
|
|
- from datetime import datetime
|
|
|
|
|
|
|
|
# 创建Talent节点属性
|
|
# 创建Talent节点属性
|
|
talent_properties = {
|
|
talent_properties = {
|
|
@@ -1031,7 +1043,10 @@ def add_parsed_talents(api_response_data):
|
|
'data': None
|
|
'data': None
|
|
}
|
|
}
|
|
|
|
|
|
- logging.info(f"开始处理人才数据,共 {len(results)} 条记录")
|
|
|
|
|
|
+ # 从api_response_data中提取task_type
|
|
|
|
+ task_type = api_response_data.get('task_type', '')
|
|
|
|
+
|
|
|
|
+ logging.info(f"开始处理人才数据,共 {len(results)} 条记录,任务类型: {task_type}")
|
|
|
|
|
|
processed_results = []
|
|
processed_results = []
|
|
success_count = 0
|
|
success_count = 0
|
|
@@ -1069,13 +1084,21 @@ def add_parsed_talents(api_response_data):
|
|
logging.warning(f"第 {i+1} 条记录缺少data字段")
|
|
logging.warning(f"第 {i+1} 条记录缺少data字段")
|
|
continue
|
|
continue
|
|
|
|
|
|
- # 处理人才数据 - 新格式直接使用 item_data
|
|
|
|
|
|
+ # 从结果项中提取人才数据和图片保存地址
|
|
talent_data = item_data
|
|
talent_data = item_data
|
|
|
|
|
|
|
|
+ # 根据task_type决定如何提取minio_path
|
|
|
|
+ if task_type == "招聘":
|
|
|
|
+ # 如果task_type为"招聘",从result_item中提取id字段的值
|
|
|
|
+ minio_path = str(result_item.get('id', ''))
|
|
|
|
+ else:
|
|
|
|
+ # 其他情况,从result_item中提取minio_path字段
|
|
|
|
+ minio_path = result_item.get('minio_path', '')
|
|
|
|
+
|
|
# 处理单个人才数据
|
|
# 处理单个人才数据
|
|
if talent_data and isinstance(talent_data, dict):
|
|
if talent_data and isinstance(talent_data, dict):
|
|
try:
|
|
try:
|
|
- talent_result = add_single_talent(talent_data)
|
|
|
|
|
|
+ talent_result = add_single_talent(talent_data, minio_path, task_type)
|
|
if talent_result.get('success', False):
|
|
if talent_result.get('success', False):
|
|
success_count += 1
|
|
success_count += 1
|
|
processed_results.append({
|
|
processed_results.append({
|