﻿/* 设备主权限 */
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_72'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_72', N'跳过当天保养计划校验', N'BIZ_EQUIP', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_73'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_73', N'跳过当天保养计划校验查看', N'BIZ_EQUIP_72', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_74'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_74', N'跳过当天保养计划校验新增', N'BIZ_EQUIP_72', N'SYSADMIN', GETDATE() );
END;

IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_75'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_75', N'跳过当天保养计划校验删除', N'BIZ_EQUIP_72', N'SYSADMIN', GETDATE() );
END;

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

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

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

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

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

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

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

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

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

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

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

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


/* PM保养权限 */
IF NOT EXISTS
(
    SELECT TOP (1)
           *
    FROM dbo.Auths WITH (NOLOCK)
    WHERE AuthCode = 'BIZ_EQUIP_25'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_25', 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_26'
)
BEGIN
    INSERT INTO SFCData.dbo.Auths
    (
        AuthCode,
        AuthName,
        FatherAuthCode,
        CreateBy,
        CreateOn
    )
    VALUES
    (N'BIZ_EQUIP_26', N'设备的PM保养计划', N'BIZ_EQUIP_25', N'SYSADMIN', GETDATE() );
END;

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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