|
|
@@ -296,7 +296,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//工序需要等待时间记录
|
|
|
List<StartTimeDto> starts = new List<StartTimeDto>();
|
|
|
//1、获取工艺路径下的第一层级工序
|
|
|
- List<mes_tech_process> fistChilds = tech_Processes.Where(p=>p.parentprocid == tech_id).OrderBy(m=>m.Id).ToList();
|
|
|
+ List<mes_tech_process> fistChilds = tech_Processes.Where(p => p.parentprocid == tech_id).OrderBy(m => m.Id).ToList();
|
|
|
if (fistChilds.Count == 0)
|
|
|
{
|
|
|
throw new NotImplementedException("当前工艺路径没有配置工序,请调整!");
|
|
|
@@ -312,7 +312,8 @@ namespace Business.ResourceExamineManagement
|
|
|
//计算最后一个工序耗时
|
|
|
curTakeTime = CalcTakeTime(chd, packages);
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
curTakeTime = CalcTakeTime(chd, chd.lq.Value);
|
|
|
}
|
|
|
sumTimes += curTakeTime;
|
|
|
@@ -334,7 +335,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="proc"></param>
|
|
|
/// <param name="quantity">LeadQuantity to Start Next</param>
|
|
|
/// <returns></returns>
|
|
|
- private decimal CalcTakeTime(mes_tech_process proc,decimal quantity)
|
|
|
+ private decimal CalcTakeTime(mes_tech_process proc, decimal quantity)
|
|
|
{
|
|
|
decimal takeTime = 0.00m;//当前工序前置准备时间(分钟)
|
|
|
if (proc.wctype == 1)//人工型:数量/uph(一小时生产数量)*60(小时转换为分钟)/wsinuse(工位数)
|
|
|
@@ -355,13 +356,65 @@ namespace Business.ResourceExamineManagement
|
|
|
return takeTime;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 生成主工单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="BomNumber">Bom编码</param>
|
|
|
+ /// <param name="Quantity">需要数量</param>
|
|
|
+ /// <param name="DeliverDate">交付日期</param>
|
|
|
+ /// <param name="OrderId">销售订单ID</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task GenerateMorder(string BomNumber, decimal? Quantity, DateTime DeliverDate, long OrderId)
|
|
|
+ {
|
|
|
+ //需要生成的物料,需要生产的数量,对应销售订单。
|
|
|
+
|
|
|
+ //1.库存、在制工单检查完成后 当前BOM需要自制时 产生工单。
|
|
|
+
|
|
|
+ //2.每一个销售订单行对应一个工单。
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(BomNumber) || Quantity == null)
|
|
|
+ {
|
|
|
+ //TODO: 参数异常 直接返回
|
|
|
+ }
|
|
|
+ //获取销售订单信息
|
|
|
+ //var seorder = await _crm_seorder.FindAsync(x => x.Id == OrderId);
|
|
|
+ var seorderentry = await _crm_seorderentry.FindAsync(x => x.seorder_id == OrderId);
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 检查成品库存
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="OrderId">销售订单ID</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<bool> CheckFinishedProductInventory(long OrderId)
|
|
|
+ {
|
|
|
+ //获取销售订单信息
|
|
|
+ var seorder = await _crm_seorder.FindAsync(x => x.Id == OrderId);
|
|
|
+ //获取销售订单子表
|
|
|
+ var seorderentry = await _crm_seorderentry.FindAsync(x => x.seorder_id == OrderId);
|
|
|
+ if (string.IsNullOrEmpty(seorderentry.bom_number))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Expression<Func<ic_item_stock, bool>> filter = x => x.icitem_id == long.Parse(seorderentry.bom_number);
|
|
|
+ var ic_Item_Stocks = await _ic_item_stock.GetManyByCondition(filter);
|
|
|
+
|
|
|
+ if (seorderentry.qty <= ic_Item_Stocks.Sum(x => x.sqty))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 检查在制工单
|
|
|
/// </summary>
|
|
|
/// <param name="bomNumber">Bom编码</param>
|
|
|
/// <param name="Quantity">需要数量</param>
|
|
|
- /// <param name="EndDate">交付日期</param>
|
|
|
+ /// <param name="DeliverDate">交付日期</param>
|
|
|
/// <param name="OrderId">销售订单ID</param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<List<mes_morder>> CheckMorder(string bomNumber, decimal? Quantity, DateTime DeliverDate, long OrderId)
|
|
|
@@ -706,14 +759,14 @@ namespace Business.ResourceExamineManagement
|
|
|
/// 计算物料库存量
|
|
|
/// </summary>
|
|
|
/// <param name="returnlist"></param>
|
|
|
- public void BomStock(List<BomChildExamineDto> returnlist,long bangid,long orderid,long orderentryid, long factoryid)
|
|
|
+ public void BomStock(List<BomChildExamineDto> returnlist, long bangid, long orderid, long orderentryid, long factoryid)
|
|
|
{
|
|
|
returnlist = returnlist.OrderBy(s => s.num).ToList();
|
|
|
//取物料库存记录
|
|
|
FilterDefinition<ic_item_stock> filter = Builders<ic_item_stock>.Filter.In(s => s.icitem_id, returnlist.Select(c => c.item_id).ToList());
|
|
|
var stocklist = _ic_item_stock.GetManyByIds(filter).Result;
|
|
|
//取当前订单的物料库存占用记录
|
|
|
- var occupylist = _ic_item_stockoccupy.GetManyByCondition(p=>p.bang_id == bangid && p.order_id == orderid).Result;
|
|
|
+ var occupylist = _ic_item_stockoccupy.GetManyByCondition(p => p.bang_id == bangid && p.order_id == orderid).Result;
|
|
|
//计算剩余库存
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
@@ -723,9 +776,9 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
//非虚拟件
|
|
|
//当前物料的库存数量
|
|
|
- decimal stockQty = stocklist.Where(s => s.icitem_id == item.item_id).Sum(p=>p.sqty.GetValueOrDefault());
|
|
|
+ decimal stockQty = stocklist.Where(s => s.icitem_id == item.item_id).Sum(p => p.sqty.GetValueOrDefault());
|
|
|
//获取当前订单其他订单行当前物料的占用数量
|
|
|
- decimal otherStockQty = occupylist.Where(s => s.icitem_id == item.item_id).Sum(p=>p.quantity);
|
|
|
+ decimal otherStockQty = occupylist.Where(s => s.icitem_id == item.item_id).Sum(p => p.quantity);
|
|
|
//当前订单行物料库存情况
|
|
|
item.sqty = stockQty - otherStockQty;
|
|
|
}
|