设备类添加产品字段、添加物模型类,新增产品CRUD方法

This commit is contained in:
2026-09-03 17:16:28 +08:00
parent cfa8e78d33
commit bcd6484f45
29 changed files with 1611 additions and 23 deletions
@@ -16,14 +16,14 @@ namespace Service.Implement
public class AlertRuleService : IAlertRuleService
{
/// <summary>
/// 获取全告警规则列表
/// 获取全告警规则列表OwnerType=0,不含产品/设备归属规则)
/// </summary>
public async Task<Result<List<AlertRuleDto>>> GetListAsync()
{
try
{
var list = await SqlSugarContext.DbContext.Queryable<AlertRuleEntity>()
.Where(x => x.IsDel == 0)
.Where(x => x.IsDel == 0 && x.OwnerType == 0)
.OrderBy(x => x.CreateTime, SqlSugar.OrderByType.Desc)
.ToListAsync();
@@ -36,6 +36,27 @@ namespace Service.Implement
}
}
/// <summary>
/// 获取某归属对象下的规则列表(OwnerType=产品/设备,可选按点过滤)
/// </summary>
public async Task<Result<List<AlertRuleDto>>> GetOwnerRulesAsync(int ownerType, long ownerId, string? pointCode)
{
try
{
var list = await SqlSugarContext.DbContext.Queryable<AlertRuleEntity>()
.Where(x => x.IsDel == 0 && x.OwnerType == (byte)ownerType && x.OwnerId == ownerId)
.WhereIF(!string.IsNullOrWhiteSpace(pointCode), x => x.PointCode == pointCode)
.OrderBy(x => x.CreateTime, SqlSugar.OrderByType.Desc)
.ToListAsync();
return Result<List<AlertRuleDto>>.Success(list.ToDtoList());
}
catch (Exception ex)
{
return Result<List<AlertRuleDto>>.Error("查询归属告警规则失败", ex);
}
}
/// <summary>
/// 新增告警规则(DTO → Entitystring Id 转 long
/// </summary>