diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs index 5d32519b..99c5bcb4 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs @@ -14,5 +14,22 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 生产任务编号 /// public string mo_task_code { get; set; } + /// + /// 开始时间 + /// + public long[] estimated_start_date { get; set; } + /// + /// 结束时间 + /// + public long[] estimated_end_date { get; set; } + + /// + /// 产线 + /// + public string workline { get; set; } + /// + /// 工序 + /// + public string process { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index a285f4b6..f0e28267 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -51,14 +51,35 @@ namespace Tnb.ProductionMgr if (input == null) throw new ArgumentNullException("input"); List trees = new(); var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); + var list = await _db.Queryable().Where(it => it.Category == "workline").ToListAsync(); if (_dicWorkLine.Count < 1) { - var list = await _db.Queryable().Where(it => it.Category == "workline").ToListAsync(); + _dicWorkLine = list.ToDictionary(x => x.Id, x => Tuple.Create(x.EnCode, x.FullName)); } + bool start = false; + bool end=false; + DateTime[] startTimes = new DateTime[2]; + DateTime[] endTimes = new DateTime[2]; + if (input.estimated_start_date != null && input.estimated_start_date.Count() == 2) + { + start=true; + startTimes[0] = GetDateTimeMilliseconds(input.estimated_start_date![0]); + startTimes[1] = GetDateTimeMilliseconds(input.estimated_start_date![1]); + } + if (input.estimated_end_date != null && input.estimated_end_date.Count() == 2) + { + end = true; + endTimes[0] = GetDateTimeMilliseconds(input.estimated_end_date![0]); + endTimes[1] = GetDateTimeMilliseconds(input.estimated_end_date![1]); + + } var items = await _db.Queryable().LeftJoin((a, b) => a.process_id == b.id).LeftJoin((a, b, c) => a.mo_id == c.id) .WhereIF(!string.IsNullOrEmpty(input.mo_task_code), a => a.mo_task_code == input.mo_task_code.Trim()) + .WhereIF(start, a => startTimes[0] <= a.estimated_start_date && startTimes[1] >= a.estimated_start_date) + .WhereIF(end, a => endTimes[0] <= a.estimated_end_date && endTimes[1] >= a.estimated_end_date) + .WhereIF(!string.IsNullOrEmpty(input.workline), a => list.Where(p => p.EnCode.Contains(input.workline) || p.FullName.Contains(input.workline)).Select(p => p.Id).ToList().Contains(a.workline_id!)) .Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled") .Select((a, b, c) => new PrdMoTask { @@ -101,6 +122,23 @@ namespace Tnb.ProductionMgr } } var treeList = trees.ToTree(); + if (!string.IsNullOrEmpty(input.process)) + { + foreach (var item in treeList) + { + bool flag = false; + if (item.process_id != null && item.process_id.Contains(input.process)) + flag = true; + if (item.children != null) + { + List childs = (List)(Object)item.children; + if (childs.Where(p => p.process_id.Contains(input.process)).Any()) + flag = true; + } + if (!flag) + treeList.Remove(item); + } + } SqlSugarPagedList pagedList = new() { list = treeList, @@ -113,15 +151,24 @@ namespace Tnb.ProductionMgr }; return PageResult.SqlSugarPageResult(pagedList); } + private static DateTime GetDateTimeMilliseconds(long timestamp) + { + long begtime = timestamp * 10000; + DateTime dt_1970 = new DateTime(1970, 1, 1, 8, 0, 0); + long tricks_1970 = dt_1970.Ticks;//1970年1月1日刻度 + long time_tricks = tricks_1970 + begtime;//日志日期刻度 + DateTime dt = new DateTime(time_tricks);//转化为DateTime + return dt; + } private async Task GetChild(string parentId, List nodes, Dictionary dic) { var items = await _db.Queryable() .LeftJoin((a, b) => a.process_id == b.id) .LeftJoin((a, b, c) => a.mo_id == c.id) - .LeftJoin((a,b,c,d)=>a.mbom_process_id==d.id) + .LeftJoin((a, b, c, d) => a.mbom_process_id == d.id) .Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled") - .OrderBy((a,b,c,d)=>d.ordinal) + .OrderBy((a, b, c, d) => d.ordinal) .Select((a, b, c) => new PrdMoTask { id = a.id, @@ -134,7 +181,7 @@ namespace Tnb.ProductionMgr plan_end_date = a.estimated_end_date, plan_qty = c.plan_qty, //complete_qty = SqlFunc.Subqueryable().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty), - complete_qty = a.reported_work_qty+a.scrap_qty, + complete_qty = a.reported_work_qty + a.scrap_qty, mo_task_status = a.mo_task_status, }).ToListAsync(); @@ -152,7 +199,7 @@ namespace Tnb.ProductionMgr nsChild[i].process_id = $"{items[i].process_code}/{items[i].process_name}"; nsChild[i].plan_start_date = items[i].estimated_start_date.HasValue ? items[i].estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; nsChild[i].plan_end_date = items[i].estimated_end_date.HasValue ? items[i].estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; - + if (nsChild[i].workline_id.IsNotEmptyOrNull()) { var workLine = _dicWorkLine.ContainsKey(nsChild[i].workline_id) ? (Tuple)_dicWorkLine[nsChild[i].workline_id] : null;