-- =============================================
-- Oracle version for contract launch module
-- Execute with:
-- sqlplus developer/dev123@localhost/XEPDB1 @zgwl_contract_launch_oracle.sql
-- =============================================

WHENEVER SQLERROR EXIT SQL.SQLCODE;

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE SEAL_CONTRACT_LAUNCH_LOG';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE SEAL_CONTRACT_LAUNCH_PLAN';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE SEAL_CONTRACT_LAUNCH_FILE';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE SEAL_CONTRACT_LAUNCH_PARTY';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE SEAL_CONTRACT_LAUNCH_MAIN';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_LOG';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -2289 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_PLAN';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -2289 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_FILE';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -2289 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_PARTY';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -2289 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_MAIN';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -2289 THEN RAISE; END IF;
END;
/

CREATE TABLE SEAL_CONTRACT_LAUNCH_MAIN (
    ID NUMBER(19) NOT NULL,
    CONTRACT_SYS_ID VARCHAR2(64 CHAR) NOT NULL,
    CONTRACT_CODE VARCHAR2(64 CHAR),
    LAW_CONTRACT_CODE VARCHAR2(64 CHAR),
    LAW_CONTRACT_ID VARCHAR2(64 CHAR),
    CONTRACT_NAME VARCHAR2(200 CHAR) NOT NULL,
    CONTRACT_TYPE VARCHAR2(64 CHAR) NOT NULL,
    CONTRACT_TYPE_CODE VARCHAR2(64 CHAR) NOT NULL,
    CONTRACT_SOURCE VARCHAR2(32 CHAR) DEFAULT 'ECP' NOT NULL,
    CREATION_MODE VARCHAR2(20 CHAR) NOT NULL,
    TEMPLATE_ID NUMBER(19),
    TEMPLATE_CODE VARCHAR2(64 CHAR),
    TEMPLATE_NAME VARCHAR2(200 CHAR),
    STATUS VARCHAR2(30 CHAR) NOT NULL,
    APPROVE_STATUS VARCHAR2(30 CHAR),
    APPROVE_MESSAGE VARCHAR2(500 CHAR),
    SEAL_CONTRACT_ID VARCHAR2(64 CHAR),
    SEAL_CONTRACT_STATUS NUMBER(10),
    CONTRACT_AMOUNT NUMBER(20, 2),
    CURRENCY_NAME VARCHAR2(20 CHAR),
    CONTRACT_PERIOD_TYPE VARCHAR2(10 CHAR),
    PERIOD_EXPLAIN VARCHAR2(500 CHAR),
    EFFECTIVE_START DATE,
    EFFECTIVE_END DATE,
    PAYMENT_METHOD VARCHAR2(500 CHAR),
    PRIMARY_CONTENT VARCHAR2(2000 CHAR),
    AMOUNT_EXPLAIN VARCHAR2(2000 CHAR),
    VALUATION_MODE VARCHAR2(10 CHAR),
    NEED_AMENDMENTS VARCHAR2(4 CHAR) DEFAULT '0',
    ESTIMATED_AMOUNT NUMBER(20, 2),
    SEAL_TYPE VARCHAR2(50 CHAR),
    TEXT_SOURCE VARCHAR2(50 CHAR),
    MANDATE_TYPE VARCHAR2(50 CHAR),
    CARGO_TYPE VARCHAR2(50 CHAR),
    ASSIST_DEPARTMENT_NAME VARCHAR2(200 CHAR),
    EXECUTOR_ACCOUNT VARCHAR2(64 CHAR),
    CREATOR_PHONE VARCHAR2(32 CHAR),
    SELF_CODE VARCHAR2(64 CHAR),
    MAIN_CONTRACT_CODE VARCHAR2(200 CHAR),
    SIGNING_SUBJECT_CODE VARCHAR2(500 CHAR),
    DATE_TYPE VARCHAR2(10 CHAR),
    IS_ADDIT INTEGER DEFAULT 2,
    IS_ELECTRON VARCHAR2(4 CHAR) DEFAULT '1',
    PAYMENT_DIRECTION VARCHAR2(10 CHAR),
    PUSH_URL VARCHAR2(500 CHAR),
    IS_MAJOR_CONTRACT INTEGER DEFAULT 0,
    IS_OPEN_BIDDING INTEGER DEFAULT 0,
    IS_YEAR_BUDGET INTEGER DEFAULT 0,
    IS_SHARE VARCHAR2(4 CHAR) DEFAULT '0',
    CONTRACT_NATURE VARCHAR2(4 CHAR) DEFAULT '0',
    IS_SGAT VARCHAR2(4 CHAR) DEFAULT '0',
    IS_NORMAL VARCHAR2(4 CHAR) DEFAULT '1',
    IS_TERMINATED VARCHAR2(4 CHAR) DEFAULT '0',
    IS_SINGLE_AGREEMENT VARCHAR2(4 CHAR) DEFAULT '0',
    BIDDING_NO VARCHAR2(100 CHAR),
    OPEN_BIDDING_REMARK VARCHAR2(500 CHAR),
    CONTRACT_GIST_REMARK VARCHAR2(1000 CHAR),
    EW_AMOUNT_TYPE VARCHAR2(100 CHAR),
    DJ_AMOUNT NUMBER(20, 2),
    YJ_AMOUNT NUMBER(20, 2),
    YFK_AMOUNT NUMBER(20, 2),
    BZJ_AMOUNT NUMBER(20, 2),
    BODY_SUMMARY VARCHAR2(2000 CHAR),
    TEMPLATE_FIELD_VALUES_JSON CLOB,
    CONTRACT_TEXT_FILE_NAME VARCHAR2(255 CHAR),
    CONTRACT_TEXT_FILE_PATH VARCHAR2(500 CHAR),
    CONTRACT_TEXT_FILE_TYPE VARCHAR2(50 CHAR),
    CONTRACT_TEXT_FILE_SIZE NUMBER(19),
    SIGNED_FILE_NAME VARCHAR2(255 CHAR),
    SIGNED_FILE_PATH VARCHAR2(500 CHAR),
    SIGNED_FILE_TYPE VARCHAR2(50 CHAR),
    SIGNED_FILE_SIZE NUMBER(19),
    SIGNED_OFFLINE_REASON VARCHAR2(1000 CHAR),
    SIGN_DATE DATE,
    SEAL_DATE DATE,
    ACTIVE_DATE DATE,
    ARCHIVE_DATE DATE,
    ARCHIVE_KEEPER VARCHAR2(64 CHAR),
    ARCHIVE_KEEPER_UNIT VARCHAR2(200 CHAR),
    ARCHIVE_KEEPER_UNIT_CODE VARCHAR2(100 CHAR),
    INVOICE_DATE DATE,
    RECEIVE_DATE DATE,
    REMIND_DAYS NUMBER(10) DEFAULT 3,
    INITIATOR VARCHAR2(64 CHAR),
    INITIATOR_DEPT VARCHAR2(200 CHAR),
    COMPANY_NAME VARCHAR2(200 CHAR),
    ORG_ID VARCHAR2(64 CHAR),
    QUERY_SCOPE VARCHAR2(20 CHAR),
    CREATE_BY VARCHAR2(64 CHAR),
    CREATE_TIME DATE DEFAULT SYSDATE,
    UPDATE_BY VARCHAR2(64 CHAR),
    UPDATE_TIME DATE DEFAULT SYSDATE,
    IS_DELETED VARCHAR2(2 CHAR) DEFAULT 'N',
    REMARK VARCHAR2(1000 CHAR),
    CONSTRAINT PK_SEAL_CONTRACT_LAUNCH_MAIN PRIMARY KEY (ID),
    CONSTRAINT UK_SEAL_CONTRACT_SYS_ID UNIQUE (CONTRACT_SYS_ID)
);

