工艺参数测点

This commit is contained in:
2024-09-09 17:28:14 +08:00
parent 8d2f9cc3ac
commit 6f826598cb
4 changed files with 254 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ using Tnb.ProductionMgr.Entities.Entity;
using Tnb.ProductionMgr.Entities.Entity.ErpEntity;
using Tnb.BasicData.Entities.Dto;
using Tnb.BasicData;
using Tnb.PerMgr.Entities;
namespace Tnb.ProductionMgr
{
@@ -1600,5 +1601,113 @@ namespace Tnb.ProductionMgr
return msg;
}
/// <summary>
/// 监测工艺
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<String> MonitorPer()
{
List<PerProcessStandardsH> perProcessStandardsHs = await _db.Queryable<PrdMoTask>()
.InnerJoin<PerProcessStandardsH>((a,b)=>a.material_id==b.output_material_id && a.eqp_id==b.equip_id && a.mold_id==b.molds_id)
.Where((a,b)=>!SqlFunc.IsNullOrEmpty(a.eqp_id) && a.mo_task_status==DictConst.InProgressEnCode && b.enabled==1)
.Select((a, b) => new PerProcessStandardsH
{
id = a.id,
// process_type = b.process_type,
// code = b.code,
// file_name = b.file_name,
// enabled = b.enabled,
output_material_id = b.output_material_id,
equip_id = b.equip_id,
molds_id = b.molds_id,
process_id = b.process_id,
// input_material_id = b.input_material_id,
version = b.version,
// create_id = b.create_id,
// create_time = b.create_time,
// modify_id = b.modify_id,
// modify_time = b.modify_time,
// org_id = b.org_id,
// remark = b.remark,
// f_flowtaskid = b.f_flowtaskid,
// f_flowid = b.f_flowid,
// moulding_cycle = b.moulding_cycle,
mo_task_id = b.mo_task_id,
mo_task_code = b.mo_task_code,
})
.ToListAsync();
List<string> hids = perProcessStandardsHs.Select(x => x.id).ToList();
List<EqpDaq> eqpDaqs = await _db.Queryable<EqpDaq>()
.InnerJoin<PerProcessStandardsD>((a, b) => a.id == b.daq_id)
.Where((a, b) => hids.Contains(b.process_standards_id))
.ToListAsync();
List<PerAbnormalAlarm> insertList = new List<PerAbnormalAlarm>();
foreach (var item in perProcessStandardsHs)
{
List<PerProcessStandardsD> processStandardsDs = await _db.Queryable<PerProcessStandardsD>()
.InnerJoin<PerProcessParam>((x,y)=>x.process_param_id==y.id)
.Where(x=>x.process_standards_id==item.id && !SqlFunc.IsNullOrEmpty(x.daq_id))
.Select((x,y)=>new PerProcessStandardsD
{
id = x.id,
process_standards_id = x.process_standards_id,
process_param_type_id = x.process_param_type_id,
process_param_id = x.process_param_id,
value = x.value,
upper_value = x.upper_value,
lower_value = x.lower_value,
daq_id = x.daq_id,
name = y.name,
})
.ToListAsync();
if (processStandardsDs.IsNullOrEmpty()) continue;
foreach (var dItem in processStandardsDs)
{
EqpDaq eqpDaq = eqpDaqs.Find(x => x.id == dItem.daq_id);
if (eqpDaq == null) continue;
string key = $"{eqpDaq.equip_code}:${eqpDaq.label_name}";
if (await _redisData.ExistsAsync(key))
{
decimal realValue = _redisData.Get<decimal>(key);
if (realValue < dItem.lower_value || realValue > dItem.upper_value)
{
insertList.Add(new PerAbnormalAlarm()
{
id = SnowflakeIdHelper.NextId(),
mo_task_id = item.mo_task_id,
mo_task_code = item.mo_task_code,
type = "10",
equip_id = item.equip_id,
mold_id = item.molds_id,
product_id = item.output_material_id,
process_standards_id = item.id,
process_param_id = dItem.process_param_id,
process_alarm_type = "1",
real_value = realValue,
set_value = dItem.value,
process_standards_item_id = dItem.id,
content = dItem.name,
upper_value = dItem.upper_value,
lower_value = dItem.lower_value,
process_standards_version = item.version,
create_time = DateTime.Now,
});
}
}
}
}
if (!insertList.IsEmpty())
{
await _db.Insertable(insertList).ExecuteCommandAsync();
}
return "成功";
}
}
}