-- ============================================================================
-- 应急信息管理模块 DDL — 12 张表（Oracle DDL 转 PG）
-- ============================================================================

-- 1. 应急预案基本信息
CREATE TABLE slaj.t_busi_conplan_basic (
    guid CHAR(32) PRIMARY KEY, plan_name VARCHAR(100), org_guid CHAR(32), entry_time TIMESTAMP,
    eva_cycle NUMERIC, revised CHAR(1), plan_type CHAR(1), creper_guid CHAR(32), create_time TIMESTAMP,
    updper_guid CHAR(32), update_time TIMESTAMP, plan_status CHAR(1), parent_id CHAR(32),
    revision_info VARCHAR(200), parent_name VARCHAR(100), revise_time TIMESTAMP
);
COMMENT ON TABLE slaj.t_busi_conplan_basic IS '应急预案基本信息表';

-- 2. 演练评估
CREATE TABLE slaj.t_busi_drill_eva (
    de_guid CHAR(32) PRIMARY KEY, basic_id VARCHAR(500), eva_time TIMESTAMP, org_guid CHAR(32),
    creper_guid CHAR(32), create_time TIMESTAMP, updper_guid CHAR(32), update_time TIMESTAMP,
    assess VARCHAR(200), dr_guid CHAR(32)
);
COMMENT ON TABLE slaj.t_busi_drill_eva IS '应急演练评估信息表';

-- 3. 演练记录
CREATE TABLE slaj.t_busi_drill_record (
    dr_guid CHAR(32) PRIMARY KEY, basic_id VARCHAR(500), drill_type CHAR(1), drill_time TIMESTAMP,
    partake_num NUMERIC DEFAULT 0, partake_org VARCHAR(200), org_guid CHAR(32), creper_guid CHAR(32),
    create_time TIMESTAMP, updper_guid CHAR(32), update_time TIMESTAMP, drill_name VARCHAR(200),
    pdr_guid CHAR(32), rdb CHAR(1), cor_status CHAR(1)
);
COMMENT ON TABLE slaj.t_busi_drill_record IS '演练实施记录表';

-- 4. 保险评估
CREATE TABLE slaj.t_busi_insure_eva (
    guid CHAR(32) PRIMARY KEY, org_guid CHAR(32), create_time TIMESTAMP, start_date TIMESTAMP,
    end_date TIMESTAMP, eng_total NUMERIC, is_insure NUMERIC, not_insure NUMERIC, tend_total NUMERIC,
    tend_is_insure NUMERIC, tend_not_insure NUMERIC, bxl NUMERIC, nbxl NUMERIC, bx_fx NUMERIC,
    date_type CHAR(1), date_year CHAR(4), date_quarter CHAR(1)
);
COMMENT ON TABLE slaj.t_busi_insure_eva IS '应急预案安全生产评价';

-- 5. 预案统计
CREATE TABLE slaj.t_busi_plan_count (
    guid CHAR(32) PRIMARY KEY, org_guid CHAR(32), create_time TIMESTAMP, zh_plan NUMERIC,
    zx_plan NUMERIC, xc_plan NUMERIC, org_num NUMERIC, report_plan_org NUMERIC,
    org_plan_ra NUMERIC, drill_num NUMERIC, plan_drill_ra NUMERIC
);
COMMENT ON TABLE slaj.t_busi_plan_count IS '应急预案统计';

-- 6. 预案公示
CREATE TABLE slaj.t_busi_plan_disclosure (
    di_guid CHAR(32) PRIMARY KEY, basic_id CHAR(32), public_time TIMESTAMP, public_type VARCHAR(50),
    public_scope VARCHAR(100), org_guid CHAR(32), creper_guid CHAR(32), create_time TIMESTAMP,
    updper_guid CHAR(32), update_time TIMESTAMP, public_status CHAR(1)
);
COMMENT ON TABLE slaj.t_busi_plan_disclosure IS '预案信息公开表';

