20261105_fault_frequency.sql 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. -- 振动故障频率参数与测点映射
  2. -- 目标库:energy_prod
  3. -- 版本:2026-11-05
  4. -- 说明:只新增表/字段,不改动既有业务表结构;与现有 unit_dict_brand_model、
  5. -- unit_bearings、unit_dynamo、unit_gearbox* 兼容。
  6. CREATE TABLE IF NOT EXISTS component_fault_spec (
  7. id BIGINT AUTO_INCREMENT PRIMARY KEY,
  8. component_type VARCHAR(32) NOT NULL DEFAULT 'bearing'
  9. COMMENT 'bearing/main_bearing/generator/gearbox_bearing/gearbox_gear',
  10. brand VARCHAR(128) NOT NULL,
  11. model VARCHAR(128) NOT NULL,
  12. position VARCHAR(32) NOT NULL DEFAULT ''
  13. COMMENT 'front/rear/drive_end/non_drive_end/planet/low_speed/high_speed/input/output',
  14. stage INT NOT NULL DEFAULT 0 COMMENT '齿轮箱级数,0 表示不区分',
  15. n_rolls DECIMAL(10,3) NULL COMMENT '滚动体数量',
  16. roller_diameter DECIMAL(10,3) NULL COMMENT '滚动体直径 mm',
  17. pitch_diameter DECIMAL(10,3) NULL COMMENT '节圆直径 mm',
  18. contact_angle DECIMAL(10,3) NULL COMMENT '接触角 度',
  19. gear_teeth INT NULL COMMENT '齿轮齿数',
  20. stage_count INT NULL COMMENT '齿轮箱级数',
  21. pole_pairs INT NULL COMMENT '发电机极对数',
  22. source VARCHAR(128) NULL COMMENT '参数来源',
  23. confidence DECIMAL(5,2) NOT NULL DEFAULT 1.00 COMMENT '0-1',
  24. valid_state VARCHAR(16) NOT NULL DEFAULT 'valid'
  25. COMMENT 'valid/missing/review',
  26. create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
  27. update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  28. UNIQUE KEY uk_fault_spec (component_type, brand, model, position, stage)
  29. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='部件故障频率参数库';
  30. CREATE TABLE IF NOT EXISTS measurement_point_component (
  31. id BIGINT AUTO_INCREMENT PRIMARY KEY,
  32. point_name VARCHAR(255) NOT NULL COMMENT '波形 mesure_point_name',
  33. component_type VARCHAR(32) NOT NULL COMMENT '部件类型',
  34. position VARCHAR(32) NOT NULL DEFAULT '' COMMENT '安装位置',
  35. stage INT NOT NULL DEFAULT 0 COMMENT '级数',
  36. note VARCHAR(255) NULL,
  37. create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
  38. UNIQUE KEY uk_point_name (point_name)
  39. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='测点到部件/位置映射';
  40. -- 复用现有轴承字典中的几何参数,避免重复维护
  41. INSERT INTO component_fault_spec
  42. (component_type, brand, model, position, stage,
  43. n_rolls, roller_diameter, pitch_diameter, contact_angle,
  44. source, confidence, valid_state)
  45. SELECT 'bearing', manufacture, model_number, '', 0,
  46. rolls_number, rolls_diameter, circle_diameter, theta_deg,
  47. 'unit_dict_brand_model', 0.95, 'valid'
  48. FROM unit_dict_brand_model
  49. WHERE unit_type = 1
  50. AND rolls_number IS NOT NULL
  51. AND rolls_diameter IS NOT NULL
  52. AND circle_diameter IS NOT NULL
  53. AND theta_deg IS NOT NULL
  54. ON DUPLICATE KEY UPDATE
  55. n_rolls = VALUES(n_rolls),
  56. roller_diameter = VALUES(roller_diameter),
  57. pitch_diameter = VALUES(pitch_diameter),
  58. contact_angle = VALUES(contact_angle),
  59. source = VALUES(source),
  60. confidence = VALUES(confidence),
  61. valid_state = VALUES(valid_state);
  62. -- 测点映射(与前端测点英文键保持一致)
  63. INSERT INTO measurement_point_component
  64. (point_name, component_type, position, stage, note)
  65. VALUES
  66. ('main_bearing_radial_vertical_vibration','main_bearing','main',0,'主轴承径向垂直'),
  67. ('main_bearing_radial_vibration','main_bearing','main',0,'主轴承径向'),
  68. ('main_bearing_radial_horizontal_vibration','main_bearing','main',0,'主轴承径向水平'),
  69. ('main_bearing_axial_vibration','main_bearing','main',0,'主轴承轴向'),
  70. ('front_main_bearing_radial_vertical_vibration','main_bearing','front',0,'前主轴承径向垂直'),
  71. ('front_main_bearing_radial_vibration','main_bearing','front',0,'前主轴承径向'),
  72. ('front_main_bearing_radial_horizontal_vibration','main_bearing','front',0,'前主轴承径向水平'),
  73. ('front_main_bearing_axial_vibration','main_bearing','front',0,'前主轴承轴向'),
  74. ('rear_main_bearing_radial_vertical_vibration','main_bearing','rear',0,'后主轴承径向垂直'),
  75. ('rear_main_bearing_radial_vibration','main_bearing','rear',0,'后主轴承径向'),
  76. ('rear_main_bearing_radial_horizontal_vibration','main_bearing','rear',0,'后主轴承径向水平'),
  77. ('rear_main_bearing_axial_vibration','main_bearing','rear',0,'后主轴承轴向'),
  78. ('generator_radial_1_vibration','generator','drive_end',0,'发电机径向1'),
  79. ('generator_radial_2_vibration','generator','non_drive_end',0,'发电机径向2'),
  80. ('generator_drive_end_radial_vibration','generator','drive_end',0,'发电机驱动端'),
  81. ('generator_non_drive_end_radial_vibration','generator','non_drive_end',0,'发电机非驱动端'),
  82. ('stator_radial_horizontal_vibration','generator','stator',0,'定子径向水平'),
  83. ('gearbox_first_stage_planet_large_ring_radial_vibration','gearbox_gear','planet',1,'一级行星级大齿圈'),
  84. ('gearbox_first_stage_planet_radial_vibration','gearbox_gear','planet',1,'一级行星级'),
  85. ('gearbox_second_stage_planet_large_ring_radial_vibration','gearbox_gear','planet',2,'二级行星级大齿圈'),
  86. ('gearbox_second_stage_planet_radial_vibration','gearbox_gear','planet',2,'二级行星级'),
  87. ('gearbox_second_stage_planet_axial_vibration','gearbox_gear','planet',2,'二级行星级轴向'),
  88. ('gearbox_third_stage_planet_radial_vibration','gearbox_gear','planet',3,'三级行星级'),
  89. ('gearbox_low_speed_shaft_output_end_radial_vibration','gearbox_bearing','low_speed',0,'低速轴输出端'),
  90. ('gearbox_input_end_radial_vibration','gearbox_bearing','input',0,'齿轮箱输入端'),
  91. ('gearbox_output_shaft_axial_vibration','gearbox_bearing','output',0,'齿轮箱输出轴'),
  92. ('gearbox_high_speed_shaft_output_end_radial_vibration','gearbox_bearing','high_speed',0,'高速轴输出端'),
  93. ('gearbox_high_speed_shaft_output_end_axial_vibration','gearbox_bearing','high_speed',0,'高速轴输出端轴向')
  94. ON DUPLICATE KEY UPDATE
  95. component_type = VALUES(component_type),
  96. position = VALUES(position),
  97. stage = VALUES(stage),
  98. note = VALUES(note);
  99. -- 报警表补充故障频率证据字段
  100. ALTER TABLE vibration_alarm_event
  101. ADD COLUMN fault_type VARCHAR(32) NULL COMMENT 'BPFO/BPFI/BSF/FTF/GMF',
  102. ADD COLUMN characteristic_freq DOUBLE NULL COMMENT '特征频率 Hz',
  103. ADD COLUMN fault_order DOUBLE NULL COMMENT '阶次',
  104. ADD COLUMN spec_source VARCHAR(128) NULL COMMENT '参数来源',
  105. ADD COLUMN diagnosis_detail VARCHAR(512) NULL COMMENT '诊断证据';