CREATE TABLE SEAL_CONTRACT_LAUNCH_PARTY (
    ID NUMBER(19) NOT NULL,
    CONTRACT_ID NUMBER(19) NOT NULL,
    ROLE_CODE VARCHAR2(10 CHAR) NOT NULL,
    ROLE_NAME VARCHAR2(20 CHAR) NOT NULL,
    SORT_ORDER NUMBER(10) DEFAULT 1,
    PARTNER_ID NUMBER(19),
    OPPOSITE_ID VARCHAR2(64 CHAR),
    COMPANY_NAME VARCHAR2(200 CHAR) NOT NULL,
    COMPANY_TYPE VARCHAR2(50 CHAR),
    OPPOSITE_CHARACTER VARCHAR2(20 CHAR),
    CONTACT_NAME VARCHAR2(100 CHAR),
    CONTACT_PHONE VARCHAR2(50 CHAR),
    CONTACT_EMAIL VARCHAR2(100 CHAR),
    CONTACT_ADDRESS VARCHAR2(500 CHAR),
    REGISTERED_ADDRESS VARCHAR2(500 CHAR),
    LEGAL_REPRESENTATIVE VARCHAR2(100 CHAR),
    CREDIT_CODE VARCHAR2(100 CHAR),
    BANK_NAME VARCHAR2(200 CHAR),
    BANK_ACCOUNT VARCHAR2(100 CHAR),
    NATURAL_PERSON_ID_TYPE VARCHAR2(20 CHAR),
    NATURAL_PERSON_ID_NUMBER VARCHAR2(100 CHAR),
    IS_GROUP_INTERNAL VARCHAR2(4 CHAR),
    IS_HONG_KONG_MACAO_TAIWAN VARCHAR2(4 CHAR),
    CREATE_BY VARCHAR2(64 CHAR),
    CREATE_TIME DATE DEFAULT SYSDATE,
    UPDATE_BY VARCHAR2(64 CHAR),
    UPDATE_TIME DATE DEFAULT SYSDATE,
    IS_DELETED VARCHAR2(2 CHAR) DEFAULT 'N',
    REMARK VARCHAR2(1000 CHAR),
    CONSTRAINT PK_SEAL_CONTRACT_LAUNCH_PARTY PRIMARY KEY (ID)
);

