-- HF编码维护
IF EXISTS (SELECT *
           FROM sys.all_objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_base_hf_code]')
             AND type IN ('U'))
    DROP TABLE [dbo].[eam_base_hf_code]
GO

CREATE TABLE [dbo].[eam_base_hf_code]
(
    [id]          nvarchar(32) COLLATE Chinese_PRC_CI_AS  NOT NULL,
    [create_by]   nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [create_time] datetime2(7)                            NULL,
    [update_by]   nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [update_time] datetime2(7)                            NULL,
    [del_flag]    int                                     NULL,
    [hf_code]     nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL,
    [hf_name]     nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [hf_category] nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [hf_status]   nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [hf_version]  nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[eam_base_hf_code]
    SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
     'MS_Description', N'主键',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'删除标记',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'HF编码',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'hf_code'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'模板名称',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'hf_name'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'模板分类',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'hf_category'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'状态;启用、禁用',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'hf_status'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'版本;V1，V2+',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code',
     'COLUMN', N'hf_version'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'报表HFCode维护',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_base_hf_code'
GO
ALTER TABLE [dbo].[eam_base_hf_code]
    ADD CONSTRAINT [PK__eam_base__3213E83F80327B31] PRIMARY KEY CLUSTERED ([id])
        WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
        ON [PRIMARY]
GO

--技术鉴定规范
IF EXISTS (SELECT *
           FROM sys.all_objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_evaluation_standard]')
             AND type IN ('U'))
    DROP TABLE [dbo].[eam_technical_status_evaluation_standard]
GO

CREATE TABLE [dbo].[eam_technical_status_evaluation_standard]
(
    [id]                         nvarchar(32) COLLATE Chinese_PRC_CI_AS  NOT NULL,
    [create_by]                  nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [create_time]                datetime2(7)                            NULL,
    [update_by]                  nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [update_time]                datetime2(7)                            NULL,
    [del_flag]                   int                                     NULL,
    [standard_name]              nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [standard_code]              nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [evaluation_period]          int                                     NULL,
    [equipment_id]               nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
    [standard_status]            nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [has_safety_equipment_check] nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [has_precision_check]        nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [has_other_check]            nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [standard_version]           nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [remark]                     nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL
)
GO

ALTER TABLE [dbo].[eam_technical_status_evaluation_standard]
    SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
     'MS_Description', N'主键',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'删除标记',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'规范名称',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'standard_name'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'规范编码',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'standard_code'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'鉴定周期',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'evaluation_period'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备ID',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'equipment_id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'规范状态;待提交、启用、作废',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'standard_status'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'是否有安全装置检查;是否',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'has_safety_equipment_check'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'是否有设备精度检查;是否',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'has_precision_check'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'是否有其他检查;是否',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'has_other_check'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'版本;V1,V2+',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'standard_version'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'备注',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard',
     'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'技术状态鉴定规范',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard'
GO
ALTER TABLE [dbo].[eam_technical_status_evaluation_standard]
    ADD CONSTRAINT [PK__eam_tech__3213E83FB7E202C0] PRIMARY KEY CLUSTERED ([id])
        WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
        ON [PRIMARY]
GO
--技术状态鉴定规范明细
IF EXISTS (SELECT *
           FROM sys.all_objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_evaluation_standard_detail]')
             AND type IN ('U'))
    DROP TABLE [dbo].[eam_technical_status_evaluation_standard_detail]
GO

CREATE TABLE [dbo].[eam_technical_status_evaluation_standard_detail]
(
    [id]              nvarchar(32) COLLATE Chinese_PRC_CI_AS  NOT NULL,
    [create_by]       nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [create_time]     datetime2(7)                            NULL,
    [update_by]       nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [update_time]     datetime2(7)                            NULL,
    [standard_id]     nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
    [check_category]  nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [item_code]       int                                     NULL,
    [item_name]       nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [tolerance_value] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL,
    [sub_item_name]   nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL
)
GO

