|
|
@@ -4894,6 +4894,7 @@ namespace Business.Replenishment
|
|
|
{
|
|
|
//如果有计划工单,则需要生成pr po oo
|
|
|
List<mo_srm_pr_main> prmainlist = new List<mo_srm_pr_main>();
|
|
|
+ List<srm_pr_main> pr_mainlist = new List<srm_pr_main>();
|
|
|
if (_CalcBomViewAppService.SRMPRDtoList.Any())
|
|
|
{
|
|
|
List<List<mo_srm_pr_main>> prlist = _CalcBomViewAppService.SRMPRDtoList.Where(f => f.srm_Pr_Main != null).Select(s => s.srm_Pr_Main).ToList();
|
|
|
@@ -4934,6 +4935,9 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ pr_mainlist = ObjectMapper.Map<List<mo_srm_pr_main>, List<srm_pr_main>>(prmainlist);
|
|
|
+ pr_mainlist.ForEach(a => { a.analogcalcversion = analogCalcVersion; });
|
|
|
}
|
|
|
//暂时屏蔽重新生成工单物料明细
|
|
|
List<WorkOrdDetail> mainWorkOrdDetails = new List<WorkOrdDetail>();
|
|
|
@@ -5093,7 +5097,7 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
}
|
|
|
//数据库需要减少的PR集合
|
|
|
- CalcPrDel(prDelList, dbPurchaseList, ic_items, DBprmainList.Where(x=>x.state==1).ToList(), updatPrList, deletePrList, prmainlist);//只取新增状态的PR,可以做删除或者修改
|
|
|
+ CalcPrDel(prDelList, dbPurchaseList, ic_items, DBprmainList.Where(x=>x.state==1).ToList(), updatPrList, deletePrList, pr_mainlist);//只取新增状态的PR,可以做删除或者修改
|
|
|
new NLogHelper("AlignmentCalcList").WriteLog("AlignmentCalcList", JsonConvert.SerializeObject(AlignmentCalcList), _currentTenant.Id.ToString());
|
|
|
}
|
|
|
|
|
|
@@ -5148,10 +5152,8 @@ namespace Business.Replenishment
|
|
|
var moentrylist = ObjectMapper.Map<List<mo_mes_moentry>, List<mes_moentry>>(_CalcBomViewAppService.moentriesInsertList);
|
|
|
_businessDbContext.BulkInsert(moentrylist);
|
|
|
}
|
|
|
- if (prmainlist.Any())
|
|
|
+ if (pr_mainlist.Any())
|
|
|
{
|
|
|
- var pr_mainlist = ObjectMapper.Map<List<mo_srm_pr_main>, List<srm_pr_main>>(prmainlist);
|
|
|
- pr_mainlist.ForEach(a => { a.analogcalcversion = analogCalcVersion;}) ;
|
|
|
_businessDbContext.BulkInsert(pr_mainlist);
|
|
|
}
|
|
|
if (_CalcBomViewAppService.newStockOccList.Any())
|
|
|
@@ -5207,7 +5209,7 @@ namespace Business.Replenishment
|
|
|
return rtn;
|
|
|
}
|
|
|
|
|
|
- public void CalcPrDel(List<AlignmentCalcDto> prDelList,List<srm_purchase> purchase,List<ic_item> ic_items, List<srm_pr_main> dbPrlist, List<srm_pr_main> updatPrList, List<srm_pr_main> deletePrList,List<mo_srm_pr_main> prmainlist)
|
|
|
+ public void CalcPrDel(List<AlignmentCalcDto> prDelList,List<srm_purchase> purchase,List<ic_item> ic_items, List<srm_pr_main> dbPrlist, List<srm_pr_main> updatPrList, List<srm_pr_main> deletePrList,List<srm_pr_main> prmainlist)
|
|
|
{
|
|
|
prDelList.ForEach(dto => {
|
|
|
var itemPurList = purchase.Where(x => x.number == dto.ItemNum).ToList();
|
|
|
@@ -5228,12 +5230,16 @@ namespace Business.Replenishment
|
|
|
moPr.pr_rqty = moPr.pr_aqty;
|
|
|
moPr.pr_sqty = moPr.pr_aqty;
|
|
|
dto.updateQty += qty;
|
|
|
+ qty = 0;
|
|
|
+ dto.updatePrlist.Add(moPr);
|
|
|
continue;
|
|
|
}
|
|
|
else if (moPr.pr_aqty == qty)//一个PR够减
|
|
|
{
|
|
|
dto.deleteQty += qty;
|
|
|
prmainlist.Remove(moPr);
|
|
|
+ qty = 0;
|
|
|
+ dto.deletePrlist.Add(moPr);
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
@@ -5241,37 +5247,48 @@ namespace Business.Replenishment
|
|
|
dto.deleteQty += moPr.pr_aqty.GetValueOrDefault();
|
|
|
qty -= moPr.pr_aqty.GetValueOrDefault();
|
|
|
prmainlist.Remove(moPr);
|
|
|
+ dto.deletePrlist.Add(moPr);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //当前物料当前供应商的在途采购申请
|
|
|
- var itemSupplierList = dbPrlist.Where(x => x.icitem_id == icitem.Id && x.pr_purchaseid == c.supplier_id).OrderByDescending(f => f.pr_sarrive_date).ToList();
|
|
|
- if (itemSupplierList.Any())
|
|
|
+ if (qty > 0)
|
|
|
{
|
|
|
- foreach (var itemPr in itemSupplierList)
|
|
|
+ //当前物料当前供应商的在途采购申请
|
|
|
+ var itemSupplierList = dbPrlist.Where(x => x.icitem_id == icitem.Id && x.pr_purchaseid == c.supplier_id).OrderByDescending(f => f.pr_sarrive_date).ToList();
|
|
|
+ if (itemSupplierList.Any())
|
|
|
{
|
|
|
- if (itemPr.pr_aqty > qty)//一个PR够减
|
|
|
- {
|
|
|
- itemPr.pr_aqty = itemPr.pr_aqty - qty;
|
|
|
- itemPr.pr_rqty = itemPr.pr_aqty;
|
|
|
- itemPr.pr_sqty = itemPr.pr_aqty;
|
|
|
- updatPrList.Add(itemPr);
|
|
|
- dto.updatePrlist.Add(itemPr);
|
|
|
- dto.updateQty = qty;
|
|
|
- continue;
|
|
|
- }
|
|
|
- else if (itemPr.pr_aqty == qty)//一个PR够减
|
|
|
+ foreach (var itemPr in itemSupplierList)
|
|
|
{
|
|
|
- dto.deleteQty += qty;
|
|
|
- deletePrList.Add(itemPr);
|
|
|
- dto.deletePrlist.Add(itemPr);
|
|
|
- continue;
|
|
|
- }
|
|
|
- else {
|
|
|
- dto.deleteQty += itemPr.pr_aqty.GetValueOrDefault();
|
|
|
- qty -= itemPr.pr_aqty.GetValueOrDefault();
|
|
|
- deletePrList.Add(itemPr);
|
|
|
- dto.deletePrlist.Add(itemPr);
|
|
|
+ if (itemPr.pr_aqty > qty)//一个PR够减
|
|
|
+ {
|
|
|
+ itemPr.pr_aqty = itemPr.pr_aqty - qty;
|
|
|
+ itemPr.pr_rqty = itemPr.pr_aqty;
|
|
|
+ itemPr.pr_sqty = itemPr.pr_aqty;
|
|
|
+ updatPrList.Add(itemPr);
|
|
|
+ dto.updatePrlist.Add(itemPr);
|
|
|
+ dto.updateQty = qty;
|
|
|
+ qty = 0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else if (itemPr.pr_aqty == qty)//一个PR够减
|
|
|
+ {
|
|
|
+ dto.deleteQty += qty;
|
|
|
+ deletePrList.Add(itemPr);
|
|
|
+ dto.deletePrlist.Add(itemPr);
|
|
|
+ qty = 0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dto.deleteQty += itemPr.pr_aqty.GetValueOrDefault();
|
|
|
+ qty -= itemPr.pr_aqty.GetValueOrDefault();
|
|
|
+ deletePrList.Add(itemPr);
|
|
|
+ dto.deletePrlist.Add(itemPr);
|
|
|
+ }
|
|
|
+ if (qty == 0)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|