|
|
@@ -0,0 +1,69 @@
|
|
|
+-- 101903 功率预测上报: 新增上报批次表/字典, report 表加 batch_no 列 (aicoding/101903.md)
|
|
|
+-- 可重复执行
|
|
|
+
|
|
|
+-- -----------------------------------------------------
|
|
|
+-- 1. 上报批次表 data_power_forecast_report_batch
|
|
|
+-- -----------------------------------------------------
|
|
|
+CREATE TABLE IF NOT EXISTS data_power_forecast_report_batch (
|
|
|
+ id SERIAL NOT NULL,
|
|
|
+ station_code VARCHAR(64) NOT NULL,
|
|
|
+ station_name VARCHAR(255),
|
|
|
+ batch_no VARCHAR(128) NOT NULL,
|
|
|
+ type VARCHAR(16) NOT NULL,
|
|
|
+ report_day INTEGER NOT NULL,
|
|
|
+ est_report_time VARCHAR(16) NOT NULL,
|
|
|
+ status INTEGER NOT NULL DEFAULT 1,
|
|
|
+ generate_source VARCHAR(16) NOT NULL DEFAULT 'auto',
|
|
|
+ create_time TIMESTAMP NOT NULL DEFAULT now(),
|
|
|
+ update_time TIMESTAMP NOT NULL DEFAULT now(),
|
|
|
+ remark VARCHAR(512),
|
|
|
+ CONSTRAINT pk_data_power_forecast_report_batch PRIMARY KEY (id)
|
|
|
+);
|
|
|
+
|
|
|
+-- 单场站幂等保险(任务按 station_code + report_day + est_report_time + type 查重)
|
|
|
+CREATE UNIQUE INDEX IF NOT EXISTS uk_data_power_forecast_report_batch
|
|
|
+ ON data_power_forecast_report_batch (station_code, report_day, est_report_time, type);
|
|
|
+
|
|
|
+COMMENT ON TABLE data_power_forecast_report_batch IS '功率预测上报批次';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.id IS '唯一标识';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.station_code IS '场站编码';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.station_name IS '场站名称';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.batch_no IS '上报批次号';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.type IS '类型(short短期,ultra超短期)';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.report_day IS '上报日(yyyyMMdd,北京时间)';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.est_report_time IS '预计上报时间(HH:mm:ss,北京时间)';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.status IS '状态(1待确认,2已确认)';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.generate_source IS '生成来源(auto自动,manually手动)';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.create_time IS '创建时间';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.update_time IS '更新时间';
|
|
|
+COMMENT ON COLUMN data_power_forecast_report_batch.remark IS '备注';
|
|
|
+
|
|
|
+-- -----------------------------------------------------
|
|
|
+-- 2. report 表加 batch_no 列(101901 统计查询按 batch_no is null 隔离)
|
|
|
+-- -----------------------------------------------------
|
|
|
+ALTER TABLE data_short_term_power_forecast_report ADD COLUMN IF NOT EXISTS batch_no VARCHAR(128);
|
|
|
+COMMENT ON COLUMN data_short_term_power_forecast_report.batch_no IS '上报批次号';
|
|
|
+
|
|
|
+ALTER TABLE data_super_short_term_forecast_report ADD COLUMN IF NOT EXISTS batch_no VARCHAR(128);
|
|
|
+COMMENT ON COLUMN data_super_short_term_forecast_report.batch_no IS '上报批次号';
|
|
|
+
|
|
|
+-- -----------------------------------------------------
|
|
|
+-- 3. 字典配置项 power_forecast_report_batch_config
|
|
|
+-- dict_value 存整个 JSON 数组: [{stationCode, type, period, times, initInterval}]
|
|
|
+-- 例: [{"stationCode":"3301","type":"short","period":"daily","times":["08:00:00"],"initInterval":60}]
|
|
|
+-- initInterval 单位分钟(提前生成窗口)
|
|
|
+-- -----------------------------------------------------
|
|
|
+-- JSON 数组配置可能超过 dict_value 原长度(VARCHAR(100)), 扩容(可重复执行)
|
|
|
+ALTER TABLE sys_dict_data ALTER COLUMN dict_value TYPE VARCHAR(2000);
|
|
|
+
|
|
|
+INSERT INTO sys_dict_type (dict_id, dict_name, dict_type, status, create_by, create_time, remark)
|
|
|
+SELECT
|
|
|
+nextval(pg_get_serial_sequence('sys_dict_type', 'dict_id')),
|
|
|
+'文件上报配置', 'power_forecast_report_batch_config', '0', 'admin', now(), '短期/超短期功率预测上报批次生成配置'
|
|
|
+WHERE NOT EXISTS (SELECT 1 FROM sys_dict_type t WHERE t.dict_type = 'power_forecast_report_batch_config');
|
|
|
+
|
|
|
+INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark)
|
|
|
+SELECT
|
|
|
+nextval(pg_get_serial_sequence('sys_dict_data', 'dict_code')),
|
|
|
+1, '短期/超短期批次生成配置', '[]', 'power_forecast_report_batch_config', '', '', 'Y', '0', 'admin', now(), 'JSON数组, 每项含 stationCode/type/period/times/initInterval(分钟)'
|
|
|
+WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data t WHERE t.dict_type = 'power_forecast_report_batch_config');
|