34 lines
1.1 KiB
C#
Raw Normal View History

2025-03-17 08:35:19 +08:00
using JiShe.CollectBus.IotSystems.Records;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2025-03-18 13:56:38 +08:00
using JiShe.CollectBus.Common.Consts;
2025-03-17 15:51:40 +08:00
using JiShe.CollectBus.EnergySystems.TableViews;
using JiShe.CollectBus.FreeSql;
2025-03-17 08:35:19 +08:00
using Volo.Abp.Domain.Repositories;
2025-03-17 15:51:40 +08:00
using JiShe.CollectBus.IotSystems.PrepayModel;
2025-03-26 17:18:20 +08:00
using JiShe.CollectBus.Ammeters;
using JiShe.CollectBus.Common.BuildSendDatas;
using JiShe.CollectBus.Common.Enums;
using JiShe.CollectBus.Common.Helpers;
2025-03-17 08:35:19 +08:00
namespace JiShe.CollectBus.EnergySystem
{
2025-03-17 15:51:40 +08:00
public class CacheAppService : CollectBusAppService, ICacheAppService
2025-03-17 08:35:19 +08:00
{
public async Task SetHashByKey()
2025-03-17 15:51:40 +08:00
{
var data = await SqlProvider.Instance.Change(DbEnum.EnergyDB).Select<V_FocusAmmeter>().ToListAsync();
var groupData = data.GroupBy(a => $"{a.FocusAreaCode}{a.FocusAddress}").ToList();
foreach (var group in groupData)
{
2025-03-21 14:30:11 +08:00
await FreeRedisProvider.Instance.HSetAsync($"{RedisConst.CacheAmmeterFocusKey}:{group.Key}", group.ToDictionary(a => $"{a.ID}_{a.Address}", b => b));
2025-03-17 15:51:40 +08:00
}
}
2025-03-17 08:35:19 +08:00
}
}