diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GanntSaveInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GanntSaveInput.cs
new file mode 100644
index 00000000..01a52bce
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GanntSaveInput.cs
@@ -0,0 +1,15 @@
+namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
+{
+ public class GanntSaveInput
+ {
+ public string id { get; set; }
+ public string row_id { get; set; }
+ public GanntTime time { get; set; }
+ }
+
+ public class GanntTime
+ {
+ public DateTime? start { get; set; }
+ public DateTime? end { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index dca6214a..55101a1c 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -2221,5 +2221,115 @@ namespace Tnb.ProductionMgr
}
+ ///
+ /// 获取组装包装生产排产甘特图信息
+ ///
+ ///
+ [HttpPost]
+ public async Task GetGanntInfo2()
+ {
+ var db = _repository.AsSugarClient();
+ Dictionary result = new Dictionary();
+ var listRows = await db.Queryable()
+ .Where(x => x.DeleteMark==null && (x.Category == DictConst.RegionCategoryWorklineCode || x.Category == DictConst.RegionCategoryWorkshopCode))
+ .OrderByDescending(x=>x.Category)
+ .Select(x => new
+ {
+ id = x.Id,
+ expanded = true,
+ label = x.FullName,
+ parentId = x.Category==DictConst.RegionCategoryWorklineCode ? x.ParentId : ""
+ }).ToListAsync();
+
+ 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)
+ .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.workline_id,
+ time = new GanntTime
+ {
+ start = a.estimated_start_date,
+ 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
+ {
+ // 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")
+ }
+ })
+ .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(min.ToString("yyyy-MM-dd")).Ticks);
+ TimeSpan ts3 = ts1.Subtract(ts2).Duration();
+
+
+ result.Add("listRows",listRows);
+ result.Add("charItems",charItems);
+ result.Add("totalDays",ts3.TotalDays);
+ return result;
+ }
+
+ ///
+ /// 保存组装包装生产排产甘特图信息
+ ///
+ ///
+ [HttpPost]
+ public async Task SaveData2(List input)
+ {
+ var db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ foreach (var item in input)
+ {
+
+ if(await db.Queryable().Where(x=>x.Id==item.row_id && x.Category==DictConst.RegionCategoryWorkshopCode).AnyAsync())
+ throw Oops.Bah("不能排在车间上");
+ var prdMoTask = await db.Queryable().SingleAsync(x => x.id == item.id);
+ if (prdMoTask.workline_id != item.row_id)
+ {
+ await db.Updateable()
+ .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()
+ .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()
+ .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;
+ }
+
}
+
+
+
}