注塑挤出排产

This commit is contained in:
2023-10-11 13:58:37 +08:00
parent 8100ce0a21
commit fa1b602409
2 changed files with 117 additions and 1 deletions

View File

@@ -2225,6 +2225,78 @@ namespace Tnb.ProductionMgr
}
/// <summary>
/// 获取组装包装生产排产甘特图信息
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> GetGanntInfo1()
{
var db = _repository.AsSugarClient();
Dictionary<string, object> result = new Dictionary<string, object>();
var listRows = await db.Queryable<EqpEquipment>()
.LeftJoin<EqpEquipType>((a,b)=>a.equip_type_id==b.id)
.Where((a,b)=>b.code=="ZSJ" || b.code=="005")
.OrderBy((a,b)=>b.code)
.Select((a,b) => new
{
id = a.id,
expanded = true,
label = a.name,
parentId = ""
}).ToListAsync();
DateTime startTime = Convert.ToDateTime(new DateTime(DateTime.Now.Year,DateTime.Now.Month,1).AddDays(-15).ToString("yyyy-MM-dd 00:00:00"));
DateTime endTime = Convert.ToDateTime(new DateTime(DateTime.Now.Year,DateTime.Now.Month,1).AddMonths(1).AddDays(-1).AddDays(15).ToString("yyyy-MM-dd 23:59:59"));
var charItems = await db.Queryable<PrdMoTask>()
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
.LeftJoin<DictionaryDataEntity>((a,b,c)=>c.DictionaryTypeId==DictConst.PrdTaskStatusTypeId && a.mo_task_status==c.EnCode)
.Where((a, b) => a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_status == DictConst.ToBeScheduledEncode || a.mo_task_status == DictConst.MoStatusPauseCode || a.mo_task_status == DictConst.InProgressEnCode)
.Where((a,b)=>a.schedule_type==1 && string.IsNullOrEmpty(a.parent_id))
.Where((a,b)=>a.estimated_start_date!=null && a.estimated_end_date!=null)
.Where((a,b)=>a.estimated_start_date>=startTime && a.estimated_end_date<=endTime)
.Select((a, b,c) => new
{
id = a.id,
label = b.name,
material_name = b.name,
reported_work_qty = a.reported_work_qty==null ? 0 : a.reported_work_qty,
scheduled_qty = a.scheduled_qty,
mo_task_status = c.FullName,
// label = b.name +" " +(a.reported_work_qty==null?0:a.reported_work_qty)+"/"+a.scheduled_qty + " " +c.FullName,
rowId = a.eqp_id,
time = new GanntTime
{
start = a.estimated_start_date,
end = a.estimated_end_date
},
//linkedWith = SqlFunc.Subqueryable<PrdMoTask>().Where(x=>a.schedule_type==2 && string.IsNullOrEmpty(a.parent_id) && a.workline_id==x.workline_id && (x.mo_task_status==DictConst.ToBeStartedEnCode || x.mo_task_status==DictConst.MoStatusPauseCode || x.mo_task_status==DictConst.ToBeScheduledEncode)).ToList(x=>x.id),
tips = new GanntTimeTips
{
// material_code = b.code,
// material_name = b.name,
mo_task_code = a.mo_task_code,
// start_time = a.estimated_start_date==null ? "" : a.estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
// end_time = a.estimated_end_date==null ? "" : a.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
start_time = a.estimated_start_date,
end_time = a.estimated_end_date,
}
})
.ToListAsync();
// DateTime min = (DateTime)charItems.Min(x => x.time.start);
TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).Ticks);
TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(startTime.ToString("yyyy-MM-dd")).Ticks);
TimeSpan ts3 = ts1.Subtract(ts2).Duration();
result.Add("listRows",listRows);
result.Add("charItems",charItems);
result.Add("startTime",startTime);
result.Add("endTime",endTime);
result.Add("totalDays",ts3.TotalDays);
return result;
}
/// <summary>
/// 获取组装包装生产排产甘特图信息
/// </summary>
@@ -2296,6 +2368,49 @@ namespace Tnb.ProductionMgr
return result;
}
/// <summary>
/// 保存注塑挤出生产排产甘特图信息
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> SaveData1(List<GanntSaveInput> input)
{
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
foreach (var item in input)
{
// if(await db.Queryable<OrganizeEntity>().Where(x=>x.Id==item.row_id && x.Category==DictConst.RegionCategoryWorkshopCode).AnyAsync())
// throw Oops.Bah("不能排在车间上");
var prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == item.id);
if (prdMoTask.eqp_id != item.row_id)
{
await db.Updateable<PrdMoTask>()
.SetColumns(x=>x.workline_id == item.row_id)
.Where(x=>x.id==item.id).ExecuteCommandAsync();
}
if (prdMoTask.estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm") != item.time.start.Value.ToString("yyyy-MM-dd HH:mm"))
{
await db.Updateable<PrdMoTask>()
.SetColumns(x=>x.estimated_start_date==item.time.start)
.Where(x=>x.id==item.id).ExecuteCommandAsync();
}
if (prdMoTask.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm")!=item.time.end.Value.ToString("yyyy-MM-dd HH:mm"))
{
await db.Updateable<PrdMoTask>()
.SetColumns(x=>x.estimated_end_date==item.time.end)
.Where(x=>x.id==item.id).ExecuteCommandAsync();
}
}
});
if(!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
return result.IsSuccess ? "排产成功" : result.ErrorMessage;
}
/// <summary>
/// 保存组装包装生产排产甘特图信息
/// </summary>