diff --git a/DataBase/版本日志/SGGLDB_V2026-06-24_材料仓库主键关联修正.sql b/DataBase/版本日志/SGGLDB_V2026-06-24_材料仓库主键关联修正.sql new file mode 100644 index 00000000..9ce5a161 --- /dev/null +++ b/DataBase/版本日志/SGGLDB_V2026-06-24_材料仓库主键关联修正.sql @@ -0,0 +1,162 @@ +/* +用途: +1. 为材料出入库和库存表补充 WarehouseId 字段。 +2. 将历史 WarehouseCode 中保存的仓库名称/主键统一回填到 WarehouseId。 +3. 库存表按 项目+材料主编码+仓库主键 合并重复库存。 + +执行前建议先备份数据库,并先执行最后的“未匹配检查”确认是否存在重名或缺失仓库。 +*/ + +SET XACT_ABORT ON; +BEGIN TRAN; + +IF COL_LENGTH('dbo.Tw_InOutPlanMaster', 'WarehouseId') IS NULL +BEGIN + ALTER TABLE dbo.Tw_InOutPlanMaster ADD WarehouseId NVARCHAR(50) NULL; +END; + +IF COL_LENGTH('dbo.Tw_InputMaster', 'WarehouseId') IS NULL +BEGIN + ALTER TABLE dbo.Tw_InputMaster ADD WarehouseId NVARCHAR(50) NULL; +END; + +IF COL_LENGTH('dbo.Tw_OutputMaster', 'WarehouseId') IS NULL +BEGIN + ALTER TABLE dbo.Tw_OutputMaster ADD WarehouseId NVARCHAR(50) NULL; +END; + +IF COL_LENGTH('dbo.Tw_MaterialStock', 'WarehouseId') IS NULL +BEGIN + ALTER TABLE dbo.Tw_MaterialStock ADD WarehouseId NVARCHAR(50) NULL; +END; + +IF EXISTS ( + SELECT 1 + FROM dbo.Base_Warehouse + GROUP BY ProjectId, WarehouseName + HAVING COUNT(1) > 1 +) +BEGIN + THROW 51000, N'同一项目存在重名仓库,历史 WarehouseCode 名称数据无法唯一回填,请先处理 Base_Warehouse 重名数据。', 1; +END; + +/* 历史数据中 WarehouseCode 可能保存仓库名称,也可能已经保存 WarehouseId,这里两种都兼容。 */ +UPDATE m +SET + m.WarehouseId = w.WarehouseId, + m.WarehouseCode = w.WarehouseName +FROM dbo.Tw_InOutPlanMaster AS m +INNER JOIN dbo.Base_Warehouse AS w + ON w.ProjectId = m.ProjectId + AND (w.WarehouseId = m.WarehouseCode OR w.WarehouseName = m.WarehouseCode OR w.WarehouseId = m.WarehouseId) +WHERE ISNULL(m.WarehouseId, '') <> w.WarehouseId + OR ISNULL(m.WarehouseCode, '') <> w.WarehouseName; + +UPDATE m +SET + m.WarehouseId = w.WarehouseId, + m.WarehouseCode = w.WarehouseName +FROM dbo.Tw_InputMaster AS m +INNER JOIN dbo.Base_Warehouse AS w + ON w.ProjectId = m.ProjectId + AND (w.WarehouseId = m.WarehouseCode OR w.WarehouseName = m.WarehouseCode OR w.WarehouseId = m.WarehouseId) +WHERE ISNULL(m.WarehouseId, '') <> w.WarehouseId + OR ISNULL(m.WarehouseCode, '') <> w.WarehouseName; + +UPDATE m +SET + m.WarehouseId = w.WarehouseId, + m.WarehouseCode = w.WarehouseName +FROM dbo.Tw_OutputMaster AS m +INNER JOIN dbo.Base_Warehouse AS w + ON w.ProjectId = m.ProjectId + AND (w.WarehouseId = m.WarehouseCode OR w.WarehouseName = m.WarehouseCode OR w.WarehouseId = m.WarehouseId) +WHERE ISNULL(m.WarehouseId, '') <> w.WarehouseId + OR ISNULL(m.WarehouseCode, '') <> w.WarehouseName; + +UPDATE s +SET + s.WarehouseId = w.WarehouseId, + s.WarehouseCode = w.WarehouseName +FROM dbo.Tw_MaterialStock AS s +INNER JOIN dbo.Base_Warehouse AS w + ON w.ProjectId = s.ProjectId + AND (w.WarehouseId = s.WarehouseCode OR w.WarehouseName = s.WarehouseCode OR w.WarehouseId = s.WarehouseId) +WHERE ISNULL(s.WarehouseId, '') <> w.WarehouseId + OR ISNULL(s.WarehouseCode, '') <> w.WarehouseName; + +/* 回填后,历史上同一仓库可能因“名称”和“主键”各有一条库存记录,这里合并为一条。 */ +IF OBJECT_ID('tempdb..#StockMerge') IS NOT NULL +BEGIN + DROP TABLE #StockMerge; +END; + +SELECT + ProjectId, + PipeLineMatCode, + WarehouseId, + MIN(Id) AS KeepId, + SUM(ISNULL(StockNum, 0)) AS TotalStock +INTO #StockMerge +FROM dbo.Tw_MaterialStock +WHERE WarehouseId IS NOT NULL +GROUP BY ProjectId, PipeLineMatCode, WarehouseId +HAVING COUNT(1) > 1; + +UPDATE s +SET s.StockNum = m.TotalStock +FROM dbo.Tw_MaterialStock AS s +INNER JOIN #StockMerge AS m ON m.KeepId = s.Id; + +DELETE s +FROM dbo.Tw_MaterialStock AS s +INNER JOIN #StockMerge AS m + ON m.ProjectId = s.ProjectId + AND m.PipeLineMatCode = s.PipeLineMatCode + AND m.WarehouseId = s.WarehouseId + AND s.Id <> m.KeepId; + +IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_Tw_InOutPlanMaster_Project_WarehouseId' AND object_id = OBJECT_ID('dbo.Tw_InOutPlanMaster')) +BEGIN + CREATE INDEX IX_Tw_InOutPlanMaster_Project_WarehouseId ON dbo.Tw_InOutPlanMaster(ProjectId, WarehouseId); +END; + +IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_Tw_InputMaster_Project_WarehouseId' AND object_id = OBJECT_ID('dbo.Tw_InputMaster')) +BEGIN + CREATE INDEX IX_Tw_InputMaster_Project_WarehouseId ON dbo.Tw_InputMaster(ProjectId, WarehouseId); +END; + +IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_Tw_OutputMaster_Project_WarehouseId' AND object_id = OBJECT_ID('dbo.Tw_OutputMaster')) +BEGIN + CREATE INDEX IX_Tw_OutputMaster_Project_WarehouseId ON dbo.Tw_OutputMaster(ProjectId, WarehouseId); +END; + +IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_Tw_MaterialStock_Project_Material_WarehouseId' AND object_id = OBJECT_ID('dbo.Tw_MaterialStock')) +BEGIN + CREATE INDEX IX_Tw_MaterialStock_Project_Material_WarehouseId ON dbo.Tw_MaterialStock(ProjectId, PipeLineMatCode, WarehouseId); +END; + +COMMIT TRAN; + +/* 未匹配检查:这些记录需要人工确认仓库名称是否错误、是否重名或是否缺少 Base_Warehouse 数据。 */ +SELECT 'Tw_InOutPlanMaster' AS TableName, Id, ProjectId, WarehouseCode, WarehouseId +FROM dbo.Tw_InOutPlanMaster +WHERE ISNULL(WarehouseCode, '') <> '' AND ISNULL(WarehouseId, '') = '' +UNION ALL +SELECT 'Tw_InputMaster' AS TableName, Id, ProjectId, WarehouseCode, WarehouseId +FROM dbo.Tw_InputMaster +WHERE ISNULL(WarehouseCode, '') <> '' AND ISNULL(WarehouseId, '') = '' +UNION ALL +SELECT 'Tw_OutputMaster' AS TableName, Id, ProjectId, WarehouseCode, WarehouseId +FROM dbo.Tw_OutputMaster +WHERE ISNULL(WarehouseCode, '') <> '' AND ISNULL(WarehouseId, '') = '' +UNION ALL +SELECT 'Tw_MaterialStock' AS TableName, Id, ProjectId, WarehouseCode, WarehouseId +FROM dbo.Tw_MaterialStock +WHERE ISNULL(WarehouseCode, '') <> '' AND ISNULL(WarehouseId, '') = ''; + +/* 仓库重名检查:如果同一项目有重名仓库,历史名称数据无法唯一回填,需要先处理重名。 */ +SELECT ProjectId, WarehouseName, COUNT(1) AS RepeatCount +FROM dbo.Base_Warehouse +GROUP BY ProjectId, WarehouseName +HAVING COUNT(1) > 1; diff --git a/SGGL/BLL/CLGL/TwAntiCorrosionTrustService.cs b/SGGL/BLL/CLGL/TwAntiCorrosionTrustService.cs index 4cc318ec..5ebf0b2f 100644 --- a/SGGL/BLL/CLGL/TwAntiCorrosionTrustService.cs +++ b/SGGL/BLL/CLGL/TwAntiCorrosionTrustService.cs @@ -119,7 +119,9 @@ namespace BLL ProjectId = om.ProjectId, CusBillCode = om.CusBillCode, InOutPlanMasterId = om.InOutPlanMasterId, + WarehouseId = om.WarehouseId, WarehouseCode = om.WarehouseCode, + WarehouseName = om.WarehouseCode, Source = om.Source, TypeInt = om.TypeInt, State = om.State, @@ -160,7 +162,9 @@ namespace BLL ProjectId = om.ProjectId, CusBillCode = om.CusBillCode, InOutPlanMasterId = om.InOutPlanMasterId, + WarehouseId = om.WarehouseId, WarehouseCode = om.WarehouseCode, + WarehouseName = om.WarehouseCode, Source = om.Source, TypeInt = om.TypeInt, State = om.State, diff --git a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs index e515799d..71b767b2 100644 --- a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs +++ b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs @@ -13,7 +13,10 @@ namespace BLL { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - string WarehouseId = Base_WarehouseService.GetWarehouseList(projectid).Where(x => x.WarehouseName == WarehouseCode).Select(x => x.WarehouseId).FirstOrDefault(); + string WarehouseId = Base_WarehouseService.GetWarehouseList(projectid) + .Where(x => x.WarehouseId == WarehouseCode || x.WarehouseName == WarehouseCode) + .Select(x => x.WarehouseId) + .FirstOrDefault(); ///所需材料数量列表 var NeedOutMateriaList = from x in db.HJGL_PipeLineMat join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode @@ -30,7 +33,7 @@ namespace BLL var RealInMateriaList = (from x in db.Tw_InputDetail join master in db.Tw_InputMaster on x.InputMasterId equals master.Id join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode - where master.ProjectId == projectid && master.WarehouseCode == WarehouseCode + where master.ProjectId == projectid && master.WarehouseId == WarehouseId group x by x.MaterialCode into g where (string.IsNullOrEmpty(materialCode) || g.Key.Contains(materialCode)) @@ -41,7 +44,7 @@ namespace BLL }).ToList(); //库存数量 var tw_MaterialStock = (from x in db.Tw_MaterialStock - where x.WarehouseCode == WarehouseCode && x.ProjectId == projectid + where x.WarehouseId == WarehouseId && x.ProjectId == projectid select x).ToList(); var needMateriaList = NeedOutMateriaList.ToList(); @@ -98,7 +101,7 @@ namespace BLL { Tw_MaterialStockOutput twMaterialStockOutput = new Tw_MaterialStockOutput { - WarehouseCode = warehouseCode, + WarehouseId = warehouseCode, ProjectId = projectId }; var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStockOutput).ToList();//获取库存列表 @@ -110,7 +113,7 @@ namespace BLL join master in db.Tw_InOutPlanMaster on detail.InOutPlanMasterId equals master.Id where master.InOutType == (int)TwConst.InOutType.出库 && (master.State == (int)TwConst.State.待审核 || master.State == (int)TwConst.State.已审核) - && master.WarehouseCode == warehouseCode + && master.WarehouseId == warehouseCode && master.ProjectId == projectId group detail by detail.MaterialCode into g select new @@ -178,7 +181,7 @@ namespace BLL List pipelineIds = new List(); pipelineIds.Add(pipelineId); var pipelineModel = PipelineService.GetPipelineByPipelineId(pipelineId); - string warehouseCode = BLL.Base_WarehouseService.GetWarehouseByWarehouseId(PipelineService.GetPipelineByPipelineId(pipelineModel.PipelineId).WarehouseId).WarehouseName; + string warehouseCode = PipelineService.GetPipelineByPipelineId(pipelineModel.PipelineId).WarehouseId; var PipeMatMatch = GetPipeMatMatch(pipelineModel.ProjectId, pipelineIds, warehouseCode); var pipeMatchRate = GetPipeMatch(PipeMatMatch).FirstOrDefault(x => x.PipelineId == pipelineId); return pipeMatchRate?.MatchRate; @@ -240,7 +243,7 @@ namespace BLL } var masterModle = db.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == outPlanMasterId); - results = GetMatMatchOutput(requiredMaterials, masterModle.WarehouseCode, masterModle.ProjectId); + results = GetMatMatchOutput(requiredMaterials, masterModle.WarehouseId, masterModle.ProjectId); return results; } diff --git a/SGGL/BLL/CLGL/TwInOutplandetailRelationService.cs b/SGGL/BLL/CLGL/TwInOutplandetailRelationService.cs index 5f05d8c3..741d9a9c 100644 --- a/SGGL/BLL/CLGL/TwInOutplandetailRelationService.cs +++ b/SGGL/BLL/CLGL/TwInOutplandetailRelationService.cs @@ -82,12 +82,12 @@ namespace BLL return Funs.DB.Tw_InOutPlanDetail_Relation.FirstOrDefault(x => x.Id == Id); } - public static Model.Tw_InOutPlanDetail_Relation GetByPipelineId(string pipelineId, string WarehouseCode) + public static Model.Tw_InOutPlanDetail_Relation GetByPipelineId(string pipelineId, string warehouseId) { int typeInt = (int)TwConst.TypeInt.散件出库; var q = from x in Funs.DB.Tw_InOutPlanDetail_Relation join y in Funs.DB.Tw_InOutPlanMaster on x.InOutPlanMasterId equals y.Id - where x.PipelineId == pipelineId && y.WarehouseCode == WarehouseCode && y.TypeInt != typeInt + where x.PipelineId == pipelineId && y.WarehouseId == warehouseId && y.TypeInt != typeInt select x; return q.FirstOrDefault(); } diff --git a/SGGL/BLL/CLGL/TwInOutplandetailService.cs b/SGGL/BLL/CLGL/TwInOutplandetailService.cs index 5bfbeea7..912e7057 100644 --- a/SGGL/BLL/CLGL/TwInOutplandetailService.cs +++ b/SGGL/BLL/CLGL/TwInOutplandetailService.cs @@ -29,7 +29,7 @@ namespace BLL from mat in mm.DefaultIfEmpty() join master in Funs.DB.Tw_InOutPlanMaster on x.InOutPlanMasterId equals master.Id into masters from master in masters.DefaultIfEmpty() - join stock in Funs.DB.Tw_MaterialStock on new { x.MaterialCode, master.WarehouseCode, master.ProjectId } equals new { MaterialCode = stock.PipeLineMatCode, stock.WarehouseCode, stock.ProjectId } into st + join stock in Funs.DB.Tw_MaterialStock on new { x.MaterialCode, master.WarehouseId, master.ProjectId } equals new { MaterialCode = stock.PipeLineMatCode, stock.WarehouseId, stock.ProjectId } into st from stock in st.DefaultIfEmpty() where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && diff --git a/SGGL/BLL/CLGL/TwInOutplanmasterService.cs b/SGGL/BLL/CLGL/TwInOutplanmasterService.cs index ad3fbe48..5f10d815 100644 --- a/SGGL/BLL/CLGL/TwInOutplanmasterService.cs +++ b/SGGL/BLL/CLGL/TwInOutplanmasterService.cs @@ -40,12 +40,15 @@ namespace BLL from warehouseperson in warehousepersons.DefaultIfEmpty() join unit in Funs.DB.Base_Unit on x.ReqUnitId equals unit.UnitId into units from unit in units.DefaultIfEmpty() + join warehouse in Funs.DB.Base_Warehouse on x.WarehouseId equals warehouse.WarehouseId into warehouses + from warehouse in warehouses.DefaultIfEmpty() orderby x.CreateDate descending where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && (string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId)) && (string.IsNullOrEmpty(table.CusBillCode) || x.CusBillCode.Contains(table.CusBillCode)) && - (string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode)) && + (string.IsNullOrEmpty(table.WarehouseId) || x.WarehouseId == table.WarehouseId) && + (string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode) || x.WarehouseId.Contains(table.WarehouseCode)) && (string.IsNullOrEmpty(table.CreateMan) || x.CreateMan.Contains(table.CreateMan)) && (string.IsNullOrEmpty(table.OutputMasterId) || x.OutputMasterId.Contains(table.OutputMasterId)) && (string.IsNullOrEmpty(table.ReqUnitId) || x.ReqUnitId.Contains(table.ReqUnitId)) && @@ -60,7 +63,9 @@ namespace BLL Id = x.Id, ProjectId = x.ProjectId, CusBillCode = x.CusBillCode, - WarehouseCode = x.WarehouseCode, + WarehouseId = x.WarehouseId, + WarehouseCode = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName, + WarehouseName = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName, Source = x.Source, InOutType = x.InOutType, TypeInt = x.TypeInt, @@ -117,7 +122,9 @@ namespace BLL Id = x.Id, ProjectId = x.ProjectId, CusBillCode = x.CusBillCode, + WarehouseId = x.WarehouseId, WarehouseCode = x.WarehouseCode, + WarehouseName = x.WarehouseName, Source = x.Source, InOutType = x.InOutType, TypeInt = x.TypeInt, @@ -167,7 +174,9 @@ namespace BLL Id = x.Id, ProjectId = x.ProjectId, CusBillCode = x.CusBillCode, + WarehouseId = x.WarehouseId, WarehouseCode = x.WarehouseCode, + WarehouseName = x.WarehouseName, Source = x.Source, InOutType = x.InOutType, TypeInt = x.TypeInt, @@ -268,11 +277,13 @@ namespace BLL responeData.message = "导入数据为空!"; return responeData; } - var warehouseCodeList = temeplateDtoIns.Select(x => x.WarehouseCode).Distinct().ToList(); //获取导入文件的仓库编号 + var warehouseList = Base_WarehouseService.GetWarehouseList(projectid); + var warehouseCodeList = temeplateDtoIns.Select(x => CleanImportText(x.WarehouseCode)).Distinct().ToList(); //获取导入文件的仓库 string errorWarehouseCode = ""; foreach (var item in warehouseCodeList) { - if (!Base_WarehouseService.GetWarehouseList(projectid).Select(x => x.WarehouseName == item).Any()) + var warehouse = warehouseList.FirstOrDefault(x => x.WarehouseId == item || x.WarehouseName == item); + if (warehouse == null) { errorWarehouseCode += item + ","; } @@ -287,6 +298,15 @@ namespace BLL return responeData; //} } + foreach (var item in temeplateDtoIns) + { + var warehouse = warehouseList.FirstOrDefault(x => x.WarehouseId == CleanImportText(item.WarehouseCode) || x.WarehouseName == CleanImportText(item.WarehouseCode)); + if (warehouse != null) + { + // 导入模板仍允许填仓库名称,入库申请保存时同时固化仓库主键,后续改名不影响关联。 + item.WarehouseCode = warehouse.WarehouseName; + } + } var typeString = temeplateDtoIns.Select(x => x.TypeString).Distinct().ToList(); //获取导入文件的类型 if (typeString.Where(x => string.IsNullOrEmpty(x)).Count() > 0) { @@ -362,8 +382,11 @@ namespace BLL //通过映射实体赋值 var twInOutPlanMaster = mapper.Map(CusBillCodeDtoIns).FirstOrDefault(); var twInOutPlanDetails = mapperDetail.Map(CusBillCodeDtoIns.Where(x => !string.IsNullOrEmpty(x.MaterialCode) && !string.IsNullOrEmpty(x.PlanNum)).ToList()); + var importWarehouse = warehouseList.FirstOrDefault(x => x.WarehouseName == FirstCusBillCodeDtoIns.WarehouseCode); twInOutPlanMaster.Id = SQLHelper.GetNewID(); + twInOutPlanMaster.WarehouseId = importWarehouse?.WarehouseId; + twInOutPlanMaster.WarehouseCode = importWarehouse?.WarehouseName ?? twInOutPlanMaster.WarehouseCode; twInOutPlanMaster.InOutType = (int)TwConst.InOutType.入库; twInOutPlanMaster.State = (int)TwConst.State.待审核; @@ -457,7 +480,8 @@ namespace BLL errors.Add("第" + rowIndex + "行,仓库,此项为必填项!"); continue; } - if (!warehouseList.Any(x => x.WarehouseName == rowWarehouseCode)) + var rowWarehouse = warehouseList.FirstOrDefault(x => x.WarehouseId == rowWarehouseCode || x.WarehouseName == rowWarehouseCode); + if (rowWarehouse == null) { errors.Add("第" + rowIndex + "行,仓库[" + rowWarehouseCode + "]不存在!"); continue; @@ -499,16 +523,17 @@ namespace BLL continue; } - var stock = allStock.FirstOrDefault(x => x.WarehouseCode == rowWarehouseCode && x.Code == materialCode && x.HeatNo == heatNo && x.BatchNo == batchNo); + var stock = allStock.FirstOrDefault(x => x.WarehouseId == rowWarehouse.WarehouseId && x.Code == materialCode && x.HeatNo == heatNo && x.BatchNo == batchNo); if (stock == null) { - errors.Add("第" + rowIndex + "行,仓库[" + rowWarehouseCode + "]库存中不存在此材料编码/炉号/批号-" + materialCode + "/" + heatNo + "/" + batchNo); + errors.Add("第" + rowIndex + "行,仓库[" + rowWarehouse.WarehouseName + "]库存中不存在此材料编码/炉号/批号-" + materialCode + "/" + heatNo + "/" + batchNo); continue; } detailRows.Add(new Tw_OutHistoryImportRow { - WarehouseCode = stock.WarehouseCode, + WarehouseId = rowWarehouse.WarehouseId, + WarehouseCode = rowWarehouse.WarehouseName, MaterialCode = stock.PipeLineMatCode, Code = stock.Code, HeatNo = stock.HeatNo, @@ -533,13 +558,14 @@ namespace BLL return responeData; } - var stockErrors = detailRows.GroupBy(x => new { x.WarehouseCode, x.MaterialCode }) + var stockErrors = detailRows.GroupBy(x => new { x.WarehouseId, x.WarehouseCode, x.MaterialCode }) .Select(x => new { + x.Key.WarehouseId, x.Key.WarehouseCode, x.Key.MaterialCode, Num = x.Sum(y => y.Num), - Stock = allStock.FirstOrDefault(y => y.WarehouseCode == x.Key.WarehouseCode && y.PipeLineMatCode == x.Key.MaterialCode) + 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) @@ -555,6 +581,7 @@ namespace BLL int planCount = 0; foreach (var group in detailRows.GroupBy(x => new { + x.WarehouseId, x.WarehouseCode, x.ReqUnitId, OutputDate = x.OutputDate.Date, @@ -568,6 +595,7 @@ namespace BLL Id = planId, ProjectId = projectId, CusBillCode = cusBillCode, + WarehouseId = group.Key.WarehouseId, WarehouseCode = group.Key.WarehouseCode, WeldTaskId = unitWorkId, Source = 2, @@ -667,13 +695,15 @@ namespace BLL } public static void Add(Model.Tw_InOutPlanMaster newtable) { + var warehouseName = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId); Model.Tw_InOutPlanMaster table = new Model.Tw_InOutPlanMaster { Id = newtable.Id, ProjectId = newtable.ProjectId, CusBillCode = newtable.CusBillCode, - WarehouseCode = newtable.WarehouseCode, + WarehouseId = newtable.WarehouseId, + WarehouseCode = warehouseName ?? newtable.WarehouseCode, Source = newtable.Source, Category = newtable.Category, InOutType = newtable.InOutType, @@ -704,7 +734,8 @@ namespace BLL table.Id = newtable.Id; table.ProjectId = newtable.ProjectId; table.CusBillCode = newtable.CusBillCode; - table.WarehouseCode = newtable.WarehouseCode; + table.WarehouseId = newtable.WarehouseId; + table.WarehouseCode = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId) ?? newtable.WarehouseCode; table.Category = newtable.Category; table.Source = newtable.Source; table.InOutType = newtable.InOutType; @@ -810,6 +841,7 @@ namespace BLL Id = Guid.NewGuid().ToString(), OutputMasterId = outMaster.Id, ProjectId = outMaster.ProjectId, + WarehouseId = outMaster.WarehouseId, WarehouseCode = outMaster.WarehouseCode, Source = 2, Category = outMaster.Category, @@ -895,7 +927,7 @@ namespace BLL public static Dictionary GetWarehouseCode(string projectId) { - var q = Base_WarehouseService.GetWarehouseList(projectId).Distinct().ToDictionary(x => x.WarehouseName, x => x.WarehouseName); + var q = Base_WarehouseService.GetWarehouseList(projectId).Distinct().ToDictionary(x => x.WarehouseName, x => x.WarehouseId); return q; } public static string GetDataInCusBillCode(string projectid, string unitcode, string typeString, string unitWorkCode = "", string Category = "") @@ -1039,6 +1071,8 @@ namespace BLL var outPlanDetailListPiece = outMateriaList.Where(x => x.MaterialName.Contains("个"));//管件 var outPlanDetailListOthere = outMateriaList.Where(x => x.MaterialName.Contains("米"));//管段 var weldTaskCode = WeldTaskService.GetWeldTaskById(weldTask.WeldTaskId)?.TaskCode; + var taskPipeline = PipelineService.GetPipelineByPipelineId(weldTask.PipelineId); + var taskWarehouse = BLL.Base_WarehouseService.GetWarehouseByWarehouseId(taskPipeline?.WarehouseId); if (outPlanDetailListPiece.Any()) { Model.Tw_InOutPlanMaster table = new Model.Tw_InOutPlanMaster @@ -1047,7 +1081,8 @@ namespace BLL ProjectId = weldTask.ProjectId, // CusBillCode = string.Format("{0:yyyyMMdd}", DateTime.Now) + UnitService.GetUnitCodeByUnitId(weldTask.UnitId) + "-" + UnitWorkService.getUnitWorkByUnitWorkId(weldTask.UnitWorkId)?.UnitWorkCode + "AP-PF01", CusBillCode = TwInOutplanmasterService.GetCusBillCodeByTaskCode(weldTaskCode, TwConst.TypeInt.领料出库, TwConst.Category.管件), - WarehouseCode = BLL.Base_WarehouseService.GetWarehouseByWarehouseId(PipelineService.GetPipelineByPipelineId(weldTask.PipelineId).WarehouseId).WarehouseName, + WarehouseId = taskWarehouse?.WarehouseId, + WarehouseCode = taskWarehouse?.WarehouseName, Source = 1, InOutType = (int)TwConst.InOutType.出库, TypeInt = (int)TwConst.TypeInt.领料出库, @@ -1088,7 +1123,8 @@ namespace BLL Id = Guid.NewGuid().ToString(), ProjectId = weldTask.ProjectId, CusBillCode = TwInOutplanmasterService.GetCusBillCodeByTaskCode(weldTaskCode, TwConst.TypeInt.领料出库, TwConst.Category.管段), - WarehouseCode = BLL.Base_WarehouseService.GetWarehouseByWarehouseId(PipelineService.GetPipelineByPipelineId(weldTask.PipelineId).WarehouseId).WarehouseName, + WarehouseId = taskWarehouse?.WarehouseId, + WarehouseCode = taskWarehouse?.WarehouseName, Source = 1, InOutType = (int)TwConst.InOutType.出库, TypeInt = (int)TwConst.TypeInt.领料出库, diff --git a/SGGL/BLL/CLGL/TwInputmasterService.cs b/SGGL/BLL/CLGL/TwInputmasterService.cs index e835407a..49c33281 100644 --- a/SGGL/BLL/CLGL/TwInputmasterService.cs +++ b/SGGL/BLL/CLGL/TwInputmasterService.cs @@ -31,12 +31,15 @@ namespace BLL from warehouseperson in warehousepersons.DefaultIfEmpty() join unit in Funs.DB.Base_Unit on x.ReqUnitId equals unit.UnitId into units from unit in units.DefaultIfEmpty() + join warehouse in Funs.DB.Base_Warehouse on x.WarehouseId equals warehouse.WarehouseId into warehouses + from warehouse in warehouses.DefaultIfEmpty() where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && (string.IsNullOrEmpty(table.InOutPlanMasterId) || x.InOutPlanMasterId.Contains(table.InOutPlanMasterId)) && (string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId)) && (string.IsNullOrEmpty(table.CusBillCode) || x.CusBillCode.Contains(table.CusBillCode)) && - (string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode)) && + (string.IsNullOrEmpty(table.WarehouseId) || x.WarehouseId == table.WarehouseId) && + (string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode) || x.WarehouseId.Contains(table.WarehouseCode)) && (string.IsNullOrEmpty(table.CreateMan) || x.CreateMan.Contains(table.CreateMan)) && (string.IsNullOrEmpty(table.ReqUnitId) || x.ReqUnitId.Contains(table.ReqUnitId)) && (table.TypeInt == null || x.TypeInt == table.TypeInt) && @@ -48,7 +51,9 @@ namespace BLL ProjectId = x.ProjectId, CusBillCode = x.CusBillCode, InOutPlanMasterId = x.InOutPlanMasterId, - WarehouseCode = x.WarehouseCode, + WarehouseId = x.WarehouseId, + WarehouseCode = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName, + WarehouseName = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName, Source = x.Source, Category = x.Category, TypeInt = x.TypeInt, @@ -93,7 +98,9 @@ namespace BLL ProjectId = x.ProjectId, CusBillCode = x.CusBillCode, InOutPlanMasterId = x.InOutPlanMasterId, + WarehouseId = x.WarehouseId, WarehouseCode = x.WarehouseCode, + WarehouseName = x.WarehouseName, Source = x.Source, TypeInt = x.TypeInt, State = x.State, @@ -133,7 +140,9 @@ namespace BLL ProjectId = x.ProjectId, CusBillCode = x.CusBillCode, InOutPlanMasterId = x.InOutPlanMasterId, + WarehouseId = x.WarehouseId, WarehouseCode = x.WarehouseCode, + WarehouseName = x.WarehouseName, Source = x.Source, TypeInt = x.TypeInt, State = x.State, @@ -172,7 +181,8 @@ namespace BLL ProjectId = newtable.ProjectId, InOutPlanMasterId = newtable.InOutPlanMasterId, CusBillCode = newtable.CusBillCode, - WarehouseCode = newtable.WarehouseCode, + WarehouseId = newtable.WarehouseId, + WarehouseCode = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId) ?? newtable.WarehouseCode, Category = newtable.Category, Source = newtable.Source, TypeInt = newtable.TypeInt, @@ -200,7 +210,8 @@ namespace BLL table.ProjectId = newtable.ProjectId; table.InOutPlanMasterId = newtable.InOutPlanMasterId; table.CusBillCode = newtable.CusBillCode; - table.WarehouseCode = newtable.WarehouseCode; + table.WarehouseId = newtable.WarehouseId; + table.WarehouseCode = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId) ?? newtable.WarehouseCode; table.Category = newtable.Category; table.Source = newtable.Source; table.TypeInt = newtable.TypeInt; @@ -258,6 +269,7 @@ namespace BLL Id = Guid.NewGuid().ToString(), InOutPlanMasterId = plan.Id, ProjectId = plan.ProjectId, + WarehouseId = plan.WarehouseId, WarehouseCode = plan.WarehouseCode, Source = plan.Source, TypeInt = plan.TypeInt, @@ -289,7 +301,7 @@ namespace BLL }; TwInputdetailService.Add(detailTable); TwInputdetailBarCodeService.AddByInputDetail(master, detailTable); - TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseCode, TwConst.InOutType.入库, detailTable.ActNum); + TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseId, TwConst.InOutType.入库, detailTable.ActNum); } var planTable = TwInOutplanmasterService.GetById(plan.Id); @@ -330,7 +342,7 @@ namespace BLL { TwInputdetailService.DeleteById(detail.Id); //撤销入库,即减去库存 - TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseCode, TwConst.InOutType.出库, detail.ActNum); + TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseId, TwConst.InOutType.出库, detail.ActNum); } plan.State = (int)TwConst.State.已审核; TwInOutplanmasterService.Update(plan); diff --git a/SGGL/BLL/CLGL/TwMaterialstockService.cs b/SGGL/BLL/CLGL/TwMaterialstockService.cs index ac078e0b..4deb619b 100644 --- a/SGGL/BLL/CLGL/TwMaterialstockService.cs +++ b/SGGL/BLL/CLGL/TwMaterialstockService.cs @@ -29,16 +29,21 @@ namespace BLL var q = from x in db.Tw_MaterialStock join mat in db.HJGL_MaterialCodeLib on x.PipeLineMatCode equals mat.MaterialCode into mm from mat in mm.DefaultIfEmpty() + join warehouse in db.Base_Warehouse on x.WarehouseId equals warehouse.WarehouseId into warehouses + from warehouse in warehouses.DefaultIfEmpty() where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && - (string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode)) && + (string.IsNullOrEmpty(table.WarehouseId) || x.WarehouseId == table.WarehouseId) && + (string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode) || x.WarehouseId.Contains(table.WarehouseCode)) && (string.IsNullOrEmpty(table.PipeLineMatCode) || x.PipeLineMatCode.Contains(table.PipeLineMatCode)) && (string.IsNullOrEmpty(table.MaterialUnit) || mat.MaterialUnit.Contains(table.MaterialUnit)) && (string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId)) select new Model.Tw_MaterialStockOutput { Id = x.Id, - WarehouseCode = x.WarehouseCode, + WarehouseId = x.WarehouseId, + WarehouseCode = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName, + WarehouseName = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName, PipeLineMatCode = x.PipeLineMatCode, StockNum = x.StockNum, ProjectId = x.ProjectId, @@ -88,7 +93,8 @@ namespace BLL Model.Tw_MaterialStock table = new Model.Tw_MaterialStock { Id = newtable.Id, - WarehouseCode = newtable.WarehouseCode, + WarehouseId = newtable.WarehouseId, + WarehouseCode = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId) ?? newtable.WarehouseCode, PipeLineMatCode = newtable.PipeLineMatCode, StockNum = newtable.StockNum, ProjectId = newtable.ProjectId, @@ -104,7 +110,8 @@ namespace BLL if (table != null) { table.Id = newtable.Id; - table.WarehouseCode = newtable.WarehouseCode; + table.WarehouseId = newtable.WarehouseId; + table.WarehouseCode = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId) ?? newtable.WarehouseCode; table.PipeLineMatCode = newtable.PipeLineMatCode; table.StockNum = newtable.StockNum; table.ProjectId = newtable.ProjectId; @@ -125,16 +132,16 @@ namespace BLL } /// - /// 根据项目编码,材料编码,仓库编码,数量增减库存 + /// 根据项目编码,材料编码,仓库主键,数量增减库存 /// /// /// - /// + /// /// /// - public static void UpdateStockNum(string ProjectId, string MaterialCode, string WarehouseCode, TwConst.InOutType inOutType, decimal? StockNum) + public static void UpdateStockNum(string ProjectId, string MaterialCode, string warehouseId, TwConst.InOutType inOutType, decimal? StockNum) { - Model.Tw_MaterialStock table = Funs.DB.Tw_MaterialStock.FirstOrDefault(x => x.ProjectId == ProjectId && x.PipeLineMatCode == MaterialCode && x.WarehouseCode == WarehouseCode); + Model.Tw_MaterialStock table = Funs.DB.Tw_MaterialStock.FirstOrDefault(x => x.ProjectId == ProjectId && x.PipeLineMatCode == MaterialCode && x.WarehouseId == warehouseId); //如果是入库,则库存数量加上,如果是出库,则库存数量减去 if (inOutType == TwConst.InOutType.出库) { @@ -153,7 +160,8 @@ namespace BLL Id = Guid.NewGuid().ToString(), ProjectId = ProjectId, PipeLineMatCode = MaterialCode, - WarehouseCode = WarehouseCode, + WarehouseId = warehouseId, + WarehouseCode = Base_WarehouseService.GetWarehouseNameById(warehouseId), StockNum = StockNum ?? 0, }; Funs.DB.Tw_MaterialStock.InsertOnSubmit(newtable); diff --git a/SGGL/BLL/CLGL/TwOutputdetailService..cs b/SGGL/BLL/CLGL/TwOutputdetailService..cs index bbd6db54..03079244 100644 --- a/SGGL/BLL/CLGL/TwOutputdetailService..cs +++ b/SGGL/BLL/CLGL/TwOutputdetailService..cs @@ -28,7 +28,7 @@ namespace BLL from mat in mm.DefaultIfEmpty() join master in Funs.DB.Tw_OutputMaster on x.OutputMasterId equals master.Id into masters from master in masters.DefaultIfEmpty() - join stock in Funs.DB.Tw_MaterialStock on new { x.MaterialCode, master.WarehouseCode, master.ProjectId } equals new { MaterialCode = stock.PipeLineMatCode, stock.WarehouseCode, stock.ProjectId } into st + join stock in Funs.DB.Tw_MaterialStock on new { x.MaterialCode, master.WarehouseId, master.ProjectId } equals new { MaterialCode = stock.PipeLineMatCode, stock.WarehouseId, stock.ProjectId } into st from stock in st.DefaultIfEmpty() where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && diff --git a/SGGL/BLL/CLGL/TwOutputmasterService.cs b/SGGL/BLL/CLGL/TwOutputmasterService.cs index cc3fa475..9ea2bb76 100644 --- a/SGGL/BLL/CLGL/TwOutputmasterService.cs +++ b/SGGL/BLL/CLGL/TwOutputmasterService.cs @@ -39,12 +39,15 @@ namespace BLL from warehouseperson in warehousepersons.DefaultIfEmpty() join unit in Funs.DB.Base_Unit on x.ReqUnitId equals unit.UnitId into units from unit in units.DefaultIfEmpty() + join warehouse in Funs.DB.Base_Warehouse on x.WarehouseId equals warehouse.WarehouseId into warehouses + from warehouse in warehouses.DefaultIfEmpty() where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && (string.IsNullOrEmpty(table.InOutPlanMasterId) || x.InOutPlanMasterId.Contains(table.InOutPlanMasterId)) && (string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId)) && (string.IsNullOrEmpty(table.CusBillCode) || x.CusBillCode.Contains(table.CusBillCode)) && - (string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode)) && + (string.IsNullOrEmpty(table.WarehouseId) || x.WarehouseId == table.WarehouseId) && + (string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode) || x.WarehouseId.Contains(table.WarehouseCode)) && (string.IsNullOrEmpty(table.CreateMan) || x.CreateMan.Contains(table.CreateMan)) && (string.IsNullOrEmpty(table.ReqUnitId) || x.ReqUnitId.Contains(table.ReqUnitId)) && (string.IsNullOrEmpty(table.UnitWorkId) || y.WeldTaskId.Contains(table.UnitWorkId)) && @@ -58,7 +61,9 @@ namespace BLL ProjectId = x.ProjectId, CusBillCode = x.CusBillCode, InOutPlanMasterId = x.InOutPlanMasterId, - WarehouseCode = x.WarehouseCode, + WarehouseId = x.WarehouseId, + WarehouseCode = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName, + WarehouseName = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName, Category = x.Category, Source = x.Source, TypeInt = x.TypeInt, @@ -105,7 +110,9 @@ namespace BLL Id = x.Id, ProjectId = x.ProjectId, CusBillCode = x.CusBillCode, + WarehouseId = x.WarehouseId, WarehouseCode = x.WarehouseCode, + WarehouseName = x.WarehouseName, InOutPlanMasterId = x.InOutPlanMasterId, Source = x.Source, TypeInt = x.TypeInt, @@ -152,7 +159,9 @@ namespace BLL ProjectId = x.ProjectId, CusBillCode = x.CusBillCode, InOutPlanMasterId = x.InOutPlanMasterId, + WarehouseId = x.WarehouseId, WarehouseCode = x.WarehouseCode, + WarehouseName = x.WarehouseName, Source = x.Source, TypeInt = x.TypeInt, State = x.State, @@ -197,7 +206,8 @@ namespace BLL ProjectId = newtable.ProjectId, InOutPlanMasterId = newtable.InOutPlanMasterId, CusBillCode = newtable.CusBillCode, - WarehouseCode = newtable.WarehouseCode, + WarehouseId = newtable.WarehouseId, + WarehouseCode = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId) ?? newtable.WarehouseCode, Category = newtable.Category, Source = newtable.Source, TypeInt = newtable.TypeInt, @@ -226,7 +236,8 @@ namespace BLL table.ProjectId = newtable.ProjectId; table.InOutPlanMasterId = newtable.InOutPlanMasterId; table.CusBillCode = newtable.CusBillCode; - table.WarehouseCode = newtable.WarehouseCode; + table.WarehouseId = newtable.WarehouseId; + table.WarehouseCode = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId) ?? newtable.WarehouseCode; table.Category = newtable.Category; table.Source = newtable.Source; table.TypeInt = newtable.TypeInt; @@ -285,6 +296,7 @@ namespace BLL InOutPlanMasterId = plan.Id, ProjectId = plan.ProjectId, CusBillCode = GetCusBillCode(plan.WeldTaskCode, (TwConst.TypeInt)plan.TypeInt, (BLL.TwConst.Category)plan.Category, plan.CusBillCode), + WarehouseId = plan.WarehouseId, WarehouseCode = plan.WarehouseCode, Category = plan.Category, Source = plan.Source, @@ -314,7 +326,7 @@ namespace BLL ActNum = detail.ActNum, }; TwOutputdetailService.Add(detailTable); - TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseCode, TwConst.InOutType.出库, detailTable.ActNum); + TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseId, TwConst.InOutType.出库, detailTable.ActNum); } plan.State = (int)TwConst.State.已完成; @@ -344,7 +356,7 @@ namespace BLL { TwOutputdetailService.DeleteById(detail.Id); //撤销出库,即增加库存 - TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseCode, TwConst.InOutType.入库, detail.ActNum); + TwMaterialstockService.UpdateStockNum(master.ProjectId, detail.MaterialCode, master.WarehouseId, TwConst.InOutType.入库, detail.ActNum); } var planModel = TwInOutplanmasterService.GetById(planId); planModel.State = (int)TwConst.State.已审核; @@ -402,4 +414,4 @@ namespace BLL } -} \ No newline at end of file +} diff --git a/SGGL/BLL/HJGL/BaseInfo/Base_WarehouseService.cs b/SGGL/BLL/HJGL/BaseInfo/Base_WarehouseService.cs index f3eec28a..03cc1d46 100644 --- a/SGGL/BLL/HJGL/BaseInfo/Base_WarehouseService.cs +++ b/SGGL/BLL/HJGL/BaseInfo/Base_WarehouseService.cs @@ -16,6 +16,22 @@ namespace BLL return Funs.DB.Base_Warehouse.FirstOrDefault(e => e.WarehouseId == warehouseId); } + /// + /// 根据项目和仓库名称获取仓库信息,主要用于历史名称数据迁移和导入校验。 + /// + public static Model.Base_Warehouse GetWarehouseByName(string projectId, string warehouseName) + { + return Funs.DB.Base_Warehouse.FirstOrDefault(e => e.ProjectId == projectId && e.WarehouseName == warehouseName); + } + + /// + /// 获取仓库显示名称,材料业务保存主键后仍用名称做列表显示。 + /// + public static string GetWarehouseNameById(string warehouseId) + { + return Funs.DB.Base_Warehouse.Where(e => e.WarehouseId == warehouseId).Select(e => e.WarehouseName).FirstOrDefault(); + } + /// /// 新增仓库信息 /// diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs index d0f6a212..b59d9605 100644 --- a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs @@ -58,7 +58,7 @@ namespace FineUIPro.Web.CLGL } if (drpWarehouse.SelectedValue != Const._Null) { - table.WarehouseCode = drpWarehouse.SelectedValue; + table.WarehouseId = drpWarehouse.SelectedValue; } var tb = BLL.TwInOutplanmasterService.GetListData(table, Grid1); Grid1.RecordCount = TwInOutplanmasterService.Count; @@ -542,4 +542,4 @@ namespace FineUIPro.Web.CLGL } } } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/CLGL/InputMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InputMaster.aspx.cs index c35657c3..5edb9e9c 100644 --- a/SGGL/FineUIPro.Web/CLGL/InputMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/InputMaster.aspx.cs @@ -55,7 +55,7 @@ namespace FineUIPro.Web.CLGL } if (drpWarehouse.SelectedValue != Const._Null) { - table.WarehouseCode = drpWarehouse.SelectedValue; + table.WarehouseId = drpWarehouse.SelectedValue; } var tb = BLL.TwInputmasterService.GetListData(table, Grid1); Grid1.RecordCount = TwInputmasterService.Count; diff --git a/SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs b/SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs index 841f2295..61b6bba0 100644 --- a/SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/MaterialStock.aspx.cs @@ -32,7 +32,7 @@ namespace FineUIPro.Web.CLGL table.PipeLineMatCode = txtMatCode.Text.Trim(); if (drpWarehouse.SelectedValue != Const._Null) { - table.WarehouseCode = drpWarehouse.SelectedValue; + table.WarehouseId = drpWarehouse.SelectedValue; } table.ProjectId = this.CurrUser.LoginProjectId; var tb = BLL.TwMaterialstockService.GetListData(table, Grid1); @@ -230,4 +230,4 @@ namespace FineUIPro.Web.CLGL BindGrid(); } } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs index 10d0e45b..b60868ea 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs @@ -73,7 +73,7 @@ namespace FineUIPro.Web.CLGL } if (drpWarehouse.SelectedValue != Const._Null) { - table.WarehouseCode = drpWarehouse.SelectedValue; + table.WarehouseId = drpWarehouse.SelectedValue; } if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID)) { diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterDetailImport.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterDetailImport.aspx.cs index b4dfc24c..5fa207c2 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterDetailImport.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterDetailImport.aspx.cs @@ -328,7 +328,7 @@ namespace FineUIPro.Web.CLGL private List GetSelectableStockList(Tw_InOutPlanMaster master) { Tw_MaterialStockOutput stockQuery = new Tw_MaterialStockOutput(); - stockQuery.WarehouseCode = master.WarehouseCode; + stockQuery.WarehouseId = master.WarehouseId; stockQuery.ProjectId = CurrUser.LoginProjectId; stockQuery.MaterialUnit = GetRequiredMaterialUnit(master.Category); return TwMaterialstockService.GetTw_MaterialStockByModle(stockQuery); diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterEdit.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterEdit.aspx.cs index 60204057..68ea0f7c 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterEdit.aspx.cs @@ -62,7 +62,7 @@ namespace FineUIPro.Web.CLGL txtCreateDate.Text = result.CreateDate.Value.ToString("yyyy-MM-dd"); drpReqUnit.SelectedValue = result.ReqUnitId; drpTypeInt.SelectedValue = result.TypeInt.ToString(); - drpWarehouse.SelectedValue = result.WarehouseCode; + drpWarehouse.SelectedValue = result.WarehouseId; drpCategory.SelectedValue = result.Category.ToString(); txtRemark.Text = result.Remark; txtCusBillCode.Text = result.CusBillCode; @@ -184,7 +184,8 @@ namespace FineUIPro.Web.CLGL Id = Id, ProjectId = this.CurrUser.LoginProjectId, CusBillCode = txtCusBillCode.Text, - WarehouseCode = drpWarehouse.SelectedValue, + WarehouseId = drpWarehouse.SelectedValue, + WarehouseCode = drpWarehouse.SelectedText, WeldTaskId = UnitWorkId, Source = 1, CreateDate = DateTime.Now, @@ -202,7 +203,8 @@ namespace FineUIPro.Web.CLGL { var model = TwInOutplanmasterService.GetById(Id); model.CusBillCode = txtCusBillCode.Text; - model.WarehouseCode = drpWarehouse.SelectedValue; + model.WarehouseId = drpWarehouse.SelectedValue; + model.WarehouseCode = drpWarehouse.SelectedText; // model.WeldTaskId = UnitWorkId; model.Source = 1; model.CreateDate = DateTime.Now; diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelectStock.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelectStock.aspx.cs index 41734104..43a6d5e3 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelectStock.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMasterSelectStock.aspx.cs @@ -42,7 +42,7 @@ namespace FineUIPro.Web.CLGL Model.Tw_MaterialStockOutput table = new Model.Tw_MaterialStockOutput(); table.PipeLineMatCode = txtMatCode.Text.Trim(); - table.WarehouseCode = inoutplanmaster.WarehouseCode; + table.WarehouseId = inoutplanmaster.WarehouseId; table.ProjectId = this.CurrUser.LoginProjectId; if (inoutplanmaster.Category == (int)TwConst.Category.管段) { @@ -160,4 +160,4 @@ namespace FineUIPro.Web.CLGL BindGrid(); } } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs index 0b2a3193..3f3ac0e8 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs @@ -77,7 +77,7 @@ namespace FineUIPro.Web.CLGL } if (drpWarehouse.SelectedValue != Const._Null) { - table.WarehouseCode = drpWarehouse.SelectedValue; + table.WarehouseId = drpWarehouse.SelectedValue; } if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID)) @@ -697,4 +697,4 @@ namespace FineUIPro.Web.CLGL } } } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs index a3b0c7c2..a6fe2a6d 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs @@ -312,7 +312,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage { var completeInOutPlanDetailRelationList = from x in Funs.DB.Tw_InOutPlanDetail_Relation join y in Funs.DB.Tw_InOutPlanMaster on x.InOutPlanMasterId equals y.Id - where y.State == (int)TwConst.State.已完成 && y.WarehouseCode == drpWarehouse.SelectedValue + where y.State == (int)TwConst.State.已完成 && y.WarehouseId == drpWarehouse.SelectedValue select x; var pipeline = (from x in Funs.DB.HJGL_Pipeline @@ -1083,7 +1083,10 @@ namespace FineUIPro.Web.HJGL.WeldingManage protected void drpWarehouse_SelectedIndexChanged(object sender, EventArgs e) { - WarehouseId = Base_WarehouseService.GetWarehouseList(this.CurrUser.LoginProjectId).Where(x => x.WarehouseName == drpWarehouse.SelectedValue).Select(x => x.WarehouseId).FirstOrDefault(); + WarehouseId = Base_WarehouseService.GetWarehouseList(this.CurrUser.LoginProjectId) + .Where(x => x.WarehouseId == drpWarehouse.SelectedValue || x.WarehouseName == drpWarehouse.SelectedValue) + .Select(x => x.WarehouseId) + .FirstOrDefault(); this.InitTreeMenu();//加载树 } } diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReport.aspx b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReport.aspx index 5e2659ad..cd1e72bb 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReport.aspx +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReport.aspx @@ -6,7 +6,7 @@ 焊接日报 - + -
- - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - <%-- + + + + + + + + <%-- @@ -77,340 +77,340 @@ --%> - - - + + - - - + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + $('.imgPreview').on('click', function () { + // $('.imgPreview').hide() + }); + } + F.ready(function () { + showImg(); + }) + diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReport.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReport.aspx.cs index 76d23bbc..67b00331 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReport.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReport.aspx.cs @@ -6,6 +6,7 @@ using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; +using System.Web; namespace FineUIPro.Web.HJGL.WeldingManage { @@ -402,13 +403,21 @@ namespace FineUIPro.Web.HJGL.WeldingManage protected string ConvertImageUrlByImage(object photoUrl) { - string url = string.Empty; - if (photoUrl != null) + if (photoUrl == null || string.IsNullOrEmpty(photoUrl.ToString())) { - url = BLL.UploadAttachmentService.ShowImage("../../", photoUrl.ToString()); - + return string.Empty; } - return url; + + string htmlStr = ""; + foreach (string item in photoUrl.ToString().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + { + string imageUrl = "../../" + item.Replace('\\', '/'); + // 日报表格图片只用于本页放大预览,不包跳转链接,避免点击时打开新标签页。 + htmlStr += ""; + } + htmlStr += "
"; + return htmlStr; } #region 焊接日报 维护事件 diff --git a/SGGL/Model/CLGL/Tw_InOutMasterOutput.cs b/SGGL/Model/CLGL/Tw_InOutMasterOutput.cs index 48187c30..429c7eb3 100644 --- a/SGGL/Model/CLGL/Tw_InOutMasterOutput.cs +++ b/SGGL/Model/CLGL/Tw_InOutMasterOutput.cs @@ -14,6 +14,7 @@ namespace Model public string TypeString { get; set; } public string CreateManName { get; set; } public string WarehouseManName { get; set; } + public string WarehouseName { get; set; } public string AuditManName { get; set; } public string AuditManName2 { get; set; } public string ReqUnitName { get; set; } diff --git a/SGGL/Model/CLGL/Tw_MaterialStockOutput.cs b/SGGL/Model/CLGL/Tw_MaterialStockOutput.cs index 49b83c4b..4c9fced6 100644 --- a/SGGL/Model/CLGL/Tw_MaterialStockOutput.cs +++ b/SGGL/Model/CLGL/Tw_MaterialStockOutput.cs @@ -2,6 +2,7 @@ { public class Tw_MaterialStockOutput: Tw_MaterialStock { + public string WarehouseName { get; set; } public string Code { get; set; } public string HeatNo { get; set; } public string BatchNo { get; set; } diff --git a/SGGL/Model/CLGL/Tw_OutHistoryImportRow.cs b/SGGL/Model/CLGL/Tw_OutHistoryImportRow.cs index 1d67b137..c4aa61c6 100644 --- a/SGGL/Model/CLGL/Tw_OutHistoryImportRow.cs +++ b/SGGL/Model/CLGL/Tw_OutHistoryImportRow.cs @@ -6,6 +6,8 @@ namespace Model { public string WarehouseCode { get; set; } + public string WarehouseId { get; set; } + public string MaterialCode { get; set; } public string Code { get; set; } diff --git a/SGGL/Model/CLGL/Tw_WarehouseIdExtensions.cs b/SGGL/Model/CLGL/Tw_WarehouseIdExtensions.cs new file mode 100644 index 00000000..20305175 --- /dev/null +++ b/SGGL/Model/CLGL/Tw_WarehouseIdExtensions.cs @@ -0,0 +1,85 @@ +using System; +using System.Data.Linq.Mapping; + +namespace Model +{ + public partial class Tw_InOutPlanMaster + { + private string _WarehouseId; + + [Column(Storage = "_WarehouseId", DbType = "NVarChar(50)")] + public string WarehouseId + { + get { return this._WarehouseId; } + set + { + if (this._WarehouseId != value) + { + this.SendPropertyChanging(); + this._WarehouseId = value; + this.SendPropertyChanged("WarehouseId"); + } + } + } + } + + public partial class Tw_InputMaster + { + private string _WarehouseId; + + [Column(Storage = "_WarehouseId", DbType = "NVarChar(50)")] + public string WarehouseId + { + get { return this._WarehouseId; } + set + { + if (this._WarehouseId != value) + { + this.SendPropertyChanging(); + this._WarehouseId = value; + this.SendPropertyChanged("WarehouseId"); + } + } + } + } + + public partial class Tw_OutputMaster + { + private string _WarehouseId; + + [Column(Storage = "_WarehouseId", DbType = "NVarChar(50)")] + public string WarehouseId + { + get { return this._WarehouseId; } + set + { + if (this._WarehouseId != value) + { + this.SendPropertyChanging(); + this._WarehouseId = value; + this.SendPropertyChanged("WarehouseId"); + } + } + } + } + + public partial class Tw_MaterialStock + { + private string _WarehouseId; + + [Column(Storage = "_WarehouseId", DbType = "NVarChar(50)")] + public string WarehouseId + { + get { return this._WarehouseId; } + set + { + if (this._WarehouseId != value) + { + this.SendPropertyChanging(); + this._WarehouseId = value; + this.SendPropertyChanged("WarehouseId"); + } + } + } + } +} diff --git a/SGGL/Model/Model.csproj b/SGGL/Model/Model.csproj index 5edae2cc..b76d682b 100644 --- a/SGGL/Model/Model.csproj +++ b/SGGL/Model/Model.csproj @@ -233,6 +233,7 @@ +