﻿/* 设备主权限 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP', N'设备', N'BIZ', N'SYSADMIN', GETDATE() );
END;

/* 软件配置 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_BASE_CONFIG'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_BASE_CONFIG', N'软件配置', N'BIZ_EQUIP', N'SYSADMIN', GETDATE() );
END;

/* 设备软件的设备信息权限 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_DEVICE'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_DEVICE', N'设备数据权限', N'BIZ_EQUIP', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_DEVICE_01'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_DEVICE_01', N'设备新增', N'BIZ_EQUIP_DEVICE', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_DEVICE_02'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_DEVICE_02', N'设备修改', N'BIZ_EQUIP_DEVICE', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_DEVICE_03'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_DEVICE_03', N'设备状态修改', N'BIZ_EQUIP_DEVICE', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_DEVICE_OEM'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_DEVICE_OEM', N'设备的OEM数据权限', N'BIZ_EQUIP_DEVICE', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_DEVICE_KH'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_DEVICE_KH', N'设备的KH数据权限', N'BIZ_EQUIP_DEVICE', N'SYSADMIN', GETDATE() );
END;



/* 设备保修 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_001'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_001', N'设备报修', N'BIZ_EQUIP', N'SYSADMIN', GETDATE() );
END;



/* Tag 红卡片 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_TAG'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_TAG', N'Tag', N'BIZ_EQUIP', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_TAG_01'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_TAG_01', N'Tag查看', N'BIZ_EQUIP_TAG', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_TAG_02'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_TAG_02', N'Tag新增', N'BIZ_EQUIP_TAG', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_TAG_03'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_TAG_03', N'Tag修改', N'BIZ_EQUIP_TAG', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_TAG_04'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_TAG_04', N'Tag维修', N'BIZ_EQUIP_TAG', N'SYSADMIN', GETDATE() );
END;


/* PM保养权限 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_PM'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM', N'设备的PM保养', N'BIZ_EQUIP', N'SYSADMIN', GETDATE() );
END;



/* PM 保养计划 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_PM_PLAN'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PLAN', N'设备的PM保养计划', N'BIZ_EQUIP_PM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PLAN_01', N'设备的PM保养计划查看', N'BIZ_EQUIP_PM_PLAN', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PLAN_02', N'设备的PM保养计划新增', N'BIZ_EQUIP_PM_PLAN', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PLAN_03', N'设备的PM保养计划编辑', N'BIZ_EQUIP_PM_PLAN', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PLAN_04', N'设备的PM保养计划导入', N'BIZ_EQUIP_PM_PLAN', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PLAN_05', N'设备的PM保养计划删除', N'BIZ_EQUIP_PM_PLAN', N'SYSADMIN', GETDATE() );
END;

/* AM 保养计划 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_AM_PLAN'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PLAN', N'设备的AM保养计划', N'BIZ_EQUIP_AM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PLAN_01', N'设备的AM保养计划查看', N'BIZ_EQUIP_AM_PLAN', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PLAN_02', N'设备的AM保养计划新增', N'BIZ_EQUIP_AM_PLAN', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PLAN_03', N'设备的AM保养计划编辑', N'BIZ_EQUIP_AM_PLAN', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PLAN_04', N'设备的AM保养计划导入', N'BIZ_EQUIP_AM_PLAN', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PLAN_05', N'设备的AM保养计划删除', N'BIZ_EQUIP_AM_PLAN', N'SYSADMIN', GETDATE() );
END;

/* AM保养权限 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_AM'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM', N'设备的AM保养', N'BIZ_EQUIP', N'SYSADMIN', GETDATE() );
END;

/* PM 点检表*/
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_PM_FORM'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_FORM', N'设备的PM点检表', N'BIZ_EQUIP_PM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_PM_FORM_01'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_FORM_01', N'设备的PM点检表查看', N'BIZ_EQUIP_PM_FORM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_PM_FORM_02'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_FORM_02', N'设备的PM点检表新增', N'BIZ_EQUIP_PM_FORM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_PM_FORM_03'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_FORM_03', N'设备的PM点检表修改', N'BIZ_EQUIP_PM_FORM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_PM_FORM_04'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_FORM_04', N'设备的PM点检表启用/禁用', N'BIZ_EQUIP_PM_FORM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_PM_FORM_05'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_FORM_05', N'设备的PM点检表分配', N'BIZ_EQUIP_PM_FORM', N'SYSADMIN', GETDATE() );
END;

/* AM 点检表*/
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_AM_FORM'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_FORM', N'设备的AM点检表', N'BIZ_EQUIP_AM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_AM_FORM_01'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_FORM_01', N'设备的AM点检表查看', N'BIZ_EQUIP_AM_FORM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_AM_FORM_02'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_FORM_02', N'设备的AM点检表新增', N'BIZ_EQUIP_AM_FORM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_AM_FORM_03'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_FORM_03', N'设备的AM点检表修改', N'BIZ_EQUIP_AM_FORM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_AM_FORM_04'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_FORM_04', N'设备的AM点检表启用/禁用', N'BIZ_EQUIP_AM_FORM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_AM_FORM_05'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_FORM_05', N'设备的AM点检表分配', N'BIZ_EQUIP_AM_FORM', N'SYSADMIN', GETDATE() );
END;

