docs: 更新字段
- 更新数据库schema和文档,增加insert_card和bright_g字段支持 - 同步更新heartbeatProcessor.js和databaseManager.js以支持新字段
This commit is contained in:
@@ -98,6 +98,9 @@ class DatabaseManager {
|
||||
device_count int2 NOT NULL,
|
||||
comm_seq int4 NOT NULL,
|
||||
|
||||
insert_card int2,
|
||||
bright_g int2,
|
||||
|
||||
elec_address text[],
|
||||
air_address text[],
|
||||
voltage double precision[],
|
||||
@@ -148,6 +151,8 @@ class DatabaseManager {
|
||||
ALTER TABLE heartbeat.heartbeat_events ADD COLUMN IF NOT EXISTS set_temp int2[];
|
||||
ALTER TABLE heartbeat.heartbeat_events ADD COLUMN IF NOT EXISTS now_temp int2[];
|
||||
ALTER TABLE heartbeat.heartbeat_events ADD COLUMN IF NOT EXISTS solenoid_valve int2[];
|
||||
ALTER TABLE heartbeat.heartbeat_events ADD COLUMN IF NOT EXISTS insert_card int2;
|
||||
ALTER TABLE heartbeat.heartbeat_events ADD COLUMN IF NOT EXISTS bright_g int2;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_heartbeat_events_hotel_id ON heartbeat.heartbeat_events (hotel_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_heartbeat_events_power_state ON heartbeat.heartbeat_events (power_state);
|
||||
@@ -413,6 +418,8 @@ class DatabaseManager {
|
||||
'carbon_state',
|
||||
'device_count',
|
||||
'comm_seq',
|
||||
'insert_card',
|
||||
'bright_g',
|
||||
'elec_address',
|
||||
'air_address',
|
||||
'voltage',
|
||||
@@ -445,6 +452,8 @@ class DatabaseManager {
|
||||
e.carbon_state,
|
||||
e.device_count,
|
||||
e.comm_seq,
|
||||
e.insert_card ?? null,
|
||||
e.bright_g ?? null,
|
||||
Array.isArray(e.elec_address) ? e.elec_address : null,
|
||||
Array.isArray(e.air_address) ? e.air_address : null,
|
||||
Array.isArray(e.voltage) ? e.voltage : null,
|
||||
|
||||
@@ -512,6 +512,8 @@ class HeartbeatProcessor {
|
||||
carbon_state: pick(['carbon_state', 'carbonState', 'CarbonState']),
|
||||
device_count: pick(['device_count', 'deviceCount', 'DeviceCount']),
|
||||
comm_seq: pick(['comm_seq', 'commSeq', 'CommSeq']),
|
||||
insert_card: pick(['insert_card', 'insertCard', 'InsertCard']),
|
||||
bright_g: pick(['bright_g', 'brightG', 'BrightG']),
|
||||
extra: pick(['extra', 'Extra']),
|
||||
electricity: pick(['electricity', 'Electricity']),
|
||||
air_conditioner: pick(['air_conditioner', 'airConditioner', 'AirConditioner']),
|
||||
@@ -563,6 +565,8 @@ class HeartbeatProcessor {
|
||||
normalized.carbon_state = toIntOrUndefined(normalized.carbon_state);
|
||||
normalized.device_count = toIntOrUndefined(normalized.device_count);
|
||||
normalized.comm_seq = toIntOrUndefined(normalized.comm_seq);
|
||||
normalized.insert_card = toIntOrUndefined(normalized.insert_card);
|
||||
normalized.bright_g = toIntOrUndefined(normalized.bright_g);
|
||||
|
||||
// 其余未知字段塞进 extra(避免丢信息),但不覆盖显式 extra
|
||||
if (!normalized.extra || typeof normalized.extra !== 'object') {
|
||||
@@ -585,6 +589,8 @@ class HeartbeatProcessor {
|
||||
'carbon_state','carbonState','CarbonState',
|
||||
'device_count','deviceCount','DeviceCount',
|
||||
'comm_seq','commSeq','CommSeq',
|
||||
'insert_card','insertCard','InsertCard',
|
||||
'bright_g','brightG','BrightG',
|
||||
'extra','Extra',
|
||||
'electricity','Electricity',
|
||||
'air_conditioner','airConditioner','AirConditioner'
|
||||
|
||||
Reference in New Issue
Block a user