This commit is contained in:
yang.lee
2023-12-06 11:48:09 +08:00
3 changed files with 20 additions and 3 deletions

View File

@@ -106,7 +106,11 @@ namespace Tnb.EquipMgr
a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss");
})
.ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
var EqpMaintainRecordHs = await db.Queryable<EqpMaintainRecordH>().Where(p => list.list.Select(p => p.equip_id_id).ToList().Contains(p.equip_id)).ToListAsync();
foreach (var data in list.list)
{
data.last_execute_time = EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).Any() ? EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
}
return PageResult<EqpMaintainRecordListOutput>.SqlSugarPageResult(list);
}

View File

@@ -12,5 +12,7 @@ namespace Tnb.ProductionMgr.Entities.Dto
public string? end_repair_time { get; set; }
public string? confirm_time { get; set; }
public string status { get; set; }
public string breakdown_name { get; set; }
public string andon_type_name { get; set; }
}
}

View File

@@ -105,7 +105,7 @@ namespace Tnb.ProductionMgr
}
if (string.IsNullOrEmpty(input.sidx))
{
input.sidx = "create_time";
input.sidx = "promoter_time";
input.sort = "desc";
}
@@ -116,8 +116,10 @@ namespace Tnb.ProductionMgr
.LeftJoin<UserEntity>((a, b, c, d) => a.create_id == d.Id)
.LeftJoin<DictionaryTypeEntity>((a, b, c, d, e) => e.EnCode == DictConst.AndonStatus)
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e, f) => a.status == f.EnCode && e.Id == f.DictionaryTypeId)
.LeftJoin<AndonBreakDown>((a,b,c,d,e,f,g)=>a.breakdown==g.id)
.LeftJoin<AndonType>((a,b,c,d,e,f,g,h)=>a.andon_type_id==h.id)
.WhereIF(statusList.Count > 0, a => statusList.Contains(a.status))
.Select((a, b, c, d, e, f) => new AndonPadListOutput
.Select((a, b, c, d, e, f,g,h) => new AndonPadListOutput
{
id = a.id,
andon_info_name = b.name,
@@ -129,6 +131,8 @@ namespace Tnb.ProductionMgr
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,
andon_type_name = h.name,
breakdown_name = g.name
})
.MergeTable()
.OrderBy($"{input.sidx} {input.sort}")
@@ -142,7 +146,10 @@ namespace Tnb.ProductionMgr
public async Task<dynamic> AddAndon(AddAndonInput input)
{
AndonInfo andonInfo = await _db.Queryable<AndonInfo>().SingleAsync(x => x.id == input.andon_info_id);
AndonBreakDown andonBreakDown = await _db.Queryable<AndonBreakDown>().SingleAsync(x => x.id == input.andon_breakdown_id);
AndonRecords andonRecords = input.Adapt<AndonRecords>();
andonRecords.breakdown = input.andon_breakdown_id;
andonRecords.breakdown_type = andonBreakDown?.type_id;
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
{
@@ -279,6 +286,7 @@ namespace Tnb.ProductionMgr
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.repair_id == _userManager.UserId)
.SetColumns(x=>x.status==DictConst.AndonStatusYXY)
.SetColumns(x => x.response_time == DateTime.Now)
.ExecuteCommandAsync();
Dictionary<string, string> postData = new()
@@ -320,6 +328,7 @@ namespace Tnb.ProductionMgr
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.start_repair_time == DateTime.Now)
.SetColumns(x=>x.status==DictConst.AndonStatusCLZ)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return true;
@@ -356,6 +365,7 @@ namespace Tnb.ProductionMgr
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.end_repair_time == DateTime.Now)
.SetColumns(x=>x.status==DictConst.AndonStatusDQR)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return true;
@@ -392,6 +402,7 @@ namespace Tnb.ProductionMgr
{
_ = await _db.Updateable<AndonRecords>()
.SetColumns(x => x.confirm_time == DateTime.Now)
.SetColumns(x=>x.status==DictConst.AndonStatusYWC)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return true;