ALTER TABLE [dbo].[eam_technical_status_evaluation_standard_detail]
    SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
     'MS_Description', N'主键',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'规范ID',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'standard_id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'检查分类;精度检查、安全装置检查、其他检查',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'check_category'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'项目序号',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'item_code'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'检查项目',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'item_name'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'允差值;精度检查展示',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'tolerance_value'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'检查子项目;精度检查展示，可以为空',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail',
     'COLUMN', N'sub_item_name'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'技术状态鉴定规范明细',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_standard_detail'
GO

ALTER TABLE [dbo].[eam_technical_status_evaluation_standard_detail]
    ADD CONSTRAINT [PK__eam_tech__3213E83F6C420333] PRIMARY KEY CLUSTERED ([id])
        WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
        ON [PRIMARY]
GO

--技术状态鉴定工单
IF EXISTS (SELECT *
           FROM sys.all_objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_evaluation_order]')
             AND type IN ('U'))
    DROP TABLE [dbo].[eam_technical_status_evaluation_order]
GO

CREATE TABLE [dbo].[eam_technical_status_evaluation_order]
(
    [id]                                       nvarchar(32) COLLATE Chinese_PRC_CI_AS  NOT NULL,
    [create_by]                                nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [create_time]                              datetime2(7)                            NULL,
    [update_by]                                nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [update_time]                              datetime2(7)                            NULL,
    [del_flag]                                 int                                     NULL,
    [order_num]                                nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [equipment_id]                             nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
    [standard_id]                              nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
    [evaluation_date]                          datetime2(7)                            NULL,
    [freeze_order_date]                        datetime2(7)                            NULL,
    [order_expiration_date]                    datetime2(7)                            NULL,
    [actual_start_time]                        datetime2(7)                            NULL,
    [actual_end_time]                          datetime2(7)                            NULL,
    [evaluator]                                nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [evaluation_status]                        nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [creation_method]                          nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [safety_check_completed]                   nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [precision_check_completed]                nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [other_check_completed]                    nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [safety_check_confirm]                     nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [safety_check_confirm_time]                datetime2(7)                            NULL,
    [safety_check_result]                      nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [safety_check_comment]                     nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [precision_check_confirm]                  nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [precision_check_confirm_time]             datetime2(7)                            NULL,
    [precision_check_confirm_result]           nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [precision_check_confirm_comment]          nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [other_check_confirm]                      nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [other_check_confirm_time]                 datetime2(7)                            NULL,
    [other_check_confirm_result]               nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [other_check_confirm_comment]              nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [safety_equipment_check_result]            nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [precision_check_result]                   nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [functional_check_result]                  nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [other_check_result]                       nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [repairer_signature]                       nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [repairer_signature_time]                  datetime2(7)                            NULL,
    [repair_manager_signature]                 nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [repair_manager_signature_time]            datetime2(7)                            NULL,
    [repair_manager_signature_result]          nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [repair_manager_comment]                   nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [sample_check_result]                      nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [process_technician_signature]             nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [process_technician_signature_time]        datetime2(7)                            NULL,
    [process_technician_comment]               nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [depart_technical_leader_signature]        nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [depart_technical_leader_signature_time]   nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [depart_technical_leader_signature_result] nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [depart_technical_leader_comment]          nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [evaluation_result]                        nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [evaluation_reason]                        nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [inspector_signature]                      nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [inspector_signature_time]                 datetime2(7)                            NULL,
    [inspector_comment]                        nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [hf_code_a]                                nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL,
    [hf_code_b]                                nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL,
    [hf_code_c]                                nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL,
    [hf_code_d]                                nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL,
    [remark]                                   nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    CONSTRAINT [PK__eam_tech__3213E83F3B4971F7] PRIMARY KEY CLUSTERED ([id])
        WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
        ON [PRIMARY]
)
    ON [PRIMARY]
GO

ALTER TABLE [dbo].[eam_technical_status_evaluation_order]
    SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
     'MS_Description', N'主键',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'删除标记',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'工单号',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'order_num'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备ID',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'equipment_id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'规范ID',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'standard_id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'计划鉴定日期;提前70天生成工单',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'evaluation_date'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'锁定工单日期;提前55天锁定工单',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'freeze_order_date'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'工单过期日期;到期未做直接过期，并修改设备技术状态为禁用',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'order_expiration_date'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'实际开始时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'actual_start_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'实际结束时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'actual_end_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'鉴定人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'evaluator'
