using Castle.Core.Logging; using JiShe.IoT.IoTPlatformAggregation.Dto; using JiShe.ServicePro.CTWingManagement.CTWingProducts; using JiShe.ServicePro.Enums; using JiShe.ServicePro.OneNETManagement.OneNETProducts; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp; namespace JiShe.IoT.IoTPlatformAggregation { /// /// 平台聚合服务 /// public class IoTPlatformAggregationService : IoTAppService, IIoTPlatformAggregationService { private readonly ILogger _logger; private readonly ICTWingProductService _ctwingProductService; private readonly IOneNETProductService _oneNetProductService; public IoTPlatformAggregationService(ILogger logger, ICTWingProductService ctwingProductService, IOneNETProductService oneNetProductService) { _logger = logger; _ctwingProductService = ctwingProductService; _oneNetProductService = oneNetProductService; } /// /// 获取平台产品信息 /// /// /// public async Task> GetIoTPlatformProductInfoAsync(IoTPlatformProductInfoInput input ) { try { if (input == null) { throw new UserFriendlyException($"{nameof(GetIoTPlatformProductInfoAsync)} 平台产品聚合服务获取产品信息失败,参数异常"); } List ioTPlatformProductInfoOutputs = new List(); if (input.IoTPlatformType == IoTPlatformTypeEnum.CTWing) { var ctwingProductInfos = await _ctwingProductService.GetAllListAsync(); if(ctwingProductInfos == null) { return ioTPlatformProductInfoOutputs; } foreach (var ctwingProductInfo in ctwingProductInfos) { ioTPlatformProductInfoOutputs.Add(new IoTPlatformProductInfoOutput { IoTPlatformType = IoTPlatformTypeEnum.CTWing, IoTPlatformProductId = ctwingProductInfo.IoTPlatformProductId, ProductName = ctwingProductInfo.ProductName }); } } if(input.IoTPlatformType == IoTPlatformTypeEnum.OneNET) { var oneNetProductInfos = await _oneNetProductService.GetAllListAsync(); if(oneNetProductInfos == null) { return ioTPlatformProductInfoOutputs; } foreach (var oneNetProductInfo in oneNetProductInfos) { ioTPlatformProductInfoOutputs.Add(new IoTPlatformProductInfoOutput { IoTPlatformType = IoTPlatformTypeEnum.OneNET, IoTPlatformProductId = oneNetProductInfo.IoTPlatformProductId, ProductName = oneNetProductInfo.ProductName }); } } return ioTPlatformProductInfoOutputs; } catch (Exception) { throw; } } } }