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#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* 版权所有 (c) 2025 WenJY 保留所有权利。
* CLR版本4.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>();
}
}
}