GO

EXEC sp_addextendedproperty
     'MS_Description',
     N'鉴定状态;待鉴定、鉴定中、维修室主任签字、工艺人员签字、使用单位技术主管签字、设备检验员签字、已完成、已锁定、变更中、已过期',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'evaluation_status'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建方式',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'creation_method'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'安全装置检查是否完成;是否',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'safety_check_completed'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备精度检查是否完成;是否',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'precision_check_completed'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'其他检查是否完成;是否',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'other_check_completed'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'安全装置检查确认人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'safety_check_confirm'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'安全装置检查确认时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'safety_check_confirm_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'安全装置检查确认结果',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'safety_check_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'安全装置检查确认意见',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'safety_check_comment'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备精度检查确认人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'precision_check_confirm'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备精度检查确认时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'precision_check_confirm_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备精度检查确认结果',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'precision_check_confirm_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备精度检查确认意见',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'precision_check_confirm_comment'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'其他检查确认人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'other_check_confirm'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'其他检查确认时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'other_check_confirm_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'其他检查确认结果',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'other_check_confirm_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'其他检查确认意见',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'other_check_confirm_comment'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'安全装置检查结果;是、否',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'safety_equipment_check_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'精度参数检查结果;是、否、无',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'precision_check_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'功能状态检查结果;是、否',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'functional_check_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'其他检查结果;是、否、无',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'other_check_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'维修人签字',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'repairer_signature'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'维修人签字时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'repairer_signature_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'维修室主任签字',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'repair_manager_signature'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'维修室主任签字时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'repair_manager_signature_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'维修室主任签字结果',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'repair_manager_signature_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'维修室主任意见',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'repair_manager_comment'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'试件检查结果;合格、不合格',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'sample_check_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'工艺员签字',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'process_technician_signature'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'工艺员签字时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'process_technician_signature_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'工艺员意见',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'process_technician_comment'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'使用单位技术主管签字',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'depart_technical_leader_signature'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'使用单位技术主管签字时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'depart_technical_leader_signature_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'使用单位技术主管签字结果',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'depart_technical_leader_signature_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'使用单位技术主管意见',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'depart_technical_leader_comment'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'鉴定结果;合格、限用、禁用',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'evaluation_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'限/禁用原因(多选);安全装置、设备功能、精度、试件、其他',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'evaluation_reason'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备检查人签字',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'inspector_signature'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备检查人签字时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'inspector_signature_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'设备检查人意见',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'inspector_comment'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'附录A HF编码',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'hf_code_a'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'附录B HF编码',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'hf_code_b'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'附录C HF编码',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'hf_code_c'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'附录D HF编码',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'hf_code_d'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'备注',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order',
     'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'技术状态鉴定工单',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order'

--技术状态鉴定工单明细
IF EXISTS (SELECT *
           FROM sys.all_objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_evaluation_order_detail]')
             AND type IN ('U'))
    DROP TABLE [dbo].[eam_technical_status_evaluation_order_detail]
GO

CREATE TABLE [dbo].[eam_technical_status_evaluation_order_detail]
(
    [id]                            nvarchar(32) COLLATE Chinese_PRC_CI_AS  NOT NULL,
    [create_by]                     nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [create_time]                   datetime2(7)                            NULL,
    [update_by]                     nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [update_time]                   datetime2(7)                            NULL,
    [order_id]                      nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
    [item_code]                     int                                     NULL,
    [check_category]                nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [item_name]                     nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [tolerance_value]               nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL,
    [sub_item_name]                 nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [safety_equipment_check_result] nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
    [other_check_result]            nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
    [precision_check_result]        numeric(24, 4)                          NULL,
    [repairman_signature]           nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
    [repairman_signature_time]      datetime2(7)                            NULL,
    CONSTRAINT [PK__eam_tech__3213E83F680090BC] PRIMARY KEY CLUSTERED ([id])
        WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
        ON [PRIMARY]
)
    ON [PRIMARY]
