using Microsoft.AspNetCore.Mvc; using System.Net; using System.Net.Http.Headers; using Microsoft.Extensions.Hosting.Internal; using Microsoft.AspNetCore.Http.Extensions; using IStation.Untity; using Furion.DynamicApiController; using System.ComponentModel.DataAnnotations; using Mapster; namespace IStation.Application { /// /// FlowMeter /// [Route("Dma/FlowMeter/Logic")] [ApiDescriptionSettings("Dma", Name = "流量计(业务)", Order = 70)] public class FlowMeter_LogicController : IDynamicApiController { /// /// 通过 CorpID 获取列表(业务) /// [Route("GetListByCorpID@V1.0")] [HttpGet] public List GetListByCorpID([FromQuery][Required] CorpIDInput input) { var corpId = input.CorpID; var cacheKey = $"Dma_FlowMeter_Logic_GetListByCorpID_{corpId}"; var vmList = MemoryCacheHelper.GetSet(cacheKey, () => { var siteList=new Service.DmaSite().GetByCorpID(corpId); if (siteList == null || siteList.Count < 1) return default; var serviceBinding = new Service.DmaSiteBinding(); var serviceProduct = new Service.Product(); var serviceManu = new Service.Manufacturer(); var serviceMapping = new Service.DmaSiteMapping(); var serviceDma = new Service.DmaArea(); var vmCacheList = new List(); foreach (var site in siteList) { var binding = serviceBinding.GetUseByDmaSiteID(site.CorpID, site.ID); if (binding == null) continue; var product = serviceProduct.GetByID(binding.CorpID, binding.FlowMeterID); if (product == null) continue; var manu = serviceManu.GetByID(product.CorpID,product.ManufacturerID); var vm = new FlowMeterLogicDto(product,manu?.Name); vmCacheList.Add(vm); var mappingList = serviceMapping.GetByDmaSiteID(site.CorpID,site.ID); if (mappingList != null && mappingList.Count > 0) { var flowIn = mappingList.Find(t=>t.Direction==Model.eDmaDirection.FlowIn); if (flowIn != null) { var flowInDma = serviceDma.GetByID(flowIn.CorpID,flowIn.DmaAreaID); vm.FlowIn = flowInDma?.Name; } var flowOut = mappingList.Find(t=>t.Direction==Model.eDmaDirection.FlowOut); if (flowOut != null) { var flowOutDma = serviceDma.GetByID(flowOut.CorpID, flowOut.DmaAreaID); vm.FlowOut = flowOutDma?.Name; } } } return vmCacheList; }, CacheHelper.CacheLevel2); return vmList; } } }