change - 添加报警数据过滤

master
wenjy 2 months ago
parent 3cc1bba50f
commit 8a13bcf707

@ -55,7 +55,7 @@ namespace SlnMesnac.Business
public delegate void GimbaRotationControl(string wPanPos, string wTiltPos, string wZoomPos);
public event GimbaRotationControl GimbaRotationControlEvent;
public AutoModeBusiness(SerilogHelper log, PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices, Irecord_busbar_tempServices record_busbar_TempServices, AppConfig appConfig) : base(log, plc, base_Cabinet_InfoServices, base_Busbar_InfoServices)
public AutoModeBusiness(SerilogHelper log, PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices, Irecord_busbar_tempServices record_busbar_TempServices, Ibase_alarm_infoServices base_Alarm_InfoServices, AppConfig appConfig, Irecord_busbar_alarmServices record_Busbar_AlarmServices) : base(log, plc, base_Cabinet_InfoServices, base_Busbar_InfoServices, base_Alarm_InfoServices, record_Busbar_AlarmServices)
{
_record_busbar_TempServices = record_busbar_TempServices;
_appConfig = appConfig;
@ -244,11 +244,10 @@ namespace SlnMesnac.Business
}
//这里采集数据
_log.Info($"5S后开始测温");
Task.Delay(5000).Wait();
_log.Info($"2S后开始测温");
Task.Delay(2000).Wait();
_log.Info($"温度测量完成,最高温度:{_realTemperatureInfo.fMaxTemperature};最低温度:{_realTemperatureInfo.fMinTemperature};平均温度:{_realTemperatureInfo.fAverageTemperature};温差:{_realTemperatureInfo.fTemperatureDiff}");
this.SaveBusbarTemp(busbar.busbarCode, busbar.cabinetCode, _realTemperatureInfo,busbar.isPictures);
Task.Delay(1000).Wait();
//if (!_plc.writeFloatByAddress("VD1524", 0))
//{
@ -329,22 +328,28 @@ namespace SlnMesnac.Business
recordTime = DateTime.Now,
};
if (realTemperatureInfo.fMaxTemperature > 65)
{
record.isAlarm = 1;
string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
record.filePath = sJpegPicFileName ;
CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
}
else
{
if (isPictures == 1)
{
//if (realTemperatureInfo.fMaxTemperature > 65)
//{
// record.isAlarm = 1;
// string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
// record.filePath = sJpegPicFileName ;
// CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
//}
//else
//{
// if (isPictures == 1)
// {
// string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
// record.filePath = sJpegPicFileName;
// CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
// }
//}
string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
record.filePath = sJpegPicFileName;
CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
}
}
base.JudgBusbarIsAlarm((int)busbarCode, ref record);
var res = _record_busbar_TempServices.Insert(record);

@ -39,7 +39,7 @@ namespace SlnMesnac.Business
private readonly Irecord_busbar_tempServices _record_busbar_TempServices;
public FixedPointBusiness(SerilogHelper log, PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices, Irecord_busbar_tempServices record_busbar_TempServices) : base(log, plc, base_Cabinet_InfoServices, base_Busbar_InfoServices)
public FixedPointBusiness(SerilogHelper log, PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices, Irecord_busbar_tempServices record_busbar_TempServices, Ibase_alarm_infoServices base_Alarm_InfoServices, Irecord_busbar_alarmServices record_Busbar_AlarmServices) : base(log, plc, base_Cabinet_InfoServices, base_Busbar_InfoServices, base_Alarm_InfoServices, record_Busbar_AlarmServices)
{
_record_busbar_TempServices = record_busbar_TempServices;
}
@ -170,11 +170,10 @@ namespace SlnMesnac.Business
GimbaRotationControlEvent?.Invoke(busbar.wPanPos, busbar.wTiltPos, busbar.wZoomPos);
}
_log.Info($"5S后开始测温");
Task.Delay(5000).Wait();
_log.Info($"2S后开始测温");
Task.Delay(2000).Wait();
_log.Info($"温度测量完成,最高温度:{_realTemperatureInfo.fMaxTemperature};最低温度:{_realTemperatureInfo.fMinTemperature};平均温度:{_realTemperatureInfo.fAverageTemperature};温差:{_realTemperatureInfo.fTemperatureDiff}");
this.SaveBusbarTemp(busbar.busbarCode, busbar.cabinetCode, _realTemperatureInfo, busbar.isPictures);
Task.Delay(1000).Wait();
}
/// <summary>
@ -200,22 +199,28 @@ namespace SlnMesnac.Business
recordTime = DateTime.Now,
};
if (realTemperatureInfo.fMaxTemperature > 65)
{
record.isAlarm = 1;
string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
record.filePath = sJpegPicFileName;
CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
}
else
{
if (isPictures == 1)
{
//if (realTemperatureInfo.fMaxTemperature > 65)
//{
// record.isAlarm = 1;
// string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
// record.filePath = sJpegPicFileName;
// CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
//}
//else
//{
// if (isPictures == 1)
// {
// string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
// record.filePath = sJpegPicFileName;
// CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
// }
//}
string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
record.filePath = sJpegPicFileName;
CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
}
}
base.JudgBusbarIsAlarm((int)busbarCode, ref record);
var res = _record_busbar_TempServices.Insert(record);