GO

ALTER TABLE [dbo].[eam_technical_status_evaluation_order_detail]
    SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
     'MS_Description', N'主键',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'创建时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新人',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'更新时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'工单ID',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'order_id'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'序号',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'item_code'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'检查分类;精度检查、安全装置检查、其他检查',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'check_category'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'检查项目',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'item_name'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'允差值;精度检查展示',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'tolerance_value'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'检查子项目;精度检查展示，可以为空',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'sub_item_name'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'安全装置检查结果;是、否、无',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'safety_equipment_check_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'其他检查结果',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'other_check_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'精度检验结果',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'precision_check_result'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'维修人/精度检查者签字',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'repairman_signature'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'维修人/精度检查者签字时间',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail',
     'COLUMN', N'repairman_signature_time'
GO

EXEC sp_addextendedproperty
     'MS_Description', N'技术状态鉴定工单明细',
     'SCHEMA', N'dbo',
     'TABLE', N'eam_technical_status_evaluation_order_detail'


--技术状态鉴定工单变更
IF EXISTS (SELECT *
           FROM sys.objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_evaluation_order_change]')
             AND type in (N'U'))
    DROP TABLE [dbo].[eam_technical_status_evaluation_order_change];
CREATE TABLE [dbo].[eam_technical_status_evaluation_order_change]
(
    id                                NVARCHAR(32) NOT NULL,
    create_by                         NVARCHAR(50),
    create_time                       DATETIME2,
    update_by                         NVARCHAR(50),
    update_time                       DATETIME2,
    del_flag                          INT,
    order_id                          NVARCHAR(32),
    change_order_num                  NVARCHAR(100),
    applicant                         NVARCHAR(50),
    factory_org_code                  NVARCHAR(100),
    apply_date                        DATETIME2,
    change_status                     NVARCHAR(64),
    apply_reason                      NVARCHAR(64),
    deferred_maintenance_date         DATETIME2,
    equipment_manager_signature       NVARCHAR(50),
    equipment_manager_signature_time  DATETIME2,
    depart_manager_signature          NVARCHAR(50),
    depart_manager_signature_time     DATETIME2,
    depart_manager_comment            NVARCHAR(255),
    production_support_signature      NVARCHAR(50),
    production_support_signature_time DATETIME2,
    production_support_comment        NVARCHAR(255),
    hf_code                           NVARCHAR(100),
    PRIMARY KEY (id)
);

EXEC sp_addextendedproperty 'MS_Description', '技术状态鉴定工单变更', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, null, null;
EXEC sp_addextendedproperty 'MS_Description', '主键', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', id;
EXEC sp_addextendedproperty 'MS_Description', '创建人', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', create_by;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', create_time;
EXEC sp_addextendedproperty 'MS_Description', '更新人', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', update_by;
EXEC sp_addextendedproperty 'MS_Description', '更新时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', update_time;
EXEC sp_addextendedproperty 'MS_Description', '删除标记', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', del_flag;
EXEC sp_addextendedproperty 'MS_Description', '工单ID', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', order_id;
EXEC sp_addextendedproperty 'MS_Description', '变更单号', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', change_order_num;
EXEC sp_addextendedproperty 'MS_Description', '申请人', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', applicant;
EXEC sp_addextendedproperty 'MS_Description', '申请部门', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', factory_org_code;
EXEC sp_addextendedproperty 'MS_Description', '申请日期', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', apply_date;
EXEC sp_addextendedproperty 'MS_Description', '变更状态;待提交、待主管审核、待部门确认、待保障部确认、已作废、已完成',
     'SCHEMA', dbo, 'table', eam_technical_status_evaluation_order_change, 'column', change_status;
EXEC sp_addextendedproperty 'MS_Description',
     '变更原因;生产任务急无法停机、设备故障正处于维修状态、设备已报废、设备大修、搬迁、改造', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', apply_reason;
