From 01ae65b8abcd2ca16b1aeda6d2496f514566de00 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Mon, 28 Sep 2026 13:41:22 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=98=AF=E5=90=A6=E9=9C=80=E8=A6=81=E6=9D=90?= =?UTF-8?q?=E6=96=99=E7=82=89=E6=89=B9=E5=8F=B7=E8=BF=9B=E8=A1=8C=E7=AE=A1?= =?UTF-8?q?=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SGGL/BLL/CLGL/TwArrivalStatisticsService.cs | 213 ++++++++++-------- SGGL/BLL/CLGL/TwInOutplandetailService.cs | 21 +- SGGL/BLL/CLGL/TwInOutplanmasterService.cs | 67 +++++- .../HJGL/BaseInfo/MaterialCodeLibService.cs | 36 ++- SGGL/BLL/ProjectData/Project_SysSetService.cs | 69 ++++++ .../CLGL/ArrivalStatistics.aspx.cs | 3 +- SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs | 1 + .../CLGL/InPlanMasterApplyEdit.aspx.cs | 7 +- .../CLGL/InPlanMasterDetailImport.aspx.cs | 20 +- .../CLGL/InPlanMasterEdit.aspx.cs | 3 +- .../CLGL/InputBarCodeQuery.aspx.cs | 1 + SGGL/FineUIPro.Web/CLGL/InputMaster.aspx.cs | 6 + SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs | 1 + SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs | 2 +- .../CLGL/OutPlanMasterDetailImport.aspx.cs | 29 ++- .../CLGL/OutPlanMasterEdit.aspx.cs | 1 + .../CLGL/OutPlanMasterHistoryImport.aspx.cs | 11 +- .../CLGL/OutPlanMasterOut.aspx.cs | 3 +- .../CLGL/OutPlanMasterSelect.aspx.cs | 1 + .../CLGL/OutPlanMasterSelectStock.aspx.cs | 1 + SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs | 2 +- .../HJGL/BaseInfo/MaterialCodeLib.aspx.cs | 7 +- .../HJGL/BaseInfo/MaterialCodeLibEdit.aspx.cs | 31 ++- .../DataImport/MaterialInformation.aspx.cs | 8 +- .../MaterialInformationEdit.aspx.cs | 24 +- .../HJGL/WeldingManage/PipelineMatIn.aspx.cs | 27 ++- .../HJGL/WeldingManage/WeldMatMatch.aspx.cs | 35 ++- .../ProjectData/ProjectSysSet.aspx | 6 + .../ProjectData/ProjectSysSet.aspx.cs | 37 ++- .../ProjectSysSet.aspx.designer.cs | 9 + SGGL/FineUIPro.Web/common/PageBase.cs | 17 ++ 31 files changed, 526 insertions(+), 173 deletions(-) diff --git a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs index 1daa3004..f4ddcd7e 100644 --- a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs +++ b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs @@ -115,13 +115,28 @@ namespace BLL /// public static List GetMatMatchOutput(List requiredMaterials, string warehouseCode, string projectId, bool matchByMaterialCodeLibCode = false) { - Tw_MaterialStockOutput twMaterialStockOutput = new Tw_MaterialStockOutput + var stockList = GetAvailableStockList(warehouseCode, projectId); + if (matchByMaterialCodeLibCode) + { + MatchByMaterialBatch(requiredMaterials, stockList); + } + else + { + MatchByMaterialCode(requiredMaterials, stockList); + } + return requiredMaterials; + } + + /// + /// 获取库存快照,并预扣待审核、已审核出库计划占用量。 + /// + private static List GetAvailableStockList(string warehouseCode, string projectId) + { + var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(new Tw_MaterialStockOutput { WarehouseId = warehouseCode, ProjectId = projectId - }; - var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStockOutput).ToList();//获取库存列表 - + }).ToList(); // 预扣除出库申请单中状态为待审核/已审核的材料数量 using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { @@ -148,115 +163,103 @@ namespace BLL } } } + return stockList; + } - // 以下三个集合只服务于“按材料 Code 挑选材料主编码”的场景: - // remainingRequiredNumByCode:当前明细及后续明细的剩余总需求; - // stocksByCode:同一 Code 下所有可用的材料主编码库存; - // usedMaterialCodesByCode:本轮匹配已经使用过的材料主编码,用于优先继续消耗其余量。 - Dictionary remainingRequiredNumByCode = null; - Dictionary> stocksByCode = null; - Dictionary> usedMaterialCodesByCode = null; - if (matchByMaterialCodeLibCode) + /// + /// 按材料编码直接匹配同编码库存,用于不使用炉批号的项目。 + /// + private static void MatchByMaterialCode(List requiredMaterials, List stockList) + { + foreach (var material in requiredMaterials) { - // 按 Code 汇总全部需求,选择新主编码时可判断一个库存能否覆盖剩余需求。 - remainingRequiredNumByCode = requiredMaterials - .Where(x => !string.IsNullOrEmpty(x.MaterialCode)) - .GroupBy(x => x.MaterialCode) - .ToDictionary(x => x.Key, x => x.Sum(y => y.NeedNum ?? 0)); - - // 出库申请预扣后,仅保留仍有可用数量的主编码库存。 - stocksByCode = stockList - .Where(x => !string.IsNullOrEmpty(x.Code) && (x.StockNum ?? 0) > 0) - .GroupBy(x => x.Code) - .ToDictionary(x => x.Key, x => x.ToList()); - - // 每个 Code 独立记录已经启用的主编码,避免不同材料之间相互影响。 - usedMaterialCodesByCode = stocksByCode.ToDictionary(x => x.Key, x => new HashSet()); + var stock = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode); + ApplyMatchResult(material, stock); } + } + + /// + /// 按材料编码选择具体炉批号主编码,保留减少主编码种类、优先耗尽库存的原有顺序。 + /// + private static void MatchByMaterialBatch(List requiredMaterials, List stockList) + { + var remainingRequiredNumByCode = requiredMaterials + .Where(x => !string.IsNullOrEmpty(x.MaterialCode)) + .GroupBy(x => x.MaterialCode) + .ToDictionary(x => x.Key, x => x.Sum(y => y.NeedNum ?? 0)); + var stocksByCode = stockList + .Where(x => !string.IsNullOrEmpty(x.Code) && (x.StockNum ?? 0) > 0) + .GroupBy(x => x.Code) + .ToDictionary(x => x.Key, x => x.ToList()); + var usedMaterialCodesByCode = stocksByCode.ToDictionary(x => x.Key, x => new HashSet()); foreach (var material in requiredMaterials) { - material.Id = Guid.NewGuid().ToString(); - // 材料导入只保存材料编码 Code,匹配时按 Code 从库存中挑选实际材料主编码 PipeLineMatCode。 Tw_MaterialStockOutput stock = null; - if (matchByMaterialCodeLibCode) + if (!string.IsNullOrEmpty(material.MaterialCode) && stocksByCode.ContainsKey(material.MaterialCode)) { - if (!string.IsNullOrEmpty(material.MaterialCode) && stocksByCode.ContainsKey(material.MaterialCode)) - { - decimal needNum = material.NeedNum ?? 0; - decimal remainingRequiredNum = remainingRequiredNumByCode[material.MaterialCode]; - // StockNum 会在每条明细匹配后原地扣减,这里读取的是本轮实时剩余库存。 - var candidates = stocksByCode[material.MaterialCode] - .Where(x => (x.StockNum ?? 0) > 0) - .ToList(); - var usedMaterialCodes = usedMaterialCodesByCode[material.MaterialCode]; + decimal needNum = material.NeedNum ?? 0; + decimal remainingRequiredNum = remainingRequiredNumByCode[material.MaterialCode]; + var candidates = stocksByCode[material.MaterialCode] + .Where(x => (x.StockNum ?? 0) > 0) + .ToList(); + var usedMaterialCodes = usedMaterialCodesByCode[material.MaterialCode]; - // 第一优先级:复用已使用且能完整满足当前明细的主编码,减少主编码种类; - // 在多个已用主编码都满足时,选择库存最小的,使其更接近用完。 - stock = candidates - .Where(x => usedMaterialCodes.Contains(x.PipeLineMatCode) && (x.StockNum ?? 0) >= needNum) + stock = candidates + .Where(x => usedMaterialCodes.Contains(x.PipeLineMatCode) && (x.StockNum ?? 0) >= needNum) + .OrderBy(x => x.StockNum ?? 0) + .ThenBy(x => x.PipeLineMatCode) + .FirstOrDefault() + ?? candidates + .Where(x => !usedMaterialCodes.Contains(x.PipeLineMatCode) && (x.StockNum ?? 0) >= remainingRequiredNum) .OrderBy(x => x.StockNum ?? 0) .ThenBy(x => x.PipeLineMatCode) .FirstOrDefault() - // 第二优先级:启用一个能覆盖剩余总需求的新主编码,保证后续仍只使用这一种主编码; - // 若有多个可选,选择库存最小的,减少最终余料。 - ?? candidates - .Where(x => !usedMaterialCodes.Contains(x.PipeLineMatCode) && (x.StockNum ?? 0) >= remainingRequiredNum) - .OrderBy(x => x.StockNum ?? 0) - .ThenBy(x => x.PipeLineMatCode) - .FirstOrDefault() - // 第三优先级:无法一次覆盖剩余总需求时,选择刚好能满足当前明细且余量最小的新主编码。 - ?? candidates - .Where(x => !usedMaterialCodes.Contains(x.PipeLineMatCode) && (x.StockNum ?? 0) >= needNum) - .OrderBy(x => x.StockNum ?? 0) - .ThenBy(x => x.PipeLineMatCode) - .FirstOrDefault() - // 所有库存都不足以完整满足当前明细时,选择库存最大的主编码以保证匹配量最大; - // 库存相同时优先已使用的主编码,最后按主编码排序保证结果稳定。 - ?? candidates - .OrderByDescending(x => x.StockNum ?? 0) - .ThenByDescending(x => usedMaterialCodes.Contains(x.PipeLineMatCode)) - .ThenBy(x => x.PipeLineMatCode) - .FirstOrDefault(); + ?? candidates + .Where(x => !usedMaterialCodes.Contains(x.PipeLineMatCode) && (x.StockNum ?? 0) >= needNum) + .OrderBy(x => x.StockNum ?? 0) + .ThenBy(x => x.PipeLineMatCode) + .FirstOrDefault() + ?? candidates + .OrderByDescending(x => x.StockNum ?? 0) + .ThenByDescending(x => usedMaterialCodes.Contains(x.PipeLineMatCode)) + .ThenBy(x => x.PipeLineMatCode) + .FirstOrDefault(); - if (stock != null) - { - usedMaterialCodes.Add(stock.PipeLineMatCode); - } - // 当前明细处理完后,只保留后续明细的总需求供下一轮选码判断。 - remainingRequiredNumByCode[material.MaterialCode] -= needNum; + if (stock != null) + { + usedMaterialCodes.Add(stock.PipeLineMatCode); } + remainingRequiredNumByCode[material.MaterialCode] -= needNum; } - else - { - // 旧调用传入的是材料主编码,保持原来的精确匹配逻辑。 - stock = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode); - } - var thisMaterialStockNum = stock?.StockNum ?? 0; - if (thisMaterialStockNum >= material.NeedNum) - { - material.MatchNum = material.NeedNum; - material.MatchRate = 1; - material.MatchRateString = "100%"; - } - else - { - material.MatchNum = thisMaterialStockNum < 0 ? 0 : thisMaterialStockNum; - material.MatchRate = (material.NeedNum == 0 ? 0 : ((material.MatchNum ?? 0) / material.NeedNum)); - material.MatchRateString = Math.Round((decimal)(material.MatchRate ?? 0) * 100, 2).ToString() + "%"; - - } - // 这里保存的是本次计算匹配到的临时材料主编码;是否已反写以 HJGL_PipeLineMat.MaterialCode 为准。 - material.MatchMaterialCode = stock?.PipeLineMatCode; - // 本轮匹配会连续消耗同一库存快照,防止后续材料重复占用已匹配数量。 - if (stock != null) - { - stock.StockNum -= material.MatchNum; - } + ApplyMatchResult(material, stock); } + } - var results = requiredMaterials; - return results; + /// + /// 回填单条材料匹配结果,并扣减本轮库存快照。 + /// + private static void ApplyMatchResult(Tw_PipeMatMatchOutput material, Tw_MaterialStockOutput stock) + { + material.Id = Guid.NewGuid().ToString(); + var stockNum = stock == null ? 0 : stock.StockNum ?? 0; + if (stockNum >= material.NeedNum) + { + material.MatchNum = material.NeedNum; + material.MatchRate = 1; + material.MatchRateString = "100%"; + } + else + { + material.MatchNum = stockNum < 0 ? 0 : stockNum; + material.MatchRate = material.NeedNum == 0 ? 0 : (material.MatchNum ?? 0) / material.NeedNum; + material.MatchRateString = Math.Round((decimal)(material.MatchRate ?? 0) * 100, 2).ToString() + "%"; + } + material.MatchMaterialCode = stock == null ? null : stock.PipeLineMatCode; + if (stock != null) + { + stock.StockNum -= material.MatchNum; + } } /// /// 获取管线匹配率 @@ -350,6 +353,7 @@ namespace BLL { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { + bool usesMaterialBatchNumber = Project_SysSetService.UsesMaterialBatchNumber(projectId); var results = new List(); if (pipelineIds == null || !pipelineIds.Any()) { @@ -411,8 +415,11 @@ namespace BLL .Select(x => x.PipeLineMat.MaterialCode2) .Distinct() .ToList(); + var exactMaterialCodes = usesMaterialBatchNumber + ? materialCodes + : materialCodes.Concat(materialCode2s).Distinct().ToList(); var libByMaterialCode = db.HJGL_MaterialCodeLib - .Where(x => materialCodes.Contains(x.MaterialCode)) + .Where(x => exactMaterialCodes.Contains(x.MaterialCode)) .ToList() .GroupBy(x => x.MaterialCode) .ToDictionary(x => x.Key, x => x.First()); @@ -431,10 +438,18 @@ namespace BLL lib = libByMaterialCode[x.PipeLineMat.MaterialCode]; } // 未反写时只能按导入材料编码 Code 找候选材料库。 - else if (!string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2) && libByCode.ContainsKey(x.PipeLineMat.MaterialCode2)) + else if (usesMaterialBatchNumber + && !string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2) + && libByCode.ContainsKey(x.PipeLineMat.MaterialCode2)) { lib = libByCode[x.PipeLineMat.MaterialCode2]; } + else if (!usesMaterialBatchNumber + && !string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2) + && libByMaterialCode.ContainsKey(x.PipeLineMat.MaterialCode2)) + { + lib = libByMaterialCode[x.PipeLineMat.MaterialCode2]; + } string code = !string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2) ? x.PipeLineMat.MaterialCode2 : lib?.Code; return new Tw_PipeMatMatchOutput @@ -517,7 +532,7 @@ namespace BLL newRequiredMaterials.AddRange(orderedPipelineMaterials[id].Where(x => !addedMaterialIds.Contains(x.PipeLineMatId))); } - results = GetMatMatchOutput(newRequiredMaterials, warehouseCode, projectId, true); + results = GetMatMatchOutput(newRequiredMaterials, warehouseCode, projectId, usesMaterialBatchNumber); // 组件匹配率以当前区域剩余未焊口的材料需求为口径,并回填到每条明细供表格合并展示。 foreach (var componentGroup in results.GroupBy(x => new { x.PipelineId, x.PrefabricatedComponents })) { diff --git a/SGGL/BLL/CLGL/TwInOutplandetailService.cs b/SGGL/BLL/CLGL/TwInOutplandetailService.cs index 912e7057..73e3ad7f 100644 --- a/SGGL/BLL/CLGL/TwInOutplandetailService.cs +++ b/SGGL/BLL/CLGL/TwInOutplandetailService.cs @@ -110,6 +110,19 @@ namespace BLL /// /// public static void AddList(IEnumerable list, string inoutPlanMasterId) + { + AddList(list, inoutPlanMasterId, null); + } + + /// + /// 批量添加导入计划明细,并按项目炉批号模式生成材料主编码。 + /// + public static void AddList(IEnumerable list, string inoutPlanMasterId, bool usesMaterialBatch) + { + AddList(list, inoutPlanMasterId, (bool?)usesMaterialBatch); + } + + private static void AddList(IEnumerable list, string inoutPlanMasterId, bool? usesMaterialBatch) { int sortIndex = 1; List details = new List(); @@ -120,12 +133,14 @@ namespace BLL Id = SQLHelper.GetNewID(), InOutPlanMasterId = inoutPlanMasterId, PipelineComponentId = item.PipelineComponentId, - MaterialCode = item.MaterialCode + "-" + item.HeatNo + "-" + item.BatchNo, + MaterialCode = usesMaterialBatch.HasValue + ? MaterialCodeLibService.BuildMaterialCode(item.MaterialCode, item.HeatNo, item.BatchNo, usesMaterialBatch.Value) + : item.MaterialCode, PlanNum = item.PlanNum, ActNum = item.ActNum, SortIndex = sortIndex, - HeatNo = item.HeatNo, - BatchNo = item.BatchNo, + HeatNo = usesMaterialBatch == false ? null : item.HeatNo, + BatchNo = usesMaterialBatch == false ? null : item.BatchNo, DeliveryDate = item.DeliveryDate }; sortIndex++; diff --git a/SGGL/BLL/CLGL/TwInOutplanmasterService.cs b/SGGL/BLL/CLGL/TwInOutplanmasterService.cs index ed53317d..ee06b94e 100644 --- a/SGGL/BLL/CLGL/TwInOutplanmasterService.cs +++ b/SGGL/BLL/CLGL/TwInOutplanmasterService.cs @@ -260,15 +260,16 @@ namespace BLL public static ResponeData ImportData(string OriFileName, string path, string projectid, string creatUserId) { var responeData = new ResponeData(); + bool usesMaterialBatch = Project_SysSetService.UsesMaterialBatchNumber(projectid); List temeplateDtoIns; try { temeplateDtoIns = MiniExcel.Query(path, startCell: "A1").ToList(); foreach (var item in temeplateDtoIns) { - item.MaterialCode = item.MaterialCode.Trim(); - item.HeatNo = item.HeatNo.Trim(); - item.BatchNo = item.BatchNo.Trim(); + item.MaterialCode = CleanImportText(item.MaterialCode); + item.HeatNo = usesMaterialBatch ? CleanImportText(item.HeatNo) : null; + item.BatchNo = usesMaterialBatch ? CleanImportText(item.BatchNo) : null; } } catch (Exception ex) @@ -285,6 +286,12 @@ namespace BLL responeData.message = "导入数据为空!"; return responeData; } + if (usesMaterialBatch && temeplateDtoIns.Any(x => string.IsNullOrEmpty(x.HeatNo) || string.IsNullOrEmpty(x.BatchNo))) + { + responeData.code = 0; + responeData.message = "导入数据中炉号、批号不能为空!"; + return responeData; + } var warehouseList = Base_WarehouseService.GetWarehouseList(projectid); var warehouseCodeList = temeplateDtoIns.Select(x => CleanImportText(x.WarehouseCode)).Distinct().ToList(); //获取导入文件的仓库 string errorWarehouseCode = ""; @@ -418,8 +425,8 @@ namespace BLL twInOutPlanMaster.CreateDate = DateTime.Now; twInOutPlanMaster.Remark = OriFileName; Add(twInOutPlanMaster); - MaterialCodeLibService.AddList(temeplateDtoIns); //插入材料编码库 - TwInOutplandetailService.AddList(twInOutPlanDetails, twInOutPlanMaster.Id); //插入入库明细 + MaterialCodeLibService.AddList(temeplateDtoIns, usesMaterialBatch); //插入材料编码库 + TwInOutplandetailService.AddList(twInOutPlanDetails, twInOutPlanMaster.Id, usesMaterialBatch); //插入入库明细 } return responeData; @@ -432,6 +439,7 @@ namespace BLL public static ResponeData ImportOutHistoryData(string oriFileName, string path, string projectId, string createUserId, string unitWorkId) { var responeData = new ResponeData(); + bool usesMaterialBatch = Project_SysSetService.UsesMaterialBatchNumber(projectId); if (string.IsNullOrEmpty(unitWorkId)) { responeData.code = 0; @@ -442,7 +450,17 @@ namespace BLL List importRows; try { - importRows = MiniExcel.Query(path, startCell: "A1").ToList(); + importRows = usesMaterialBatch + ? MiniExcel.Query(path, startCell: "A1").ToList() + : MiniExcel.Query(path, startCell: "A1") + .Select(x => new Tw_OutHistoryDataIn + { + WarehouseCode = x.WarehouseCode, + MaterialCode = x.MaterialCode, + Num = x.Num, + OutputDate = x.OutputDate, + ReqUnitName = x.ReqUnitName + }).ToList(); } catch (Exception ex) { @@ -499,12 +517,12 @@ namespace BLL errors.Add("第" + rowIndex + "行,材料编码,此项为必填项!"); continue; } - if (string.IsNullOrEmpty(heatNo)) + if (usesMaterialBatch && string.IsNullOrEmpty(heatNo)) { errors.Add("第" + rowIndex + "行,炉号,此项为必填项!"); continue; } - if (string.IsNullOrEmpty(batchNo)) + if (usesMaterialBatch && string.IsNullOrEmpty(batchNo)) { errors.Add("第" + rowIndex + "行,批号,此项为必填项!"); continue; @@ -531,10 +549,14 @@ namespace BLL continue; } - var stock = allStock.FirstOrDefault(x => x.WarehouseId == rowWarehouse.WarehouseId && x.Code == materialCode && x.HeatNo == heatNo && x.BatchNo == batchNo); + var stock = usesMaterialBatch + ? allStock.FirstOrDefault(x => x.WarehouseId == rowWarehouse.WarehouseId && x.Code == materialCode && x.HeatNo == heatNo && x.BatchNo == batchNo) + : allStock.FirstOrDefault(x => x.WarehouseId == rowWarehouse.WarehouseId && x.PipeLineMatCode == materialCode); if (stock == null) { - errors.Add("第" + rowIndex + "行,仓库[" + rowWarehouse.WarehouseName + "]库存中不存在此材料编码/炉号/批号-" + materialCode + "/" + heatNo + "/" + batchNo); + errors.Add(usesMaterialBatch + ? "第" + rowIndex + "行,仓库[" + rowWarehouse.WarehouseName + "]库存中不存在此材料编码/炉号/批号-" + materialCode + "/" + heatNo + "/" + batchNo + : "第" + rowIndex + "行,仓库[" + rowWarehouse.WarehouseName + "]库存中不存在此材料编码-" + materialCode); continue; } @@ -576,7 +598,9 @@ namespace BLL Stock = allStock.FirstOrDefault(y => y.WarehouseId == x.Key.WarehouseId && y.PipeLineMatCode == x.Key.MaterialCode) }) .Where(x => x.Stock == null || (x.Stock.StockNum ?? 0) < x.Num) - .Select(x => "仓库[" + x.WarehouseCode + "]" + (x.Stock == null ? x.MaterialCode : x.Stock.Code + "/" + x.Stock.HeatNo + "/" + x.Stock.BatchNo) + .Select(x => "仓库[" + x.WarehouseCode + "]" + (x.Stock == null + ? x.MaterialCode + : usesMaterialBatch ? x.Stock.Code + "/" + x.Stock.HeatNo + "/" + x.Stock.BatchNo : x.Stock.PipeLineMatCode) + "库存不足,库存:" + (x.Stock?.StockNum ?? 0) + ",导入数量:" + x.Num) .ToList(); if (stockErrors.Count > 0) @@ -1404,6 +1428,27 @@ namespace BLL } + /// + /// 不使用炉批号时的历史出库动态模板列映射。 + /// + public class Tw_OutHistoryDataNoBatchIn + { + [MiniExcelLibs.Attributes.ExcelColumnIndex("A")] + public string WarehouseCode { get; set; } + + [MiniExcelLibs.Attributes.ExcelColumnIndex("B")] + public string MaterialCode { get; set; } + + [MiniExcelLibs.Attributes.ExcelColumnIndex("C")] + public string Num { get; set; } + + [MiniExcelLibs.Attributes.ExcelColumnIndex("D")] + public string OutputDate { get; set; } + + [MiniExcelLibs.Attributes.ExcelColumnIndex("E")] + public string ReqUnitName { get; set; } + } + } } diff --git a/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs b/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs index fe386918..34e7ff86 100644 --- a/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs +++ b/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs @@ -6,6 +6,19 @@ using System.Linq; public static class MaterialCodeLibService { + /// + /// 按项目炉批号设置生成材料主编码。 + /// + public static string BuildMaterialCode(string code, string heatNo, string batchNo, bool usesMaterialBatch) + { + if (!usesMaterialBatch) + { + return code; + } + + return code + "-" + heatNo + "-" + batchNo; + } + /// ///获取材料库信息 /// @@ -160,25 +173,25 @@ /// /// /// - public static void AddList(List list) + public static void AddList(List list, bool usesMaterialBatch) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - var materialCodes = from x in db.HJGL_MaterialCodeLib select x.MaterialCode; - var ls = from x in list - where !materialCodes.Contains(x.MaterialCode + "-" + x.HeatNo + "-" + x.BatchNo) - select x; - List codes = new List(); + var materialCodes = new HashSet( + db.HJGL_MaterialCodeLib.Select(x => x.MaterialCode), + System.StringComparer.OrdinalIgnoreCase); + var codes = new HashSet(System.StringComparer.OrdinalIgnoreCase); List details = new List(); - foreach (var item in ls) + foreach (var item in list) { - if (!codes.Contains(item.MaterialCode + "-" + item.HeatNo + "-" + item.BatchNo)) + string materialCode = BuildMaterialCode(item.MaterialCode, item.HeatNo, item.BatchNo, usesMaterialBatch); + if (!materialCodes.Contains(materialCode) && codes.Add(materialCode)) { Model.HJGL_MaterialCodeLib table = new Model.HJGL_MaterialCodeLib { - MaterialCode = item.MaterialCode + "-" + item.HeatNo + "-" + item.BatchNo, - HeatNo = item.HeatNo, - BatchNo = item.BatchNo, + MaterialCode = materialCode, + HeatNo = usesMaterialBatch ? item.HeatNo : null, + BatchNo = usesMaterialBatch ? item.BatchNo : null, MaterialName = item.MaterialName, MaterialSpec = item.MaterialSpec, MaterialUnit = item.MaterialUnit, @@ -186,7 +199,6 @@ Code = item.MaterialCode }; details.Add(table); - codes.Add(table.MaterialCode); } } diff --git a/SGGL/BLL/ProjectData/Project_SysSetService.cs b/SGGL/BLL/ProjectData/Project_SysSetService.cs index 3cf2ba78..e9105a36 100644 --- a/SGGL/BLL/ProjectData/Project_SysSetService.cs +++ b/SGGL/BLL/ProjectData/Project_SysSetService.cs @@ -6,6 +6,71 @@ namespace BLL { public static class Project_SysSetService { + /// + /// 材料炉批号设置编号。 + /// + public const string MaterialBatchSetId = "12"; + + /// + /// 材料炉批号设置名称。 + /// + public const string MaterialBatchSetName = "材料是否使用炉批号"; + + /// + /// 获取项目是否使用材料炉批号。未配置时保持历史行为,默认使用炉批号。 + /// + public static bool UsesMaterialBatchNumber(string projectId) + { + var setting = GetSysSetBySetId(MaterialBatchSetId, projectId); + return setting == null || setting.IsAuto != false; + } + + /// + /// 获取关闭材料炉批号设置前的数据兼容性提示。 + /// + public static string GetDisableMaterialBatchWarning(string projectId) + { + var db = Funs.DB; + var invalidStockCount = (from stock in db.Tw_MaterialStock + join material in db.HJGL_MaterialCodeLib on stock.PipeLineMatCode equals material.MaterialCode + where stock.ProjectId == projectId + && stock.StockNum != null + && stock.StockNum != 0 + && material.MaterialCode != material.Code + select stock.Id).Count(); + + var invalidPlanDetailCount = (from detail in db.Tw_InOutPlanDetail + join master in db.Tw_InOutPlanMaster on detail.InOutPlanMasterId equals master.Id + join material in db.HJGL_MaterialCodeLib on detail.MaterialCode equals material.MaterialCode + where master.ProjectId == projectId + && (master.State == (int)TwConst.State.待提交 + || master.State == (int)TwConst.State.待审核 + || master.State == (int)TwConst.State.已审核) + && material.MaterialCode != material.Code + select detail.Id).Count(); + + var invalidPipelineMaterialCount = (from material in db.HJGL_PipeLineMat + join pipeline in db.HJGL_Pipeline on material.PipelineId equals pipeline.PipelineId + where pipeline.ProjectId == projectId + && (material.MaterialCode == null + || material.MaterialCode == "" + || material.MaterialCode2 == null + || material.MaterialCode2 == "" + || material.MaterialCode != material.MaterialCode2) + select material.PipeLineMatId).Count(); + + if (invalidStockCount == 0 && invalidPlanDetailCount == 0 && invalidPipelineMaterialCount == 0) + { + return ""; + } + + return string.Format( + "无法关闭材料炉批号设置:非零库存主编码不一致 {0} 条;未完成出入库单主编码不一致 {1} 条;管线材料编码未归一化 {2} 条。请先处理后重试。", + invalidStockCount, + invalidPlanDetailCount, + invalidPipelineMaterialCount); + } + /// /// 获取avevanet 地址 /// @@ -111,6 +176,10 @@ namespace BLL Model.Project_Sys_Set newSet = db.Project_Sys_Set.FirstOrDefault(e => e.SetId == set.SetId && e.ProjectId == set.ProjectId); if (newSet != null) { + if (set.SetName != null && set.SetName != "") + { + newSet.SetName = set.SetName; + } newSet.IsAuto = set.IsAuto; newSet.SetValue = set.SetValue; db.SubmitChanges(); diff --git a/SGGL/FineUIPro.Web/CLGL/ArrivalStatistics.aspx.cs b/SGGL/FineUIPro.Web/CLGL/ArrivalStatistics.aspx.cs index 8a93f70d..7dbe2050 100644 --- a/SGGL/FineUIPro.Web/CLGL/ArrivalStatistics.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/ArrivalStatistics.aspx.cs @@ -18,6 +18,7 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { drpWarehouse.DataTextField = "Key"; @@ -192,4 +193,4 @@ namespace FineUIPro.Web.CLGL #endregion 导出按钮 } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs index d9454e8e..a1e1ad54 100644 --- a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs @@ -17,6 +17,7 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid2); if (!IsPostBack) { this.GetButtonPower(); diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.cs index c7a9f0e1..13549736 100644 --- a/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.cs @@ -40,6 +40,7 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid2); if (!IsPostBack) { InitDrpList(); @@ -260,7 +261,7 @@ namespace FineUIPro.Web.CLGL { if (validateDetail) { - Alert.ShowInTop("请选择材料主编码!", MessageBoxIcon.Warning); + Alert.ShowInTop(Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId) ? "请选择材料主编码!" : "请选择材料编码!", MessageBoxIcon.Warning); return false; } continue; @@ -388,8 +389,10 @@ namespace FineUIPro.Web.CLGL private List GetMaterialList() { + bool usesMaterialBatch = Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); return MaterialCodeLibService.GetMaterialCodeLibList() - .Where(x => string.IsNullOrEmpty(x.ProjectId) || x.ProjectId == this.CurrUser.LoginProjectId) + .Where(x => (string.IsNullOrEmpty(x.ProjectId) || x.ProjectId == this.CurrUser.LoginProjectId) + && (usesMaterialBatch || x.MaterialCode == x.Code)) .OrderBy(x => x.MaterialCode) .ToList(); } diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.cs index 104ab08d..28b89ef7 100644 --- a/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.cs @@ -31,6 +31,7 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { hdFileName.Text = string.Empty; @@ -122,14 +123,21 @@ namespace FineUIPro.Web.CLGL return responeData; } + bool usesMaterialBatch = Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); bool hasMaterialCode = table.Columns.Contains("材料主编码"); bool hasCodeInfo = table.Columns.Contains("材料编码") && table.Columns.Contains("炉号") && table.Columns.Contains("批号"); - if (!hasMaterialCode && !hasCodeInfo) + if (usesMaterialBatch && !hasMaterialCode && !hasCodeInfo) { responeData.code = 0; responeData.message = "导入Excel格式错误!模板列必须包含材料主编码,或同时包含材料编码、炉号、批号"; return responeData; } + if (!usesMaterialBatch && !table.Columns.Contains("材料编码")) + { + responeData.code = 0; + responeData.message = "导入Excel格式错误!模板列必须包含:材料编码、计划入库数量"; + return responeData; + } Tw_InOutPlanMaster master = TwInOutplanmasterService.GetById(Id); if (master == null) @@ -148,7 +156,7 @@ namespace FineUIPro.Web.CLGL List materialList = MaterialCodeLibService.GetMaterialCodeLibList(); for (int i = 0; i < table.Rows.Count; i++) { - string materialCode = hasMaterialCode ? GetCellValue(table.Rows[i], "材料主编码") : string.Empty; + string materialCode = usesMaterialBatch && hasMaterialCode ? GetCellValue(table.Rows[i], "材料主编码") : string.Empty; string code = table.Columns.Contains("材料编码") ? GetCellValue(table.Rows[i], "材料编码") : string.Empty; string heatNo = table.Columns.Contains("炉号") ? GetCellValue(table.Rows[i], "炉号") : string.Empty; string batchNo = table.Columns.Contains("批号") ? GetCellValue(table.Rows[i], "批号") : string.Empty; @@ -160,7 +168,11 @@ namespace FineUIPro.Web.CLGL } HJGL_MaterialCodeLib material = null; - if (!string.IsNullOrEmpty(materialCode)) + if (!usesMaterialBatch) + { + material = materialList.FirstOrDefault(x => x.MaterialCode == code); + } + else if (!string.IsNullOrEmpty(materialCode)) { material = materialList.FirstOrDefault(x => x.MaterialCode == materialCode); } @@ -296,7 +308,7 @@ namespace FineUIPro.Web.CLGL string tempPath = tempDirectory + "入库明细导入模板" + string.Format("{0:yyyyMMddHHmmss}", DateTime.Now) + ".xlsx"; DataTable template = new DataTable(); - template.Columns.Add("材料主编码"); + template.Columns.Add(Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId) ? "材料主编码" : "材料编码"); template.Columns.Add("计划入库数量"); MiniExcel.SaveAs(tempPath, template); diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMasterEdit.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMasterEdit.aspx.cs index eea0d104..78203312 100644 --- a/SGGL/FineUIPro.Web/CLGL/InPlanMasterEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/InPlanMasterEdit.aspx.cs @@ -22,6 +22,7 @@ namespace FineUIPro.Web.CLGL } protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { Id = Request.QueryString["Id"]; @@ -135,4 +136,4 @@ namespace FineUIPro.Web.CLGL throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/CLGL/InputBarCodeQuery.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InputBarCodeQuery.aspx.cs index 784e49ed..3128feda 100644 --- a/SGGL/FineUIPro.Web/CLGL/InputBarCodeQuery.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/InputBarCodeQuery.aspx.cs @@ -9,6 +9,7 @@ namespace FineUIPro.Web.CLGL { protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); diff --git a/SGGL/FineUIPro.Web/CLGL/InputMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InputMaster.aspx.cs index 15ad718c..7ab5fe7a 100644 --- a/SGGL/FineUIPro.Web/CLGL/InputMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/InputMaster.aspx.cs @@ -17,6 +17,12 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid2, Grid3); + if (!Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId)) + { + GridPipeDetail.FindColumn("PipeHeatNo").Hidden = true; + GridPipeDetail.FindColumn("PipeBatchNo").Hidden = true; + } if (!IsPostBack) { this.GetButtonPower(); diff --git a/SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs b/SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs index 96526621..d00e3b51 100644 --- a/SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs @@ -12,6 +12,7 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs index f7e5be7d..db674a08 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs @@ -15,7 +15,7 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { - + ConfigureMaterialBatchColumns(Grid2, Grid3, Grid4); if (!IsPostBack) { this.GetButtonPower(); diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterDetailImport.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterDetailImport.aspx.cs index 84e1ad22..949c3781 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterDetailImport.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterDetailImport.aspx.cs @@ -31,6 +31,7 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { hdFileName.Text = string.Empty; @@ -115,7 +116,10 @@ namespace FineUIPro.Web.CLGL return responeData; } - string[] requiredColumns = { "材料编码", "炉号", "批号", "计划数量" }; + bool usesMaterialBatch = Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); + string[] requiredColumns = usesMaterialBatch + ? new[] { "材料编码", "炉号", "批号", "计划数量" } + : new[] { "材料编码", "计划数量" }; foreach (string columnName in requiredColumns) { @@ -145,8 +149,8 @@ namespace FineUIPro.Web.CLGL for (int i = 0; i < table.Rows.Count; i++) { string code = GetCellValue(table.Rows[i], "材料编码"); - string heatNo = GetCellValue(table.Rows[i], "炉号"); - string batchNo = GetCellValue(table.Rows[i], "批号"); + string heatNo = table.Columns.Contains("炉号") ? GetCellValue(table.Rows[i], "炉号") : string.Empty; + string batchNo = table.Columns.Contains("批号") ? GetCellValue(table.Rows[i], "批号") : string.Empty; string planNumText = GetCellValue(table.Rows[i], "计划数量"); if (string.IsNullOrEmpty(code) && string.IsNullOrEmpty(heatNo) && string.IsNullOrEmpty(batchNo) && string.IsNullOrEmpty(planNumText)) @@ -159,12 +163,12 @@ namespace FineUIPro.Web.CLGL result.Add("第" + (i + 2).ToString() + "行,材料编码,此项为必填项!"); continue; } - if (string.IsNullOrEmpty(heatNo)) + if (usesMaterialBatch && string.IsNullOrEmpty(heatNo)) { result.Add("第" + (i + 2).ToString() + "行,炉号,此项为必填项!"); continue; } - if (string.IsNullOrEmpty(batchNo)) + if (usesMaterialBatch && string.IsNullOrEmpty(batchNo)) { result.Add("第" + (i + 2).ToString() + "行,批号,此项为必填项!"); continue; @@ -177,10 +181,14 @@ namespace FineUIPro.Web.CLGL continue; } - Tw_MaterialStockOutput stock = stockList.FirstOrDefault(x => x.Code == code && x.HeatNo == heatNo && x.BatchNo == batchNo); + Tw_MaterialStockOutput stock = usesMaterialBatch + ? stockList.FirstOrDefault(x => x.Code == code && x.HeatNo == heatNo && x.BatchNo == batchNo) + : stockList.FirstOrDefault(x => x.PipeLineMatCode == code); if (stock == null) { - result.Add("第" + (i + 2).ToString() + "行,当前仓库可选库存中不存在此材料编码/炉号/批号-" + code + "/" + heatNo + "/" + batchNo); + result.Add(usesMaterialBatch + ? "第" + (i + 2).ToString() + "行,当前仓库可选库存中不存在此材料编码/炉号/批号-" + code + "/" + heatNo + "/" + batchNo + : "第" + (i + 2).ToString() + "行,当前仓库可选库存中不存在此材料编码-" + code); continue; } @@ -299,8 +307,11 @@ namespace FineUIPro.Web.CLGL string tempPath = tempDirectory + "出库明细导入模板" + string.Format("{0:yyyyMMddHHmmss}", DateTime.Now) + ".xlsx"; DataTable template = new DataTable(); template.Columns.Add("材料编码"); - template.Columns.Add("炉号"); - template.Columns.Add("批号"); + if (Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId)) + { + template.Columns.Add("炉号"); + template.Columns.Add("批号"); + } template.Columns.Add("计划数量"); MiniExcel.SaveAs(tempPath, template); diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterEdit.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterEdit.aspx.cs index 9b655ede..769731ad 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterEdit.aspx.cs @@ -36,6 +36,7 @@ namespace FineUIPro.Web.CLGL } protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1, Grid2); if (!IsPostBack) { InitDrpList(); diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterHistoryImport.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterHistoryImport.aspx.cs index 55c81f1d..71323e10 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterHistoryImport.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterHistoryImport.aspx.cs @@ -30,6 +30,10 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { + if (!Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId)) + { + lblTip.Text = "模板列:仓库、材料编码、数量、出库时间、领用单位。导入后会按材料单位自动拆分管段/管件单据,并直接生成出库单扣减对应仓库的库存。"; + } if (!IsPostBack) { UnitWorkId = Request.Params["UnitWorkId"]; @@ -106,8 +110,11 @@ namespace FineUIPro.Web.CLGL DataTable template = new DataTable(); template.Columns.Add("仓库"); template.Columns.Add("材料编码"); - template.Columns.Add("炉号"); - template.Columns.Add("批号"); + if (Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId)) + { + template.Columns.Add("炉号"); + template.Columns.Add("批号"); + } template.Columns.Add("数量"); template.Columns.Add("出库时间"); template.Columns.Add("领用单位"); diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterOut.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterOut.aspx.cs index 531e8d36..51bc6bc7 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterOut.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterOut.aspx.cs @@ -22,6 +22,7 @@ namespace FineUIPro.Web.CLGL } protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { Id = Request.QueryString["Id"]; @@ -109,4 +110,4 @@ namespace FineUIPro.Web.CLGL throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelect.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelect.aspx.cs index a648a1b8..8674624d 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelect.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelect.aspx.cs @@ -47,6 +47,7 @@ namespace FineUIPro.Web.CLGL /// protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { UnitWorkId = Request.QueryString["UnitWorkId"]; diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelectStock.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelectStock.aspx.cs index 43a6d5e3..b021cd57 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelectStock.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelectStock.aspx.cs @@ -19,6 +19,7 @@ namespace FineUIPro.Web.CLGL } protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { Id = Request.QueryString["Id"]; diff --git a/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs index 0b84b22d..c1f1f013 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs @@ -19,7 +19,7 @@ namespace FineUIPro.Web.CLGL protected void Page_Load(object sender, EventArgs e) { - + ConfigureMaterialBatchColumns(Grid2); if (!IsPostBack) { this.GetButtonPower(); diff --git a/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLib.aspx.cs b/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLib.aspx.cs index 6d165aec..56f5c502 100644 --- a/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLib.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLib.aspx.cs @@ -17,6 +17,7 @@ namespace FineUIPro.Web.HJGL.BaseInfo /// protected void Page_Load(object sender, EventArgs e) { + ConfigureMaterialBatchColumns(Grid1); if (!IsPostBack) { this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); @@ -35,6 +36,10 @@ namespace FineUIPro.Web.HJGL.BaseInfo string strSql = @" SELECT * FROM dbo.HJGL_MaterialCodeLib WHERE 1=1"; List listStr = new List(); + if (!BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId)) + { + strSql += " AND MaterialCode = Code"; + } if (!string.IsNullOrEmpty(this.txtCode.Text.Trim())) { @@ -269,4 +274,4 @@ namespace FineUIPro.Web.HJGL.BaseInfo } #endregion } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLibEdit.aspx.cs b/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLibEdit.aspx.cs index 64e4c0aa..fa0fc3f0 100644 --- a/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLibEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLibEdit.aspx.cs @@ -14,6 +14,13 @@ namespace FineUIPro.Web.HJGL.BaseInfo /// protected void Page_Load(object sender, EventArgs e) { + bool usesMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); + this.txtHeatNo.Hidden = !usesMaterialBatch; + this.txtBatchNo.Hidden = !usesMaterialBatch; + this.txtHeatNo.Required = usesMaterialBatch; + this.txtBatchNo.Required = usesMaterialBatch; + this.txtHeatNo.ShowRedStar = usesMaterialBatch; + this.txtBatchNo.ShowRedStar = usesMaterialBatch; if (!IsPostBack) { btnClose.OnClientClick = ActiveWindow.GetHideReference(); @@ -52,27 +59,29 @@ namespace FineUIPro.Web.HJGL.BaseInfo protected void btnSave_Click(object sender, EventArgs e) { string materialCode = Request.Params["MaterialCode"]; - if (string.IsNullOrEmpty(materialCode)) + bool usesMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); + string code = this.txtCode.Text.Trim(); + string heatNo = usesMaterialBatch ? this.txtHeatNo.Text.Trim() : null; + string batchNo = usesMaterialBatch ? this.txtBatchNo.Text.Trim() : null; + string generatedMaterialCode = BLL.MaterialCodeLibService.BuildMaterialCode(code, heatNo, batchNo, usesMaterialBatch); + var duplicate = Funs.DB.HJGL_MaterialCodeLib.FirstOrDefault(x => x.MaterialCode == generatedMaterialCode); + if (duplicate != null && duplicate.MaterialCode != materialCode) { - var q = Funs.DB.HJGL_MaterialCodeLib.FirstOrDefault(x => x.MaterialCode == materialCode); - if (q != null) - { - Alert.ShowInTop("此材料编码、炉号、批号已存在!", MessageBoxIcon.Warning); - return; - } + Alert.ShowInTop("此材料编码、炉号、批号已存在!", MessageBoxIcon.Warning); + return; } Model.HJGL_MaterialCodeLib newLib = new Model.HJGL_MaterialCodeLib { - MaterialCode = this.txtCode.Text.Trim() + "-" + this.txtHeatNo.Text.Trim() + "-" + this.txtBatchNo.Text.Trim(), - HeatNo = this.txtHeatNo.Text.Trim(), - BatchNo = this.txtBatchNo.Text.Trim(), + MaterialCode = generatedMaterialCode, + HeatNo = heatNo, + BatchNo = batchNo, MaterialName = this.txtMaterialName.Text.Trim(), MaterialSpec = this.txtMaterialSpec.Text.Trim(), MaterialMade = this.txtMaterialMade.Text.Trim(), MaterialDef = this.txtMaterialDef.Text.Trim(), MaterialUnit = txtMaterialUnit.Text.Trim(), - Code = this.txtCode.Text.Trim(), + Code = code, DesignInstitute = string.IsNullOrWhiteSpace(txtDesignInstitute.Text) ? null : txtDesignInstitute.Text.Trim() diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs index 5ba881a3..4b508212 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs @@ -15,7 +15,13 @@ namespace FineUIPro.Web.HJGL.DataImport protected void Page_Load(object sender, EventArgs e) { - + ConfigureMaterialBatchColumns(Grid1, Grid2, Grid3); + if (!Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId)) + { + Grid1.FindColumn("MaterialCode").Hidden = true; + Grid2.FindColumn("MaterialCode").Hidden = true; + Grid3.FindColumn("MaterialCode").Hidden = true; + } if (!IsPostBack) { this.InitTreeMenu();//加载树 diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformationEdit.aspx.cs b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformationEdit.aspx.cs index 94cc7a3f..c021ce52 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformationEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformationEdit.aspx.cs @@ -23,15 +23,22 @@ namespace FineUIPro.Web.HJGL.DataImport protected void Page_Load(object sender, EventArgs e) { + bool usesMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); this.txtHeatNo.Readonly = true; this.txtBatchNo.Readonly = true; + this.drpMainMaterialCode.Hidden = !usesMaterialBatch; + this.txtHeatNo.Hidden = !usesMaterialBatch; + this.txtBatchNo.Hidden = !usesMaterialBatch; if (!IsPostBack) { btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.PipeLineMatId = Request.Params["PipeLineMatId"]; - BindMainMaterialCodes(); + if (usesMaterialBatch) + { + BindMainMaterialCodes(); + } Model.HJGL_PipeLineMat pipeLineMat = PipelineMatService.GetPipeLineMat(this.PipeLineMatId); if (pipeLineMat == null) @@ -111,6 +118,19 @@ namespace FineUIPro.Web.HJGL.DataImport } string mainMaterialCode = GetMainMaterialCode(); + bool usesMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); + string materialCode = this.txtMaterialCode.Text.Trim(); + if (!usesMaterialBatch) + { + Model.HJGL_MaterialCodeLib material = MaterialCodeLibService.GetMaterialCodeLib(materialCode); + if (material == null) + { + Alert.ShowInTop("材料编码库不存在此材料编码,请先维护材料主数据!", MessageBoxIcon.Warning); + return; + } + + mainMaterialCode = materialCode; + } if (!string.IsNullOrEmpty(mainMaterialCode) && MaterialCodeLibService.GetMaterialCodeLib(mainMaterialCode) == null) { Alert.ShowInTop("所选材料主编码不存在,请重新选择!", MessageBoxIcon.Warning); @@ -120,7 +140,7 @@ namespace FineUIPro.Web.HJGL.DataImport PipelineMatService.UpdateMaterialCodes( this.PipeLineMatId, mainMaterialCode, - this.txtMaterialCode.Text.Trim()); + materialCode); PipelineMatService.UpdatePipeArea(this.PipeLineMatId, this.drpPipeArea.SelectedValue); ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs index 472eb940..2953f231 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineMatIn.aspx.cs @@ -42,6 +42,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage /// protected void Page_Load(object sender, EventArgs e) { + if (!BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId)) + { + ckIncludeBatch.Checked = false; + ckIncludeBatch.Enabled = false; + ckIncludeBatch.Hidden = true; + } if (!IsPostBack) { this.hdFileName.Text = string.Empty; @@ -117,7 +123,10 @@ namespace FineUIPro.Web.HJGL.WeldingManage if (e.EventArgument == "Confirm_OK") { string rootPath = Server.MapPath("~/"); - string filePath = ckIncludeBatch.Checked ? Const.PipelineMatWithBatchTemplateUrl : Const.PipelineMatTemplateUrl; + bool usesMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); + string filePath = usesMaterialBatch && ckIncludeBatch.Checked + ? Const.PipelineMatWithBatchTemplateUrl + : Const.PipelineMatTemplateUrl; string uploadfilepath = rootPath + filePath; string fileName = Path.GetFileName(filePath); FileInfo info = new FileInfo(uploadfilepath); @@ -137,7 +146,8 @@ namespace FineUIPro.Web.HJGL.WeldingManage { Model.ResponeData responeData = new Model.ResponeData(); List result = new List(); - bool includeBatch = ckIncludeBatch.Checked; + bool usesMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); + bool includeBatch = usesMaterialBatch && ckIncludeBatch.Checked; int minColumnCount = includeBatch ? 8 : 6; matList.Clear(); @@ -239,11 +249,17 @@ namespace FineUIPro.Web.HJGL.WeldingManage } else { - var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.Code == materialCode select x; + var lib = usesMaterialBatch + ? from x in Funs.DB.HJGL_MaterialCodeLib where x.Code == materialCode select x + : from x in Funs.DB.HJGL_MaterialCodeLib where x.MaterialCode == materialCode select x; if (lib.Count() == 0) { result.Add("第" + (i + 2).ToString() + "行,材料编码库不存在此材料编码-" + materialCode + "
"); } + else if (!usesMaterialBatch) + { + item.MaterialCode = lib.First().MaterialCode; + } } } else @@ -515,6 +531,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage } public void AddHJGL_PipeLineMat(List matList) { + bool usesMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); foreach (var item in matList) { var pipeLineMat = from x in Funs.DB.HJGL_PipeLineMat @@ -536,9 +553,9 @@ namespace FineUIPro.Web.HJGL.WeldingManage item.PipeLineMatId = oldPipeLineMat.PipeLineMatId; oldPipeLineMat.Number=item.Number; oldPipeLineMat.MaterialCode2 = item.MaterialCode2; - if (!string.IsNullOrEmpty(item.MaterialCode)) + if (!usesMaterialBatch || !string.IsNullOrEmpty(item.MaterialCode)) { - oldPipeLineMat.MaterialCode = item.MaterialCode; + oldPipeLineMat.MaterialCode = item.MaterialCode; } BLL.PipelineMatService.UpdatePipeLineMat(oldPipeLineMat); } diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs index fa86fc85..4a843798 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs @@ -112,6 +112,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage { tw_PipeMatMatchOutputs = new List(); PipeArea = Request.Params["PipeArea"]; + ConfigureMaterialBatchControls(); BindWarehouseOptions(); dicSeclectPipeLine = new Dictionary(); priorityWeldJoints = new Dictionary>(); @@ -119,6 +120,17 @@ namespace FineUIPro.Web.HJGL.WeldingManage InitTreeMenu(); } + /// + /// 不使用炉批号时,材料编码已在导入阶段确定,无需再次保存或清除主编码。 + /// + private void ConfigureMaterialBatchControls() + { + bool usesMaterialBatchNumber = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); + btnConfirmMaterialCode.Hidden = !usesMaterialBatchNumber; + btnClearMaterialCode.Hidden = !usesMaterialBatchNumber; + Grid1.FindColumn("MatchMaterialCode").Hidden = !usesMaterialBatchNumber; + } + /// /// 绑定当前项目可用仓库,并触发仓库切换后的树刷新。 /// @@ -594,10 +606,21 @@ namespace FineUIPro.Web.HJGL.WeldingManage return new HashSet(); } - var confirmedIds = Funs.DB.HJGL_PipeLineMat - .Where(x => pipeLineMatIds.Contains(x.PipeLineMatId) && x.MaterialCode != null && x.MaterialCode != "") - .Select(x => x.PipeLineMatId) - .ToList(); + bool usesMaterialBatchNumber = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); + var confirmedIds = usesMaterialBatchNumber + ? Funs.DB.HJGL_PipeLineMat + .Where(x => pipeLineMatIds.Contains(x.PipeLineMatId) && x.MaterialCode != null && x.MaterialCode != "") + .Select(x => x.PipeLineMatId) + .ToList() + : Funs.DB.HJGL_PipeLineMat + .Where(x => pipeLineMatIds.Contains(x.PipeLineMatId) + && x.MaterialCode != null + && x.MaterialCode != "" + && x.MaterialCode2 != null + && x.MaterialCode2 != "" + && x.MaterialCode == x.MaterialCode2) + .Select(x => x.PipeLineMatId) + .ToList(); return new HashSet(confirmedIds); } @@ -622,7 +645,9 @@ namespace FineUIPro.Web.HJGL.WeldingManage /// 事件参数。 protected void btnMatchHelp_Click(object sender, EventArgs e) { - Alert.ShowInTop("1、管线绿色为匹配率100%,明细绿色为已反写材料主编码,红色为匹配率小于100%,蓝色为手动优先焊口。
2、库存匹配顺序为手动优先焊口、存在已焊口的续作组件、其他未开工组件。
3、一个焊口可能对应多条材料明细,该焊口全部有效明细已反写材料主编码后才允许一键生成任务单。
4、焊口已进行焊前准备,匹配了焊评才能生成任务单", "说明", MessageBoxIcon.Information); + bool usesMaterialBatchNumber = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); + string confirmedText = usesMaterialBatchNumber ? "已反写材料主编码" : "材料编码与主编码一致"; + Alert.ShowInTop("1、管线绿色为匹配率100%,明细绿色为" + confirmedText + ",红色为匹配率小于100%,蓝色为手动优先焊口。
2、库存匹配顺序为手动优先焊口、存在已焊口的续作组件、其他未开工组件。
3、一个焊口可能对应多条材料明细,该焊口全部有效明细已确认后才允许一键生成任务单。
4、焊口已进行焊前准备,匹配了焊评才能生成任务单", "说明", MessageBoxIcon.Information); } /// diff --git a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx index 4c77b905..282ed4fa 100644 --- a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx +++ b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx @@ -44,6 +44,12 @@ + + + + + + diff --git a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs index 070cc629..44d4af52 100644 --- a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs +++ b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs @@ -51,6 +51,16 @@ namespace FineUIPro.Web.common.ProjectSet ShowNotify("请选择项目!", MessageBoxIcon.Warning); return; } + bool useMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(projectId); + if (useMaterialBatch && !this.ckbUseMaterialBatch.Checked) + { + string warning = BLL.Project_SysSetService.GetDisableMaterialBatchWarning(projectId); + if (warning != "") + { + ShowNotify(warning, MessageBoxIcon.Warning); + return; + } + } #region 云眸 ///通用 var getProject = ProjectService.GetProjectByProjectId(projectId); @@ -172,6 +182,7 @@ namespace FineUIPro.Web.common.ProjectSet } BLL.Project_SysSetService.AddSet(newThickness); } + UpsertMaterialBatchSetting(projectId); if (this.ckbPdms.Checked) { pdms.IsAuto = true; @@ -221,6 +232,28 @@ namespace FineUIPro.Web.common.ProjectSet } } + private void UpsertMaterialBatchSetting(string projectId) + { + var existing = BLL.Project_SysSetService.GetSysSetBySetId(BLL.Project_SysSetService.MaterialBatchSetId, projectId); + if (existing != null) + { + existing.SetName = BLL.Project_SysSetService.MaterialBatchSetName; + existing.IsAuto = this.ckbUseMaterialBatch.Checked; + BLL.Project_SysSetService.UpdateSet(existing); + } + else + { + var newSet = new Model.Project_Sys_Set + { + SetId = BLL.Project_SysSetService.MaterialBatchSetId, + ProjectId = projectId, + SetName = BLL.Project_SysSetService.MaterialBatchSetName, + IsAuto = this.ckbUseMaterialBatch.Checked + }; + BLL.Project_SysSetService.AddSet(newSet); + } + } + private void UpsertValueById(string setId, string projectId, string value, string setName = null) { if (string.IsNullOrEmpty(value)) return; @@ -353,6 +386,7 @@ namespace FineUIPro.Web.common.ProjectSet /// private void Show(string projectId) { + this.ckbUseMaterialBatch.Checked = true; var q = from x in Funs.DB.Project_Sys_Set where x.ProjectId == projectId select x; if (q.Any()) { @@ -365,6 +399,7 @@ namespace FineUIPro.Web.common.ProjectSet SetBatchFromDict(dict, "5"); SetCheckFromDict(dict, "6", this.ckbJointB); SetCheckFromDict(dict, "7", this.ckbThickness); + SetCheckFromDict(dict, BLL.Project_SysSetService.MaterialBatchSetId, this.ckbUseMaterialBatch); SetRadioValueFromDict(dict, "8", this.rblPressUnit, defaultValue: "2"); if (dict.ContainsKey("9")) this.AvevaNetUrl.Text = dict["9"].SetValue; SetCheckFromDict(dict, "10", this.ckPressMustCheckBItem); @@ -446,4 +481,4 @@ namespace FineUIPro.Web.common.ProjectSet } #endregion } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.designer.cs b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.designer.cs index 7fc98aa3..4777b366 100644 --- a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.designer.cs @@ -104,6 +104,15 @@ namespace FineUIPro.Web.common.ProjectSet /// protected global::FineUIPro.CheckBox ckbPdms; + /// + /// ckbUseMaterialBatch 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.CheckBox ckbUseMaterialBatch; + /// /// ckbJointB 控件。 /// diff --git a/SGGL/FineUIPro.Web/common/PageBase.cs b/SGGL/FineUIPro.Web/common/PageBase.cs index 0d1bf8a8..fc84975b 100644 --- a/SGGL/FineUIPro.Web/common/PageBase.cs +++ b/SGGL/FineUIPro.Web/common/PageBase.cs @@ -46,6 +46,23 @@ namespace FineUIPro.Web } } + /// + /// 不使用炉批号时,统一隐藏材料表格中的炉号、批号列。 + /// + protected void ConfigureMaterialBatchColumns(params Grid[] grids) + { + if (Project_SysSetService.UsesMaterialBatchNumber(CurrUser.LoginProjectId)) + { + return; + } + + foreach (var grid in grids) + { + grid.FindColumn("HeatNo").Hidden = true; + grid.FindColumn("BatchNo").Hidden = true; + } + } + #region OnInit protected override void OnInit(EventArgs e) From 719b3435029be630ea03999b671130d11611c228 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Sat, 10 Oct 2026 09:49:46 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix(hjgl):=20=E5=AE=8C=E5=96=84=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=8D=95=E7=94=9F=E6=88=90=E6=9D=A1=E4=BB=B6=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 选中管线无法生成任务单时,按材料确认、焊口条件和既有单据状态提示阻断原因,便于快速定位处理。 --- .../HJGL/WeldingManage/WeldMatMatch.aspx.cs | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs index 4a843798..0fce39d6 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs @@ -533,7 +533,8 @@ namespace FineUIPro.Web.HJGL.WeldingManage private void BindTaskWeldJointSummary(List materialDetails) { // 合计行复用生成任务单的同一套判断,保证页面显示数量和按钮实际生成数量一致。 - int taskWeldJointCount = GetTaskWeldJointIdsFromMaterialDetails(materialDetails).Count; + string failureReason; + int taskWeldJointCount = GetTaskWeldJointIdsFromMaterialDetails(materialDetails, out failureReason).Count; JObject summary = new JObject(); summary.Add("PipelineCode", "合计"); summary.Add("PrefabricatedComponents", "可生成任务单焊口数:"); @@ -647,7 +648,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage { bool usesMaterialBatchNumber = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId); string confirmedText = usesMaterialBatchNumber ? "已反写材料主编码" : "材料编码与主编码一致"; - Alert.ShowInTop("1、管线绿色为匹配率100%,明细绿色为" + confirmedText + ",红色为匹配率小于100%,蓝色为手动优先焊口。
2、库存匹配顺序为手动优先焊口、存在已焊口的续作组件、其他未开工组件。
3、一个焊口可能对应多条材料明细,该焊口全部有效明细已确认后才允许一键生成任务单。
4、焊口已进行焊前准备,匹配了焊评才能生成任务单", "说明", MessageBoxIcon.Information); + Alert.ShowInTop("1、管线绿色为匹配率100%,明细绿色为" + confirmedText + ",红色为匹配率小于100%,蓝色为手动优先焊口。
2、库存匹配顺序为手动优先焊口、存在已焊口的续作组件、其他未开工组件。
3、一个焊口可能对应多条材料明细,该焊口全部有效明细已确认后才允许一键生成任务单。
4、请先在施工基础信息录入中匹配 WPS,确保焊接方法不为空;焊口属性须与工厂预制或现场安装一致,且未生成任务单、焊接日报或焊前准备记录", "说明", MessageBoxIcon.Information); } /// @@ -1091,10 +1092,11 @@ namespace FineUIPro.Web.HJGL.WeldingManage } // 生成任务单按 Grid2 勾选管线批量取焊口,不再要求用户在 Grid1 明细逐条勾选。 - var selectedWeldJointIds = GetTaskWeldJointIdsFromSelectedPipelines(); + string failureReason; + var selectedWeldJointIds = GetTaskWeldJointIdsFromSelectedPipelines(out failureReason); if (!selectedWeldJointIds.Any()) { - ShowNotify("选中管线中没有已反写材料主编码的可生成任务单焊口!", MessageBoxIcon.Warning); + ShowNotify(failureReason, MessageBoxIcon.Warning); return; } @@ -1121,7 +1123,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage { if (selectedWeldJointIds == null || !selectedWeldJointIds.Any()) { - ShowNotify("选中管线中没有已反写材料主编码的可生成任务单焊口!", MessageBoxIcon.Warning); + ShowNotify("没有符合生成条件的焊口,请重新进行材料匹配并检查焊口施工基础信息!", MessageBoxIcon.Warning); return false; } var weldingRods = from x in Funs.DB.Base_Consumables where x.ConsumablesType == WeldingRodConsumablesType select x; @@ -1243,9 +1245,11 @@ namespace FineUIPro.Web.HJGL.WeldingManage /// /// 从 Grid2 选中的管线中收集可生成任务单的焊口ID。 /// + /// 没有可生成焊口时的原因。 /// 可生成任务单的焊口ID集合。 - private HashSet GetTaskWeldJointIdsFromSelectedPipelines() + private HashSet GetTaskWeldJointIdsFromSelectedPipelines(out string failureReason) { + failureReason = "请先在材料匹配列表中选择需要生成任务单的管线!"; // Grid2 的选中管线是任务单生成范围,Grid1 当前展示哪条管线不影响批量生成。 var selectedPipelineIds = Grid2.SelectedRowIDArray == null ? new HashSet() @@ -1259,16 +1263,18 @@ namespace FineUIPro.Web.HJGL.WeldingManage // 生成任务单只校验参与匹配的有效材料明细,零用量材料不参与焊口材料齐套判断。 .Where(x => selectedPipelineIds.Contains(x.PipelineId) && !string.IsNullOrEmpty(x.WeldJointId) && (x.NeedNum ?? 0) > 0) .ToList(); - return GetTaskWeldJointIdsFromMaterialDetails(materialDetails); + return GetTaskWeldJointIdsFromMaterialDetails(materialDetails, out failureReason); } /// /// 根据材料明细判断焊口是否材料齐套且满足任务单生成条件。 /// /// 候选材料匹配明细。 + /// 材料确认或焊口生成条件未满足时的提示。 /// 可生成任务单的焊口ID集合。 - private HashSet GetTaskWeldJointIdsFromMaterialDetails(List materialDetails) + private HashSet GetTaskWeldJointIdsFromMaterialDetails(List materialDetails, out string failureReason) { + failureReason = "选中管线没有有效的待生成任务单材料明细,请检查材料用量及是否已生成任务单或焊接日报!"; if (materialDetails == null || !materialDetails.Any()) { return new HashSet(); @@ -1277,15 +1283,31 @@ namespace FineUIPro.Web.HJGL.WeldingManage materialDetails = materialDetails .Where(x => x != null && !string.IsNullOrEmpty(x.WeldJointId) && (x.NeedNum ?? 0) > 0) .ToList(); - // 同一焊口可能有多条有效材料明细,所有明细都反写材料主编码后才算可生成任务单。 + if (!materialDetails.Any()) + { + return new HashSet(); + } + // 同一焊口可能有多条有效材料明细,所有明细的材料编码都确认后才算可生成任务单。 var confirmedPipeLineMatIds = GetConfirmedPipeLineMatIds(materialDetails); var weldJointIds = materialDetails .GroupBy(x => x.WeldJointId) .Where(x => x.All(y => IsMaterialCodeConfirmed(y, confirmedPipeLineMatIds))) - .Select(x => x.Key); + .Select(x => x.Key) + .ToList(); + if (!weldJointIds.Any()) + { + failureReason = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId) + ? "选中管线的焊口材料主编码尚未全部确认,请先保存材料主编码!" + : "选中管线的焊口材料编码尚未全部确认,请检查管线材料的主编码是否与材料编码一致!"; + return new HashSet(); + } // 材料齐套后还要继续套用任务单视图条件,保证合计数量和点击生成按钮的实际范围一致。 - return new HashSet(GetTaskableWeldJointRows(weldJointIds).Select(x => x.WeldJointId)); + var taskWeldJointIds = new HashSet(GetTaskableWeldJointRows(weldJointIds).Select(x => x.WeldJointId)); + failureReason = taskWeldJointIds.Any() + ? string.Empty + : "选中管线的材料编码已确认,但没有满足任务单生成条件的焊口。请先在“施工基础信息录入”匹配 WPS 并确认焊接方法不为空,同时检查焊口属性、任务单、焊接日报及焊前准备状态!"; + return taskWeldJointIds; } #endregion 按钮事件 From ba73be33705d755b874c4e28bdbccc645ae74525 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Sat, 10 Oct 2026 09:49:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?refactor(project-set):=20=E7=B2=BE=E7=AE=80?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将配置页范围收敛到焊接环境设置,移除不再由此页面维护的配置入口及对应读写逻辑。 --- .../ProjectData/ProjectSysSet.aspx | 87 +----------- .../ProjectData/ProjectSysSet.aspx.cs | 89 ------------- .../ProjectSysSet.aspx.designer.cs | 126 ------------------ 3 files changed, 1 insertion(+), 301 deletions(-) diff --git a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx index 282ed4fa..48865548 100644 --- a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx +++ b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx @@ -14,25 +14,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%-- - --%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs index 44d4af52..8270560d 100644 --- a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs +++ b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using System.Collections.Generic; using FineUIPro; -using System.Text.RegularExpressions; namespace FineUIPro.Web.common.ProjectSet { @@ -61,35 +60,6 @@ namespace FineUIPro.Web.common.ProjectSet return; } } - #region 云眸 - ///通用 - var getProject = ProjectService.GetProjectByProjectId(projectId); - if (getProject != null) - { - getProject.IsYunMou = this.ckbIsYunMou.Checked; - if (this.ckbIsYunMou.Checked) - { - var token = YunMouHelper.getToken(); - string data; - data = Regex.Replace(getProject.ProjectCode, "[^0-9A-Fa-f]", "", RegexOptions.IgnoreCase); - YunMouHelper.addDevicesGroups(getProject.ProjectName, data, token); - var groupId = YunMouHelper.addPermissionGroups(getProject.ProjectName, token); - if (!string.IsNullOrEmpty(groupId)) - { - getProject.YunMouGroupId = groupId; - } - } - else - { - var token = YunMouHelper.getToken(); - string data; - data = Regex.Replace(getProject.ProjectCode, "[^0-9A-Fa-f]", "", RegexOptions.IgnoreCase); - YunMouHelper.deleteDevicesGroups(data, token);//删除设备分组,如果有子节点,可以不删除 - - } - Funs.DB.SubmitChanges(); - } - #endregion #region 焊接 // 焊接 Model.Project_Sys_Set dayReport = BLL.Project_SysSetService.GetSysSetBySetId("1", projectId); @@ -194,21 +164,6 @@ namespace FineUIPro.Web.common.ProjectSet UpsertBatchSetting("5", projectId); ShowNotify("提交成功!", MessageBoxIcon.Success); } - private void SaveColorModelSettings(string projectId) - { - UpsertByName("管线未完成", projectId, this.txtPipelineNOComplete.Text.Trim()); - UpsertByName("管线已完成", projectId, this.txtPipelineComplete.Text.Trim()); - UpsertByName("焊口未完成", projectId, this.drpJointNOCompleteColor.SelectedValue.Trim()); - UpsertByName("焊口已完成", projectId, this.drpJointCompleteColor.SelectedValue.Trim()); - } - - private void SaveQualitySettings(string projectId) - { - UpsertByName("检试验设备到期提醒天数", projectId, this.txtRemindDay.Text.Trim()); - UpsertByName("月报开始日期", projectId, this.txtStarTime.Text.Trim()); - UpsertByName("月报结束日期", projectId, this.txtEndTime.Text.Trim()); - } - #endregion #region Upsert Helpers @@ -277,28 +232,6 @@ namespace FineUIPro.Web.common.ProjectSet } } - private void UpsertByName(string setName, string projectId, string value) - { - if (string.IsNullOrEmpty(value)) return; - var existing = BLL.Project_SysSetService.GetSysSetBySetName(setName, projectId); - if (existing != null) - { - existing.SetValue = value; - BLL.Project_SysSetService.UpdateSet(existing); - } - else - { - var newSet = new Model.Project_Sys_Set - { - SetId = SQLHelper.GetNewID(typeof(Model.Project_Sys_Set)), - ProjectId = projectId, - SetName = setName, - SetValue = value - }; - BLL.Project_SysSetService.AddSet(newSet); - } - } - private void UpsertTrustSetting(string setId, string projectId, string selectedValue) { var existing = BLL.Project_SysSetService.GetSysSetBySetId(setId, projectId); @@ -405,28 +338,6 @@ namespace FineUIPro.Web.common.ProjectSet SetCheckFromDict(dict, "10", this.ckPressMustCheckBItem); if (dict.ContainsKey("11")) this.rbMaterialColorAttribute.SelectedValue = dict["11"].SetValue == "1" ? "1" : "2"; } - var getProject = ProjectService.GetProjectByProjectId(projectId); - if (getProject != null && getProject.IsYunMou == true) - { - this.ckbIsYunMou.Checked = true; - } - //颜色模型设置 - var m1 = BLL.Project_SysSetService.GetSysSetBySetName("管线未完成", this.CurrUser.LoginProjectId); - if (m1 != null) this.txtPipelineNOComplete.Text = m1.SetValue; - var m2 = BLL.Project_SysSetService.GetSysSetBySetName("管线已完成", this.CurrUser.LoginProjectId); - if (m2 != null) this.txtPipelineComplete.Text = m2.SetValue; - var m3 = BLL.Project_SysSetService.GetSysSetBySetName("焊口未完成", this.CurrUser.LoginProjectId); - if (m3 != null) this.drpJointNOCompleteColor.SelectedValue = m3.SetValue; - var m4 = BLL.Project_SysSetService.GetSysSetBySetName("焊口已完成", this.CurrUser.LoginProjectId); - if (m4 != null) this.drpJointCompleteColor.SelectedValue = m4.SetValue; - - ///质量页面呈现 - var c1 = BLL.Project_SysSetService.GetSysSetBySetName("检试验设备到期提醒天数", this.CurrUser.LoginProjectId); - if (c1 != null) this.txtRemindDay.Text = c1.SetValue; - var c2 = BLL.Project_SysSetService.GetSysSetBySetName("月报开始日期", this.CurrUser.LoginProjectId); - if (c2 != null) this.txtStarTime.Text = c2.SetValue; else this.txtStarTime.Text = "25"; - var c3 = BLL.Project_SysSetService.GetSysSetBySetName("月报结束日期", this.CurrUser.LoginProjectId); - if (c3 != null) this.txtEndTime.Text = c3.SetValue; else this.txtEndTime.Text = "24"; } private void SetCheckFromDict(Dictionary dict, string setId, CheckBox checkBox) diff --git a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.designer.cs b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.designer.cs index 4777b366..568d10a7 100644 --- a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.designer.cs @@ -50,33 +50,6 @@ namespace FineUIPro.Web.common.ProjectSet /// protected global::FineUIPro.Region Region2; - /// - /// GroupPanel0 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.GroupPanel GroupPanel0; - - /// - /// Form4 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.Form Form4; - - /// - /// ckbIsYunMou 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.CheckBox ckbIsYunMou; - /// /// GroupPanel2 控件。 /// @@ -275,105 +248,6 @@ namespace FineUIPro.Web.common.ProjectSet /// protected global::FineUIPro.TextBox AvevaNetUrl; - /// - /// GroupPanel3 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.GroupPanel GroupPanel3; - - /// - /// Form3 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.Form Form3; - - /// - /// txtPipelineNOComplete 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.NumberBox txtPipelineNOComplete; - - /// - /// txtPipelineComplete 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.NumberBox txtPipelineComplete; - - /// - /// drpJointNOCompleteColor 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.DropDownList drpJointNOCompleteColor; - - /// - /// drpJointCompleteColor 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.DropDownList drpJointCompleteColor; - - /// - /// GroupPanel1 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.GroupPanel GroupPanel1; - - /// - /// SimpleForm1 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.Form SimpleForm1; - - /// - /// txtRemindDay 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.NumberBox txtRemindDay; - - /// - /// txtStarTime 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.NumberBox txtStarTime; - - /// - /// txtEndTime 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.NumberBox txtEndTime; - /// /// Toolbar1 控件。 /// From ed951cbad0730611ba57218ca54a83f58c224147 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Sat, 10 Oct 2026 09:54:16 +0800 Subject: [PATCH 4/4] 1 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 04b16705..8ce9e4df 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ SGGL/.svn /SGGL/FineUIPro.Web/File/PDF/Pipe /.omo/run-continuation /SGGL/.reasonix +/SGGL/.pi/tasks/01a0fa3e-ad54-77c6-9132-e75b28516df3-22972