细节调整

This commit is contained in:
yanghongwei 2025-04-22 21:06:17 +08:00
parent c9ce660695
commit dc1065a603
2 changed files with 8 additions and 8 deletions

View File

@ -46,13 +46,6 @@ namespace LY.App.Controllers
{
ApiResult result = new ApiResult();
var positions = await _positionService.Index();
positions.ForEach(async p =>
{
foreach (var item in p.Devices)
{
item.IsOnline = await _redisService.ExistsAsync(RedisKeyList.DeviceStatus(item.DeviceSN));
}
});
var alarmCount = await _redisService.GetOrSetAsync(RedisKeyList.index_data(),
async () => await _alarmService.IndexCount(),
TimeSpan.FromDays(1));

View File

@ -1,4 +1,5 @@
using LY.App.Common;
using LY.App.Common.Redis;
using LY.App.Extensions.DI;
using LY.App.Model;
using Mapster;
@ -17,9 +18,11 @@ namespace LY.App.Service
public class PositionService
{
private readonly SqlSugarClient _db;
public PositionService(SqlSugarClient db)
private readonly RedisService _redisService;
public PositionService(SqlSugarClient db, RedisService redisService)
{
_db = db;
_redisService = redisService;
}
/// <summary>
/// 添加
@ -147,6 +150,10 @@ namespace LY.App.Service
{
item.SetRegionJson();
item.Devices = deviceList.Where(s => s.PositionId == item.Id).ToList()?.Adapt<List<DeviceItem>>() ?? new List<DeviceItem>();
item.Devices.ForEach(async s =>
{
s.IsOnline = await _redisService.ExistsAsync(RedisKeyList.DeviceStatus(s.DeviceSN));
});
}
return result;
}