using FreeRedis; using FreeSql; using JiShe.CollectBus.FreeRedisProvider; using JiShe.CollectBus.FreeSql; using JiShe.CollectBus.Localization; using JiShe.CollectBus.Workers.DTO.Energy; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Application.Services; namespace JiShe.CollectBus; [ApiExplorerSettings(GroupName = CollectBusDomainSharedConsts.Business)] public abstract class CollectBusAppService : ApplicationService { public IFreeSqlProvider SqlProvider => LazyServiceProvider.LazyGetRequiredService(); protected IRedisClient? FreeRedis => LazyServiceProvider.LazyGetService()?.FreeRedis; protected CollectBusAppService() { LocalizationResource = typeof(CollectBusResource); ObjectMapperContext = typeof(CollectBusApplicationModule); } #region 能耗相关 /// /// 查找当前采集器下所有电表 /// /// 采集端Code /// protected async Task> GetAmmetersByGatherCode(string gatherCode = "V4-Gather-8890") { string sql = $@"SELECT C.ID,C.Name,C.FocusID,C.SingleRate,C.MeteringCode,C.Code AS BrandType,C.Baudrate,C.Password,C.MeteringPort,C.[Address] AS AmmerterAddress,C.TypeName,C.Protocol,C.TripState,C.[State],B.[Address],B.AreaCode,B.AutomaticReport,D.DataTypes,B.TimeDensity,A.GatherCode,C.Special,C.[ProjectID],B.AbnormalState,B.LastTime FROM TB_GatherInfo(NOLOCK) AS A INNER JOIN TB_FocusInfo(NOLOCK) AS B ON A.ID = B.GatherInfoID AND B.RemoveState >= 0 AND B.State>=0 INNER JOIN TB_AmmeterInfo(NOLOCK) AS C ON B.ID = C.FocusID AND C.State>= 0 AND C.State<100 INNER JOIN TB_AmmeterGatherItem(NOLOCK) AS D ON C.ID = D.AmmeterID AND D.State>=0 WHERE A.GatherCode = {gatherCode}"; return await SqlProvider.Instance.Change(DbEnum.EnergyDB).Select(sql).ToListAsync(); } #endregion }