@ -49,7 +49,7 @@ namespace SlnMesnac.Business
public delegate void GimbaRotationControl(string wPanPos, string wTiltPos, string wZoomPos);
public event GimbaRotationControl GimbaRotationControlEvent;
public InspModeBusiness(SerilogHelper log, PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices, Irecord_inspection_cabinetServices service, Irecord_busbar_tempServices irecord_Busbar_TempServices) : base(log, plc, base_Cabinet_InfoServices, base_Busbar_InfoServices)
public InspModeBusiness(SerilogHelper log, PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices, Irecord_inspection_cabinetServices service, Irecord_busbar_tempServices irecord_Busbar_TempServices,Ibase_alarm_infoServices base_Alarm_InfoServices, Irecord_busbar_alarmServices record_Busbar_AlarmServices) : base(log, plc, base_Cabinet_InfoServices, base_Busbar_InfoServices, base_Alarm_InfoServices, record_Busbar_AlarmServices)
{
_record_busbar_TempServices = irecord_Busbar_TempServices;
_service = service;
@ -186,11 +186,10 @@ namespace SlnMesnac.Business
}
//这里采集数据
_log.Info($"5S后开始测温");
Task.Delay(5000).Wait();
_log.Info($"2S后开始测温");
Task.Delay(2000).Wait();
_log.Info($"温度测量完成,最高温度:{_realTemperatureInfo.fMaxTemperature};最低温度:{_realTemperatureInfo.fMinTemperature};平均温度:{_realTemperatureInfo.fAverageTemperature};温差:{_realTemperatureInfo.fTemperatureDiff}");
this.SaveBusbarTemp(busbar.busbarCode, busbar.cabinetCode, _realTemperatureInfo, busbar.isPictures);
Task.Delay(1000).Wait();
if (busbar.isRotate == 1)
{
@ -266,22 +265,28 @@ namespace SlnMesnac.Business
recordTime = DateTime.Now,
};
if (realTemperatureInfo.fMaxTemperature > 65)
{
record.isAlarm = 1;
string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
record.filePath = sJpegPicFileName;
CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
}
else
{
if (isPictures == 1)
{
//if (realTemperatureInfo.fMaxTemperature > 65)
//{
// record.isAlarm = 1;
// string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
// record.filePath = sJpegPicFileName;
// CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
//}
//else
//{
// if (isPictures == 1)
// {
// string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
// record.filePath = sJpegPicFileName;
// CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
// }
//}
string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
record.filePath = sJpegPicFileName;
CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName);
}
}
base.JudgBusbarIsAlarm((int)busbarCode, ref record);
var res = _record_busbar_TempServices.Insert(record);

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* T14-GEN3-7895
* SlnMesnac.Business
* 04146a2b-c51d-4164-8c51-158a99301078
*
* WenJY
*
* 2024-11-07 9:52:46
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Business
{
/// <summary>
/// 手动模式
/// </summary>
internal class ManualModeBusiness
{
}
}

