using JiShe.CollectBus.IotSystems.Records; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using JiShe.CollectBus.Common.Consts; using JiShe.CollectBus.EnergySystems.TableViews; using JiShe.CollectBus.FreeSql; using Volo.Abp.Domain.Repositories; using JiShe.CollectBus.IotSystems.PrepayModel; namespace JiShe.CollectBus.EnergySystem { public class CacheAppService : CollectBusAppService, ICacheAppService { //public async Task GetHashByKey(string key) //{ // await FreeRedisProvider.Instance.HGetAsync(key,); //} public async Task SetHashByKey(string key) { var data = await SqlProvider.Instance.Change(DbEnum.EnergyDB).Select().ToListAsync(); var groupData = data.GroupBy(a => $"{a.FocusAreaCode}{a.FocusAddress}").ToList(); foreach (var group in groupData) { try { var aa = group.ToDictionary(a => $"{a.ID}_{a.Address}" , b => b); await FreeRedisProvider.Instance.HSetAsync($"{RedisConst.CacheAmmeterFocusKey}:{group.Key}", aa); } catch (Exception e) { Console.WriteLine(e); throw; } } } } }