250 lines
8.1 KiB
Python
250 lines
8.1 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
# -*- coding: utf-8 -*-
|
||
|
|
|
||
|
|
import json
|
||
|
|
import re
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
def load_visual_design_data():
|
||
|
|
"""加载视觉设计岗位简历数据"""
|
||
|
|
with open('网页未导入数据/视觉设计产业/视觉设计岗位简历.json', 'r', encoding='utf-8') as f:
|
||
|
|
return json.load(f)
|
||
|
|
|
||
|
|
def create_position_groups(visual_data):
|
||
|
|
"""根据岗位群对数据进行分组"""
|
||
|
|
groups = {}
|
||
|
|
|
||
|
|
for position in visual_data:
|
||
|
|
group_name = position['简历岗位群']
|
||
|
|
if group_name not in groups:
|
||
|
|
groups[group_name] = []
|
||
|
|
groups[group_name].append(position)
|
||
|
|
|
||
|
|
return groups
|
||
|
|
|
||
|
|
def convert_to_industries_format(position_groups):
|
||
|
|
"""转换为industries格式"""
|
||
|
|
industries = []
|
||
|
|
|
||
|
|
for group_id, (group_name, positions) in enumerate(position_groups.items()):
|
||
|
|
industry = {
|
||
|
|
"id": f"visual_design_{group_id + 1}",
|
||
|
|
"name": group_name,
|
||
|
|
"positions": [],
|
||
|
|
"questions": [{
|
||
|
|
"id": f"group_q{group_id + 1}",
|
||
|
|
"question": f"# 一、专业能力与行业认知",
|
||
|
|
"subQuestions": [{
|
||
|
|
"id": f"q{group_id + 1}_1",
|
||
|
|
"question": f"{group_name}类岗位的核心职责是什么?",
|
||
|
|
"answer": f"负责{group_name}相关工作,包括设计规划、创意实现、项目协作等。"
|
||
|
|
}]
|
||
|
|
}]
|
||
|
|
}
|
||
|
|
|
||
|
|
for pos_id, position in enumerate(positions):
|
||
|
|
# 确定岗位等级
|
||
|
|
level = position.get('岗位等级标签', '普通岗')
|
||
|
|
|
||
|
|
# 创建岗位对象
|
||
|
|
pos_obj = {
|
||
|
|
"id": f"visual_design_{group_id + 1}_{pos_id + 1}",
|
||
|
|
"title": position['岗位名称'],
|
||
|
|
"level": level,
|
||
|
|
"avatar": position.get('简历头像url', ''),
|
||
|
|
"department": group_name,
|
||
|
|
"type": "全职",
|
||
|
|
"experience": "1-3年",
|
||
|
|
"education": "大专",
|
||
|
|
"salary": "6-12K",
|
||
|
|
"location": "苏州",
|
||
|
|
"updateTime": "2024-01-20",
|
||
|
|
"description": f"负责{position['岗位名称']}相关工作",
|
||
|
|
"requirements": [
|
||
|
|
f"具备{group_name}专业技能",
|
||
|
|
"熟悉相关设计软件",
|
||
|
|
"具备良好的沟通协作能力",
|
||
|
|
"有创新意识和学习能力"
|
||
|
|
]
|
||
|
|
}
|
||
|
|
|
||
|
|
industry["positions"].append(pos_obj)
|
||
|
|
|
||
|
|
industries.append(industry)
|
||
|
|
|
||
|
|
return industries
|
||
|
|
|
||
|
|
def create_resume_templates(visual_data):
|
||
|
|
"""创建简历模板数据"""
|
||
|
|
templates = {}
|
||
|
|
|
||
|
|
# 按岗位群分组
|
||
|
|
groups = create_position_groups(visual_data)
|
||
|
|
|
||
|
|
for group_name, positions in groups.items():
|
||
|
|
templates[group_name] = []
|
||
|
|
|
||
|
|
for position in positions:
|
||
|
|
template = {
|
||
|
|
"id": f"resume_{len(templates[group_name]) + 1}",
|
||
|
|
"position": position['岗位名称'],
|
||
|
|
"level": position.get('岗位等级标签', '普通岗'),
|
||
|
|
"industry": group_name,
|
||
|
|
"studentInfo": {
|
||
|
|
"name": "张小同",
|
||
|
|
"gender": "女",
|
||
|
|
"age": 22,
|
||
|
|
"education": "大专",
|
||
|
|
"major": "数字媒体艺术设计",
|
||
|
|
"avatar": position.get('简历头像url', '')
|
||
|
|
},
|
||
|
|
"content": {
|
||
|
|
"original": position.get('简历内容', ''),
|
||
|
|
"modified": position.get('简历内容', '')
|
||
|
|
},
|
||
|
|
"interviewQuestions": position.get('面试题内容', '')
|
||
|
|
}
|
||
|
|
|
||
|
|
templates[group_name].append(template)
|
||
|
|
|
||
|
|
return templates
|
||
|
|
|
||
|
|
def create_joblevel_data(visual_data):
|
||
|
|
"""创建joblevel.json数据"""
|
||
|
|
job_levels = {
|
||
|
|
"储备干部岗": [],
|
||
|
|
"技术骨干岗": [],
|
||
|
|
"普通岗": []
|
||
|
|
}
|
||
|
|
|
||
|
|
# 映射岗位等级
|
||
|
|
level_mapping = {
|
||
|
|
"储备干部岗": "high",
|
||
|
|
"技术骨干岗": "middle",
|
||
|
|
"普通岗": "ordinary"
|
||
|
|
}
|
||
|
|
|
||
|
|
for i, position in enumerate(visual_data):
|
||
|
|
level_name = position.get('岗位等级标签', '普通岗')
|
||
|
|
|
||
|
|
job_data = {
|
||
|
|
"record_id": f"visual_design_{i + 1}",
|
||
|
|
"position_name": position['岗位名称'],
|
||
|
|
"img": position.get('简历头像url', '')
|
||
|
|
}
|
||
|
|
|
||
|
|
if level_name in job_levels:
|
||
|
|
job_levels[level_name].append(job_data)
|
||
|
|
|
||
|
|
# 构建最终数据结构
|
||
|
|
result = {
|
||
|
|
"code": 200,
|
||
|
|
"message": "操作成功",
|
||
|
|
"data": {}
|
||
|
|
}
|
||
|
|
|
||
|
|
for level_name, positions in job_levels.items():
|
||
|
|
level_key = level_mapping.get(level_name, "ordinary")
|
||
|
|
result["data"][level_key] = {
|
||
|
|
"name": level_name,
|
||
|
|
"list": positions
|
||
|
|
}
|
||
|
|
|
||
|
|
return result
|
||
|
|
|
||
|
|
def update_resume_interview_mock(industries, resume_templates):
|
||
|
|
"""更新resumeInterviewMock.js文件"""
|
||
|
|
|
||
|
|
# 创建完整的mock数据结构
|
||
|
|
mock_data = {
|
||
|
|
"industries": industries,
|
||
|
|
"resumeTemplates": resume_templates,
|
||
|
|
"myResume": {
|
||
|
|
"name": "张小同",
|
||
|
|
"studentId": "2024001",
|
||
|
|
"major": "数字媒体艺术设计",
|
||
|
|
"education": "大专",
|
||
|
|
"avatar": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/butler_position_avatar/default_student.jpeg"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# 读取原文件
|
||
|
|
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||
|
|
content = f.read()
|
||
|
|
|
||
|
|
# 生成新的数据内容
|
||
|
|
js_content = f"""// 简历与面试题Mock数据
|
||
|
|
|
||
|
|
// 岗位群列表
|
||
|
|
const industries = {json.dumps(industries, ensure_ascii=False, indent=2)};
|
||
|
|
|
||
|
|
// 简历模板数据
|
||
|
|
const resumeTemplates = {json.dumps(resume_templates, ensure_ascii=False, indent=2)};
|
||
|
|
|
||
|
|
// 我的简历数据
|
||
|
|
const myResume = {json.dumps(mock_data['myResume'], ensure_ascii=False, indent=2)};
|
||
|
|
|
||
|
|
// 获取页面数据
|
||
|
|
export const getMockPageData = () => {{
|
||
|
|
return {{
|
||
|
|
industries,
|
||
|
|
resumeTemplates,
|
||
|
|
myResume
|
||
|
|
}};
|
||
|
|
}};
|
||
|
|
|
||
|
|
// 导出各个数据模块
|
||
|
|
export {{ industries, resumeTemplates, myResume }};
|
||
|
|
"""
|
||
|
|
|
||
|
|
# 写入文件
|
||
|
|
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||
|
|
f.write(js_content)
|
||
|
|
|
||
|
|
print("✅ 已更新 resumeInterviewMock.js")
|
||
|
|
|
||
|
|
def update_joblevel_json(joblevel_data):
|
||
|
|
"""更新joblevel.json文件"""
|
||
|
|
with open('src/data/joblevel.json', 'w', encoding='utf-8') as f:
|
||
|
|
json.dump(joblevel_data, f, ensure_ascii=False, indent=4)
|
||
|
|
|
||
|
|
print("✅ 已更新 joblevel.json")
|
||
|
|
|
||
|
|
def main():
|
||
|
|
print("🚀 开始更新视觉设计产业数据...")
|
||
|
|
|
||
|
|
# 1. 加载视觉设计数据
|
||
|
|
print("📖 加载视觉设计岗位数据...")
|
||
|
|
visual_data = load_visual_design_data()
|
||
|
|
print(f" 共加载 {len(visual_data)} 个岗位")
|
||
|
|
|
||
|
|
# 2. 创建岗位群分组
|
||
|
|
print("📝 创建岗位群分组...")
|
||
|
|
position_groups = create_position_groups(visual_data)
|
||
|
|
print(f" 共分为 {len(position_groups)} 个岗位群")
|
||
|
|
for group_name, positions in position_groups.items():
|
||
|
|
print(f" - {group_name}: {len(positions)} 个岗位")
|
||
|
|
|
||
|
|
# 3. 转换为industries格式
|
||
|
|
print("🔄 转换数据格式...")
|
||
|
|
industries = convert_to_industries_format(position_groups)
|
||
|
|
|
||
|
|
# 4. 创建简历模板数据
|
||
|
|
resume_templates = create_resume_templates(visual_data)
|
||
|
|
|
||
|
|
# 5. 创建joblevel数据
|
||
|
|
joblevel_data = create_joblevel_data(visual_data)
|
||
|
|
|
||
|
|
# 6. 更新文件
|
||
|
|
print("💾 更新文件...")
|
||
|
|
update_resume_interview_mock(industries, resume_templates)
|
||
|
|
update_joblevel_json(joblevel_data)
|
||
|
|
|
||
|
|
print("🎉 数据更新完成!")
|
||
|
|
print("\n📊 更新统计:")
|
||
|
|
print(f" - 产业数量: {len(industries)}")
|
||
|
|
print(f" - 岗位总数: {sum(len(industry['positions']) for industry in industries)}")
|
||
|
|
print(f" - 简历模板: {sum(len(templates) for templates in resume_templates.values())}")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|