From bb6615ebb025537e3764472895b360707bf81839 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Tue, 7 Jul 2026 10:40:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(hjgl):=20=E5=AE=8C=E5=96=84=E7=84=8A?= =?UTF-8?q?=E5=89=8D=E6=A3=80=E6=9F=A5=E5=92=8C=E9=98=B2=E8=85=90=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 焊前检查需要同时覆盖下料、组对和防腐检查,并支持移动端查询与保存。 扩展焊前检查模型、服务和页面字段,补充检查结果、不合格原因、整改要求、 附件和防腐检查记录,便于按焊口和材料追溯检查过程。 --- DataBase/版本日志/SGGLDB_V2026-06-30-lpf.sql | 195 ++ SGGL/BLL/API/APIUserService.cs | 2 + .../API/HJGL/APIPreWeldInspectionService.cs | 356 +-- SGGL/BLL/CLGL/TwInputdetailBarCodeService.cs | 19 + SGGL/BLL/Common/Const.cs | 5 + .../HJGL/WeldingManage/PipelineMatService.cs | 50 + .../BLL/HJGL/WeldingManage/PipelineService.cs | 2 + .../WeldingManage/PreWeldInspectionService.cs | 593 +++- .../CLGL/AntiCorrosionCheckRecord.aspx | 101 + .../CLGL/AntiCorrosionCheckRecord.aspx.cs | 85 + .../AntiCorrosionCheckRecord.aspx.designer.cs | 47 + .../CLGL/AntiCorrosionCheckRecordEdit.aspx | 103 + .../CLGL/AntiCorrosionCheckRecordEdit.aspx.cs | 119 + ...iCorrosionCheckRecordEdit.aspx.designer.cs | 32 + .../CLGL/AntiCorrosionCheckRecordView.aspx | 95 + .../CLGL/AntiCorrosionCheckRecordView.aspx.cs | 64 + ...iCorrosionCheckRecordView.aspx.designer.cs | 36 + SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx | 55 +- SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs | 45 + .../DataIn/PDMS输出(设计)数据模板.xlsx | Bin 9768 -> 9780 bytes .../File/Fastreport/焊口铭牌.frx | 124 +- SGGL/FineUIPro.Web/FineUIPro.Web.csproj | 34 +- .../HJGL/DataImport/MaterialInformation.aspx | 28 +- .../DataImport/MaterialInformation.aspx.cs | 56 +- .../MaterialInformation.aspx.designer.cs | 27 + .../DataImport/MaterialInformationEdit.aspx | 41 + .../MaterialInformationEdit.aspx.cs | 57 + .../MaterialInformationEdit.aspx.designer.cs | 80 + .../HJGL/InfoQuery/JointQuery.aspx.cs | 8 +- .../HJGL/PreWeld/CuttingCheck.aspx | 27 +- .../HJGL/PreWeld/CuttingCheckEdit.aspx | 46 + .../HJGL/PreWeld/CuttingCheckEdit.aspx.cs | 44 +- .../PreWeld/CuttingCheckEdit.aspx.designer.cs | 63 + .../HJGL/PreWeld/FitupCheck.aspx | 34 +- .../HJGL/PreWeld/FitupCheck.aspx.cs | 2 +- .../HJGL/PreWeld/FitupCheckEdit.aspx | 52 + .../HJGL/PreWeld/FitupCheckEdit.aspx.cs | 79 +- .../PreWeld/FitupCheckEdit.aspx.designer.cs | 72 + .../WeldingManage/PipelineListPDMSIn.aspx | 4 + .../WeldingManage/PipelineListPDMSIn.aspx.cs | 27 +- .../HJGL/WeldingManage/WeldJointList.aspx | 4 + .../HJGL/WeldingManage/WeldJointList.aspx.cs | 16 +- .../HJGL/WeldingManage/WeldMatMatch.aspx | 23 +- .../HJGL/WeldingManage/WeldMatMatch.aspx.cs | 464 ++- .../WeldMatMatch.aspx.designer.cs | 36 +- SGGL/FineUIPro.Web/common/Menu_HJGL.xml | 25 +- SGGL/FineUIPro.Web/common/Menu_SysSet.xml | 18 - .../APIItem/HJGL/PreWeldInspectionItem.cs | 744 ++++- .../APIItem/HJGL/ViewHJGLWeldJointExtend.cs | 11 +- SGGL/Model/CLGL/Tw_WarehouseIdExtensions.cs | 85 - SGGL/Model/Model.cs | 2510 ++++++++--------- SGGL/Model/Model.csproj | 3 +- .../AntiCorrosionCheckController.cs | 89 + .../PreWeldCuttingCheckController.cs | 51 + .../PreWeldFitupCheckController.cs | 51 + .../PreWeldInspectionController.cs | 48 +- SGGL/WebAPI/WebAPI.csproj | 5 +- 57 files changed, 5035 insertions(+), 2057 deletions(-) create mode 100644 DataBase/版本日志/SGGLDB_V2026-06-30-lpf.sql create mode 100644 SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecord.aspx create mode 100644 SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecord.aspx.cs create mode 100644 SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecord.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecordEdit.aspx create mode 100644 SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecordEdit.aspx.cs create mode 100644 SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecordEdit.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecordView.aspx create mode 100644 SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecordView.aspx.cs create mode 100644 SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecordView.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformationEdit.aspx create mode 100644 SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformationEdit.aspx.cs create mode 100644 SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformationEdit.aspx.designer.cs delete mode 100644 SGGL/Model/CLGL/Tw_WarehouseIdExtensions.cs create mode 100644 SGGL/WebAPI/Controllers/HJGL/WeldingManage/AntiCorrosionCheckController.cs create mode 100644 SGGL/WebAPI/Controllers/HJGL/WeldingManage/PreWeldCuttingCheckController.cs create mode 100644 SGGL/WebAPI/Controllers/HJGL/WeldingManage/PreWeldFitupCheckController.cs diff --git a/DataBase/版本日志/SGGLDB_V2026-06-30-lpf.sql b/DataBase/版本日志/SGGLDB_V2026-06-30-lpf.sql new file mode 100644 index 00000000..59d08010 --- /dev/null +++ b/DataBase/版本日志/SGGLDB_V2026-06-30-lpf.sql @@ -0,0 +1,195 @@ +INSERT INTO Sys_Menu (MenuId,MenuName,Icon,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed) +VALUES (N'7B62483A-4B6F-4A8C-9C61-5D0E2B4B7C31',N'¼',N'table',N'CLGL/AntiCorrosionCheckRecord.aspx',20,N'4E88A676-89E3-44EC-BF50-37BE5F09D903',N'Menu_HJGL',0,1,1); +GO + INSERT INTO Sys_ButtonToMenu (ButtonToMenuId,MenuId,ButtonName,SortIndex) + VALUES (N'0A98FA4C-092A-4DB6-AE01-9FE68FFA7F6C',N'7B62483A-4B6F-4A8C-9C61-5D0E2B4B7C31',N'',2); + GO + INSERT INTO Sys_ButtonToMenu (ButtonToMenuId,MenuId,ButtonName,SortIndex) + VALUES (N'D7C0E150-2335-4A2A-BED8-1D17BB4C0F56',N'7B62483A-4B6F-4A8C-9C61-5D0E2B4B7C31',N'',6); + GO + INSERT INTO Sys_ButtonToMenu (ButtonToMenuId,MenuId,ButtonName,SortIndex) + VALUES (N'26894317-ED67-446E-8148-9C22A7546669',N'7B62483A-4B6F-4A8C-9C61-5D0E2B4B7C31',N'ѯ',1); + GO + INSERT INTO Sys_ButtonToMenu (ButtonToMenuId,MenuId,ButtonName,SortIndex) + VALUES (N'17D8B2DC-B13D-4F9E-A2E5-750DD1B72763',N'7B62483A-4B6F-4A8C-9C61-5D0E2B4B7C31',N'ɾ',4); + GO + INSERT INTO Sys_ButtonToMenu (ButtonToMenuId,MenuId,ButtonName,SortIndex) + VALUES (N'24D59456-1E9C-47D4-98CB-CF281889E951',N'7B62483A-4B6F-4A8C-9C61-5D0E2B4B7C31',N'޸',3); +GO +update Sys_Menu set MenuName='ܵϼ¼' where MenuId='D1B5A8B7-5D2A-4C51-9B7E-6A2F15B7F002' +GO +update Sys_Menu set MenuName='Լ¼' where MenuId='D1B5A8B7-5D2A-4C51-9B7E-6A2F15B7F003' +GO +-- ========================================================= +-- / / Լ¼ +-- ˵ +-- 1. ¼ +-- 2. ϡԼ¼ڱʷǾɼ¼ +-- 3. нűעͣںάǨ +-- ========================================================= + +-- ========================= +-- 1. ¼ +-- ========================= +IF OBJECT_ID('dbo.HJGL_AntiCorrosionCheckRecord', 'U') IS NULL +BEGIN + CREATE TABLE dbo.HJGL_AntiCorrosionCheckRecord + ( + -- + AntiCorrosionCheckId NVARCHAR(50) NOT NULL PRIMARY KEY, + + -- ĿID + ProjectId NVARCHAR(50) NOT NULL, + + -- λID + UnitWorkId NVARCHAR(50) NULL, + + -- ID + MaterialId NVARCHAR(50) NULL, + + -- ϱ룬鰴ά׷ + MaterialCode NVARCHAR(50) NOT NULL, + + -- ȼ + AnticorrosionLevel NVARCHAR(100) NULL, + + -- ֵID Tw_PaintCodeDict.IdмᡢϢֵͨѯ + PaintId NVARCHAR(50) NULL, + + -- Ĥ + FilmThickness DECIMAL(18,2) NULL, + + -- ɰϢ + SandBlasting NVARCHAR(500) NULL, + + -- ɰϢ + RustSandBlasting NVARCHAR(500) NULL, + + -- + CheckResult NVARCHAR(20) NOT NULL, + + -- + CheckPerson NVARCHAR(50) NULL, + + -- ʱ + CheckTime DATETIME NOT NULL, + + -- ϸԭ + UnqualifiedReason NVARCHAR(1000) NULL, + + -- Ҫ + RectifyRequirement NVARCHAR(1000) NULL, + + -- ע + Remark NVARCHAR(1000) NULL, + + -- + CreateUser NVARCHAR(50) NULL, + + -- ʱ + CreateTime DATETIME NOT NULL CONSTRAINT DF_HJGL_AntiCorrosionCheckRecord_CreateTime DEFAULT(GETDATE()) + ); +END; +GO + +-- άȲѯ +IF NOT EXISTS ( + SELECT 1 + FROM sys.indexes + WHERE name = 'IX_AntiCorrosionCheck_MaterialCode' + AND object_id = OBJECT_ID('dbo.HJGL_AntiCorrosionCheckRecord') +) +BEGIN + CREATE INDEX IX_AntiCorrosionCheck_MaterialCode + ON dbo.HJGL_AntiCorrosionCheckRecord(ProjectId, MaterialCode, CheckTime DESC); +END; +GO + +-- ========================= +-- 2. չϼ¼ +-- ========================= +-- ϳ +IF COL_LENGTH('dbo.HJGL_PreWeldCuttingCheck', 'CuttingLength') IS NULL + ALTER TABLE dbo.HJGL_PreWeldCuttingCheck ADD CuttingLength DECIMAL(18,2) NULL; + +-- ¿ʽ +IF COL_LENGTH('dbo.HJGL_PreWeldCuttingCheck', 'GrooveForm') IS NULL + ALTER TABLE dbo.HJGL_PreWeldCuttingCheck ADD GrooveForm NVARCHAR(100) NULL; + +-- ¿ڽǶ +IF COL_LENGTH('dbo.HJGL_PreWeldCuttingCheck', 'GrooveAngle') IS NULL + ALTER TABLE dbo.HJGL_PreWeldCuttingCheck ADD GrooveAngle DECIMAL(18,2) NULL; + +-- +IF COL_LENGTH('dbo.HJGL_PreWeldCuttingCheck', 'CheckResult') IS NULL + ALTER TABLE dbo.HJGL_PreWeldCuttingCheck ADD CheckResult NVARCHAR(20) NULL; + +-- ϸԭ +IF COL_LENGTH('dbo.HJGL_PreWeldCuttingCheck', 'UnqualifiedReason') IS NULL + ALTER TABLE dbo.HJGL_PreWeldCuttingCheck ADD UnqualifiedReason NVARCHAR(1000) NULL; + +-- Ҫ +IF COL_LENGTH('dbo.HJGL_PreWeldCuttingCheck', 'RectifyRequirement') IS NULL + ALTER TABLE dbo.HJGL_PreWeldCuttingCheck ADD RectifyRequirement NVARCHAR(1000) NULL; + +-- ϼ¼ںʱѯ +IF NOT EXISTS ( + SELECT 1 + FROM sys.indexes + WHERE name = 'IX_PreWeldCuttingCheck_WeldJoint_Time' + AND object_id = OBJECT_ID('dbo.HJGL_PreWeldCuttingCheck') +) +BEGIN + CREATE INDEX IX_PreWeldCuttingCheck_WeldJoint_Time + ON dbo.HJGL_PreWeldCuttingCheck(WeldJointId, CheckTime DESC); +END; +GO + +-- ========================= +-- 3. չԼ¼ +-- ========================= +-- +IF COL_LENGTH('dbo.HJGL_PreWeldFitupCheck', 'WeldReinforcement') IS NULL + ALTER TABLE dbo.HJGL_PreWeldFitupCheck ADD WeldReinforcement DECIMAL(18,2) NULL; + +-- ߶ +IF COL_LENGTH('dbo.HJGL_PreWeldFitupCheck', 'WeldHeight') IS NULL + ALTER TABLE dbo.HJGL_PreWeldFitupCheck ADD WeldHeight DECIMAL(18,2) NULL; + +-- +IF COL_LENGTH('dbo.HJGL_PreWeldFitupCheck', 'WeldWidth') IS NULL + ALTER TABLE dbo.HJGL_PreWeldFitupCheck ADD WeldWidth DECIMAL(18,2) NULL; + +-- ȱ +IF COL_LENGTH('dbo.HJGL_PreWeldFitupCheck', 'SurfaceDefect') IS NULL + ALTER TABLE dbo.HJGL_PreWeldFitupCheck ADD SurfaceDefect NVARCHAR(500) NULL; + +-- +IF COL_LENGTH('dbo.HJGL_PreWeldFitupCheck', 'CheckResult') IS NULL + ALTER TABLE dbo.HJGL_PreWeldFitupCheck ADD CheckResult NVARCHAR(20) NULL; + +-- ϸԭ +IF COL_LENGTH('dbo.HJGL_PreWeldFitupCheck', 'UnqualifiedReason') IS NULL + ALTER TABLE dbo.HJGL_PreWeldFitupCheck ADD UnqualifiedReason NVARCHAR(1000) NULL; + +-- Ҫ +IF COL_LENGTH('dbo.HJGL_PreWeldFitupCheck', 'RectifyRequirement') IS NULL + ALTER TABLE dbo.HJGL_PreWeldFitupCheck ADD RectifyRequirement NVARCHAR(1000) NULL; + +-- Լ¼ںʱѯ +IF NOT EXISTS ( + SELECT 1 + FROM sys.indexes + WHERE name = 'IX_PreWeldFitupCheck_WeldJoint_Time' + AND object_id = OBJECT_ID('dbo.HJGL_PreWeldFitupCheck') +) +BEGIN + CREATE INDEX IX_PreWeldFitupCheck_WeldJoint_Time + ON dbo.HJGL_PreWeldFitupCheck(WeldJointId, CheckTime DESC); +END; + +--Ϣӷȼֶ +IF COL_LENGTH('dbo.HJGL_Pipeline', 'PaintId') IS NULL + ALTER TABLE dbo.HJGL_Pipeline ADD PaintId NVARCHAR(20) NULL; +GO + diff --git a/SGGL/BLL/API/APIUserService.cs b/SGGL/BLL/API/APIUserService.cs index b345156a..7ece0536 100644 --- a/SGGL/BLL/API/APIUserService.cs +++ b/SGGL/BLL/API/APIUserService.cs @@ -36,6 +36,8 @@ namespace BLL newItem.Telephone = getUser.Telephone; newItem.IsOffice = getUser.IsOffice; newItem.SignatureUrl = getUser.SignatureUrl; + newItem.WorkPostId= getUser.WorkPostId; + newItem.WorkPostName = WorkPostService.getWorkPostNameById(getUser.WorkPostId); if (!string.IsNullOrEmpty(getUser.Account)) { newItem.UserType = (getUser.PersonId == Const.sedinId ? "2" : "1"); diff --git a/SGGL/BLL/API/HJGL/APIPreWeldInspectionService.cs b/SGGL/BLL/API/HJGL/APIPreWeldInspectionService.cs index 815ffb76..84d66d7e 100644 --- a/SGGL/BLL/API/HJGL/APIPreWeldInspectionService.cs +++ b/SGGL/BLL/API/HJGL/APIPreWeldInspectionService.cs @@ -1,28 +1,35 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; namespace BLL { /// - /// 小程序焊前抽检接口服务 + /// 小程序焊前检查接口服务 /// public static class APIPreWeldInspectionService { /// - /// 根据焊口ID获取焊前抽检基础信息 + /// 根据焊口ID获取焊前基础信息 /// - /// 焊口ID - /// 焊口基础信息 public static Model.PreWeldJointItem GetPreWeldJointByWeldJointId(string weldJointId) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { + var getweldJointPaintId = (from x in db.HJGL_WeldJoint + join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId + where x.WeldJointId == weldJointId + select y.PaintId).FirstOrDefault(); + var getweldJointMaterialCode = (from x in db.HJGL_PipeLineMat + where x.WeldJointId == weldJointId + select x.MaterialCode).FirstOrDefault(); var query = from x in db.HJGL_WeldJoint join p in db.Base_Project on x.ProjectId equals p.ProjectId into projects - from p in projects.DefaultIfEmpty() - join g in db.Base_GrooveType on x.GrooveTypeId equals g.GrooveTypeId into grooveTypes - from g in grooveTypes.DefaultIfEmpty() + from p in projects.DefaultIfEmpty() + join pl in db.HJGL_Pipeline on x.PipelineId equals pl.PipelineId into pipelines + from pl in pipelines.DefaultIfEmpty() + join paint in db.Tw_PaintCodeDict on pl.PaintId equals paint.Id into paints + from paint in paints.DefaultIfEmpty() where x.WeldJointId == weldJointId select new Model.PreWeldJointItem { @@ -30,15 +37,25 @@ namespace BLL WeldJointCode = x.WeldJointCode, PipelineId = x.PipelineId, PipelineCode = x.PipelineCode, + PaintId= pl.PaintId, + PaintCode = paint == null ? string.Empty : paint.PaintCode, ProjectId = x.ProjectId, ProjectName = p == null ? string.Empty : p.ProjectName, - GrooveTypeId = x.GrooveTypeId, - GrooveTypeCode = g == null ? string.Empty : g.GrooveTypeCode, - GrooveTypeName = g == null ? string.Empty : g.GrooveTypeName, - GrooveProcessType = x.GrooveProcessType, - GrooveAngle = x.GrooveAngle, - FitupGap = x.FitupGap, - Misalignment = x.Misalignment + preWeldMaterialItems = (from m in db.HJGL_PipeLineMat + join lib in db.HJGL_MaterialCodeLib on m.MaterialCode equals lib.MaterialCode into libs + from lib in libs.DefaultIfEmpty() + where m.WeldJointId == weldJointId + select new Model.PreWeldMaterialItem + { + MaterialCode = lib.MaterialCode, + MaterialName = lib.MaterialName, + MaterialSpec = lib.MaterialSpec, + MaterialMade = lib.MaterialMade, + MaterialDef = lib.MaterialDef, + MaterialUnit = lib.MaterialUnit, + HeatNo = lib.HeatNo, + BatchNo = lib.BatchNo, + }).ToList() }; var item = query.FirstOrDefault(); @@ -52,14 +69,166 @@ namespace BLL } /// - /// 回填下料、组对抽检附件路径 + /// 获取焊口下料记录列表 + /// + public static List GetCuttingChecksByWeldJointId(string weldJointId) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var data = (from c in db.HJGL_PreWeldCuttingCheck + join w in db.HJGL_WeldJoint on c.WeldJointId equals w.WeldJointId + join p in db.Person_Persons on c.CheckPerson equals p.PersonId into persons + from p in persons.DefaultIfEmpty() + where c.WeldJointId == weldJointId + orderby c.CheckTime descending + select new Model.PreWeldCuttingCheckItem + { + CuttingCheckId = c.CuttingCheckId, + ProjectId = c.ProjectId, + WeldJointId = c.WeldJointId, + PipelineCode = w.PipelineCode, + WeldJointCode = w.WeldJointCode, + CuttingLength = c.CuttingLength, + GrooveForm = c.GrooveForm, + GrooveAngle = c.GrooveAngle, + IsMaterialCodeBatchNoAccurate = c.IsMaterialCodeBatchNoAccurate, + IsMaterialQuantityAccurate = c.IsMaterialQuantityAccurate, + IsQualified = c.IsQualified, + CheckPerson = c.CheckPerson, + CheckPersonName = p == null ? string.Empty : p.PersonName, + CheckTime = c.CheckTime, + CreateUser = c.CreateUser, + CreateTime = c.CreateTime, + AttachUrl1 = null, + CheckResult = c.CheckResult, + UnqualifiedReason = c.UnqualifiedReason, + RectifyRequirement = c.RectifyRequirement, + Remark = c.Remark + }).ToList(); + foreach (var item in data) + { + item.AttachUrl1 = GetAttachUrl(db, Const.HJGL_PreWeldCuttingCheckMenuId, item.CuttingCheckId); + } + return data; + } + } + + /// + /// 获取焊口组对记录列表 + /// + public static List GetFitupChecksByWeldJointId(string weldJointId) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var data = (from f in db.HJGL_PreWeldFitupCheck + join w in db.HJGL_WeldJoint on f.WeldJointId equals w.WeldJointId + join g in db.Base_GrooveType on f.GrooveTypeId equals g.GrooveTypeId into grooveTypes + from g in grooveTypes.DefaultIfEmpty() + join p in db.Person_Persons on f.CheckPerson equals p.PersonId into persons + from p in persons.DefaultIfEmpty() + where f.WeldJointId == weldJointId + orderby f.CheckTime descending + select new Model.PreWeldFitupCheckItem + { + FitupCheckId = f.FitupCheckId, + ProjectId = f.ProjectId, + WeldJointId = f.WeldJointId, + PipelineCode = w.PipelineCode, + WeldJointCode = w.WeldJointCode, + GrooveTypeId = f.GrooveTypeId, + GrooveTypeCode = g == null ? string.Empty : g.GrooveTypeCode, + GrooveTypeName = g == null ? string.Empty : g.GrooveTypeName, + GrooveProcessType = f.GrooveProcessType, + GrooveAngle = f.GrooveAngle, + FitupGap = f.FitupGap, + Misalignment = f.Misalignment, + WeldReinforcement = f.WeldReinforcement, + WeldHeight = f.WeldHeight, + WeldWidth = f.WeldWidth, + SurfaceDefect = f.SurfaceDefect, + CheckPerson = f.CheckPerson, + CheckPersonName = p == null ? string.Empty : p.PersonName, + CheckTime = f.CheckTime, + CreateUser = f.CreateUser, + CreateTime = f.CreateTime, + AttachUrl1 = null, + CheckResult = f.CheckResult, + UnqualifiedReason = f.UnqualifiedReason, + RectifyRequirement = f.RectifyRequirement, + Remark = f.Remark + }).ToList(); + foreach (var item in data) + { + item.AttachUrl1 = GetAttachUrl(db, Const.HJGL_PreWeldFitupCheckMenuId, item.FitupCheckId); + } + return data; + } + } + + /// + /// 按材料编码获取防腐检查记录 + /// + public static List GetAntiCorrosionChecksByMaterialCode(string materialCode, string projectId) + { + return PreWeldInspectionService.GetAntiCorrosionChecksByMaterialCode(materialCode, projectId); + } + /// + /// 按焊口获取防腐检查记录列表 + /// + /// + /// + public static List GetAntiCorrosionChecksByWeldJointId(string weldJointId) + { + return PreWeldInspectionService.GetAntiCorrosionChecksByWeldJointId(weldJointId); + } + /// + /// 保存下料检查 + /// + public static string SaveCuttingCheck(Model.PreWeldCuttingCheckInput item) + { + return PreWeldInspectionService.SaveCuttingCheck(item); + } + + /// + /// 保存组对检查 + /// + public static string SaveFitupCheck(Model.PreWeldFitupCheckInput item) + { + return PreWeldInspectionService.SaveFitupCheck(item); + } + + /// + /// 保存防腐检查 + /// + public static string SaveAntiCorrosionCheck(Model.AntiCorrosionCheckRecordInput item) + { + return PreWeldInspectionService.SaveAntiCorrosionCheck(item); + } + + /// + /// 获取防腐代码字典 + /// + public static List GetPaintCodeList() + { + return TwAntiCorrosionTrustService.GetPaintCodeList(); + } + + /// + /// 兼容旧接口:按焊口获取组对记录最新一条 + /// + public static Model.HJGL_PreWeldFitupCheck GetFitupCheckByWeldJointId(string weldJointId) + { + return PreWeldInspectionService.GetFitupCheckByWeldJointId(weldJointId); + } + + /// + /// 回写下料、组对附件地址 /// - /// 数据库上下文 - /// 焊前抽检基础信息 private static void SetInspectionAttachUrl(Model.SGGLDB db, Model.PreWeldJointItem item) { var cuttingCheckId = db.HJGL_PreWeldCuttingCheck .Where(x => x.WeldJointId == item.WeldJointId) + .OrderByDescending(x => x.CheckTime) .Select(x => x.CuttingCheckId) .FirstOrDefault(); if (!string.IsNullOrEmpty(cuttingCheckId)) @@ -69,6 +238,7 @@ namespace BLL var fitupCheckId = db.HJGL_PreWeldFitupCheck .Where(x => x.WeldJointId == item.WeldJointId) + .OrderByDescending(x => x.CheckTime) .Select(x => x.FitupCheckId) .FirstOrDefault(); if (!string.IsNullOrEmpty(fitupCheckId)) @@ -78,12 +248,8 @@ namespace BLL } /// - /// 按菜单和业务ID获取附件路径 + /// 根据菜单和业务ID获取附件地址 /// - /// 数据库上下文 - /// 菜单ID - /// 业务ID - /// 附件路径 private static string GetAttachUrl(Model.SGGLDB db, string menuId, string toKeyId) { var attachUrl = db.AttachFile @@ -92,149 +258,5 @@ namespace BLL .FirstOrDefault(); return string.IsNullOrEmpty(attachUrl) ? attachUrl : attachUrl.Replace('\\', '/'); } - - /// - /// 保存下料抽检,已存在同一焊口记录时更新原记录 - /// - /// 下料抽检参数 - public static void SaveCuttingCheck(Model.PreWeldCuttingCheckItem item) - { - if (item == null) - { - throw new ArgumentNullException("item"); - } - if (string.IsNullOrEmpty(item.WeldJointId)) - { - throw new ArgumentException("焊口ID不能为空。"); - } - - using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) - { - var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == item.WeldJointId); - if (weldJoint == null) - { - throw new ArgumentException("未找到对应焊口。"); - } - - var check = db.HJGL_PreWeldCuttingCheck.FirstOrDefault(x => x.WeldJointId == item.WeldJointId); - if (check == null) - { - check = new Model.HJGL_PreWeldCuttingCheck - { - CuttingCheckId = Guid.NewGuid().ToString(), - WeldJointId = item.WeldJointId, - ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId, - CreateUser = item.CreateUser ?? item.CheckPerson, - CreateTime = DateTime.Now - }; - db.HJGL_PreWeldCuttingCheck.InsertOnSubmit(check); - } - - check.ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId; - check.IsMaterialCodeBatchNoAccurate = item.IsMaterialCodeBatchNoAccurate; - check.IsMaterialQuantityAccurate = item.IsMaterialQuantityAccurate; - // 下料抽检合格规则:材料编码及炉批号、材料数量两个检查项均准确才合格。 - check.IsQualified = item.IsMaterialCodeBatchNoAccurate && item.IsMaterialQuantityAccurate; - check.CheckPerson = item.CheckPerson; - check.CheckTime = item.CheckTime ?? DateTime.Now; - check.Remark = item.Remark; - - db.SubmitChanges(); - - SaveInspectionAttachUrl(item.AttachUrl1, Const.HJGL_PreWeldCuttingCheckMenuId, check.CuttingCheckId); - } - } - - /// - /// 保存组对抽检,已存在同一焊口记录时更新原记录并回写焊口主表 - /// - /// 组对抽检参数 - public static void SaveFitupCheck(Model.PreWeldFitupCheckItem item) - { - if (item == null) - { - throw new ArgumentNullException("item"); - } - if (string.IsNullOrEmpty(item.WeldJointId)) - { - throw new ArgumentException("焊口ID不能为空。"); - } - if (string.IsNullOrEmpty(item.GrooveTypeId)) - { - throw new ArgumentException("坡口类型不能为空。"); - } - - using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) - { - var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == item.WeldJointId); - if (weldJoint == null) - { - throw new ArgumentException("未找到对应焊口。"); - } - if (!db.Base_GrooveType.Any(x => x.GrooveTypeId == item.GrooveTypeId)) - { - throw new ArgumentException("坡口类型不存在。"); - } - - var check = db.HJGL_PreWeldFitupCheck.FirstOrDefault(x => x.WeldJointId == item.WeldJointId); - if (check == null) - { - check = new Model.HJGL_PreWeldFitupCheck - { - FitupCheckId = Guid.NewGuid().ToString(), - WeldJointId = item.WeldJointId, - ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId, - CreateUser = item.CreateUser ?? item.CheckPerson, - CreateTime = DateTime.Now - }; - db.HJGL_PreWeldFitupCheck.InsertOnSubmit(check); - } - - check.ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId; - check.GrooveTypeId = item.GrooveTypeId; - check.GrooveProcessType = item.GrooveProcessType; - check.GrooveAngle = item.GrooveAngle; - check.FitupGap = item.FitupGap; - check.Misalignment = item.Misalignment; - check.CheckPerson = item.CheckPerson; - check.CheckTime = item.CheckTime ?? DateTime.Now; - check.Remark = item.Remark; - - // 组对抽检字段需同步回写焊口主表,供焊口台账和后续业务复用。 - weldJoint.GrooveTypeId = item.GrooveTypeId; - weldJoint.GrooveProcessType = item.GrooveProcessType; - weldJoint.GrooveAngle = item.GrooveAngle; - weldJoint.FitupGap = item.FitupGap; - weldJoint.Misalignment = item.Misalignment; - - db.SubmitChanges(); - - SaveInspectionAttachUrl(item.AttachUrl1, Const.HJGL_PreWeldFitupCheckMenuId, check.FitupCheckId); - } - } - - /// - /// 保存焊前抽检附件,空附件时清理原附件。 - /// - /// 附件路径 - /// 菜单ID - /// 业务数据ID - private static void SaveInspectionAttachUrl(string attachUrl, string menuId, string dataId) - { - // AttachUrl1 为 null 表示旧调用方未传附件参数,避免误删已有附件;空字符串表示明确清空附件。 - if (attachUrl == null) - { - return; - } - - if (!string.IsNullOrEmpty(attachUrl)) - { - UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(attachUrl, 10, null), attachUrl, menuId, dataId); - } - else - { - CommonService.DeleteAttachFileById(menuId, dataId); - } - } } } diff --git a/SGGL/BLL/CLGL/TwInputdetailBarCodeService.cs b/SGGL/BLL/CLGL/TwInputdetailBarCodeService.cs index 714ed8ef..7d3bcee3 100644 --- a/SGGL/BLL/CLGL/TwInputdetailBarCodeService.cs +++ b/SGGL/BLL/CLGL/TwInputdetailBarCodeService.cs @@ -57,7 +57,26 @@ namespace BLL return q.ToList(); } + public static List GetListData(string materialCode) + { + var q = from mat in Funs.DB.HJGL_MaterialCodeLib + where + mat.MaterialCode == materialCode + select new Tw_InputDetailBarCodeOutput + { + MaterialCode = mat.MaterialCode, + Code = mat.Code, + HeatNo = mat.HeatNo, + BatchNo = mat.BatchNo, + MaterialName = mat.MaterialName, + MaterialDef = mat.MaterialDef, + MaterialSpec = mat.MaterialSpec, + MaterialUnit = mat.MaterialUnit, + BarCode = mat.MaterialCode + }; + return q.ToList(); + } public static void AddByInputDetail(Tw_InputMaster inputMaster, Tw_InputDetail inputDetail) { if (inputMaster == null || inputDetail == null) diff --git a/SGGL/BLL/Common/Const.cs b/SGGL/BLL/Common/Const.cs index 8878a8ea..f7f2f3de 100644 --- a/SGGL/BLL/Common/Const.cs +++ b/SGGL/BLL/Common/Const.cs @@ -2949,6 +2949,11 @@ namespace BLL /// 组对抽检列表台账 /// public const string HJGL_PreWeldFitupCheckMenuId = "D1B5A8B7-5D2A-4C51-9B7E-6A2F15B7F003"; + + /// + /// 防腐检查记录 + /// + public const string Tw_AntiCorrosionCheckRecordMenuId = "7B62483A-4B6F-4A8C-9C61-5D0E2B4B7C31"; #endregion #region 预制设计 diff --git a/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs b/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs index 07b2b998..31dbd6b8 100644 --- a/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs +++ b/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs @@ -61,6 +61,22 @@ namespace BLL } } + /// + /// 维护管线材料导入编码,只更新材料编码字段,避免影响材料主编码和焊口关联。 + /// + /// 管线材料ID + /// 材料编码 + public static void UpdateMaterialCode2(string pipelineMatId, string materialCode) + { + Model.SGGLDB db = Funs.DB; + Model.HJGL_PipeLineMat pipeLineMat = db.HJGL_PipeLineMat.FirstOrDefault(e => e.PipeLineMatId == pipelineMatId); + if (pipeLineMat != null) + { + pipeLineMat.MaterialCode2 = materialCode; + db.SubmitChanges(); + } + } + /// /// 根据材料匹配结果反写材料主编码 /// @@ -94,6 +110,40 @@ namespace BLL return count; } + + /// + /// 按管线材料ID清除已反写的材料主编码,保留导入材料编码。 + /// + /// 管线材料ID列表。 + /// 清除数量。 + public static int ClearMaterialCodeByPipeLineMatIds(IEnumerable pipeLineMatIds) + { + var idList = pipeLineMatIds == null + ? new List() + : pipeLineMatIds.Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList(); + if (!idList.Any()) + { + return 0; + } + + Model.SGGLDB db = Funs.DB; + int count = 0; + var pipeLineMats = db.HJGL_PipeLineMat + .Where(e => idList.Contains(e.PipeLineMatId) && e.MaterialCode != null && e.MaterialCode != "") + .ToList(); + foreach (var item in pipeLineMats) + { + item.MaterialCode = null; + count++; + } + + if (count > 0) + { + db.SubmitChanges(); + } + + return count; + } /// /// 根据unitworkid删除焊口 /// diff --git a/SGGL/BLL/HJGL/WeldingManage/PipelineService.cs b/SGGL/BLL/HJGL/WeldingManage/PipelineService.cs index fe8c91d4..b9183242 100644 --- a/SGGL/BLL/HJGL/WeldingManage/PipelineService.cs +++ b/SGGL/BLL/HJGL/WeldingManage/PipelineService.cs @@ -616,6 +616,7 @@ namespace BLL newPipeline.PCMedium = pipeline.PCMedium; newPipeline.PCtype = pipeline.PCtype; newPipeline.MaterialId = pipeline.MaterialId; + newPipeline.PaintId = pipeline.PaintId; newPipeline.State = pipeline.State; newPipeline.FlowingSection = pipeline.FlowingSection; db.HJGL_Pipeline.InsertOnSubmit(newPipeline); @@ -656,6 +657,7 @@ namespace BLL newPipeline.PCtype = pipeline.PCtype; newPipeline.Remark = pipeline.Remark; newPipeline.MaterialId = pipeline.MaterialId; + newPipeline.PaintId = pipeline.PaintId; newPipeline.IsFinished = pipeline.IsFinished; newPipeline.PlanStartDate = pipeline.PlanStartDate; newPipeline.PlanEndDate = pipeline.PlanEndDate; diff --git a/SGGL/BLL/HJGL/WeldingManage/PreWeldInspectionService.cs b/SGGL/BLL/HJGL/WeldingManage/PreWeldInspectionService.cs index 71f0d24a..d4669c3e 100644 --- a/SGGL/BLL/HJGL/WeldingManage/PreWeldInspectionService.cs +++ b/SGGL/BLL/HJGL/WeldingManage/PreWeldInspectionService.cs @@ -1,16 +1,16 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; namespace BLL { /// - /// 焊前抽检台账服务 + /// 焊前检查台账服务 /// public static class PreWeldInspectionService { /// - /// 获取下料抽检台账 + /// 获取下料检查台账 /// public static Tuple, int> GetCuttingCheckList(string projectId, string pipelineCode, string weldJointCode, int pageIndex, int pageSize) { @@ -48,6 +48,9 @@ namespace BLL WeldJointId = x.c.WeldJointId, PipelineCode = x.w.PipelineCode, WeldJointCode = x.w.WeldJointCode, + CuttingLength = x.c.CuttingLength, + GrooveForm = x.c.GrooveForm, + GrooveAngle = x.c.GrooveAngle, IsMaterialCodeBatchNoAccurate = x.c.IsMaterialCodeBatchNoAccurate, IsMaterialQuantityAccurate = x.c.IsMaterialQuantityAccurate, IsQualified = x.c.IsQualified, @@ -56,16 +59,23 @@ namespace BLL CheckTime = x.c.CheckTime, CreateUser = x.c.CreateUser, CreateTime = x.c.CreateTime, + CheckResult = x.c.CheckResult, + UnqualifiedReason = x.c.UnqualifiedReason, + RectifyRequirement = x.c.RectifyRequirement, Remark = x.c.Remark }) .ToList(); + foreach (var item in data) + { + item.AttachUrl1 = GetInspectionAttachUrl(db, Const.HJGL_PreWeldCuttingCheckMenuId, item.CuttingCheckId); + } return Tuple.Create(data, total); } } /// - /// 获取组对抽检台账 + /// 获取组对检查台账 /// public static Tuple, int> GetFitupCheckList(string projectId, string pipelineCode, string weldJointCode, int pageIndex, int pageSize) { @@ -96,14 +106,14 @@ namespace BLL } int total = query.Count(); - var data = query.OrderBy(x => x.w.PipelineCode).ThenBy(x => x.w.WeldJointCode) + var data = query.OrderByDescending(x => x.f.CheckTime) .Skip(pageIndex * pageSize) .Take(pageSize) .Select(x => new Model.PreWeldFitupCheckItem { FitupCheckId = x.f.FitupCheckId, ProjectId = x.f.ProjectId, - WeldJointId = x.w.WeldJointId, + WeldJointId = x.f.WeldJointId, PipelineCode = x.w.PipelineCode, WeldJointCode = x.w.WeldJointCode, GrooveTypeId = x.f.GrooveTypeId, @@ -113,21 +123,32 @@ namespace BLL GrooveAngle = x.f.GrooveAngle, FitupGap = x.f.FitupGap, Misalignment = x.f.Misalignment, + WeldReinforcement = x.f.WeldReinforcement, + WeldHeight = x.f.WeldHeight, + WeldWidth = x.f.WeldWidth, + SurfaceDefect = x.f.SurfaceDefect, CheckPerson = x.f.CheckPerson, CheckPersonName = x.CheckPersonName, CheckTime = x.f.CheckTime, CreateUser = x.f.CreateUser, CreateTime = x.f.CreateTime, + CheckResult = x.f.CheckResult, + UnqualifiedReason = x.f.UnqualifiedReason, + RectifyRequirement = x.f.RectifyRequirement, Remark = x.f.Remark }) .ToList(); + foreach (var item in data) + { + item.AttachUrl1 = GetInspectionAttachUrl(db, Const.HJGL_PreWeldFitupCheckMenuId, item.FitupCheckId); + } return Tuple.Create(data, total); } } /// - /// 获取下料抽检实体 + /// 获取下料检查实体 /// public static Model.HJGL_PreWeldCuttingCheck GetCuttingCheckById(string cuttingCheckId) { @@ -138,14 +159,568 @@ namespace BLL } /// - /// 获取组对抽检实体 + /// 获取组对检查实体 + /// + public static Model.HJGL_PreWeldFitupCheck GetFitupCheckById(string fitupCheckId) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + return db.HJGL_PreWeldFitupCheck.FirstOrDefault(x => x.FitupCheckId == fitupCheckId); + } + } + + /// + /// 兼容旧调用:按焊口获取组对检查记录,返回最新一条 /// public static Model.HJGL_PreWeldFitupCheck GetFitupCheckByWeldJointId(string weldJointId) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - return db.HJGL_PreWeldFitupCheck.FirstOrDefault(x => x.WeldJointId == weldJointId); + return db.HJGL_PreWeldFitupCheck.Where(x => x.WeldJointId == weldJointId) + .OrderByDescending(x => x.CheckTime) + .FirstOrDefault(); } } + + /// + /// 按焊口获取下料记录 + /// + public static List GetCuttingChecksByWeldJointId(string weldJointId) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + return db.HJGL_PreWeldCuttingCheck.Where(x => x.WeldJointId == weldJointId) + .OrderByDescending(x => x.CheckTime) + .ToList(); + } + } + + /// + /// 按焊口获取组对记录 + /// + public static List GetFitupChecksByWeldJointId(string weldJointId) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + return db.HJGL_PreWeldFitupCheck.Where(x => x.WeldJointId == weldJointId) + .OrderByDescending(x => x.CheckTime) + .ToList(); + } + } + + /// + /// 保存下料检查;传入主键时修改对应记录,否则新增一条记录 + /// + public static string SaveCuttingCheck(Model.PreWeldCuttingCheckInput item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + if (string.IsNullOrEmpty(item.WeldJointId)) + { + throw new ArgumentException("焊口ID不能为空。"); + } + + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == item.WeldJointId); + if (weldJoint == null) + { + throw new ArgumentException("未找到对应焊口。"); + } + + var check = string.IsNullOrEmpty(item.CuttingCheckId) + ? null + : db.HJGL_PreWeldCuttingCheck.FirstOrDefault(x => x.CuttingCheckId == item.CuttingCheckId); + if (check == null) + { + check = new Model.HJGL_PreWeldCuttingCheck + { + CuttingCheckId = string.IsNullOrEmpty(item.CuttingCheckId) ? Guid.NewGuid().ToString() : item.CuttingCheckId, + CreateTime = DateTime.Now + }; + db.HJGL_PreWeldCuttingCheck.InsertOnSubmit(check); + } + + check.WeldJointId = item.WeldJointId; + check.ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId; + check.CuttingLength = item.CuttingLength; + check.GrooveForm = item.GrooveForm; + check.GrooveAngle = item.GrooveAngle; + check.IsMaterialCodeBatchNoAccurate = item.IsMaterialCodeBatchNoAccurate; + check.IsMaterialQuantityAccurate = item.IsMaterialQuantityAccurate; + // 下料检查合格规则:材料编码批次和材料数量都准确才判定为合格。 + check.IsQualified = item.IsMaterialCodeBatchNoAccurate && item.IsMaterialQuantityAccurate; + check.CheckPerson = item.CheckPerson; + check.CheckTime = item.CheckTime ?? DateTime.Now; + check.CreateUser = item.CreateUser ?? item.CheckPerson; + check.CheckResult = item.CheckResult; + check.UnqualifiedReason = item.UnqualifiedReason; + check.RectifyRequirement = item.RectifyRequirement; + check.Remark = item.Remark; + db.SubmitChanges(); + SaveInspectionAttachUrl(item.AttachUrl1, Const.HJGL_PreWeldCuttingCheckMenuId, check.CuttingCheckId); + return check.CuttingCheckId; + } + } + + /// + /// 保存组对检查;传入主键时修改对应记录,否则新增一条记录 + /// + public static string SaveFitupCheck(Model.PreWeldFitupCheckInput item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + if (string.IsNullOrEmpty(item.WeldJointId)) + { + throw new ArgumentException("焊口ID不能为空。"); + } + if (string.IsNullOrEmpty(item.GrooveTypeId)) + { + throw new ArgumentException("坡口类型不能为空。"); + } + + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == item.WeldJointId); + if (weldJoint == null) + { + throw new ArgumentException("未找到对应焊口。"); + } + if (!db.Base_GrooveType.Any(x => x.GrooveTypeId == item.GrooveTypeId)) + { + throw new ArgumentException("坡口类型不存在。"); + } + + var check = string.IsNullOrEmpty(item.FitupCheckId) + ? null + : db.HJGL_PreWeldFitupCheck.FirstOrDefault(x => x.FitupCheckId == item.FitupCheckId); + if (check == null) + { + check = new Model.HJGL_PreWeldFitupCheck + { + FitupCheckId = string.IsNullOrEmpty(item.FitupCheckId) ? Guid.NewGuid().ToString() : item.FitupCheckId, + CreateTime = DateTime.Now + }; + db.HJGL_PreWeldFitupCheck.InsertOnSubmit(check); + } + + check.ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId; + check.WeldJointId = item.WeldJointId; + check.GrooveTypeId = item.GrooveTypeId; + check.GrooveProcessType = item.GrooveProcessType; + check.GrooveAngle = item.GrooveAngle; + check.FitupGap = item.FitupGap; + check.Misalignment = item.Misalignment; + check.WeldReinforcement = item.WeldReinforcement; + check.WeldHeight = item.WeldHeight; + check.WeldWidth = item.WeldWidth; + check.SurfaceDefect = item.SurfaceDefect; + check.CheckPerson = item.CheckPerson; + check.CheckTime = item.CheckTime ?? DateTime.Now; + check.CreateUser = item.CreateUser ?? item.CheckPerson; + check.CheckResult = item.CheckResult; + check.UnqualifiedReason = item.UnqualifiedReason; + check.RectifyRequirement = item.RectifyRequirement; + check.Remark = item.Remark; + + // 组对检查需要同步回写焊口主表,保证焊口基础信息保持最新 + weldJoint.GrooveTypeId = item.GrooveTypeId; + weldJoint.GrooveProcessType = item.GrooveProcessType; + weldJoint.GrooveAngle = item.GrooveAngle; + weldJoint.FitupGap = item.FitupGap; + weldJoint.Misalignment = item.Misalignment; + + db.SubmitChanges(); + SaveInspectionAttachUrl(item.AttachUrl1, Const.HJGL_PreWeldFitupCheckMenuId, check.FitupCheckId); + return check.FitupCheckId; + } + } + + /// + /// 获取防腐检查台账 + /// + public static Tuple, int> GetAntiCorrosionCheckList(string projectId, string materialCode, string paintCode, string intermediatePaint, string topcoat, string filmThickness, string checkResult, DateTime? startTime, DateTime? endTime, int pageIndex, int pageSize) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var query = from r in db.HJGL_AntiCorrosionCheckRecord + join m in db.HJGL_MaterialCodeLib on r.MaterialCode equals m.MaterialCode into materialJoin + from m in materialJoin.DefaultIfEmpty() + join paint in db.Tw_PaintCodeDict on r.PaintId equals paint.Id into paintJoin + from paint in paintJoin.DefaultIfEmpty() + join person in db.Person_Persons on r.CheckPerson equals person.PersonId into personJoin + from person in personJoin.DefaultIfEmpty() + where string.IsNullOrEmpty(projectId) || r.ProjectId == projectId + select new { r, m, paint, person }; + if (!string.IsNullOrEmpty(materialCode)) + { + query = query.Where(x => x.r.MaterialCode.Contains(materialCode)); + } + if (!string.IsNullOrEmpty(paintCode)) + { + query = query.Where(x => x.paint != null && x.paint.PaintCode.Contains(paintCode)); + } + if (!string.IsNullOrEmpty(intermediatePaint)) + { + query = query.Where(x => x.paint != null && x.paint.IntermediatePaint.Contains(intermediatePaint)); + } + if (!string.IsNullOrEmpty(topcoat)) + { + query = query.Where(x => x.paint != null && x.paint.Topcoat.Contains(topcoat)); + } + decimal filmThicknessValue; + if (!string.IsNullOrWhiteSpace(filmThickness) && decimal.TryParse(filmThickness, out filmThicknessValue)) + { + query = query.Where(x => x.r.FilmThickness == filmThicknessValue); + } + if (!string.IsNullOrEmpty(checkResult)) + { + query = query.Where(x => x.r.CheckResult == checkResult); + } + if (startTime.HasValue) + { + query = query.Where(x => x.r.CheckTime >= startTime.Value); + } + if (endTime.HasValue) + { + query = query.Where(x => x.r.CheckTime < endTime.Value.AddDays(1)); + } + + int total = query.Count(); + var data = query.OrderByDescending(x => x.r.CheckTime) + .Skip(pageIndex * pageSize) + .Take(pageSize) + .Select(x => new Model.AntiCorrosionCheckRecordItem + { + AntiCorrosionCheckId = x.r.AntiCorrosionCheckId, + ProjectId = x.r.ProjectId, + UnitWorkId = x.r.UnitWorkId, + MaterialId = x.r.MaterialId, + MaterialCode = x.r.MaterialCode, + MaterialName = x.m == null ? string.Empty : x.m.MaterialName, + MaterialSpec = x.m == null ? string.Empty : x.m.MaterialSpec, + MaterialMade = x.m == null ? string.Empty : x.m.MaterialMade, + MaterialDef = x.m == null ? string.Empty : x.m.MaterialDef, + MaterialUnit = x.m == null ? string.Empty : x.m.MaterialUnit, + HeatNo = x.m == null ? string.Empty : x.m.HeatNo, + BatchNo = x.m == null ? string.Empty : x.m.BatchNo, + Code = x.m == null ? string.Empty : x.m.Code, + AnticorrosionLevel = x.r.AnticorrosionLevel, + PaintId = x.r.PaintId, + PaintCode = x.paint == null ? string.Empty : x.paint.PaintCode, + Primer = x.paint == null ? string.Empty : x.paint.Primer, + IntermediatePaint = x.paint == null ? string.Empty : x.paint.IntermediatePaint, + Topcoat = x.paint == null ? string.Empty : x.paint.Topcoat, + ColorCode = x.paint == null ? string.Empty : x.paint.ColorCode, + FilmThickness = x.r.FilmThickness, + SandBlasting = x.r.SandBlasting, + RustSandBlasting = x.r.RustSandBlasting, + CheckResult = x.r.CheckResult, + CheckPerson = x.r.CheckPerson, + CheckPersonName = x.person == null ? string.Empty : x.person.PersonName, + CheckTime = x.r.CheckTime, + UnqualifiedReason = x.r.UnqualifiedReason, + RectifyRequirement = x.r.RectifyRequirement, + Remark = x.r.Remark, + CreateUser = x.r.CreateUser, + CreateTime = x.r.CreateTime + }) + .ToList(); + foreach (var item in data) + { + item.AttachUrl1 = GetInspectionAttachUrl(db, Const.Tw_AntiCorrosionCheckRecordMenuId, item.AntiCorrosionCheckId); + } + + return Tuple.Create(data, total); + } + } + + /// + /// 根据防腐记录ID获取详情 + /// + public static Model.AntiCorrosionCheckRecordItem GetAntiCorrosionCheckById(string antiCorrosionCheckId) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var query = from r in db.HJGL_AntiCorrosionCheckRecord + join m in db.HJGL_MaterialCodeLib on r.MaterialCode equals m.MaterialCode into materialJoin + from m in materialJoin.DefaultIfEmpty() + join paint in db.Tw_PaintCodeDict on r.PaintId equals paint.Id into paintJoin + from paint in paintJoin.DefaultIfEmpty() + join person in db.Person_Persons on r.CheckPerson equals person.PersonId into personJoin + from person in personJoin.DefaultIfEmpty() + where r.AntiCorrosionCheckId == antiCorrosionCheckId + select new Model.AntiCorrosionCheckRecordItem + { + AntiCorrosionCheckId = r.AntiCorrosionCheckId, + ProjectId = r.ProjectId, + UnitWorkId = r.UnitWorkId, + MaterialId = r.MaterialId, + MaterialCode = r.MaterialCode, + MaterialName = m == null ? string.Empty : m.MaterialName, + MaterialSpec = m == null ? string.Empty : m.MaterialSpec, + MaterialMade = m == null ? string.Empty : m.MaterialMade, + MaterialDef = m == null ? string.Empty : m.MaterialDef, + MaterialUnit = m == null ? string.Empty : m.MaterialUnit, + HeatNo = m == null ? string.Empty : m.HeatNo, + BatchNo = m == null ? string.Empty : m.BatchNo, + Code = m == null ? string.Empty : m.Code, + AnticorrosionLevel = r.AnticorrosionLevel, + PaintId = r.PaintId, + PaintCode = paint == null ? string.Empty : paint.PaintCode, + Primer = paint == null ? string.Empty : paint.Primer, + IntermediatePaint = paint == null ? string.Empty : paint.IntermediatePaint, + Topcoat = paint == null ? string.Empty : paint.Topcoat, + ColorCode = paint == null ? string.Empty : paint.ColorCode, + FilmThickness = r.FilmThickness, + SandBlasting = r.SandBlasting, + RustSandBlasting = r.RustSandBlasting, + CheckResult = r.CheckResult, + CheckPerson = r.CheckPerson, + CheckPersonName = person == null ? string.Empty : person.PersonName, + CheckTime = r.CheckTime, + UnqualifiedReason = r.UnqualifiedReason, + RectifyRequirement = r.RectifyRequirement, + Remark = r.Remark, + CreateUser = r.CreateUser, + CreateTime = r.CreateTime + }; + var item = query.FirstOrDefault(); + if (item != null) + { + item.AttachUrl1 = GetInspectionAttachUrl(db, Const.Tw_AntiCorrosionCheckRecordMenuId, item.AntiCorrosionCheckId); + } + return item; + } + } + + /// + /// 按材料编码获取防腐记录列表 + /// + public static List GetAntiCorrosionChecksByMaterialCode(string materialCode, string projectId) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var query = from r in db.HJGL_AntiCorrosionCheckRecord + join m in db.HJGL_MaterialCodeLib on r.MaterialCode equals m.MaterialCode into materialJoin + from m in materialJoin.DefaultIfEmpty() + join paint in db.Tw_PaintCodeDict on r.PaintId equals paint.Id into paintJoin + from paint in paintJoin.DefaultIfEmpty() + join person in db.Person_Persons on r.CheckPerson equals person.PersonId into personJoin + from person in personJoin.DefaultIfEmpty() + where r.MaterialCode == materialCode && (string.IsNullOrEmpty(projectId) || r.ProjectId == projectId) + orderby r.CheckTime descending + select new Model.AntiCorrosionCheckRecordItem + { + AntiCorrosionCheckId = r.AntiCorrosionCheckId, + ProjectId = r.ProjectId, + UnitWorkId = r.UnitWorkId, + MaterialId = r.MaterialId, + MaterialCode = r.MaterialCode, + MaterialName = m == null ? string.Empty : m.MaterialName, + MaterialSpec = m == null ? string.Empty : m.MaterialSpec, + MaterialMade = m == null ? string.Empty : m.MaterialMade, + MaterialDef = m == null ? string.Empty : m.MaterialDef, + MaterialUnit = m == null ? string.Empty : m.MaterialUnit, + HeatNo = m == null ? string.Empty : m.HeatNo, + BatchNo = m == null ? string.Empty : m.BatchNo, + Code = m == null ? string.Empty : m.Code, + AnticorrosionLevel = r.AnticorrosionLevel, + PaintId = r.PaintId, + PaintCode = paint == null ? string.Empty : paint.PaintCode, + Primer = paint == null ? string.Empty : paint.Primer, + IntermediatePaint = paint == null ? string.Empty : paint.IntermediatePaint, + Topcoat = paint == null ? string.Empty : paint.Topcoat, + ColorCode = paint == null ? string.Empty : paint.ColorCode, + FilmThickness = r.FilmThickness, + SandBlasting = r.SandBlasting, + RustSandBlasting = r.RustSandBlasting, + CheckResult = r.CheckResult, + CheckPerson = r.CheckPerson, + CheckPersonName = person == null ? string.Empty : person.PersonName, + CheckTime = r.CheckTime, + UnqualifiedReason = r.UnqualifiedReason, + RectifyRequirement = r.RectifyRequirement, + Remark = r.Remark, + CreateUser = r.CreateUser, + CreateTime = r.CreateTime + }; + var data = query.ToList(); + foreach (var item in data) + { + item.AttachUrl1 = GetInspectionAttachUrl(db, Const.Tw_AntiCorrosionCheckRecordMenuId, item.AntiCorrosionCheckId); + } + return data; + } + } + + /// + /// 按焊口获取防腐检查记录列表 + /// + /// + /// + public static List GetAntiCorrosionChecksByWeldJointId(string weldJointId) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + + var getweldJointPaintId=(from x in db.HJGL_WeldJoint + join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId + where x.WeldJointId == weldJointId + select y.PaintId).FirstOrDefault(); + var getweldJointMaterialCode = (from x in db.HJGL_PipeLineMat + where x.WeldJointId == weldJointId + select x.MaterialCode).FirstOrDefault(); + var query = from r in db.HJGL_AntiCorrosionCheckRecord + join m in db.HJGL_MaterialCodeLib on r.MaterialCode equals m.MaterialCode into materialJoin + from m in materialJoin.DefaultIfEmpty() + join paint in db.Tw_PaintCodeDict on r.PaintId equals paint.Id into paintJoin + from paint in paintJoin.DefaultIfEmpty() + join person in db.Person_Persons on r.CheckPerson equals person.PersonId into personJoin + from person in personJoin.DefaultIfEmpty() + join weldmat in db.HJGL_PipeLineMat on r.MaterialCode equals weldmat.MaterialCode into weldJoin + from weldmat in weldJoin.DefaultIfEmpty() + where weldmat.WeldJointId == weldJointId && (string.IsNullOrEmpty(getweldJointPaintId) || r.PaintId == getweldJointPaintId) + orderby r.CheckTime descending + select new Model.AntiCorrosionCheckRecordItem + { + AntiCorrosionCheckId = r.AntiCorrosionCheckId, + ProjectId = r.ProjectId, + UnitWorkId = r.UnitWorkId, + MaterialId = r.MaterialId, + MaterialCode = r.MaterialCode, + MaterialName = m == null ? string.Empty : m.MaterialName, + MaterialSpec = m == null ? string.Empty : m.MaterialSpec, + MaterialMade = m == null ? string.Empty : m.MaterialMade, + MaterialDef = m == null ? string.Empty : m.MaterialDef, + MaterialUnit = m == null ? string.Empty : m.MaterialUnit, + HeatNo = m == null ? string.Empty : m.HeatNo, + BatchNo = m == null ? string.Empty : m.BatchNo, + Code = m == null ? string.Empty : m.Code, + AnticorrosionLevel = r.AnticorrosionLevel, + PaintId = r.PaintId, + PaintCode = paint == null ? string.Empty : paint.PaintCode, + Primer = paint == null ? string.Empty : paint.Primer, + IntermediatePaint = paint == null ? string.Empty : paint.IntermediatePaint, + Topcoat = paint == null ? string.Empty : paint.Topcoat, + ColorCode = paint == null ? string.Empty : paint.ColorCode, + FilmThickness = r.FilmThickness, + SandBlasting = r.SandBlasting, + RustSandBlasting = r.RustSandBlasting, + CheckResult = r.CheckResult, + CheckPerson = r.CheckPerson, + CheckPersonName = person == null ? string.Empty : person.PersonName, + CheckTime = r.CheckTime, + UnqualifiedReason = r.UnqualifiedReason, + RectifyRequirement = r.RectifyRequirement, + Remark = r.Remark, + CreateUser = r.CreateUser, + CreateTime = r.CreateTime + }; + var data = query.ToList(); + foreach (var item in data) + { + item.AttachUrl1 = GetInspectionAttachUrl(db, Const.Tw_AntiCorrosionCheckRecordMenuId, item.AntiCorrosionCheckId); + } + return data; + } + } + + /// + /// 保存防腐检查,始终新增一条历史记录 + /// + public static string SaveAntiCorrosionCheck(Model.AntiCorrosionCheckRecordInput item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + if (string.IsNullOrEmpty(item.MaterialCode)) + { + throw new ArgumentException("材料编码不能为空。"); + } + if (string.IsNullOrEmpty(item.PaintId)) + { + throw new ArgumentException("防腐代码不能为空。"); + } + + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + if (!db.Tw_PaintCodeDict.Any(x => x.Id == item.PaintId && x.IsUsed)) + { + throw new ArgumentException("防腐代码不存在或已停用。"); + } + + var check = string.IsNullOrEmpty(item.AntiCorrosionCheckId) + ? null + : db.HJGL_AntiCorrosionCheckRecord.FirstOrDefault(x => x.AntiCorrosionCheckId == item.AntiCorrosionCheckId); + if (check == null) + { + check = new Model.HJGL_AntiCorrosionCheckRecord + { + AntiCorrosionCheckId = string.IsNullOrEmpty(item.AntiCorrosionCheckId) ? Guid.NewGuid().ToString() : item.AntiCorrosionCheckId, + CreateTime = DateTime.Now + }; + db.HJGL_AntiCorrosionCheckRecord.InsertOnSubmit(check); + } + + var materialId = item.MaterialId; + + check.ProjectId = item.ProjectId; + check.MaterialId = materialId; + check.MaterialCode = item.MaterialCode; + check.AnticorrosionLevel = item.AnticorrosionLevel; + check.PaintId = item.PaintId; + check.FilmThickness = item.FilmThickness; + check.SandBlasting = item.SandBlasting; + check.RustSandBlasting = item.RustSandBlasting; + check.CheckResult = item.CheckResult; + check.CheckPerson = item.CheckPerson; + check.CheckTime = item.CheckTime ?? DateTime.Now; + check.UnqualifiedReason = item.UnqualifiedReason; + check.RectifyRequirement = item.RectifyRequirement; + check.Remark = item.Remark; + check.CreateUser = string.IsNullOrEmpty(item.CreateUser) ? item.CheckPerson : item.CreateUser; + db.SubmitChanges(); + SaveInspectionAttachUrl(item.AttachUrl1, Const.Tw_AntiCorrosionCheckRecordMenuId, check.AntiCorrosionCheckId); + return check.AntiCorrosionCheckId; + } + } + + /// + /// 保存检查附件 + /// + private static void SaveInspectionAttachUrl(string attachUrl, string menuId, string dataId) + { + if (attachUrl == null) + { + return; + } + + if (!string.IsNullOrEmpty(attachUrl)) + { + UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(attachUrl, 10, null), attachUrl, menuId, dataId); + } + else + { + CommonService.DeleteAttachFileById(menuId, dataId); + } + } + + /// + /// 根据菜单和记录ID获取检查附件地址 + /// + private static string GetInspectionAttachUrl(Model.SGGLDB db, string menuId, string dataId) + { + var attachUrl = db.AttachFile + .Where(x => x.MenuId == menuId && x.ToKeyId == dataId) + .Select(x => x.AttachUrl) + .FirstOrDefault(); + return string.IsNullOrEmpty(attachUrl) ? attachUrl : attachUrl.Replace('\\', '/'); + } } } diff --git a/SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecord.aspx b/SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecord.aspx new file mode 100644 index 00000000..26bc60e7 --- /dev/null +++ b/SGGL/FineUIPro.Web/CLGL/AntiCorrosionCheckRecord.aspx @@ -0,0 +1,101 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AntiCorrosionCheckRecord.aspx.cs" Inherits="FineUIPro.Web.CLGL.AntiCorrosionCheckRecord" %> + + + + + 防腐检查记录 + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +