Switch warehouse matching to use IDs

This commit is contained in:
2026-06-24 23:25:06 +08:00
parent 4670220614
commit bd9b5a6f4d
27 changed files with 776 additions and 419 deletions
@@ -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,
+10 -7
View File
@@ -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<string> pipelineIds = new List<string>();
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;
}
@@ -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();
}
+1 -1
View File
@@ -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)) &&
+51 -15
View File
@@ -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<string, string> 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.,
+18 -6
View File
@@ -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);
+17 -9
View File
@@ -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
}
/// <summary>
/// 根据项目编码,材料编码,仓库编码,数量增减库存
/// 根据项目编码,材料编码,仓库主键,数量增减库存
/// </summary>
/// <param name="ProjectId"></param>
/// <param name="MaterialCode"></param>
/// <param name="WarehouseCode"></param>
/// <param name="warehouseId"></param>
/// <param name="inOutType"></param>
/// <param name="StockNum"></param>
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);
+1 -1
View File
@@ -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)) &&
+19 -7
View File
@@ -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
}
}
}