/* 设备的PM保养 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_PM_PRESERVE'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PRESERVE', N'PM的设备保养', N'BIZ_EQUIP_PM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PRESERVE_01', N'PM的设备保养记录查看', N'BIZ_EQUIP_PM_PRESERVE', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PRESERVE_02', N'PM的设备保养记录新增', N'BIZ_EQUIP_PM_PRESERVE', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_PM_PRESERVE_03', N'PM的设备保养记录修改', N'BIZ_EQUIP_PM_PRESERVE', N'SYSADMIN', GETDATE() );
END;

/* 设备的AM保养 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_AM_PRESERVE'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PRESERVE', N'AM的设备保养', N'BIZ_EQUIP_AM', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PRESERVE_01', N'AM的设备保养记录查看', N'BIZ_EQUIP_AM_PRESERVE', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PRESERVE_02', N'AM的设备保养记录新增', N'BIZ_EQUIP_AM_PRESERVE', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_AM_PRESERVE_03', N'AM的设备保养记录修改', N'BIZ_EQUIP_AM_PRESERVE', N'SYSADMIN', GETDATE() );
END;


/* 设备维修 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_REPAIRRECORD'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_REPAIRRECORD', N'设备维修', N'BIZ_EQUIP', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_REPAIRRECORD_01', N'设备维修查看', N'BIZ_EQUIP_REPAIRRECORD', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_REPAIRRECORD_02', N'设备维修编辑', N'BIZ_EQUIP_REPAIRRECORD', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_REPAIRRECORD_03', N'设备维修导入', N'BIZ_EQUIP_REPAIRRECORD', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_REPAIRRECORD_04', N'设备维修确认权限-工程师', N'BIZ_EQUIP_REPAIRRECORD', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_REPAIRRECORD_05', N'设备维修确认权限-技术人员', N'BIZ_EQUIP_REPAIRRECORD', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = '[REDACTED]'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_REPAIRRECORD_06', N'设备维修确认权限-维修主管', N'BIZ_EQUIP_REPAIRRECORD', N'SYSADMIN', GETDATE() );
END;


/* 字段配置 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD', N'字段配置', N'BIZ_EQUIP', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION', N'现象区分', N'BIZ_EQUIP_FIELD', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION_01'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION_01', N'现象区分新增', N'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION', N'SYSADMIN', GETDATE() );
END;


IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION_02'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION_02', N'现象区分编辑', N'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION', N'SYSADMIN', GETDATE() );
END;


IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION_03'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION_03', N'现象区分禁用/启用', N'BIZ_EQUIP_FIELD_SYMPTOMLDISTINCTION', N'SYSADMIN', GETDATE() );
END;



IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_MAINTENANCEN'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_MAINTENANCEN', N'维修方式', N'BIZ_EQUIP_FIELD', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_MAINTENANCEN_01'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_MAINTENANCEN_01', N'维修方式新增', N'BIZ_EQUIP_FIELD_MAINTENANCEN', N'SYSADMIN', GETDATE() );
END;


IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_MAINTENANCEN_02'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_MAINTENANCEN_02', N'维修方式编辑', N'BIZ_EQUIP_FIELD_MAINTENANCEN', N'SYSADMIN', GETDATE() );
END;


IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_MAINTENANCEN_03'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_MAINTENANCEN_03', N'维修方式禁用/启用', N'BIZ_EQUIP_FIELD_MAINTENANCEN', N'SYSADMIN', GETDATE() );
END;




IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_ACCESSORIES'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_ACCESSORIES', N'配件维护', N'BIZ_EQUIP_FIELD', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_ACCESSORIES_01'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_ACCESSORIES_01', N'配件维护新增', N'BIZ_EQUIP_FIELD_ACCESSORIES', N'SYSADMIN', GETDATE() );
END;


IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_ACCESSORIES_02'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_ACCESSORIES_02', N'配件维护编辑', N'BIZ_EQUIP_FIELD_ACCESSORIES', N'SYSADMIN', GETDATE() );
END;


IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_ACCESSORIES_03'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_ACCESSORIES_03', N'配件维护禁用/启用', N'BIZ_EQUIP_FIELD_ACCESSORIES', N'SYSADMIN', GETDATE() );
END;



IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED', N'故障发生地', N'BIZ_EQUIP_FIELD', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED_01'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED_01', N'故障发生地新增', N'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED', N'SYSADMIN', GETDATE() );
END;


IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED_02'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED_02', N'故障发生地编辑', N'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED', N'SYSADMIN', GETDATE() );
END;


IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED_03'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED_03', N'故障发生地禁用/启用', N'BIZ_EQUIP_FIELD_WHEREFAILUREOCCURRED', N'SYSADMIN', GETDATE() );
END;
