Files
ALL-teach_sys/frontend_智能制造/scripts/update_all_positions.py
KQL cd2e307402 初始化12个产业教务系统项目
主要内容:
- 包含12个产业的完整教务系统前端代码
- 智能启动脚本 (start-industry.sh)
- 可视化产业导航页面 (index.html)
- 项目文档 (README.md)

优化内容:
- 删除所有node_modules和.yoyo文件夹,从7.5GB减少到2.7GB
- 添加.gitignore文件避免上传不必要的文件
- 自动依赖管理和智能启动系统

产业列表:
1. 文旅产业 (5150)
2. 智能制造 (5151)
3. 智能开发 (5152)
4. 财经商贸 (5153)
5. 视觉设计 (5154)
6. 交通物流 (5155)
7. 大健康 (5156)
8. 土木水利 (5157)
9. 食品产业 (5158)
10. 化工产业 (5159)
11. 能源产业 (5160)
12. 环保产业 (5161)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 14:14:14 +08:00

151 lines
6.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import re
import sys
def escape_for_js(text):
"""转义字符串用于JavaScript"""
if not text:
return ""
text = text.replace('\\', '\\\\')
text = text.replace('`', '\\`')
text = text.replace('${', '\\${')
return text
def parse_resume_content(resume_content):
"""解析简历内容,提取项目经历、专业技能和个人总结"""
# 项目经历
project_match = re.search(r'# 一、项目经历(.*?)(?=# 二、|$)', resume_content, re.DOTALL)
project_experience = ""
if project_match:
project_text = project_match.group(1).strip()
project_text = project_text.replace('### ', '')
project_text = project_text.replace('# ', '')
project_experience = project_text
# 专业技能
skills_match = re.search(r'# 二、[专业技能|掌握技能](.*?)(?=# 三、|$)', resume_content, re.DOTALL)
skills = ""
if skills_match:
skills_text = skills_match.group(1).strip()
skills_text = skills_text.replace('### ', '')
skills_text = skills_text.replace('# ', '')
skills = skills_text
# 个人总结
summary_match = re.search(r'# 三、[个人总结|个人评价](.*?)$', resume_content, re.DOTALL)
summary = ""
if summary_match:
summary_text = summary_match.group(1).strip()
summary = summary_text
return {
'projectExperience': project_experience,
'skills': skills,
'personalSummary': summary
}
def process_part(part_number):
"""处理指定部分的简历数据"""
# 读取对应部分的JSON文件
file_path = f'/Users/apple/Documents/cursor/教务系统/frontend/网页未导入数据/个人简历内容_part{part_number}.json'
print(f"\n处理第 {part_number} 部分...")
with open(file_path, 'r', encoding='utf-8') as f:
data = json.load(f)
# 创建岗位名称到简历内容的映射
position_map = {}
for item in data:
if '❌岗位名称查询' in item and '简历内容' in item:
position_name = item['❌岗位名称查询']
resume_data = parse_resume_content(item['简历内容'])
position_map[position_name] = resume_data
print(f" 处理岗位: {position_name}")
# 保存映射数据
output_file = f'/Users/apple/Documents/cursor/教务系统/frontend/scripts/resume_mapping_part{part_number}.json'
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(position_map, f, ensure_ascii=False, indent=2)
print(f"{part_number} 部分处理完成,共处理 {len(position_map)} 个岗位")
print(f"映射数据已保存到: {output_file}")
return position_map
def update_mockdata_with_mapping(position_map, part_number):
"""使用映射数据更新mockData.js"""
print(f"\n开始更新 mockData.js (第 {part_number} 部分)...")
# 读取当前的mockData.js文件
with open('/Users/apple/Documents/cursor/教务系统/frontend/src/data/mockData.js', 'r', encoding='utf-8') as f:
content = f.read()
updated_count = 0
# 对每个岗位进行更新
for position_name, resume_data in position_map.items():
# 查找该岗位在mockData.js中的位置
# 使用更灵活的模式匹配
pattern = rf'name:\s*["\']({re.escape(position_name)})["\']'
matches = list(re.finditer(pattern, content))
if matches:
for match in matches:
# 找到岗位后需要在其resume对象中添加新字段
start_pos = match.start()
# 查找该岗位的resume对象
resume_pattern = r'resume:\s*\{'
resume_match = re.search(resume_pattern, content[start_pos:start_pos+2000])
if resume_match:
resume_start = start_pos + resume_match.end()
# 查找resume对象的结束位置
brace_count = 1
i = resume_start
while i < len(content) and brace_count > 0:
if content[i] == '{':
brace_count += 1
elif content[i] == '}':
brace_count -= 1
i += 1
# 在resume对象末尾添加新字段在最后一个}之前)
insert_pos = i - 1
# 检查是否已经有这些字段
resume_section = content[resume_start:insert_pos]
if 'projectExperience' not in resume_section:
# 构建要插入的内容
new_fields = f''',
projectExperience: `{escape_for_js(resume_data['projectExperience'])}`,
skills: `{escape_for_js(resume_data['skills'])}`,
personalSummary: `{escape_for_js(resume_data['personalSummary'])}`'''
# 插入新字段
content = content[:insert_pos] + new_fields + content[insert_pos:]
updated_count += 1
print(f" ✓ 更新岗位: {position_name}")
# 写回文件
with open('/Users/apple/Documents/cursor/教务系统/frontend/src/data/mockData.js', 'w', encoding='utf-8') as f:
f.write(content)
print(f"{part_number} 部分更新完成,共更新 {updated_count} 个岗位")
return updated_count
# 主程序
if __name__ == "__main__":
if len(sys.argv) > 1:
# 处理指定部分
part_num = int(sys.argv[1])
position_map = process_part(part_num)
update_mockdata_with_mapping(position_map, part_num)
else:
print("请指定要处理的部分 (1, 2, 或 3)")
print("使用方法: python3 update_all_positions.py <部分编号>")
print("例如: python3 update_all_positions.py 1")