Files
ALL-teach_sys/frontend_能源/fix_position_levels_final.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

87 lines
3.4 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
def fix_position_levels_final():
"""
最终修复项目详情数据中的岗位等级标签
"""
# 读取能源岗位简历数据,建立岗位名称到等级的映射
with open("网页未导入数据/能源产业/能源岗位简历.json", 'r', encoding='utf-8') as f:
resume_data = json.load(f)
# 建立岗位名称到等级的映射字典
position_level_mapping = {}
for item in resume_data:
position_name = item.get("岗位名称", "")
position_level = item.get("岗位等级标签", "技术骨干岗")
if position_name:
position_level_mapping[position_name] = position_level
print("🔍 岗位等级映射表构建完成")
print(f" 技术骨干岗: {len([p for p, l in position_level_mapping.items() if l == '技术骨干岗'])}")
print(f" 储备干部岗: {len([p for p, l in position_level_mapping.items() if l == '储备干部岗'])}")
print(f" 普通岗: {len([p for p, l in position_level_mapping.items() if l == '普通岗'])}")
# 读取当前的Mock数据
with open("src/mocks/projectLibraryMock.js", 'r', encoding='utf-8') as f:
content = f.read()
# 定义替换函数,支持多行匹配
def replace_level(match):
spaces1 = match.group(1)
current_level = match.group(2)
spaces2 = match.group(3)
position_name = match.group(4)
spaces3 = match.group(5)
# 查找正确的等级
correct_level = position_level_mapping.get(position_name, current_level)
# 如果等级不同,则替换
if correct_level != current_level:
print(f" 📝 更新 {position_name}: {current_level}{correct_level}")
return f'{spaces1}"level": "{correct_level}",{spaces2}"position": "{position_name}"{spaces3}'
# 使用正则表达式替换所有的level字段支持多行和空格
pattern = r'(\s*)"level":\s*"([^"]*)",(\s*)"position":\s*"([^"]*)"\s*(\s*)'
updated_content = re.sub(pattern, replace_level, content)
# 写入更新后的内容
with open("src/mocks/projectLibraryMock.js", 'w', encoding='utf-8') as f:
f.write(updated_content)
# 统计修复结果
updated_matches = re.findall(r'"level":\s*"([^"]*)".*?"position":\s*"([^"]*)"', updated_content)
level_stats = {}
change_count = 0
for level, position in updated_matches:
if level not in level_stats:
level_stats[level] = []
level_stats[level].append(position)
# 检查是否有变化
original_level = "技术骨干岗" # 原来都是这个等级
correct_level = position_level_mapping.get(position, "技术骨干岗")
if original_level != correct_level:
change_count += 1
print(f"\n✅ 修复完成!共检查 {len(updated_matches)} 个岗位,其中 {change_count} 个等级标签需要更新")
print("\n更新后的等级标签统计:")
for level in ["技术骨干岗", "储备干部岗", "普通岗"]:
if level in level_stats:
positions = level_stats[level]
print(f" {level}: {len(positions)}个岗位")
for pos in positions[:3]:
print(f" - {pos}")
if len(positions) > 3:
print(f" ... 还有{len(positions)-3}个岗位")
print()
if __name__ == "__main__":
fix_position_levels_final()