-- ============================================================================
-- 应急信息管理模块 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 '应急预案基本信息表';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.guid          IS '预案id';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.plan_name     IS '预案名称';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.org_guid      IS '机构guid';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.entry_time    IS '生效时间';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.eva_cycle     IS '评估周期';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.revised       IS '是否需要修订（枚举guid）';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.plan_type     IS '预案类型（枚举guid）';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.creper_guid   IS '创建人guid';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.create_time   IS '创建时间';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.updper_guid   IS '修改人guid';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.update_time   IS '修改时间';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.plan_status   IS '预案状态（枚举guid）';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.parent_id     IS '被修订的预案的id';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.revision_info IS '修订主要情况';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.parent_name   IS '被修订预案名称';
COMMENT ON COLUMN slaj.t_busi_conplan_basic.revise_time   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 '应急演练评估信息表';
COMMENT ON COLUMN slaj.t_busi_drill_eva.de_guid      IS '数据id';
COMMENT ON COLUMN slaj.t_busi_drill_eva.basic_id     IS '预案id';
COMMENT ON COLUMN slaj.t_busi_drill_eva.eva_time     IS '评估时间';
COMMENT ON COLUMN slaj.t_busi_drill_eva.org_guid     IS '填报机构guid';
COMMENT ON COLUMN slaj.t_busi_drill_eva.creper_guid  IS '创建人guid';
COMMENT ON COLUMN slaj.t_busi_drill_eva.create_time  IS '创建时间';
COMMENT ON COLUMN slaj.t_busi_drill_eva.updper_guid  IS '修改人guid';
COMMENT ON COLUMN slaj.t_busi_drill_eva.update_time  IS '修改时间';
COMMENT ON COLUMN slaj.t_busi_drill_eva.assess       IS '评估主持单位';
COMMENT ON COLUMN slaj.t_busi_drill_eva.dr_guid      IS '演练记录id';

-- 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 '演练实施记录表';
COMMENT ON COLUMN slaj.t_busi_drill_record.dr_guid      IS '数据id';
COMMENT ON COLUMN slaj.t_busi_drill_record.basic_id     IS '预案id';
COMMENT ON COLUMN slaj.t_busi_drill_record.drill_type   IS '演练类型';
COMMENT ON COLUMN slaj.t_busi_drill_record.drill_time   IS '演练时间';
COMMENT ON COLUMN slaj.t_busi_drill_record.partake_num  IS '参与人数';
COMMENT ON COLUMN slaj.t_busi_drill_record.partake_org  IS '参与单位';
COMMENT ON COLUMN slaj.t_busi_drill_record.org_guid     IS '填报人所在机构guid';
COMMENT ON COLUMN slaj.t_busi_drill_record.creper_guid  IS '创建人guid';
COMMENT ON COLUMN slaj.t_busi_drill_record.create_time  IS '创建时间';
COMMENT ON COLUMN slaj.t_busi_drill_record.updper_guid  IS '修改人guid';
COMMENT ON COLUMN slaj.t_busi_drill_record.update_time  IS '修改时间';
COMMENT ON COLUMN slaj.t_busi_drill_record.drill_name   IS '预案演练名称';
COMMENT ON COLUMN slaj.t_busi_drill_record.pdr_guid     IS '整改记录id';
COMMENT ON COLUMN slaj.t_busi_drill_record.rdb          IS '评估状态 1未评估 2已评估';
COMMENT ON COLUMN slaj.t_busi_drill_record.cor_status   IS '演练状态 1演练 2重新演练';

