From 7b5b060ffc08390f65440f79adb55fa30856f7eb Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Wed, 16 Sep 2026 15:49:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(hjgl):=20=E5=AE=8C=E5=96=84=E7=AE=A1?= =?UTF-8?q?=E7=BA=BF=E9=A2=84=E5=88=B6=E4=B8=8E=E7=84=8A=E6=8E=A5=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同步管线组件、材料和焊口关联数据,优化预制组件打印及焊接相关查询,减少业务台账与实际关联信息不一致。 --- .../WeldingManage/PipelineComponentService.cs | 139 +++++++++++++----- .../HJGL/WeldingManage/PipelineMatService.cs | 36 +++++ .../File/Fastreport/组件打印.frx | 32 +--- .../File/Fastreport/组件打印_60x162.frx | 34 +---- SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.cs | 12 +- .../HJGL/PointTrust/TrustBatch.aspx.cs | 6 +- .../HJGL/PreDesign/PrePipeline.aspx | 15 +- .../HJGL/PreDesign/PrePipeline.aspx.cs | 64 ++------ .../PreDesign/PrePipeline.aspx.designer.cs | 18 --- .../HJGL/PreDesign/PrePipelineEdit.aspx.cs | 4 +- .../WeldingManage/WeldAppearanceCheck.aspx.cs | 7 +- .../HJGL/WeldingManage/WeldReport.aspx.cs | 4 +- .../PipelineComponentPrintDto.cs | 3 - 13 files changed, 179 insertions(+), 195 deletions(-) diff --git a/SGGL/BLL/HJGL/WeldingManage/PipelineComponentService.cs b/SGGL/BLL/HJGL/WeldingManage/PipelineComponentService.cs index f0ae5ad7..8b35bb6f 100644 --- a/SGGL/BLL/HJGL/WeldingManage/PipelineComponentService.cs +++ b/SGGL/BLL/HJGL/WeldingManage/PipelineComponentService.cs @@ -194,9 +194,6 @@ namespace BLL from aunit in aunitJoin.DefaultIfEmpty() join unitwork in db.WBS_UnitWork on pipe.UnitWorkId equals unitwork.UnitWorkId into unitworkJoin from unitwork in unitworkJoin.DefaultIfEmpty() - join mater in db.Base_Material on pipe.MaterialId equals mater.MaterialId into materJoin - from mater in materJoin.DefaultIfEmpty() - where com.QRCode != "" orderby com.PipelineComponentCode, com.PipelineId select new PipelineComponentPrintDto { @@ -208,13 +205,10 @@ namespace BLL PreUnit = punit.UnitName, AssembleUnit = aunit.UnitName, PrefabricatedComponents = mat.PrefabricatedComponents, - QRCode = com.QRCode, State = com.State, PlanStartDate = string.Format("yyyy-MM-dd", pipe.PlanStartDate), PipelineCode = pipe.PipelineCode, - FlowingSection = pipe.FlowingSection, QRCode2 = "PrePipeline$" + com.PipelineComponentId, - MaterialCode = mater.MaterialCode, IsPrint = com.IsPrint }; @@ -278,14 +272,15 @@ namespace BLL return; } - var model_mat = BLL.PipelineMatService.GetPipeLineMat(pipeLineMatId); + Model.SGGLDB db = Funs.DB; + var model_mat = db.HJGL_PipeLineMat.FirstOrDefault(x => x.PipeLineMatId == pipeLineMatId); if (model_mat == null || string.IsNullOrEmpty(model_mat.PipelineId)) { return; } var PipelineId = model_mat.PipelineId; - var pipelineModel = BLL.PipelineService.GetPipelineByPipelineId(PipelineId); + var pipelineModel = db.HJGL_Pipeline.FirstOrDefault(x => x.PipelineId == PipelineId); if (pipelineModel == null) { return; @@ -294,37 +289,64 @@ namespace BLL var PipeArea = pipelineModel.PipeArea; if (PipeArea == PipelineService.PipeArea_SHOP && !string.IsNullOrEmpty(model_mat.PrefabricatedComponents)) { - // var model = GetPipelineComponentByMatId(pipeLineMatId); - var model = GetPipelineComponentByCodeandpipelineId(model_mat.PrefabricatedComponents, PipelineId); + var model = db.HJGL_Pipeline_Component.FirstOrDefault(x => x.PipelineComponentCode == model_mat.PrefabricatedComponents + && x.PipelineId == PipelineId); // 组件号可能来自导入数据,未包含分隔符时直接使用原值,避免截取时报错。 var drawingName = GetDrawingNameByComponentCode(model_mat.PrefabricatedComponents); - if (model != null) + if (model == null) { - model.PipelineId = PipelineId; - model.PipelineComponentCode = model_mat.PrefabricatedComponents; - model.DrawingName = drawingName; - model.State = State0; - model.ProductionState = 0; - UpdatePipelineComponent(model); - } - else - { - model = new Model.HJGL_Pipeline_Component(); - model.PipelineComponentId = SQLHelper.GetNewID(); - model.PipelineId = PipelineId; - model.PipelineComponentCode = model_mat.PrefabricatedComponents; - model.DrawingName = drawingName; - model.State = State0; - model.ProductionState = 0; - model.IsPrint = false; - AddPipelineComponent(model); + model = new Model.HJGL_Pipeline_Component + { + PipelineComponentId = SQLHelper.GetNewID(), + IsPrint = false + }; + db.HJGL_Pipeline_Component.InsertOnSubmit(model); } + model.PipelineId = PipelineId; + model.PipelineComponentCode = model_mat.PrefabricatedComponents; + model.DrawingName = drawingName; + model.State = State0; + model.ProductionState = 0; + + // 材料导入同步组件时,同时按焊口幂等维护组件关联,避免只生成组件主数据。 + SyncPipelineComponentJoint(db, model, model_mat.WeldJointId); + db.SubmitChanges(); + } + } + + /// + /// 按焊口同步预制组件关联。 + /// + private static void SyncPipelineComponentJoint(Model.SGGLDB db, Model.HJGL_Pipeline_Component pipelineComponent, string weldJointId) + { + if (pipelineComponent == null || string.IsNullOrEmpty(weldJointId)) + { + return; } + var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == weldJointId); + if (weldJoint == null) + { + return; + } + var componentJoint = db.HJGL_Pipeline_ComponentJoint.FirstOrDefault(x => x.WeldJointId == weldJointId); + if (componentJoint == null) + { + componentJoint = new Model.HJGL_Pipeline_ComponentJoint + { + Id = SQLHelper.GetNewID(), + WeldJointId = weldJoint.WeldJointId, + State = State0 + }; + db.HJGL_Pipeline_ComponentJoint.InsertOnSubmit(componentJoint); + } - + // 已存在的关联保留生产状态,只刷新组件及焊口标识。 + componentJoint.PipelineComponentId = pipelineComponent.PipelineComponentId; + componentJoint.PipelineComponentCode = pipelineComponent.PipelineComponentCode; + componentJoint.WeldJointCode = weldJoint.WeldJointCode; } private static string GetDrawingNameByComponentCode(string pipelineComponentCode) @@ -371,6 +393,53 @@ namespace BLL db.SubmitChanges(); } + /// + /// 修改管线预制组件基础信息,并同步材料及焊口关联中的组件编号。 + /// + public static void UpdatePipelineComponentBasicInfo(Model.HJGL_Pipeline_Component pipeline) + { + if (pipeline == null || string.IsNullOrEmpty(pipeline.PipelineComponentId)) + { + return; + } + + Model.SGGLDB db = Funs.DB; + var current = db.HJGL_Pipeline_Component.FirstOrDefault(e => e.PipelineComponentId == pipeline.PipelineComponentId); + if (current == null) + { + return; + } + + string oldPipelineComponentCode = current.PipelineComponentCode; + current.PipelineId = pipeline.PipelineId; + current.PreUnit = pipeline.PreUnit; + current.AssembleUnit = pipeline.AssembleUnit; + current.PipelineComponentCode = pipeline.PipelineComponentCode; + current.BoxNumber = pipeline.BoxNumber; + + if (!string.Equals(oldPipelineComponentCode, pipeline.PipelineComponentCode, StringComparison.Ordinal)) + { + // 组件编号是材料和组件焊口关联的逻辑键,编辑时必须同步更新。 + if (!string.IsNullOrEmpty(oldPipelineComponentCode)) + { + var pipelineMaterials = db.HJGL_PipeLineMat.Where(x => x.PipelineId == current.PipelineId + && x.PrefabricatedComponents == oldPipelineComponentCode); + foreach (var pipelineMaterial in pipelineMaterials) + { + pipelineMaterial.PrefabricatedComponents = pipeline.PipelineComponentCode; + } + } + + var componentJoints = db.HJGL_Pipeline_ComponentJoint.Where(x => x.PipelineComponentId == current.PipelineComponentId); + foreach (var componentJoint in componentJoints) + { + componentJoint.PipelineComponentCode = pipeline.PipelineComponentCode; + } + } + + db.SubmitChanges(); + } + /// /// 修改管线预制组件 /// @@ -507,10 +576,14 @@ namespace BLL public static void DeletePipelineComponentBypipelineId(string pipelineId) { Model.SGGLDB db = Funs.DB; - var mdoel = db.HJGL_Pipeline_Component.Where(e => e.PipelineId == pipelineId); - if (mdoel != null) + var components = db.HJGL_Pipeline_Component.Where(e => e.PipelineId == pipelineId).ToList(); + if (components.Count > 0) { - db.HJGL_Pipeline_Component.DeleteAllOnSubmit(mdoel); + // 更新导入会重建管线组件,先清理旧组件焊口关联,避免遗留孤儿数据。 + var componentIds = components.Select(x => x.PipelineComponentId).ToArray(); + var componentJoints = db.HJGL_Pipeline_ComponentJoint.Where(x => componentIds.Contains(x.PipelineComponentId)); + db.HJGL_Pipeline_ComponentJoint.DeleteAllOnSubmit(componentJoints); + db.HJGL_Pipeline_Component.DeleteAllOnSubmit(components); db.SubmitChanges(); } } diff --git a/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs b/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs index ca07e9bc..b0dbdb9e 100644 --- a/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs +++ b/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs @@ -6,6 +6,42 @@ namespace BLL public static class PipelineMatService { + /// + /// 按焊口编号顺序,先左后右校准零数量材料的主编码。 + /// + public static int CalibrateSharedMaterialCodes(string pipelineId) + { + Model.SGGLDB db = Funs.DB; + var materials = db.HJGL_PipeLineMat.Where(x => x.PipelineId == pipelineId).ToList(); + var joints = db.HJGL_WeldJoint.Where(x => x.PipelineId == pipelineId) + .OrderBy(x => x.WeldJointCode).ToList(); + int count = 0; + + foreach (var material in materials.Where(x => x.Number == 0m)) + { + int jointIndex = joints.FindIndex(x => x.WeldJointId == material.WeldJointId); + HJGL_PipeLineMat source = null; + if (jointIndex > 0) + { + source = materials.FirstOrDefault(x => x.WeldJointId == joints[jointIndex - 1].WeldJointId + && x.MaterialCode2 == material.MaterialCode2 && x.MaterialCode != null); + } + if (source == null && jointIndex < joints.Count - 1) + { + source = materials.FirstOrDefault(x => x.WeldJointId == joints[jointIndex + 1].WeldJointId + && x.MaterialCode2 == material.MaterialCode2 && x.MaterialCode != null); + } + if (source != null) + { + material.MaterialCode = source.MaterialCode; + count++; + } + } + + db.SubmitChanges(); + return count; + } + /// ///获取管线材料信息 /// diff --git a/SGGL/FineUIPro.Web/File/Fastreport/组件打印.frx b/SGGL/FineUIPro.Web/File/Fastreport/组件打印.frx index e631d637..6565826e 100644 --- a/SGGL/FineUIPro.Web/File/Fastreport/组件打印.frx +++ b/SGGL/FineUIPro.Web/File/Fastreport/组件打印.frx @@ -109,13 +109,10 @@ namespace FastReport - - - @@ -151,47 +148,28 @@ namespace FastReport - - + - - - - - + - + - - + - - - - - - - - + - - - - - - diff --git a/SGGL/FineUIPro.Web/File/Fastreport/组件打印_60x162.frx b/SGGL/FineUIPro.Web/File/Fastreport/组件打印_60x162.frx index eff815c8..e46113a7 100644 --- a/SGGL/FineUIPro.Web/File/Fastreport/组件打印_60x162.frx +++ b/SGGL/FineUIPro.Web/File/Fastreport/组件打印_60x162.frx @@ -109,13 +109,10 @@ namespace FastReport - - - @@ -150,48 +147,29 @@ namespace FastReport - - + - + - - - - - + - + - - + - - - - - - - - + - - - - - - diff --git a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.cs b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.cs index db6f5366..a0748452 100644 --- a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.cs @@ -312,11 +312,13 @@ namespace FineUIPro.Web.HJGL.NDT } foreach (var trust in trusts) { - string code = string.Empty; - Model.HJGL_Batch_PointBatch batch = BLL.PointBatchService.GetPointBatchById(trust.PointBatchId); - var pointBatch = PointBatchService.GetPointBatchById(batch.PointBatchId); - code = "DK-" + pointBatch.PointBatchCode.Substring(pointBatch.PointBatchCode.Length - 4) + "【" + string.Format("{0:yyyy-MM-dd}", pointBatch.StartDate) + "】" + "【" + UnitService.GetUnitNameByUnitId(pointBatch.UnitId) + "】"; - + string code = trust.TrustBatchCode; + Model.HJGL_Batch_PointBatch batch = null; + if (this.Type != "R") + { + batch = BLL.PointBatchService.GetPointBatchById(trust.PointBatchId); + code = "DK-" + batch.PointBatchCode.Substring(batch.PointBatchCode.Length - 4) + "【" + string.Format("{0:yyyy-MM-dd}", batch.StartDate) + "】" + "【" + UnitService.GetUnitNameByUnitId(batch.UnitId) + "】"; + } TreeNode newNode = new TreeNode(); //string code = trust.TrustBatchCode; // 未检测委托红色显示 diff --git a/SGGL/FineUIPro.Web/HJGL/PointTrust/TrustBatch.aspx.cs b/SGGL/FineUIPro.Web/HJGL/PointTrust/TrustBatch.aspx.cs index 8f844b2f..e7a5fea3 100644 --- a/SGGL/FineUIPro.Web/HJGL/PointTrust/TrustBatch.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/PointTrust/TrustBatch.aspx.cs @@ -646,13 +646,13 @@ namespace FineUIPro.Web.HJGL.PointTrust DataRow dr = dt.NewRow(); - if (this.tvControlItem.SelectedNode == null) + if (string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID)) { Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning); return; } - string reportId = this.tvControlItem.SelectedNode.NodeID; - var trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(reportId); + string reportId = this.tvControlItem.SelectedNodeID; + var trust = BLL.Batch_BatchTrustService.GetBatchTrustViewById(reportId); if (trust == null) { Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning); diff --git a/SGGL/FineUIPro.Web/HJGL/PreDesign/PrePipeline.aspx b/SGGL/FineUIPro.Web/HJGL/PreDesign/PrePipeline.aspx index 27e2552c..74863146 100644 --- a/SGGL/FineUIPro.Web/HJGL/PreDesign/PrePipeline.aspx +++ b/SGGL/FineUIPro.Web/HJGL/PreDesign/PrePipeline.aspx @@ -61,10 +61,6 @@ - - - -