feat: 新增客户用电回路全链路功能

新增客户用电回路表及相关数据库迁移、后端服务、控制器、DTO、实体类和权限配置;新增前端API封装,同时调整路由名称以匹配新业务模块,复用现有菜单权限避免403错误。
This commit is contained in:
andyesfly committed 2026-10-12 15:20:08 +08:00
1 parent 3596462eca
commit f72644c24f
12 files changed
+1975 -411

No files matched your search

+41
View File
@@ -386,6 +386,47 @@ COMMENT ON COLUMN customer_room.created_at IS '创建时间';
CREATE INDEX idx_room_customer ON customer_room (customer_id);
CREATE INDEX idx_room_building ON customer_room (building_id);
-- 12.1 客户用电回路表(空间拓扑末端节点:建筑 → 楼层 → 房间 → 回路)
DROP TABLE IF EXISTS customer_circuit CASCADE;
CREATE TABLE customer_circuit (
id BIGSERIAL PRIMARY KEY,
customer_id BIGINT NOT NULL REFERENCES customer(id),
building_id BIGINT NOT NULL REFERENCES customer_building(id),
room_id BIGINT REFERENCES customer_room(id),
floor_no VARCHAR(16),
circuit_code VARCHAR(64) NOT NULL UNIQUE,
circuit_name VARCHAR(128) NOT NULL,
loop_spec VARCHAR(128),
load_type VARCHAR(32),
rated_voltage VARCHAR(32),
rated_current VARCHAR(32),
rated_power NUMERIC(10,2),
status SMALLINT NOT NULL DEFAULT 1,
remark TEXT,
sort_order INT NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
COMMENT ON TABLE customer_circuit IS '客户用电回路表(空间拓扑末端节点)';
COMMENT ON COLUMN customer_circuit.id IS '自增主键';
COMMENT ON COLUMN customer_circuit.customer_id IS '客户 ID(→ customer)';
COMMENT ON COLUMN customer_circuit.building_id IS '所属建筑 ID(→ customer_building)';
COMMENT ON COLUMN customer_circuit.room_id IS '所属房间 ID(→ customer_room,可空)';
COMMENT ON COLUMN customer_circuit.floor_no IS '所在楼层';
COMMENT ON COLUMN customer_circuit.circuit_code IS '回路编号(全局唯一)';
COMMENT ON COLUMN customer_circuit.circuit_name IS '回路名称';
COMMENT ON COLUMN customer_circuit.loop_spec IS '回路规格';
COMMENT ON COLUMN customer_circuit.load_type IS '负荷类型';
COMMENT ON COLUMN customer_circuit.rated_voltage IS '额定电压(配置值)';
COMMENT ON COLUMN customer_circuit.rated_current IS '额定电流(配置值)';
COMMENT ON COLUMN customer_circuit.rated_power IS '额定功率 kW(配置值)';
COMMENT ON COLUMN customer_circuit.status IS '状态:1 正常 / 0 停用';
COMMENT ON COLUMN customer_circuit.remark IS '备注';
COMMENT ON COLUMN customer_circuit.sort_order IS '排序值';
COMMENT ON COLUMN customer_circuit.created_at IS '创建时间';
CREATE INDEX idx_circuit_customer ON customer_circuit (customer_id);
CREATE INDEX idx_circuit_building ON customer_circuit (building_id);
CREATE INDEX idx_circuit_room ON customer_circuit (room_id);
-- 13. 客户设备信息表(配电间、配电井、配电箱)
DROP TABLE IF EXISTS customer_equipment CASCADE;
CREATE TABLE customer_equipment (
@@ -0,0 +1,44 @@
-- 空间拓扑与用电架构:客户用电回路表 customer_circuit
-- 语义:左树最末端节点(建筑 → 楼层 → 房间 → 回路),其中"楼层"为按 floor_no 聚合的虚拟层,不单独建表。
-- 幂等:CREATE TABLE IF NOT EXISTS / CREATE INDEX IF NOT EXISTS / COMMENT 均可重复执行。
-- 说明:rated_* 为配置额定值;实时电气量(电压/电流/功率/温度)本系统暂无采集数据源,不落库。
CREATE TABLE IF NOT EXISTS customer_circuit (
id BIGSERIAL PRIMARY KEY,
customer_id BIGINT NOT NULL REFERENCES customer(id),
building_id BIGINT NOT NULL REFERENCES customer_building(id),
room_id BIGINT REFERENCES customer_room(id),
floor_no VARCHAR(16),
circuit_code VARCHAR(64) NOT NULL UNIQUE,
circuit_name VARCHAR(128) NOT NULL,
loop_spec VARCHAR(128),
load_type VARCHAR(32),
rated_voltage VARCHAR(32),
rated_current VARCHAR(32),
rated_power NUMERIC(10,2),
status SMALLINT NOT NULL DEFAULT 1,
remark TEXT,
sort_order INT NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
COMMENT ON TABLE customer_circuit IS '客户用电回路表(空间拓扑末端节点)';
COMMENT ON COLUMN customer_circuit.id IS '自增主键';
COMMENT ON COLUMN customer_circuit.customer_id IS '客户 ID(→ customer)';
COMMENT ON COLUMN customer_circuit.building_id IS '所属建筑 ID(→ customer_building)';
COMMENT ON COLUMN customer_circuit.room_id IS '所属房间 ID(→ customer_room,可空:公共区域回路不挂房间)';
COMMENT ON COLUMN customer_circuit.floor_no IS '所在楼层(冗余,便于按楼层分组)';
COMMENT ON COLUMN customer_circuit.circuit_code IS '回路编号(全局唯一,如 CIR-0219)';
COMMENT ON COLUMN customer_circuit.circuit_name IS '回路名称';
COMMENT ON COLUMN customer_circuit.loop_spec IS '回路规格(如 三相380V / 铜芯4×25+1×16)';
COMMENT ON COLUMN customer_circuit.load_type IS '负荷类型(照明/动力/空调/插座等)';
COMMENT ON COLUMN customer_circuit.rated_voltage IS '额定电压(配置值)';
COMMENT ON COLUMN customer_circuit.rated_current IS '额定电流(配置值)';
COMMENT ON COLUMN customer_circuit.rated_power IS '额定功率 kW(配置值)';
COMMENT ON COLUMN customer_circuit.status IS '状态:1 正常 / 0 停用';
COMMENT ON COLUMN customer_circuit.remark IS '备注';
COMMENT ON COLUMN customer_circuit.sort_order IS '排序值';
COMMENT ON COLUMN customer_circuit.created_at IS '创建时间';
CREATE INDEX IF NOT EXISTS idx_circuit_customer ON customer_circuit (customer_id);
CREATE INDEX IF NOT EXISTS idx_circuit_building ON customer_circuit (building_id);
CREATE INDEX IF NOT EXISTS idx_circuit_room ON customer_circuit (room_id);