-- 7. 预案评估
CREATE TABLE slaj.t_busi_plan_eva (
    guid CHAR(32) PRIMARY KEY, org_guid CHAR(32), create_time TIMESTAMP, start_date TIMESTAMP,
    end_date TIMESTAMP, org_num NUMERIC, zh NUMERIC, zx NUMERIC, xc NUMERIC, plan NUMERIC,
    sbl NUMERIC, yl NUMERIC, yll NUMERIC, date_type CHAR(1), date_year CHAR(4),
    date_quarter CHAR(1), plan_fx NUMERIC
);
COMMENT ON TABLE slaj.t_busi_plan_eva IS '应急预案评估';

-- 8. 定期评估
CREATE TABLE slaj.t_busi_regular_evalu (
    guid CHAR(32) PRIMARY KEY, basic_id CHAR(32), eva_time TIMESTAMP, org_guid CHAR(32),
    creper_guid CHAR(32), create_time TIMESTAMP, updper_guid CHAR(32), update_time TIMESTAMP,
    eva_date TIMESTAMP, eva_result VARCHAR(2000)
);
COMMENT ON TABLE slaj.t_busi_regular_evalu IS '应急预案定期评估';

-- 9. 评审信息
CREATE TABLE slaj.t_busi_review_info (
    ri_guid CHAR(32) PRIMARY KEY, basic_id VARCHAR(500), revi_time TIMESTAMP, revi_org VARCHAR(200),
    revi_pers VARCHAR(200), revi_opin VARCHAR(2000), revi_resu CHAR(1), revi_type CHAR(1),
    org_guid CHAR(32), creper_guid CHAR(32), create_time TIMESTAMP, updper_guid CHAR(32), update_time TIMESTAMP
);
COMMENT ON TABLE slaj.t_busi_review_info IS '应急预案评审信息';

-- 10. 应急物资储备
CREATE TABLE slaj.t_busi_supplies_reserve (
    guid CHAR(32) PRIMARY KEY, org_guid CHAR(32), supp_type CHAR(1), supp_code VARCHAR(50),
    supp_name VARCHAR(200), supp_spec VARCHAR(200), supp_amount NUMERIC, supp_unit VARCHAR(20),
    note VARCHAR(200), create_time TIMESTAMP, creater VARCHAR(50), edit_time TIMESTAMP,
    editer VARCHAR(50), dist_date TIMESTAMP, mana_org_guid CHAR(32), supp_cont_type CHAR(1),
    supp_status CHAR(1), stor_cond VARCHAR(100), mana_pers VARCHAR(100), mana_pers_tel VARCHAR(50)
);
COMMENT ON TABLE slaj.t_busi_supplies_reserve IS '应急物资储备';

-- 11. 应急队伍信息
CREATE TABLE slaj.t_busi_team_info (
    guid CHAR(32) PRIMARY KEY, org_guid CHAR(32), team_type CHAR(1), team_name VARCHAR(200),
    chie_team VARCHAR(1000), team_num NUMERIC, team_tel VARCHAR(100), train_cont VARCHAR(1000),
    equi_info VARCHAR(200), team_resp VARCHAR(1000), team_code VARCHAR(100), sup_guid CHAR(32),
    note VARCHAR(200)
);
COMMENT ON TABLE slaj.t_busi_team_info IS '应急救援队伍信息';

-- 12. 培训记录
CREATE TABLE slaj.t_busi_train_record (
    tr_guid CHAR(32) PRIMARY KEY, basic_id VARCHAR(500), train_type CHAR(1), train_time TIMESTAMP,
    part_num NUMERIC, train_cont VARCHAR(2000), org_guid CHAR(32), creper_guid CHAR(32),
    create_time TIMESTAMP, updper_guid CHAR(32), update_time TIMESTAMP, train_name VARCHAR(500),
    train_addr VARCHAR(200)
);
COMMENT ON TABLE slaj.t_busi_train_record IS '应急预案培训记录表';
