完善设备管理和绑定物模型
This commit is contained in:
parent
9f61d37129
commit
645f558c4b
@ -0,0 +1,22 @@
|
||||
using JiShe.ServicePro.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.IoT.IoTPlatformAggregation.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 平台账号信息输入
|
||||
/// </summary>
|
||||
public class IoTPlatformAccountInfoInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 平台类型
|
||||
/// </summary>
|
||||
[Required]
|
||||
public IoTPlatformTypeEnum IoTPlatformType { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
using JiShe.ServicePro.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.IoT.IoTPlatformAggregation.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 平台账号信息
|
||||
/// </summary>
|
||||
public class IoTPlatformAccountInfoOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 物联网平台类型
|
||||
/// </summary>
|
||||
public IoTPlatformTypeEnum IoTPlatformType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 平台账号
|
||||
/// </summary>
|
||||
public string IoTPlatformAccount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 平台账号手机号
|
||||
/// </summary>
|
||||
public string IoTPlatformPhoneNumber { get; set; }
|
||||
}
|
||||
}
|
||||
@ -18,5 +18,10 @@ namespace JiShe.IoT.IoTPlatformAggregation.Dto
|
||||
/// </summary>
|
||||
[Required]
|
||||
public IoTPlatformTypeEnum IoTPlatformType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 平台账号
|
||||
/// </summary>
|
||||
public string IoTPlatformAccount { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,15 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
Task<List<IoTPlatformProductInfoOutput>> GetIoTPlatformProductInfoAsync(IoTPlatformProductInfoInput input
|
||||
);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取平台账号信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<IoTPlatformAccountInfoOutput>> GetIoTPlatformAccountInfoAsync(IoTPlatformAccountInfoInput input
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// 获取平台产品物模型属性信息
|
||||
/// </summary>
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
||||
using JiShe.ServicePro.Commons;
|
||||
using JiShe.ServicePro.Core;
|
||||
using JiShe.ServicePro.CTWingManagement.CTWingAccounts;
|
||||
using JiShe.ServicePro.CTWingManagement.CTWingProducts;
|
||||
using JiShe.ServicePro.Enums;
|
||||
using JiShe.ServicePro.FreeRedisProvider;
|
||||
using JiShe.ServicePro.OneNETManagement.OneNETAccounts;
|
||||
using JiShe.ServicePro.OneNETManagement.OneNETProducts;
|
||||
using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -25,14 +27,20 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
private readonly ILogger<IoTPlatformAggregationService> _logger;
|
||||
private readonly ICTWingProductService _ctwingProductService;
|
||||
private readonly IOneNETProductService _oneNetProductService;
|
||||
private readonly ICTWingAccountService _ctwingAccountService;
|
||||
private readonly IOneNETAccountService _oneNETAccountService;
|
||||
|
||||
public IoTPlatformAggregationService(ILogger<IoTPlatformAggregationService> logger,
|
||||
ICTWingProductService ctwingProductService,
|
||||
IOneNETProductService oneNetProductService)
|
||||
IOneNETProductService oneNetProductService,
|
||||
ICTWingAccountService ctwingAccountService,
|
||||
IOneNETAccountService oneNETAccountService)
|
||||
{
|
||||
_logger = logger;
|
||||
_ctwingProductService = ctwingProductService;
|
||||
_oneNetProductService = oneNetProductService;
|
||||
_ctwingAccountService = ctwingAccountService;
|
||||
_oneNETAccountService = oneNETAccountService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -47,12 +55,12 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new UserFriendlyException($"{nameof(GetIoTPlatformProductInfoAsync)} 平台产品聚合服务获取产品信息失败,参数异常");
|
||||
throw new UserFriendlyException($"{nameof(GetIoTPlatformProductInfoAsync)} 平台聚合服务获取产品信息失败,参数异常");
|
||||
}
|
||||
List<IoTPlatformProductInfoOutput> ioTPlatformProductInfoOutputs = new List<IoTPlatformProductInfoOutput>();
|
||||
if (input.IoTPlatformType == IoTPlatformTypeEnum.CTWing)
|
||||
{
|
||||
var ctwingProductInfos = await _ctwingProductService.GetAllListAsync();
|
||||
var ctwingProductInfos = await _ctwingProductService.GetAllListAsync(input.IoTPlatformAccount);
|
||||
if (ctwingProductInfos == null)
|
||||
{
|
||||
return ioTPlatformProductInfoOutputs;
|
||||
@ -71,7 +79,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
|
||||
if (input.IoTPlatformType == IoTPlatformTypeEnum.OneNET)
|
||||
{
|
||||
var oneNetProductInfos = await _oneNetProductService.GetAllListAsync();
|
||||
var oneNetProductInfos = await _oneNetProductService.GetAllListAsync(input.IoTPlatformAccount);
|
||||
if (oneNetProductInfos == null)
|
||||
{
|
||||
return ioTPlatformProductInfoOutputs;
|
||||
@ -96,6 +104,67 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取平台账号信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<IoTPlatformAccountInfoOutput>> GetIoTPlatformAccountInfoAsync(IoTPlatformAccountInfoInput input
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new UserFriendlyException($"{nameof(GetIoTPlatformAccountInfoAsync)} 平台聚合服务获取账户信息失败,参数异常");
|
||||
}
|
||||
List<IoTPlatformAccountInfoOutput> ioTPlatformAccountInfoOutputs = new List<IoTPlatformAccountInfoOutput>();
|
||||
if (input.IoTPlatformType == IoTPlatformTypeEnum.CTWing)
|
||||
{
|
||||
var ctwingAccountInfos = await _ctwingAccountService.GetAllListAsync();
|
||||
if (ctwingAccountInfos == null)
|
||||
{
|
||||
return ioTPlatformAccountInfoOutputs;
|
||||
}
|
||||
|
||||
foreach (var ctwingProductInfo in ctwingAccountInfos)
|
||||
{
|
||||
ioTPlatformAccountInfoOutputs.Add(new IoTPlatformAccountInfoOutput
|
||||
{
|
||||
IoTPlatformType = IoTPlatformTypeEnum.CTWing,
|
||||
IoTPlatformAccount = ctwingProductInfo.AccountId,
|
||||
IoTPlatformPhoneNumber = ctwingProductInfo.PhoneNumber
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (input.IoTPlatformType == IoTPlatformTypeEnum.OneNET)
|
||||
{
|
||||
var oneNetAccountInfos = await _oneNETAccountService.GetAllListAsync();
|
||||
if (oneNetAccountInfos == null)
|
||||
{
|
||||
return ioTPlatformAccountInfoOutputs;
|
||||
}
|
||||
foreach (var oneNetProductInfo in oneNetAccountInfos)
|
||||
{
|
||||
ioTPlatformAccountInfoOutputs.Add(new IoTPlatformAccountInfoOutput
|
||||
{
|
||||
IoTPlatformType = IoTPlatformTypeEnum.OneNET,
|
||||
IoTPlatformAccount = oneNetProductInfo.OneNETAccountId,
|
||||
IoTPlatformPhoneNumber = oneNetProductInfo.PhoneNumber
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return ioTPlatformAccountInfoOutputs;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取平台产品物模型属性信息
|
||||
@ -152,7 +221,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
return selectResults;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
oneNETAllThingModel = oneNetProductInfos.ThingModelInfos.Deserialize<OneNETAllThingModel>();
|
||||
|
||||
|
||||
@ -33,6 +33,18 @@ namespace JiShe.IoT.Controllers
|
||||
return await _iotPlatformAggregationService.GetIoTPlatformProductInfoAsync(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取平台账号信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost(nameof(GetIoTPlatformAccountInfoAsync))]
|
||||
[SwaggerOperation(summary: "获取平台账号信息", Tags = new[] { "AggregationIoTPlatform" })]
|
||||
public async Task<List<IoTPlatformAccountInfoOutput>> GetIoTPlatformAccountInfoAsync(IoTPlatformAccountInfoInput input)
|
||||
{
|
||||
return await _iotPlatformAggregationService.GetIoTPlatformAccountInfoAsync(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取平台产品物模型属性信息
|
||||
/// </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user