@ -1,4 +1,5 @@
using Serilog;
using SlnMesnac.Model.dto;
using SlnMesnac.Plc;
using SlnMesnac.Repository;
using SlnMesnac.Repository.service;
@ -41,16 +42,21 @@ namespace SlnMesnac.Business.@base
public readonly Ibase_cabinet_infoServices _ibase_Cabinet_InfoServices;
public readonly Ibase_busbar_infoServices _ibase_Busbar_InfoServices;
private readonly Ibase_alarm_infoServices _ibase_Alarm_InfoServices;
private readonly Irecord_busbar_alarmServices _iRecord_Busbar_AlarmServices;
public bool isFlag = false;
public BaseBusiness(SerilogHelper log,PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices)
public BaseBusiness(SerilogHelper log,PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices,
Ibase_busbar_infoServices base_Busbar_InfoServices, Ibase_alarm_infoServices base_Alarm_InfoServices,
Irecord_busbar_alarmServices record_Busbar_AlarmServices)
{
_log = log;
_plc = plc;
_ibase_Cabinet_InfoServices = base_Cabinet_InfoServices;
_ibase_Busbar_InfoServices = base_Busbar_InfoServices;
_ibase_Alarm_InfoServices = base_Alarm_InfoServices;
_iRecord_Busbar_AlarmServices = record_Busbar_AlarmServices;
}
/// <summary>
@ -122,5 +128,57 @@ namespace SlnMesnac.Business.@base
{
busbarInfos = _ibase_Busbar_InfoServices.Query(x=>x.cabinetCode == cabinetCode && x.isChecked == 1 && x.isInsp == isInsp).ToList();
}
public void JudgBusbarIsAlarm(int busbarCode,ref record_busbar_temp busbarTemp)
{
try
{
var alarmInfos = _ibase_Alarm_InfoServices.Query(x => x.busbarCode == busbarCode).ToList();
if (alarmInfos != null)
{
foreach (var alarm in alarmInfos)
{
record_busbar_alarm busbarAlarm = new record_busbar_alarm();
if (alarm.judgMethod == 1) //大于
{
if (busbarTemp.tempMax < alarm.alarmValue) //取反为正常数据
{
continue;
}
}
else if (alarm.judgMethod == 2) //小于
{
if (busbarTemp.tempMax > alarm.alarmValue) //取反为正常数据
{
continue;
}
}
else
{
continue;
}
busbarAlarm.busbarCode = busbarTemp.busbarCode;
busbarAlarm.cabinetCode = busbarTemp.cabinetCode;
busbarAlarm.tempMax = busbarTemp.tempMax;
busbarAlarm.tempMin = busbarTemp.tempMin;
busbarAlarm.tempAvg = busbarTemp.tempAvg;
busbarAlarm.tempDiff = busbarTemp.tempDiff;
busbarAlarm.filePath = busbarTemp.filePath;
busbarAlarm.alarmType = alarm.alarmType;
busbarAlarm.alarmValue = alarm.alarmValue;
busbarAlarm.recordTime = DateTime.Now;
_iRecord_Busbar_AlarmServices.Insert(busbarAlarm);
busbarTemp.isAlarm = 1;
}
}
}
catch(Exception e)
{
throw new InvalidOperationException($"测温数据判断异常:{e.Message}");
}
}
}
}

