|
|
-- =============================================
|
|
|
-- CNC机床数据采集系统 - 预置数据
|
|
|
-- 生成时间: 2026-04-28
|
|
|
-- =============================================
|
|
|
|
|
|
USE cnc_business;
|
|
|
|
|
|
-- 车间预置
|
|
|
INSERT IGNORE INTO cnc_workshop (name, sort_order, is_enabled) VALUES
|
|
|
('A栋', 1, 1),
|
|
|
('B栋', 2, 1),
|
|
|
('C栋', 3, 1);
|
|
|
|
|
|
-- 品牌预置(FANUC)
|
|
|
INSERT IGNORE INTO cnc_brand (brand_name, device_field, tags_path, is_enabled) VALUES
|
|
|
('FANUC', 'device', 'tags', 1);
|
|
|
|
|
|
-- FANUC字段映射预置
|
|
|
SET @fanuc_brand_id = (SELECT id FROM cnc_brand WHERE brand_name = 'FANUC');
|
|
|
|
|
|
INSERT IGNORE INTO cnc_brand_field_mapping (brand_id, standard_field, field_name, match_by, data_type, is_required) VALUES
|
|
|
(@fanuc_brand_id, 'program_name', 'program_name', 'id', 'string', 1),
|
|
|
(@fanuc_brand_id, 'part_count', 'part_count', 'id', 'number', 1),
|
|
|
(@fanuc_brand_id, 'device_status', 'device_status', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'run_status', 'run_status', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'operate_mode', 'operate_mode', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'spindle_speed_set', 'spindle_speed_set', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'feed_speed_set', 'feed_speed_set', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'spindle_speed_actual', 'spindle_speed_actual', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'feed_speed_actual', 'feed_speed_actual', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'spindle_load', 'spindle_load', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'spindle_override', 'spindle_override', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'power_on_time', 'power_on_time', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'run_time', 'run_time', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'cutting_time', 'cutting_time', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'cycle_time', 'cycle_time', 'id', 'number', 0),
|
|
|
(@fanuc_brand_id, 'machining_status', 'machining_status', 'id', 'string', 0);
|
|
|
|
|
|
-- 系统配置预置
|
|
|
INSERT IGNORE INTO cnc_sys_config (config_key, config_value, value_type, description) VALUES
|
|
|
('ping_interval', '60', 'number', 'Ping检测间隔(秒)'),
|
|
|
('collect_retry_count', '3', 'number', '采集失败重试次数'),
|
|
|
('collect_retry_interval', '30', 'number', '采集重试间隔(秒)'),
|
|
|
('collect_fail_alert_threshold', '5', 'number', '连续失败N次触发告警'),
|
|
|
('heartbeat_interval', '10', 'number', '心跳写入间隔(秒)'),
|
|
|
('daily_summary_time', '01:00', 'string', '日终汇总执行时间'),
|
|
|
('config_poll_interval', '30', 'number', '采集服务轮询配置间隔(秒)'),
|
|
|
('log_retention_days', '90', 'number', '原始采集日志保留天数'),
|
|
|
('system_log_retention_days', '30', 'number', '系统日志保留天数'),
|
|
|
('alert_log_retention_days', '180', 'number', '异常日志保留天数'),
|
|
|
('heartbeat_retention_days', '7', 'number', '心跳记录保留天数'),
|
|
|
('bigscreen_refresh_interval', '10', 'number', '大屏刷新间隔(秒)'),
|
|
|
('api_token', '', 'string', '前端API Token'),
|
|
|
('collector_api_port', '5800', 'number', '采集服务管理API端口'),
|
|
|
('collector_api_key', '', 'string', '采集服务间通信API Key'),
|
|
|
('error_retry_base_interval', '60', 'number', '任务错误重试基础间隔(秒)'),
|
|
|
('admin_username', 'admin', 'string', '管理员用户名(不可修改)'),
|
|
|
('admin_password_hash', '$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy', 'string', '管理员密码哈希(默认admin123)');
|
|
|
|
|
|
-- 大屏卡片配置预置
|
|
|
INSERT IGNORE INTO cnc_screen_config (card_key, card_type, title, metric, dimension, sort_order, is_enabled) VALUES
|
|
|
('total_online', 'stat_number', '在线机床数', 'online_count', NULL, 1, 1),
|
|
|
('total_production_today', 'stat_number', '今日总产量', 'part_count', NULL, 2, 1),
|
|
|
('workshop_production', 'bar_chart', '各车间产量', 'part_count', 'workshop', 3, 1),
|
|
|
('worker_rank', 'rank_list', '工人产量排行', 'part_count', 'worker', 4, 1),
|
|
|
('machine_rank', 'rank_list', '机床产量排行', 'part_count', 'machine', 5, 1),
|
|
|
('machine_status', 'status_grid', '机床状态总览', 'status', NULL, 6, 1),
|
|
|
('collector_status', 'stat_number', '采集服务状态', 'status', NULL, 7, 1),
|
|
|
('production_trend', 'line_chart', '产量趋势(7天)', 'part_count', NULL, 8, 1);
|
|
|
|
|
|
|