This commit is contained in:
qianjiawei
2023-09-05 16:15:18 +08:00
parent 893b0bd95f
commit 36e4944e5e
6 changed files with 176 additions and 4 deletions

View File

@@ -135,6 +135,10 @@ namespace Tnb.EquipMgr
item_name = e.name,
})
.ToListAsync();
//新增功能
var ToolMoldMaintainPlanRelation= _db.Queryable<ToolMoldMaintainPlanRelation>().Where((a) => a.maintain_plan_id == input.plan_id && a.mold_id == input.mold_id&& !string.IsNullOrEmpty(a.group_id)).First();
if (ToolMoldMaintainPlanRelation != null)
items = items.Where(a => a.item_group_id == ToolMoldMaintainPlanRelation.group_id).ToList();
var checkItems = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.plan_id == input.plan_id && it.mold_id == input.mold_id).Select(it => new
{
plan_id = it.plan_id,
@@ -183,7 +187,7 @@ namespace Tnb.EquipMgr
var isOk = await _db.Updateable<ToolMolds>(mold).Where(it => it.id == input.mold_id).ExecuteCommandHasChangeAsync();
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
var plan = await _db.Queryable<ToolMoldMaintainPlanRelation>().LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
.Where(a => a.mold_id == input.mold_id).Select((a, b) => b).FirstAsync();
.Where(a => a.mold_id == input.mold_id && a.maintain_plan_id == input.plan_id).Select((a, b) => b).FirstAsync();
if (plan is not null)
{
@@ -200,6 +204,10 @@ namespace Tnb.EquipMgr
var row = await _db.Insertable(record).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
var groupids = _db.Queryable<ToolMoldMaintainPlanRelation>().Where(a => !string.IsNullOrEmpty(a.group_id) && a.mold_id == input.mold_id && a.maintain_plan_id == input.plan_id).ToList().Select(p => p.group_id);
/*
var maintainInfos = await _db.Queryable<ToolMoldMaintainGroupRelation>()
.LeftJoin<ToolMoldMaintainGroup>((a, b) => a.item_group_id == b.id)
.LeftJoin<ToolMoldMaintainGroupItem>((a, b, c) => b.id == c.item_group_id)
@@ -213,12 +221,27 @@ namespace Tnb.EquipMgr
check_item_name = d.name
})
.ToListAsync();
*/
var maintainInfos = await _db.Queryable<ToolMoldMaintainGroupRelation>()
.LeftJoin<ToolMoldMaintainGroup>((a, b) => a.item_group_id == b.id)
.LeftJoin<ToolMoldMaintainGroupItem>((a, b, c) => b.id == c.item_group_id)
.LeftJoin<ToolMoldMaintainItem>((a, b, c, d) => c.item_id == d.id)
.WhereIF(groupids.Count() > 0, (a) => groupids.Contains(a.item_group_id))
.Where(a => a.mold_id == input.mold_id)
.Select((a, b, c, d) => new
{
group_id = b.id,
group_name = b.name,
check_item_id = d.id,
check_item_name = d.name
}).ToListAsync();
if (maintainInfos?.Count > 0)
{
List<ToolMoldMaintainRunRecordD> recordDs = new();
foreach (var info in maintainInfos)
{
ToolMoldMaintainRunRecordD record_d = new();
record_d.mainid = record.id;
record_d.group_id = info.group_id;
record_d.group_name = info.group_name;
record_d.check_item_id = info.check_item_id;
@@ -253,6 +276,7 @@ namespace Tnb.EquipMgr
record.mold_id = input.mold_id;
record.item_group_id = item.item_group_id;
record.item_id = item.item_id;
record.status = 1;
records.Add(record);
}
var row = await _db.Insertable(records).ExecuteCommandAsync();
@@ -283,6 +307,11 @@ namespace Tnb.EquipMgr
item_name = e.name,
})
.ToListAsync();
//新增功能
var ToolMoldMaintainPlanRelation = _db.Queryable<ToolMoldMaintainPlanRelation>().Where((a) => a.maintain_plan_id == input.plan_id && a.mold_id == input.mold_id && !string.IsNullOrEmpty(a.group_id)).First();
if (ToolMoldMaintainPlanRelation != null)
items = items.Where(a => a.item_group_id == ToolMoldMaintainPlanRelation.group_id).ToList();
var checkItems = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.plan_id == input.plan_id && it.mold_id == input.mold_id).Select(it => new
{
plan_id = it.plan_id,