feat: 实现 G5 数据库同步与房间状态聚合逻辑,支持多环境异步双写,优化数据插入与去重逻辑,移除冗余字段
This commit is contained in:
63
docs/rcu_action_events_g5.sql
Normal file
63
docs/rcu_action_events_g5.sql
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : FnOS 80
|
||||
Source Server Type : PostgreSQL
|
||||
Source Server Version : 150017 (150017)
|
||||
Source Host : 10.8.8.80:5434
|
||||
Source Catalog : log_platform
|
||||
Source Schema : rcu_action
|
||||
|
||||
Target Server Type : PostgreSQL
|
||||
Target Server Version : 150017 (150017)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 10/03/2026 16:01:04
|
||||
*/
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for rcu_action_events_g5
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS "rcu_action"."rcu_action_events_g5";
|
||||
CREATE TABLE "rcu_action"."rcu_action_events_g5" (
|
||||
"guid" int4 NOT NULL DEFAULT nextval('"rcu_action".rcu_action_events_g5_guid_seq1'::regclass),
|
||||
"ts_ms" int8 NOT NULL,
|
||||
"write_ts_ms" int8 NOT NULL,
|
||||
"hotel_id" int4 NOT NULL,
|
||||
"room_id" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
|
||||
"device_id" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
|
||||
"direction" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
|
||||
"cmd_word" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
|
||||
"frame_id" int4 NOT NULL,
|
||||
"udp_raw" text COLLATE "pg_catalog"."default" NOT NULL,
|
||||
"action_type" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
|
||||
"sys_lock_status" int2,
|
||||
"report_count" int2,
|
||||
"dev_type" int2,
|
||||
"dev_addr" int2,
|
||||
"dev_loop" int4,
|
||||
"dev_data" int4,
|
||||
"fault_count" int2,
|
||||
"error_type" int2,
|
||||
"error_data" int2,
|
||||
"type_l" int2,
|
||||
"type_h" int2,
|
||||
"details" jsonb,
|
||||
"extra" jsonb,
|
||||
"loop_name" varchar(255) COLLATE "pg_catalog"."default"
|
||||
)
|
||||
TABLESPACE "ts_hot"
|
||||
;
|
||||
|
||||
-- ----------------------------
|
||||
-- Indexes structure for table rcu_action_events_g5
|
||||
-- ----------------------------
|
||||
CREATE INDEX "idx_g5_prod_ts_ms" ON "rcu_action"."rcu_action_events_g5" USING btree (
|
||||
"ts_ms" "pg_catalog"."int8_ops" DESC NULLS FIRST
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
-- Primary Key structure for table rcu_action_events_g5
|
||||
-- ----------------------------
|
||||
ALTER TABLE "rcu_action"."rcu_action_events_g5" ADD CONSTRAINT "rcu_action_events_g5_pkey" PRIMARY KEY ("ts_ms", "guid");
|
||||
88
docs/room_status_moment_g5.sql
Normal file
88
docs/room_status_moment_g5.sql
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : FnOS 80
|
||||
Source Server Type : PostgreSQL
|
||||
Source Server Version : 150017 (150017)
|
||||
Source Host : 10.8.8.80:5434
|
||||
Source Catalog : log_platform
|
||||
Source Schema : room_status
|
||||
|
||||
Target Server Type : PostgreSQL
|
||||
Target Server Version : 150017 (150017)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 10/03/2026 10:32:13
|
||||
*/
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for room_status_moment_g5
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS "room_status"."room_status_moment_g5";
|
||||
CREATE TABLE "room_status"."room_status_moment_g5" (
|
||||
"hotel_id" int2 NOT NULL,
|
||||
"room_id" text COLLATE "pg_catalog"."default" NOT NULL,
|
||||
"device_id" text COLLATE "pg_catalog"."default" NOT NULL,
|
||||
"ts_ms" int8 NOT NULL DEFAULT ((EXTRACT(epoch FROM clock_timestamp()) * (1000)::numeric))::bigint,
|
||||
"sys_lock_status" int2,
|
||||
"online_status" int2,
|
||||
"launcher_version" text COLLATE "pg_catalog"."default",
|
||||
"app_version" text COLLATE "pg_catalog"."default",
|
||||
"config_version" text COLLATE "pg_catalog"."default",
|
||||
"register_ts_ms" int8,
|
||||
"upgrade_ts_ms" int8,
|
||||
"config_ts_ms" int8,
|
||||
"ip" text COLLATE "pg_catalog"."default",
|
||||
"pms_status" int2,
|
||||
"power_state" int2,
|
||||
"cardless_state" int2,
|
||||
"service_mask" int8,
|
||||
"insert_card" int2,
|
||||
"bright_g" int2,
|
||||
"agreement_ver" text COLLATE "pg_catalog"."default",
|
||||
"air_address" _text COLLATE "pg_catalog"."default",
|
||||
"air_state" _int2,
|
||||
"air_model" _int2,
|
||||
"air_speed" _int2,
|
||||
"air_set_temp" _int2,
|
||||
"air_now_temp" _int2,
|
||||
"air_solenoid_valve" _int2,
|
||||
"elec_address" _text COLLATE "pg_catalog"."default",
|
||||
"elec_voltage" _float8,
|
||||
"elec_ampere" _float8,
|
||||
"elec_power" _float8,
|
||||
"elec_phase" _float8,
|
||||
"elec_energy" _float8,
|
||||
"elec_sum_energy" _float8,
|
||||
"carbon_state" int2,
|
||||
"dev_loops" jsonb,
|
||||
"energy_carbon_sum" float8,
|
||||
"energy_nocard_sum" float8,
|
||||
"external_device" jsonb DEFAULT '{}'::jsonb,
|
||||
"faulty_device_count" jsonb DEFAULT '{}'::jsonb
|
||||
)
|
||||
WITH (fillfactor=90)
|
||||
TABLESPACE "ts_hot"
|
||||
;
|
||||
|
||||
-- ----------------------------
|
||||
-- Indexes structure for table room_status_moment_g5
|
||||
-- ----------------------------
|
||||
CREATE INDEX "idx_rsm_g5_dashboard_query" ON "room_status"."room_status_moment_g5" USING btree (
|
||||
"hotel_id" "pg_catalog"."int2_ops" ASC NULLS LAST,
|
||||
"online_status" "pg_catalog"."int2_ops" ASC NULLS LAST,
|
||||
"power_state" "pg_catalog"."int2_ops" ASC NULLS LAST
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
-- Triggers structure for table room_status_moment_g5
|
||||
-- ----------------------------
|
||||
CREATE TRIGGER "trg_update_rsm_ts_ms" BEFORE UPDATE ON "room_status"."room_status_moment_g5"
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE "room_status"."update_ts_ms_g5"();
|
||||
|
||||
-- ----------------------------
|
||||
-- Primary Key structure for table room_status_moment_g5
|
||||
-- ----------------------------
|
||||
ALTER TABLE "room_status"."room_status_moment_g5" ADD CONSTRAINT "room_status_moment_g5_pkey" PRIMARY KEY ("hotel_id", "room_id");
|
||||
Reference in New Issue
Block a user