279 lines
8.3 KiB
JavaScript
279 lines
8.3 KiB
JavaScript
|
|
const fs = require('fs');
|
|||
|
|
const path = require('path');
|
|||
|
|
|
|||
|
|
// 读取智能开发岗位简历数据
|
|||
|
|
const smartDevData = JSON.parse(
|
|||
|
|
fs.readFileSync('./网页未导入数据/智能开发产业/智能开发岗位简历.json', 'utf-8')
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// 按岗位群分组
|
|||
|
|
const groupedData = {};
|
|||
|
|
smartDevData.forEach(item => {
|
|||
|
|
const group = item['简历岗位群'];
|
|||
|
|
if (!groupedData[group]) {
|
|||
|
|
groupedData[group] = {
|
|||
|
|
positions: [],
|
|||
|
|
questions: item['面试题'],
|
|||
|
|
questionsContent: item['面试题内容']
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
groupedData[group].positions.push(item);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 生成industries数组
|
|||
|
|
const industries = [];
|
|||
|
|
let industryIndex = 0;
|
|||
|
|
|
|||
|
|
Object.keys(groupedData).sort().forEach(groupName => {
|
|||
|
|
const groupData = groupedData[groupName];
|
|||
|
|
industryIndex++;
|
|||
|
|
|
|||
|
|
const industry = {
|
|||
|
|
id: `smartdev_${industryIndex}`,
|
|||
|
|
name: groupName,
|
|||
|
|
positions: groupData.positions.map((pos, index) => ({
|
|||
|
|
id: `smartdev_${industryIndex}_${index + 1}`,
|
|||
|
|
title: pos['岗位名称'],
|
|||
|
|
level: pos['岗位等级标签'],
|
|||
|
|
avatar: pos['简历头像url'],
|
|||
|
|
department: groupName,
|
|||
|
|
type: "全职",
|
|||
|
|
experience: "1-3年",
|
|||
|
|
education: "大专",
|
|||
|
|
salary: "6-12K",
|
|||
|
|
location: "苏州",
|
|||
|
|
updateTime: "2024-01-20",
|
|||
|
|
description: `负责${pos['岗位名称']}相关工作`,
|
|||
|
|
requirements: extractRequirements(pos['简历内容'])
|
|||
|
|
})),
|
|||
|
|
questions: parseQuestions(groupData.questionsContent)
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
industries.push(industry);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 生成resumeTemplates对象
|
|||
|
|
const resumeTemplates = {};
|
|||
|
|
|
|||
|
|
Object.keys(groupedData).sort().forEach(groupName => {
|
|||
|
|
const groupData = groupedData[groupName];
|
|||
|
|
|
|||
|
|
resumeTemplates[groupName] = groupData.positions.map(pos => ({
|
|||
|
|
position: pos['岗位名称'],
|
|||
|
|
level: pos['岗位等级标签'],
|
|||
|
|
avatar: pos['简历头像url'],
|
|||
|
|
content: {
|
|||
|
|
original: pos['简历内容'],
|
|||
|
|
modified: pos['简历内容'] // 暂时使用相同内容,后续可以添加修改版
|
|||
|
|
},
|
|||
|
|
studentInfo: extractStudentInfo(pos['简历内容'])
|
|||
|
|
}));
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 辅助函数:提取职位要求(从简历中提取核心能力前4条)
|
|||
|
|
function extractRequirements(resumeContent) {
|
|||
|
|
const requirements = [];
|
|||
|
|
const coreSkillsMatch = resumeContent.match(/### (一)核心能力\s*\n\n([\s\S]*?)### (二)/);
|
|||
|
|
|
|||
|
|
if (coreSkillsMatch) {
|
|||
|
|
const skills = coreSkillsMatch[1].split('\n')
|
|||
|
|
.filter(line => line.match(/^\d+\./))
|
|||
|
|
.slice(0, 4)
|
|||
|
|
.map(line => line.replace(/^\d+\.\s*/, '').trim());
|
|||
|
|
|
|||
|
|
return skills.length > 0 ? skills : [
|
|||
|
|
"具备相关专业知识和技能",
|
|||
|
|
"熟悉行业标准和规范",
|
|||
|
|
"良好的团队协作能力",
|
|||
|
|
"持续学习和创新能力"
|
|||
|
|
];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return [
|
|||
|
|
"具备相关专业知识和技能",
|
|||
|
|
"熟悉行业标准和规范",
|
|||
|
|
"良好的团队协作能力",
|
|||
|
|
"持续学习和创新能力"
|
|||
|
|
];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 辅助函数:解析面试题
|
|||
|
|
function parseQuestions(questionsContent) {
|
|||
|
|
if (!questionsContent) return [];
|
|||
|
|
|
|||
|
|
const questions = [];
|
|||
|
|
const sections = questionsContent.split(/# [一二三四五六七八九十]+、/);
|
|||
|
|
|
|||
|
|
sections.forEach((section, sectionIndex) => {
|
|||
|
|
if (sectionIndex === 0 || !section.trim()) return;
|
|||
|
|
|
|||
|
|
const lines = section.split('\n');
|
|||
|
|
const sectionTitle = lines[0] ? lines[0].trim() : `第${sectionIndex}部分`;
|
|||
|
|
|
|||
|
|
const subQuestions = [];
|
|||
|
|
let currentQuestion = null;
|
|||
|
|
let currentAnswer = '';
|
|||
|
|
|
|||
|
|
lines.forEach(line => {
|
|||
|
|
const questionMatch = line.match(/^\d+\.\s+(.+)/);
|
|||
|
|
const answerMatch = line.match(/^示例答案[::]\s*(.+)/);
|
|||
|
|
|
|||
|
|
if (questionMatch) {
|
|||
|
|
if (currentQuestion) {
|
|||
|
|
subQuestions.push({
|
|||
|
|
id: `q${sectionIndex}_${subQuestions.length + 1}`,
|
|||
|
|
question: currentQuestion,
|
|||
|
|
answer: currentAnswer.trim()
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
currentQuestion = questionMatch[1].trim();
|
|||
|
|
currentAnswer = '';
|
|||
|
|
} else if (answerMatch) {
|
|||
|
|
currentAnswer = answerMatch[1].trim();
|
|||
|
|
} else if (currentAnswer && line.trim()) {
|
|||
|
|
currentAnswer += ' ' + line.trim();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 添加最后一个问题
|
|||
|
|
if (currentQuestion) {
|
|||
|
|
subQuestions.push({
|
|||
|
|
id: `q${sectionIndex}_${subQuestions.length + 1}`,
|
|||
|
|
question: currentQuestion,
|
|||
|
|
answer: currentAnswer.trim()
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (subQuestions.length > 0) {
|
|||
|
|
questions.push({
|
|||
|
|
id: `group_q${sectionIndex}`,
|
|||
|
|
question: `# ${sectionTitle}`,
|
|||
|
|
subQuestions: subQuestions
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
return questions;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 辅助函数:提取学生信息
|
|||
|
|
function extractStudentInfo(resumeContent) {
|
|||
|
|
const info = {
|
|||
|
|
project_experience: {},
|
|||
|
|
core_skills: [],
|
|||
|
|
composite_skills: [],
|
|||
|
|
personal_summary: ""
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 提取项目经历
|
|||
|
|
const projectMatch = resumeContent.match(/### (一)项目名称[::]\s*(.+)/);
|
|||
|
|
const positionMatch = resumeContent.match(/### (二)实习岗位[::]\s*(.+)/);
|
|||
|
|
const timeMatch = resumeContent.match(/### ([三四])实习时间[::]\s*(.+)/);
|
|||
|
|
const companyMatch = resumeContent.match(/### ([三四])实习单位[::]\s*(.+)/);
|
|||
|
|
|
|||
|
|
if (projectMatch) info.project_experience.project_name = projectMatch[1].trim();
|
|||
|
|
if (positionMatch) info.project_experience.position = positionMatch[1].trim();
|
|||
|
|
if (timeMatch) info.project_experience.time_period = timeMatch[1].trim();
|
|||
|
|
if (companyMatch) info.project_experience.company = companyMatch[1].trim();
|
|||
|
|
|
|||
|
|
// 提取岗位职责
|
|||
|
|
const dutiesMatch = resumeContent.match(/### (五)岗位职责[::]\s*\n\n([\s\S]*?)#/);
|
|||
|
|
if (dutiesMatch) {
|
|||
|
|
info.project_experience.description = dutiesMatch[1]
|
|||
|
|
.split('\n')
|
|||
|
|
.filter(line => line.match(/^\d+\./))
|
|||
|
|
.map(line => line.replace(/^\d+\.\s*/, '').trim())
|
|||
|
|
.join(' ;\n');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 提取核心技能
|
|||
|
|
const coreSkillsMatch = resumeContent.match(/### (一)核心能力\s*\n\n([\s\S]*?)### (二)/);
|
|||
|
|
if (coreSkillsMatch) {
|
|||
|
|
info.core_skills = coreSkillsMatch[1]
|
|||
|
|
.split('\n')
|
|||
|
|
.filter(line => line.match(/^\d+\./))
|
|||
|
|
.map(line => line.replace(/^\d+\.\s*/, '').trim());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 提取复合能力
|
|||
|
|
const compositeSkillsMatch = resumeContent.match(/### (二)复合能力\s*\n\n([\s\S]*?)#/);
|
|||
|
|
if (compositeSkillsMatch) {
|
|||
|
|
info.composite_skills = compositeSkillsMatch[1]
|
|||
|
|
.split('\n')
|
|||
|
|
.filter(line => line.match(/^\d+\./))
|
|||
|
|
.map(line => line.replace(/^\d+\.\s*/, '').split(/[::]/)[0].trim())
|
|||
|
|
.slice(0, 2);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 提取个人总结
|
|||
|
|
const summaryMatch = resumeContent.match(/# 三、个人[总评][结价]\s*\n\n([\s\S]*?)$/);
|
|||
|
|
if (summaryMatch) {
|
|||
|
|
info.personal_summary = summaryMatch[1].trim();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return info;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 生成最终的Mock数据结构
|
|||
|
|
const mockData = `// 简历与面试题Mock数据
|
|||
|
|
|
|||
|
|
// 岗位群列表
|
|||
|
|
const industries = ${JSON.stringify(industries, null, 2)};
|
|||
|
|
|
|||
|
|
// 简历模板数据
|
|||
|
|
const resumeTemplates = ${JSON.stringify(resumeTemplates, null, 2)};
|
|||
|
|
|
|||
|
|
// 我的简历数据
|
|||
|
|
const myResume = {
|
|||
|
|
personalInfo: {
|
|||
|
|
name: "张明",
|
|||
|
|
phone: "138****8888",
|
|||
|
|
email: "zhangming@example.com",
|
|||
|
|
age: 22,
|
|||
|
|
education: "苏州信息职业技术学院 2020.9-2023.6",
|
|||
|
|
experience: "应届毕业生",
|
|||
|
|
location: "苏州"
|
|||
|
|
},
|
|||
|
|
workExperience: [
|
|||
|
|
{
|
|||
|
|
company: "苏州某智能科技企业",
|
|||
|
|
position: "AI开发实习生",
|
|||
|
|
duration: "2023.03-2023.06",
|
|||
|
|
description: "负责AI模型开发与应用相关工作"
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
skills: ["Python编程", "机器学习", "深度学习", "数据分析"],
|
|||
|
|
projects: [
|
|||
|
|
{
|
|||
|
|
name: "智能应用开发项目",
|
|||
|
|
role: "AI开发实习生",
|
|||
|
|
duration: "2023.04-2023.06",
|
|||
|
|
description: "参与智能应用的模型开发和部署"
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 获取页面mock数据的函数
|
|||
|
|
export function getMockPageData() {
|
|||
|
|
return resumeInterviewMockData;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 导出合并的数据
|
|||
|
|
export const resumeInterviewMockData = {
|
|||
|
|
industries,
|
|||
|
|
resumeTemplates,
|
|||
|
|
myResume
|
|||
|
|
};`;
|
|||
|
|
|
|||
|
|
// 写入转换后的数据
|
|||
|
|
fs.writeFileSync('./convertedResumeData.js', mockData, 'utf-8');
|
|||
|
|
|
|||
|
|
console.log('数据转换完成!');
|
|||
|
|
console.log(`- 生成了 ${industries.length} 个岗位群`);
|
|||
|
|
console.log(`- 总计 ${smartDevData.length} 个岗位`);
|
|||
|
|
console.log('- 输出文件: convertedResumeData.js');
|
|||
|
|
|
|||
|
|
// 生成岗位列表供hasRealModifiedVersion函数使用
|
|||
|
|
const allPositions = smartDevData.map(item => item['岗位名称']);
|
|||
|
|
console.log('\n所有岗位列表(用于hasRealModifiedVersion函数):');
|
|||
|
|
console.log(JSON.stringify(allPositions, null, 2));
|