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

275 lines
29 KiB
MySQL
Raw Normal View History

2024-05-08 10:02:08 +08:00
<EFBFBD><EFBFBD>UPDATE [dbo].[Batch_BatchTrustItem] SET WeldJointId=
(SELECT p.WeldJointId FROM [dbo].[Batch_PointBatchItem] p WHERE p.PointBatchItemId=Batch_BatchTrustItem.PointBatchItemId)
WHERE Batch_BatchTrustItem.WeldJointId IS NULL
GO
ALTER PROC [dbo].[sp_rpt_UnitWorkareaAnalyze]
@UnitNo VARCHAR(400) = NULL,
@AreaNo VARCHAR(50) = NULL,
@installationId VARCHAR(50) = NULL,
@ste_steeltype varchar(50) = NULL,
@startTime datetime = NULL,
@endTime datetime = NULL,
@projectId NVARCHAR(50) = NULL
AS
/*USMO<EFBFBD>]:<EFBFBD>^R<EFBFBD>g*/
SELECT
WorkArea.ProjectId,
WorkArea.WorkAreaCode AS baw_areano,--<EFBFBD>]:S<EFBFBD>N<EFBFBD>S
Unit.UnitCode AS bsu_unitcode,--USMO<EFBFBD>Nx
Unit.UnitName AS bsu_unitname, --USMO T<EFBFBD>y
Installation.InstallationCode, --ňn<EFBFBD>N<EFBFBD>S
Installation.InstallationName, --ňn T<EFBFBD>y
--
qg
ISNULL(total.total_jot,0) AS total_jot, --;`
q<EFBFBD>S
--- /}<EFBFBD><EFBFBD>pe start
ISNULL(total_sjot.total_sjot,0) AS total_sjot, --<EFBFBD><EFBFBD>6R;`
q<EFBFBD>Spe
ISNULL(total_fjot.total_fjot,0) AS total_fjot, --<EFBFBD>[ň;`
q<EFBFBD>Spe
ISNULL(cut_total_jot.cut_total_jot,0) AS cut_total_jot, --Rd<EFBFBD>
q<EFBFBD>S
CAST(ISNULL(total.total_din,0) AS DECIMAL(19,2)) AS total_din,--;`<EFBFBD><EFBFBD><EFBFBD>V
CAST(ISNULL(total_sjot.total_Sdin,0) AS DECIMAL(19,2)) AS total_Sdin, --<EFBFBD><EFBFBD>6R;`<EFBFBD><EFBFBD><EFBFBD>V
CAST(ISNULL(total_fjot.total_Fdin,0) AS DECIMAL(19,2)) AS total_Fdin, --<EFBFBD>[ň;`<EFBFBD><EFBFBD><EFBFBD>V
ISNULL(finished_total_jot_bq.finished_total_jot_bq,0) AS finished_total_jot_bq, --,gg<EFBFBD>[b
q<EFBFBD>Spe
ISNULL(finished_total_sjot_bq.finished_total_sjot_bq,0) AS finished_total_sjot_bq, --,gg<EFBFBD>[b<EFBFBD><EFBFBD>6R
q<EFBFBD>Spe
ISNULL(finished_total_fjot_bq.finished_total_fjot_bq,0) AS finished_total_fjot_bq, --,gg<EFBFBD>[b<EFBFBD>[ň
q<EFBFBD>Spe
Convert(nvarchar(10),(CAST((CASE ISNULL(total_jot.total_jot ,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(finished_total_jot_bq.finished_total_jot_bq,0) / (1.0 * total_jot.total_jot)
END) AS DECIMAL(19,3))*100))+'%' AS finisedrate_bq, --,gg<EFBFBD>[b<EFBFBD>k<EFBFBD>O
convert(nvarchar(10),(CAST((CASE ISNULL(total_jot.total_jot,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(finished_total_sjot_bq.finished_total_sjot_bq,0)/ (1.0 *total_jot.total_jot)
END) AS DECIMAL(19,3))*100))+'%' AS finisedrate_s_bq, -- ,gg<EFBFBD><EFBFBD>6R<EFBFBD>[b<EFBFBD>k<EFBFBD>O
convert(nvarchar(10),(CAST((CASE ISNULL(total_jot.total_jot,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(finished_total_fjot_bq.finished_total_fjot_bq,0)/ (1.0 *total_jot.total_jot)
END) AS DECIMAL(19,3))*100)) AS finisedrate_f_bq, -- ,gg<EFBFBD>[ň<EFBFBD>[b<EFBFBD>k<EFBFBD>O
CAST(ISNULL(finished_total_jot_bq.finished_total_din_bq ,0) AS DECIMAL(19,2)) AS finished_total_din_bq, --,gg<EFBFBD>[b<EFBFBD><EFBFBD><EFBFBD>V
CAST(ISNULL(finished_total_sjot_bq.finished_total_Sdin_bq,0) AS DECIMAL(19,2)) AS finished_total_Sdin_bq,----,gg<EFBFBD>[b<EFBFBD><EFBFBD>6R<EFBFBD><EFBFBD><EFBFBD>V
CAST(ISNULL(finished_total_fjot_bq.finished_total_Fdin_bq,0) AS DECIMAL(19,2)) AS finished_total_Fdin_bq, ----,gg<EFBFBD>[b<EFBFBD>[ň<EFBFBD><EFBFBD><EFBFBD>V
Convert(nvarchar(10),(CAST((CASE ISNULL(total_jot.total_din,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(finished_total_jot_bq.finished_total_din_bq ,0)/ (1.0 * total_jot.total_din)
END) AS DECIMAL(19,3))*100))+'%' AS finisedrate_din_bq, --,gg<EFBFBD>[b<EFBFBD><EFBFBD><EFBFBD>V<EFBFBD>k<EFBFBD>O
convert(nvarchar(10),(CAST((CASE ISNULL(total_jot.total_din,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(finished_total_sjot_bq.finished_total_Sdin_bq,0) /(1.0 * total_jot.total_din)
END) AS DECIMAL(19,3))*100))+'%' AS finisedrate_din_s_bq, -- ,gg<EFBFBD>[b<EFBFBD><EFBFBD>6R<EFBFBD><EFBFBD><EFBFBD>V<EFBFBD>k<EFBFBD>O
convert(nvarchar(10),(CAST((CASE ISNULL(total_jot.total_din,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(finished_total_fjot_bq.finished_total_Fdin_bq,0)/ (1.0 * total_jot.total_din)
END) AS DECIMAL(19,3))*100))+'%' AS finisedrate_din_f_bq, -- ,gg<EFBFBD>[b<EFBFBD>[ň<EFBFBD><EFBFBD><EFBFBD>V<EFBFBD>k<EFBFBD>O
ISNULL(finished_total_jot.finished_total_jot,0) AS finished_total_jot, --<EFBFBD>[b
q<EFBFBD>S
ISNULL(finished_total_sjot.finished_total_sjot,0) AS finished_total_sjot, --<EFBFBD>[b<EFBFBD><EFBFBD>6R
q<EFBFBD>S
ISNULL(finished_total_fjot.finished_total_fjot,0) AS finished_total_fjot,--<EFBFBD>[b<EFBFBD>[ň
q<EFBFBD>S
convert(nvarchar(10),(CAST((CASE ISNULL(total_jot.total_jot ,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(finished_total_jot.finished_total_jot,0)/ (1.0 * total_jot.total_jot)
END) AS DECIMAL(19,3))*100))+'%' AS finisedrate, --<EFBFBD>[b<EFBFBD>k<EFBFBD>O
convert(nvarchar(10),((CAST((CASE ISNULL(total_jot.total_jot,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(finished_total_fjot.finished_total_fjot,0) / (1.0 * total_jot.total_jot)
END) AS DECIMAL(19,3)))*100))+'%' AS finisedrate_f, -- <EFBFBD>[ň<EFBFBD>[b<EFBFBD>k<EFBFBD>O
convert(nvarchar(10),((CAST((CASE ISNULL(total_jot.total_jot,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(finished_total_sjot.finished_total_sjot,0) / (1.0 * total_jot.total_jot)
END) AS DECIMAL(19,3)))*100))+'%' AS finisedrate_s, -- <EFBFBD><EFBFBD>6R<EFBFBD>[b<EFBFBD>k<EFBFBD>O
CAST(ISNULL(total_jot.finished_total_din,0) AS DECIMAL(19,2)) AS finished_total_din, --<EFBFBD>[b<EFBFBD><EFBFBD><EFBFBD>V
CAST(ISNULL(total_sjot.finished_total_Sdin,0) AS DECIMAL(19,2)) AS finished_total_Sdin,--<EFBFBD>[b<EFBFBD><EFBFBD>6R<EFBFBD><EFBFBD><EFBFBD>V
CAST(ISNULL(total_fjot.finished_total_Fdin,0) AS DECIMAL(19,2)) AS finished_total_Fdin, --<EFBFBD>[b<EFBFBD>[ň<EFBFBD><EFBFBD><EFBFBD>V
Convert(nvarchar(10),((CAST((CASE ISNULL(total_jot.total_din,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(total_jot.finished_total_din,0) / (1.0 * total_jot.total_din)
END) AS DECIMAL(19,3)))*100))+'%' AS finisedrate_din, ---<EFBFBD>[b<EFBFBD><EFBFBD><EFBFBD>V<EFBFBD>k<EFBFBD>O
convert(nvarchar(10),((CAST((CASE ISNULL(total_jot.total_din,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(total_sjot.finished_total_Sdin,0) / (1.0 *total_jot.total_din)
END) AS DECIMAL(19,3)))*100))+'%' AS finisedrate_din_s, -- <EFBFBD>[b<EFBFBD><EFBFBD>6R<EFBFBD><EFBFBD><EFBFBD>V<EFBFBD>k<EFBFBD>O
convert(nvarchar(10),((CAST((CASE ISNULL(total_jot.total_din,0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(total_fjot.finished_total_Fdin,0) / (1.0 *total_jot.total_din)
END) AS DECIMAL(19,3)))*100))+'%' AS finisedrate_din_f -- <EFBFBD>[b<EFBFBD>[ň<EFBFBD><EFBFBD><EFBFBD>V<EFBFBD>k<EFBFBD>O
FROM Project_WorkArea AS WorkArea
LEFT JOIN Base_Unit AS Unit ON WorkArea.UnitId =Unit.UnitId
LEFT JOIN Project_Installation AS Installation ON Installation.InstallationId = WorkArea.InstallationId
LEFT JOIN (SELECT COUNT(*) total_jot ,Pipeline_Pipeline.WorkAreaId ,SUM(Size) AS total_din
,SUM(DoneDin) AS finished_total_din
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId = Pipeline_WeldJoint.Material1Id
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null)
GROUP BY Pipeline_Pipeline.WorkAreaId) AS total ON total.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) total_jot ,Pipeline_Pipeline.WorkAreaId ,SUM(Size) AS total_din
,SUM(DoneDin) AS finished_total_din
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId = Pipeline_WeldJoint.Material1Id
WHERE Pipeline_WeldJoint.WeldingDailyId is not NULL AND (SteelType =@ste_steeltype or @ste_steeltype is null)
GROUP BY Pipeline_Pipeline.WorkAreaId) AS total_jot ON total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) total_sjot ,Pipeline_Pipeline.WorkAreaId, SUM(Size) AS total_Sdin
,SUM(DoneDin) AS finished_total_Sdin
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId =Pipeline_WeldJoint.Material1Id
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null) and Pipeline_WeldJoint.JointArea='S'
GROUP BY Pipeline_Pipeline.WorkAreaId) AS total_sjot ON total_sjot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) total_fjot ,Pipeline_Pipeline.WorkAreaId, SUM(Size) AS total_Fdin
,SUM(DoneDin) AS finished_total_Fdin
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId = Pipeline_WeldJoint.Material1Id
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null) and Pipeline_WeldJoint.JointArea='F'
GROUP BY Pipeline_Pipeline.WorkAreaId) AS total_fjot ON total_fjot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) cut_total_jot ,Pipeline_Pipeline.WorkAreaId
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId =Pipeline_WeldJoint.Material1Id
LEFT JOIN Batch_PointBatchItem ON Batch_PointBatchItem.WeldJointId=Pipeline_WeldJoint.WeldJointId
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null) and Batch_PointBatchItem.CutDate is not null
GROUP BY Pipeline_Pipeline.WorkAreaId) AS cut_total_jot ON cut_total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) finished_total_jot_bq ,Pipeline_Pipeline.WorkAreaId ,SUM(DoneDin) AS finished_total_din_bq
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId = Pipeline_WeldJoint.Material1Id
LEFT JOIN Pipeline_WeldingDaily ON Pipeline_WeldingDaily.WeldingDailyId = Pipeline_WeldJoint.WeldingDailyId
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null) and Pipeline_WeldJoint.WeldingDailyId is not null
and (WeldingDate >= @startTime OR @startTime IS NULL) and (WeldingDate <=@endTime OR @endTime IS NULL)
GROUP BY Pipeline_Pipeline.WorkAreaId) AS finished_total_jot_bq ON finished_total_jot_bq.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) finished_total_sjot_bq ,Pipeline_Pipeline.WorkAreaId,SUM(DoneDin) AS finished_total_Sdin_bq
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId = Pipeline_WeldJoint.Material1Id
LEFT JOIN Pipeline_WeldingDaily ON Pipeline_WeldingDaily.WeldingDailyId = Pipeline_WeldJoint.WeldingDailyId
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null) and Pipeline_WeldJoint.WeldingDailyId is not null
and (WeldingDate >= @startTime OR @startTime IS NULL) and (WeldingDate <=@endTime OR @endTime IS NULL)
and JointArea='S'
GROUP BY Pipeline_Pipeline.WorkAreaId) AS finished_total_sjot_bq ON finished_total_sjot_bq.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) finished_total_fjot_bq ,Pipeline_Pipeline.WorkAreaId , SUM(DoneDin) AS finished_total_Fdin_bq
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId = Pipeline_WeldJoint.Material1Id
LEFT JOIN Pipeline_WeldingDaily ON Pipeline_WeldingDaily.WeldingDailyId = Pipeline_WeldJoint.WeldingDailyId
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null) and Pipeline_WeldJoint.WeldingDailyId is not null
and (WeldingDate >= @startTime OR @startTime IS NULL) and (WeldingDate <=@endTime OR @endTime IS NULL)
and JointArea='F'
GROUP BY Pipeline_Pipeline.WorkAreaId) AS finished_total_fjot_bq ON finished_total_fjot_bq.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) finished_total_jot ,Pipeline_Pipeline.WorkAreaId
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId = Pipeline_WeldJoint.Material1Id
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null) and WeldingDailyId is not null
GROUP BY Pipeline_Pipeline.WorkAreaId) AS finished_total_jot ON finished_total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) finished_total_sjot ,Pipeline_Pipeline.WorkAreaId
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId = Pipeline_WeldJoint.Material1Id
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null) and WeldingDailyId is not null
and JointArea='S'
GROUP BY Pipeline_Pipeline.WorkAreaId) AS finished_total_sjot ON finished_total_sjot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN (SELECT COUNT(*) finished_total_fjot ,Pipeline_Pipeline.WorkAreaId
FROM Pipeline_WeldJoint
LEFT JOIN Pipeline_Pipeline ON Pipeline_WeldJoint.PipelineId = Pipeline_Pipeline.PipelineId
LEFT JOIN Base_Material ON Base_Material.MaterialId = Pipeline_WeldJoint.Material1Id
WHERE (SteelType =@ste_steeltype or @ste_steeltype is null) and WeldingDailyId is not null
and JointArea='F'
GROUP BY Pipeline_Pipeline.WorkAreaId) AS finished_total_fjot ON finished_total_fjot.WorkAreaId = WorkArea.WorkAreaId
WHERE
(WorkArea.ProjectId=@projectId OR @projectId IS NULL ) AND
(WorkArea.WorkAreaId=@areano OR @AreaNo IS NULL ) AND
(WorkArea.UnitId=@unitno OR @UnitNo IS NULL) AND
(WorkArea.InstallationId=@installationId OR @installationId IS NULL)
ORDER BY Unit.UnitCode ,Installation.InstallationCode
GO
ALTER VIEW [dbo].[View_Batch_PointBatch]
AS
/*************<EFBFBD>p<EFBFBD>SUSƉ<EFBFBD>V*************/
SELECT PointBatch.PointBatchId
,PointBatch.PointBatchCode
,PointBatch.ProjectId
,Project.ProjectCode
,Project.ProjectName
,PointBatch.UnitId
,Unit.UnitName
,Unit.UnitCode
,Unit.UnitTypeId
,PointBatch.InstallationId
,Installation.InstallationCode
,Installation.InstallationName
,PointBatch.DetectionTypeId
,DetectionType.DetectionTypeCode
,DetectionType.DetectionTypeName
,PointBatch.DetectionRateId
,DetectionRate.DetectionRateCode
,DetectionRate.DetectionRateValue
,PointBatch.WelderId
,Welder.WelderCode
,Welder.WelderName
,PointBatch.MediumId
,Medium.MediumCode
,Medium.MediumName
,PointBatch.MaterialId
,Material.MaterialCode
,PointBatch.WeldTypeId
,WeldType.WeldTypeCode
,WeldType.WeldTypeName
,PointBatch.StartDate
,PointBatch.EndDate
,PointBatch.ClearDate
,PointBatch.IsTrust
,PointBatch.IsCheck
FROM Batch_PointBatch AS PointBatch
LEFT JOIN Base_Project AS Project ON PointBatch.ProjectId=Project.ProjectId
LEFT JOIN Base_Unit AS Unit ON PointBatch.UnitId=Unit.UnitId
LEFT JOIN Project_Installation AS Installation ON PointBatch.InstallationId=Installation.InstallationId
LEFT JOIN Base_DetectionType AS DetectionType ON PointBatch.DetectionTypeId=DetectionType.DetectionTypeId
LEFT JOIN Base_DetectionRate AS DetectionRate ON PointBatch.DetectionRateId=DetectionRate.DetectionRateId
LEFT JOIN Welder_Welder AS Welder ON PointBatch.WelderId=Welder.WelderId
LEFT JOIN Base_Medium AS Medium ON PointBatch.MediumId=Medium.MediumId
LEFT JOIN Base_Material AS Material ON PointBatch.MaterialId=Material.MaterialId
LEFT JOIN Base_WeldType AS WeldType ON PointBatch.WeldTypeId=WeldType.WeldTypeId
GO