|
|
@@ -1283,13 +1283,16 @@ namespace Business.Replenishment
|
|
|
CaclMaterialShortage(returnlist);
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
- if (subItem.Any(s=>s.ItemNumber==item.item_number&&s.PlanMonth== planPreMonth))
|
|
|
+ if(item.item_number!=a.SAPItemNumber)
|
|
|
{
|
|
|
- subItem.Find(s => s.ItemNumber == item.item_number && s.PlanMonth == planPreMonth).Qty += item.needCount;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- subItem.Add(new ReplenishmentSubItemDto { ItemNumber = item.item_number,Qty=item.needCount,PlanMonth= planPreMonth });
|
|
|
+ if (subItem.Any(s => s.ItemNumber == item.item_number && s.PlanMonth == planPreMonth))
|
|
|
+ {
|
|
|
+ subItem.Find(s => s.ItemNumber == item.item_number && s.PlanMonth == planPreMonth).Qty += item.needCount;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ subItem.Add(new ReplenishmentSubItemDto { ItemNumber = item.item_number, Qty = item.needCount, PlanMonth = planPreMonth });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -3194,7 +3197,8 @@ namespace Business.Replenishment
|
|
|
input.month = DateTime.Now.Month;
|
|
|
ReplenishmentDto replenishmentDto = GetROPParam(input.factory_id.ToString());
|
|
|
//DOP运行资源检查每个成品和半成品SKU的可用库存,当可用库存 <= 修正后ROP时,自动生成月度计划订单(MPlan order,MPO48年月日3位流水号)= EOP;可用库存为没有被其他SO和PO占用的(合格成品或半成品库存 + WIP);
|
|
|
- var ropModelList = _replenishmentROPWeekPlan.GetListAsync(a => a.planmonth==$"{DateTime.Now.Year}-{DateTime.Now.Month.ToString("00")}" && a.erp_cls==1 && a.distributionchannel=="瑞奇" && a.factory_id==input.factory_id && !a.IsDeleted).Result;
|
|
|
+ string planMonthQuery = $"{DateTime.Now.Year}-{DateTime.Now.Month.ToString("00")}";
|
|
|
+ var ropModelList = _replenishmentROPWeekPlan.GetListAsync(a => a.planmonth== planMonthQuery && a.erp_cls==1 && a.distributionchannel=="瑞奇" && a.factory_id==input.factory_id && !a.IsDeleted).Result;
|
|
|
List<string> planItemList = ropModelList?.Select(a => a.number).Distinct().ToList();
|
|
|
var itemList = _mysql_ic_item.GetListAsync(a => planItemList.Contains(a.number) && !a.IsDeleted).Result;
|
|
|
//获取BOM用于分解到原材料
|
|
|
@@ -3415,7 +3419,7 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
|
|
|
//DOP运行资源检查每个原材料SKU的可用库存,当可用库存<=修正后ROP时,自动生成月度采购申请(Purchase request,PR46年月日4位流水号)=EOP;可用库存为没有被其他SO和PO占用的(合格原材料库存+在途库存);
|
|
|
- var ropMaterialModelList = _replenishmentROPWeekPlan.GetListAsync(a => a.planmonth == $"{DateTime.Now.Year}-{DateTime.Now.Month.ToString("00")}" && a.erp_cls == 3 && a.distributionchannel == "瑞奇" && a.factory_id == input.factory_id && !a.IsDeleted).Result;
|
|
|
+ var ropMaterialModelList = _replenishmentROPWeekPlan.GetListAsync(a => a.planmonth == planMonthQuery && a.erp_cls == 3 && a.distributionchannel == "瑞奇" && a.factory_id == input.factory_id && !a.IsDeleted).Result;
|
|
|
|
|
|
List<srm_pr_main> prList = new List<srm_pr_main>();
|
|
|
var numbers = ropMaterialModelList.Where(a => a.erp_cls == 3).Select(b => b.number).ToList();
|
|
|
@@ -4549,14 +4553,16 @@ namespace Business.Replenishment
|
|
|
List<string> numbers = pretreatments.Select(s => s.item_number).ToList();
|
|
|
List<string> locationList = new List<string> { "1000", "1001", "5008", "8000", "8001" };
|
|
|
var locStock = _invMaster.Select(a => numbers.Contains(a.ItemNum) && a.IsActive && a.Domain == factoryId.ToString() && locationList.Contains(a.Location));
|
|
|
+ var sapInvList = _SAPInv.Select(a => a.WERKS == factoryId.ToString() && numbers.Contains(a.MATNR) && (a.SOBKZ.ToUpper() == "O"));
|
|
|
//设置当前计算bangid
|
|
|
icitemStokc.ForEach(item => {
|
|
|
item.bang_id = bangid;
|
|
|
- var pret = pretreatments.Find(s => s.item_id == item.icitem_id);
|
|
|
- if (pret != null)
|
|
|
- {
|
|
|
- item.sqty = locStock.Where(s => s.ItemNum == pret.item_number).Sum(p => p.AvailStatusQty.GetValueOrDefault() + p.Assay.GetValueOrDefault());
|
|
|
- }
|
|
|
+ /*var pret = pretreatments.Find(s => s.item_id == item.icitem_id);
|
|
|
+ if(pret != null) {
|
|
|
+ }*/
|
|
|
+ item.sqty = 0;
|
|
|
+ item.sqty = locStock.Where(s => s.ItemNum == item.icitem_number).Sum(p => p.AvailStatusQty.GetValueOrDefault() + p.Assay.GetValueOrDefault());
|
|
|
+ item.sqty += sapInvList.Where(x => x.MATNR == item.icitem_number).Sum(p => p.LABST + p.INSME);
|
|
|
});
|
|
|
var moIcitemStokc = ObjectMapper.Map<List<ic_item_stock>, List<mo_ic_item_stock>>(icitemStokc);
|
|
|
moIcitemStokc.ForEach(item => { item.GenerateNewId(help.NextId()); });
|