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

120 lines
4.7 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
def get_position_levels_from_resume():
"""从化工岗位简历.json获取岗位等级映射"""
with open('网页未导入数据/化工产业/化工岗位简历.json', 'r', encoding='utf-8') as f:
data = json.load(f)
position_levels = {}
for item in data:
position = item.get('岗位名称', '').strip()
level = item.get('岗位等级标签', '').strip()
if position and level:
position_levels[position] = level
return position_levels
def fix_position_levels():
"""修正项目详情中的岗位等级"""
# 获取正确的岗位等级映射
resume_levels = get_position_levels_from_resume()
# 需要修正的岗位等级映射
fixes_needed = {
'精细化工操作技术员': '普通岗',
'产品工艺工程师助理': '储备干部岗',
'化工制程工程师': '技术骨干岗',
'日化调香师': '技术骨干岗',
'实验室主任助理': '储备干部岗',
'化妆品研发助理': '技术骨干岗',
'自动化设备维护技术员': '普通岗'
}
# 对于在简历中找不到的岗位,根据命名规则设置合理的等级
not_found_positions = {
'药物合成工程师': '技术骨干岗',
'化工设备机械工程师': '技术骨干岗',
'安全工程师': '技术骨干岗',
'化工工艺安全工程师': '技术骨干岗', # 原来是管理岗,改为技术骨干岗
'农药配方工程师': '技术骨干岗',
'农药剂型研发工程师': '技术骨干岗',
'农药研发工程师': '技术骨干岗', # 原来是管理岗,改为技术骨干岗
'高级染料工程师': '技术骨干岗', # 原来是管理岗,改为技术骨干岗
'安全管理经理': '技术骨干岗', # 原来是管理岗,改为技术骨干岗
'质量保证经理QA': '技术骨干岗', # 原来是管理岗,改为技术骨干岗
'质量体系工程师': '技术骨干岗',
'化工仪器仪表维护技术员': '普通岗',
'EHS工程师': '技术骨干岗',
'化工DCS工程师': '技术骨干岗',
'DCS维护工程师': '技术骨干岗',
'污水处理工程师': '技术骨干岗',
'PLC编程工程师': '技术骨干岗'
}
# 合并所有需要修正的岗位
all_fixes = {**fixes_needed, **not_found_positions}
# 读取mock文件
with open('src/mocks/projectLibraryMock.js', 'r', encoding='utf-8') as f:
lines = f.readlines()
# 修正岗位等级
new_lines = []
for i, line in enumerate(lines):
# 检查是否包含需要修正的岗位
modified = False
for position, correct_level in all_fixes.items():
# 查找岗位名称
if f'"position": "{position}"' in line:
# 检查前一行是否有level
if i > 0 and '"level":' in lines[i-1]:
# 修改前一行的level
prev_line = lines[i-1]
# 替换level值
new_prev_line = re.sub(
r'"level":\s*"[^"]*"',
f'"level": "{correct_level}"',
prev_line
)
if new_prev_line != prev_line:
# 如果前一行已经添加到new_lines需要替换它
if new_lines and new_lines[-1] == prev_line:
new_lines[-1] = new_prev_line
print(f"✅ 修正: {position}{correct_level}")
modified = True
if not modified:
new_lines.append(line)
else:
new_lines.append(line)
# 保存修正后的文件
with open('src/mocks/projectLibraryMock.js', 'w', encoding='utf-8') as f:
f.writelines(new_lines)
print("\n✅ 岗位等级修正完成!")
# 验证语法
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__":
# 备份原文件
import shutil
import datetime
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}")
# 执行修正
fix_position_levels()