执行代码清理,修复warning

This commit is contained in:
2023-11-06 19:59:12 +08:00
parent c6b8dfc861
commit 1dbb17f103
118 changed files with 5046 additions and 4111 deletions

View File

@@ -55,17 +55,17 @@ namespace Tnb.EquipMgr
.Where(a => a.maintain_plan_id == planId)
.Select((a, b, c, d) => new
{
mold_id = a.mold_id,
plan_start_time = d.plan_start_time,
designer = d.designer
a.mold_id,
d.plan_start_time,
d.designer
})
.ToListAsync();
var moldids = planMoldRelations.Select(x => x.mold_id).ToList();
var molds = await _db.Queryable<ToolMolds>().Where(it => moldids.Contains(it.id)).ToListAsync();
List<string> moldids = planMoldRelations.Select(x => x.mold_id).ToList();
List<ToolMolds> molds = await _db.Queryable<ToolMolds>().Where(it => moldids.Contains(it.id)).ToListAsync();
foreach (var planMoldRelation in planMoldRelations)
{
var mold = molds.Where(p => p.id == planMoldRelation.mold_id).FirstOrDefault();
ToolMolds? mold = molds.Where(p => p.id == planMoldRelation.mold_id).FirstOrDefault();
if (mold != null)
{
dynamic info = new ExpandoObject();
@@ -74,12 +74,12 @@ namespace Tnb.EquipMgr
info.mold_name = mold.mold_name;
info.mold_status = (await _dictionaryDataService.GetInfo(mold.mold_status!))?.FullName;
info.maintain_qty = mold.maintain_qty;
info.designer = planMoldRelation.designer == null ? "" : planMoldRelation.designer;
info.designer = planMoldRelation.designer ?? "";
info.plan_start_time = planMoldRelation.plan_start_time == null ? "" : ((DateTime)planMoldRelation.plan_start_time).ToString("yyyy-MM-dd");
var moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
ToolMoldsEquipment moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
if (moldEqpRelation != null)
{
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moldEqpRelation.equipment_id);
EqpEquipment eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moldEqpRelation.equipment_id);
info.eqp_code = eqp.code;
info.eqp_name = eqp.name;
}
@@ -92,19 +92,21 @@ namespace Tnb.EquipMgr
[HttpGet]
public async Task<dynamic> GetMaintainInfo([FromQuery] MaintainInfoQueryinput input)
{
Dictionary<string, string> dicstatus = new Dictionary<string, string>();
dicstatus.Add("UnMaintain", "待保养");
dicstatus.Add("Completed", "已完成");
Dictionary<string, string> dicstatus = new()
{
{ "UnMaintain", "待保养" },
{ "Completed", "已完成" }
};
List<dynamic> result = new();
var plans = await _db.Queryable<ToolMoldMaintainPlan>().ToListAsync();
var ToolMolds = await _db.Queryable<ToolMolds>().ToListAsync();
var ToolMoldsEquipments = await _db.Queryable<ToolMoldsEquipment>().ToListAsync();
var EqpEquipments = await _db.Queryable<EqpEquipment>().ToListAsync();
var dic = await _db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == "26149299883285").ToListAsync();
var users = await _db.Queryable<UserEntity>().ToListAsync();
var records = _db.Queryable<ToolMoldMaintainItemRecord>().ToList();
var runrecords = _db.Queryable<ToolMoldMaintainRunRecord>().ToList();
foreach (var plan in plans)
List<ToolMoldMaintainPlan> plans = await _db.Queryable<ToolMoldMaintainPlan>().ToListAsync();
List<ToolMolds> ToolMolds = await _db.Queryable<ToolMolds>().ToListAsync();
List<ToolMoldsEquipment> ToolMoldsEquipments = await _db.Queryable<ToolMoldsEquipment>().ToListAsync();
List<EqpEquipment> EqpEquipments = await _db.Queryable<EqpEquipment>().ToListAsync();
List<DictionaryDataEntity> dic = await _db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == "26149299883285").ToListAsync();
List<UserEntity> users = await _db.Queryable<UserEntity>().ToListAsync();
List<ToolMoldMaintainItemRecord> records = _db.Queryable<ToolMoldMaintainItemRecord>().ToList();
List<ToolMoldMaintainRunRecord> runrecords = _db.Queryable<ToolMoldMaintainRunRecord>().ToList();
foreach (ToolMoldMaintainPlan plan in plans)
{
var planMoldRelations = await _db.Queryable<ToolMoldMaintainPlanRelation>()
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
@@ -112,25 +114,27 @@ namespace Tnb.EquipMgr
.Where(a => a.maintain_plan_id == plan.id)
.Select((a, b, c) => new
{
mold_id = a.mold_id,
plan_start_time = c.plan_start_time,
a.mold_id,
c.plan_start_time,
}).ToListAsync();
if (planMoldRelations?.Count > 0)
{
var mids = planMoldRelations.Select(x => x.mold_id).ToList();
var molds = ToolMolds.Where(it => mids.Contains(it.id))
List<string> mids = planMoldRelations.Select(x => x.mold_id).ToList();
List<ToolMolds> molds = ToolMolds.Where(it => mids.Contains(it.id))
.WhereIF(!string.IsNullOrEmpty(input.keyword), p => p.mold_code!.Contains(input.keyword!) || p.mold_name!.Contains(input.keyword!))
.ToList();
if (molds?.Count > 0)
{
for (int i = 0, cnt = molds.Count; i < cnt; i++)
{
var mold = molds[i];
ToolMolds mold = molds[i];
if (!string.IsNullOrEmpty(input.status))
{
var moldstatus = records.Where(p => p.mold_id == mold.id && p.plan_id == plan.id).Any() ? "已完成" : "待保养";
string moldstatus = records.Where(p => p.mold_id == mold.id && p.plan_id == plan.id).Any() ? "已完成" : "待保养";
if (input.status != moldstatus)
{
continue;
}
}
dynamic info = new ExpandoObject();
info.mold_id = mold.id;
@@ -146,13 +150,13 @@ namespace Tnb.EquipMgr
info.starttime = "";
if (runrecords.Where(p => p.mold_code == mold.mold_code && p.plan_code == plan.plan_code).Any())
{
var run = runrecords.Where(p => p.mold_code == mold.mold_code && p.plan_code == plan.plan_code).First();
ToolMoldMaintainRunRecord run = runrecords.Where(p => p.mold_code == mold.mold_code && p.plan_code == plan.plan_code).First();
info.starttime = run.plan_start_time != null ? ((DateTime)run.plan_start_time).ToString("yyyy-MM-dd") : "";
}
var moldEqpRelation = ToolMoldsEquipments.Where(it => it.mold_id == mold.id).FirstOrDefault();
ToolMoldsEquipment? moldEqpRelation = ToolMoldsEquipments.Where(it => it.mold_id == mold.id).FirstOrDefault();
if (moldEqpRelation != null)
{
var eqp = EqpEquipments.Where(it => it.id == moldEqpRelation.equipment_id).FirstOrDefault();
EqpEquipment? eqp = EqpEquipments.Where(it => it.id == moldEqpRelation.equipment_id).FirstOrDefault();
if (eqp != null)
{
info.eqp_code = eqp.code;
@@ -167,9 +171,14 @@ namespace Tnb.EquipMgr
if (!string.IsNullOrEmpty(input.sort))
{
if (input.sort == "createtime")
{
result = result.OrderByDescending(p => p.createtime).ToList();
}
if (input.sort == "plan_start_time")
result = result.OrderByDescending(p => p.plan_start_time).ToList(); ;
{
result = result.OrderByDescending(p => p.plan_start_time).ToList();
};
}
return result;
}
@@ -188,8 +197,8 @@ namespace Tnb.EquipMgr
{
input.sidx = "b." + input.sidx;
}
var records = await _db.Queryable<ToolMoldMaintainItemRecord>().Select(p => p.plan_id + p.mold_id).ToListAsync();
var result = await _db.Queryable<ToolMoldMaintainPlanRelation>()
List<string> records = await _db.Queryable<ToolMoldMaintainItemRecord>().Select(p => p.plan_id + p.mold_id).ToListAsync();
SqlSugarPagedList<PadMainListOutput> result = await _db.Queryable<ToolMoldMaintainPlanRelation>()
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.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)
@@ -214,7 +223,7 @@ namespace Tnb.EquipMgr
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),
starttime = d.plan_start_time == null ? "" : d.plan_start_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);
}
@@ -244,8 +253,12 @@ namespace Tnb.EquipMgr
[HttpGet]
public async Task<dynamic> GetCheckItemAndGrpByMoldId([FromQuery] CheckItemQueryinput input)
{
if (input == null) throw new ArgumentNullException(nameof(input));
var items = await _db.Queryable<ToolMoldMaintainPlanRelation>()
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
List<CheckItemOutput>? items = await _db.Queryable<ToolMoldMaintainPlanRelation>()
.InnerJoin<ToolMoldMaintainGroupRelation>((a, b) => a.mold_id == b.mold_id)
.InnerJoin<ToolMoldMaintainGroupItem>((a, b, c) => b.item_group_id == c.item_group_id)
.InnerJoin<ToolMoldMaintainGroup>((a, b, c, d) => c.item_group_id == d.id)
@@ -262,22 +275,25 @@ namespace Tnb.EquipMgr
})
.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();
ToolMoldMaintainPlanRelation 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,
item_id = it.item_id,
item_group_id = it.item_group_id,
mold_id = it.mold_id,
it.plan_id,
it.item_id,
it.item_group_id,
it.mold_id,
}).ToListAsync();
var dicCheckItems = checkItems.GroupBy(g => $"{g.plan_id}{g.mold_id}{g.item_group_id}{g.item_id}").ToDictionary(x => x.Key, x => x.FirstOrDefault());
if (items?.Count > 0 && checkItems?.Count > 0)
{
foreach (var item in items)
foreach (CheckItemOutput? item in items)
{
var key = $"{item.plan_id}{item.mold_id}{item.item_group_id}{item.item_id}";
string key = $"{item.plan_id}{item.mold_id}{item.item_group_id}{item.item_id}";
if (dicCheckItems.ContainsKey(key) && dicCheckItems[key] != null)
{
item.status = 1;
@@ -300,8 +316,12 @@ namespace Tnb.EquipMgr
[HttpPost]
public async Task MaintainStart(MoldMaintainRunUpInput input)
{
if (input == null) throw new ArgumentNullException("input");
var flag = _db.Queryable<ToolMoldMaintainRunRecord>()
if (input == null)
{
throw new ArgumentNullException("input");
}
bool flag = _db.Queryable<ToolMoldMaintainRunRecord>()
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.plan_code == b.plan_code)
.LeftJoin<ToolMolds>((a, b, c) => a.mold_code == c.mold_code)
.Where((a, b, c) => b.id == input.plan_id && c.id == input.mold_id).Any();
@@ -313,33 +333,41 @@ namespace Tnb.EquipMgr
{
await _db.Ado.BeginTranAsync();
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.MaintainStatusTypeId);
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == input.mold_id);
Dictionary<string, object> dic = await _dictionaryDataService.GetDicByTypeId(DictConst.MaintainStatusTypeId);
ToolMolds mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == input.mold_id);
if (mold != null)
{
mold.mold_status = MoldUseStatus.MOLD_USE_STATUS_MAINTAIN_ID;
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)
bool isOk = await _db.Updateable<ToolMolds>(mold).Where(it => it.id == input.mold_id).ExecuteCommandHasChangeAsync();
if (!isOk)
{
throw Oops.Oh(ErrorCode.COM1001);
}
ToolMoldMaintainPlan? plan = await _db.Queryable<ToolMoldMaintainPlanRelation>().LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
.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)
{
//插入保养计划记录
ToolMoldMaintainRunRecord record = new();
record.plan_code = plan.plan_code;
record.mode = plan.mode;
record.plan_status = dic.ContainsKey(plan.plan_code) ? dic[plan.plan_code].ToString() : "";
record.designer = _userManager.RealName;
record.designer_time = DateTime.Now;
record.mold_code = mold.mold_code;
record.mold_name = mold.mold_name;
record.plan_start_time = string.IsNullOrEmpty(input.starttime) ? DateTime.Now : DateTime.Parse(input.starttime);
var row = await _db.Insertable(record).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
ToolMoldMaintainRunRecord record = new()
{
plan_code = plan.plan_code,
mode = plan.mode,
plan_status = dic.ContainsKey(plan.plan_code) ? dic[plan.plan_code].ToString() : "",
designer = _userManager.RealName,
designer_time = DateTime.Now,
mold_code = mold.mold_code,
mold_name = mold.mold_name,
plan_start_time = string.IsNullOrEmpty(input.starttime) ? DateTime.Now : DateTime.Parse(input.starttime)
};
int 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);
IEnumerable<string> 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>()
@@ -374,16 +402,21 @@ namespace Tnb.EquipMgr
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;
record_d.check_item_name = info.check_item_name;
ToolMoldMaintainRunRecordD record_d = new()
{
mainid = record.id,
group_id = info.group_id,
group_name = info.group_name,
check_item_id = info.check_item_id,
check_item_name = info.check_item_name
};
recordDs.Add(record_d);
}
row = await _db.Insertable(recordDs).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
if (row < 1)
{
throw Oops.Oh(ErrorCode.COM1001);
}
}
}
}
@@ -405,47 +438,71 @@ namespace Tnb.EquipMgr
[HttpPost]
public async Task FinishMaintain(MoldMaintainRunUpInput input)
{
if (input == null) throw new ArgumentNullException("input");
if (input.items == null || input.items.Count == 0) throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty");
List<ToolMoldMaintainItemRecord> records = new();
foreach (var item in input.items)
if (input == null)
{
ToolMoldMaintainItemRecord record = new();
record.plan_id = input.plan_id;
record.mold_id = input.mold_id;
record.item_group_id = item.item_group_id;
record.item_id = item.item_id;
record.status = 1;
record.result = item.result;
throw new ArgumentNullException("input");
}
if (input.items == null || input.items.Count == 0)
{
throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty");
}
List<ToolMoldMaintainItemRecord> records = new();
foreach (MaintainItemInfo item in input.items)
{
ToolMoldMaintainItemRecord record = new()
{
plan_id = input.plan_id,
mold_id = input.mold_id,
item_group_id = item.item_group_id,
item_id = item.item_id,
status = 1,
result = item.result
};
records.Add(record);
}
await _db.Insertable(records).ExecuteCommandAsync();
await _db.Updateable<ToolMolds>().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLD_USE_STATUS_ZK_ID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
var count = await _db.Queryable<ToolMoldMaintainPlanRelation>().Where(p => p.maintain_plan_id == input.plan_id).Select(p => p.mold_id).Distinct().CountAsync();
var finish = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(p => p.plan_id == input.plan_id).Select(p => p.mold_id).Distinct().CountAsync();
_ = await _db.Insertable(records).ExecuteCommandAsync();
_ = await _db.Updateable<ToolMolds>().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLD_USE_STATUS_ZK_ID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
int count = await _db.Queryable<ToolMoldMaintainPlanRelation>().Where(p => p.maintain_plan_id == input.plan_id).Select(p => p.mold_id).Distinct().CountAsync();
int finish = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(p => p.plan_id == input.plan_id).Select(p => p.mold_id).Distinct().CountAsync();
if (count == finish)
await _db.Updateable<ToolMoldMaintainPlan>().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync();
{
_ = await _db.Updateable<ToolMoldMaintainPlan>().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync();
}
}
[HttpPost]
public async Task MaintainItemFinish(MoldMaintainRunUpInput input)
{
if (input == null) throw new ArgumentNullException("input");
if (input.items == null || input.items.Count == 0) throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty");
List<ToolMoldMaintainItemRecord> records = new();
foreach (var item in input.items)
if (input == null)
{
ToolMoldMaintainItemRecord record = new();
record.plan_id = input.plan_id;
record.mold_id = input.mold_id;
record.item_group_id = item.item_group_id;
record.item_id = item.item_id;
record.status = 1;
throw new ArgumentNullException("input");
}
if (input.items == null || input.items.Count == 0)
{
throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty");
}
List<ToolMoldMaintainItemRecord> records = new();
foreach (MaintainItemInfo item in input.items)
{
ToolMoldMaintainItemRecord record = new()
{
plan_id = input.plan_id,
mold_id = input.mold_id,
item_group_id = item.item_group_id,
item_id = item.item_id,
status = 1
};
records.Add(record);
}
var row = await _db.Insertable(records).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
int row = await _db.Insertable(records).ExecuteCommandAsync();
if (row < 1)
{
throw Oops.Oh(ErrorCode.COM1001);
}
}
/// <summary>
@@ -456,7 +513,7 @@ namespace Tnb.EquipMgr
[HttpPost]
public async Task MaintainFinish(MoldMaintainRunUpInput input)
{
var items = await _db.Queryable<ToolMoldMaintainPlanRelation>()
List<CheckItemOutput>? items = await _db.Queryable<ToolMoldMaintainPlanRelation>()
.InnerJoin<ToolMoldMaintainGroupRelation>((a, b) => a.mold_id == b.mold_id)
.InnerJoin<ToolMoldMaintainGroupItem>((a, b, c) => b.item_group_id == c.item_group_id)
.InnerJoin<ToolMoldMaintainGroup>((a, b, c, d) => c.item_group_id == d.id)
@@ -473,28 +530,30 @@ namespace Tnb.EquipMgr
})
.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();
ToolMoldMaintainPlanRelation 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,
item_id = it.item_id,
item_group_id = it.item_group_id,
mold_id = it.mold_id,
it.plan_id,
it.item_id,
it.item_group_id,
it.mold_id,
}).ToListAsync();
var dicCheckItems = checkItems.GroupBy(g => $"{g.plan_id}{g.mold_id}{g.item_group_id}{g.item_id}").ToDictionary(x => x.Key, x => x.FirstOrDefault());
var maintainedItems = items.Where(it => dicCheckItems.ContainsKey($"{it.plan_id}{it.mold_id}{it.item_group_id}{it.item_id}") && dicCheckItems[$"{it.plan_id}{it.mold_id}{it.item_group_id}{it.item_id}"] != null).ToList();
if ((items?.Count > 0 && maintainedItems?.Count > 0) || (maintainedItems == null || maintainedItems.Count < 1))
List<CheckItemOutput>? maintainedItems = items.Where(it => dicCheckItems.ContainsKey($"{it.plan_id}{it.mold_id}{it.item_group_id}{it.item_id}") && dicCheckItems[$"{it.plan_id}{it.mold_id}{it.item_group_id}{it.item_id}"] != null).ToList();
if ((items?.Count > 0 && maintainedItems?.Count > 0) || maintainedItems == null || maintainedItems.Count < 1)
{
if (maintainedItems.Count < items.Count || (maintainedItems == null || maintainedItems.Count < 1))
if (maintainedItems.Count < items.Count || maintainedItems == null || maintainedItems.Count < 1)
{
throw new AppFriendlyException("当前模具有未完成的保养项目", 500);
}
}
var row = await _db.Updateable<ToolMolds>().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLD_USE_STATUS_ZK_ID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
var allMoldStatus = await _db.Queryable<ToolMoldMaintainPlanRelation>().InnerJoin<ToolMolds>((a, b) => a.mold_id == b.id)
int row = await _db.Updateable<ToolMolds>().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLD_USE_STATUS_ZK_ID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
List<string?> allMoldStatus = await _db.Queryable<ToolMoldMaintainPlanRelation>().InnerJoin<ToolMolds>((a, b) => a.mold_id == b.id)
.Where((a, b) => a.maintain_plan_id == input.plan_id)
.Select((a, b) => b.mold_status)
.ToListAsync();
@@ -502,8 +561,10 @@ namespace Tnb.EquipMgr
{
row = await _db.Updateable<ToolMoldMaintainPlan>().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync();
}
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
if (row < 1)
{
throw Oops.Oh(ErrorCode.COM1001);
}
}
}