diff --git a/DataBase/版本日志/SGGLDB_V2026-06-11-lpf.sql b/DataBase/版本日志/SGGLDB_V2026-06-11-lpf.sql new file mode 100644 index 00000000..4a70683b --- /dev/null +++ b/DataBase/版本日志/SGGLDB_V2026-06-11-lpf.sql @@ -0,0 +1,3 @@ +ALTER table HJGL_PipeLineMat add WeldJointId nvarchar(50); +ALTER table HJGL_PipeLineMat add MaterialCode2 nvarchar(50); +ALTER table Tw_InOutPlanDetail_Relation add WeldJointId nvarchar(50); diff --git a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs index 896701d7..e515799d 100644 --- a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs +++ b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs @@ -94,14 +94,14 @@ namespace BLL /// /// /// - public static List GetMatMatchOutput(List requiredMaterials, string warehouseCode, string projectId) + public static List GetMatMatchOutput(List requiredMaterials, string warehouseCode, string projectId, bool matchByMaterialCodeLibCode = false) { Tw_MaterialStockOutput twMaterialStockOutput = new Tw_MaterialStockOutput { WarehouseCode = warehouseCode, ProjectId = projectId }; -var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStockOutput).ToList();//获取库存列表 + var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStockOutput).ToList();//获取库存列表 // 预扣除出库申请单中状态为待审核/已审核的材料数量 using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) @@ -133,7 +133,14 @@ var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStoc foreach (var material in requiredMaterials) { material.Id = Guid.NewGuid().ToString(); - var thisMaterialStockNum = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode)?.StockNum ?? 0; + var stock = matchByMaterialCodeLibCode + ? stockList + .Where(x => x.Code == material.MaterialCode && (x.StockNum ?? 0) > 0) + .OrderByDescending(x => (x.StockNum ?? 0) >= (material.NeedNum ?? 0)) + .ThenBy(x => x.PipeLineMatCode) + .FirstOrDefault() + : stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode); + var thisMaterialStockNum = stock?.StockNum ?? 0; if (thisMaterialStockNum >= material.NeedNum) { material.MatchNum = material.NeedNum; @@ -147,8 +154,8 @@ var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStoc material.MatchRateString = Math.Round((decimal)(material.MatchRate ?? 0) * 100, 2).ToString() + "%"; } + material.MatchMaterialCode = stock?.PipeLineMatCode; //修改stockList对应的库存数量 - var stock = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode); if (stock != null) { stock.StockNum -= material.MatchNum; @@ -246,56 +253,104 @@ var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStoc /// /// /// - public static List GetPipeMatMatch(string projectId, List pipelineIds, string warehouseCode, Dictionary> priorityComponents = null) + public static List GetPipeMatMatch(string projectId, List pipelineIds, string warehouseCode, Dictionary> priorityWeldJoints = null) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var results = new List(); // 获取所需材料列表 - var requiredMaterials = (from x in db.HJGL_PipeLineMat - join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode + var pipeLineMats = (from x in db.HJGL_PipeLineMat join z in db.HJGL_Pipeline on x.PipelineId equals z.PipelineId join m in db.WBS_UnitWork on z.UnitWorkId equals m.UnitWorkId - where z.ProjectId == projectId && pipelineIds.Contains(z.PipelineId) && x.PrefabricatedComponents != "" //x.PrefabricatedComponents!="" 用于筛选非散件材料 - select new Tw_PipeMatMatchOutput - { - Id = Guid.NewGuid().ToString(), - PipelineId = x.PipelineId, - PipelineCode = z.PipelineCode, - UnitWorkId = z.UnitWorkId, - UnitWorkName = m.UnitWorkName, - PrefabricatedComponents = x.PrefabricatedComponents, - MaterialCode = x.MaterialCode, - Code = y.Code, - HeatNo = y.HeatNo, - BatchNo = y.BatchNo, - MaterialName = y.MaterialName, - MaterialSpec = y.MaterialSpec, - MaterialUnit = y.MaterialUnit, - MaterialDef = y.MaterialDef, - NeedNum = x.Number, - } - ).ToList(); + join w in db.HJGL_WeldJoint on x.WeldJointId equals w.WeldJointId into weldJoin + from w in weldJoin.DefaultIfEmpty() + where z.ProjectId == projectId && pipelineIds.Contains(z.PipelineId) && x.PrefabricatedComponents != "" //x.PrefabricatedComponents!="" 用于筛选非散件材料 + select new + { + PipeLineMat = x, + PipelineCode = z.PipelineCode, + UnitWorkId = z.UnitWorkId, + UnitWorkName = m.UnitWorkName, + WeldJointCode = w == null ? null : w.WeldJointCode + }).ToList(); + + var materialCodes = pipeLineMats + .Where(x => !string.IsNullOrEmpty(x.PipeLineMat.MaterialCode)) + .Select(x => x.PipeLineMat.MaterialCode) + .Distinct() + .ToList(); + var materialCode2s = pipeLineMats + .Where(x => !string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2)) + .Select(x => x.PipeLineMat.MaterialCode2) + .Distinct() + .ToList(); + var libByMaterialCode = db.HJGL_MaterialCodeLib + .Where(x => materialCodes.Contains(x.MaterialCode)) + .ToList() + .GroupBy(x => x.MaterialCode) + .ToDictionary(x => x.Key, x => x.First()); + var libByCode = db.HJGL_MaterialCodeLib + .Where(x => materialCode2s.Contains(x.Code)) + .ToList() + .GroupBy(x => x.Code) + .ToDictionary(x => x.Key, x => x.First()); + + var requiredMaterials = pipeLineMats.Select(x => + { + HJGL_MaterialCodeLib lib = null; + if (!string.IsNullOrEmpty(x.PipeLineMat.MaterialCode) && libByMaterialCode.ContainsKey(x.PipeLineMat.MaterialCode)) + { + lib = libByMaterialCode[x.PipeLineMat.MaterialCode]; + } + else if (!string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2) && libByCode.ContainsKey(x.PipeLineMat.MaterialCode2)) + { + lib = libByCode[x.PipeLineMat.MaterialCode2]; + } + + string code = !string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2) ? x.PipeLineMat.MaterialCode2 : lib?.Code; + return new Tw_PipeMatMatchOutput + { + Id = Guid.NewGuid().ToString(), + PipeLineMatId = x.PipeLineMat.PipeLineMatId, + PipelineId = x.PipeLineMat.PipelineId, + PipelineCode = x.PipelineCode, + UnitWorkId = x.UnitWorkId, + UnitWorkName = x.UnitWorkName, + PrefabricatedComponents = x.PipeLineMat.PrefabricatedComponents, + WeldJointId = x.PipeLineMat.WeldJointId, + WeldJointCode = x.WeldJointCode, + MaterialCode = code, + MatchMaterialCode = x.PipeLineMat.MaterialCode, + Code = code, + HeatNo = lib?.HeatNo, + BatchNo = lib?.BatchNo, + MaterialName = lib?.MaterialName, + MaterialSpec = lib?.MaterialSpec, + MaterialUnit = lib?.MaterialUnit, + MaterialDef = lib?.MaterialDef, + NeedNum = x.PipeLineMat.Number, + }; + }).ToList(); var newRequiredMaterials = new List(); foreach (string id in pipelineIds) { var pipelineMaterials = requiredMaterials.Where(x => x.PipelineId == id).ToList(); - if (priorityComponents != null && priorityComponents.ContainsKey(id) && priorityComponents[id] != null && priorityComponents[id].Any()) + if (priorityWeldJoints != null && priorityWeldJoints.ContainsKey(id) && priorityWeldJoints[id] != null && priorityWeldJoints[id].Any()) { - var components = priorityComponents[id]; + var weldJointIds = priorityWeldJoints[id]; newRequiredMaterials.AddRange(pipelineMaterials - .Where(x => components.Contains(x.PrefabricatedComponents)) - .OrderBy(x => components.IndexOf(x.PrefabricatedComponents))); + .Where(x => weldJointIds.Contains(x.WeldJointId)) + .OrderBy(x => weldJointIds.IndexOf(x.WeldJointId))); newRequiredMaterials.AddRange(pipelineMaterials - .Where(x => !components.Contains(x.PrefabricatedComponents))); + .Where(x => !weldJointIds.Contains(x.WeldJointId))); } else { newRequiredMaterials.AddRange(pipelineMaterials); } } - results = GetMatMatchOutput(newRequiredMaterials, warehouseCode, projectId); + results = GetMatMatchOutput(newRequiredMaterials, warehouseCode, projectId, true); return results; } } diff --git a/SGGL/BLL/CLGL/TwInOutplandetailRelationService.cs b/SGGL/BLL/CLGL/TwInOutplandetailRelationService.cs index ea011d04..7ce7ca5e 100644 --- a/SGGL/BLL/CLGL/TwInOutplandetailRelationService.cs +++ b/SGGL/BLL/CLGL/TwInOutplandetailRelationService.cs @@ -102,6 +102,7 @@ namespace BLL MaterialCode = newtable.MaterialCode, PrefabricatedComponents = newtable.PrefabricatedComponents, Number = newtable.Number, + WeldJointId = newtable.WeldJointId, }; Funs.DB.Tw_InOutPlanDetail_Relation.InsertOnSubmit(table); Funs.DB.SubmitChanges(); @@ -133,6 +134,7 @@ namespace BLL table.MaterialCode = newtable.MaterialCode; table.PrefabricatedComponents = newtable.PrefabricatedComponents; table.Number = newtable.Number; + table.WeldJointId = newtable.WeldJointId; Funs.DB.SubmitChanges(); } @@ -158,56 +160,6 @@ namespace BLL } } - public static void InsertByPipeLineMat(string inOutPlanMasterId, List tw_PipeLineMats) - { - var master = TwInOutplanmasterService.GetById(inOutPlanMasterId); - if (master == null) - { - return; - } - var outMateriaList = from x in tw_PipeLineMats - group x by new { x.MaterialCode, x.MaterialUnit } - into g - select new - { - g.Key.MaterialCode, - planNum = g.Sum(x => x.Number) ?? 0, - MaterialName = g.Key.MaterialUnit, - }; - - switch (master.Category) - { - case (int)TwConst.Category.管段: - outMateriaList.Where(x => x.MaterialName.Contains("米"));//管段 - break; - case (int)TwConst.Category.管件: - outMateriaList.Where(x => x.MaterialName.Contains("个"));//管件 - break; - } - - foreach (var item in outMateriaList) - { - Model.Tw_InOutPlanDetail detail = new Model.Tw_InOutPlanDetail - { - Id = Guid.NewGuid().ToString(), - InOutPlanMasterId = inOutPlanMasterId, - MaterialCode = item.MaterialCode, - PlanNum = item.planNum, - }; - TwInOutplandetailService.Add(detail); - } - var twinoutplandetailRelationList = tw_PipeLineMats.Select(x => new Tw_InOutPlanDetail_Relation - { - PipelineId = x.PipelineId, - MaterialCode = x.MaterialCode, - Number = x.Number, - PrefabricatedComponents = x.PrefabricatedComponents, - }).ToList(); - TwInoutplandetailRelationService.AddList(twinoutplandetailRelationList, inOutPlanMasterId); - - } - - public static IEnumerable GetPrintListByOutputMasterIds(List outputMasterIds) { var q = from x in Funs.DB.Tw_InOutPlanDetail_Relation diff --git a/SGGL/BLL/CLGL/TwInOutplanmasterService.cs b/SGGL/BLL/CLGL/TwInOutplanmasterService.cs index 052dd234..539252f2 100644 --- a/SGGL/BLL/CLGL/TwInOutplanmasterService.cs +++ b/SGGL/BLL/CLGL/TwInOutplanmasterService.cs @@ -992,36 +992,22 @@ namespace BLL .Select(e => e.WeldJointId) .Distinct() .ToList(); - var taskComponents = (from relation in db.HJGL_Pipeline_ComponentJoint - join component in db.HJGL_Pipeline_Component on relation.PipelineComponentId equals component.PipelineComponentId into componentJoin - from componentItem in componentJoin.DefaultIfEmpty() - join weldJointItem in db.HJGL_WeldJoint on relation.WeldJointId equals weldJointItem.WeldJointId - where taskWeldJointIds.Contains(relation.WeldJointId) - && weldJointItem.PipelineId != null - && (relation.PipelineComponentCode != null || (componentItem != null && componentItem.PipelineComponentCode != null)) - select new - { - PipelineId = weldJointItem.PipelineId, - PipelineComponentCode = componentItem != null && componentItem.PipelineComponentCode != null ? componentItem.PipelineComponentCode : relation.PipelineComponentCode - }).Distinct().ToList(); //领料出库需要排除散件材料 var allMaterDatial = (from x in db.HJGL_PipeLineMat join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode - where pipelineList.Contains(x.PipelineId) && x.PrefabricatedComponents != null + where pipelineList.Contains(x.PipelineId) + && taskWeldJointIds.Contains(x.WeldJointId) + && x.PrefabricatedComponents != null select new { x.PipelineId, x.PrefabricatedComponents, + x.WeldJointId, x.MaterialCode, x.Number, y.MaterialUnit, }).ToList(); - var componentPipelineIds = taskComponents.Select(x => x.PipelineId).Distinct().ToList(); - var MaterDatial = taskComponents.Any() - ? allMaterDatial.Where(mat => !componentPipelineIds.Contains(mat.PipelineId) - || taskComponents.Any(component => component.PipelineId == mat.PipelineId - && component.PipelineComponentCode == mat.PrefabricatedComponents)).ToList() - : allMaterDatial; + var MaterDatial = allMaterDatial; //var outMateriaList = from x in db.HJGL_PipeLineMat // join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode // where pipelineList.Contains(x.PipelineId) @@ -1077,12 +1063,13 @@ namespace BLL }; TwInOutplandetailService.Add(detail); } - var twinoutplandetailRelationList = MaterDatial.Select(x => new Tw_InOutPlanDetail_Relation + var twinoutplandetailRelationList = MaterDatial.Where(x => x.MaterialUnit.Contains("个")).Select(x => new Tw_InOutPlanDetail_Relation { PipelineId = x.PipelineId, MaterialCode = x.MaterialCode, Number = x.Number, PrefabricatedComponents = x.PrefabricatedComponents, + WeldJointId = x.WeldJointId, }).ToList(); TwInoutplandetailRelationService.AddList(twinoutplandetailRelationList, table.Id); } @@ -1116,12 +1103,13 @@ namespace BLL }; TwInOutplandetailService.Add(detail); } - var twinoutplandetailRelationList = MaterDatial.Select(x => new Tw_InOutPlanDetail_Relation + var twinoutplandetailRelationList = MaterDatial.Where(x => x.MaterialUnit.Contains("米")).Select(x => new Tw_InOutPlanDetail_Relation { PipelineId = x.PipelineId, MaterialCode = x.MaterialCode, Number = x.Number, PrefabricatedComponents = x.PrefabricatedComponents, + WeldJointId = x.WeldJointId, }).ToList(); TwInoutplandetailRelationService.AddList(twinoutplandetailRelationList, table.Id); } diff --git a/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs b/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs index 5a1b7b27..07b2b998 100644 --- a/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs +++ b/SGGL/BLL/HJGL/WeldingManage/PipelineMatService.cs @@ -31,6 +31,8 @@ namespace BLL { PipeLineMatId = pipelineMat.PipeLineMatId, MaterialCode = pipelineMat.MaterialCode, + MaterialCode2 = pipelineMat.MaterialCode2, + WeldJointId = pipelineMat.WeldJointId, PipelineId = pipelineMat.PipelineId, Number = pipelineMat.Number, PrefabricatedComponents = pipelineMat.PrefabricatedComponents, @@ -50,12 +52,48 @@ namespace BLL if (newPipelineMat != null) { newPipelineMat.MaterialCode = pipelineMat.MaterialCode; + newPipelineMat.MaterialCode2 = pipelineMat.MaterialCode2; + newPipelineMat.WeldJointId = pipelineMat.WeldJointId; newPipelineMat.PipelineId = pipelineMat.PipelineId; newPipelineMat.Number = pipelineMat.Number; newPipelineMat.PrefabricatedComponents = pipelineMat.PrefabricatedComponents; db.SubmitChanges(); } } + + /// + /// 根据材料匹配结果反写材料主编码 + /// + /// 匹配成功的管线材料 + /// 反写数量 + public static int UpdateMaterialCodeByMatchOutputs(IEnumerable matchedMaterials) + { + Model.SGGLDB db = Funs.DB; + int count = 0; + foreach (var item in matchedMaterials) + { + if (item == null || string.IsNullOrEmpty(item.PipeLineMatId) || string.IsNullOrEmpty(item.MatchMaterialCode)) + { + continue; + } + + var pipeLineMat = db.HJGL_PipeLineMat.FirstOrDefault(e => e.PipeLineMatId == item.PipeLineMatId); + if (pipeLineMat == null) + { + continue; + } + + pipeLineMat.MaterialCode = item.MatchMaterialCode; + count++; + } + + if (count > 0) + { + db.SubmitChanges(); + } + + return count; + } /// /// 根据unitworkid删除焊口 /// diff --git a/SGGL/FineUIPro.Web/File/Excel/DataIn/PipelineMat.xlsx b/SGGL/FineUIPro.Web/File/Excel/DataIn/PipelineMat.xlsx index d21e1b9b..f5949321 100644 Binary files a/SGGL/FineUIPro.Web/File/Excel/DataIn/PipelineMat.xlsx and b/SGGL/FineUIPro.Web/File/Excel/DataIn/PipelineMat.xlsx differ diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index 3a383262..f41730d4 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -17208,4 +17208,4 @@ --> - + \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx index ff4b0ce8..46d743df 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx @@ -119,6 +119,10 @@ FieldType="String" HeaderText="预制组件" HeaderTextAlign="Center" TextAlign="Left"> + + @@ -178,6 +182,10 @@ + + @@ -235,6 +243,10 @@ + + diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs index 36f6deb8..c4889bdc 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs @@ -195,7 +195,7 @@ namespace FineUIPro.Web.HJGL.DataImport return (from x in Funs.DB.HJGL_Pipeline join y in Funs.DB.PTP_PipelineList on x.PipelineId equals y.PipelineId join z in Funs.DB.PTP_TestPackage on y.PTP_ID equals z.PTP_ID - join m in Funs.DB.HJGL_PipeLineMat.Where(e => e.MaterialCode.Contains(txtMaterialCode.Text.Trim())) + join m in Funs.DB.HJGL_PipeLineMat.Where(e => (e.MaterialCode != null && e.MaterialCode.Contains(txtMaterialCode.Text.Trim())) || (e.MaterialCode2 != null && e.MaterialCode2.Contains(txtMaterialCode.Text.Trim()))) on x.PipelineId equals m.PipelineId into temp from m in temp.DefaultIfEmpty() where x.ProjectId == this.CurrUser.LoginProjectId @@ -241,7 +241,7 @@ namespace FineUIPro.Web.HJGL.DataImport { return (from x in Funs.DB.HJGL_Pipeline join y in Funs.DB.PTP_PipelineList on x.PipelineId equals y.PipelineId - join m in Funs.DB.HJGL_PipeLineMat.Where(e => e.MaterialCode.Contains(txtMaterialCode.Text.Trim())) + join m in Funs.DB.HJGL_PipeLineMat.Where(e => (e.MaterialCode != null && e.MaterialCode.Contains(txtMaterialCode.Text.Trim())) || (e.MaterialCode2 != null && e.MaterialCode2.Contains(txtMaterialCode.Text.Trim()))) on x.PipelineId equals m.PipelineId into temp from m in temp.DefaultIfEmpty() where y.PTP_ID == ptpId @@ -320,11 +320,18 @@ namespace FineUIPro.Web.HJGL.DataImport /// private void BindGrid1(string pipelineId, string unitworkid) { - string strSql = @" SELECT pipe.PipeLineMatId, lib.MaterialCode,lib.Code,lib.HeatNo,lib.BatchNo,lib.MaterialName,lib.MaterialUnit, - lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef,pipe.Number,pipe.PrefabricatedComponents + string strSql = @" SELECT pipe.PipeLineMatId, pipe.MaterialCode,ISNULL(pipe.MaterialCode2, lib.Code) AS Code,lib.HeatNo,lib.BatchNo, + ISNULL(lib.MaterialName, libCode.MaterialName) AS MaterialName, + ISNULL(lib.MaterialUnit, libCode.MaterialUnit) AS MaterialUnit, + ISNULL(lib.MaterialSpec, libCode.MaterialSpec) AS MaterialSpec, + ISNULL(lib.MaterialMade, libCode.MaterialMade) AS MaterialMade, + ISNULL(lib.MaterialDef, libCode.MaterialDef) AS MaterialDef, + pipe.Number,pipe.PrefabricatedComponents,weld.WeldJointCode FROM dbo.HJGL_PipeLineMat pipe LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode LEFT JOIN HJGL_Pipeline line ON pipe.PipelineId=line.PipelineId + OUTER APPLY (SELECT TOP 1 * FROM dbo.HJGL_MaterialCodeLib codeLib WHERE codeLib.ProjectId=line.ProjectId AND codeLib.Code=pipe.MaterialCode2 ORDER BY codeLib.MaterialCode) libCode + LEFT JOIN dbo.HJGL_WeldJoint weld ON weld.WeldJointId = pipe.WeldJointId WHERE line.UnitWorkId=@UnitWorkId and line.PipeArea='1' and pipe.PrefabricatedComponents !='' "; List listStr = new List(); //if (!string.IsNullOrEmpty(txtMaterialCode.Text.Trim())) @@ -340,7 +347,7 @@ namespace FineUIPro.Web.HJGL.DataImport } if (!string.IsNullOrEmpty(txtMaterialCode2.Text.Trim())) { - strSql += " and lib.MaterialCode like @MaterialCode "; + strSql += " and (pipe.MaterialCode2 like @MaterialCode or lib.MaterialCode like @MaterialCode or lib.Code like @MaterialCode) "; listStr.Add(new SqlParameter("@MaterialCode", "%" + txtMaterialCode2.Text.Trim() + "%")); } @@ -355,11 +362,18 @@ namespace FineUIPro.Web.HJGL.DataImport } private void BindGrid2(string pipelineId, string unitworkid) { - string strSql = @" SELECT pipe.PipeLineMatId, lib.MaterialCode,lib.Code,lib.HeatNo,lib.BatchNo,lib.MaterialName,lib.MaterialUnit, - lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef,pipe.Number + string strSql = @" SELECT pipe.PipeLineMatId, pipe.MaterialCode,ISNULL(pipe.MaterialCode2, lib.Code) AS Code,lib.HeatNo,lib.BatchNo, + ISNULL(lib.MaterialName, libCode.MaterialName) AS MaterialName, + ISNULL(lib.MaterialUnit, libCode.MaterialUnit) AS MaterialUnit, + ISNULL(lib.MaterialSpec, libCode.MaterialSpec) AS MaterialSpec, + ISNULL(lib.MaterialMade, libCode.MaterialMade) AS MaterialMade, + ISNULL(lib.MaterialDef, libCode.MaterialDef) AS MaterialDef, + pipe.Number,weld.WeldJointCode FROM dbo.HJGL_PipeLineMat pipe LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode LEFT JOIN HJGL_Pipeline line ON pipe.PipelineId=line.PipelineId + OUTER APPLY (SELECT TOP 1 * FROM dbo.HJGL_MaterialCodeLib codeLib WHERE codeLib.ProjectId=line.ProjectId AND codeLib.Code=pipe.MaterialCode2 ORDER BY codeLib.MaterialCode) libCode + LEFT JOIN dbo.HJGL_WeldJoint weld ON weld.WeldJointId = pipe.WeldJointId WHERE line.UnitWorkId=@UnitWorkId and line.PipeArea='2' "; List listStr = new List(); if (!string.IsNullOrEmpty(pipelineId)) @@ -370,7 +384,7 @@ namespace FineUIPro.Web.HJGL.DataImport } if (!string.IsNullOrEmpty(txtMaterialCode2.Text.Trim())) { - strSql += " and lib.MaterialCode like @MaterialCode "; + strSql += " and (pipe.MaterialCode2 like @MaterialCode or lib.MaterialCode like @MaterialCode or lib.Code like @MaterialCode) "; listStr.Add(new SqlParameter("@MaterialCode", "%" + txtMaterialCode2.Text.Trim() + "%")); } @@ -386,11 +400,18 @@ namespace FineUIPro.Web.HJGL.DataImport private void BindGrid3(string pipelineId, string unitworkid) { - string strSql = @" SELECT pipe.PipeLineMatId, lib.MaterialCode,lib.Code,lib.HeatNo,lib.BatchNo,lib.MaterialName,lib.MaterialUnit, - lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef,pipe.Number,pipe.PrefabricatedComponents + string strSql = @" SELECT pipe.PipeLineMatId, pipe.MaterialCode,ISNULL(pipe.MaterialCode2, lib.Code) AS Code,lib.HeatNo,lib.BatchNo, + ISNULL(lib.MaterialName, libCode.MaterialName) AS MaterialName, + ISNULL(lib.MaterialUnit, libCode.MaterialUnit) AS MaterialUnit, + ISNULL(lib.MaterialSpec, libCode.MaterialSpec) AS MaterialSpec, + ISNULL(lib.MaterialMade, libCode.MaterialMade) AS MaterialMade, + ISNULL(lib.MaterialDef, libCode.MaterialDef) AS MaterialDef, + pipe.Number,pipe.PrefabricatedComponents,weld.WeldJointCode FROM dbo.HJGL_PipeLineMat pipe LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode LEFT JOIN HJGL_Pipeline line ON pipe.PipelineId=line.PipelineId + OUTER APPLY (SELECT TOP 1 * FROM dbo.HJGL_MaterialCodeLib codeLib WHERE codeLib.ProjectId=line.ProjectId AND codeLib.Code=pipe.MaterialCode2 ORDER BY codeLib.MaterialCode) libCode + LEFT JOIN dbo.HJGL_WeldJoint weld ON weld.WeldJointId = pipe.WeldJointId WHERE line.UnitWorkId=@UnitWorkId and line.PipeArea='1' and (pipe.PrefabricatedComponents is null or pipe.PrefabricatedComponents='') "; List listStr = new List(); //if (!string.IsNullOrEmpty(txtMaterialCode.Text.Trim())) @@ -406,7 +427,7 @@ namespace FineUIPro.Web.HJGL.DataImport } if (!string.IsNullOrEmpty(txtMaterialCode2.Text.Trim())) { - strSql += " and lib.MaterialCode like @MaterialCode "; + strSql += " and (pipe.MaterialCode2 like @MaterialCode or lib.MaterialCode like @MaterialCode or lib.Code like @MaterialCode) "; listStr.Add(new SqlParameter("@MaterialCode", "%" + txtMaterialCode2.Text.Trim() + "%")); } diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs index 719ec24c..34e12ba8 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs @@ -138,7 +138,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage Model.ResponeData responeData = new Model.ResponeData(); List result = new List(); - if (count < 6) + if (count < 5) { responeData.code = 0; responeData.message = "导入Excel格式错误!Excel只有" + count.ToString().Trim() + "列"; @@ -182,43 +182,48 @@ namespace FineUIPro.Web.HJGL.WeldingManage if (pds[i].C != null && !string.IsNullOrEmpty(pds[i].C.ToString())) { - string materialCode = pds[i].C.ToString().Trim(); - string furnaceNo = pds[i].D == null ? string.Empty : pds[i].D.ToString().Trim(); - string batchNo = pds[i].E == null ? string.Empty : pds[i].E.ToString().Trim(); - if (pds[i].D == null || string.IsNullOrEmpty(pds[i].D.ToString())) + if (!string.IsNullOrEmpty(item.PipelineId)) { - result.Add((i + 2) + "Line, [炉号] 不能为空
"); - } - if (pds[i].E == null || string.IsNullOrEmpty(pds[i].E.ToString())) - { - result.Add((i + 2) + "Line, [批号] 不能为空
"); - } - if (!string.IsNullOrEmpty(materialCode) && !string.IsNullOrEmpty(furnaceNo) && !string.IsNullOrEmpty(batchNo)) - { - string fullMaterialCode = materialCode + "-" + furnaceNo + "-" + batchNo; - var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.MaterialCode == fullMaterialCode select x; - if (lib.Count() > 0) + string weldJointCode = pds[i].C.ToString().Trim(); + var weldJoint = BLL.WeldJointService.GetWeldJointsByWeldJointCode(item.PipelineId, weldJointCode); + if (weldJoint != null) { - item.MaterialCode = fullMaterialCode; + item.WeldJointId = weldJoint.WeldJointId; } else { - result.Add("不存在此材料:" + fullMaterialCode); - + result.Add("第" + (i + 2).ToString() + "行,当前管线不存在此焊口号-" + weldJointCode + "
"); } } + } + else + { + result.Add((i + 2) + "Line, [焊口号] 不能为空
"); + } + if (pds[i].D != null && !string.IsNullOrEmpty(pds[i].D.ToString())) + { + string materialCode = pds[i].D.ToString().Trim(); + var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.Code == materialCode select x; + if (lib.Count() > 0) + { + item.MaterialCode2 = materialCode; + } + else + { + result.Add("第" + (i + 2).ToString() + "行,材料编码库不存在此材料编码-" + materialCode + "
"); + } } else { result.Add((i + 2) + "Line, [材料编码] 不能为空
"); } - if (pds[i].F != null && !string.IsNullOrEmpty(pds[i].F.ToString())) + if (pds[i].E != null && !string.IsNullOrEmpty(pds[i].E.ToString())) { try { - var number = Funs.GetNewDecimal(pds[i].F.ToString()); + var number = Funs.GetNewDecimal(pds[i].E.ToString()); item.Number = number; } catch (Exception) @@ -247,7 +252,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage // result.Add((i + 2) + "Line, [预制组件] 不能为空
"); } } - var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode == item.MaterialCode && x.PrefabricatedComponents == item.PrefabricatedComponents); + var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode2 == item.MaterialCode2 && x.WeldJointId == item.WeldJointId && x.PrefabricatedComponents == item.PrefabricatedComponents); if (model.Count() == 0) { matList.Add(item); @@ -478,7 +483,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage { foreach (var item in matList) { - var pipeLineMat = from x in Funs.DB.HJGL_PipeLineMat where x.MaterialCode == item.MaterialCode && x.PipelineId == item.PipelineId && x.PrefabricatedComponents == item.PrefabricatedComponents select x; + var pipeLineMat = from x in Funs.DB.HJGL_PipeLineMat + where x.MaterialCode2 == item.MaterialCode2 + && x.WeldJointId == item.WeldJointId + && x.PipelineId == item.PipelineId + && x.PrefabricatedComponents == item.PrefabricatedComponents + select x; if (pipeLineMat.Count() == 0 || pipeLineMat == null) { item.PipeLineMatId = SQLHelper.GetNewID(typeof(Model.HJGL_PipeLineMat)); @@ -486,7 +496,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage } else { - item.PipeLineMatId = pipeLineMat.First().PipeLineMatId; + var oldPipeLineMat = pipeLineMat.First(); + item.PipeLineMatId = oldPipeLineMat.PipeLineMatId; + if (string.IsNullOrEmpty(item.MaterialCode)) + { + item.MaterialCode = oldPipeLineMat.MaterialCode; + } BLL.PipelineMatService.UpdatePipeLineMat(item); } BLL.HJGL_PipelineComponentService.SyncPipelineComponentByMatId(item.PipeLineMatId); diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx index e49f353f..edfe3aae 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx @@ -27,16 +27,19 @@ } .f-grid-row.red { - background-color: red; + color: red; + font-weight: bold; } .f-grid-row.green { - background-color: green; + color: green; + font-weight: bold; } .f-grid-row.priority { - background-color: #1e88e5; + /* background-color: #1e88e5;*/ color: #fff; + font-weight: bold; } .f-grid-row { @@ -143,10 +146,12 @@ - - + + - + + + @@ -181,7 +186,7 @@ @@ -193,10 +198,18 @@ FieldType="String" HeaderText="预制组件号" HeaderTextAlign="Center" TextAlign="Left">
+ + + + diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs index 884a1bb0..b188911d 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs @@ -70,21 +70,21 @@ namespace FineUIPro.Web.HJGL.WeldingManage } } - public Dictionary> priorityComponents + public Dictionary> priorityWeldJoints { get { - var value = ViewState["priorityComponents"] as Dictionary>; + var value = ViewState["priorityWeldJoints"] as Dictionary>; if (value == null) { value = new Dictionary>(); - ViewState["priorityComponents"] = value; + ViewState["priorityWeldJoints"] = value; } return value; } set { - ViewState["priorityComponents"] = value; + ViewState["priorityWeldJoints"] = value; } } @@ -104,7 +104,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage ; HJGL_MaterialService.materialStockItems_FIELD = new List(); HJGL_MaterialService.materialStockItems_SHOP = new List(); dicSeclectPipeLine = new Dictionary(); - priorityComponents = new Dictionary>(); + priorityWeldJoints = new Dictionary>(); var pipeline = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId select x.FlowingSection).Distinct().ToList(); @@ -377,14 +377,25 @@ namespace FineUIPro.Web.HJGL.WeldingManage #region 数据绑定 private void BindGrid() { - string strSql = @"SELECT lib.MaterialCode,lib.MaterialName,lib.MaterialUnit, - lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef,sum(pipe.Number)as Number , + string strSql = @"SELECT ISNULL(pipe.MaterialCode2, lib.Code) AS MaterialCode, + ISNULL(lib.MaterialName, libCode.MaterialName) AS MaterialName, + ISNULL(lib.MaterialUnit, libCode.MaterialUnit) AS MaterialUnit, + ISNULL(lib.MaterialSpec, libCode.MaterialSpec) AS MaterialSpec, + ISNULL(lib.MaterialMade, libCode.MaterialMade) AS MaterialMade, + ISNULL(lib.MaterialDef, libCode.MaterialDef) AS MaterialDef, + sum(pipe.Number)as Number , '0' as MatchNum,'否' AS CheckState FROM dbo.HJGL_PipeLineMat pipe LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode + LEFT JOIN dbo.HJGL_Pipeline line ON line.PipelineId = pipe.PipelineId + OUTER APPLY (SELECT TOP 1 * FROM dbo.HJGL_MaterialCodeLib codeLib WHERE codeLib.ProjectId=line.ProjectId AND codeLib.Code=pipe.MaterialCode2 ORDER BY codeLib.MaterialCode) libCode WHERE PipelineId=@PipelineId - group by lib.MaterialCode,lib.MaterialName,lib.MaterialUnit, - lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef "; + group by ISNULL(pipe.MaterialCode2, lib.Code), + ISNULL(lib.MaterialName, libCode.MaterialName), + ISNULL(lib.MaterialUnit, libCode.MaterialUnit), + ISNULL(lib.MaterialSpec, libCode.MaterialSpec), + ISNULL(lib.MaterialMade, libCode.MaterialMade), + ISNULL(lib.MaterialDef, libCode.MaterialDef) "; List listStr = new List(); listStr.Add(new SqlParameter("@PipelineId", this.tvControlItem.SelectedNodeID)); SqlParameter[] parameter = listStr.ToArray(); @@ -394,7 +405,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage Grid1.DataSource = dt; Grid1.DataBind(); } - void BindGrid2() + void BindGrid2(IEnumerable keepSelectedPipelineIds = null) { //var result = tw_PipeMatMatchOutputs // .GroupBy(item => new { item.PipelineId, item.PipelineCode,item.UnitWorkName }) // 按 PipelineId 和 PipelineCode 分组 @@ -424,6 +435,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage Rate = Math.Round((decimal)output.Average(item => item.MatchRate) * 100, 2); lbRate.Text = "匹配率:" + Rate.ToString() + "%"; }*/ + var keepSelectedList = keepSelectedPipelineIds == null ? new List() : keepSelectedPipelineIds.Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList(); var selectList = new List(); for (int i = 0; i < Grid2.Rows.Count; i++) { @@ -443,7 +455,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage } if (cbSelectCom.Checked) { - Grid2.SelectedRowIDArray = selectList.ToArray(); + selectList.AddRange(keepSelectedList); + Grid2.SelectedRowIDArray = selectList.Distinct().ToArray(); + } + else if (keepSelectedList.Any()) + { + Grid2.SelectedRowIDArray = keepSelectedList.ToArray(); } } @@ -486,7 +503,9 @@ namespace FineUIPro.Web.HJGL.WeldingManage private void BindMaterialDetail(string pipelineId) { - var tb = tw_PipeMatMatchOutputs.Where(x => x.PipelineId == pipelineId).ToList(); + var tb = GetNoTaskMaterialDetails() + .Where(x => x.PipelineId == pipelineId) + .ToList(); Grid1.DataSource = tb; Grid1.DataBind(); @@ -499,7 +518,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage continue; } - if (IsPriorityComponent(model.PipelineId, model.PrefabricatedComponents)) + if (IsPriorityWeldJoint(model.PipelineId, model.WeldJointId)) { Grid1.Rows[i].RowCssClass = "priority"; selectList.Add(model.Id); @@ -513,30 +532,54 @@ namespace FineUIPro.Web.HJGL.WeldingManage Grid1.SelectedRowIDArray = selectList.ToArray(); } - private bool IsPriorityComponent(string pipelineId, string prefabricatedComponents) + private List GetNoTaskMaterialDetails() { - return !string.IsNullOrEmpty(pipelineId) - && !string.IsNullOrEmpty(prefabricatedComponents) - && priorityComponents.ContainsKey(pipelineId) - && priorityComponents[pipelineId].Contains(prefabricatedComponents); + var matchOutputs = tw_PipeMatMatchOutputs ?? new List(); + var weldJointIds = matchOutputs + .Where(x => !string.IsNullOrEmpty(x.WeldJointId)) + .Select(x => x.WeldJointId) + .Distinct() + .ToList(); + if (!weldJointIds.Any()) + { + return matchOutputs; + } + + var taskWeldJointIds = Funs.DB.HJGL_WeldTask + .Where(x => weldJointIds.Contains(x.WeldJointId)) + .Select(x => x.WeldJointId) + .Distinct() + .ToList(); + return matchOutputs + .Where(x => string.IsNullOrEmpty(x.WeldJointId) || !taskWeldJointIds.Contains(x.WeldJointId)) + .ToList(); } - private Dictionary> GetPriorityComponentList() + private bool IsPriorityWeldJoint(string pipelineId, string weldJointId) { - return priorityComponents + return !string.IsNullOrEmpty(pipelineId) + && !string.IsNullOrEmpty(weldJointId) + && priorityWeldJoints.ContainsKey(pipelineId) + && priorityWeldJoints[pipelineId].Contains(weldJointId); + } + + private Dictionary> GetPriorityWeldJointList() + { + return priorityWeldJoints .Where(x => x.Value != null && x.Value.Any()) .ToDictionary(x => x.Key, x => x.Value.ToList()); } private void RefreshMatchResult() { + var keepSelectedPipelineIds = Grid2.SelectedRowIDArray == null ? new List() : Grid2.SelectedRowIDArray.ToList(); tw_PipeMatMatchOutputs = TwArrivalStatisticsService.GetPipeMatMatch( this.CurrUser.LoginProjectId, dicSeclectPipeLine.Keys.ToList(), drpWarehouse.SelectedValue, - GetPriorityComponentList()); + GetPriorityWeldJointList()); BindGrid3(); - BindGrid2(); + BindGrid2(keepSelectedPipelineIds); } protected void Grid2_RowClick(object sender, GridRowClickEventArgs e) @@ -692,7 +735,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage foreach (string rowId in Grid3.SelectedRowIDArray) { dicSeclectPipeLine.Remove(rowId); - priorityComponents.Remove(rowId); + priorityWeldJoints.Remove(rowId); var node = tvControlItem.FindNode(rowId); if (node != null) { @@ -713,38 +756,85 @@ namespace FineUIPro.Web.HJGL.WeldingManage return; } - var selectedComponents = new HashSet(); + var selectedWeldJoints = new HashSet(); foreach (int rowIndex in Grid1.SelectedRowIndexArray) { - if (Grid1.DataKeys[rowIndex].Length < 3) + if (Grid1.DataKeys[rowIndex].Length < 4) { continue; } string pipelineId = Grid1.DataKeys[rowIndex][1]?.ToString(); - string componentCode = Grid1.DataKeys[rowIndex][2]?.ToString(); - if (pipelineId == selectedPipelineId && !string.IsNullOrEmpty(componentCode)) + string weldJointId = Grid1.DataKeys[rowIndex][3]?.ToString(); + if (pipelineId == selectedPipelineId && !string.IsNullOrEmpty(weldJointId)) { - selectedComponents.Add(componentCode); + selectedWeldJoints.Add(weldJointId); } } - if (selectedComponents.Any()) + if (selectedWeldJoints.Any()) { - priorityComponents[selectedPipelineId] = selectedComponents; + priorityWeldJoints[selectedPipelineId] = selectedWeldJoints; } else { - priorityComponents.Remove(selectedPipelineId); + priorityWeldJoints.Remove(selectedPipelineId); } + var keepSelectedPipelineIds = Grid2.SelectedRowIDArray == null ? new List() : Grid2.SelectedRowIDArray.ToList(); + if (!keepSelectedPipelineIds.Contains(selectedPipelineId)) + { + keepSelectedPipelineIds.Add(selectedPipelineId); + } RefreshMatchResult(); + Grid2.SelectedRowIDArray = keepSelectedPipelineIds.Distinct().ToArray(); BindMaterialDetail(selectedPipelineId); } + protected void btnConfirmMaterialCode_Click(object sender, EventArgs e) + { + if (Grid2.SelectedRowIDArray == null || !Grid2.SelectedRowIDArray.Any()) + { + ShowNotify("请先选择需要保存匹配结果的管线!", MessageBoxIcon.Warning); + return; + } + + if (tw_PipeMatMatchOutputs == null || !tw_PipeMatMatchOutputs.Any()) + { + RefreshMatchResult(); + } + + var selectedPipelineIds = Grid2.SelectedRowIDArray.ToList(); + var matchedMaterials = tw_PipeMatMatchOutputs + .Where(x => selectedPipelineIds.Contains(x.PipelineId)) + .ToList(); + if (!matchedMaterials.Any()) + { + ShowNotify("未找到保存的材料匹配明细!", MessageBoxIcon.Warning); + return; + } + + var invalidMaterials = matchedMaterials + .Where(x => string.IsNullOrEmpty(x.MatchMaterialCode) || (x.MatchRate ?? 0) < 1) + .ToList(); + /* if (invalidMaterials.Any()) + { + ShowNotify("存在未100%匹配的材料,不能反写材料主编码!", MessageBoxIcon.Warning); + return; + }*/ + + int count = BLL.PipelineMatService.UpdateMaterialCodeByMatchOutputs(matchedMaterials); + ShowNotify("已保存材料主编码" + count.ToString() + "条!", MessageBoxIcon.Success); + RefreshMatchResult(); + if (Grid2.SelectedRowIDArray.Any()) + { + BindMaterialDetail(Grid2.SelectedRowIDArray.First()); + } + } + protected void btnGenTask_Click(object sender, EventArgs e) { - if (Grid2.SelectedRowIDArray.Count() > 0) + if (GetSelectedWeldJointIdsFromGrid1().Any()) { if (SaveTask()) { @@ -760,23 +850,30 @@ namespace FineUIPro.Web.HJGL.WeldingManage } else { - ShowNotify("请先选择需要发起任单的管线!", MessageBoxIcon.Warning); + ShowNotify("请先在材料匹配明细中选择需要生成任务单的焊口!", MessageBoxIcon.Warning); } } private bool SaveTask() { + var selectedWeldJointIds = GetSelectedWeldJointIdsFromGrid1(); + if (!selectedWeldJointIds.Any()) + { + ShowNotify("请先在材料匹配明细中选择需要生成任务单的焊口!", MessageBoxIcon.Warning); + return false; + } var weldingRods = from x in Funs.DB.Base_Consumables where x.ConsumablesType == "2" select x; var weldingWires = from x in Funs.DB.Base_Consumables where x.ConsumablesType == "1" select x; + var selectedWeldJointIdList = selectedWeldJointIds.ToList(); var selectRowId = (from x in Funs.DB.View_HJGL_NoWeldJointFind - where Grid2.SelectedRowIDArray.ToList().Contains(x.PipelineId) && x.WeldingDailyId == null && + where selectedWeldJointIdList.Contains(x.WeldJointId) && x.WeldingDailyId == null && x.WeldTaskId == null && x.WeldingMethodCode != null select x).ToList(); Dictionary unitworkTaskCode = new Dictionary(); Dictionary unitworkSerialNumber = new Dictionary(); Dictionary matchPipeline = new Dictionary(); - foreach (var rowIndex in Grid2.SelectedRowIndexArray) + for (int rowIndex = 0; rowIndex < Grid2.Rows.Count; rowIndex++) { matchPipeline.Add(rowIndex + 1, Grid2.Rows[rowIndex].RowID); } @@ -784,16 +881,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage { selectRowId = selectRowId.Where(x => x.JointAttribute == "预制口").ToList(); } - var priorityWeldJointIds = GetPriorityWeldJointIds(Grid2.SelectedRowIDArray.ToList()); - if (priorityWeldJointIds.Any()) - { - if (priorityWeldJointIds.Any(x => !x.Value.Any())) - { - ShowNotify("选中组件未找到关联焊口,无法按组件生成任务单!", MessageBoxIcon.Warning); - return false; - } - selectRowId = selectRowId.Where(x => !priorityWeldJointIds.ContainsKey(x.PipelineId) || priorityWeldJointIds[x.PipelineId].Contains(x.WeldJointId)).ToList(); - } if (!selectRowId.Any()) { ShowNotify("未找到可生成任务单的焊口!", MessageBoxIcon.Warning); @@ -909,28 +996,41 @@ namespace FineUIPro.Web.HJGL.WeldingManage return true; } + private HashSet GetSelectedWeldJointIdsFromGrid1() + { + var selectedWeldJointIds = new HashSet(); + if (Grid1.SelectedRowIndexArray == null) + { + return selectedWeldJointIds; + } + + foreach (int rowIndex in Grid1.SelectedRowIndexArray) + { + if (Grid1.DataKeys[rowIndex].Length < 4) + { + continue; + } + + string weldJointId = Grid1.DataKeys[rowIndex][3]?.ToString(); + if (!string.IsNullOrEmpty(weldJointId)) + { + selectedWeldJointIds.Add(weldJointId); + } + } + + return selectedWeldJointIds; + } + private Dictionary> GetPriorityWeldJointIds(List selectedPipelineIds) { var result = new Dictionary>(); - var selectedPriority = priorityComponents + var selectedPriority = priorityWeldJoints .Where(x => selectedPipelineIds.Contains(x.Key) && x.Value != null && x.Value.Any()) .ToList(); foreach (var item in selectedPriority) { - string pipelineId = item.Key; - var componentCodes = item.Value.ToList(); - var weldJointIds = (from joint in Funs.DB.HJGL_Pipeline_ComponentJoint - join weldJoint in Funs.DB.HJGL_WeldJoint on joint.WeldJointId equals weldJoint.WeldJointId - join component in Funs.DB.HJGL_Pipeline_Component on joint.PipelineComponentId equals component.PipelineComponentId into componentJoin - from componentItem in componentJoin.DefaultIfEmpty() - where joint.WeldJointId != null - && weldJoint.PipelineId == pipelineId - && ((componentItem != null && componentCodes.Contains(componentItem.PipelineComponentCode)) - || componentCodes.Contains(joint.PipelineComponentCode)) - select joint.WeldJointId).Distinct().ToList(); - - result[pipelineId] = new HashSet(weldJointIds); + result[item.Key] = new HashSet(item.Value); } return result; diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.designer.cs index 1095bf1c..d66e65e6 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.designer.cs @@ -266,6 +266,15 @@ namespace FineUIPro.Web.HJGL.WeldingManage /// protected global::FineUIPro.Button btnPriorityComponents; + /// + /// btnConfirmMaterialCode 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnConfirmMaterialCode; + /// /// btnGenTask 控件。 /// diff --git a/SGGL/Model/CLGL/Tw_PipeMatMatchOutput.cs b/SGGL/Model/CLGL/Tw_PipeMatMatchOutput.cs index eb058fda..63b6fa80 100644 --- a/SGGL/Model/CLGL/Tw_PipeMatMatchOutput.cs +++ b/SGGL/Model/CLGL/Tw_PipeMatMatchOutput.cs @@ -11,12 +11,16 @@ namespace Model public class Tw_PipeMatMatchOutput { public string Id { get; set; } + public string PipeLineMatId { get; set; } public string PipelineId { get; set; } public string PipelineCode { get; set; } public string UnitWorkId { get; set; } public string UnitWorkName { get; set; } public string PrefabricatedComponents { get; set; } + public string WeldJointId { get; set; } + public string WeldJointCode { get; set; } public string MaterialCode { get; set; } + public string MatchMaterialCode { get; set; } public string Code { get; set; } public string HeatNo { get; set; } public string BatchNo { get; set; } diff --git a/SGGL/Model/Model.cs b/SGGL/Model/Model.cs index 8f3f6bdb..616c58fa 100644 --- a/SGGL/Model/Model.cs +++ b/SGGL/Model/Model.cs @@ -105869,6 +105869,10 @@ namespace Model private System.Nullable _IsLooseParts; + private string _WeldJointId; + + private string _MaterialCode2; + private EntityRef _HJGL_MaterialCodeLib; private EntityRef _HJGL_Pipeline; @@ -105889,6 +105893,10 @@ namespace Model partial void OnPrefabricatedComponentsChanged(); partial void OnIsLoosePartsChanging(System.Nullable value); partial void OnIsLoosePartsChanged(); + partial void OnWeldJointIdChanging(string value); + partial void OnWeldJointIdChanged(); + partial void OnMaterialCode2Changing(string value); + partial void OnMaterialCode2Changed(); #endregion public HJGL_PipeLineMat() @@ -106026,6 +106034,46 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WeldJointId", DbType="NVarChar(50)")] + public string WeldJointId + { + get + { + return this._WeldJointId; + } + set + { + if ((this._WeldJointId != value)) + { + this.OnWeldJointIdChanging(value); + this.SendPropertyChanging(); + this._WeldJointId = value; + this.SendPropertyChanged("WeldJointId"); + this.OnWeldJointIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_MaterialCode2", DbType="NVarChar(50)")] + public string MaterialCode2 + { + get + { + return this._MaterialCode2; + } + set + { + if ((this._MaterialCode2 != value)) + { + this.OnMaterialCode2Changing(value); + this.SendPropertyChanging(); + this._MaterialCode2 = value; + this.SendPropertyChanged("MaterialCode2"); + this.OnMaterialCode2Changed(); + } + } + } + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_HJGL_PipeLineMat_HJGL_MaterialCodeLib", Storage="_HJGL_MaterialCodeLib", ThisKey="MaterialCode", OtherKey="MaterialCode", IsForeignKey=true)] public HJGL_MaterialCodeLib HJGL_MaterialCodeLib { @@ -277039,6 +277087,8 @@ namespace Model private System.Nullable _Number; + private string _WeldJointId; + #region 可扩展性方法定义 partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -277055,6 +277105,8 @@ namespace Model partial void OnPrefabricatedComponentsChanged(); partial void OnNumberChanging(System.Nullable value); partial void OnNumberChanged(); + partial void OnWeldJointIdChanging(string value); + partial void OnWeldJointIdChanged(); #endregion public Tw_InOutPlanDetail_Relation() @@ -277182,6 +277234,26 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WeldJointId", DbType="NVarChar(50)")] + public string WeldJointId + { + get + { + return this._WeldJointId; + } + set + { + if ((this._WeldJointId != value)) + { + this.OnWeldJointIdChanging(value); + this.SendPropertyChanging(); + this._WeldJointId = value; + this.SendPropertyChanged("WeldJointId"); + this.OnWeldJointIdChanged(); + } + } + } + public event PropertyChangingEventHandler PropertyChanging; public event PropertyChangedEventHandler PropertyChanged;