模具保养

This commit is contained in:
qianjiawei
2023-12-01 16:21:23 +08:00
parent 955c47da6f
commit fdefdeba97
3 changed files with 46 additions and 11 deletions

View File

@@ -37,4 +37,10 @@
public string result { get; set; } 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; }
}
} }

View File

@@ -16,5 +16,6 @@
public string plan_start_time { get; set; } public string plan_start_time { get; set; }
public string starttime { get; set; } public string starttime { get; set; }
public string finishtime { get; set; }
} }
} }

View File

@@ -196,33 +196,35 @@ namespace Tnb.EquipMgr
else else
{ {
input.sidx = "b." + input.sidx; input.sidx = "b." + input.sidx;
input.sort = "desc";
} }
List<string> records = await _db.Queryable<ToolMoldMaintainItemRecord>().Select(p => p.plan_id + p.mold_id).ToListAsync(); List<string> records = await _db.Queryable<ToolMoldMaintainItemRecord>().Select(p => p.plan_id + p.mold_id).ToListAsync();
SqlSugarPagedList<PadMainListOutput> result = await _db.Queryable<ToolMoldMaintainPlanRelation>() SqlSugarPagedList<PadMainListOutput> result = await _db.Queryable<ToolMoldMaintainPlanRelation>()
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id) .LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id) .LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c, d) => b.plan_code == d.plan_code && c.mold_code == d.mold_code) .LeftJoin<ToolMoldMaintainRunRecord>((a, b, c, d) => b.plan_code == d.plan_code && c.mold_code == d.mold_code)
.LeftJoin<ToolMoldMaintainItemRecord>((a, b, c, d, e) => e.plan_id == b.id && e.mold_id == c.id) // .LeftJoin<ToolMoldMaintainItemRecord>((a, b, c, d, e) => e.plan_id == b.id && e.mold_id == c.id)
.LeftJoin<UserEntity>((a, b, c, d, e, f) => b.create_id == f.Id) .LeftJoin<UserEntity>((a, b, c, d, e) => b.create_id == e.Id)
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e, f, g) => c.mold_status == g.Id) .LeftJoin<DictionaryDataEntity>((a, b, c, d, e, f) => c.mold_status == f.Id)
.Where((a, b, c, d, e, f) => b.create_time != null) .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(!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, g) => b.create_time != null && b.create_time >= start_time) .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, g) => b.create_time != null && b.create_time <= end_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, g) => !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))
.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) => records.Contains(a.maintain_plan_id + a.mold_id))
.Select((a, b, c, d, e, f, g) => new PadMainListOutput .Select((a, b, c, d, e, f) => new PadMainListOutput
{ {
plan_id = b.id, plan_id = b.id,
mold_id = c.id, mold_id = c.id,
mold_code = c.mold_code!, mold_code = c.mold_code!,
mold_name = c.mold_name!, mold_name = c.mold_name!,
mold_status = g.FullName!, mold_status = f.FullName!,
status = input.status, status = input.status,
createuser = f.RealName, createuser = e.RealName,
createtime = b.create_time == null ? "" : b.create_time.Value.ToString(DbTimeFormat.SS), 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), 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), 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); }).OrderBy($"{input.sidx} {input.sort}").ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
return PageResult<PadMainListOutput>.SqlSugarPageResult(result); return PageResult<PadMainListOutput>.SqlSugarPageResult(result);
} }
@@ -303,7 +305,23 @@ namespace Tnb.EquipMgr
return items; return items;
} }
[HttpPost]
public async Task<dynamic> GetMaintainItem(MoldMaintainRunUpInput input)
{
var data = await _db.Queryable<ToolMoldMaintainItemRecord>()
.LeftJoin<ToolMoldMaintainItem>((a, b) => a.item_id == b.id)
.LeftJoin<ToolMoldMaintainGroup>((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;
}
/// <summary> /// <summary>
/// 模具保养计划执行-开始模具保养 /// 模具保养计划执行-开始模具保养
/// </summary> /// </summary>
@@ -447,6 +465,11 @@ namespace Tnb.EquipMgr
{ {
throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty"); throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty");
} }
var plan_code = _db.Queryable<ToolMoldMaintainPlan>().Where(p => p.id == input.plan_id).Select(p=>p.plan_code).First();
var mold_code = _db.Queryable<ToolMolds>().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<ToolMoldMaintainRunRecord>().SetColumns(it => new ToolMoldMaintainRunRecord { plan_end_time = DateTime.Now }).Where(it => it.plan_code == plan_code && it.mold_code== mold_code).ExecuteCommandAsync();
}
List<ToolMoldMaintainItemRecord> records = new(); List<ToolMoldMaintainItemRecord> records = new();
foreach (MaintainItemInfo item in input.items) foreach (MaintainItemInfo item in input.items)
@@ -505,6 +528,11 @@ namespace Tnb.EquipMgr
} }
} }
/// <summary> /// <summary>
/// 模具保养计划执行-保养完成 /// 模具保养计划执行-保养完成
/// </summary> /// </summary>