工单完成情况汇总

This commit is contained in:
2023-09-21 15:45:03 +08:00
parent 84d65644c7
commit 1d9e74b45f
5 changed files with 120 additions and 3 deletions

View File

@@ -362,7 +362,52 @@ namespace Tnb.ProductionMgr
.ExecuteCommandHasChangeAsync();
}
/// <summary>
/// 工单统计
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> GetPrdMoStatistics(PrdMoStatisticsInput input)
{
var result = await _db.Queryable<PrdMo>()
.LeftJoin<DictionaryDataEntity>((a, b) => a.mo_status == b.Id)
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
.WhereIF(!string.IsNullOrEmpty(input.mo_status), (a, b) => b.EnCode == input.mo_status)
// .OrderByDescending((a,b,c)=>a.reported_work_qty==null?0:a.reported_work_qty*100/a.plan_qty)
.Select((a, b, c) => new PrdMoStatisticsOutput
{
id = a.id,
mo_code = a.mo_code,
mo_status = b.FullName,
material_code = c.code,
material_name = c.name,
plan_qty = a.plan_qty,
scheduled_qty = a.scheduled_qty,
tobe_scheduled_qty = a.plan_qty - a.scheduled_qty,
reported_work_qty = a.reported_work_qty,
complete_rate = a.reported_work_qty==null?0:SqlFunc.ToDecimal(a.reported_work_qty*100)/SqlFunc.ToDecimal(a.plan_qty),
children = SqlFunc.Subqueryable<PrdMoTask>()
.LeftJoin<DictionaryDataEntity>((x,y)=>x.mo_task_code==y.EnCode && y.DictionaryTypeId==DictConst.PrdTaskStatusTypeId)
.Where(x=>x.mo_id==a.id)
.OrderByDesc((x,y)=>x.create_time)
.ToList((x,y)=>new PrdMoStatisticsDetailOutput()
{
id = x.id,
mo_task_code = x.mo_task_code,
mo_task_status = y.FullName,
estimated_start_date = x.estimated_start_date==null ? "" : x.estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
estimated_end_date = x.estimated_end_date==null ? "" : x.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
scheduled_qty = x.scheduled_qty,
reported_work_qty = x.reported_work_qty,
scrap_qty = x.scrap_qty,
}),
})
.MergeTable().OrderByDescending(a=>a.complete_rate)
.ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<PrdMoStatisticsOutput>.SqlSugarPageResult(result);
}
#endregion