-- 撤销吊销业务表
-- XQ-20260314-001
CREATE TABLE "AICCS"."TS_BIZ_CANCEL_REVOKE"
(
    "BIZ_ID" VARCHAR(72) NOT NULL,
    "BIZ_SEQ" VARCHAR(100),
    "PRIPID" VARCHAR(72),
    "UNISCID" VARCHAR(36),
    "REGNO" VARCHAR(60),
    "ENTNAME" VARCHAR(200),
    "REVOKE_REASON" VARCHAR(200),
    "REVOKE_DATE" DATE,
    "CANCEL_REVOKE_DATE" VARCHAR(20),
    "CANCEL_REVOKE_REASON" VARCHAR(200),
    "APPROVAL_DOC_NO" VARCHAR(100),
    "APPROVAL_DEPT" VARCHAR(200),
    "APPROVAL_DEPT_ID" VARCHAR(100),
    "STATUS" VARCHAR(1) DEFAULT '1',
    "CURRENT_NODE" VARCHAR(1) DEFAULT '1',
    "REMARKS" VARCHAR(200),
    "HANDLER_ID" VARCHAR(100),
    "HANDLER_NAME" VARCHAR(100),
    "HANDLER_DATE" DATE,
    "CREATE_TIME" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP,
    "UPDATE_TIME" TIMESTAMP(0),
    NOT CLUSTER PRIMARY KEY("BIZ_ID")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT ON TABLE "AICCS"."TS_BIZ_CANCEL_REVOKE" IS '撤销吊销业务表';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."BIZ_ID" IS '业务ID';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."BIZ_SEQ" IS '业务编号';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."PRIPID" IS '主体身份代码';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."UNISCID" IS '统一社会信用代码';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."REGNO" IS '注册号';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."ENTNAME" IS '企业名称';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."REVOKE_REASON" IS '吊销原因';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."REVOKE_DATE" IS '吊销日期';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."CANCEL_REVOKE_DATE" IS '撤销吊销日期';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."CANCEL_REVOKE_REASON" IS '撤销吊销原因';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."APPROVAL_DOC_NO" IS '批准文号';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."APPROVAL_DEPT" IS '批准部门';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."APPROVAL_DEPT_ID" IS '批准部门ID';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."STATUS" IS '状态：1-待受理，2-受理中，3-审核中，4-审批中，5-已通过，6-已拒绝';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."CURRENT_NODE" IS '当前节点：1-受理，2-审核，3-审批';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."REMARKS" IS '备注';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."HANDLER_ID" IS '经办人ID';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."HANDLER_NAME" IS '经办人姓名';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."HANDLER_DATE" IS '经办时间';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."CREATE_TIME" IS '创建时间';
COMMENT ON COLUMN "AICCS"."TS_BIZ_CANCEL_REVOKE"."UPDATE_TIME" IS '更新时间';

-- 撤销吊销审批记录表
CREATE TABLE "AICCS"."TS_CANCEL_REVOKE_APPROVE"
(
    "APPROVE_ID" VARCHAR(72) NOT NULL,
    "BIZ_ID" VARCHAR(72),
    "NODE" VARCHAR(1),
    "APPROVER_ID" VARCHAR(100),
    "APPROVER_NAME" VARCHAR(100),
    "APPROVE_STATUS" VARCHAR(1),
    "APPROVE_OPINION" VARCHAR(500),
    "APPROVE_TIME" TIMESTAMP(0),
    "CREATE_TIME" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP,
    NOT CLUSTER PRIMARY KEY("APPROVE_ID")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT ON TABLE "AICCS"."TS_CANCEL_REVOKE_APPROVE" IS '撤销吊销审批记录表';
COMMENT ON COLUMN "AICCS"."TS_CANCEL_REVOKE_APPROVE"."APPROVE_ID" IS '审批ID';
COMMENT ON COLUMN "AICCS"."TS_CANCEL_REVOKE_APPROVE"."BIZ_ID" IS '业务ID';
COMMENT ON COLUMN "AICCS"."TS_CANCEL_REVOKE_APPROVE"."NODE" IS '节点：1-受理，2-审核，3-审批';
COMMENT ON COLUMN "AICCS"."TS_CANCEL_REVOKE_APPROVE"."APPROVER_ID" IS '审批人ID';
COMMENT ON COLUMN "AICCS"."TS_CANCEL_REVOKE_APPROVE"."APPROVER_NAME" IS '审批人姓名';
COMMENT ON COLUMN "AICCS"."TS_CANCEL_REVOKE_APPROVE"."APPROVE_STATUS" IS '审批状态：1-通过，2-拒绝';
COMMENT ON COLUMN "AICCS"."TS_CANCEL_REVOKE_APPROVE"."APPROVE_OPINION" IS '审批意见';
COMMENT ON COLUMN "AICCS"."TS_CANCEL_REVOKE_APPROVE"."APPROVE_TIME" IS '审批时间';
COMMENT ON COLUMN "AICCS"."TS_CANCEL_REVOKE_APPROVE"."CREATE_TIME" IS '创建时间';

-- 创建索引
CREATE INDEX "IDX_TS_BIZ_CANCEL_REVOKE_STATUS" ON "AICCS"."TS_BIZ_CANCEL_REVOKE"("STATUS");
CREATE INDEX "IDX_TS_BIZ_CANCEL_REVOKE_PRIPID" ON "AICCS"."TS_BIZ_CANCEL_REVOKE"("PRIPID");
CREATE INDEX "IDX_TS_CANCEL_REVOKE_APPROVE_BIZ_ID" ON "AICCS"."TS_CANCEL_REVOKE_APPROVE"("BIZ_ID");