EXEC sp_addextendedproperty 'MS_Description', '变更鉴定日期', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', deferred_maintenance_date;
EXEC sp_addextendedproperty 'MS_Description', '主管领导签字', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', equipment_manager_signature;
EXEC sp_addextendedproperty 'MS_Description', '主管领导签字时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', equipment_manager_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '部门领导签字;根据变更原因类型区分不同的人审批', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', depart_manager_signature;
EXEC sp_addextendedproperty 'MS_Description', '部门领导签字时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', depart_manager_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '部门领导意见', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', depart_manager_comment;
EXEC sp_addextendedproperty 'MS_Description', '生产保障部领导签字', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', production_support_signature;
EXEC sp_addextendedproperty 'MS_Description', '生产保障部领导签字时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', production_support_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '生产保障部领导意见', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', production_support_comment;
EXEC sp_addextendedproperty 'MS_Description', 'HF编码', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_order_change, 'column', hf_code;


--技术状态变更申请
IF EXISTS (SELECT *
           FROM sys.objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_change]')
             AND type in (N'U'))
    DROP TABLE [dbo].[eam_technical_status_change];
CREATE TABLE [dbo].[eam_technical_status_change]
(
    id                              NVARCHAR(32) NOT NULL,
    create_by                       NVARCHAR(50),
    create_time                     DATETIME2,
    update_by                       NVARCHAR(50),
    update_time                     DATETIME2,
    del_flag                        INT,
    change_order_num                NVARCHAR(100),
    change_status                   NVARCHAR(64),
    designer                        NVARCHAR(50),
    designer_time                   DATETIME2,
    depart_header_signature         NVARCHAR(50),
    depart_header_signature_time    DATETIME2,
    depart_header_signature_comment NVARCHAR(255),
    depart_leader_signature         NVARCHAR(50),
    depart_leader_signature_time    DATETIME2,
    depart_leader_signature_comment NVARCHAR(255),
    hf_code                         NVARCHAR(100),
    PRIMARY KEY (id)
);

EXEC sp_addextendedproperty 'MS_Description', '技术状态变更申请', 'SCHEMA', dbo, 'table', eam_technical_status_change,
     null, null;
EXEC sp_addextendedproperty 'MS_Description', '主键', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column', id;
EXEC sp_addextendedproperty 'MS_Description', '创建人', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column',
     create_by;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column',
     create_time;
EXEC sp_addextendedproperty 'MS_Description', '更新人', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column',
     update_by;
EXEC sp_addextendedproperty 'MS_Description', '更新时间', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column',
     update_time;
EXEC sp_addextendedproperty 'MS_Description', '删除标记', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column',
     del_flag;
EXEC sp_addextendedproperty 'MS_Description', '变更单号', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column',
     change_order_num;
EXEC sp_addextendedproperty 'MS_Description', '变更单状态', 'SCHEMA', dbo, 'table', eam_technical_status_change,
     'column', change_status;
EXEC sp_addextendedproperty 'MS_Description', '编制人', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column',
     designer;
EXEC sp_addextendedproperty 'MS_Description', '编制时间', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column',
     designer_time;
EXEC sp_addextendedproperty 'MS_Description', '使用单位室主管签字', 'SCHEMA', dbo, 'table', eam_technical_status_change,
     'column', depart_header_signature;
EXEC sp_addextendedproperty 'MS_Description', '使用单位室主管签字时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_change, 'column', depart_header_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '使用单位室主管意见', 'SCHEMA', dbo, 'table', eam_technical_status_change,
     'column', depart_header_signature_comment;
EXEC sp_addextendedproperty 'MS_Description', '使用单位部主管签字', 'SCHEMA', dbo, 'table', eam_technical_status_change,
     'column', depart_leader_signature;
EXEC sp_addextendedproperty 'MS_Description', '使用单位部主管签字时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_change, 'column', depart_leader_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '使用单位部主管签字', 'SCHEMA', dbo, 'table', eam_technical_status_change,
     'column', depart_leader_signature_comment;
EXEC sp_addextendedproperty 'MS_Description', 'HF编码', 'SCHEMA', dbo, 'table', eam_technical_status_change, 'column',
     hf_code;


