You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.3 KiB
C#

#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2025 WenJY
* CLR4.0.30319.42000
* Mr.Wen's MacBook Pro
* Sln.Imm.Daemon.Repository.service.Impl
* 4D067141-7FEC-4ED6-A69C-F285D68FFDEF
*
* WenJY
*
* 2025-09-05 11:27:26
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
using Sln.Imm.Daemon.Model.dao;
using Sln.Imm.Daemon.Repository.service.@base;
using SqlSugar;
namespace Sln.Imm.Daemon.Repository.service.Impl;
public class BaseDeviceParamServiceImpl : BaseServiceImpl<BaseDeviceParam>,IBaseDeviceParamService {
public BaseDeviceParamServiceImpl(Repository<BaseDeviceParam> rep) : base(rep)
{
}
/// <summary>
/// 查出所有报警参数(三色灯相关)
/// </summary>
/// <param name="device">设备信息,为 null 或 deviceCode 为空时返回空列表</param>
/// <returns>报警参数列表,无匹配或异常时返回空列表,保证调用方不因空指针中断</returns>
public List<BaseDeviceParam> GetDeviceAlarmParams(BaseDeviceInfo device)
{
try
{
if (device == null)
return new List<BaseDeviceParam>();
if (string.IsNullOrEmpty(device.deviceCode))
return new List<BaseDeviceParam>();
var ctx = _rep?.Context;
if (ctx == null)
return new List<BaseDeviceParam>();
var list = ctx.Queryable<BaseDeviceParam>()
.Where(x => x.deviceCode == device.deviceCode)
.Where(x => x.paramName != null && x.paramName.Contains("三色灯"))
.ToList();
return list ?? new List<BaseDeviceParam>();
}
catch (Exception)
{
// 任何异常(含 NRE、SqlSugar/DB 异常)均返回空列表,避免单台设备导致整轮采集停止;调用方会走“未读取到报警点位”并继续下一轮
return new List<BaseDeviceParam>();
}
}
}