工单完成情况汇总
This commit is contained in:
@@ -72,8 +72,11 @@ public static class DictConst
|
|||||||
/// 工单状态-强制接单
|
/// 工单状态-强制接单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string MoCloseId = "25501969636645";
|
public const string MoCloseId = "25501969636645";
|
||||||
|
/// <summary>
|
||||||
|
/// 工单状态-code
|
||||||
|
/// </summary>
|
||||||
|
public const string MoTaskStatusCode = "OrderStatus";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 工单状态 已下发字典Id
|
/// 工单状态 已下发字典Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
public class PrdMoStatisticsInput
|
||||||
|
{
|
||||||
|
public string mo_status { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 页码.
|
||||||
|
/// </summary>
|
||||||
|
public int currentPage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 页容量.
|
||||||
|
/// </summary>
|
||||||
|
public int pageSize { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
public class PrdMoStatisticsOutput
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public string mo_code { get; set; }
|
||||||
|
public string mo_status { get; set; }
|
||||||
|
public string material_name { get; set; }
|
||||||
|
public string material_code { get; set; }
|
||||||
|
public decimal? plan_qty { get; set; }
|
||||||
|
public decimal? scheduled_qty { get; set; }
|
||||||
|
public decimal? tobe_scheduled_qty { get; set; }
|
||||||
|
public decimal? reported_work_qty { get; set; }
|
||||||
|
public decimal? complete_rate { get; set; }
|
||||||
|
public List<PrdMoStatisticsDetailOutput> children { get; set; } = new List<PrdMoStatisticsDetailOutput>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PrdMoStatisticsDetailOutput
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public string mo_task_code { get; set; }
|
||||||
|
public string mo_task_status { get; set; }
|
||||||
|
public string estimated_start_date { get; set; }
|
||||||
|
public string estimated_end_date { get; set; }
|
||||||
|
public decimal? scheduled_qty { get; set; }
|
||||||
|
public decimal? reported_work_qty { get; set; }
|
||||||
|
public decimal? scrap_qty { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -362,7 +362,52 @@ namespace Tnb.ProductionMgr
|
|||||||
.ExecuteCommandHasChangeAsync();
|
.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
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -670,6 +670,9 @@ namespace Tnb.ProductionMgr
|
|||||||
if (input.schedule_type.Value == 1) //注塑、基础排产
|
if (input.schedule_type.Value == 1) //注塑、基础排产
|
||||||
{
|
{
|
||||||
var mo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
var mo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||||
|
BasMbomProcess basMbomProcess = null;
|
||||||
|
if(!string.IsNullOrEmpty(input.bom_id))
|
||||||
|
basMbomProcess = await db.Queryable<BasMbomProcess>().FirstAsync(x => x.mbom_id == input.bom_id);
|
||||||
var moTask = input.Adapt<PrdMoTask>();
|
var moTask = input.Adapt<PrdMoTask>();
|
||||||
moTask.id = SnowflakeIdHelper.NextId();
|
moTask.id = SnowflakeIdHelper.NextId();
|
||||||
moTask.create_id = _userManager.UserId;
|
moTask.create_id = _userManager.UserId;
|
||||||
@@ -677,6 +680,7 @@ namespace Tnb.ProductionMgr
|
|||||||
moTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
moTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||||
moTask.scheduled_qty = input.scheduled_qty;
|
moTask.scheduled_qty = input.scheduled_qty;
|
||||||
moTask.unit_id = mo.unit_id;
|
moTask.unit_id = mo.unit_id;
|
||||||
|
moTask.mbom_process_id = basMbomProcess?.id ?? "";
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(input.eqp_id))
|
if (!string.IsNullOrEmpty(input.eqp_id))
|
||||||
{
|
{
|
||||||
@@ -2335,6 +2339,26 @@ namespace Tnb.ProductionMgr
|
|||||||
return result.IsSuccess ? "排产成功" : result.ErrorMessage;
|
return result.IsSuccess ? "排产成功" : result.ErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取工单各个状态数量
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetMoTaskStatusNum()
|
||||||
|
{
|
||||||
|
return await _db.Queryable<DictionaryTypeEntity>().
|
||||||
|
LeftJoin<DictionaryDataEntity>((a,b)=>a.Id==b.DictionaryTypeId)
|
||||||
|
.LeftJoin<PrdMo>((a,b,c)=>b.Id==c.mo_status)
|
||||||
|
.Where((a,b,c)=>a.EnCode==DictConst.MoTaskStatusCode)
|
||||||
|
.GroupBy((a,b,c)=>new { mo_status_code = b.EnCode,mo_status_name = b.FullName})
|
||||||
|
.Select((a,b,c) => new
|
||||||
|
{
|
||||||
|
mo_status_code = b.EnCode,
|
||||||
|
mo_status_name = b.FullName,
|
||||||
|
count = SqlFunc.AggregateCount(c.mo_status)
|
||||||
|
}).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user