diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs index e9a2cf48..e25142a3 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs @@ -37,4 +37,10 @@ public string result { get; set; } } + public class MaintainItemResult + { + public string item_name { get; set; } + public string group_name { get; set; } + public string result { get; set; } + } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/PadMainListOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/PadMainListOutput.cs index 30431bcc..85437eee 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/PadMainListOutput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/PadMainListOutput.cs @@ -16,5 +16,6 @@ public string plan_start_time { get; set; } public string starttime { get; set; } + public string finishtime { get; set; } } } diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs index 2ada52bb..63c0924d 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs @@ -196,33 +196,35 @@ namespace Tnb.EquipMgr else { input.sidx = "b." + input.sidx; + input.sort = "desc"; } List records = await _db.Queryable().Select(p => p.plan_id + p.mold_id).ToListAsync(); SqlSugarPagedList result = await _db.Queryable() .LeftJoin((a, b) => a.maintain_plan_id == b.id) .LeftJoin((a, b, c) => a.mold_id == c.id) .LeftJoin((a, b, c, d) => b.plan_code == d.plan_code && c.mold_code == d.mold_code) - .LeftJoin((a, b, c, d, e) => e.plan_id == b.id && e.mold_id == c.id) - .LeftJoin((a, b, c, d, e, f) => b.create_id == f.Id) - .LeftJoin((a, b, c, d, e, f, g) => c.mold_status == g.Id) + // .LeftJoin((a, b, c, d, e) => e.plan_id == b.id && e.mold_id == c.id) + .LeftJoin((a, b, c, d, e) => b.create_id == e.Id) + .LeftJoin((a, b, c, d, e, f) => c.mold_status == f.Id) .Where((a, b, c, d, e, f) => b.create_time != null) - .WhereIF(!string.IsNullOrEmpty(input.maintain_info), (a, b, c, d, e, f, g) => c.mold_code!.Contains(input.maintain_info) || c.mold_name!.Contains(input.maintain_info)) - .WhereIF(start_time != null, (a, b, c, d, e, f, g) => b.create_time != null && b.create_time >= start_time) - .WhereIF(end_time != null, (a, b, c, d, e, f, g) => b.create_time != null && b.create_time <= end_time) - .WhereIF(input.status == "待保养", (a, b, c, d, e, f, g) => !records.Contains(a.maintain_plan_id + a.mold_id)) - .WhereIF(input.status == "已完成", (a, b, c, d, e, f, g) => records.Contains(a.maintain_plan_id + a.mold_id)) - .Select((a, b, c, d, e, f, g) => new PadMainListOutput + .WhereIF(!string.IsNullOrEmpty(input.maintain_info), (a, b, c, d, e, f) => c.mold_code!.Contains(input.maintain_info) || c.mold_name!.Contains(input.maintain_info)) + .WhereIF(start_time != null, (a, b, c, d, e, f) => b.create_time != null && b.create_time >= start_time) + .WhereIF(end_time != null, (a, b, c, d, e, f) => b.create_time != null && b.create_time <= end_time) + .WhereIF(input.status == "待保养", (a, b, c, d, e, f) => !records.Contains(a.maintain_plan_id + a.mold_id)) + .WhereIF(input.status == "已完成", (a, b, c, d, e, f) => records.Contains(a.maintain_plan_id + a.mold_id)) + .Select((a, b, c, d, e, f) => new PadMainListOutput { plan_id = b.id, mold_id = c.id, mold_code = c.mold_code!, mold_name = c.mold_name!, - mold_status = g.FullName!, + mold_status = f.FullName!, status = input.status, - createuser = f.RealName, + createuser = e.RealName, createtime = b.create_time == null ? "" : b.create_time.Value.ToString(DbTimeFormat.SS), plan_start_time = b.plan_start_date == null ? "" : b.plan_start_date.Value.ToString(DbTimeFormat.SS), starttime = d.plan_start_time == null ? "" : d.plan_start_time.Value.ToString(DbTimeFormat.SS), + finishtime= d.plan_end_time == null ? "" : d.plan_end_time.Value.ToString(DbTimeFormat.SS), }).OrderBy($"{input.sidx} {input.sort}").ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50); return PageResult.SqlSugarPageResult(result); } @@ -303,7 +305,23 @@ namespace Tnb.EquipMgr return items; } + [HttpPost] + public async Task GetMaintainItem(MoldMaintainRunUpInput input) + { + var data = await _db.Queryable() + .LeftJoin((a, b) => a.item_id == b.id) + .LeftJoin((a, b, c) => a.item_group_id == c.id) + .Where((a, b, c) => a.plan_id == input.plan_id && a.mold_id == input.mold_id) + .Select((a, b, c) => new MaintainItemResult + { + group_name = c.name!, + item_name = b.name!, + result = a.result, + }) + .ToListAsync(); + return data; + } /// /// 模具保养计划执行-开始模具保养 /// @@ -447,6 +465,11 @@ namespace Tnb.EquipMgr { throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty"); } + var plan_code = _db.Queryable().Where(p => p.id == input.plan_id).Select(p=>p.plan_code).First(); + var mold_code = _db.Queryable().Where(p => p.id == input.mold_id).Select(p => p.mold_code).First(); + if (!string.IsNullOrEmpty(plan_code)&& !string.IsNullOrEmpty(mold_code)) { + _ = await _db.Updateable().SetColumns(it => new ToolMoldMaintainRunRecord { plan_end_time = DateTime.Now }).Where(it => it.plan_code == plan_code && it.mold_code== mold_code).ExecuteCommandAsync(); + } List records = new(); foreach (MaintainItemInfo item in input.items) @@ -505,6 +528,11 @@ namespace Tnb.EquipMgr } } + + + + + /// /// 模具保养计划执行-保养完成 ///