-- 部件维修记录表
CREATE TABLE t_rel_compo_record (
  RECORD_ID NUMBER(20) NOT NULL,
  PLANT VARCHAR2(100),
  DEV_NAME VARCHAR2(200),
  DEV_TAG VARCHAR2(100),
  COMPO_NAME VARCHAR2(200),
  COMPO_ID VARCHAR2(100),
  MAINT_TYPE VARCHAR2(50),
  MAINT_DEPT VARCHAR2(100),
  INSPECTOR VARCHAR2(100),
  INSPECT_CONTENT VARCHAR2(500),
  INSPECT_TIME DATE,
  RESPONSIBLE VARCHAR2(100),
  MAINT_CONTENT VARCHAR2(500),
  MAINT_RESULT VARCHAR2(50),
  MAINT_TIME DATE,
  MAINT_COST NUMBER(18,2),
  MAINT_DURATION NUMBER(10,2),
  PROCESS_LOSS VARCHAR2(500),
  ATTACHMENTS VARCHAR2(500),
  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_compo_record PRIMARY KEY (RECORD_ID)
);

-- 添加表注释
COMMENT ON TABLE t_rel_compo_record IS '部件维修记录表';

-- 添加字段注释
COMMENT ON COLUMN t_rel_compo_record.RECORD_ID IS '记录ID';
COMMENT ON COLUMN t_rel_compo_record.PLANT IS '装置';
COMMENT ON COLUMN t_rel_compo_record.DEV_NAME IS '设备名称';
COMMENT ON COLUMN t_rel_compo_record.DEV_TAG IS '设备位号';
COMMENT ON COLUMN t_rel_compo_record.COMPO_NAME IS '部件名称';
COMMENT ON COLUMN t_rel_compo_record.COMPO_ID IS '部件ID';
COMMENT ON COLUMN t_rel_compo_record.MAINT_TYPE IS '维修类型';
COMMENT ON COLUMN t_rel_compo_record.MAINT_DEPT IS '维修部门';
COMMENT ON COLUMN t_rel_compo_record.INSPECTOR IS '检查人';
COMMENT ON COLUMN t_rel_compo_record.INSPECT_CONTENT IS '检查内容';
COMMENT ON COLUMN t_rel_compo_record.INSPECT_TIME IS '检查时间';
COMMENT ON COLUMN t_rel_compo_record.RESPONSIBLE IS '维修责任人';
COMMENT ON COLUMN t_rel_compo_record.MAINT_CONTENT IS '维修内容';
COMMENT ON COLUMN t_rel_compo_record.MAINT_RESULT IS '维修结果';
COMMENT ON COLUMN t_rel_compo_record.MAINT_TIME IS '维修时间';
COMMENT ON COLUMN t_rel_compo_record.MAINT_COST IS '维修费用';
COMMENT ON COLUMN t_rel_compo_record.MAINT_DURATION IS '维修时长';
COMMENT ON COLUMN t_rel_compo_record.PROCESS_LOSS IS '工艺损失';
COMMENT ON COLUMN t_rel_compo_record.ATTACHMENTS IS '附件';
COMMENT ON COLUMN t_rel_compo_record.DEL_FLAG IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN t_rel_compo_record.CREATER_CODE IS '创建人';
COMMENT ON COLUMN t_rel_compo_record.CREATEDATE IS '创建时间';
COMMENT ON COLUMN t_rel_compo_record.UPDATER_CODE IS '修改人';
COMMENT ON COLUMN t_rel_compo_record.UPDATEDATE IS '修改时间';
COMMENT ON COLUMN t_rel_compo_record.DEPT_ID IS '部门编号';
COMMENT ON COLUMN t_rel_compo_record.REMARKS IS '备注';

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

-- 创建索引
CREATE INDEX idx_compo_record_dev_tag ON t_rel_compo_record(DEV_TAG);
CREATE INDEX idx_compo_record_compo_id ON t_rel_compo_record(COMPO_ID);
CREATE INDEX idx_compo_record_maint_time ON t_rel_compo_record(MAINT_TIME);
CREATE INDEX idx_compo_record_inspect_time ON t_rel_compo_record(INSPECT_TIME);
CREATE INDEX idx_compo_record_responsible ON t_rel_compo_record(RESPONSIBLE);
CREATE INDEX idx_compo_record_dept_id ON t_rel_compo_record(DEPT_ID);
