工艺参数测点
This commit is contained in:
137
PerMgr/Tnb.PerMgr.Entities/Entity/PerAbnormalAlarm.cs
Normal file
137
PerMgr/Tnb.PerMgr.Entities/Entity/PerAbnormalAlarm.cs
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.PerMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异常告警
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("per_abnormal_alarm")]
|
||||||
|
public partial class PerAbnormalAlarm : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public PerAbnormalAlarm()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 告警编号
|
||||||
|
/// </summary>
|
||||||
|
public string? code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生产任务单id
|
||||||
|
/// </summary>
|
||||||
|
public string? mo_task_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生产任务编号
|
||||||
|
/// </summary>
|
||||||
|
public string? mo_task_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关联单id
|
||||||
|
/// </summary>
|
||||||
|
public string? association_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 告警类别
|
||||||
|
/// </summary>
|
||||||
|
public string type { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备id
|
||||||
|
/// </summary>
|
||||||
|
public string? equip_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模具id
|
||||||
|
/// </summary>
|
||||||
|
public string? mold_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 产品id
|
||||||
|
/// </summary>
|
||||||
|
public string? product_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺标准id
|
||||||
|
/// </summary>
|
||||||
|
public string? process_standards_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 实际值/修改设定值
|
||||||
|
/// </summary>
|
||||||
|
public decimal? real_value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设定值
|
||||||
|
/// </summary>
|
||||||
|
public decimal? set_value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺标准项id
|
||||||
|
/// </summary>
|
||||||
|
public string? process_standards_item_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 告警内容
|
||||||
|
/// </summary>
|
||||||
|
public string? content { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 状态
|
||||||
|
/// </summary>
|
||||||
|
public string? status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上限
|
||||||
|
/// </summary>
|
||||||
|
public decimal? upper_value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下限
|
||||||
|
/// </summary>
|
||||||
|
public decimal? lower_value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺标准版本
|
||||||
|
/// </summary>
|
||||||
|
public string? process_standards_version { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建用户
|
||||||
|
/// </summary>
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所属组织
|
||||||
|
/// </summary>
|
||||||
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺参数id
|
||||||
|
/// </summary>
|
||||||
|
public string? process_param_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程任务Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowtaskid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程引擎Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺告警类别1 实际值告警 2 设定值告警
|
||||||
|
/// </summary>
|
||||||
|
public string? process_alarm_type { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -48,5 +48,7 @@ public partial class PerProcessStandardsD : BaseEntity<string>
|
|||||||
/// 数据采集id
|
/// 数据采集id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? daq_id { get; set; }
|
public string? daq_id { get; set; }
|
||||||
|
|
||||||
|
public string name { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -108,5 +108,11 @@ public partial class PerProcessStandardsH : BaseEntity<string>
|
|||||||
/// 成型周期
|
/// 成型周期
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? moulding_cycle { get; set; }
|
public decimal? moulding_cycle { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public string mo_task_id { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public string mo_task_code { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ using Tnb.ProductionMgr.Entities.Entity;
|
|||||||
using Tnb.ProductionMgr.Entities.Entity.ErpEntity;
|
using Tnb.ProductionMgr.Entities.Entity.ErpEntity;
|
||||||
using Tnb.BasicData.Entities.Dto;
|
using Tnb.BasicData.Entities.Dto;
|
||||||
using Tnb.BasicData;
|
using Tnb.BasicData;
|
||||||
|
using Tnb.PerMgr.Entities;
|
||||||
|
|
||||||
namespace Tnb.ProductionMgr
|
namespace Tnb.ProductionMgr
|
||||||
{
|
{
|
||||||
@@ -1600,5 +1601,113 @@ namespace Tnb.ProductionMgr
|
|||||||
return msg;
|
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 "成功";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user