andon
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
using JNPF.Common.Filter;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class AndonPdaListInput : PageInputBase
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,11 +68,11 @@ namespace Tnb.ProductionMgr
|
|||||||
andon_info_name = b.name,
|
andon_info_name = b.name,
|
||||||
promoter_name = d.RealName,
|
promoter_name = d.RealName,
|
||||||
repair_name = c.RealName,
|
repair_name = c.RealName,
|
||||||
promoter_time = a.create_time == null ? "" : a.create_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("yyyy-MM-dd hh:mm: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("yyyy-MM-dd hh:mm: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("yyyy-MM-dd hh:mm: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("yyyy-MM-dd hh:mm:ss"),
|
confirm_time = a.confirm_time == null ? "" : a.confirm_time.Value.ToString(DbTimeFormat.SS),
|
||||||
status = f.FullName,
|
status = f.FullName,
|
||||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
|
|
||||||
@@ -80,6 +80,64 @@ namespace Tnb.ProductionMgr
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetAndonPdaList(AndonPdaListInput input)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||||
|
string? status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : "";
|
||||||
|
List<string> 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<AndonPadListOutput> result = await _db.Queryable<AndonRecords>()
|
||||||
|
.LeftJoin<AndonInfo>((a, b) => a.andon_info_id == b.id)
|
||||||
|
.LeftJoin<UserEntity>((a, b, c) => a.repair_id == c.Id)
|
||||||
|
.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)
|
||||||
|
.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<AndonPadListOutput>.SqlSugarPageResult(result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<dynamic> AddAndon(AddAndonInput input)
|
public async Task<dynamic> AddAndon(AddAndonInput input)
|
||||||
{
|
{
|
||||||
@@ -247,19 +305,28 @@ namespace Tnb.ProductionMgr
|
|||||||
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
|
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
|
||||||
if (andonRecords != null)
|
if (andonRecords != null)
|
||||||
{
|
{
|
||||||
if (andonRecords.status != DictConst.AndonStatusYXY)
|
if (andonRecords.repair_id!=_userManager.UserId)
|
||||||
{
|
{
|
||||||
throw Oops.Bah($"状态错误");
|
UserEntity user = await _db.Queryable<UserEntity>().SingleAsync(x => x.Id == andonRecords.repair_id);
|
||||||
|
throw Oops.Bah($"您不是处理人");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_ = await _db.Updateable<AndonRecords>()
|
if (andonRecords.status != DictConst.AndonStatusYXY)
|
||||||
.SetColumns(x => x.start_repair_time == DateTime.Now)
|
{
|
||||||
.Where(x => x.id == id)
|
throw Oops.Bah($"状态错误");
|
||||||
.ExecuteCommandAsync();
|
}
|
||||||
return true;
|
else
|
||||||
|
{
|
||||||
|
_ = await _db.Updateable<AndonRecords>()
|
||||||
|
.SetColumns(x => x.start_repair_time == DateTime.Now)
|
||||||
|
.Where(x => x.id == id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -274,19 +341,28 @@ namespace Tnb.ProductionMgr
|
|||||||
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
|
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
|
||||||
if (andonRecords != null)
|
if (andonRecords != null)
|
||||||
{
|
{
|
||||||
if (andonRecords.status != DictConst.AndonStatusCLZ)
|
if (andonRecords.repair_id!=_userManager.UserId)
|
||||||
{
|
{
|
||||||
throw Oops.Bah($"状态错误");
|
UserEntity user = await _db.Queryable<UserEntity>().SingleAsync(x => x.Id == andonRecords.repair_id);
|
||||||
|
throw Oops.Bah($"您不是处理人");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_ = await _db.Updateable<AndonRecords>()
|
if (andonRecords.status != DictConst.AndonStatusCLZ)
|
||||||
.SetColumns(x => x.end_repair_time == DateTime.Now)
|
{
|
||||||
.Where(x => x.id == id)
|
throw Oops.Bah($"状态错误");
|
||||||
.ExecuteCommandAsync();
|
}
|
||||||
return true;
|
else
|
||||||
|
{
|
||||||
|
_ = await _db.Updateable<AndonRecords>()
|
||||||
|
.SetColumns(x => x.end_repair_time == DateTime.Now)
|
||||||
|
.Where(x => x.id == id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -301,19 +377,28 @@ namespace Tnb.ProductionMgr
|
|||||||
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
|
AndonRecords andonRecords = await _db.Queryable<AndonRecords>().SingleAsync(x => x.id == id);
|
||||||
if (andonRecords != null)
|
if (andonRecords != null)
|
||||||
{
|
{
|
||||||
if (andonRecords.status != DictConst.AndonStatusYWC)
|
if (andonRecords.repair_id!=_userManager.UserId)
|
||||||
{
|
{
|
||||||
throw Oops.Bah($"状态错误");
|
UserEntity user = await _db.Queryable<UserEntity>().SingleAsync(x => x.Id == andonRecords.repair_id);
|
||||||
|
throw Oops.Bah($"您不是处理人");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_ = await _db.Updateable<AndonRecords>()
|
if (andonRecords.status != DictConst.AndonStatusYWC)
|
||||||
.SetColumns(x => x.confirm_time == DateTime.Now)
|
{
|
||||||
.Where(x => x.id == id)
|
throw Oops.Bah($"状态错误");
|
||||||
.ExecuteCommandAsync();
|
}
|
||||||
return true;
|
else
|
||||||
|
{
|
||||||
|
_ = await _db.Updateable<AndonRecords>()
|
||||||
|
.SetColumns(x => x.confirm_time == DateTime.Now)
|
||||||
|
.Where(x => x.id == id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user