Files
online_sys/frontend_智能开发/fixJobLevels.cjs
KQL a7242f0c69 Initial commit: 教务系统在线平台
- 包含4个产业方向的前端项目:智能开发、智能制造、大健康、财经商贸
- 已清理node_modules、.yoyo等大文件,项目大小从2.6GB优化至631MB
- 配置完善的.gitignore文件

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-12 18:16:55 +08:00

177 lines
5.6 KiB
JavaScript
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.

const fs = require('fs');
// 读取智能开发岗位简历数据,获取正确的岗位等级标签
const jobsData = JSON.parse(
fs.readFileSync('./网页未导入数据/智能开发产业/智能开发岗位简历.json', 'utf-8')
);
// 构建岗位等级映射表
const jobLevelMap = {};
jobsData.forEach(job => {
const jobName = job['岗位名称'];
const level = job['岗位等级标签'];
if (jobName && level) {
jobLevelMap[jobName] = level;
}
});
console.log('岗位等级映射表:');
console.log(jobLevelMap);
// 读取智能开发项目案例数据
const projectData = JSON.parse(
fs.readFileSync('./网页未导入数据/智能开发产业/智能开发项目案例.json', 'utf-8')
);
// 重新构建项目数据,使用正确的岗位等级标签
const projects = projectData.map((item, index) => {
// 解析适用岗位
const positionsStr = item['适用岗位'] || '';
const positionsList = positionsStr ? positionsStr.split(',').map(p => p.trim()) : [];
// 为岗位分配正确的等级(从岗位简历数据中查找)
const positions = positionsList.map(pos => {
// 先在映射表中查找精确匹配
let level = jobLevelMap[pos];
// 如果没找到,尝试模糊匹配
if (!level) {
// 查找包含该岗位名称的映射
for (const [key, value] of Object.entries(jobLevelMap)) {
if (key.includes(pos) || pos.includes(key)) {
level = value;
break;
}
}
}
// 如果还是没找到,使用默认值
if (!level) {
// 基于关键词判断
if (pos.includes('助理') || pos.includes('实习')) {
level = '普通岗';
} else if (pos.includes('高级') || pos.includes('专家') || pos.includes('总监') || pos.includes('经理')) {
level = '储备干部岗';
} else {
level = '技术骨干岗';
}
console.log(`⚠️ 岗位"${pos}"未找到精确匹配,使用默认等级:${level}`);
}
return {
level: level,
position: pos
};
});
// 提取项目详情
const projectDetail = item['项目案例内容'] || '';
let overview = '';
let process = '';
let keyPoints = '';
if (projectDetail) {
const overviewMatch = projectDetail.match(/项目概述[\s\S]*?(?=\n#|$)/);
if (overviewMatch) {
overview = overviewMatch[0].replace(/^.*项目概述\s*/, '').replace(/^[\n#]+/, '').trim();
overview = overview.replace(/^#\s*/gm, '').replace(/\*\*/g, '').replace(/\n+/g, ' ');
if (overview.length > 500) {
overview = overview.substring(0, 497) + '...';
}
}
const processMatch = projectDetail.match(/项目整体流程介绍[\s\S]*?(?=\n#.*项目案例关键技术点|$)/);
if (processMatch) {
process = processMatch[0].replace(/^.*项目整体流程介绍\s*/, '').trim();
}
const keyPointsMatch = projectDetail.match(/项目案例关键技术点[\s\S]*$/);
if (keyPointsMatch) {
keyPoints = keyPointsMatch[0].replace(/^.*项目案例关键技术点\s*/, '').trim();
}
}
if (!overview) {
overview = `${item['案例名称']}是一个${item['所属垂直方向'] || '智能开发'}方向的项目,旨在提升相关技术能力和实践经验。`;
}
return {
id: index + 1,
name: item['案例名称'],
positions: positions, // 带等级的岗位数组
positionsList: positionsList, // 岗位名称列表
unit: item['对应单元名称(垂直能力课)'] || item['对应单元名称(复合能力课)'] || '',
direction: item['所属垂直方向'] || '智能开发',
overview: overview,
process: process,
keyPoints: keyPoints,
compoundUnit: item['对应单元名称(复合能力课)'] || '',
verticalUnit: item['对应单元名称(垂直能力课)'] || ''
};
});
// 更新projectLibraryMock.js
const mockPath = './src/mocks/projectLibraryMock.js';
let mockContent = fs.readFileSync(mockPath, 'utf-8');
// 更新getMockProjectDetail函数确保返回正确的岗位等级
const newGetMockProjectDetail = `
export const getMockProjectDetail = (id) => {
// 智能开发项目详细数据(包含正确的岗位等级标签)
const projects = ${JSON.stringify(projects, null, 2)};
const project = projects.find(p => p.id === parseInt(id));
if (!project) {
return {
success: false,
code: 404,
message: "项目不存在",
data: null
};
}
// 构造返回数据
return {
success: true,
code: 0,
message: "success",
data: {
id: project.id,
title: project.name,
category: project.direction,
description: project.overview,
overview: project.overview,
applicablePositions: project.positions || [], // 使用带等级的岗位数组
correspondingUnits: project.unit ? [project.unit] : [],
process: project.process || "",
keyPoints: project.keyPoints || "",
attachments: []
}
};
};`;
// 替换getMockProjectDetail函数
const detailFuncPattern = /export const getMockProjectDetail[\s\S]*?\n\};/;
const detailFuncMatch = mockContent.match(detailFuncPattern);
if (detailFuncMatch) {
mockContent = mockContent.replace(detailFuncMatch[0], newGetMockProjectDetail);
} else {
mockContent += '\n' + newGetMockProjectDetail;
}
// 写入文件
fs.writeFileSync(mockPath, mockContent, 'utf-8');
console.log('\n✅ 岗位等级标签已修正!');
// 输出前5个项目的岗位等级信息
console.log('\n前5个项目的岗位等级');
projects.slice(0, 5).forEach((p, i) => {
console.log(`\n${i + 1}. ${p.name}`);
p.positions.forEach(pos => {
console.log(` - ${pos.position}: ${pos.level}`);
});
});