获取备料计划
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
public class MaterialPreparationPlanOutput
|
||||||
|
{
|
||||||
|
public string mo_task_id { get; set; }
|
||||||
|
public string mo_task_code { get; set; }
|
||||||
|
public string material_id { get; set; }
|
||||||
|
public string material_code { get; set; }
|
||||||
|
public int? num { get; set; }
|
||||||
|
public List<MaterialPreparationPlanDOutput> children { get; set; } = new List<MaterialPreparationPlanDOutput>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MaterialPreparationPlanDOutput
|
||||||
|
{
|
||||||
|
public int? rate_num { get; set; }
|
||||||
|
public string mo_task_id { get; set; }
|
||||||
|
public string mo_task_code { get; set; }
|
||||||
|
public string parent_id { get; set; }
|
||||||
|
public string material_id { get; set; }
|
||||||
|
public string material_code { get; set; }
|
||||||
|
public List<MaterialPreparationPlanDDOutput> children { get; set; } = new List<MaterialPreparationPlanDDOutput>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MaterialPreparationPlanDDOutput
|
||||||
|
{
|
||||||
|
public string material_id { get; set; }
|
||||||
|
public string material_code { get; set; }
|
||||||
|
public decimal? num { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,5 +19,12 @@ namespace Tnb.ProductionMgr.Interfaces
|
|||||||
/// <param name="eqpId"></param>
|
/// <param name="eqpId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<PrdMoTask>> GetListByEqpId(string eqpId);
|
Task<List<PrdMoTask>> GetListByEqpId(string eqpId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取备料计划
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<dynamic> GetMaterialPreparationPlan();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2121,7 +2121,7 @@ namespace Tnb.ProductionMgr
|
|||||||
return await _db.Queryable<PrdMoTask>().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
|
return await _db.Queryable<PrdMoTask>().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算预计结束日期
|
/// 计算预计结束日期
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -2607,6 +2607,70 @@ namespace Tnb.ProductionMgr
|
|||||||
count = SqlFunc.AggregateCount(c.mo_status)
|
count = SqlFunc.AggregateCount(c.mo_status)
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取备料计划
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<dynamic> GetMaterialPreparationPlan()
|
||||||
|
{
|
||||||
|
string now = DateTime.Now.ToString("yyyy-MM-dd");
|
||||||
|
var childrenList = await _db.Queryable<PrdMoTask>()
|
||||||
|
.LeftJoin<PrdMoTask>((a, b) => a.id == b.parent_id)
|
||||||
|
.LeftJoin<BasMaterial>((a, b, c) => b.material_id == c.id)
|
||||||
|
.Where((a, b) => a.schedule_type == 2 && string.IsNullOrEmpty(a.parent_id) && a.estimated_start_date.Value.ToString("yyyy-MM-dd") == now)
|
||||||
|
.Select((a, b, c) => new MaterialPreparationPlanDOutput
|
||||||
|
{
|
||||||
|
mo_task_id = b.id,
|
||||||
|
mo_task_code = b.mo_task_code,
|
||||||
|
rate_num = SqlFunc.Subqueryable<BasMbom>().Where(o => o.id == a.bom_id)
|
||||||
|
.OrderByDesc(o => o.create_time).Select(o => o.num),
|
||||||
|
parent_id = b.parent_id,
|
||||||
|
material_id = b.material_id,
|
||||||
|
material_code = c.code,
|
||||||
|
children = SqlFunc.Subqueryable<BasMbomInput>()
|
||||||
|
.LeftJoin<BasMaterial>((x, y) => x.material_id == y.id)
|
||||||
|
.Where((x, y) => x.mbom_process_id == b.mbom_process_id)
|
||||||
|
.ToList((x, y) => new MaterialPreparationPlanDDOutput()
|
||||||
|
{
|
||||||
|
material_id = x.material_id,
|
||||||
|
material_code = y.code,
|
||||||
|
num = x.num
|
||||||
|
})
|
||||||
|
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
var prdMoTaskList = await _db.Queryable<PrdMoTask>()
|
||||||
|
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||||
|
.Where(a => a.schedule_type == 2 && string.IsNullOrEmpty(a.parent_id) && a.estimated_start_date.Value.ToString("yyyy-MM-dd") == now)
|
||||||
|
.Select((a,b)=>new MaterialPreparationPlanOutput()
|
||||||
|
{
|
||||||
|
mo_task_id = a.id,
|
||||||
|
mo_task_code = a.mo_task_code,
|
||||||
|
material_id = b.id,
|
||||||
|
material_code = b.code,
|
||||||
|
num = a.scheduled_qty,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var item in prdMoTaskList)
|
||||||
|
{
|
||||||
|
item.children = childrenList.Where(x => x.parent_id == item.mo_task_id).ToList();
|
||||||
|
foreach (var itemChild in item.children)
|
||||||
|
{
|
||||||
|
foreach (var itemChildChild in itemChild.children)
|
||||||
|
{
|
||||||
|
if (itemChildChild.num > 0 && itemChild.rate_num != null && itemChild.rate_num>0)
|
||||||
|
{
|
||||||
|
itemChildChild.num = item.num * itemChildChild.num / itemChild.rate_num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return prdMoTaskList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user