CREATE TABLE SEAL_CONTRACT_LAUNCH_FILE (
    ID NUMBER(19) NOT NULL,
    CONTRACT_ID NUMBER(19) NOT NULL,
    FILE_CATEGORY VARCHAR2(30 CHAR) NOT NULL,
    FILE_NAME VARCHAR2(255 CHAR) NOT NULL,
    FILE_PATH VARCHAR2(500 CHAR) NOT NULL,
    LEGAL_FILE_URL VARCHAR2(1000 CHAR),
    FILE_TYPE VARCHAR2(50 CHAR),
    FILE_SIZE NUMBER(19),
    SORT_ORDER NUMBER(10) DEFAULT 1,
    CREATE_BY VARCHAR2(64 CHAR),
    CREATE_TIME DATE DEFAULT SYSDATE,
    UPDATE_BY VARCHAR2(64 CHAR),
    UPDATE_TIME DATE DEFAULT SYSDATE,
    IS_DELETED VARCHAR2(2 CHAR) DEFAULT 'N',
    REMARK VARCHAR2(1000 CHAR),
    CONSTRAINT PK_SEAL_CONTRACT_LAUNCH_FILE PRIMARY KEY (ID)
);

CREATE TABLE SEAL_CONTRACT_LAUNCH_PLAN (
    ID NUMBER(19) NOT NULL,
    CONTRACT_ID NUMBER(19) NOT NULL,
    PLAN_MATTER VARCHAR2(500 CHAR) NOT NULL,
    PLAN_WHERE VARCHAR2(500 CHAR) NOT NULL,
    PLAN_TIME DATE NOT NULL,
    PLAN_DAY NUMBER(10) DEFAULT 3,
    PLAN_MONEY NUMBER(20, 2),
    PLAN_SUBJECT_CODE VARCHAR2(100 CHAR),
    PLAN_SUBJECT_NAME VARCHAR2(200 CHAR),
    PLAN_DETAIL VARCHAR2(1000 CHAR),
    PLAN_STATUS VARCHAR2(20 CHAR) DEFAULT '0',
    CREATE_BY VARCHAR2(64 CHAR),
    CREATE_TIME DATE DEFAULT SYSDATE,
    UPDATE_BY VARCHAR2(64 CHAR),
    UPDATE_TIME DATE DEFAULT SYSDATE,
    IS_DELETED VARCHAR2(2 CHAR) DEFAULT 'N',
    REMARK VARCHAR2(1000 CHAR),
    CONSTRAINT PK_SEAL_CONTRACT_LAUNCH_PLAN PRIMARY KEY (ID)
);

