create table AccessInterfaceLog
(
	[Id] [bigint] NOT NULL,
	[Action] [int] NOT NULL,
	[OperateAddress] [nvarchar](200) NULL,
	[OperateUserId]  [nvarchar](200)  NULL,
	[OperateUserName]  [nvarchar](200)  NULL,
	[IPAddress] [nvarchar](50) NULL,
	[Param1] [nvarchar](200) NULL,
	[Param2] [nvarchar](200) NULL,
	[Param3] [nvarchar](200) NULL,
	[ParaJSON] [nvarchar](max) NULL,
	[ResultJson] [nvarchar](max) NULL,
	[Keys] [nvarchar](max) NULL,
	[CreatedTime] [datetimeoffset](7) NULL,
	[UpdatedTime] [datetimeoffset](7) NULL,
	[CreatedUserId] [bigint] NULL,
	[CreatedUserName] [nvarchar](50) NULL,
	[UpdatedUserId] [bigint] NULL,
	[UpdatedUserName] [nvarchar](50) NULL,
	[IsDeleted] [bit] NOT NULL,
)


--20231124

drop table KnifeToolEquipmentMonitor
drop table KnifeToolEquipmentInfo
drop table KnifeToolEquipmentInfoLog
drop table KnifeToolEquipmentUpdateLog


IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[KnifeToolEquipmentMonitor]') AND type in (N'U')) DROP TABLE [dbo].[KnifeToolEquipmentMonitor];
CREATE TABLE [dbo].[KnifeToolEquipmentMonitor](
	[Id] [bigint] NOT NULL,
    EquipmentID VARCHAR(32),
    WorkingProcedure VARCHAR(32),
    Remarks1 VARCHAR(255),
    Remarks2 VARCHAR(255),
    Remarks3 VARCHAR(255),
	[CreatedTime] [datetime2](7) NULL,
	[UpdatedTime] [datetime2](7) NULL,
	[CreatedUserId] [bigint] NULL,
	[CreatedUserName] [nvarchar](50) NULL,
	[UpdatedUserId] [bigint] NULL,
	[UpdatedUserName] [nvarchar](50) NULL,
	[IsDeleted] [bit] NOT NULL,
);

EXEC sp_addextendedproperty 'MS_Description', '设备刀具信息监控', 'SCHEMA', dbo, 'table', KnifeToolEquipmentMonitor, null, null;
EXEC sp_addextendedproperty 'MS_Description', '设备编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentMonitor, 'column', EquipmentID;
EXEC sp_addextendedproperty 'MS_Description', '工序编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentMonitor, 'column', WorkingProcedure;
EXEC sp_addextendedproperty 'MS_Description', '备注1', 'SCHEMA', dbo, 'table', KnifeToolEquipmentMonitor, 'column', Remarks1;
EXEC sp_addextendedproperty 'MS_Description', '备注2', 'SCHEMA', dbo, 'table', KnifeToolEquipmentMonitor, 'column', Remarks2;
EXEC sp_addextendedproperty 'MS_Description', '备注3', 'SCHEMA', dbo, 'table', KnifeToolEquipmentMonitor, 'column', Remarks3;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[KnifeToolEquipmentInfo]') AND type in (N'U')) DROP TABLE [dbo].[KnifeToolEquipmentInfo];
CREATE TABLE [dbo].[KnifeToolEquipmentInfo](
	[Id] [bigint] NOT NULL,
    EquipmentID VARCHAR(32),
    WorkingProcedure VARCHAR(32),
    Station VARCHAR(255),
    KnifeToolID VARCHAR(255),
    KnifeToolName VARCHAR(255),
    StartLife INT,
    CurrentLife INT,
    ChangeStartTime [datetime2](7) NULL,
    Remarks1 VARCHAR(255),
    Remarks2 VARCHAR(255),
    Remarks3 VARCHAR(255),
	[CreatedTime] [datetime2](7) NULL,
	[UpdatedTime] [datetime2](7) NULL,
	[CreatedUserId] [bigint] NULL,
	[CreatedUserName] [nvarchar](50) NULL,
	[UpdatedUserId] [bigint] NULL,
	[UpdatedUserName] [nvarchar](50) NULL,
	[IsDeleted] [bit] NOT NULL,
);

