主要内容: - 包含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>
123 lines
4.2 KiB
Python
123 lines
4.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
替换目标岗位优先级板块的数据
|
|
根据能源岗位简历.json中的批次信息分组岗位
|
|
"""
|
|
|
|
import json
|
|
import re
|
|
from datetime import datetime
|
|
|
|
def extract_positions_by_batch(energy_data):
|
|
"""从能源数据中提取并按批次分组岗位"""
|
|
batch1 = []
|
|
batch2 = []
|
|
batch3 = []
|
|
|
|
for item in energy_data:
|
|
position_name = item["岗位名称"]
|
|
batch = item.get("批次", "")
|
|
|
|
if "第一批次" in batch:
|
|
batch1.append(position_name)
|
|
elif "第二批次" in batch:
|
|
batch2.append(position_name)
|
|
elif "第三批次" in batch:
|
|
batch3.append(position_name)
|
|
|
|
return batch1, batch2, batch3
|
|
|
|
def update_target_position_file(batch1, batch2, batch3):
|
|
"""更新TargetPosition组件文件中的岗位数据"""
|
|
file_path = 'src/pages/JobStrategyDetailPage/components/TargetPosition/index.jsx'
|
|
|
|
# 创建备份
|
|
backup_path = f'{file_path}.backup_{datetime.now().strftime("%Y%m%d_%H%M%S")}'
|
|
|
|
print(f"读取文件: {file_path}")
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
print(f"备份原文件到: {backup_path}")
|
|
with open(backup_path, 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
|
|
# 构建新的批次数据字符串
|
|
batch1_str = ',\n '.join([f'"{pos}"' for pos in batch1])
|
|
batch2_str = ',\n '.join([f'"{pos}"' for pos in batch2])
|
|
batch3_str = ',\n '.join([f'"{pos}"' for pos in batch3])
|
|
|
|
new_batch_data = f''' // 定义三个批次的岗位数据
|
|
const initialBatchPositions = {{
|
|
batch1: [
|
|
{batch1_str}
|
|
],
|
|
batch2: [
|
|
{batch2_str}
|
|
],
|
|
batch3: [
|
|
{batch3_str}
|
|
]
|
|
}};'''
|
|
|
|
# 使用正则表达式替换
|
|
pattern = r' // 定义三个批次的岗位数据\n const initialBatchPositions = \{[\s\S]*?\n \};'
|
|
|
|
if re.search(pattern, content):
|
|
new_content = re.sub(pattern, new_batch_data, content)
|
|
print("✅ 成功匹配并替换岗位数据")
|
|
else:
|
|
print("⚠️ 未找到匹配的数据结构,尝试其他模式...")
|
|
# 尝试另一种模式
|
|
pattern2 = r'const initialBatchPositions = \{[\s\S]*?\};'
|
|
if re.search(pattern2, content):
|
|
new_content = re.sub(pattern2,
|
|
f'const initialBatchPositions = {{\n batch1: [\n {batch1_str}\n ],\n batch2: [\n {batch2_str}\n ],\n batch3: [\n {batch3_str}\n ]\n }}',
|
|
content)
|
|
print("✅ 使用备选模式成功替换")
|
|
else:
|
|
print("❌ 无法找到要替换的数据结构")
|
|
return False
|
|
|
|
# 写回文件
|
|
print(f"写入更新后的内容到: {file_path}")
|
|
with open(file_path, 'w', encoding='utf-8') as f:
|
|
f.write(new_content)
|
|
|
|
return True
|
|
|
|
def main():
|
|
# 读取能源岗位数据
|
|
energy_data_path = '网页未导入数据/能源产业/能源岗位简历.json'
|
|
|
|
print(f"读取能源岗位数据: {energy_data_path}")
|
|
with open(energy_data_path, 'r', encoding='utf-8') as f:
|
|
energy_data = json.load(f)
|
|
|
|
print(f"共读取到 {len(energy_data)} 个岗位")
|
|
|
|
# 提取并分组岗位
|
|
batch1, batch2, batch3 = extract_positions_by_batch(energy_data)
|
|
|
|
print(f"\n岗位分组结果:")
|
|
print(f" 第一批次: {len(batch1)} 个岗位")
|
|
print(f" 第二批次: {len(batch2)} 个岗位")
|
|
print(f" 第三批次: {len(batch3)} 个岗位")
|
|
|
|
# 显示每批次前3个岗位
|
|
print(f"\n第一批次示例: {batch1[:3] if batch1 else '无'}")
|
|
print(f"第二批次示例: {batch2[:3] if batch2 else '无'}")
|
|
print(f"第三批次示例: {batch3[:3] if batch3 else '无'}")
|
|
|
|
# 更新组件文件
|
|
if update_target_position_file(batch1, batch2, batch3):
|
|
print("\n✅ 目标岗位优先级数据替换完成!")
|
|
print(f" - 第一批次: {len(batch1)} 个岗位")
|
|
print(f" - 第二批次: {len(batch2)} 个岗位")
|
|
print(f" - 第三批次: {len(batch3)} 个岗位")
|
|
else:
|
|
print("\n❌ 替换失败,请检查文件格式")
|
|
|
|
if __name__ == "__main__":
|
|
main() |