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-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-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
|
|
|
|
{
|
2025-03-17 15:51:40 +08:00
|
|
|
|
//public async Task<V_FocusAmmeter> GetHashByKey(string key)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// await FreeRedisProvider.Instance.HGetAsync<V_FocusAmmeter>(key,);
|
|
|
|
|
|
//}
|
2025-03-17 08:35:19 +08:00
|
|
|
|
|
2025-03-17 15:51:40 +08:00
|
|
|
|
public async Task SetHashByKey(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
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)
|
|
|
|
|
|
{
|
|
|
|
|
|
var aa = data.ToDictionary(a => a.Address, b => b);
|
|
|
|
|
|
await FreeRedisProvider.Instance.HSetAsync(group.Key, aa);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-03-17 08:35:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|