Initial commit
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,36 @@
|
||||
create type _node_type as enum ('junction', 'reservoir', 'tank');
|
||||
|
||||
create type _link_type as enum ('pipe', 'pump', 'valve');
|
||||
|
||||
create type _curve_type as enum ('PUMP', 'EFFICIENCY', 'VOLUME', 'HEADLOSS');
|
||||
|
||||
create type _region_type as enum ('NONE', 'DMA', 'SA', 'VD', 'WDA');
|
||||
|
||||
create table _node
|
||||
(
|
||||
id varchar(32) primary key
|
||||
, type _node_type not null
|
||||
);
|
||||
|
||||
create table _link
|
||||
(
|
||||
id varchar(32) primary key
|
||||
, type _link_type not null
|
||||
);
|
||||
|
||||
create table _curve
|
||||
(
|
||||
id varchar(32) primary key
|
||||
, type _curve_type not null
|
||||
);
|
||||
|
||||
create table _pattern
|
||||
(
|
||||
id varchar(32) primary key
|
||||
);
|
||||
|
||||
create table _region
|
||||
(
|
||||
id varchar(32) primary key
|
||||
, type _region_type not null
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
-- [TITLE]
|
||||
|
||||
create table title
|
||||
(
|
||||
value text
|
||||
);
|
||||
|
||||
insert into title (value) values ('');
|
||||
@@ -0,0 +1,13 @@
|
||||
-- [STATUS]
|
||||
|
||||
create type link_status as enum ('OPEN', 'CLOSED', 'ACTIVE');
|
||||
|
||||
create table status
|
||||
(
|
||||
link varchar(32) primary key references _link(id)
|
||||
, status link_status
|
||||
, setting float8
|
||||
, check (status is not null or setting is not null)
|
||||
);
|
||||
|
||||
-- ddelete when delete link
|
||||
@@ -0,0 +1,8 @@
|
||||
-- [PATTERNS]
|
||||
|
||||
create table patterns
|
||||
(
|
||||
_order serial primary key
|
||||
, id varchar(32) references _pattern(id) not null
|
||||
, factor float8 not null
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
-- [CURVES]
|
||||
|
||||
create table curves
|
||||
(
|
||||
_order serial primary key
|
||||
, id varchar(32) references _curve(id) not null
|
||||
, x float8 not null
|
||||
, y float8 not null
|
||||
);
|
||||
@@ -0,0 +1,7 @@
|
||||
-- [CONTROLS]
|
||||
|
||||
create table controls
|
||||
(
|
||||
_order serial primary key
|
||||
, line text not null
|
||||
);
|
||||
@@ -0,0 +1,7 @@
|
||||
-- [RULES]
|
||||
|
||||
create table rules
|
||||
(
|
||||
_order serial primary key
|
||||
, line text not null
|
||||
);
|
||||
@@ -0,0 +1,40 @@
|
||||
-- [ENERGY]
|
||||
|
||||
create table energy
|
||||
(
|
||||
key text primary key
|
||||
, value text not null
|
||||
);
|
||||
|
||||
insert into energy (key, value) values
|
||||
('GLOBAL PRICE', '0')
|
||||
, ('GLOBAL PATTERN', '')
|
||||
, ('GLOBAL EFFIC', '75')
|
||||
, ('DEMAND CHARGE', '0')
|
||||
;
|
||||
|
||||
create table energy_pump_price
|
||||
(
|
||||
pump varchar(32) primary key references pumps(id) not null
|
||||
, price float8 not null
|
||||
);
|
||||
|
||||
-- delete when delete pump
|
||||
|
||||
create table energy_pump_pattern
|
||||
(
|
||||
pump varchar(32) primary key references pumps(id) not null
|
||||
, pattern varchar(32) references _pattern(id) not null
|
||||
);
|
||||
|
||||
-- delete when delete pump
|
||||
-- delete when delete pattern
|
||||
|
||||
create table energy_pump_effic
|
||||
(
|
||||
pump varchar(32) primary key references pumps(id) not null
|
||||
, effic varchar(32) references _curve(id) not null
|
||||
);
|
||||
|
||||
-- delete when delete pump
|
||||
-- delete when delete curve
|
||||
@@ -0,0 +1,9 @@
|
||||
-- [EMITTERS]
|
||||
|
||||
create table emitters
|
||||
(
|
||||
junction varchar(32) primary key references junctions(id)
|
||||
, coefficient float8 not null
|
||||
);
|
||||
|
||||
-- delete when delete junction
|
||||
@@ -0,0 +1,9 @@
|
||||
-- [QUALITY]
|
||||
|
||||
create table quality
|
||||
(
|
||||
node varchar(32) primary key references _node(id)
|
||||
, quality float8 not null
|
||||
);
|
||||
|
||||
-- delete when delete ndoe
|
||||
@@ -0,0 +1,14 @@
|
||||
-- [SOURCES]
|
||||
|
||||
create type sources_type as enum ('CONCEN', 'MASS', 'FLOWPACED', 'SETPOINT');
|
||||
|
||||
create table sources
|
||||
(
|
||||
node varchar(32) primary key references _node(id)
|
||||
, s_type sources_type not null
|
||||
, strength float8 not null
|
||||
, pattern varchar(32) references _pattern(id)
|
||||
);
|
||||
|
||||
-- delete when delete node
|
||||
-- unset pattern when delete pattern
|
||||
@@ -0,0 +1,41 @@
|
||||
-- [REACTIONS]
|
||||
|
||||
create table reactions
|
||||
(
|
||||
key text primary key
|
||||
, value text not null
|
||||
);
|
||||
|
||||
insert into reactions (key, value) values
|
||||
('ORDER BULK', '1')
|
||||
, ('ORDER WALL', '1')
|
||||
, ('ORDER TANK', '1')
|
||||
, ('GLOBAL BULK', '0')
|
||||
, ('GLOBAL WALL', '0')
|
||||
, ('LIMITING POTENTIAL', '0')
|
||||
, ('ROUGHNESS CORRELATION', '0')
|
||||
;
|
||||
|
||||
create table reactions_pipe_bulk
|
||||
(
|
||||
pipe varchar(32) primary key references pipes(id) not null
|
||||
, value float8 not null
|
||||
);
|
||||
|
||||
-- delete when delete pipe
|
||||
|
||||
create table reactions_pipe_wall
|
||||
(
|
||||
pipe varchar(32) primary key references pipes(id) not null
|
||||
, value float8 not null
|
||||
);
|
||||
|
||||
-- delete when delete pipe
|
||||
|
||||
create table reactions_tank
|
||||
(
|
||||
tank varchar(32) primary key references tanks(id) not null
|
||||
, value float8 not null
|
||||
);
|
||||
|
||||
-- delete when delete tank
|
||||
@@ -0,0 +1,7 @@
|
||||
-- [JUNCTIONS]
|
||||
|
||||
create table junctions
|
||||
(
|
||||
id varchar(32) primary key references _node(id)
|
||||
, elevation float8 not null
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
-- [MIXING]
|
||||
|
||||
create type mixing_model as enum ('MIXED', '2COMP', 'FIFO', 'LIFO');
|
||||
|
||||
create table mixing
|
||||
(
|
||||
tank varchar(32) primary key references tanks(id)
|
||||
, model mixing_model not null
|
||||
, value float8
|
||||
);
|
||||
|
||||
-- delete when delete tank
|
||||
@@ -0,0 +1,20 @@
|
||||
-- [TIMES]
|
||||
|
||||
create table times
|
||||
(
|
||||
key text primary key
|
||||
, value text not null
|
||||
);
|
||||
|
||||
insert into times (key, value) values
|
||||
('DURATION', '0:00')
|
||||
, ('HYDRAULIC TIMESTEP', '1:00')
|
||||
, ('QUALITY TIMESTEP', '0:05')
|
||||
, ('RULE TIMESTEP', '0:05')
|
||||
, ('PATTERN TIMESTEP', '1:00')
|
||||
, ('PATTERN START', '0:00')
|
||||
, ('REPORT TIMESTEP', '1:00')
|
||||
, ('REPORT START', '0:00')
|
||||
, ('START CLOCKTIME', '12:00 AM')
|
||||
, ('STATISTIC', 'NONE') -- NONE / AVERAGED / MINIMUM / MAXIMUM / RANGE
|
||||
;
|
||||
@@ -0,0 +1,18 @@
|
||||
-- [REPORT]
|
||||
|
||||
create table report
|
||||
(
|
||||
key text primary key
|
||||
, value text not null
|
||||
);
|
||||
|
||||
insert into report (key, value) values
|
||||
('PAGESIZE', '0')
|
||||
--, ('FILE', '')
|
||||
, ('STATUS', 'FULL')
|
||||
, ('SUMMARY', 'YES')
|
||||
, ('MESSAGES', 'YES')
|
||||
, ('ENERGY', 'YES')
|
||||
, ('NODES', 'ALL')
|
||||
, ('LINKS', 'ALL')
|
||||
;
|
||||
@@ -0,0 +1,77 @@
|
||||
-- [OPTIONS]
|
||||
|
||||
-- TODO: constraint
|
||||
|
||||
create table options
|
||||
(
|
||||
key text primary key
|
||||
, value text not null
|
||||
);
|
||||
|
||||
insert into options (key, value) values
|
||||
('UNITS', 'LPS')
|
||||
, ('PRESSURE', 'METERS')
|
||||
, ('HEADLOSS', 'H-W')
|
||||
, ('QUALITY', 'NONE')
|
||||
, ('UNBALANCED', 'STOP')
|
||||
, ('PATTERN', '1')
|
||||
, ('DEMAND MODEL', 'DDA')
|
||||
, ('DEMAND MULTIPLIER', '1.0')
|
||||
, ('EMITTER EXPONENT', '0.5')
|
||||
, ('VISCOSITY', '1.0')
|
||||
, ('DIFFUSIVITY', '1.0')
|
||||
, ('SPECIFIC GRAVITY', '1.0')
|
||||
, ('TRIALS', '40')
|
||||
, ('ACCURACY', '0.001')
|
||||
, ('HEADERROR', '0.0001')
|
||||
, ('FLOWCHANGE', '0.0001')
|
||||
, ('MINIMUM PRESSURE', '0.0001')
|
||||
, ('REQUIRED PRESSURE', '20.0')
|
||||
, ('PRESSURE EXPONENT', '0.5')
|
||||
, ('TOLERANCE', '0.01')
|
||||
, ('HTOL', '0.0005')
|
||||
, ('QTOL', '0.0001')
|
||||
, ('RQTOL', '0.0000001')
|
||||
, ('CHECKFREQ', '2')
|
||||
, ('MAXCHECK', '10')
|
||||
, ('DAMPLIMIT', '0')
|
||||
;
|
||||
|
||||
|
||||
create table options_v3
|
||||
(
|
||||
key text primary key
|
||||
, value text not null
|
||||
);
|
||||
|
||||
insert into options_v3 (key, value) values
|
||||
('FLOW_UNITS', 'LPS')
|
||||
, ('PRESSURE_UNITS', 'METERS')
|
||||
, ('HEADLOSS_MODEL', 'H-W')
|
||||
, ('SPECIFIC_GRAVITY', '1.0')
|
||||
, ('SPECIFIC_VISCOSITY', '1.0')
|
||||
, ('MAXIMUM_TRIALS', '40')
|
||||
, ('HEAD_TOLERANCE', '0.0005')
|
||||
, ('FLOW_TOLERANCE', '0.0001')
|
||||
, ('FLOW_CHANGE_LIMIT', '0.0001')
|
||||
, ('RELATIVE_ACCURACY', '0.001')
|
||||
, ('TIME_WEIGHT', '0.0')
|
||||
, ('STEP_SIZING', 'FULL')
|
||||
, ('IF_UNBALANCED', 'STOP')
|
||||
, ('DEMAND_MODEL', 'FIXED')
|
||||
, ('DEMAND_PATTERN', '1')
|
||||
, ('DEMAND_MULTIPLIER', '1.0')
|
||||
, ('MINIMUM_PRESSURE', '0.0001')
|
||||
, ('SERVICE_PRESSURE', '20.0')
|
||||
, ('PRESSURE_EXPONENT', '0.5')
|
||||
, ('LEAKAGE_MODEL', 'NONE')
|
||||
, ('LEAKAGE_COEFF1', '0.0')
|
||||
, ('LEAKAGE_COEFF2', '0.0')
|
||||
, ('EMITTER_EXPONENT', '0.5')
|
||||
, ('QUALITY_MODEL', 'NONE')
|
||||
, ('QUALITY_NAME', 'CHEMICAL')
|
||||
, ('QUALITY_UNITS', 'MG/L')
|
||||
, ('TRACE_NODE', '')
|
||||
, ('SPECIFIC_DIFFUSIVITY', '1.0')
|
||||
, ('QUALITY_TOLERANCE', '0.01')
|
||||
;
|
||||
@@ -0,0 +1,11 @@
|
||||
-- [COORDINATES]
|
||||
|
||||
create table coordinates
|
||||
(
|
||||
node varchar(32) primary key references _node(id)
|
||||
, coord geometry
|
||||
);
|
||||
|
||||
-- delete when delete node
|
||||
|
||||
create index coordinates_gist on coordinates using gist(coord);
|
||||
@@ -0,0 +1,11 @@
|
||||
-- [VERTICES]
|
||||
|
||||
create table vertices
|
||||
(
|
||||
_order serial primary key
|
||||
, link varchar(32) references _link(id) not null
|
||||
, x float8 not null
|
||||
, y float8 not null
|
||||
);
|
||||
|
||||
-- delete when delete link
|
||||
@@ -0,0 +1,12 @@
|
||||
-- [LABELS]
|
||||
|
||||
create table labels
|
||||
(
|
||||
x float8 not null
|
||||
, y float8 not null
|
||||
, label text not null
|
||||
, node varchar(32) references _node(id)
|
||||
, primary key (x, y)
|
||||
);
|
||||
|
||||
-- unset node when delete node
|
||||
@@ -0,0 +1,8 @@
|
||||
-- [BACKDROP]
|
||||
|
||||
create table backdrop
|
||||
(
|
||||
content text primary key
|
||||
);
|
||||
|
||||
insert into backdrop (content) values ('');
|
||||
@@ -0,0 +1 @@
|
||||
-- [END]
|
||||
@@ -0,0 +1,9 @@
|
||||
create type scada_device_type as enum ('PRESSURE', 'DEMAND', 'QUALITY', 'LEVEL', 'FLOW', 'UNKNOWN');
|
||||
|
||||
create table scada_device
|
||||
(
|
||||
id text primary key
|
||||
, name text
|
||||
, address text
|
||||
, sd_type scada_device_type
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
-- [RESERVOIRS]
|
||||
|
||||
create table reservoirs
|
||||
(
|
||||
id varchar(32) primary key references _node(id)
|
||||
, head float8 not null
|
||||
, pattern varchar(32) references _pattern(id)
|
||||
);
|
||||
|
||||
-- unset pattern when delete pattern
|
||||
@@ -0,0 +1,7 @@
|
||||
create table scada_device_data
|
||||
(
|
||||
device_id text not null references scada_device(id)
|
||||
, time timestamp not null
|
||||
, value float8 not null
|
||||
, primary key (device_id, time)
|
||||
);
|
||||
@@ -0,0 +1,14 @@
|
||||
create type scada_model_type as enum ('JUNCTION', 'RESERVOIR', 'TANK', 'PIPE', 'PUMP', 'VALVE');
|
||||
|
||||
create type scada_element_status as enum ('OFF', 'ON');
|
||||
|
||||
create table scada_element
|
||||
(
|
||||
id text primary key
|
||||
, x float8 not null
|
||||
, y float8 not null
|
||||
, device_id text references scada_device(id)
|
||||
, model_id varchar(32) -- add constraint in API
|
||||
, model_type scada_model_type
|
||||
, status scada_element_status not null default 'OFF'
|
||||
);
|
||||
@@ -0,0 +1,48 @@
|
||||
create type region_type as enum ('NONE', 'DMA', 'SA', 'VD', 'WDA');
|
||||
|
||||
create table region
|
||||
(
|
||||
id text primary key
|
||||
, boundary geometry not null --unique
|
||||
, r_type region_type not null default 'NONE'
|
||||
);
|
||||
|
||||
create index region_gist on region using gist(boundary);
|
||||
|
||||
|
||||
create table temp_region
|
||||
(
|
||||
id text primary key
|
||||
, boundary geometry not null unique
|
||||
);
|
||||
|
||||
create index temp_region_gist on temp_region using gist(boundary);
|
||||
|
||||
|
||||
create table temp_node
|
||||
(
|
||||
node varchar(32) primary key references _node(id)
|
||||
);
|
||||
|
||||
|
||||
create table temp_link_1
|
||||
(
|
||||
link varchar(32) primary key references _link(id)
|
||||
, geom geometry not null unique
|
||||
);
|
||||
|
||||
|
||||
create table temp_link_2
|
||||
(
|
||||
link varchar(32) primary key references _link(id)
|
||||
, geom geometry not null unique
|
||||
);
|
||||
|
||||
|
||||
create table temp_vd_topology
|
||||
(
|
||||
id serial
|
||||
, source integer
|
||||
, target integer
|
||||
, cost float8
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
create table region_dma
|
||||
(
|
||||
id text primary key references region(id)
|
||||
, parent text --references region_dma(id)
|
||||
, nodes text not null
|
||||
);
|
||||
@@ -0,0 +1,7 @@
|
||||
create table region_sa
|
||||
(
|
||||
id text primary key references region(id)
|
||||
, time_index integer not null
|
||||
, source varchar(32) not null -- references _node(id)
|
||||
, nodes text not null
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
create table region_vd
|
||||
(
|
||||
id text primary key references region(id)
|
||||
, center varchar(32) not null -- references _node(id)
|
||||
, nodes text not null
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
create table region_wda
|
||||
(
|
||||
id text primary key references region(id)
|
||||
, demand float8 not null default 0.0
|
||||
);
|
||||
@@ -0,0 +1,11 @@
|
||||
-- [HISTORY_PATTERNS_FLOWS]
|
||||
-- WMH
|
||||
-- 2025/01/12
|
||||
-- Save pattern and pattern based history flow data. Use it for flow update pattern
|
||||
create table history_patterns_flows
|
||||
(
|
||||
_order serial primary key
|
||||
, id varchar(32) references _pattern(id) not null
|
||||
, factor float8 not null
|
||||
, flow float8 not null
|
||||
);
|
||||
@@ -0,0 +1,44 @@
|
||||
-- [SCADA_INFO]
|
||||
-- 王名豪
|
||||
-- 2025/01/12
|
||||
-- 存储水厂提供的SCADA设备相关数据,包括设备ID、类型(reservoir_liquid_level/tank_liquid_level/fixed_pump/variable_pump/source_outflow/pipe_flow/pressure/demand/quality、关联的模型元素ID、关联的模式、
|
||||
-- 关联的干管流量计对应的模型元素ID(即demand(大用户)处于某个pipe_flow(干管流量计)之下,demand不是根据水量大小来确定的,而是根据设备情况和是否单独设置pattern决定
|
||||
-- 关联的出厂流量计对应的模型元素ID若干个(即确认该设备的水源是哪几个,根据水源不同,设置为不同的分区)
|
||||
-- SCADA设备通过数据接口查询的ID、传输模式(实时/非实时)、传输频率(多久传回一次数据)
|
||||
-- X坐标、Y坐标、基于X坐标和Y坐标生成geometry类型的数据
|
||||
|
||||
create table scada_info
|
||||
(
|
||||
id varchar(32) primary key
|
||||
, type varchar(32) not null
|
||||
, associated_element_id varchar(32) not null
|
||||
, associated_pattern varchar(32)
|
||||
, associated_pipe_flow_id varchar(32)
|
||||
, associated_source_outflow_id1 varchar(32)
|
||||
, associated_source_outflow_id2 varchar(32)
|
||||
, associated_source_outflow_id3 varchar(32)
|
||||
, associated_source_outflow_id4 varchar(32)
|
||||
, associated_source_outflow_id5 varchar(32)
|
||||
, associated_source_outflow_id6 varchar(32)
|
||||
, associated_source_outflow_id7 varchar(32)
|
||||
, associated_source_outflow_id8 varchar(32)
|
||||
, associated_source_outflow_id9 varchar(32)
|
||||
, associated_source_outflow_id10 varchar(32)
|
||||
, associated_source_outflow_id11 varchar(32)
|
||||
, associated_source_outflow_id12 varchar(32)
|
||||
, associated_source_outflow_id13 varchar(32)
|
||||
, associated_source_outflow_id14 varchar(32)
|
||||
, associated_source_outflow_id15 varchar(32)
|
||||
, associated_source_outflow_id16 varchar(32)
|
||||
, associated_source_outflow_id17 varchar(32)
|
||||
, associated_source_outflow_id18 varchar(32)
|
||||
, associated_source_outflow_id19 varchar(32)
|
||||
, associated_source_outflow_id20 varchar(32)
|
||||
, API_query_id varchar(32)
|
||||
, transmission_mode varchar(32) not null
|
||||
, transmission_frequency text not null
|
||||
, reliability int not null
|
||||
, X_coor float8 not null
|
||||
, Y_coor float8 not null
|
||||
, coord geometry
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
-- [USERS]
|
||||
-- 王名豪
|
||||
-- 2025/03/23
|
||||
-- 存储系统的用户信息,如用户名,密码
|
||||
|
||||
create table users (
|
||||
user_id SERIAL PRIMARY KEY,
|
||||
username varchar(32) not null unique,
|
||||
password varchar(32) not null
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
-- [TANKS]
|
||||
|
||||
create type tanks_overflow as enum ('YES', 'NO');
|
||||
|
||||
create table tanks
|
||||
(
|
||||
id varchar(32) primary key references _node(id)
|
||||
, elevation float8 not null
|
||||
, init_level float8 not null
|
||||
, min_level float8 not null
|
||||
, max_level float8 not null
|
||||
, diameter float8 not null
|
||||
, min_vol float8 not null
|
||||
, vol_curve varchar(32) references _curve(id)
|
||||
, overflow tanks_overflow
|
||||
);
|
||||
|
||||
-- unset vol_curve when delete curve
|
||||
@@ -0,0 +1,14 @@
|
||||
-- [SCHEME_LIST]
|
||||
-- 王名豪
|
||||
-- 2025/03/23
|
||||
-- 存储进行手动模拟后的方案列表
|
||||
|
||||
create table scheme_list (
|
||||
scheme_id SERIAL PRIMARY KEY,
|
||||
scheme_name varchar(32) not null,
|
||||
scheme_type varchar(32) not null,
|
||||
username varchar(32) not null REFERENCES "users"(username) ON UPDATE CASCADE ON DELETE RESTRICT,
|
||||
create_time TIMESTAMP WITH TIME ZONE not null DEFAULT date_trunc('minute', CURRENT_TIMESTAMP),
|
||||
scheme_start_time varchar(50) not null,
|
||||
scheme_detail JSON
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
-- [PIPE_RISK_PROBABILITY]
|
||||
-- 王名豪
|
||||
-- 2025/04/16
|
||||
-- 存储管道风险评价结果
|
||||
|
||||
CREATE TABLE pipe_risk_probability (
|
||||
id SERIAL PRIMARY KEY,
|
||||
pipeID VARCHAR(255),
|
||||
pipeage FLOAT,
|
||||
risk_probability_now FLOAT,
|
||||
x FLOAT[], -- Since x is a list, it's stored as text (stringified list)
|
||||
y FLOAT[] -- Similarly, y will be stored as text (stringified list)
|
||||
);
|
||||
@@ -0,0 +1,14 @@
|
||||
-- [SENSOR_PLACEMENT]
|
||||
-- 王名豪
|
||||
-- 2025/04/18
|
||||
-- 存储测压点的布置方案
|
||||
|
||||
CREATE TABLE sensor_placement (
|
||||
id SERIAL PRIMARY KEY,
|
||||
scheme_name varchar(32) not null,
|
||||
sensor_number int,
|
||||
min_diameter int,
|
||||
username varchar(32) not null REFERENCES "users"(username) ON UPDATE CASCADE ON DELETE RESTRICT,
|
||||
create_time TIMESTAMP WITH TIME ZONE not null DEFAULT date_trunc('minute', CURRENT_TIMESTAMP),
|
||||
sensor_location TEXT[]
|
||||
);
|
||||
@@ -0,0 +1,13 @@
|
||||
-- [BURST_LOCATE_RESULT]
|
||||
-- 王名豪
|
||||
-- 2025/04/19
|
||||
-- 存储爆管侦测定位结果
|
||||
|
||||
CREATE TABLE burst_locate_result (
|
||||
id SERIAL PRIMARY KEY,
|
||||
type varchar(32) not null,
|
||||
burst_incident varchar(32) not null,
|
||||
leakage float,
|
||||
detect_time TIMESTAMP WITH TIME ZONE not null DEFAULT date_trunc('minute', CURRENT_TIMESTAMP),
|
||||
locate_result JSON
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
-- [PIPES]
|
||||
|
||||
create type pipes_status as enum ('OPEN', 'CLOSED', 'CV');
|
||||
|
||||
create table pipes
|
||||
(
|
||||
id varchar(32) primary key references _link(id)
|
||||
, node1 varchar(32) references _node(id) not null
|
||||
, node2 varchar(32) references _node(id) not null
|
||||
, length float8 not null
|
||||
, diameter float8 not null
|
||||
, roughness float8 not null
|
||||
, minor_loss float8 not null
|
||||
, status pipes_status not null
|
||||
, check (node1 <> node2)
|
||||
);
|
||||
|
||||
-- delete when delete node1
|
||||
-- delete when delete node2
|
||||
@@ -0,0 +1,19 @@
|
||||
-- [PUMPS]
|
||||
|
||||
create table pumps
|
||||
(
|
||||
id varchar(32) primary key references _link(id)
|
||||
, node1 varchar(32) references _node(id) not null
|
||||
, node2 varchar(32) references _node(id) not null
|
||||
, power float8
|
||||
, head varchar(32) references _curve(id)
|
||||
, speed float8
|
||||
, pattern varchar(32) references _pattern(id)
|
||||
, check (power is not null or head is not null)
|
||||
, check ((power is not null and head is not null) is false)
|
||||
);
|
||||
|
||||
-- delete when delete node1
|
||||
-- delete when delete node2
|
||||
-- unset head when delete curve
|
||||
-- unset pattern when delete pattern
|
||||
@@ -0,0 +1,17 @@
|
||||
-- [VALVES]
|
||||
|
||||
create type valves_type as enum ('PRV', 'PSV', 'PBV', 'FCV', 'TCV', 'GPV');
|
||||
|
||||
create table valves
|
||||
(
|
||||
id varchar(32) primary key references _link(id)
|
||||
, node1 varchar(32) references _node(id) not null
|
||||
, node2 varchar(32) references _node(id) not null
|
||||
, diameter float8 not null
|
||||
, v_type valves_type not null
|
||||
, setting text not null
|
||||
, minor_loss float8 not null
|
||||
);
|
||||
|
||||
-- delete when delete node1
|
||||
-- delete when delete node2
|
||||
@@ -0,0 +1,17 @@
|
||||
-- [TAGS]
|
||||
|
||||
create table tags_node
|
||||
(
|
||||
id varchar(32) primary key references _node(id)
|
||||
, tag text not null
|
||||
);
|
||||
|
||||
-- delete when delete node
|
||||
|
||||
create table tags_link
|
||||
(
|
||||
id varchar(32) primary key references _link(id)
|
||||
, tag text not null
|
||||
);
|
||||
|
||||
-- delete when delete link
|
||||
@@ -0,0 +1,13 @@
|
||||
-- [DEMANDS]
|
||||
|
||||
create table demands
|
||||
(
|
||||
_order serial primary key
|
||||
, junction varchar(32) references junctions(id) not null
|
||||
, demand float8 not null
|
||||
, pattern varchar(32) references _pattern(id)
|
||||
, category text
|
||||
);
|
||||
|
||||
-- delete when delete junction
|
||||
-- unset pattern when delete pattern
|
||||
@@ -0,0 +1,5 @@
|
||||
create table extension_data
|
||||
(
|
||||
key text primary key
|
||||
, value text not null
|
||||
);
|
||||
@@ -0,0 +1,55 @@
|
||||
create table operation
|
||||
(
|
||||
id bigserial primary key
|
||||
, redo text not null
|
||||
, undo text not null
|
||||
, parent integer references operation(id) on delete cascade
|
||||
, redo_child integer references operation(id) -- must update before delete
|
||||
, redo_cs text not null
|
||||
, undo_cs text not null
|
||||
);
|
||||
|
||||
insert into operation (id, redo, undo, redo_cs, undo_cs) values (0, '', '', '', '');
|
||||
|
||||
create table current_operation
|
||||
(
|
||||
id bigint primary key references operation(id) -- must update before delete
|
||||
);
|
||||
|
||||
insert into current_operation (id) values (0);
|
||||
|
||||
create table snapshot_operation
|
||||
(
|
||||
id bigint primary key references operation(id) on delete cascade
|
||||
, tag text not null unique
|
||||
);
|
||||
|
||||
create table restore_operation
|
||||
(
|
||||
id bigint primary key references operation(id) -- set after reading inp
|
||||
);
|
||||
|
||||
insert into restore_operation (id) values (0);
|
||||
|
||||
|
||||
create table batch_operation
|
||||
(
|
||||
id bigserial primary key
|
||||
, redo text not null
|
||||
, undo text not null
|
||||
, parent integer references operation(id) on delete cascade
|
||||
, redo_child integer references operation(id) -- must update before delete
|
||||
, redo_cs text not null
|
||||
, undo_cs text not null
|
||||
);
|
||||
|
||||
insert into batch_operation (id, redo, undo, redo_cs, undo_cs) values (0, '', '', '', '');
|
||||
|
||||
create type operation_table_option as enum ('operation', 'batch_operation');
|
||||
|
||||
create table operation_table
|
||||
(
|
||||
option operation_table_option primary key
|
||||
);
|
||||
|
||||
insert into operation_table (option) values ('operation');
|
||||
@@ -0,0 +1,15 @@
|
||||
drop table if exists _region;
|
||||
|
||||
drop table if exists _pattern;
|
||||
|
||||
drop table if exists _curve;
|
||||
|
||||
drop table if exists _link;
|
||||
|
||||
drop table if exists _node;
|
||||
|
||||
drop type if exists _curve_type;
|
||||
|
||||
drop type if exists _link_type;
|
||||
|
||||
drop type if exists _node_type;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [TITLE]
|
||||
|
||||
drop table if exists title;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [STATUS]
|
||||
|
||||
drop table if exists status;
|
||||
|
||||
drop type if exists link_status;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [PATTERNS]
|
||||
|
||||
drop table if exists patterns;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [CURVES]
|
||||
|
||||
drop table if exists curves;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [CONTROLS]
|
||||
|
||||
drop table if exists controls;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [RULES]
|
||||
|
||||
drop table if exists rules;
|
||||
@@ -0,0 +1,9 @@
|
||||
-- [ENERGY]
|
||||
|
||||
drop table if exists energy_pump_effic;
|
||||
|
||||
drop table if exists energy_pump_pattern;
|
||||
|
||||
drop table if exists energy_pump_price;
|
||||
|
||||
drop table if exists energy;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [EMITTERS]
|
||||
|
||||
drop table if exists emitters;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [QUALITY]
|
||||
|
||||
drop table if exists quality;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [SOURCES]
|
||||
|
||||
drop table if exists sources;
|
||||
|
||||
drop type if exists sources_type;
|
||||
@@ -0,0 +1,9 @@
|
||||
-- [REACTIONS]
|
||||
|
||||
drop table if exists reactions_tank;
|
||||
|
||||
drop table if exists reactions_pipe_wall;
|
||||
|
||||
drop table if exists reactions_pipe_bulk;
|
||||
|
||||
drop table if exists reactions;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [JUNCTIONS]
|
||||
|
||||
drop table if exists junctions;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [MIXING]
|
||||
|
||||
drop table if exists mixing;
|
||||
|
||||
drop type if exists mixing_model;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [TIMES]
|
||||
|
||||
drop table if exists times;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [REPORT]
|
||||
|
||||
drop table if exists report;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [OPTIONS]
|
||||
|
||||
drop table if exists options_v3;
|
||||
|
||||
drop table if exists options;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [COORDINATES]
|
||||
|
||||
drop index if exists coordinates_gist;
|
||||
|
||||
drop table if exists coordinates;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [VERTICES]
|
||||
|
||||
drop table if exists vertices;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [LABELS]
|
||||
|
||||
drop table if exists labels;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [BACKDROP]
|
||||
|
||||
drop table if exists backdrop;
|
||||
@@ -0,0 +1 @@
|
||||
-- [END]
|
||||
@@ -0,0 +1,3 @@
|
||||
drop table if exists scada_device;
|
||||
|
||||
drop type if exists scada_device_type;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [RESERVOIRS]
|
||||
|
||||
drop table if exists reservoirs;
|
||||
@@ -0,0 +1 @@
|
||||
drop table if exists scada_device_data;
|
||||
@@ -0,0 +1,5 @@
|
||||
drop table if exists scada_element;
|
||||
|
||||
drop type if exists scada_element_status;
|
||||
|
||||
drop type if exists scada_model_type;
|
||||
@@ -0,0 +1,17 @@
|
||||
drop table if exists temp_vd_topology;
|
||||
|
||||
drop table if exists temp_link_2;
|
||||
|
||||
drop table if exists temp_link_1;
|
||||
|
||||
drop table if exists temp_node;
|
||||
|
||||
drop index if exists temp_region_gist;
|
||||
|
||||
drop table if exists temp_region;
|
||||
|
||||
drop index if exists region_gist;
|
||||
|
||||
drop table if exists region;
|
||||
|
||||
drop type if exists region_type;
|
||||
@@ -0,0 +1 @@
|
||||
drop table if exists region_dma;
|
||||
@@ -0,0 +1 @@
|
||||
drop table if exists region_sa;
|
||||
@@ -0,0 +1 @@
|
||||
drop table if exists region_vd;
|
||||
@@ -0,0 +1 @@
|
||||
drop table if exists region_wda;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- WMH
|
||||
-- 2025/01/12
|
||||
drop table if exists history_patterns_flows;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- WMH
|
||||
-- 2025/01/12
|
||||
drop table if exists scada_info;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- 王名豪
|
||||
-- 2025/03/23
|
||||
-- 删除user这张表
|
||||
|
||||
drop table if exists users;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [TANKS]
|
||||
|
||||
drop table if exists tanks;
|
||||
|
||||
drop type if exists tanks_overflow;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- [SCHEME_LIST]
|
||||
-- 王名豪
|
||||
-- 2025/03/23
|
||||
-- 删除scheme_list这张表
|
||||
|
||||
drop table if exists scheme_list;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- [PIPE_RISK_PROBABILITY]
|
||||
-- 王名豪
|
||||
-- 2025/04/16
|
||||
-- 删除pipe_risk_probability这张表
|
||||
|
||||
drop table if exists pipe_risk_probability;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- [SENSOR_PLACEMENT]
|
||||
-- 王名豪
|
||||
-- 2025/04/18
|
||||
-- 删除sensor_placement这张表
|
||||
|
||||
drop table if exists sensor_placement;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- [BURST_LOCATE_RESULT]
|
||||
-- 王名豪
|
||||
-- 2025/04/19
|
||||
-- 删除burst_locate_result这张表
|
||||
|
||||
drop table if exists burst_locate_result;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [PIPES]
|
||||
|
||||
drop table if exists pipes;
|
||||
|
||||
drop type if exists pipes_status;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [PUMPS]
|
||||
|
||||
drop table if exists pumps;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [VALVES]
|
||||
|
||||
drop table if exists valves;
|
||||
|
||||
drop type if exists valves_type;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- [TAGS]
|
||||
|
||||
drop table if exists tags_link;
|
||||
|
||||
drop table if exists tags_node;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- [DEMANDS]
|
||||
|
||||
drop table if exists demands;
|
||||
@@ -0,0 +1 @@
|
||||
drop table if exists extension_data;
|
||||
@@ -0,0 +1,13 @@
|
||||
drop table if exists operation_table;
|
||||
|
||||
drop type if exists operation_table_option;
|
||||
|
||||
drop table if exists batch_operation;
|
||||
|
||||
drop table if exists restore_operation;
|
||||
|
||||
drop table if exists snapshot_operation;
|
||||
|
||||
drop table if exists current_operation;
|
||||
|
||||
drop table if exists operation;
|
||||
Reference in New Issue
Block a user