-- 设备维修计划表
CREATE TABLE t_rel_devplan (
  PLAN_ID NUMBER(20) NOT NULL,
  PLANT VARCHAR2(100),
  DEV_NAME VARCHAR2(200),
  DEV_TAG VARCHAR2(100),
  PLAN_TIME DATE,
  APPROVAL_STATUS VARCHAR2(50),
  RESPONSIBLE VARCHAR2(100),
  COMPLETION_STATUS VARCHAR2(50),
  PROCESS_ID VARCHAR2(100),
  APPROVER VARCHAR2(100),
  DEL_FLAG NUMBER(1) DEFAULT 0,
  CREATER_CODE VARCHAR2(64),
  CREATEDATE DATE,
  UPDATER_CODE VARCHAR2(64),
  UPDATEDATE DATE,
  DEPT_ID NUMBER(20),
  REMARKS VARCHAR2(500),
  CONSTRAINT pk_t_rel_devplan PRIMARY KEY (PLAN_ID)
);

-- 添加表注释
COMMENT ON TABLE t_rel_devplan IS '设备维修计划表';

-- 添加字段注释
COMMENT ON COLUMN t_rel_devplan.PLAN_ID IS '计划ID';
COMMENT ON COLUMN t_rel_devplan.PLANT IS '装置';
COMMENT ON COLUMN t_rel_devplan.DEV_NAME IS '设备名称';
COMMENT ON COLUMN t_rel_devplan.DEV_TAG IS '设备位号';
COMMENT ON COLUMN t_rel_devplan.PLAN_TIME IS '计划维修时间';
COMMENT ON COLUMN t_rel_devplan.APPROVAL_STATUS IS '计划审批状态';
COMMENT ON COLUMN t_rel_devplan.RESPONSIBLE IS '责任人';
COMMENT ON COLUMN t_rel_devplan.COMPLETION_STATUS IS '计划完成状态';
COMMENT ON COLUMN t_rel_devplan.PROCESS_ID IS '审批流程ID';
COMMENT ON COLUMN t_rel_devplan.APPROVER IS '审批人';
COMMENT ON COLUMN t_rel_devplan.DEL_FLAG IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN t_rel_devplan.CREATER_CODE IS '创建人';
COMMENT ON COLUMN t_rel_devplan.CREATEDATE IS '创建时间';
COMMENT ON COLUMN t_rel_devplan.UPDATER_CODE IS '修改人';
COMMENT ON COLUMN t_rel_devplan.UPDATEDATE IS '修改时间';
COMMENT ON COLUMN t_rel_devplan.DEPT_ID IS '部门编号';
COMMENT ON COLUMN t_rel_devplan.REMARKS IS '备注';

-- 创建序列
CREATE SEQUENCE seq_t_rel_devplan
  START WITH 1
  INCREMENT BY 1
  NOCACHE
  NOCYCLE;

-- 创建索引
CREATE INDEX idx_devplan_dev_tag ON t_rel_devplan(DEV_TAG);
CREATE INDEX idx_devplan_plan_time ON t_rel_devplan(PLAN_TIME);
CREATE INDEX idx_devplan_approval_status ON t_rel_devplan(APPROVAL_STATUS);
CREATE INDEX idx_devplan_responsible ON t_rel_devplan(RESPONSIBLE);
CREATE INDEX idx_devplan_dept_id ON t_rel_devplan(DEPT_ID);
