96 lines
3.7 KiB
C#
96 lines
3.7 KiB
C#
|
|
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
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 平台聚合服务
|
|||
|
|
/// </summary>
|
|||
|
|
public class IoTPlatformAggregationService : IoTAppService, IIoTPlatformAggregationService
|
|||
|
|
{
|
|||
|
|
private readonly ILogger<IoTPlatformAggregationService> _logger;
|
|||
|
|
private readonly ICTWingProductService _ctwingProductService;
|
|||
|
|
private readonly IOneNETProductService _oneNetProductService;
|
|||
|
|
|
|||
|
|
public IoTPlatformAggregationService(ILogger<IoTPlatformAggregationService> logger,
|
|||
|
|
ICTWingProductService ctwingProductService,
|
|||
|
|
IOneNETProductService oneNetProductService)
|
|||
|
|
{
|
|||
|
|
_logger = logger;
|
|||
|
|
_ctwingProductService = ctwingProductService;
|
|||
|
|
_oneNetProductService = oneNetProductService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取平台产品信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="input"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public async Task<List<IoTPlatformProductInfoOutput>> GetIoTPlatformProductInfoAsync(IoTPlatformProductInfoInput input
|
|||
|
|
)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (input == null)
|
|||
|
|
{
|
|||
|
|
throw new UserFriendlyException($"{nameof(GetIoTPlatformProductInfoAsync)} 平台产品聚合服务获取产品信息失败,参数异常");
|
|||
|
|
}
|
|||
|
|
List<IoTPlatformProductInfoOutput> ioTPlatformProductInfoOutputs = new List<IoTPlatformProductInfoOutput>();
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|