CREATE TABLE SEAL_CONTRACT_LAUNCH_LOG (
    ID NUMBER(19) NOT NULL,
    CONTRACT_ID NUMBER(19) NOT NULL,
    ACTION_TYPE VARCHAR2(50 CHAR) NOT NULL,
    ACTION_NAME VARCHAR2(100 CHAR) NOT NULL,
    ACTION_STATUS VARCHAR2(20 CHAR) NOT NULL,
    OPERATOR_NAME VARCHAR2(64 CHAR),
    OPERATOR_PHONE VARCHAR2(32 CHAR),
    ACTION_TIME DATE DEFAULT SYSDATE,
    ACTION_CONTENT VARCHAR2(2000 CHAR),
    CALLBACK_PAYLOAD CLOB,
    REMARK VARCHAR2(1000 CHAR),
    CONSTRAINT PK_SEAL_CONTRACT_LAUNCH_LOG PRIMARY KEY (ID)
);

COMMENT ON TABLE SEAL_CONTRACT_LAUNCH_MAIN IS '合同发起主表';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.ID IS '主键ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_SYS_ID IS '平台合同唯一编码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_CODE IS '业务合同编码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.LAW_CONTRACT_CODE IS '法务系统合同编号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.LAW_CONTRACT_ID IS '法务系统合同ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_NAME IS '合同名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_TYPE IS '合同类型中文名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_TYPE_CODE IS '合同类型编码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_SOURCE IS '合同来源';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CREATION_MODE IS '创建方式：template/manual';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.TEMPLATE_ID IS '模板ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.TEMPLATE_CODE IS '模板编号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.TEMPLATE_NAME IS '模板名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.STATUS IS '合同当前状态';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.APPROVE_STATUS IS '审批状态';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.APPROVE_MESSAGE IS '审批说明';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SEAL_CONTRACT_ID IS '签章平台合同ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SEAL_CONTRACT_STATUS IS '签章平台合同状态';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_AMOUNT IS '合同金额';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CURRENCY_NAME IS '币种';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_PERIOD_TYPE IS '合同期限类型：0固定期限 1无固定期限';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.PERIOD_EXPLAIN IS '期限说明';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.EFFECTIVE_START IS '生效开始日期';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.EFFECTIVE_END IS '生效结束日期';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.PAYMENT_METHOD IS '付款方式';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.PRIMARY_CONTENT IS '合同主要内容';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.AMOUNT_EXPLAIN IS '金额说明';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.VALUATION_MODE IS '计价方式';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.NEED_AMENDMENTS IS '是否需修订条款：1是 0否';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.ESTIMATED_AMOUNT IS '预估金额';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SEAL_QUANTITY IS '用印数量';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SEAL_TYPE IS '签订方式';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.TEXT_SOURCE IS '文本来源';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.MANDATE_TYPE IS '委托类型';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CARGO_TYPE IS '货种';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.ASSIST_DEPARTMENT_NAME IS '协助部门';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.EXECUTOR_ACCOUNT IS '合同执行人账号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CREATOR_PHONE IS '创建人手机号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SELF_CODE IS '二级单位合同编码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.MAIN_CONTRACT_CODE IS '主合同编码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SIGNING_SUBJECT_CODE IS '签约主体编码，多个用逗号分隔';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.DATE_TYPE IS '固定期间日期类型：0年 1月 2日';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_ADDIT IS '是否补录：1是 2否';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_ELECTRON IS '签署方式：0纸质 1电子';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.PAYMENT_DIRECTION IS '收支方向';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.PUSH_URL IS '法务审批回调地址';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_MAJOR_CONTRACT IS '是否重大合同';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_OPEN_BIDDING IS '是否公开招标';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_YEAR_BUDGET IS '是否列入当年预算';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_SHARE IS '是否共享';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_NATURE IS '签约主体是否涉外';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_SGAT IS '是否涉港澳台';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_NORMAL IS '是否正常';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_TERMINATED IS '是否终止';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_SINGLE_AGREEMENT IS '是否单方协议';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.BIDDING_NO IS '招标编号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.OPEN_BIDDING_REMARK IS '公开招标备注';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_GIST_REMARK IS '签订依据说明';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.EW_AMOUNT_TYPE IS '额外金额类型：DJ定金 YJ押金 YFK预付款 BZJ保证金';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.DJ_AMOUNT IS '定金金额';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.YJ_AMOUNT IS '押金金额';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.YFK_AMOUNT IS '预付款金额';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.BZJ_AMOUNT IS '保证金金额';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.BODY_SUMMARY IS '正文摘要';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.TEMPLATE_FIELD_VALUES_JSON IS '模板字段值JSON';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_TEXT_FILE_NAME IS '合同正文文件名';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_TEXT_FILE_PATH IS '合同正文文件路径';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_TEXT_FILE_TYPE IS '合同正文文件类型';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CONTRACT_TEXT_FILE_SIZE IS '合同正文文件大小';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SIGNED_FILE_NAME IS '已签署文件名';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SIGNED_FILE_PATH IS '已签署文件路径';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SIGNED_FILE_TYPE IS '已签署文件类型';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SIGNED_FILE_SIZE IS '已签署文件大小';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SIGNED_OFFLINE_REASON IS '线下签署原因';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SIGN_DATE IS '签署日期';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.SEAL_DATE IS '用印时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.ACTIVE_DATE IS '合同生效日期';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.ARCHIVE_DATE IS '归档时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.ARCHIVE_KEEPER IS '档案保管人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.ARCHIVE_KEEPER_UNIT IS '档案保管单位';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.ARCHIVE_KEEPER_UNIT_CODE IS '档案保管单位编码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.INVOICE_DATE IS '开票时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.RECEIVE_DATE IS '收款时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.REMIND_DAYS IS '提醒提前天数';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.INITIATOR IS '发起人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.INITIATOR_DEPT IS '发起部门';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.COMPANY_NAME IS '发起公司';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.ORG_ID IS '组织ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.QUERY_SCOPE IS '查询范围';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CREATE_BY IS '创建人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.CREATE_TIME IS '创建时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.UPDATE_BY IS '更新人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.UPDATE_TIME IS '更新时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.IS_DELETED IS '逻辑删除标记';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_MAIN.REMARK IS '备注';

