alter table HJGL_CH_HardTestReport add UnitWork nvarchar(50) alter table HJGL_CH_HardTestReport add InstallationId nvarchar(50) alter table HJGL_CH_HardTestReport add CheckUnitId nvarchar(50) alter table HJGL_CH_HardTestReport add ItemName nvarchar(50) alter table HJGL_CH_HardTestReport add WME_ID varchar(50) alter table HJGL_CH_HardTestReport add SurfaceState nvarchar(50) alter table HJGL_CH_HardTestReport add NDTR_ID varchar(50) go ALTER TABLE [dbo].[HJGL_CH_HardTestReport] WITH CHECK ADD CONSTRAINT [FK_HJGL_CH_HardTestReport_Project_Installation] FOREIGN KEY([InstallationId]) REFERENCES [dbo].[Project_Installation] ([InstallationId]) GO ALTER TABLE [dbo].[HJGL_CH_HardTestReport] CHECK CONSTRAINT [FK_HJGL_CH_HardTestReport_Project_Installation] GO ALTER TABLE [dbo].[HJGL_CH_HardTestReport] WITH CHECK ADD CONSTRAINT [FK_HJGL_CH_HardTestReport_Base_Unit1] FOREIGN KEY([CheckUnitId]) REFERENCES [dbo].[Base_Unit] ([UnitId]) GO ALTER TABLE [dbo].[HJGL_CH_HardTestReport] CHECK CONSTRAINT [FK_HJGL_CH_HardTestReport_Base_Unit1] GO ALTER TABLE [dbo].[HJGL_CH_HardTestReport] WITH CHECK ADD CONSTRAINT [FK_HJGL_CH_HardTestReport_HJGL_BS_NDTRate] FOREIGN KEY([NDTR_ID]) REFERENCES [dbo].[HJGL_BS_NDTRate] ([NDTR_ID]) GO ALTER TABLE [dbo].[HJGL_CH_HardTestReport] CHECK CONSTRAINT [FK_HJGL_CH_HardTestReport_HJGL_BS_NDTRate] GO ALTER TABLE [dbo].[HJGL_CH_HardTestReport] WITH CHECK ADD CONSTRAINT [FK_HJGL_CH_HardTestReport_HJGL_BS_WeldMethod] FOREIGN KEY([WME_ID]) REFERENCES [dbo].[HJGL_BS_WeldMethod] ([WME_ID]) GO ALTER TABLE [dbo].[HJGL_CH_HardTestReport] CHECK CONSTRAINT [FK_HJGL_CH_HardTestReport_HJGL_BS_WeldMethod] GO ALTER VIEW [dbo].[HJGL_View_CH_HardTestReport] /*硬度检验报告表查询列表*/ AS SELECT Report.HardTestReportId, -- 硬度检验报告id Report.ProjectId, --项目Id Report.HardTestReportCode, Report.ISO_ID, Report.STE_ID, Report.HotHardCode, Report.TrustUnitId, Report.TestDate, Report.InstrumentType, Report.EquipmentId, Report.TestStandard, Report.AuditMan, Report.TestMan, Project.ProjectName, Report.ContractUnit, Report.HotProessState, Report.SurfaceAppearance, Report.TestMethod, Report.MaterialStandard, Report.TestRate, Report.TestCount, Project.ProjectCode, IsoInfo.ISO_IsoNo, Report.IsPrintTrust, Report.IsPrintReport, CASE WHEN Steel.STE_Code IS NOT NULL THEN Steel.STE_Code ELSE Steel2.STE_Code END AS STE_Code, Unit.UnitName, Equipment.EquipmentCode AS EquipmentName, Report.UnitWork, Report.InstallationId, Report.CheckUnitId, Report.ItemName, Report.WME_ID, Report.SurfaceState, Report.NDTR_ID, installation.InstallationCode, installation.InstallationName, checkUnit.UnitName as CheckUnitName, weldMethod.WME_Name, ndtRate.NDTR_Name --(Equipment.EquipmentCode+Equipment.EquipmentName) as EquipmentName FROM dbo.HJGL_CH_HardTestReport AS Report LEFT JOIN dbo.Base_Project AS Project ON Project.ProjectId=Report.ProjectId LEFT JOIN dbo.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = Report.ISO_ID LEFT JOIN dbo.HJGL_BS_Steel AS Steel ON Steel.STE_ID=Report.STE_ID LEFT JOIN dbo.HJGL_BS_Steel AS Steel2 ON Steel2.STE_ID=IsoInfo.STE_ID LEFT JOIN dbo.Base_Unit AS Unit ON Unit.UnitId = Report.TrustUnitId LEFT JOIN dbo.HJGL_BS_Equipment AS Equipment ON Equipment.EquipmentId = Report.EquipmentId left join Project_Installation AS installation ON installation.InstallationId = Report.InstallationId left join Base_Unit as checkUnit on checkUnit.UnitId = Report.CheckUnitId left join HJGL_BS_NDTRate as ndtRate on ndtRate.NDTR_ID = Report.NDTR_ID left join HJGL_BS_WeldMethod as weldMethod on weldMethod.WME_ID = Report.WME_ID GO ALTER PROCEDURE [dbo].[HJGL_spCH_HardTestReport] ( @HardTestReportId nvarchar(50) ) AS --通过委托id获取硬度委托单及硬度检验报告信息 BEGIN SELECT Report.HardTestReportId, case when Report.HotHardCode is null then Report.HardTestReportCode else Report.HotHardCode end as HardTestReportCode, Report.ProjectId, Report.TrustUnitId, CONVERT(varchar(100), Report.TestDate, 23) as TestDate, Cast(Year(PrintReportDate) as nvarchar)+'年'+Cast(Month(PrintReportDate) as nvarchar)+'月'+Cast(Day(PrintReportDate) as nvarchar)+'日' AS PrintDate, Report.InstrumentType, Report.EquipmentId, Report.TestStandard, Report.HotHardCode, Report.HotProessState, Report.SurfaceAppearance, Report.TestMethod, '≤'+Report.MaterialStandard as MaterialStandard, Report.PrintReportDate, Report.TestRate, Report.TestCount, Project.ProjectName, Project.ProjectCode, IsoInfo.ISO_IsoNo, Unit.UnitName as TrustUnitName, Report.ContractUnit as ContractUnitName, case when Steel.STE_Code is not null then Steel.STE_Code else Steel2.STE_Code end as STE_Code, Equipment.EquipmentCode as EquipmentCode, '共检测'+CONVERT(nvarchar(10),item.pointCount)+'处'+CONVERT(nvarchar(10),item.pointCount*3)+'点,符合标准要求'+CONVERT(nvarchar(10),item.pointCount)+'处'+CONVERT(nvarchar(10),item.pointCount*3)+'点,不符合标准要求0处0点,具体检测部位详见单线图。' as testResult, Report.UnitWork, Report.InstallationId, Report.CheckUnitId, Report.ItemName, Report.WME_ID, Report.SurfaceState, Report.NDTR_ID, installation.InstallationCode, installation.InstallationName, checkUnit.UnitName as checkUnitName, rate.NDTR_Name+'%' as ndtrName, weldMethod.WME_Name, reportItem.checkCount FROM dbo.HJGL_CH_HardTestReport AS Report LEFT JOIN dbo.Base_Project AS Project ON Project.ProjectId =Report.ProjectId LEFT JOIN dbo.Base_Unit AS Unit ON Unit.UnitId =Report.TrustUnitId LEFT JOIN dbo.HJGL_BS_Equipment AS Equipment ON Equipment.EquipmentId=Report.EquipmentId LEFT JOIN dbo.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID =Report.ISO_ID LEFT JOIN dbo.HJGL_BS_Steel AS Steel ON Steel.STE_ID=Report.STE_ID LEFT JOIN dbo.HJGL_BS_Steel AS Steel2 ON Steel2.STE_ID=IsoInfo.STE_ID LEFT JOIN (SELECT COUNT(*)as pointCount,HardTestReportId FROM HJGL_CH_HardTestReportItem WHERE IsShow='True' GROUP BY HardTestReportId) AS item ON item.HardTestReportId=Report.HardTestReportId left join Project_Installation as installation on installation.InstallationId = Report.InstallationId left join Base_Unit as checkUnit on checkUnit.UnitId = Report.CheckUnitId left join HJGL_BS_WeldMethod as weldMethod on weldMethod.WME_ID = Report.WME_ID left join HJGL_BS_NDTRate as rate on rate.NDTR_ID = Report.NDTR_ID left join (select count(*) as checkCount,HardTestReportId from HJGL_View_CH_HardTestReportItem where TestPart='焊缝' group by HardTestReportId) as reportItem on reportItem.HardTestReportId = Report.HardTestReportId WHERE Report.HardTestReportId = @HardTestReportId END GO ALTER PROCEDURE [dbo].[HJGL_spCH_HardTestReportItemDistinct2] ( @HardTestReportId nvarchar(50) ) AS --通过检测id获取委托单信息 BEGIN select ROW_NUMBER() OVER(ORDER BY c.Sort1,c.Sort2,c.Sort3,c.Sort4,c.Sort5,c.SortIndex) as sort, ROW_NUMBER() OVER(ORDER BY c.Sort1,c.Sort2,c.Sort3,c.Sort4,c.Sort5,c.SortIndex) as Number, c.HardTestReportItemId, --硬度委托明细id c.HardTestReportId, -- 硬度委托id c.JOT_ID, --焊口id c.ISO_IsoNo, Batch.BatchCode,--检测批号 c.JOT_JointNo, c.Remark, c.JOT_JointDesc, --规格 c.TestPart, Result.Remark as RemarkStr, c.STE_Code, --材质 c.WED_Code from dbo.HJGL_View_CH_HardTestReportItem c left join dbo.HJGL_BO_BatchDetail BatchDetail on BatchDetail.JOT_ID=c.JOT_ID left join dbo.HJGL_BO_Batch Batch on Batch.BatchId=BatchDetail.BatchId left join dbo.HJGL_CH_HotProessResult Result ON Result.JOT_ID=c.JOT_ID and Result.HotProessTrustId=c.HotProessTrustId where c.HardTestReportId = @HardTestReportId and c.TestPart='焊缝' --order by Number,c.SortIndex union select 99999 as sort,null,null,null,null,null,null,'以下空白',null,null,null,null,null,null END GO