SGGL_SHJ/DataBase/版本日志/SGGLDB_V2023-02-20.sql

136 lines
4.8 KiB
Transact-SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

alter table HJGL_Pipeline_Component add ProductionState int
Go
update HJGL_WeldJoint set WeldingMode=task.WeldingMode
from HJGL_WeldJoint as joint ,HJGL_WeldTask as task
where task.WeldJointId =joint.WeldJointId and task.WeldingMode !=''
Go
update Sys_Menu set SortIndex='105' where MenuId='7FE911EF-616A-4F04-AACD-E53E633A9E86'
Go
/****** Object: Table [dbo].[HJGL_Pipeline_ComponentJoint] Script Date: 2023/2/18 16:21:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[HJGL_Pipeline_ComponentJoint](
[Id] [varchar](50) NOT NULL,
[PipelineComponentId] [varchar](50) NULL,
[PipelineComponentCode] [varchar](50) NULL,
[WeldJointId] [varchar](50) NULL,
[WeldJointCode] [varchar](50) NULL,
[State] [int] NULL,
CONSTRAINT [PK_HJGL_Pipeline_ComponentJoint] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
create by shuke.li 2020-9-15
*/
create function [dbo].[SplitString]
(
@Input nvarchar(max), --input string to be separated
@Separator nvarchar(max)=',', --a string that delimit the substrings in the input string
@RemoveEmptyEntries bit=1 --the return value does not include array elements that contain an empty string
)
returns @TABLE table
(
[Id] int identity(1,1),
[Value] nvarchar(max)
)
as
begin
declare @Index int, @Entry nvarchar(max)
set @Index = charindex(@Separator,@Input)
while (@Index>0)
begin
set @Entry=ltrim(rtrim(substring(@Input, 1, @Index-1)))
if (@RemoveEmptyEntries=0) or (@RemoveEmptyEntries=1 and @Entry<>'')
begin
insert into @TABLE([Value]) Values(@Entry)
end
set @Input = substring(@Input, @Index+datalength(@Separator)/2, len(@Input))
set @Index = charindex(@Separator, @Input)
end
set @Entry=ltrim(rtrim(@Input))
if (@RemoveEmptyEntries=0) or (@RemoveEmptyEntries=1 and @Entry<>'')
begin
insert into @TABLE([Value]) Values(@Entry)
end
return
end
GO
DECLARE
@PipelineComponentId varchar( 50 ),
@PipelineComponentCode varchar( 100 ),
@PipelineId varchar( 100 ),
@QRCode varchar( max ),
@QRCodeItem varchar( 100 )
DECLARE cursor_name CURSOR FOR -- <20><><EFBFBD><EFBFBD><EFBFBD>α<EFBFBD>
select PipelineComponentId ,PipelineComponentCode,PipelineId, QRCode from HJGL_Pipeline_Component where QRCode !=''
OPEN cursor_name -- <20><><EFBFBD><EFBFBD><EFBFBD>α<EFBFBD>
FETCH NEXT FROM cursor_name INTO @PipelineComponentId,@PipelineComponentCode,@PipelineId ,@QRCode -- ץȡ<D7A5><C8A1>һ<EFBFBD><D2BB><EFBFBD>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD>
WHILE @@FETCH_STATUS = 0 --(-1 <20><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD> -2 <20><><EFBFBD><EFBFBD>ȡ<EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD>ڣ<EFBFBD>
BEGIN
DECLARE QRCodeList CURSOR FOR -- <20><><EFBFBD><EFBFBD><EFBFBD>α<EFBFBD>
select value from [dbo].[SplitString](@QRCode, ';', 0)
OPEN QRCodeList -- <20><><EFBFBD><EFBFBD><EFBFBD>α<EFBFBD>
FETCH NEXT FROM QRCodeList INTO @QRCodeItem -- ץȡ<D7A5><C8A1>һ<EFBFBD><D2BB><EFBFBD>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD>
WHILE @@FETCH_STATUS = 0 --(-1 <20><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD> -2 <20><><EFBFBD><EFBFBD>ȡ<EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD>ڣ<EFBFBD>
BEGIN
DECLARE @jointcount int;
DECLARE @WeldJointId varchar( 100 ) ;
DECLARE @WeldJointCode varchar( 100 )
set @jointcount= (select COUNT (*) from HJGL_WeldJoint where PipelineId =@PipelineId and WeldJointCode = SUBSTRING(@QRCodeItem,2,LEN(@QRCodeItem)-1) )
set @WeldJointId= (select WeldJointId from HJGL_WeldJoint where PipelineId =@PipelineId and WeldJointCode =SUBSTRING(@QRCodeItem,2,LEN(@QRCodeItem)-1))
set @WeldJointCode= (select WeldJointCode from HJGL_WeldJoint where PipelineId =@PipelineId and WeldJointCode =SUBSTRING(@QRCodeItem,2,LEN(@QRCodeItem)-1))
--print @QRCodeItem
if @jointcount>0
begin
DECLARE @ComponentJointcount int;
set @ComponentJointcount=(select COUNT (*) from HJGL_Pipeline_ComponentJoint where WeldJointId= @WeldJointId)
if @ComponentJointcount>0
begin
print '<EFBFBD><EFBFBD><EFBFBD>º<EFBFBD><EFBFBD><EFBFBD>'+@WeldJointCode
update HJGL_Pipeline_ComponentJoint set PipelineComponentId=@PipelineComponentId,PipelineComponentCode =@PipelineComponentCode where Id in (select Id from HJGL_Pipeline_ComponentJoint where WeldJointId= @WeldJointId );
end
else
begin
print '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'+@WeldJointCode
insert into HJGL_Pipeline_ComponentJoint values(NEWID(),@PipelineComponentId,@PipelineComponentCode,@WeldJointId,@WeldJointCode,0)
end
end
FETCH NEXT FROM QRCodeList INTO @QRCodeItem
END
CLOSE QRCodeList -- <20>ر<EFBFBD><D8B1>α<EFBFBD>
DEALLOCATE QRCodeList -- <20>ͷ<EFBFBD><CDB7>α<EFBFBD>
FETCH NEXT FROM cursor_name INTO @PipelineComponentId,@PipelineComponentCode,@PipelineId ,@QRCode
END
CLOSE cursor_name -- <20>ر<EFBFBD><D8B1>α<EFBFBD>
DEALLOCATE cursor_name -- <20>ͷ<EFBFBD><CDB7>α<EFBFBD>