|
|
@@ -2688,12 +2688,19 @@ namespace Business.Replenishment
|
|
|
workOrdRoutings.Add(woRouting);
|
|
|
}
|
|
|
|
|
|
- var exm = exmResult.Find(s => s.morder_id == item.Id);
|
|
|
+ long fid = GetParentMo(morders, item);
|
|
|
+ var exm = exmResult.Find(s => s.morder_id == fid);
|
|
|
if (exm != null)
|
|
|
{
|
|
|
var childs = childExamineList.Where(s => s.examine_id == exm.Id && s.is_use == true).ToList();
|
|
|
+
|
|
|
+ var child = childs.Find(s => s.item_number == item.product_code);
|
|
|
+ if (child == null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
List<b_bom_child_examine> returnList = new List<b_bom_child_examine>();
|
|
|
- GetWorkDetalis(childs.Where(s => s.level == 2).ToList(), returnList, childs);
|
|
|
+ GetWorkDetalis(childs.Where(s => s.parent_id == child.fid).ToList(), returnList, childs);
|
|
|
if (returnList.Any())
|
|
|
{
|
|
|
WorkOrdDetail woDetail = null;
|
|
|
@@ -2713,20 +2720,10 @@ namespace Business.Replenishment
|
|
|
woDetail.Status = "";
|
|
|
woDetail.IsActive = true;
|
|
|
woDetail.CreateTime = DateTime.Now;
|
|
|
- decimal needCount = caleList.Sum(c => c.needCount.GetValueOrDefault());
|
|
|
- foreach (var structure in caleList)
|
|
|
+ woDetail.QtyRequired = caleList.Sum(c => c.needCount.GetValueOrDefault());
|
|
|
+ if (workOrd.QtyOrded != 0)
|
|
|
{
|
|
|
- if (woDetail.Op > structure.Op)
|
|
|
- {
|
|
|
- woDetail.Op = structure.Op;
|
|
|
- }
|
|
|
- var psm = productStructureMs.Find(x => x.ParentItem == item.morder_no && x.ComponentItem == structure.item_number);
|
|
|
- woDetail.Yield = psm == null ? 0 : psm.Scrap / 100;
|
|
|
- woDetail.QtyRequired += structure.needCount.GetValueOrDefault() * (1 + woDetail.Yield);
|
|
|
- }
|
|
|
- if (needCount != 0)
|
|
|
- {
|
|
|
- woDetail.FrozenBOMQty = woDetail.QtyRequired / needCount;
|
|
|
+ woDetail.FrozenBOMQty = Math.Round(woDetail.QtyRequired / workOrd.QtyOrded, 10);
|
|
|
}
|
|
|
workOrdDetails.Add(woDetail);
|
|
|
}
|
|
|
@@ -2735,6 +2732,26 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public long GetParentMo(List<mes_morder> morders, mes_morder item)
|
|
|
+ {
|
|
|
+ if (item.parent_id != null)
|
|
|
+ {
|
|
|
+ var parentMo = morders.Find(s => s.Id == item.parent_id);
|
|
|
+ if (parentMo != null)
|
|
|
+ {
|
|
|
+ return GetParentMo(morders, parentMo);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return item.Id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return item.Id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取虚拟件明细
|
|
|
/// </summary>
|