diff --git a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs
index 6e8d41b3..94944dea 100644
--- a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs
+++ b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs
@@ -112,13 +112,28 @@ namespace BLL
///
public static List GetMatMatchOutput(List requiredMaterials, string warehouseCode, string projectId, bool matchByMaterialCodeLibCode = false)
{
- var stockFilter = 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(stockFilter).ToList();
-
+ }).ToList();
// 预扣除出库申请单中状态为待审核/已审核的材料数量
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
@@ -145,98 +160,103 @@ namespace BLL
}
}
}
+ return stockList;
+ }
- // 按 Code 匹配时,分别跟踪剩余总需求、可用库存和本轮已使用的主编码。
- 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))
{
- List codeStocks;
- if (!string.IsNullOrEmpty(material.MaterialCode) && stocksByCode.TryGetValue(material.MaterialCode, out codeStocks))
- {
- decimal needNum = material.NeedNum ?? 0;
- decimal remainingRequiredNum = remainingRequiredNumByCode[material.MaterialCode];
- // StockNum 会在每条明细匹配后原地扣减,这里读取的是本轮实时剩余库存。
- var candidates = codeStocks
- .Where(x => (x.StockNum ?? 0) > 0)
+ 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)
+ .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)
- .ToList();
- var usedMaterialCodes = usedMaterialCodesByCode[material.MaterialCode];
+ .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();
- // 前三级共用库存升序:复用已用主编码,其次覆盖剩余总需求,最后覆盖当前明细。
- // 同级优先库存最小的主编码,减少余料;每条明细仍只选择一个主编码。
- stock = candidates
- .FirstOrDefault(x => usedMaterialCodes.Contains(x.PipeLineMatCode) && (x.StockNum ?? 0) >= needNum)
- ?? candidates.FirstOrDefault(x => !usedMaterialCodes.Contains(x.PipeLineMatCode) && (x.StockNum ?? 0) >= remainingRequiredNum)
- ?? candidates.FirstOrDefault(x => !usedMaterialCodes.Contains(x.PipeLineMatCode) && (x.StockNum ?? 0) >= needNum)
- // 都不足时取最大库存;数量相同则优先已用主编码,再按主编码排序。
- ?? 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 = Math.Max(thisMaterialStockNum, 0);
- 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);
}
+ }
- return requiredMaterials;
+ ///
+ /// 回填单条材料匹配结果,并扣减本轮库存快照。
+ ///
+ 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;
+ }
}
///
/// 获取管线匹配率
@@ -313,6 +333,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())
{
@@ -373,8 +394,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());
@@ -393,10 +417,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
@@ -476,7 +508,7 @@ namespace BLL
orderedMaterials.AddRange(orderedPipelineMaterials[id].Where(x => !addedMaterialIds.Contains(x.PipeLineMatId)));
}
- results = GetMatMatchOutput(orderedMaterials, warehouseCode, projectId, true);
+ results = GetMatMatchOutput(orderedMaterials, 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 a422ec34..50c4be4b 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 0cf2e824..f6e4ab63 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 7f266874..269f1d6a 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 a25e0a4f..3490b815 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)
@@ -121,6 +128,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);
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 a6487020..16f32924 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;
+ }
+
///
/// 绑定当前项目可用仓库,并触发仓库切换后的树刷新。
///
@@ -519,7 +531,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", "可生成任务单焊口数:");
@@ -592,10 +605,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);
}
@@ -606,7 +630,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、请先在施工基础信息录入中匹配 WPS,确保焊接方法不为空;焊口属性须与工厂预制或现场安装一致,且未生成任务单、焊接日报或焊前准备记录", "说明", MessageBoxIcon.Information);
}
///
@@ -1049,10 +1075,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;
}
@@ -1077,6 +1104,11 @@ namespace FineUIPro.Web.HJGL.WeldingManage
/// 生成成功返回 true;校验失败或无可生成焊口返回 false。
private bool SaveTask(HashSet selectedWeldJointIds)
{
+ if (selectedWeldJointIds == null || !selectedWeldJointIds.Any())
+ {
+ ShowNotify("没有符合生成条件的焊口,请重新进行材料匹配并检查焊口施工基础信息!", MessageBoxIcon.Warning);
+ return false;
+ }
var weldingRods = from x in Funs.DB.Base_Consumables where x.ConsumablesType == WeldingRodConsumablesType select x;
var weldingWires = from x in Funs.DB.Base_Consumables where x.ConsumablesType == WeldingWireConsumablesType select x;
var taskableWeldJoints = GetTaskableWeldJointRows(selectedWeldJointIds.ToList());
@@ -1188,9 +1220,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()
@@ -1204,16 +1238,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();
@@ -1222,16 +1258,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 => !string.IsNullOrEmpty(y.PipeLineMatId)
- && confirmedPipeLineMatIds.Contains(y.PipeLineMatId)))
- .Select(x => x.Key);
+ .Where(x => x.All(y => !string.IsNullOrEmpty(y.PipeLineMatId) && confirmedPipeLineMatIds.Contains(y.PipeLineMatId)))
+ .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 按钮事件
diff --git a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx
index 4c77b905..48865548 100644
--- a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx
+++ b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx
@@ -14,25 +14,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -126,78 +113,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%--
- --%>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs b/SGGL/FineUIPro.Web/ProjectData/ProjectSysSet.aspx.cs
index 070cc629..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
{
@@ -51,35 +50,16 @@ namespace FineUIPro.Web.common.ProjectSet
ShowNotify("请选择项目!", MessageBoxIcon.Warning);
return;
}
- #region 云眸
- ///通用
- var getProject = ProjectService.GetProjectByProjectId(projectId);
- if (getProject != null)
+ bool useMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(projectId);
+ if (useMaterialBatch && !this.ckbUseMaterialBatch.Checked)
{
- getProject.IsYunMou = this.ckbIsYunMou.Checked;
- if (this.ckbIsYunMou.Checked)
+ string warning = BLL.Project_SysSetService.GetDisableMaterialBatchWarning(projectId);
+ if (warning != "")
{
- 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;
- }
+ ShowNotify(warning, MessageBoxIcon.Warning);
+ return;
}
- 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);
@@ -172,6 +152,7 @@ namespace FineUIPro.Web.common.ProjectSet
}
BLL.Project_SysSetService.AddSet(newThickness);
}
+ UpsertMaterialBatchSetting(projectId);
if (this.ckbPdms.Checked)
{
pdms.IsAuto = true;
@@ -183,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
@@ -221,6 +187,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;
@@ -244,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);
@@ -353,6 +319,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,33 +332,12 @@ 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);
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)
@@ -446,4 +392,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..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 控件。
///
@@ -104,6 +77,15 @@ namespace FineUIPro.Web.common.ProjectSet
///
protected global::FineUIPro.CheckBox ckbPdms;
+ ///
+ /// ckbUseMaterialBatch 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.CheckBox ckbUseMaterialBatch;
+
///
/// ckbJointB 控件。
///
@@ -266,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 控件。
///
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)