Files
ALL-teach_sys/frontend_环保/update_job_levels_v2.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

200 lines
7.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 os
import re
from datetime import datetime
# 读取岗位等级数据
def load_job_levels():
with open('网页未导入数据/文旅产业/岗位等级.json', 'r', encoding='utf-8') as f:
data = json.load(f)
# 创建岗位名称到等级的映射
job_levels_map = {}
for item in data:
job_name = item['❌岗位名称']
level = item['前端查询名称']
job_levels_map[job_name] = level
return job_levels_map
# 更新resumeInterviewMock.js文件 - 添加level字段
def update_resume_interview_mock(job_levels_map):
file_path = 'src/mocks/resumeInterviewMock.js'
# 备份文件
backup_path = f'{file_path}.backup_{datetime.now().strftime("%Y%m%d_%H%M%S")}_levels'
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
with open(backup_path, 'w', encoding='utf-8') as f:
f.write(content)
print(f"已备份: {backup_path}")
# 更新内容
updated_count = 0
lines = content.split('\n')
new_lines = []
i = 0
while i < len(lines):
line = lines[i]
new_lines.append(line)
# 查找title字段
if 'title:' in line and 'positions' not in line:
# 提取岗位名称
match = re.search(r'title:\s*["\']([^"\']+)["\']', line)
if match:
position_name = match.group(1)
if position_name in job_levels_map:
level = job_levels_map[position_name]
# 检查下一行是否已经有level字段
has_level = False
for j in range(i+1, min(i+5, len(lines))):
if 'level:' in lines[j]:
has_level = True
# 更新现有的level字段
lines[j] = re.sub(
r'level:\s*["\'][^"\']*["\']',
f'level: "{level}"',
lines[j]
)
updated_count += 1
print(f"更新: {position_name} -> {level}")
break
# 如果没有level字段添加一个
if not has_level:
# 在title后面添加level字段
indent = len(line) - len(line.lstrip())
new_level_line = ' ' * indent + f'level: "{level}",'
# 找到合适的位置插入在title之后
new_lines.append(new_level_line)
updated_count += 1
print(f"添加: {position_name} -> {level}")
i += 1
# 写回文件
with open(file_path, 'w', encoding='utf-8') as f:
f.write('\n'.join(new_lines))
print(f"resumeInterviewMock.js 更新完成,共更新 {updated_count}")
# 更新companyJobsNew.json文件
def update_company_jobs(job_levels_map):
file_path = 'src/data/companyJobsNew.json'
# 备份文件
backup_path = f'{file_path}.backup_{datetime.now().strftime("%Y%m%d_%H%M%S")}_levels'
with open(file_path, 'r', encoding='utf-8') as f:
data = json.load(f)
with open(backup_path, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
print(f"已备份: {backup_path}")
# 更新数据
updated_count = 0
added_count = 0
for company in data:
if 'jobs' in company:
for job in company['jobs']:
position_name = job.get('positionName', '')
if position_name in job_levels_map:
new_level = job_levels_map[position_name]
if 'jobLevel' in job:
old_level = job['jobLevel']
if old_level != new_level:
job['jobLevel'] = new_level
updated_count += 1
print(f"更新: {position_name}: {old_level} -> {new_level}")
else:
job['jobLevel'] = new_level
added_count += 1
print(f"添加: {position_name} -> {new_level}")
# 写回文件
with open(file_path, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
print(f"companyJobsNew.json 更新完成,更新 {updated_count} 处,新增 {added_count}")
# 检查mockData.js中的项目库数据
def check_mock_data_projects(job_levels_map):
file_path = 'src/data/mockData.js'
print("检查mockData.js中的项目库数据...")
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# 查找所有引用的岗位
found_positions = set()
# 查找relatedPositions和targetPositions中的岗位
pattern = r'["\']([^"\']+)["\']'
# 查找包含positions的行
lines = content.split('\n')
for i, line in enumerate(lines):
if 'relatedPositions:' in line or 'targetPositions:' in line:
# 查找数组内容
j = i
bracket_count = 0
in_array = False
while j < len(lines):
if '[' in lines[j]:
in_array = True
bracket_count += lines[j].count('[')
if in_array:
matches = re.findall(pattern, lines[j])
for match in matches:
if match in job_levels_map:
found_positions.add(match)
bracket_count -= lines[j].count(']')
if in_array and bracket_count <= 0:
break
j += 1
print(f"在项目库中找到 {len(found_positions)} 个不同的岗位引用:")
for pos in sorted(found_positions):
print(f" - {pos}: {job_levels_map[pos]}")
# 主函数
def main():
print("=" * 50)
print("开始更新岗位等级数据 V2")
print("=" * 50)
# 加载岗位等级映射
job_levels_map = load_job_levels()
print(f"已加载 {len(job_levels_map)} 个岗位等级映射")
# 显示等级分布
level_counts = {}
for level in job_levels_map.values():
level_counts[level] = level_counts.get(level, 0) + 1
print("\n岗位等级分布:")
for level, count in level_counts.items():
print(f" {level}: {count} 个岗位")
print("\n" + "=" * 50)
# 更新各个文件
print("\n1. 更新简历面试题数据...")
update_resume_interview_mock(job_levels_map)
print("\n2. 更新公司岗位数据...")
update_company_jobs(job_levels_map)
print("\n3. 检查项目库数据...")
check_mock_data_projects(job_levels_map)
print("\n" + "=" * 50)
print("所有更新完成!")
print("=" * 50)
if __name__ == "__main__":
main()