Files
yunrui_asset/backend/scripts/generate-rack-import-template.js
T
zhang1106 d9c46245df feat: 添加设备位置冲突检查功能并优化操作日志
feat(api): 在设备API中添加checkPosition接口用于检查U位冲突
feat(frontend): 在设备表单和空闲设备管理中实现U位冲突检查
refactor(backend): 重构操作日志功能,添加设备描述生成和元数据构建工具
fix(backend): 修复批量导入机柜时的ID验证规则
feat(backend): 为机柜导入添加创建和跳过机柜的详细返回信息
fix(backend): 修复设备删除时未检查关联接线的问题
feat(backend): 添加机柜导入模板生成脚本
perf(frontend): 优化机柜管理页面的导入结果展示
fix(frontend): 修复设备端口删除时的关联接线检查
2026-03-26 14:35:08 +08:00

113 lines
3.0 KiB
JavaScript
Raw 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 XLSX = require('xlsx');
const path = require('path');
const templateData = [
{
'机柜ID(留空自动生成)': '',
'机柜名称': 'IDC2-SERVER-01',
'所属机房名称': 'IDC2',
'高度(U)': 42,
'最大功率(W)': 5000,
'状态': 'active'
},
{
'机柜ID(留空自动生成)': '',
'机柜名称': 'IDC2-SERVER-02',
'所属机房名称': 'IDC2',
'高度(U)': 42,
'最大功率(W)': 5000,
'状态': 'active'
},
{
'机柜ID(留空自动生成)': '',
'机柜名称': 'IDC2-SERVER-03',
'所属机房名称': 'IDC2',
'高度(U)': 42,
'最大功率(W)': 5000,
'状态': 'active'
},
{
'机柜ID(留空自动生成)': '',
'机柜名称': 'IDC4-NETWORK-01',
'所属机房名称': 'IDC4',
'高度(U)': 48,
'最大功率(W)': 8000,
'状态': 'active'
},
{
'机柜ID(留空自动生成)': '',
'机柜名称': 'IDC4-NETWORK-02',
'所属机房名称': 'IDC4',
'高度(U)': 48,
'最大功率(W)': 8000,
'状态': 'maintenance'
},
{
'机柜ID(留空自动生成)': '',
'机柜名称': 'IDC5-STORAGE-01',
'所属机房名称': 'IDC5',
'高度(U)': 42,
'最大功率(W)': 10000,
'状态': 'active'
},
{
'机柜ID(留空自动生成)': '',
'机柜名称': 'IDC5-STORAGE-02',
'所属机房名称': 'IDC5',
'高度(U)': 42,
'最大功率(W)': 10000,
'状态': 'inactive'
},
{
'机柜ID(留空自动生成)': '',
'机柜名称': 'IDC7-SERVER-01',
'所属机房名称': 'IDC7',
'高度(U)': 36,
'最大功率(W)': 6000,
'状态': 'active'
},
{
'机柜ID(留空自动生成)': '',
'机柜名称': '古荡-机柜-01',
'所属机房名称': '古荡机房1-1',
'高度(U)': 42,
'最大功率(W)': 5000,
'状态': 'active'
},
{
'机柜ID(留空自动生成)': '',
'机柜名称': '古荡-机柜-02',
'所属机房名称': '古荡机房1-1',
'高度(U)': 42,
'最大功率(W)': 5000,
'状态': 'active'
}
];
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.json_to_sheet(templateData);
ws['!cols'] = [
{ wch: 20 },
{ wch: 20 },
{ wch: 15 },
{ wch: 10 },
{ wch: 15 },
{ wch: 15 }
];
XLSX.utils.book_append_sheet(wb, ws, '机柜导入模板');
const outputPath = path.join(__dirname, '测试机柜导入.xlsx');
XLSX.writeFile(wb, outputPath);
console.log(`Excel文件已生成: ${outputPath}`);
console.log(`共 ${templateData.length} 条测试数据`);
console.log('\n字段说明:');
console.log('- 机柜ID(留空自动生成): 留空则系统自动生成唯一ID');
console.log('- 机柜名称: 必填,机柜的唯一标识名称');
console.log('- 所属机房名称: 必填,系统现有机房: IDC2, IDC4, IDC5, IDC7, 古荡机房1-1, 三墩机房1-1, 地市机房, IDCT');
console.log('- 高度(U): 必填,机柜的标准高度(1-50U');
console.log('- 最大功率(W): 必填,机柜的最大承载功率');
console.log('- 状态: active(在用)/maintenance(维护中)/inactive(停用)');