diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GanntSaveInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GanntSaveInput.cs index 01a52bce..393c24fd 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GanntSaveInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GanntSaveInput.cs @@ -12,4 +12,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public DateTime? start { get; set; } public DateTime? end { get; set; } } + + public class GanntTimeTips + { + public string mo_task_code { get; set; } + public DateTime? start_time { get; set; } + public DateTime? end_time { get; set; } + } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 55101a1c..87d405c5 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2241,12 +2241,15 @@ namespace Tnb.ProductionMgr parentId = x.Category==DictConst.RegionCategoryWorklineCode ? x.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() .LeftJoin((a, b) => a.material_id == b.id) .LeftJoin((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==2 && 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, @@ -2263,24 +2266,28 @@ namespace Tnb.ProductionMgr end = a.estimated_end_date }, //linkedWith = SqlFunc.Subqueryable().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 + 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==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); + // 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(min.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; }