82 lines
2.6 KiB
Python
82 lines
2.6 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
# -*- coding: utf-8 -*-
|
||
|
|
|
||
|
|
import json
|
||
|
|
from collections import defaultdict
|
||
|
|
|
||
|
|
def extract_job_groups():
|
||
|
|
"""
|
||
|
|
从能源岗位简历.json提取所有岗位群并生成面试题数据结构
|
||
|
|
"""
|
||
|
|
# 读取能源岗位简历数据
|
||
|
|
with open("网页未导入数据/能源产业/能源岗位简历.json", 'r', encoding='utf-8') as f:
|
||
|
|
energy_jobs = json.load(f)
|
||
|
|
|
||
|
|
# 按岗位群分组
|
||
|
|
job_groups = defaultdict(list)
|
||
|
|
for job in energy_jobs:
|
||
|
|
group_name = job.get("简历岗位群", "")
|
||
|
|
if group_name:
|
||
|
|
job_groups[group_name].append(job)
|
||
|
|
|
||
|
|
# 生成industries数据结构
|
||
|
|
industries = []
|
||
|
|
group_id = 1
|
||
|
|
|
||
|
|
for group_name, jobs in job_groups.items():
|
||
|
|
industry = {
|
||
|
|
"id": f"energy_{group_id}",
|
||
|
|
"name": group_name,
|
||
|
|
"positions": [],
|
||
|
|
"questions": [
|
||
|
|
{
|
||
|
|
"id": f"group_q{group_id}",
|
||
|
|
"question": f"# {group_name}面试题",
|
||
|
|
"subQuestions": []
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
|
||
|
|
# 添加该岗位群下的所有岗位
|
||
|
|
pos_id = 1
|
||
|
|
for job in jobs:
|
||
|
|
position = {
|
||
|
|
"id": f"energy_{group_id}_{pos_id}",
|
||
|
|
"title": job["岗位名称"],
|
||
|
|
"level": job.get("岗位等级标签", "基础岗"),
|
||
|
|
"avatar": job.get("岗位头像", ""),
|
||
|
|
"department": group_name,
|
||
|
|
"type": "全职",
|
||
|
|
"experience": "1-3年",
|
||
|
|
"education": "大专",
|
||
|
|
"salary": "8-15K",
|
||
|
|
"location": "北京",
|
||
|
|
"updateTime": "2024-01-20",
|
||
|
|
"description": f"负责{job['岗位名称']}相关工作",
|
||
|
|
"requirements": []
|
||
|
|
}
|
||
|
|
industry["positions"].append(position)
|
||
|
|
pos_id += 1
|
||
|
|
|
||
|
|
industries.append(industry)
|
||
|
|
group_id += 1
|
||
|
|
|
||
|
|
# 输出统计信息
|
||
|
|
print(f"✅ 找到 {len(job_groups)} 个岗位群")
|
||
|
|
print("📋 岗位群列表:")
|
||
|
|
for i, (group_name, jobs) in enumerate(job_groups.items(), 1):
|
||
|
|
print(f" {i}. {group_name} ({len(jobs)}个岗位)")
|
||
|
|
|
||
|
|
# 保存到文件
|
||
|
|
with open("energy_industries_data.js", 'w', encoding='utf-8') as f:
|
||
|
|
f.write("// 能源产业岗位群数据\n")
|
||
|
|
f.write("const industries = ")
|
||
|
|
f.write(json.dumps(industries, ensure_ascii=False, indent=2))
|
||
|
|
f.write(";\n\nexport default industries;")
|
||
|
|
|
||
|
|
print(f"\n✅ 数据已保存到 energy_industries_data.js")
|
||
|
|
|
||
|
|
return industries
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
extract_job_groups()
|