198 lines
7.0 KiB
Python
198 lines
7.0 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
|
|||
|
|
import json
|
|||
|
|
import re
|
|||
|
|
|
|||
|
|
print("合并面试题到单个卡片...")
|
|||
|
|
|
|||
|
|
# 读取大健康岗位简历数据
|
|||
|
|
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/网页未导入数据/大健康产业/大健康岗位简历.json', 'r', encoding='utf-8') as f:
|
|||
|
|
health_data = json.load(f)
|
|||
|
|
|
|||
|
|
# 备份当前文件
|
|||
|
|
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
|||
|
|
content = f.read()
|
|||
|
|
|
|||
|
|
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js.backup_before_merge', 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(content)
|
|||
|
|
|
|||
|
|
# 读取当前的mock数据
|
|||
|
|
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/health_mock_data_full.json', 'r', encoding='utf-8') as f:
|
|||
|
|
mock_data = json.load(f)
|
|||
|
|
|
|||
|
|
# 按岗位群分组,提取完整面试题
|
|||
|
|
position_groups = {}
|
|||
|
|
for item in health_data:
|
|||
|
|
group_name = item['简历岗位群']
|
|||
|
|
if group_name not in position_groups:
|
|||
|
|
position_groups[group_name] = {
|
|||
|
|
'positions': [],
|
|||
|
|
'questions_content': item.get('面试题内容', ''),
|
|||
|
|
'questions_title': item.get('面试题', '')
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 岗位群ID映射
|
|||
|
|
group_id_map = {
|
|||
|
|
'健康管理': 'health_management',
|
|||
|
|
'健康检查': 'health_check',
|
|||
|
|
'康复治疗': 'rehabilitation',
|
|||
|
|
'慢性病管理': 'chronic_disease',
|
|||
|
|
'轻医美': 'medical_beauty',
|
|||
|
|
'社群运营': 'community_operation',
|
|||
|
|
'心理健康': 'mental_health',
|
|||
|
|
'药品供应链管理': 'pharma_supply',
|
|||
|
|
'药品生产': 'pharma_production',
|
|||
|
|
'药品质量检测': 'pharma_quality',
|
|||
|
|
'药物研发': 'pharma_research'
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 解析面试题内容 - 将所有问题合并到一个卡片
|
|||
|
|
def parse_questions_single_card(content, group_id, group_name, questions_title):
|
|||
|
|
if not content:
|
|||
|
|
return [{
|
|||
|
|
'id': f"{group_id}_q1",
|
|||
|
|
'question': f"{group_name}岗位群面试题",
|
|||
|
|
'subQuestions': [
|
|||
|
|
{
|
|||
|
|
'id': 'q1',
|
|||
|
|
'question': f"您如何理解{group_name}工作的核心要点?",
|
|||
|
|
'answer': f"{group_name}工作需要专业知识、实践经验和良好的沟通能力。"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
'id': 'q2',
|
|||
|
|
'question': f"在{group_name}领域,您认为最重要的技能是什么?",
|
|||
|
|
'answer': f"最重要的是专业技术能力、团队协作能力和持续学习能力。"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
'id': 'q3',
|
|||
|
|
'question': f"您为什么选择{group_name}这个职业方向?",
|
|||
|
|
'answer': f"我对{group_name}领域充满热情,希望在这个领域深耕发展。"
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
}]
|
|||
|
|
|
|||
|
|
all_sub_questions = []
|
|||
|
|
q_counter = 1
|
|||
|
|
|
|||
|
|
# 提取所有大类问题
|
|||
|
|
sections = re.findall(r'#\s*([一二三四五六七八九十]+、[^\n]+)\n(.*?)(?=#\s*[一二三四五六七八九十]+、|$)', content, re.DOTALL)
|
|||
|
|
|
|||
|
|
for section_idx, (section_title, section_content) in enumerate(sections):
|
|||
|
|
# 先添加一个大类标题作为问题(不需要答案)
|
|||
|
|
all_sub_questions.append({
|
|||
|
|
'id': f'q{q_counter}',
|
|||
|
|
'question': section_title.strip(),
|
|||
|
|
'answer': '' # 大类标题没有答案
|
|||
|
|
})
|
|||
|
|
q_counter += 1
|
|||
|
|
|
|||
|
|
# 提取该大类下的具体问题和答案
|
|||
|
|
q_pattern = r'(\d+\.\s*[^\n]+)\n\s*示例答案[::]\s*\n(.*?)(?=\d+\.|#|$)'
|
|||
|
|
questions_match = re.findall(q_pattern, section_content, re.DOTALL)
|
|||
|
|
|
|||
|
|
for question_text, answer_text in questions_match:
|
|||
|
|
# 清理问题和答案文本
|
|||
|
|
question_clean = question_text.strip()
|
|||
|
|
answer_clean = answer_text.strip()
|
|||
|
|
|
|||
|
|
all_sub_questions.append({
|
|||
|
|
'id': f'q{q_counter}',
|
|||
|
|
'question': question_clean,
|
|||
|
|
'answer': answer_clean
|
|||
|
|
})
|
|||
|
|
q_counter += 1
|
|||
|
|
|
|||
|
|
# 创建单个面试题卡片,包含所有问题
|
|||
|
|
card_title = questions_title if questions_title else f"{group_name}岗位群面试题"
|
|||
|
|
|
|||
|
|
return [{
|
|||
|
|
'id': f"{group_id}_q1",
|
|||
|
|
'question': card_title,
|
|||
|
|
'subQuestions': all_sub_questions
|
|||
|
|
}]
|
|||
|
|
|
|||
|
|
# 更新industries中的questions - 每个岗位群只有一个面试题卡片
|
|||
|
|
for industry in mock_data['industries']:
|
|||
|
|
group_name = industry['name']
|
|||
|
|
if group_name in position_groups:
|
|||
|
|
questions_content = position_groups[group_name]['questions_content']
|
|||
|
|
questions_title = position_groups[group_name]['questions_title']
|
|||
|
|
|
|||
|
|
# 生成单个卡片包含所有面试题
|
|||
|
|
single_card_questions = parse_questions_single_card(
|
|||
|
|
questions_content,
|
|||
|
|
industry['id'],
|
|||
|
|
group_name,
|
|||
|
|
questions_title
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
industry['questions'] = single_card_questions
|
|||
|
|
|
|||
|
|
total_questions = len(single_card_questions[0]['subQuestions']) if single_card_questions else 0
|
|||
|
|
print(f"✓ {group_name}: 1个卡片,包含 {total_questions} 个问题")
|
|||
|
|
|
|||
|
|
# 将更新后的数据转换为JavaScript格式
|
|||
|
|
industries_js = json.dumps(mock_data['industries'], ensure_ascii=False, indent=2)
|
|||
|
|
resumeTemplates_js = json.dumps(mock_data['resumeTemplates'], ensure_ascii=False, indent=2)
|
|||
|
|
|
|||
|
|
# 创建新的Mock文件内容
|
|||
|
|
new_content = f"""// 简历与面试题Mock数据
|
|||
|
|
|
|||
|
|
// 岗位群列表
|
|||
|
|
const industries = {industries_js};
|
|||
|
|
|
|||
|
|
// 简历模板数据
|
|||
|
|
const resumeTemplates = {resumeTemplates_js};
|
|||
|
|
|
|||
|
|
// 我的简历数据
|
|||
|
|
const myResume = {{
|
|||
|
|
personalInfo: {{
|
|||
|
|
name: "张三",
|
|||
|
|
phone: "138****8888",
|
|||
|
|
email: "zhangsan@example.com",
|
|||
|
|
age: 25,
|
|||
|
|
education: "苏州信息职业技术学院 2020.9-2023.6",
|
|||
|
|
experience: "2年",
|
|||
|
|
location: "北京"
|
|||
|
|
}},
|
|||
|
|
workExperience: [
|
|||
|
|
{{
|
|||
|
|
company: "某健康管理公司",
|
|||
|
|
position: "健康管理师",
|
|||
|
|
duration: "2022.03-2024.01",
|
|||
|
|
description: "负责健康评估和健康管理方案制定工作"
|
|||
|
|
}}
|
|||
|
|
],
|
|||
|
|
skills: ["健康评估", "健康管理", "数据分析", "客户服务"],
|
|||
|
|
projects: [
|
|||
|
|
{{
|
|||
|
|
name: "企业员工健康管理项目",
|
|||
|
|
role: "健康管理师",
|
|||
|
|
duration: "2023.05-2023.12",
|
|||
|
|
description: "负责企业员工的健康评估和管理方案制定"
|
|||
|
|
}}
|
|||
|
|
]
|
|||
|
|
}};
|
|||
|
|
|
|||
|
|
// 获取页面mock数据的函数
|
|||
|
|
export function getMockPageData() {{
|
|||
|
|
return resumeInterviewMockData;
|
|||
|
|
}}
|
|||
|
|
|
|||
|
|
// 导出合并的数据
|
|||
|
|
export const resumeInterviewMockData = {{
|
|||
|
|
industries,
|
|||
|
|
resumeTemplates,
|
|||
|
|
myResume
|
|||
|
|
}};
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
# 写入新内容
|
|||
|
|
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(new_content)
|
|||
|
|
|
|||
|
|
print("\n✓ 面试题合并完成!")
|
|||
|
|
print(" - 每个岗位群现在只有一个面试题卡片")
|
|||
|
|
print(" - 所有面试题内容都在这一个卡片中")
|
|||
|
|
print(" - 原文件已备份为 resumeInterviewMock.js.backup_before_merge")
|