Basf_TCC7/HJGL/DataBase/版本日志/BSFDB_2019.06.29.sql

146 lines
11 KiB
MySQL
Raw Normal View History

2024-05-08 10:02:08 +08:00
<EFBFBD><EFBFBD> INSERT INTO dbo.Base_UnitType(UnitTypeId, UnitTypeName)
VALUES ( '1','<00>^<5E><><EFBFBD>e')
INSERT INTO dbo.Base_UnitType(UnitTypeId, UnitTypeName)
VALUES ( '2',';`bSFU')
INSERT INTO dbo.Base_UnitType(UnitTypeId, UnitTypeName)
VALUES ( '3','<00>vt')
INSERT INTO dbo.Base_UnitType(UnitTypeId, UnitTypeName)
VALUES ( '4','<00>hKm')
INSERT INTO dbo.Base_UnitType(UnitTypeId, UnitTypeName)
VALUES ( '5','<00>e<EFBFBD>]')
GO
ALTER TABLE dbo.Sys_DataInTemp ADD Value35 nvarchar(100) NULL
GO
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Sys_RolePower]') AND name = N'IX_Sys_RolePower_RoleId_ProjectId')
DROP INDEX [IX_Sys_RolePower_RoleId_ProjectId] ON [dbo].[Sys_RolePower] WITH ( ONLINE = OFF )
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Sys_RolePower_RoleId_MenuId] ON [dbo].[Sys_RolePower]
(
[RoleId] ASC,
[MenuId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER PROCEDURE [dbo].[SpGetNewCode]
@tableName VARCHAR(50),/*h<EFBFBD> T*/
@columnName VARCHAR(50),/*R T*/
@projectId NVARCHAR(50),/*y<EFBFBD><EFBFBD>v*/
@prefix VARCHAR(50),/*Am4l<EFBFBD>SxMR*/
@returnVal NVARCHAR(50) OUTPUT
AS
/*<EFBFBD><EFBFBD><EFBFBD>SN*N<EFBFBD>e<EFBFBD>vAm4l<EFBFBD>S<EFBFBD>T<EFBFBD>NMO
N<EFBFBD>X<EFBFBD>R <EFBFBD>*/
DECLARE
@sql NVARCHAR(500),
@old NVARCHAR(50),
@newid VARCHAR(50),
@maxId NVARCHAR(50)/*<EFBFBD>]RM<EFBFBD><EFBFBD>vg'Y<P*/
SELECT @sql=N'SELECT @maxId=MAX('+@columnName+') from '+@tableName+' where ProjectId = ''' + @projectId + ''' and ' + @columnName+' like ' + '''%' + @prefix + '%'''
EXEC sp_executesql @sql, N'@maxId nvarchar(50) OUTPUT', @maxId OUTPUT
/*<EFBFBD>V:NgTW[2NS<EFBFBD>bR1 <EFBFBD>K1 <EFBFBD>@b<EFBFBD>NُHNYt*/
SET @old=REVERSE(SUBSTRING(REVERSE(@maxId),1,CHARINDEX('-',REVERSE(@maxId))-1))
IF(@old IS NULL)
BEGIN
SET @newid=@prefix+'00001'
END
ELSE
BEGIN
SET @newid = (SELECT MAX(LEFT(@old,5)))+1
SET @newid = @prefix +RIGHT('00000'+@newid,5)
END
SET @returnVal=@newid
GO
CREATE PROCEDURE [dbo].[SpGetThreeNumber]
@tableName VARCHAR(50),/*h<EFBFBD> T*/
@columnName VARCHAR(50),/*R T*/
@projectId NVARCHAR(50),/*y<EFBFBD><EFBFBD>v*/
@prefix VARCHAR(50),/*Am4l<EFBFBD>SxMR*/
@returnVal NVARCHAR(50) OUTPUT
AS
/*<EFBFBD><EFBFBD><EFBFBD>S NMOAm4l<EFBFBD>S<EFBFBD>T NMO
N<EFBFBD>X<EFBFBD>R <EFBFBD>*/
DECLARE
@sql NVARCHAR(500),
@old NVARCHAR(50),
@newid VARCHAR(50),
@maxId NVARCHAR(50)/*<EFBFBD>]RM<EFBFBD><EFBFBD>vg'Y<P*/
SELECT @sql=N'SELECT @maxId=MAX('+@columnName+') from '+@tableName+' where ProjectId = ''' + @projectId + ''' and ' + @columnName+' like ' + '''%' + @prefix + '%'''
EXEC sp_executesql @sql, N'@maxId nvarchar(50) OUTPUT', @maxId OUTPUT
SET @old=@maxId
IF(@old IS NULL)
BEGIN
SET @newid=@prefix+'001'
END
ELSE
BEGIN
SET @newid = (SELECT MAX(RIGHT(@old,3)))+1
SET @newid = @prefix +RIGHT('000'+@newid,3)
END
SET @returnVal=@newid
GO
ALTER VIEW [dbo].[View_GenerateTrust]
AS
-------ck8^<EFBFBD>p<EFBFBD>Sub<EFBFBD>YXb-----------
SELECT point.ProjectId,point.InstallationId,pipe.WorkAreaId ,point.UnitId,point.DetectionTypeId,
jot.PipelineId,'1' AS PointState,CAST(0 AS BIT) AS IsCheckRepair, NULL AS TrustBatchCode
FROM dbo.Batch_PointBatchItem pointItem
LEFT JOIN dbo.Batch_PointBatch point ON point.PointBatchId = pointItem.PointBatchId
LEFT JOIN dbo.Pipeline_WeldJoint jot ON jot.WeldJointId = pointItem.WeldJointId
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
WHERE pointItem.PointState ='1' AND point.EndDate IS NOT NULL AND pointItem.CutDate IS NULL
AND (pointItem.IsBuildTrust IS NULL OR pointItem.IsBuildTrust=0) AND point.IsTrust=0
AND pointItem.IsCheckRepair=0
GROUP BY point.ProjectId,point.InstallationId,pipe.WorkAreaId,point.UnitId,point.DetectionTypeId,
jot.PipelineId
UNION ALL
-------ib<EFBFBD>ub<EFBFBD>YXb-----------
SELECT point.ProjectId,point.InstallationId,pipe.WorkAreaId ,point.UnitId,point.DetectionTypeId,
jot.PipelineId,'2' AS PointState,CAST(0 AS BIT) AS IsCheckRepair, trust.TrustBatchCode
FROM dbo.Batch_PointBatchItem pointItem
LEFT JOIN dbo.Batch_PointBatch point ON point.PointBatchId = pointItem.PointBatchId
LEFT JOIN dbo.Pipeline_WeldJoint jot ON jot.WeldJointId = pointItem.WeldJointId
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
LEFT JOIN dbo.Batch_BatchTrustItem trustItem ON trustItem.PointBatchItemId=pointItem.ToPointBatchItemId
LEFT JOIN dbo.Batch_BatchTrust trust ON trust.TrustBatchId = trustItem.TrustBatchId
WHERE pointItem.PointState ='2' AND point.EndDate IS NOT NULL
AND pointItem.CutDate IS NULL AND (pointItem.IsBuildTrust IS NULL OR pointItem.IsBuildTrust=0) AND point.IsTrust=0
GROUP BY point.ProjectId,point.InstallationId,pipe.WorkAreaId,point.UnitId,point.DetectionTypeId,
jot.PipelineId,trust.TrustBatchCode
UNION ALL
-------ԏ<EFBFBD>Oub<EFBFBD>YXb-----------
SELECT point.ProjectId,point.InstallationId,pipe.WorkAreaId ,point.UnitId,point.DetectionTypeId,
jot.PipelineId,'1' AS PointState,CAST(1 AS BIT) AS IsCheckRepair, trust.TrustBatchCode
FROM dbo.Batch_PointBatchItem pointItem
LEFT JOIN dbo.Batch_PointBatch point ON point.PointBatchId = pointItem.PointBatchId
LEFT JOIN dbo.Pipeline_WeldJoint jot ON jot.WeldJointId = pointItem.WeldJointId
LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId
LEFT JOIN dbo.Batch_BatchTrustItem trustItem ON trustItem.PointBatchItemId=pointItem.PointBatchItemId
LEFT JOIN dbo.Batch_BatchTrust trust ON trust.TrustBatchId = trustItem.TrustBatchId
WHERE pointItem.PointState ='1' AND pointItem.IsCheckRepair=1 AND point.EndDate IS NOT NULL
AND pointItem.CutDate IS NULL AND (pointItem.IsBuildTrust IS NULL OR pointItem.IsBuildTrust=0) AND point.IsTrust=0
GROUP BY point.ProjectId,point.InstallationId,pipe.WorkAreaId,point.UnitId,point.DetectionTypeId,
jot.PipelineId,trust.TrustBatchCode
GO