From 6f826598cb671a0c7248c196b001f3ac7b25d43d Mon Sep 17 00:00:00 2001
From: zhou keda <1315948824@qq.com>
Date: Mon, 9 Sep 2024 17:28:14 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E5=8F=82=E6=95=B0=E6=B5=8B?=
=?UTF-8?q?=E7=82=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/PerAbnormalAlarm.cs | 137 ++++++++++++++++++
.../Entity/PerProcessStandardsD.cs | 2 +
.../Entity/PerProcessStandardsH.cs | 6 +
.../Tnb.ProductionMgr/TimeWorkService.cs | 109 ++++++++++++++
4 files changed, 254 insertions(+)
create mode 100644 PerMgr/Tnb.PerMgr.Entities/Entity/PerAbnormalAlarm.cs
diff --git a/PerMgr/Tnb.PerMgr.Entities/Entity/PerAbnormalAlarm.cs b/PerMgr/Tnb.PerMgr.Entities/Entity/PerAbnormalAlarm.cs
new file mode 100644
index 00000000..ac7aca2d
--- /dev/null
+++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerAbnormalAlarm.cs
@@ -0,0 +1,137 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.PerMgr.Entities;
+
+///
+/// 异常告警
+///
+[SugarTable("per_abnormal_alarm")]
+public partial class PerAbnormalAlarm : BaseEntity
+{
+ public PerAbnormalAlarm()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 告警编号
+ ///
+ public string? code { get; set; }
+
+ ///
+ /// 生产任务单id
+ ///
+ public string? mo_task_id { get; set; }
+
+ ///
+ /// 生产任务编号
+ ///
+ public string? mo_task_code { get; set; }
+
+ ///
+ /// 关联单id
+ ///
+ public string? association_id { get; set; }
+
+ ///
+ /// 告警类别
+ ///
+ public string type { get; set; } = string.Empty;
+
+ ///
+ /// 设备id
+ ///
+ public string? equip_id { get; set; }
+
+ ///
+ /// 模具id
+ ///
+ public string? mold_id { get; set; }
+
+ ///
+ /// 产品id
+ ///
+ public string? product_id { get; set; }
+
+ ///
+ /// 工艺标准id
+ ///
+ public string? process_standards_id { get; set; }
+
+ ///
+ /// 实际值/修改设定值
+ ///
+ public decimal? real_value { get; set; }
+
+ ///
+ /// 设定值
+ ///
+ public decimal? set_value { get; set; }
+
+ ///
+ /// 工艺标准项id
+ ///
+ public string? process_standards_item_id { get; set; }
+
+ ///
+ /// 告警内容
+ ///
+ public string? content { get; set; }
+
+ ///
+ /// 状态
+ ///
+ public string? status { get; set; }
+
+ ///
+ /// 上限
+ ///
+ public decimal? upper_value { get; set; }
+
+ ///
+ /// 下限
+ ///
+ public decimal? lower_value { get; set; }
+
+ ///
+ /// 工艺标准版本
+ ///
+ public string? process_standards_version { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+ ///
+ /// 工艺参数id
+ ///
+ public string? process_param_id { get; set; }
+
+ ///
+ /// 流程任务Id
+ ///
+ public string? f_flowtaskid { get; set; }
+
+ ///
+ /// 流程引擎Id
+ ///
+ public string? f_flowid { get; set; }
+
+ ///
+ /// 工艺告警类别1 实际值告警 2 设定值告警
+ ///
+ public string? process_alarm_type { get; set; }
+
+}
diff --git a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs
index 0dd10a74..ceac9bd0 100644
--- a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs
+++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs
@@ -48,5 +48,7 @@ public partial class PerProcessStandardsD : BaseEntity
/// 数据采集id
///
public string? daq_id { get; set; }
+
+ public string name { get; set; }
}
\ No newline at end of file
diff --git a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
index 7a33f8f7..61991402 100644
--- a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
+++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
@@ -108,5 +108,11 @@ public partial class PerProcessStandardsH : BaseEntity
/// 成型周期
///
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; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
index 52ed2305..4a46c631 100644
--- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
@@ -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;
}
+ ///
+ /// 监测工艺
+ ///
+ ///
+ [HttpGet]
+ [AllowAnonymous]
+ public async Task MonitorPer()
+ {
+ List perProcessStandardsHs = await _db.Queryable()
+ .InnerJoin((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 hids = perProcessStandardsHs.Select(x => x.id).ToList();
+ List eqpDaqs = await _db.Queryable()
+ .InnerJoin((a, b) => a.id == b.daq_id)
+ .Where((a, b) => hids.Contains(b.process_standards_id))
+ .ToListAsync();
+ List insertList = new List();
+
+ foreach (var item in perProcessStandardsHs)
+ {
+ List processStandardsDs = await _db.Queryable()
+ .InnerJoin((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(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 "成功";
+ }
+
}
}
\ No newline at end of file