|
|
@@ -66,17 +66,18 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <summary>
|
|
|
/// 检查在途订单
|
|
|
/// </summary>
|
|
|
- public async void CheckPurchaseOrder(crm_seorderentry seorderentry, long icitem_id, decimal Quantity, DateTime DeliverDate, ic_plan ic_Plan, long bang_id)
|
|
|
+ public List<mo_srm_po_occupy> CheckPurchaseOrder(crm_seorderentry seorderentry, long icitem_id, decimal Quantity, DateTime DeliverDate, ic_plan ic_Plan, long bang_id)
|
|
|
{
|
|
|
if (seorderentry == null)
|
|
|
{
|
|
|
//TODO:入参异常
|
|
|
}
|
|
|
+ List<mo_srm_po_occupy> occupyList = new List<mo_srm_po_occupy>();
|
|
|
|
|
|
//查询出对应物料采购订单明细 --数据未被停用 && 评审通过后
|
|
|
- var poDetailList = await _mo_srm_po_list.GetManyByCondition(x => x.icitem_id == icitem_id && x.state == 1 && x.rstate == 1);
|
|
|
+ var poDetailList = _mo_srm_po_list.GetManyByCondition(x => x.icitem_id == icitem_id && x.state == 1 && x.rstate == 1).Result;
|
|
|
//采购订单占用数据
|
|
|
- var poOccupys = await _mo_srm_po_occupy.GetManyByCondition(x => poDetailList.Select(p => p.id).ToList().Contains(x.polist_id.GetValueOrDefault()));
|
|
|
+ var poOccupys = _mo_srm_po_occupy.GetManyByCondition(x => poDetailList.Select(p => p.id).ToList().Contains(x.polist_id.GetValueOrDefault())).Result;
|
|
|
//先查询出满足日期,并且数量可满足占用的数据
|
|
|
var poDetails = poDetailList.Where(x => x.rarrdate.GetValueOrDefault().AddDays(-(int)ic_Plan.self_inspection_date.GetValueOrDefault()) < DeliverDate && x.qty - x.rqty - x.esqty -
|
|
|
poOccupys.Where(p => p.polist_id.GetValueOrDefault() == x.mysql_id)?.Sum(m => m.qty) > Quantity).OrderByDescending(x => x.rarrdate).ToList();
|
|
|
@@ -105,7 +106,7 @@ namespace Business.ResourceExamineManagement
|
|
|
QuantityNumber = Quantity;
|
|
|
}
|
|
|
var mes_Mooccupy = GetMooccupies(seorderentry, item, QuantityNumber, bang_id);
|
|
|
- //mes_Mooccupies.Add(mes_Mooccupy);
|
|
|
+ occupyList.Add(mes_Mooccupy);
|
|
|
//当剩余需要数量大于0则继续寻找可占用工单,已满足需要数量停止循环查找
|
|
|
if (Quantity - PlanQty <= 0)
|
|
|
{
|
|
|
@@ -114,7 +115,7 @@ namespace Business.ResourceExamineManagement
|
|
|
Quantity = Quantity - PlanQty.GetValueOrDefault();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ return occupyList.OrderByDescending(s => s.etime).ToList();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 拼接工单占用表
|