|
@@ -1161,13 +1161,14 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
{
|
|
|
List<mo_srm_po_main> polist = new List<mo_srm_po_main>();
|
|
List<mo_srm_po_main> polist = new List<mo_srm_po_main>();
|
|
|
List<mo_srm_po_list> podetaillist = new List<mo_srm_po_list>();
|
|
List<mo_srm_po_list> podetaillist = new List<mo_srm_po_list>();
|
|
|
|
|
+ var itemList = _ic_item.Find(a => a.tenant_id == input.tenantId && a.factory_id == input.factoryId).Result;
|
|
|
//将PR按供应商和物料和日期(一周内)进行合并,生成PO
|
|
//将PR按供应商和物料和日期(一周内)进行合并,生成PO
|
|
|
//1.按照供应商、需求日期排序
|
|
//1.按照供应商、需求日期排序
|
|
|
//2.判断是不是同一个供应商,不是的话就新建一个PO;是的话判断是不是同一周,不是的话就新建一个PO,是的话判断有没有相同物料,有的话合并物料数量价格,没有的话新建一条明细
|
|
//2.判断是不是同一个供应商,不是的话就新建一个PO;是的话判断是不是同一周,不是的话就新建一个PO,是的话判断有没有相同物料,有的话合并物料数量价格,没有的话新建一条明细
|
|
|
list = list.OrderBy(a => a.pr_purchaseid).ThenBy(b => b.pr_rarrive_date).ToList();
|
|
list = list.OrderBy(a => a.pr_purchaseid).ThenBy(b => b.pr_rarrive_date).ToList();
|
|
|
long? supplierId = -1;
|
|
long? supplierId = -1;
|
|
|
DateTime supplierDate = DateTime.Now;
|
|
DateTime supplierDate = DateTime.Now;
|
|
|
- foreach (var item in list)
|
|
|
|
|
|
|
+ foreach (mo_srm_pr_main item in list)
|
|
|
{
|
|
{
|
|
|
if (item.pr_purchaseid != supplierId)
|
|
if (item.pr_purchaseid != supplierId)
|
|
|
{
|
|
{
|
|
@@ -1216,6 +1217,7 @@ namespace Business.ResourceExamineManagement
|
|
|
podetail.pr_purchase_id = po_Main.supplier_id;
|
|
podetail.pr_purchase_id = po_Main.supplier_id;
|
|
|
podetail.pr_purchase_name = po_Main.supplier_name;
|
|
podetail.pr_purchase_name = po_Main.supplier_name;
|
|
|
podetail.icitem_id = item.icitem_id;
|
|
podetail.icitem_id = item.icitem_id;
|
|
|
|
|
+ podetail.ItemNum = itemList.First(a => a.mysql_id == item.icitem_id).number;
|
|
|
podetail.icitem_name = item.icitem_name;
|
|
podetail.icitem_name = item.icitem_name;
|
|
|
podetail.qty = item.pr_aqty;
|
|
podetail.qty = item.pr_aqty;
|
|
|
podetail.netprice = item.pr_price;
|
|
podetail.netprice = item.pr_price;
|
|
@@ -1270,6 +1272,7 @@ namespace Business.ResourceExamineManagement
|
|
|
podetail.pr_purchase_id = pomain.supplier_id;
|
|
podetail.pr_purchase_id = pomain.supplier_id;
|
|
|
podetail.pr_purchase_name = pomain.supplier_name;
|
|
podetail.pr_purchase_name = pomain.supplier_name;
|
|
|
podetail.icitem_id = item.icitem_id;
|
|
podetail.icitem_id = item.icitem_id;
|
|
|
|
|
+ podetail.ItemNum = itemList.First(a => a.mysql_id == item.icitem_id).number;
|
|
|
podetail.icitem_name = item.icitem_name;
|
|
podetail.icitem_name = item.icitem_name;
|
|
|
podetail.qty = item.pr_aqty;
|
|
podetail.qty = item.pr_aqty;
|
|
|
podetail.netprice = item.pr_price;
|
|
podetail.netprice = item.pr_price;
|
|
@@ -1340,6 +1343,7 @@ namespace Business.ResourceExamineManagement
|
|
|
podetail.pr_purchase_id = po_Main.supplier_id;
|
|
podetail.pr_purchase_id = po_Main.supplier_id;
|
|
|
podetail.pr_purchase_name = po_Main.supplier_name;
|
|
podetail.pr_purchase_name = po_Main.supplier_name;
|
|
|
podetail.icitem_id = item.icitem_id;
|
|
podetail.icitem_id = item.icitem_id;
|
|
|
|
|
+ podetail.ItemNum = itemList.First(a => a.mysql_id == item.icitem_id).number;
|
|
|
podetail.icitem_name = item.icitem_name;
|
|
podetail.icitem_name = item.icitem_name;
|
|
|
podetail.qty = item.pr_aqty;
|
|
podetail.qty = item.pr_aqty;
|
|
|
podetail.netprice = item.pr_price;
|
|
podetail.netprice = item.pr_price;
|
|
@@ -1375,6 +1379,7 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
{
|
|
|
List<mo_srm_po_main> polist = new List<mo_srm_po_main>();
|
|
List<mo_srm_po_main> polist = new List<mo_srm_po_main>();
|
|
|
List<mo_srm_po_list> podetaillist = new List<mo_srm_po_list>();
|
|
List<mo_srm_po_list> podetaillist = new List<mo_srm_po_list>();
|
|
|
|
|
+ var itemList = _ic_item.Find(a => a.tenant_id == input.tenantId && a.factory_id == input.factoryId).Result;
|
|
|
//将PR按供应商和物料和日期(一周内)进行合并,生成PO
|
|
//将PR按供应商和物料和日期(一周内)进行合并,生成PO
|
|
|
//1.按照供应商、需求日期排序
|
|
//1.按照供应商、需求日期排序
|
|
|
//2.判断是不是同一个供应商,不是的话就新建一个PO;是的话判断是不是同一周,不是的话就新建一个PO,是的话判断有没有相同物料,有的话合并物料数量价格,没有的话新建一条明细
|
|
//2.判断是不是同一个供应商,不是的话就新建一个PO;是的话判断是不是同一周,不是的话就新建一个PO,是的话判断有没有相同物料,有的话合并物料数量价格,没有的话新建一条明细
|
|
@@ -1430,6 +1435,7 @@ namespace Business.ResourceExamineManagement
|
|
|
podetail.pr_purchase_id = po_Main.supplier_id;
|
|
podetail.pr_purchase_id = po_Main.supplier_id;
|
|
|
podetail.pr_purchase_name = po_Main.supplier_name;
|
|
podetail.pr_purchase_name = po_Main.supplier_name;
|
|
|
podetail.icitem_id = item.icitem_id;
|
|
podetail.icitem_id = item.icitem_id;
|
|
|
|
|
+ podetail.ItemNum = itemList.First(a => a.mysql_id == item.icitem_id).number;
|
|
|
podetail.icitem_name = item.icitem_name;
|
|
podetail.icitem_name = item.icitem_name;
|
|
|
podetail.qty = item.pr_aqty;
|
|
podetail.qty = item.pr_aqty;
|
|
|
podetail.netprice = item.pr_price;
|
|
podetail.netprice = item.pr_price;
|
|
@@ -1484,6 +1490,7 @@ namespace Business.ResourceExamineManagement
|
|
|
podetail.pr_purchase_id = pomain.supplier_id;
|
|
podetail.pr_purchase_id = pomain.supplier_id;
|
|
|
podetail.pr_purchase_name = pomain.supplier_name;
|
|
podetail.pr_purchase_name = pomain.supplier_name;
|
|
|
podetail.icitem_id = item.icitem_id;
|
|
podetail.icitem_id = item.icitem_id;
|
|
|
|
|
+ podetail.ItemNum = itemList.First(a => a.mysql_id == item.icitem_id).number;
|
|
|
podetail.icitem_name = item.icitem_name;
|
|
podetail.icitem_name = item.icitem_name;
|
|
|
podetail.qty = item.pr_aqty;
|
|
podetail.qty = item.pr_aqty;
|
|
|
podetail.netprice = item.pr_price;
|
|
podetail.netprice = item.pr_price;
|
|
@@ -1554,6 +1561,7 @@ namespace Business.ResourceExamineManagement
|
|
|
podetail.pr_purchase_id = po_Main.supplier_id;
|
|
podetail.pr_purchase_id = po_Main.supplier_id;
|
|
|
podetail.pr_purchase_name = po_Main.supplier_name;
|
|
podetail.pr_purchase_name = po_Main.supplier_name;
|
|
|
podetail.icitem_id = item.icitem_id;
|
|
podetail.icitem_id = item.icitem_id;
|
|
|
|
|
+ podetail.ItemNum = itemList.First(a => a.mysql_id == item.icitem_id).number;
|
|
|
podetail.icitem_name = item.icitem_name;
|
|
podetail.icitem_name = item.icitem_name;
|
|
|
podetail.qty = item.pr_aqty;
|
|
podetail.qty = item.pr_aqty;
|
|
|
podetail.netprice = item.pr_price;
|
|
podetail.netprice = item.pr_price;
|
|
@@ -2131,19 +2139,10 @@ namespace Business.ResourceExamineManagement
|
|
|
itemList?.ForEach(a =>
|
|
itemList?.ForEach(a =>
|
|
|
{
|
|
{
|
|
|
var find = itemLocList?.Find(c => c.ItemNum == a.ComponentItem);
|
|
var find = itemLocList?.Find(c => c.ItemNum == a.ComponentItem);
|
|
|
- var packfind = itemPackList?.Find(c => c.ItemNum == a.ComponentItem);
|
|
|
|
|
string LocationTo = "";
|
|
string LocationTo = "";
|
|
|
- bool TraceDetail = false;
|
|
|
|
|
- decimal TraceDetailQty = 0m;
|
|
|
|
|
if (find!=null)
|
|
if (find!=null)
|
|
|
{
|
|
{
|
|
|
LocationTo=find.Location;
|
|
LocationTo=find.Location;
|
|
|
- TraceDetail=find.TraceDetail;
|
|
|
|
|
- //TraceDetail为true指按需求量,否则按标签
|
|
|
|
|
- if (!TraceDetail)
|
|
|
|
|
- {
|
|
|
|
|
- TraceDetailQty = packfind.PackingQty.GetValueOrDefault();
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
//相同物料汇总
|
|
//相同物料汇总
|
|
|
var itemComponent = nbrDetailList.Find(b => b.Nbr == Nbr && b.ItemNum == a.ComponentItem);
|
|
var itemComponent = nbrDetailList.Find(b => b.Nbr == Nbr && b.ItemNum == a.ComponentItem);
|
|
@@ -2160,8 +2159,8 @@ namespace Business.ResourceExamineManagement
|
|
|
LocationFrom = LocationTo,
|
|
LocationFrom = LocationTo,
|
|
|
LocationTo = "",
|
|
LocationTo = "",
|
|
|
WorkOrd = workord,
|
|
WorkOrd = workord,
|
|
|
- QtyOrd = TraceDetail?QtyOrdSum * a.Qty: TraceDetailQty,
|
|
|
|
|
- CurrQtyOpened = TraceDetail ? QtyOrdSum * a.Qty : TraceDetailQty,
|
|
|
|
|
|
|
+ QtyOrd =QtyOrdSum * a.Qty,
|
|
|
|
|
+ CurrQtyOpened = QtyOrdSum * a.Qty ,
|
|
|
Line = i,
|
|
Line = i,
|
|
|
IsActive = true,
|
|
IsActive = true,
|
|
|
CreateTmie = DateTime.Now,
|
|
CreateTmie = DateTime.Now,
|
|
@@ -2176,42 +2175,34 @@ namespace Business.ResourceExamineManagement
|
|
|
nbrDetailList.First( b=> b.Nbr == Nbr && b.ItemNum == a.ComponentItem).QtyOrd= itemComponent.QtyOrd+ QtyOrdSum * a.Qty;
|
|
nbrDetailList.First( b=> b.Nbr == Nbr && b.ItemNum == a.ComponentItem).QtyOrd= itemComponent.QtyOrd+ QtyOrdSum * a.Qty;
|
|
|
nbrDetailList.First(b => b.Nbr == Nbr && b.ItemNum == a.ComponentItem).CurrQtyOpened = itemComponent.CurrQtyOpened + QtyOrdSum * a.Qty;
|
|
nbrDetailList.First(b => b.Nbr == Nbr && b.ItemNum == a.ComponentItem).CurrQtyOpened = itemComponent.CurrQtyOpened + QtyOrdSum * a.Qty;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if (dictItemQty.ContainsKey(a.ComponentItem))
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ nbrDetailList.ForEach(a =>
|
|
|
|
|
+ {
|
|
|
|
|
+ var find = itemLocList?.Find(c => c.ItemNum == a.ItemNum);
|
|
|
|
|
+ var packfind = itemPackList?.Find(c => c.ItemNum == a.ItemNum);
|
|
|
|
|
+ if(find!=null && !find.TraceDetail && packfind!=null && packfind.PackingQty>0)
|
|
|
{
|
|
{
|
|
|
- if(TraceDetail)
|
|
|
|
|
- {
|
|
|
|
|
- dictItemQty[a.ComponentItem] = dictItemQty[a.ComponentItem] + QtyOrdSum * a.Qty;
|
|
|
|
|
- }else
|
|
|
|
|
- {
|
|
|
|
|
- dictItemQty[a.ComponentItem] = dictItemQty[a.ComponentItem] + TraceDetailQty;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ a.CurrQtyOpened = Math.Ceiling(a.CurrQtyOpened.GetValueOrDefault() / packfind.PackingQty.GetValueOrDefault()) * packfind.PackingQty;
|
|
|
|
|
+ dictItemQty.Add(a.ItemNum, QtyOrdSum * itemList.First(b => b.ComponentItem == a.ItemNum).Qty);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- if (TraceDetail)
|
|
|
|
|
- {
|
|
|
|
|
- dictItemQty.Add(a.ComponentItem, QtyOrdSum * a.Qty);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- dictItemQty.Add(a.ComponentItem, TraceDetailQty);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ dictItemQty.Add(a.ItemNum, QtyOrdSum * itemList.First(b => b.ComponentItem == a.ItemNum).Qty);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
List<string> itemKeys = dictItemQty.Keys.ToList();
|
|
List<string> itemKeys = dictItemQty.Keys.ToList();
|
|
|
- var items = _mysql_ic_item.GetListAsync(a => itemKeys.Contains(a.number) && a.factory_id == 1001 && a.tenant_id == 1000).Result;
|
|
|
|
|
- var itemIds = items.Select(b => b.Id).ToList();
|
|
|
|
|
- var leadTimes = GetLeadTime(itemIds, 1000, 1001).Max(a=>a.ordissu_days.GetValueOrDefault());
|
|
|
|
|
|
|
+ //var items = _mysql_ic_item.GetListAsync(a => itemKeys.Contains(a.number) && a.factory_id == 1001 && a.tenant_id == 1000).Result;
|
|
|
|
|
+ //var itemIds = items.Select(b => b.Id).ToList();
|
|
|
|
|
+ //var leadTimes = GetLeadTime(itemIds, 1000, 1001).Max(a=>a.ordissu_days.GetValueOrDefault());
|
|
|
|
|
+ decimal leadTimes=itemLocList.Select(a => a.MFGMTTR).Max();
|
|
|
//没有维护备料提前期,默认取7天
|
|
//没有维护备料提前期,默认取7天
|
|
|
- if (leadTimes == 0.0M)
|
|
|
|
|
- {
|
|
|
|
|
- nbrMasterList.First(a=>a.Nbr==Nbr).Date= dbPeriodSequences.Where(a => a.WorkOrds == workord).Min(a => a.PlanDate).GetValueOrDefault().AddDays(-7);
|
|
|
|
|
|
|
+ if (leadTimes > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ nbrMasterList.First(a => a.Nbr == Nbr).Date = dbPeriodSequences.Where(a => a.WorkOrds == workord).Min(a => a.PlanDate).GetValueOrDefault().AddDays(-1 * Convert.ToDouble(leadTimes));
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- nbrMasterList.First(a => a.Nbr == Nbr).Date = dbPeriodSequences.Where(a => a.WorkOrds == workord).Min(a => a.PlanDate).GetValueOrDefault().AddDays(-1*Convert.ToDouble(leadTimes));
|
|
|
|
|
|
|
+ nbrMasterList.First(a => a.Nbr == Nbr).Date = dbPeriodSequences.Where(a => a.WorkOrds == workord).Min(a => a.PlanDate).GetValueOrDefault().AddDays(-7);
|
|
|
}
|
|
}
|
|
|
//TODO:
|
|
//TODO:
|
|
|
//因为我们并没有模拟发料的过程,在自动生成领料单的时候就要扣减库存,实际业务不能这么做。
|
|
//因为我们并没有模拟发料的过程,在自动生成领料单的时候就要扣减库存,实际业务不能这么做。
|