Files
ALL-teach_sys/frontend_化工/update_project_positions_complete.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

137 lines
4.6 KiB
Python
Raw Permalink 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 datetime
import shutil
def get_correct_positions_from_json():
"""从化工项目案例.json获取每个项目的正确岗位列表"""
# 读取化工项目案例数据
with open('网页未导入数据/化工产业/化工项目案例.json', 'r', encoding='utf-8') as f:
data = json.load(f)
# 读取化工岗位简历数据获取等级映射
with open('网页未导入数据/化工产业/化工岗位简历.json', 'r', encoding='utf-8') as f:
resume_data = json.load(f)
position_levels = {}
for item in resume_data:
position = item.get('岗位名称', '').strip()
level = item.get('岗位等级标签', '').strip()
if position and level:
position_levels[position] = level
project_positions = {}
for i, project in enumerate(data, 1):
positions_str = project.get('适用岗位', '')
# 将岗位字符串分割成列表
if positions_str:
positions = [p.strip() for p in positions_str.replace('', ',').split(',') if p.strip()]
else:
positions = []
# 为每个岗位添加等级
positions_with_level = []
for pos in positions:
# 查找岗位等级
if pos in position_levels:
level = position_levels[pos]
else:
# 根据岗位名称推测等级
if '工程师' in pos:
level = '技术骨干岗'
elif '技术员' in pos or '操作员' in pos or '实验员' in pos or '化验员' in pos or '质检员' in pos:
level = '普通岗'
elif '助理' in pos or '储备' in pos:
level = '储备干部岗'
elif '调色师' in pos or '调香师' in pos:
level = '技术骨干岗'
else:
level = '技术骨干岗' # 默认
positions_with_level.append({
'position': pos,
'level': level
})
project_positions[i] = positions_with_level
return project_positions
def update_project_positions_in_mock():
"""更新mock文件中每个项目的岗位列表"""
# 获取正确的岗位数据
correct_positions = get_correct_positions_from_json()
# 读取mock文件
with open('src/mocks/projectLibraryMock.js', 'r', encoding='utf-8') as f:
content = f.read()
# 统计更新
updates_made = 0
# 逐个项目更新岗位列表
for project_id, positions in correct_positions.items():
print(f"\n更新项目 {project_id} 的岗位列表:")
# 构建新的positions数组
positions_array = []
for pos in positions:
positions_array.append(f''' {{
"level": "{pos['level']}",
"position": "{pos['position']}"
}}''')
new_positions_str = ',\n'.join(positions_array)
new_positions_block = f''' "positions": [
{new_positions_str}
]'''
# 使用正则表达式替换项目的positions数组
# 查找模式项目ID后的positions数组
pattern = rf'("id":\s*{project_id},.*?"name":[^,]+,\s*)"positions":\s*\[[^\]]*\]'
# 替换为新的positions数组
replacement = rf'\1{new_positions_block}'
new_content = re.sub(pattern, replacement, content, flags=re.DOTALL)
if new_content != content:
content = new_content
updates_made += 1
print(f" ✅ 已更新 {len(positions)} 个岗位")
for pos in positions:
print(f" - {pos['position']} [{pos['level']}]")
else:
print(f" ⚠️ 未能更新")
# 保存更新后的文件
with open('src/mocks/projectLibraryMock.js', 'w', encoding='utf-8') as f:
f.write(content)
print(f"\n{'=' * 60}")
print(f"✅ 共更新了 {updates_made} 个项目的岗位列表")
# 验证语法
import subprocess
result = subprocess.run(['node', '-c', 'src/mocks/projectLibraryMock.js'],
capture_output=True, text=True)
if result.returncode == 0:
print("✅ JavaScript语法检查通过")
else:
print(f"❌ JavaScript语法错误: {result.stderr}")
if __name__ == "__main__":
# 备份原文件
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
backup_file = f"src/mocks/projectLibraryMock.js.backup_{timestamp}"
shutil.copy('src/mocks/projectLibraryMock.js', backup_file)
print(f"✅ 已备份到: {backup_file}")
# 执行更新
update_project_positions_in_mock()