COMMENT ON TABLE SEAL_CONTRACT_LAUNCH_PARTY IS '合同方信息表';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.ID IS '主键ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.CONTRACT_ID IS '合同主表ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.ROLE_CODE IS '角色编码：A/B/C';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.ROLE_NAME IS '角色名称：甲方/乙方/丙方';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.SORT_ORDER IS '排序号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.PARTNER_ID IS '相对方管理表主键';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.OPPOSITE_ID IS '法务相对方ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.COMPANY_NAME IS '公司名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.COMPANY_TYPE IS '公司类型';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.OPPOSITE_CHARACTER IS '公司性质';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.CONTACT_NAME IS '联系人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.CONTACT_PHONE IS '联系电话';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.CONTACT_EMAIL IS '联系邮箱';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.CONTACT_ADDRESS IS '通讯地址';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.REGISTERED_ADDRESS IS '注册地址';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.LEGAL_REPRESENTATIVE IS '法定代表人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.CREDIT_CODE IS '统一社会信用代码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.BANK_NAME IS '开户行';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.BANK_ACCOUNT IS '银行账号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.NATURAL_PERSON_ID_TYPE IS '自然人证件类型';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.NATURAL_PERSON_ID_NUMBER IS '自然人证件号码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.IS_GROUP_INTERNAL IS '是否集团内';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.IS_HONG_KONG_MACAO_TAIWAN IS '是否涉港澳台';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.CREATE_BY IS '创建人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.CREATE_TIME IS '创建时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.UPDATE_BY IS '更新人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.UPDATE_TIME IS '更新时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.IS_DELETED IS '逻辑删除标记';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PARTY.REMARK IS '备注';