-- 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 '应急预案安全生产评价';
COMMENT ON COLUMN slaj.t_busi_insure_eva.create_time     IS '生成时间';
COMMENT ON COLUMN slaj.t_busi_insure_eva.start_date      IS '开始时间';
COMMENT ON COLUMN slaj.t_busi_insure_eva.end_date        IS '结束时间';
COMMENT ON COLUMN slaj.t_busi_insure_eva.eng_total       IS '工程数量';
COMMENT ON COLUMN slaj.t_busi_insure_eva.is_insure       IS '工程安则险数量';
COMMENT ON COLUMN slaj.t_busi_insure_eva.not_insure      IS '工程无安则险数量';
COMMENT ON COLUMN slaj.t_busi_insure_eva.tend_total      IS '标段数量';
COMMENT ON COLUMN slaj.t_busi_insure_eva.tend_is_insure  IS '安责险标段数量';
COMMENT ON COLUMN slaj.t_busi_insure_eva.tend_not_insure IS '无安责险标段数量';
COMMENT ON COLUMN slaj.t_busi_insure_eva.bxl             IS '标段保险率';
COMMENT ON COLUMN slaj.t_busi_insure_eva.nbxl            IS '标段无保险率';
COMMENT ON COLUMN slaj.t_busi_insure_eva.bx_fx           IS '标段风险度';
COMMENT ON COLUMN slaj.t_busi_insure_eva.date_type       IS '统计类型 1月 3季度';
COMMENT ON COLUMN slaj.t_busi_insure_eva.date_year       IS '年份';
COMMENT ON COLUMN slaj.t_busi_insure_eva.date_quarter    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 '应急预案统计';
COMMENT ON COLUMN slaj.t_busi_plan_count.create_time     IS '生成日期';
COMMENT ON COLUMN slaj.t_busi_plan_count.zh_plan         IS '综合预案';
COMMENT ON COLUMN slaj.t_busi_plan_count.zx_plan         IS '专项预案';
COMMENT ON COLUMN slaj.t_busi_plan_count.xc_plan         IS '现场预案';
COMMENT ON COLUMN slaj.t_busi_plan_count.org_num         IS '单位数量';
COMMENT ON COLUMN slaj.t_busi_plan_count.report_plan_org IS '填报预案单位数量';
COMMENT ON COLUMN slaj.t_busi_plan_count.org_plan_ra     IS '单位填报率';
COMMENT ON COLUMN slaj.t_busi_plan_count.drill_num       IS '演练数量';
COMMENT ON COLUMN slaj.t_busi_plan_count.plan_drill_ra   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 '预案信息公开表';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.di_guid        IS '数据id';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.basic_id       IS '预案id';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.public_time    IS '公开时间';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.public_type    IS '公开方式';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.public_scope   IS '公开范围';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.org_guid       IS '填报机构guid';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.creper_guid    IS '创建人guid';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.create_time    IS '创建时间';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.updper_guid    IS '修改人guid';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.update_time    IS '修改时间';
COMMENT ON COLUMN slaj.t_busi_plan_disclosure.public_status  IS '1未公开 2已公开';