EXEC sp_addextendedproperty 'MS_Description', '设备刀具详情表', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, null, null;
EXEC sp_addextendedproperty 'MS_Description', '设备编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', EquipmentID;
EXEC sp_addextendedproperty 'MS_Description', '工序编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', WorkingProcedure;
EXEC sp_addextendedproperty 'MS_Description', '工位', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', Station;
EXEC sp_addextendedproperty 'MS_Description', '刀具编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', KnifeToolID;
EXEC sp_addextendedproperty 'MS_Description', '刀具名称', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', KnifeToolName;
EXEC sp_addextendedproperty 'MS_Description', '换上时寿命', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', StartLife;
EXEC sp_addextendedproperty 'MS_Description', '当前寿命', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', CurrentLife;
EXEC sp_addextendedproperty 'MS_Description', '换上时间', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', ChangeStartTime;
EXEC sp_addextendedproperty 'MS_Description', '备注1', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', Remarks1;
EXEC sp_addextendedproperty 'MS_Description', '备注2', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', Remarks2;
EXEC sp_addextendedproperty 'MS_Description', '备注3', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfo, 'column', Remarks3;


IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[KnifeToolEquipmentInfoLog]') AND type in (N'U')) DROP TABLE [dbo].[KnifeToolEquipmentInfoLog];
CREATE TABLE [dbo].[KnifeToolEquipmentInfoLog](
	[Id] [bigint] NOT NULL,
    EquipmentID VARCHAR(32),
    WorkingProcedure VARCHAR(32),
    Station VARCHAR(255),
    KnifeToolID VARCHAR(255),
    KnifeToolName VARCHAR(255),
    StartLife INT,
    CurrentLife INT,
    ResidueLife INT,
    ChangeStartTime [datetime2](7) NULL,
    ChangeEndTime [datetime2](7) NULL,
    Remarks1 VARCHAR(255),
    Remarks2 VARCHAR(255),
    Remarks3 VARCHAR(255),
	[CreatedTime] [datetime2](7) NULL,
	[UpdatedTime] [datetime2](7) NULL,
	[CreatedUserId] [bigint] NULL,
	[CreatedUserName] [nvarchar](50) NULL,
	[UpdatedUserId] [bigint] NULL,
	[UpdatedUserName] [nvarchar](50) NULL,
	[IsDeleted] [bit] NOT NULL,
);

EXEC sp_addextendedproperty 'MS_Description', '设备刀具更换履历表', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, null, null;
EXEC sp_addextendedproperty 'MS_Description', '设备编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', EquipmentID;
EXEC sp_addextendedproperty 'MS_Description', '工序编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', WorkingProcedure;
EXEC sp_addextendedproperty 'MS_Description', '工位', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', Station;
EXEC sp_addextendedproperty 'MS_Description', '刀具编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', KnifeToolID;
EXEC sp_addextendedproperty 'MS_Description', '刀具名称', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', KnifeToolName;
EXEC sp_addextendedproperty 'MS_Description', '换上时寿命', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', StartLife;
EXEC sp_addextendedproperty 'MS_Description', '当前寿命', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', CurrentLife;
EXEC sp_addextendedproperty 'MS_Description', '剩余寿命', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', ResidueLife;
EXEC sp_addextendedproperty 'MS_Description', '换上时间', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', ChangeStartTime;
EXEC sp_addextendedproperty 'MS_Description', '换下时间', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', ChangeEndTime;
EXEC sp_addextendedproperty 'MS_Description', '备注1', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', Remarks1;
EXEC sp_addextendedproperty 'MS_Description', '备注2', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', Remarks2;
EXEC sp_addextendedproperty 'MS_Description', '备注3', 'SCHEMA', dbo, 'table', KnifeToolEquipmentInfoLog, 'column', Remarks3;


IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[KnifeToolEquipmentUpdateLog]') AND type in (N'U')) DROP TABLE [dbo].[KnifeToolEquipmentUpdateLog];
CREATE TABLE [dbo].[KnifeToolEquipmentUpdateLog](
	[Id] [bigint] NOT NULL,
    EquipmentID VARCHAR(32),
    WorkingProcedure VARCHAR(32),
    Station VARCHAR(255),
    KnifeToolID VARCHAR(255),
    KnifeToolName VARCHAR(255),
    StartLife INT,
    CurrentLife INT,
    ResidueLife INT,
    ChangeStartTime  [datetime2](7) NULL,
    ChangeEndTime  [datetime2](7) NULL,
    OperateDesc VARCHAR(900),
    Remarks1 VARCHAR(255),
    Remarks2 VARCHAR(255),
    Remarks3 VARCHAR(255),
	[CreatedTime] [datetime2](7) NULL,
	[UpdatedTime] [datetime2](7) NULL,
	[CreatedUserId] [bigint] NULL,
	[CreatedUserName] [nvarchar](50) NULL,
	[UpdatedUserId] [bigint] NULL,
	[UpdatedUserName] [nvarchar](50) NULL,
	[IsDeleted] [bit] NOT NULL,
);

EXEC sp_addextendedproperty 'MS_Description', '设备刀具操作日志表', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, null, null;
EXEC sp_addextendedproperty 'MS_Description', '设备编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', EquipmentID;
EXEC sp_addextendedproperty 'MS_Description', '工序编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', WorkingProcedure;
EXEC sp_addextendedproperty 'MS_Description', '工位', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', Station;
EXEC sp_addextendedproperty 'MS_Description', '刀具编号', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', KnifeToolID;
EXEC sp_addextendedproperty 'MS_Description', '刀具名称', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', KnifeToolName;
EXEC sp_addextendedproperty 'MS_Description', '换上时寿命', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', StartLife;
EXEC sp_addextendedproperty 'MS_Description', '当前寿命', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', CurrentLife;
EXEC sp_addextendedproperty 'MS_Description', '剩余寿命', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', ResidueLife;
EXEC sp_addextendedproperty 'MS_Description', '换上时间', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', ChangeStartTime;
EXEC sp_addextendedproperty 'MS_Description', '换下时间', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', ChangeEndTime;
EXEC sp_addextendedproperty 'MS_Description', '操作描述', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', OperateDesc;
EXEC sp_addextendedproperty 'MS_Description', '备注1', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', Remarks1;
EXEC sp_addextendedproperty 'MS_Description', '备注2', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', Remarks2;
EXEC sp_addextendedproperty 'MS_Description', '备注3', 'SCHEMA', dbo, 'table', KnifeToolEquipmentUpdateLog, 'column', Remarks3;



USE [iWare.SCADA]
GO

/****** Object:  Table [dbo].[EquipmentQualityConfig]    Script Date: 2023/11/29 9:35:10 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[EquipmentQualityConfig](
	[Id] [bigint] NOT NULL,
	[MeasureTool] [varchar](255) NULL,
	[WorkingProcedure] [varchar](32) NULL,
	[ParamCode] [varchar](255) NULL,
	[ParamDesc] [varchar](255) NULL,
	[StandardValue] [varchar](255) NULL,
	[UpperTolerance] [varchar](255) NULL,
	[LowerTolerance] [varchar](255) NULL,
	[ParamColName] [varchar](255) NULL,
	[DecimalPlaces] [int] NULL,
	[Unit] [varchar](255) NULL,
	[ParamType] [int] NULL,
	[Remarks] [varchar](255) NULL,
	[CreatedTime] [datetime2](7) NULL,
	[UpdatedTime] [datetime2](7) NULL,
	[CreatedUserId] [bigint] NULL,
	[CreatedUserName] [nvarchar](50) NULL,
	[UpdatedUserId] [bigint] NULL,
	[UpdatedUserName] [nvarchar](50) NULL,
	[IsDeleted] [bit] NOT NULL
) ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'量具' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'MeasureTool'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'工序' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'WorkingProcedure'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'参数编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'ParamCode'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'参数名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'ParamDesc'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'名义值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'StandardValue'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'下公差' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'UpperTolerance'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上公差' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'LowerTolerance'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'参数列名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'ParamColName'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'参数类型(1:柔性 2：其他)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'ParamType'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig', @level2type=N'COLUMN',@level2name=N'Remarks'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'质量数据标准值配置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EquipmentQualityConfig'
GO

