-- 拆盘临时表：用于暂存拆盘任务电芯列表，供批量确认时使用
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Dt_SplitTemp]') AND type in (N'U'))
BEGIN
    CREATE TABLE [dbo].[Dt_SplitTemp](
        [Id] [int] IDENTITY(1,1) NOT NULL,
        [PalletCode] [nvarchar](50) NOT NULL,
        [SfcList] [nvarchar](max) NOT NULL,
        [CreateTime] [datetime] NOT NULL DEFAULT GETDATE(),
        CONSTRAINT [PK_Dt_SplitTemp] PRIMARY KEY CLUSTERED ([Id] ASC)
    );

    -- 唯一索引防止同一托盘重复写入
    CREATE UNIQUE NONCLUSTERED INDEX [IX_Dt_SplitTemp_PalletCode] ON [dbo].[Dt_SplitTemp]([PalletCode] ASC);
END
GO