-- 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 '应急预案评估';
COMMENT ON COLUMN slaj.t_busi_plan_eva.create_time  IS '生成时间';
COMMENT ON COLUMN slaj.t_busi_plan_eva.start_date   IS '开始时间';
COMMENT ON COLUMN slaj.t_busi_plan_eva.end_date     IS '结束时间';
COMMENT ON COLUMN slaj.t_busi_plan_eva.org_num      IS '单位数量';
COMMENT ON COLUMN slaj.t_busi_plan_eva.zh           IS '综合预案单位';
COMMENT ON COLUMN slaj.t_busi_plan_eva.zx           IS '专项预案单位';
COMMENT ON COLUMN slaj.t_busi_plan_eva.xc           IS '现场预案单位';
COMMENT ON COLUMN slaj.t_busi_plan_eva.plan         IS '上报预案单位';
COMMENT ON COLUMN slaj.t_busi_plan_eva.sbl          IS '上报率';
COMMENT ON COLUMN slaj.t_busi_plan_eva.yl           IS '演练率';
COMMENT ON COLUMN slaj.t_busi_plan_eva.yll          IS '演练率（累计）';
COMMENT ON COLUMN slaj.t_busi_plan_eva.date_type    IS '统计类型 1月 3季度';
COMMENT ON COLUMN slaj.t_busi_plan_eva.date_year    IS '年份';
COMMENT ON COLUMN slaj.t_busi_plan_eva.date_quarter IS '季度';
COMMENT ON COLUMN slaj.t_busi_plan_eva.plan_fx      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 '应急预案定期评估';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.guid          IS '数据id';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.basic_id      IS '预案id';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.eva_time      IS '评估时间（录入）';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.org_guid      IS '填报机构guid';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.creper_guid   IS '创建人guid';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.create_time   IS '创建时间';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.updper_guid   IS '修改人guid';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.update_time   IS '修改时间';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.eva_date      IS '评估日期';
COMMENT ON COLUMN slaj.t_busi_regular_evalu.eva_result    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 '应急预案评审信息';
COMMENT ON COLUMN slaj.t_busi_review_info.ri_guid      IS '数据id';
COMMENT ON COLUMN slaj.t_busi_review_info.basic_id     IS '预案id';
COMMENT ON COLUMN slaj.t_busi_review_info.revi_time    IS '评审时间';
COMMENT ON COLUMN slaj.t_busi_review_info.revi_org     IS '评审组织单位';
COMMENT ON COLUMN slaj.t_busi_review_info.revi_pers    IS '评审人员';
COMMENT ON COLUMN slaj.t_busi_review_info.revi_opin    IS '评审意见';
COMMENT ON COLUMN slaj.t_busi_review_info.revi_resu    IS '评审结果';
COMMENT ON COLUMN slaj.t_busi_review_info.revi_type    IS '评审类型';
COMMENT ON COLUMN slaj.t_busi_review_info.org_guid     IS '填报机构guid';
COMMENT ON COLUMN slaj.t_busi_review_info.creper_guid  IS '创建人guid';
COMMENT ON COLUMN slaj.t_busi_review_info.create_time  IS '创建时间';
COMMENT ON COLUMN slaj.t_busi_review_info.updper_guid  IS '修改人guid';
COMMENT ON COLUMN slaj.t_busi_review_info.update_time  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 '应急物资储备';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.guid           IS '数据id';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.org_guid       IS '机构guid';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.supp_type      IS '物资类型';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.supp_code      IS '物资编号';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.supp_name      IS '物资名称';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.supp_spec      IS '规格型号';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.supp_amount    IS '数量';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.supp_unit      IS '计量单位';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.note           IS '备注';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.create_time    IS '创建时间';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.creater        IS '创建人';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.edit_time      IS '编辑时间';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.editer         IS '编辑人';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.dist_date      IS '调配日期';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.mana_org_guid  IS '管理单位guid';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.supp_cont_type IS '物资内容类型';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.supp_status    IS '状态';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.stor_cond      IS '存放条件';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.mana_pers      IS '管理人员';
COMMENT ON COLUMN slaj.t_busi_supplies_reserve.mana_pers_tel  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 '应急救援队伍信息';
COMMENT ON COLUMN slaj.t_busi_team_info.guid        IS '数据id';
COMMENT ON COLUMN slaj.t_busi_team_info.org_guid    IS '机构guid';
COMMENT ON COLUMN slaj.t_busi_team_info.team_type   IS '队伍类型';
COMMENT ON COLUMN slaj.t_busi_team_info.team_name   IS '队伍名称';
COMMENT ON COLUMN slaj.t_busi_team_info.chie_team   IS '主要成员';
COMMENT ON COLUMN slaj.t_busi_team_info.team_num    IS '队伍人数';
COMMENT ON COLUMN slaj.t_busi_team_info.team_tel    IS '联系电话';
COMMENT ON COLUMN slaj.t_busi_team_info.train_cont  IS '培训内容';
COMMENT ON COLUMN slaj.t_busi_team_info.equi_info   IS '装备信息';
COMMENT ON COLUMN slaj.t_busi_team_info.team_resp   IS '队伍职责';
COMMENT ON COLUMN slaj.t_busi_team_info.team_code   IS '队伍编号';
COMMENT ON COLUMN slaj.t_busi_team_info.sup_guid    IS '所属物资guid';
COMMENT ON COLUMN slaj.t_busi_team_info.note        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 '应急预案培训记录表';
COMMENT ON COLUMN slaj.t_busi_train_record.tr_guid      IS '数据id';
COMMENT ON COLUMN slaj.t_busi_train_record.basic_id     IS '预案id';
COMMENT ON COLUMN slaj.t_busi_train_record.train_type   IS '培训类型';
COMMENT ON COLUMN slaj.t_busi_train_record.train_time   IS '培训时间';
COMMENT ON COLUMN slaj.t_busi_train_record.part_num     IS '参加人数';
COMMENT ON COLUMN slaj.t_busi_train_record.train_cont   IS '培训内容';
COMMENT ON COLUMN slaj.t_busi_train_record.org_guid     IS '填报机构guid';
COMMENT ON COLUMN slaj.t_busi_train_record.creper_guid  IS '创建人guid';
COMMENT ON COLUMN slaj.t_busi_train_record.create_time  IS '创建时间';
COMMENT ON COLUMN slaj.t_busi_train_record.updper_guid  IS '修改人guid';
COMMENT ON COLUMN slaj.t_busi_train_record.update_time  IS '修改时间';
COMMENT ON COLUMN slaj.t_busi_train_record.train_name   IS '培训名称';
COMMENT ON COLUMN slaj.t_busi_train_record.train_addr   IS '培训地点';