--技术状态变更申请明细
IF EXISTS (SELECT *
           FROM sys.objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_change_detail]')
             AND type in (N'U'))
    DROP TABLE [dbo].[eam_technical_status_change_detail];
CREATE TABLE [dbo].[eam_technical_status_change_detail]
(
    id                      NVARCHAR(32) NOT NULL,
    create_by               NVARCHAR(50),
    create_time             DATETIME2,
    update_by               NVARCHAR(50),
    update_time             DATETIME2,
    equipment_id            NVARCHAR(32),
    change_category         NVARCHAR(64),
    change_date             DATETIME2,
    change_technical_status NVARCHAR(64),
    acceptance_checker      NVARCHAR(50),
    acceptance_check_time   DATETIME2,
    acceptance_check_result NVARCHAR(64),
    order_id                NVARCHAR(32),
    PRIMARY KEY (id)
);

EXEC sp_addextendedproperty 'MS_Description', '技术状态变更申请明细', 'SCHEMA', dbo, 'table',
     eam_technical_status_change_detail, null, null;
EXEC sp_addextendedproperty 'MS_Description', '主键', 'SCHEMA', dbo, 'table', eam_technical_status_change_detail,
     'column', id;
EXEC sp_addextendedproperty 'MS_Description', '创建人', 'SCHEMA', dbo, 'table', eam_technical_status_change_detail,
     'column', create_by;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table', eam_technical_status_change_detail,
     'column', create_time;
EXEC sp_addextendedproperty 'MS_Description', '更新人', 'SCHEMA', dbo, 'table', eam_technical_status_change_detail,
     'column', update_by;
EXEC sp_addextendedproperty 'MS_Description', '更新时间', 'SCHEMA', dbo, 'table', eam_technical_status_change_detail,
     'column', update_time;
EXEC sp_addextendedproperty 'MS_Description', '设备ID', 'SCHEMA', dbo, 'table', eam_technical_status_change_detail,
     'column', equipment_id;
EXEC sp_addextendedproperty 'MS_Description', '变更原因;搬迁、大修、改造、其他', 'SCHEMA', dbo, 'table',
     eam_technical_status_change_detail, 'column', change_category;
EXEC sp_addextendedproperty 'MS_Description', '变更日期', 'SCHEMA', dbo, 'table', eam_technical_status_change_detail,
     'column', change_date;
EXEC sp_addextendedproperty 'MS_Description', '变更后技术状态;变更通过后默认设备技术状态改为禁用', 'SCHEMA', dbo,
     'table', eam_technical_status_change_detail, 'column', change_technical_status;
EXEC sp_addextendedproperty 'MS_Description', '验收检查人', 'SCHEMA', dbo, 'table', eam_technical_status_change_detail,
     'column', acceptance_checker;
EXEC sp_addextendedproperty 'MS_Description', '验收检查时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_change_detail, 'column', acceptance_check_time;
EXEC sp_addextendedproperty 'MS_Description',
     '验收检查结果;大修、改造 需要填写验收结果，搬迁按照技术状态鉴定工单维护，其他暂未使用到，只预留此类型', 'SCHEMA', dbo,
     'table', eam_technical_status_change_detail, 'column', acceptance_check_result;
EXEC sp_addextendedproperty 'MS_Description', '技术状态鉴定工单ID;搬迁使用', 'SCHEMA', dbo, 'table',
     eam_technical_status_change_detail, 'column', order_id;


--加工设备技术鉴定申请
IF EXISTS (SELECT *
           FROM sys.objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_evaluation_application]')
             AND type in (N'U'))
    DROP TABLE [dbo].[eam_technical_status_evaluation_application];
