更新12个教务系统并优化项目大小
主要更新: - 更新所有12个产业的教务系统数据和功能 - 删除所有 node_modules 文件夹(节省3.7GB) - 删除所有 .yoyo 缓存文件夹(节省1.2GB) - 删除所有 dist 构建文件(节省55MB) 项目优化: - 项目大小从 8.1GB 减少到 3.2GB(节省60%空间) - 保留完整的源代码和配置文件 - .gitignore 已配置,防止再次提交大文件 启动脚本: - start-industry.sh/bat/ps1 脚本会自动检测并安装依赖 - 首次启动时自动运行 npm install - 支持单个或批量启动产业系统 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
238
frontend_智能制造/update_interview_questions.py
Normal file
238
frontend_智能制造/update_interview_questions.py
Normal file
@@ -0,0 +1,238 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import json
|
||||
import re
|
||||
|
||||
# 读取智能制造岗位简历数据
|
||||
with open('网页未导入数据/智能制造产业/智能制造岗位简历.json', 'r', encoding='utf-8') as f:
|
||||
smart_mfg_data = json.load(f)
|
||||
|
||||
# 创建面试题映射字典
|
||||
interview_questions_map = {}
|
||||
for item in smart_mfg_data:
|
||||
job_group = item.get('简历岗位群', '')
|
||||
interview_content = item.get('面试题内容', '')
|
||||
if job_group and interview_content:
|
||||
# 存储完整的面试题内容
|
||||
interview_questions_map[job_group] = interview_content
|
||||
|
||||
# 打印找到的岗位群
|
||||
print("找到的岗位群面试题:")
|
||||
for key in interview_questions_map.keys():
|
||||
print(f"- {key}")
|
||||
|
||||
# 读取当前的mock文件
|
||||
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||||
mock_content = f.read()
|
||||
|
||||
# 备份原文件
|
||||
import datetime
|
||||
backup_time = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
with open(f'src/mocks/resumeInterviewMock.js.backup_{backup_time}', 'w', encoding='utf-8') as f:
|
||||
f.write(mock_content)
|
||||
print(f"\n已创建备份文件: src/mocks/resumeInterviewMock.js.backup_{backup_time}")
|
||||
|
||||
# 需要更新的岗位群映射
|
||||
job_group_mapping = {
|
||||
'PLC': 'PLC类岗位面试题',
|
||||
'工业机器人': '工业机器人类岗位面试题',
|
||||
'焊接工艺': '焊接工艺类岗位面试题',
|
||||
'电气设计': '电气设计类岗位面试题',
|
||||
'机器视觉': '机器视觉类岗位面试题',
|
||||
'非标自动化设计': '非标自动化类岗位面试题'
|
||||
}
|
||||
|
||||
# 解析面试题内容为结构化数据
|
||||
def parse_interview_content(content):
|
||||
"""解析面试题内容为结构化数据"""
|
||||
questions = []
|
||||
lines = content.split('\n')
|
||||
|
||||
current_section = None
|
||||
current_question = None
|
||||
current_answer = []
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
# 检查是否是大标题(如 # 一、xxx)
|
||||
if line.startswith('# '):
|
||||
# 保存之前的问题
|
||||
if current_question and current_section:
|
||||
answer_text = '\\n'.join(current_answer).strip()
|
||||
if not answer_text.startswith('示例答案') and not answer_text.startswith('答案'):
|
||||
answer_text = answer_text
|
||||
else:
|
||||
# 去掉"示例答案:"或"答案:"前缀
|
||||
answer_text = re.sub(r'^(示例答案[::]|答案[::])\s*', '', answer_text)
|
||||
|
||||
current_section['subQuestions'].append({
|
||||
'question': current_question,
|
||||
'answer': answer_text
|
||||
})
|
||||
|
||||
# 创建新section
|
||||
if current_section:
|
||||
questions.append(current_section)
|
||||
|
||||
section_title = line.replace('#', '').strip()
|
||||
current_section = {
|
||||
'title': section_title,
|
||||
'subQuestions': []
|
||||
}
|
||||
current_question = None
|
||||
current_answer = []
|
||||
|
||||
# 检查是否是问题编号(如 1. xxx)
|
||||
elif re.match(r'^\d+\.\s+', line):
|
||||
# 保存之前的问题
|
||||
if current_question and current_section:
|
||||
answer_text = '\\n'.join(current_answer).strip()
|
||||
if answer_text.startswith('示例答案') or answer_text.startswith('答案'):
|
||||
answer_text = re.sub(r'^(示例答案[::]|答案[::])\s*', '', answer_text)
|
||||
|
||||
current_section['subQuestions'].append({
|
||||
'question': current_question,
|
||||
'answer': answer_text
|
||||
})
|
||||
|
||||
# 提取新问题
|
||||
current_question = re.sub(r'^\d+\.\s+', '', line)
|
||||
current_answer = []
|
||||
|
||||
# 否则是答案内容
|
||||
else:
|
||||
if current_question:
|
||||
current_answer.append(line)
|
||||
|
||||
# 保存最后一个问题
|
||||
if current_question and current_section:
|
||||
answer_text = '\\n'.join(current_answer).strip()
|
||||
if answer_text.startswith('示例答案') or answer_text.startswith('答案'):
|
||||
answer_text = re.sub(r'^(示例答案[::]|答案[::])\s*', '', answer_text)
|
||||
|
||||
current_section['subQuestions'].append({
|
||||
'question': current_question,
|
||||
'answer': answer_text
|
||||
})
|
||||
|
||||
# 保存最后一个section
|
||||
if current_section:
|
||||
questions.append(current_section)
|
||||
|
||||
return questions
|
||||
|
||||
# 更新mock文件中的面试题
|
||||
def update_mock_questions(mock_content, job_group_name, interview_content):
|
||||
"""更新指定岗位群的面试题"""
|
||||
|
||||
# 解析面试题内容
|
||||
parsed_questions = parse_interview_content(interview_content)
|
||||
if not parsed_questions:
|
||||
print(f" 警告: 无法解析 {job_group_name} 的面试题内容")
|
||||
return mock_content
|
||||
|
||||
# 查找岗位群的位置
|
||||
pattern = rf'"name":\s*"{re.escape(job_group_name)}"'
|
||||
matches = list(re.finditer(pattern, mock_content))
|
||||
|
||||
if not matches:
|
||||
print(f" 未找到岗位群: {job_group_name}")
|
||||
return mock_content
|
||||
|
||||
for match in matches:
|
||||
# 找到questions数组的起始位置
|
||||
start_pos = match.end()
|
||||
questions_pattern = r'"questions":\s*\['
|
||||
questions_match = re.search(questions_pattern, mock_content[start_pos:start_pos+5000])
|
||||
|
||||
if not questions_match:
|
||||
continue
|
||||
|
||||
questions_start = start_pos + questions_match.end()
|
||||
|
||||
# 找到questions数组的结束位置
|
||||
bracket_count = 1
|
||||
i = questions_start
|
||||
in_string = False
|
||||
escape_next = False
|
||||
|
||||
while i < len(mock_content) and bracket_count > 0:
|
||||
char = mock_content[i]
|
||||
|
||||
if escape_next:
|
||||
escape_next = False
|
||||
elif char == '\\':
|
||||
escape_next = True
|
||||
elif char == '"' and not escape_next:
|
||||
in_string = not in_string
|
||||
elif not in_string:
|
||||
if char == '[':
|
||||
bracket_count += 1
|
||||
elif char == ']':
|
||||
bracket_count -= 1
|
||||
|
||||
i += 1
|
||||
|
||||
if bracket_count == 0:
|
||||
questions_end = i - 1
|
||||
|
||||
# 构建新的questions数组
|
||||
new_questions = []
|
||||
for idx, section in enumerate(parsed_questions):
|
||||
sub_questions = []
|
||||
for q_idx, q in enumerate(section['subQuestions']):
|
||||
answer = q['answer'].replace('"', '\\"').replace('\n', '\\n')
|
||||
sub_questions.append(f'''{{
|
||||
"id": "q{idx}_{q_idx+1}",
|
||||
"question": "{q['question']}",
|
||||
"answer": "{answer}"
|
||||
}}''')
|
||||
|
||||
new_questions.append(f'''{{
|
||||
"id": "group_q{idx+1}",
|
||||
"question": "{section['title']}",
|
||||
"subQuestions": [
|
||||
{','.join(sub_questions)}
|
||||
]
|
||||
}}''')
|
||||
|
||||
# 替换原有的questions内容
|
||||
new_questions_str = ',\n '.join(new_questions)
|
||||
mock_content = mock_content[:questions_start] + '\n ' + new_questions_str + '\n ' + mock_content[questions_end:]
|
||||
|
||||
print(f" ✓ 已更新 {job_group_name} 的面试题")
|
||||
break
|
||||
|
||||
return mock_content
|
||||
|
||||
# 执行更新
|
||||
print("\n开始更新面试题:")
|
||||
updated_content = mock_content
|
||||
|
||||
for mock_group_name, json_interview_name in job_group_mapping.items():
|
||||
print(f"\n处理 {mock_group_name}:")
|
||||
|
||||
# 查找对应的面试题内容
|
||||
found = False
|
||||
for item in smart_mfg_data:
|
||||
if item.get('面试题', '') == json_interview_name:
|
||||
interview_content = item.get('面试题内容', '')
|
||||
if interview_content:
|
||||
updated_content = update_mock_questions(updated_content, mock_group_name, interview_content)
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
print(f" 未找到 {json_interview_name} 的面试题数据")
|
||||
|
||||
# 保存更新后的文件
|
||||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||||
f.write(updated_content)
|
||||
|
||||
print("\n✅ 面试题更新完成!")
|
||||
print("已更新的岗位群:")
|
||||
for group in job_group_mapping.keys():
|
||||
print(f" - {group}")
|
||||
Reference in New Issue
Block a user