|
@@ -341,37 +341,36 @@ def add_business_card(card_data, image_file=None):
|
|
except (ValueError, TypeError):
|
|
except (ValueError, TypeError):
|
|
age_value = None
|
|
age_value = None
|
|
|
|
|
|
- business_card = BusinessCard(
|
|
|
|
- name_zh=card_data.get('name_zh', ''),
|
|
|
|
- name_en=card_data.get('name_en', ''),
|
|
|
|
- title_zh=card_data.get('title_zh', ''),
|
|
|
|
- title_en=card_data.get('title_en', ''),
|
|
|
|
- mobile=normalize_mobile_numbers(card_data.get('mobile', '')),
|
|
|
|
- phone=card_data.get('phone', ''),
|
|
|
|
- email=card_data.get('email', ''),
|
|
|
|
- hotel_zh=card_data.get('hotel_zh', ''),
|
|
|
|
- hotel_en=card_data.get('hotel_en', ''),
|
|
|
|
- address_zh=card_data.get('address_zh', ''),
|
|
|
|
- address_en=card_data.get('address_en', ''),
|
|
|
|
- postal_code_zh=card_data.get('postal_code_zh', ''),
|
|
|
|
- postal_code_en=card_data.get('postal_code_en', ''),
|
|
|
|
- brand_zh=card_data.get('brand_zh', ''),
|
|
|
|
- brand_en=card_data.get('brand_en', ''),
|
|
|
|
- affiliation_zh=card_data.get('affiliation_zh', ''),
|
|
|
|
- affiliation_en=card_data.get('affiliation_en', ''),
|
|
|
|
- birthday=datetime.strptime(card_data.get('birthday'), '%Y-%m-%d').date() if card_data.get('birthday') else None,
|
|
|
|
- age=age_value,
|
|
|
|
- native_place=card_data.get('native_place', ''),
|
|
|
|
- gender=card_data.get('gender', ''), # 新增性别字段
|
|
|
|
- residence=card_data.get('residence', ''),
|
|
|
|
- image_path=minio_path, # 最新的图片路径
|
|
|
|
- career_path=career_path, # 直接使用card_data中的career_path
|
|
|
|
- brand_group=card_data.get('brand_group', ''),
|
|
|
|
- origin_source=[create_origin_source_entry('business_card_creation', minio_path)], # 原始资料记录
|
|
|
|
- talent_profile=card_data.get('talent_profile', ''), # 人才档案
|
|
|
|
- status='active',
|
|
|
|
- updated_by='system'
|
|
|
|
- )
|
|
|
|
|
|
+ business_card = BusinessCard()
|
|
|
|
+ business_card.name_zh = card_data.get('name_zh', '')
|
|
|
|
+ business_card.name_en = card_data.get('name_en', '')
|
|
|
|
+ business_card.title_zh = card_data.get('title_zh', '')
|
|
|
|
+ business_card.title_en = card_data.get('title_en', '')
|
|
|
|
+ business_card.mobile = normalize_mobile_numbers(card_data.get('mobile', ''))
|
|
|
|
+ business_card.phone = card_data.get('phone', '')
|
|
|
|
+ business_card.email = card_data.get('email', '')
|
|
|
|
+ business_card.hotel_zh = card_data.get('hotel_zh', '')
|
|
|
|
+ business_card.hotel_en = card_data.get('hotel_en', '')
|
|
|
|
+ business_card.address_zh = card_data.get('address_zh', '')
|
|
|
|
+ business_card.address_en = card_data.get('address_en', '')
|
|
|
|
+ business_card.postal_code_zh = card_data.get('postal_code_zh', '')
|
|
|
|
+ business_card.postal_code_en = card_data.get('postal_code_en', '')
|
|
|
|
+ business_card.brand_zh = card_data.get('brand_zh', '')
|
|
|
|
+ business_card.brand_en = card_data.get('brand_en', '')
|
|
|
|
+ business_card.affiliation_zh = card_data.get('affiliation_zh', '')
|
|
|
|
+ business_card.affiliation_en = card_data.get('affiliation_en', '')
|
|
|
|
+ business_card.birthday = datetime.strptime(card_data.get('birthday'), '%Y-%m-%d').date() if card_data.get('birthday') else None
|
|
|
|
+ business_card.age = age_value
|
|
|
|
+ business_card.native_place = card_data.get('native_place', '')
|
|
|
|
+ business_card.gender = card_data.get('gender', '')
|
|
|
|
+ business_card.residence = card_data.get('residence', '')
|
|
|
|
+ business_card.image_path = minio_path
|
|
|
|
+ business_card.career_path = career_path
|
|
|
|
+ business_card.brand_group = card_data.get('brand_group', '')
|
|
|
|
+ business_card.origin_source = [create_origin_source_entry('business_card_creation', minio_path)]
|
|
|
|
+ business_card.talent_profile = card_data.get('talent_profile', '')
|
|
|
|
+ business_card.status = 'active'
|
|
|
|
+ business_card.updated_by = 'system'
|
|
|
|
|
|
db.session.add(business_card)
|
|
db.session.add(business_card)
|
|
db.session.commit()
|
|
db.session.commit()
|
|
@@ -1049,6 +1048,8 @@ def parse_business_card_with_qwen(image_data):
|
|
|
|
|
|
# 尝试从响应中提取 JSON
|
|
# 尝试从响应中提取 JSON
|
|
try:
|
|
try:
|
|
|
|
+ if response_content is None:
|
|
|
|
+ raise Exception("Qwen API 返回的内容为空")
|
|
extracted_data = json.loads(response_content)
|
|
extracted_data = json.loads(response_content)
|
|
logging.info("成功解析 Qwen 响应中的 JSON")
|
|
logging.info("成功解析 Qwen 响应中的 JSON")
|
|
except json.JSONDecodeError:
|
|
except json.JSONDecodeError:
|