diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonPdaListInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonPdaListInput.cs new file mode 100644 index 00000000..aaaf32af --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/AndonPdaListInput.cs @@ -0,0 +1,9 @@ +using JNPF.Common.Filter; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class AndonPdaListInput : PageInputBase + { + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs index 2f873ee0..1a350944 100644 --- a/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/AndonRecordService.cs @@ -68,17 +68,75 @@ namespace Tnb.ProductionMgr andon_info_name = b.name, promoter_name = d.RealName, repair_name = c.RealName, - promoter_time = a.create_time == null ? "" : a.create_time.Value.ToString("yyyy-MM-dd hh:mm:ss"), - response_time = a.response_time == null ? "" : a.response_time.Value.ToString("yyyy-MM-dd hh:mm:ss"), - start_repair_time = a.start_repair_time == null ? "" : a.start_repair_time.Value.ToString("yyyy-MM-dd hh:mm:ss"), - end_repair_time = a.end_repair_time == null ? "" : a.end_repair_time.Value.ToString("yyyy-MM-dd hh:mm:ss"), - confirm_time = a.confirm_time == null ? "" : a.confirm_time.Value.ToString("yyyy-MM-dd hh:mm:ss"), + promoter_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS), + response_time = a.response_time == null ? "" : a.response_time.Value.ToString(DbTimeFormat.SS), + start_repair_time = a.start_repair_time == null ? "" : a.start_repair_time.Value.ToString(DbTimeFormat.SS), + end_repair_time = a.end_repair_time == null ? "" : a.end_repair_time.Value.ToString(DbTimeFormat.SS), + confirm_time = a.confirm_time == null ? "" : a.confirm_time.Value.ToString(DbTimeFormat.SS), status = f.FullName, }).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result); } + + [HttpPost] + public async Task GetAndonPdaList(AndonPdaListInput input) + { + Dictionary queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary() : input.queryJson.ToObject>(); + string? status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : ""; + List statusList = new(); + if (!string.IsNullOrEmpty(status)) + { + switch (status) + { + case "1": + statusList.Add(DictConst.AndonStatusHJZ); + break; + case "2": + statusList.Add(DictConst.AndonStatusYXY); + statusList.Add(DictConst.AndonStatusCLZ); + break; + case "3": + statusList.Add(DictConst.AndonStatusDQR); + statusList.Add(DictConst.AndonStatusYWC); + break; + } + } + if (string.IsNullOrEmpty(input.sidx)) + { + input.sidx = "create_time"; + input.sort = "desc"; + } + + + SqlSugarPagedList result = await _db.Queryable() + .LeftJoin((a, b) => a.andon_info_id == b.id) + .LeftJoin((a, b, c) => a.repair_id == c.Id) + .LeftJoin((a, b, c, d) => a.create_id == d.Id) + .LeftJoin((a, b, c, d, e) => e.EnCode == DictConst.AndonStatus) + .LeftJoin((a, b, c, d, e, f) => a.status == f.EnCode && e.Id == f.DictionaryTypeId) + .WhereIF(statusList.Count > 0, a => statusList.Contains(a.status)) + .Select((a, b, c, d, e, f) => new AndonPadListOutput + { + id = a.id, + andon_info_name = b.name, + promoter_name = d.RealName, + repair_name = c.RealName, + promoter_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS), + response_time = a.response_time == null ? "" : a.response_time.Value.ToString(DbTimeFormat.SS), + start_repair_time = a.start_repair_time == null ? "" : a.start_repair_time.Value.ToString(DbTimeFormat.SS), + end_repair_time = a.end_repair_time == null ? "" : a.end_repair_time.Value.ToString(DbTimeFormat.SS), + confirm_time = a.confirm_time == null ? "" : a.confirm_time.Value.ToString(DbTimeFormat.SS), + status = f.FullName, + }) + .MergeTable() + .OrderBy($"{input.sidx} {input.sort}") + .ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + + } [HttpPost] public async Task AddAndon(AddAndonInput input) @@ -247,19 +305,28 @@ namespace Tnb.ProductionMgr AndonRecords andonRecords = await _db.Queryable().SingleAsync(x => x.id == id); if (andonRecords != null) { - if (andonRecords.status != DictConst.AndonStatusYXY) + if (andonRecords.repair_id!=_userManager.UserId) { - throw Oops.Bah($"状态错误"); + UserEntity user = await _db.Queryable().SingleAsync(x => x.Id == andonRecords.repair_id); + throw Oops.Bah($"您不是处理人"); } else { - _ = await _db.Updateable() - .SetColumns(x => x.start_repair_time == DateTime.Now) - .Where(x => x.id == id) - .ExecuteCommandAsync(); - return true; + if (andonRecords.status != DictConst.AndonStatusYXY) + { + throw Oops.Bah($"状态错误"); + } + else + { + _ = await _db.Updateable() + .SetColumns(x => x.start_repair_time == DateTime.Now) + .Where(x => x.id == id) + .ExecuteCommandAsync(); + return true; + } } + } else { @@ -274,19 +341,28 @@ namespace Tnb.ProductionMgr AndonRecords andonRecords = await _db.Queryable().SingleAsync(x => x.id == id); if (andonRecords != null) { - if (andonRecords.status != DictConst.AndonStatusCLZ) + if (andonRecords.repair_id!=_userManager.UserId) { - throw Oops.Bah($"状态错误"); + UserEntity user = await _db.Queryable().SingleAsync(x => x.Id == andonRecords.repair_id); + throw Oops.Bah($"您不是处理人"); } else { - _ = await _db.Updateable() - .SetColumns(x => x.end_repair_time == DateTime.Now) - .Where(x => x.id == id) - .ExecuteCommandAsync(); - return true; + if (andonRecords.status != DictConst.AndonStatusCLZ) + { + throw Oops.Bah($"状态错误"); + } + else + { + _ = await _db.Updateable() + .SetColumns(x => x.end_repair_time == DateTime.Now) + .Where(x => x.id == id) + .ExecuteCommandAsync(); + return true; + } } + } else { @@ -301,19 +377,28 @@ namespace Tnb.ProductionMgr AndonRecords andonRecords = await _db.Queryable().SingleAsync(x => x.id == id); if (andonRecords != null) { - if (andonRecords.status != DictConst.AndonStatusYWC) + if (andonRecords.repair_id!=_userManager.UserId) { - throw Oops.Bah($"状态错误"); + UserEntity user = await _db.Queryable().SingleAsync(x => x.Id == andonRecords.repair_id); + throw Oops.Bah($"您不是处理人"); } else { - _ = await _db.Updateable() - .SetColumns(x => x.confirm_time == DateTime.Now) - .Where(x => x.id == id) - .ExecuteCommandAsync(); - return true; + if (andonRecords.status != DictConst.AndonStatusYWC) + { + throw Oops.Bah($"状态错误"); + } + else + { + _ = await _db.Updateable() + .SetColumns(x => x.confirm_time == DateTime.Now) + .Where(x => x.id == id) + .ExecuteCommandAsync(); + return true; + } } + } else {