@ -0,0 +1,115 @@
using System;
using System.Linq;
using System.Text;
using SqlSugar;
namespace SlnMesnac.Repository
{
///<summary>
///报警信息
///</summary>
[SugarTable("base_alarm_info")]
public partial class base_alarm_info
{
public base_alarm_info(){
}
/// <summary>
/// Desc:标识
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey=true,ColumnName="obj_id")]
public int objId {get;set;}
/// <summary>
/// Desc:母排编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="busbar_code")]
public int? busbarCode {get;set;}
/// <summary>
/// Desc:报警别名
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="alarm_alias")]
public string alarmAlias {get;set;}
/// <summary>
/// Desc:报警内容
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="alarm_content")]
public string alarmContent {get;set;}
/// <summary>
/// Desc:报警类型
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="alarm_type")]
public int? alarmType {get;set;}
/// <summary>
/// Desc:报警阈值
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="alarm_value")]
public decimal? alarmValue {get;set;}
/// <summary>
/// Desc:判断方式:1-大于2-小于
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="judg_method")]
public int? judgMethod {get;set;}
/// <summary>
/// Desc:是否启用:1-是0-否;;0-否
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="is_flag")]
public int? isFlag {get;set;}
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_by")]
public string createdBy {get;set;}
/// <summary>
/// Desc:创建时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_time")]
public DateTime? createdTime {get;set;}
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_by")]
public string updatedBy {get;set;}
/// <summary>
/// Desc:更新时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_time")]
public DateTime? updatedTime {get;set;}
}
}

@ -0,0 +1,113 @@
using System;
using System.Linq;
using System.Text;
using SqlSugar;
namespace SlnMesnac.Repository
{
///<summary>
///巡检报警记录
///</summary>
[SugarTable("record_busbar_alarm")]
public partial class record_busbar_alarm
{
public record_busbar_alarm(){
}
/// <summary>
/// Desc:租户号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="objId")]
public int? objid {get;set;}
/// <summary>
/// Desc:母排编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="busbar_code")]
public int? busbarCode {get;set;}
/// <summary>
/// Desc:电柜编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="cabinet_code")]
public int? cabinetCode {get;set;}
/// <summary>
/// Desc:最高温度
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="temp_max")]
public decimal? tempMax {get;set;}
/// <summary>
/// Desc:最低温度
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="temp_min")]
public decimal? tempMin {get;set;}
/// <summary>
/// Desc:平均温度
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="temp_avg")]
public decimal? tempAvg {get;set;}
/// <summary>
/// Desc:温差
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="temp_diff")]
public decimal? tempDiff {get;set;}
/// <summary>
/// 报警阈值
/// </summary>
[SugarColumn(ColumnName = "alarm_value")]
public decimal? alarmValue { get; set; }
/// <summary>
/// Desc:图像路径
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="file_path")]
public string filePath {get;set;}
/// <summary>
/// Desc:报警类型
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="alarm_type")]
public int? alarmType {get;set;}
/// <summary>
/// Desc:是否标识:1-是0-否
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="is_flag")]
public int? isFlag {get;set;}
/// <summary>
/// Desc:记录时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="record_time")]
public DateTime? recordTime {get;set;}
}
}

@ -0,0 +1,13 @@
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Repository.service
{
public interface Ibase_alarm_infoServices: IBaseService<base_alarm_info>
{
}
}

@ -0,0 +1,13 @@
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Repository.service
{
public interface Irecord_busbar_alarmServices: IBaseService<record_busbar_alarm>
{
}
}

@ -0,0 +1,14 @@
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
namespace SlnMesnac.Repository.service.Impl
{
public class base_alarm_infoServiceImpl : BaseServiceImpl<base_alarm_info>, Ibase_alarm_infoServices
{
public base_alarm_infoServiceImpl(Repository<base_alarm_info> repository):base(repository)
{
}
}
}

@ -0,0 +1,14 @@
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
namespace SlnMesnac.Repository.service.Impl
{
public class record_busbar_alarmServiceImpl : BaseServiceImpl<record_busbar_alarm>, Irecord_busbar_alarmServices
{
public record_busbar_alarmServiceImpl(Repository<record_busbar_alarm> repository):base(repository)
{
}
}
}

@ -28,8 +28,8 @@
{
"configId": 1,
"plcType": "SiemensPlc",
"plcIp": "127.0.0.1",
//"plcIp": "192.168.2.1",
//"plcIp": "127.0.0.1",
"plcIp": "192.168.2.1",
"plcPort": 102,
"plcKey": "iot",
"isFlage": "true"

Loading…
Cancel
Save