COMMENT ON TABLE SEAL_CONTRACT_LAUNCH_FILE IS '合同附件表';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.ID IS '主键ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.CONTRACT_ID IS '合同主表ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.FILE_CATEGORY IS '文件分类：body/other/gist/signed/archive';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.FILE_NAME IS '文件名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.FILE_PATH IS '文件路径';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.LEGAL_FILE_URL IS '法务系统附件路径缓存';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.FILE_TYPE IS '文件类型';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.FILE_SIZE IS '文件大小';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.SORT_ORDER IS '排序号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.CREATE_BY IS '创建人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.CREATE_TIME IS '创建时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.UPDATE_BY IS '更新人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.UPDATE_TIME IS '更新时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.IS_DELETED IS '逻辑删除标记';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_FILE.REMARK IS '备注';

COMMENT ON TABLE SEAL_CONTRACT_LAUNCH_PLAN IS '合同履行计划表';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.ID IS '主键ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.CONTRACT_ID IS '合同主表ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_MATTER IS '履行事项';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_WHERE IS '履约条件';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_TIME IS '节点日期';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_DAY IS '提前提醒天数';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_MONEY IS '款项金额';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_SUBJECT_CODE IS '所属主体编码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_SUBJECT_NAME IS '所属主体名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_DETAIL IS '备注';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_STATUS IS '反馈状态';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.CREATE_BY IS '创建人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.CREATE_TIME IS '创建时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.UPDATE_BY IS '更新人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.UPDATE_TIME IS '更新时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.IS_DELETED IS '逻辑删除标记';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.REMARK IS '备注';

COMMENT ON TABLE SEAL_CONTRACT_LAUNCH_LOG IS '合同操作日志表';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ID IS '主键ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.CONTRACT_ID IS '合同主表ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_TYPE IS '动作类型';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_NAME IS '动作名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_STATUS IS '动作状态';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.OPERATOR_NAME IS '操作人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.OPERATOR_PHONE IS '操作人手机号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_TIME IS '操作时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_CONTENT IS '操作说明';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.CALLBACK_PAYLOAD IS '回调或接口报文';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.REMARK IS '备注';

CREATE INDEX IDX_CONTRACT_LAUNCH_STATUS ON SEAL_CONTRACT_LAUNCH_MAIN (STATUS);
CREATE INDEX IDX_CONTRACT_LAUNCH_CODE ON SEAL_CONTRACT_LAUNCH_MAIN (CONTRACT_CODE);
CREATE INDEX IDX_CONTRACT_LAUNCH_NAME ON SEAL_CONTRACT_LAUNCH_MAIN (CONTRACT_NAME);
CREATE INDEX IDX_CONTRACT_LAUNCH_CREATE_TIME ON SEAL_CONTRACT_LAUNCH_MAIN (CREATE_TIME);
CREATE INDEX IDX_CONTRACT_LAUNCH_PARTY_CONTRACT ON SEAL_CONTRACT_LAUNCH_PARTY (CONTRACT_ID);
CREATE INDEX IDX_CONTRACT_LAUNCH_FILE_CONTRACT ON SEAL_CONTRACT_LAUNCH_FILE (CONTRACT_ID);
CREATE INDEX IDX_CONTRACT_LAUNCH_PLAN_CONTRACT ON SEAL_CONTRACT_LAUNCH_PLAN (CONTRACT_ID);
CREATE INDEX IDX_CONTRACT_LAUNCH_LOG_CONTRACT ON SEAL_CONTRACT_LAUNCH_LOG (CONTRACT_ID);

CREATE SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_MAIN START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
CREATE SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_PARTY START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
CREATE SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_FILE START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
CREATE SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_PLAN START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
CREATE SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_LOG START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