CREATE TABLE [dbo].[eam_technical_status_evaluation_application]
(
    id                                NVARCHAR(32) NOT NULL,
    create_by                         NVARCHAR(50),
    create_time                       DATETIME2,
    update_by                         NVARCHAR(50),
    update_time                       DATETIME2,
    del_flag                          INT,
    application_order_num             NVARCHAR(100),
    applicant                         NVARCHAR(50),
    factory_org_code                  NVARCHAR(100),
    apply_date                        DATETIME2,
    application_status                NVARCHAR(64),
    depart_header_signature           NVARCHAR(50),
    depart_header_signature_time      DATETIME2,
    depart_header_comment             NVARCHAR(255),
    production_header_signature       NVARCHAR(50),
    production_header_signature_time  DATETIME2,
    production_header_comment         NVARCHAR(255),
    production_support_signature      NVARCHAR(50),
    production_support_signature_time DATETIME2,
    production_support_comment        NVARCHAR(255),
    hf_code                           NVARCHAR(100),
    PRIMARY KEY (id)
);

EXEC sp_addextendedproperty 'MS_Description', '加工设备技术鉴定申请;禁用状态的设备或临时进行技术鉴定时使用', 'SCHEMA',
     dbo, 'table', eam_technical_status_evaluation_application, null, null;
EXEC sp_addextendedproperty 'MS_Description', '主键', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', id;
EXEC sp_addextendedproperty 'MS_Description', '创建人', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', create_by;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', create_time;
EXEC sp_addextendedproperty 'MS_Description', '更新人', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', update_by;
EXEC sp_addextendedproperty 'MS_Description', '更新时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', update_time;
EXEC sp_addextendedproperty 'MS_Description', '删除标记', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', del_flag;
EXEC sp_addextendedproperty 'MS_Description', '申请单号', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', application_order_num;
EXEC sp_addextendedproperty 'MS_Description', '申请人', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', applicant;
EXEC sp_addextendedproperty 'MS_Description', '申请部门', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', factory_org_code;
EXEC sp_addextendedproperty 'MS_Description', '申请日期', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', apply_date;
EXEC sp_addextendedproperty 'MS_Description',
     '申请单状态;待提交、待单位室级领导审核、生产设备管理主管审核、待保障部领导审核、已作废、已完成', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', application_status;
EXEC sp_addextendedproperty 'MS_Description', '申请单位室级领导签字', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', depart_header_signature;
EXEC sp_addextendedproperty 'MS_Description', '申请单位室级领导签字时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', depart_header_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '申请单位室级领导意见', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', depart_header_comment;
EXEC sp_addextendedproperty 'MS_Description', '生产设备管理主管签字', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', production_header_signature;
EXEC sp_addextendedproperty 'MS_Description', '生产设备管理主管签字四件', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', production_header_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '生产设备管理主管意见', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', production_header_comment;
EXEC sp_addextendedproperty 'MS_Description', '生产保障部领导签字', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', production_support_signature;
EXEC sp_addextendedproperty 'MS_Description', '生产保障部领导签字时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', production_support_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '生产保障部领导意见', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', production_support_comment;
EXEC sp_addextendedproperty 'MS_Description', 'HF编码', 'SCHEMA', dbo, 'table',
     eam_technical_status_evaluation_application, 'column', hf_code;

--停用加工设备申请单
IF EXISTS (SELECT *
           FROM sys.objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_deactivate]')
             AND type in (N'U'))
    DROP TABLE [dbo].[eam_technical_status_deactivate];
CREATE TABLE [dbo].[eam_technical_status_deactivate]
(
    id                              NVARCHAR(32) NOT NULL,
    create_by                       NVARCHAR(50),
    create_time                     DATETIME2,
    update_by                       NVARCHAR(50),
    update_time                     DATETIME2,
    del_flag                        INT,
    deactivate_order_num            NVARCHAR(100),
    applicant                       NVARCHAR(50),
    factory_org_code                NVARCHAR(100),
    apply_date                      DATETIME2,
    application_status              NVARCHAR(64),
    depart_header_signature         NVARCHAR(50),
    depart_header_signature_time    DATETIME2,
    depart_header_signature_comment NVARCHAR(255),
    depart_leader_signature         NVARCHAR(50),
    depart_leader_signature_time    DATETIME2,
    depart_leader_signature_comment NVARCHAR(255),
    hf_code                         NVARCHAR(100),
    PRIMARY KEY (id)
);

