69 lines
2.3 KiB
JavaScript
69 lines
2.3 KiB
JavaScript
|
|
import fs from 'fs';
|
|||
|
|
|
|||
|
|
// 读取岗位面试状态(全产业).json文件,提取交通物流产业数据
|
|||
|
|
function readTrafficLogisticsInterviewData() {
|
|||
|
|
const allIndustryData = JSON.parse(fs.readFileSync('./网页未导入数据/岗位面试状态(全产业).json', 'utf-8'));
|
|||
|
|
|
|||
|
|
// 筛选交通物流产业的数据
|
|||
|
|
const trafficLogisticsData = allIndustryData.filter(item =>
|
|||
|
|
item["所属产业"] === "交通物流"
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
console.log(`找到交通物流产业面试状态数据 ${trafficLogisticsData.length} 条`);
|
|||
|
|
return trafficLogisticsData;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 转换数据格式以匹配项目现有结构
|
|||
|
|
function transformDataFormat(rawData) {
|
|||
|
|
return rawData.map(item => ({
|
|||
|
|
"查询岗位名称": item["查询岗位名称"],
|
|||
|
|
"查询_截止日期": item["查询_截止日期"],
|
|||
|
|
"岗位内推流程": item["岗位内推流程"],
|
|||
|
|
"流程标签": item["流程标签"],
|
|||
|
|
"流程时间": item["流程时间"],
|
|||
|
|
"内容": item["内容"]
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 备份原始文件
|
|||
|
|
function backupOriginalFile() {
|
|||
|
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|||
|
|
const backupPath = `./src/data/interviewStatus.json.backup_${timestamp}`;
|
|||
|
|
|
|||
|
|
fs.copyFileSync('./src/data/interviewStatus.json', backupPath);
|
|||
|
|
console.log(`已备份原始文件到: ${backupPath}`);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 更新面试状态数据文件
|
|||
|
|
function updateInterviewStatusFile() {
|
|||
|
|
try {
|
|||
|
|
// 备份原始文件
|
|||
|
|
backupOriginalFile();
|
|||
|
|
|
|||
|
|
// 读取交通物流数据
|
|||
|
|
const trafficLogisticsData = readTrafficLogisticsInterviewData();
|
|||
|
|
|
|||
|
|
// 转换数据格式
|
|||
|
|
const transformedData = transformDataFormat(trafficLogisticsData);
|
|||
|
|
|
|||
|
|
// 写入新文件
|
|||
|
|
fs.writeFileSync('./src/data/interviewStatus.json', JSON.stringify(transformedData, null, 2), 'utf-8');
|
|||
|
|
|
|||
|
|
console.log('✅ 面试状态数据已成功替换为交通物流产业数据');
|
|||
|
|
console.log(`共替换了 ${transformedData.length} 条记录`);
|
|||
|
|
|
|||
|
|
// 验证文件语法
|
|||
|
|
try {
|
|||
|
|
JSON.parse(fs.readFileSync('./src/data/interviewStatus.json', 'utf-8'));
|
|||
|
|
console.log('✅ 文件语法验证通过');
|
|||
|
|
} catch (error) {
|
|||
|
|
console.error('❌ 文件语法错误:', error.message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
} catch (error) {
|
|||
|
|
console.error('❌ 更新失败:', error.message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 执行更新
|
|||
|
|
updateInterviewStatusFile();
|