EXEC sp_addextendedproperty 'MS_Description', '停用加工设备申请单;申请单位申请停用设备，审批通过后修改设备状态为禁用',
     'SCHEMA', dbo, 'table', eam_technical_status_deactivate, null, null;
EXEC sp_addextendedproperty 'MS_Description', '主键', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate, 'column',
     id;
EXEC sp_addextendedproperty 'MS_Description', '创建人', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', create_by;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', create_time;
EXEC sp_addextendedproperty 'MS_Description', '更新人', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', update_by;
EXEC sp_addextendedproperty 'MS_Description', '更新时间', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', update_time;
EXEC sp_addextendedproperty 'MS_Description', '删除标记', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', del_flag;
EXEC sp_addextendedproperty 'MS_Description', '停用单号', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', deactivate_order_num;
EXEC sp_addextendedproperty 'MS_Description', '申请人', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', applicant;
EXEC sp_addextendedproperty 'MS_Description', '申请部门', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', factory_org_code;
EXEC sp_addextendedproperty 'MS_Description', '申请日期', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', apply_date;
EXEC sp_addextendedproperty 'MS_Description',
     '申请单状态;待提交、待单位室级领导审核、生产设备管理主管审核、待保障部领导审核、已作废、已完成', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate, 'column', application_status;
EXEC sp_addextendedproperty 'MS_Description', '使用单位室主管签字', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate, 'column', depart_header_signature;
EXEC sp_addextendedproperty 'MS_Description', '使用单位室主管签字时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate, 'column', depart_header_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '使用单位室主管意见', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate, 'column', depart_header_signature_comment;
EXEC sp_addextendedproperty 'MS_Description', '使用单位部主管签字', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate, 'column', depart_leader_signature;
EXEC sp_addextendedproperty 'MS_Description', '使用单位部主管签字时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate, 'column', depart_leader_signature_time;
EXEC sp_addextendedproperty 'MS_Description', '使用单位部主管签字', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate, 'column', depart_leader_signature_comment;
EXEC sp_addextendedproperty 'MS_Description', 'HF编码', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate,
     'column', hf_code;


--停用加工设备明细
IF EXISTS (SELECT *
           FROM sys.objects
           WHERE object_id = OBJECT_ID(N'[dbo].[eam_technical_status_deactivate_detail]')
             AND type in (N'U'))
    DROP TABLE [dbo].[eam_technical_status_deactivate_detail];
CREATE TABLE [dbo].[eam_technical_status_deactivate_detail]
(
    id                       NVARCHAR(32) NOT NULL,
    create_by                NVARCHAR(50),
    create_time              DATETIME2,
    update_by                NVARCHAR(50),
    update_time              DATETIME2,
    equipment_id             NVARCHAR(32),
    deactivate_reason        NVARCHAR(255),
    deactivate_duration      NUMERIC(24, 4),
    deactivate_duration_unit NVARCHAR(64),
    PRIMARY KEY (id)
);

EXEC sp_addextendedproperty 'MS_Description', '停用加工设备明细', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate_detail, null, null;
EXEC sp_addextendedproperty 'MS_Description', '主键', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate_detail,
     'column', id;
EXEC sp_addextendedproperty 'MS_Description', '创建人', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate_detail,
     'column', create_by;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate_detail, 'column', create_time;
EXEC sp_addextendedproperty 'MS_Description', '更新人', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate_detail,
     'column', update_by;
EXEC sp_addextendedproperty 'MS_Description', '更新时间', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate_detail, 'column', update_time;
EXEC sp_addextendedproperty 'MS_Description', '设备ID', 'SCHEMA', dbo, 'table', eam_technical_status_deactivate_detail,
     'column', equipment_id;
EXEC sp_addextendedproperty 'MS_Description', '停用原因', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate_detail, 'column', deactivate_reason;
EXEC sp_addextendedproperty 'MS_Description', '停用时长', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate_detail, 'column', deactivate_duration;
EXEC sp_addextendedproperty 'MS_Description', '停用时长单位;天、月、年', 'SCHEMA', dbo, 'table',
     eam_technical_status_deactivate_detail, 'column', deactivate_duration_unit;
