完善产品聚合服务
This commit is contained in:
parent
0bc946d1e9
commit
2ba44b5d30
@ -1,6 +1,7 @@
|
|||||||
using JiShe.ServicePro.Enums;
|
using JiShe.ServicePro.Enums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -15,6 +16,7 @@ namespace JiShe.IoT.IoTPlatformAggregation.Dto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 平台类型
|
/// 平台类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Required]
|
||||||
public IoTPlatformTypeEnum IoTPlatformType { get; set; }
|
public IoTPlatformTypeEnum IoTPlatformType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
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 IoTPlatformProductPropertyInfoInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 物联网平台类型,默认没有指定
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public IoTPlatformTypeEnum IoTPlatformType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物联网平台中对应的产品Id
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string IoTPlatformProductId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
||||||
|
using JiShe.ServicePro.Commons;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -19,5 +20,13 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<IoTPlatformProductInfoOutput>> GetIoTPlatformProductInfoAsync(IoTPlatformProductInfoInput input
|
Task<List<IoTPlatformProductInfoOutput>> GetIoTPlatformProductInfoAsync(IoTPlatformProductInfoInput input
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取平台产品物模型属性信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<SelectResult>> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
using Castle.Core.Logging;
|
using Castle.Core.Logging;
|
||||||
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
||||||
|
using JiShe.ServicePro.Commons;
|
||||||
|
using JiShe.ServicePro.Core;
|
||||||
using JiShe.ServicePro.CTWingManagement.CTWingProducts;
|
using JiShe.ServicePro.CTWingManagement.CTWingProducts;
|
||||||
using JiShe.ServicePro.Enums;
|
using JiShe.ServicePro.Enums;
|
||||||
|
using JiShe.ServicePro.FreeRedisProvider;
|
||||||
using JiShe.ServicePro.OneNETManagement.OneNETProducts;
|
using JiShe.ServicePro.OneNETManagement.OneNETProducts;
|
||||||
|
using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -49,7 +53,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
|||||||
if (input.IoTPlatformType == IoTPlatformTypeEnum.CTWing)
|
if (input.IoTPlatformType == IoTPlatformTypeEnum.CTWing)
|
||||||
{
|
{
|
||||||
var ctwingProductInfos = await _ctwingProductService.GetAllListAsync();
|
var ctwingProductInfos = await _ctwingProductService.GetAllListAsync();
|
||||||
if(ctwingProductInfos == null)
|
if (ctwingProductInfos == null)
|
||||||
{
|
{
|
||||||
return ioTPlatformProductInfoOutputs;
|
return ioTPlatformProductInfoOutputs;
|
||||||
}
|
}
|
||||||
@ -65,10 +69,10 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(input.IoTPlatformType == IoTPlatformTypeEnum.OneNET)
|
if (input.IoTPlatformType == IoTPlatformTypeEnum.OneNET)
|
||||||
{
|
{
|
||||||
var oneNetProductInfos = await _oneNetProductService.GetAllListAsync();
|
var oneNetProductInfos = await _oneNetProductService.GetAllListAsync();
|
||||||
if(oneNetProductInfos == null)
|
if (oneNetProductInfos == null)
|
||||||
{
|
{
|
||||||
return ioTPlatformProductInfoOutputs;
|
return ioTPlatformProductInfoOutputs;
|
||||||
}
|
}
|
||||||
@ -91,5 +95,85 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取平台产品物模型属性信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<SelectResult>> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (input == null)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException($"{nameof(GetIoTPlatformProductPropertyInfoAsync)} 平台产品聚合服务获取产品属性信息失败,参数异常");
|
||||||
|
}
|
||||||
|
var key = string.Format($"{RedisConst.CachePlatformProductThingModelInfoKey}", input.IoTPlatformType);
|
||||||
|
List<SelectResult> selectResults = new List<SelectResult>();
|
||||||
|
|
||||||
|
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
|
||||||
|
// });
|
||||||
|
//}
|
||||||
|
_logger.LogError($"{nameof(GetIoTPlatformProductPropertyInfoAsync)}产品聚合服务暂不支持CTWing产品物模型属性信息查询");
|
||||||
|
|
||||||
|
return selectResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (input.IoTPlatformType == IoTPlatformTypeEnum.OneNET)
|
||||||
|
{
|
||||||
|
|
||||||
|
var oneNETAllThingModel = FreeRedisProvider.Instance.HGet<OneNETAllThingModel>(key, input.IoTPlatformProductId);
|
||||||
|
if (oneNETAllThingModel != null)
|
||||||
|
{
|
||||||
|
return OneNETAllThingModel.GetAllPropertiesSelectResult(oneNETAllThingModel.Properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
var oneNetProductInfos = await _oneNetProductService.GetProductInfoAsync(new IdInput<string>() { Id = input.IoTPlatformProductId });
|
||||||
|
if (oneNetProductInfos == null || string.IsNullOrWhiteSpace(oneNetProductInfos.ThingModelInfos))
|
||||||
|
{
|
||||||
|
return selectResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
oneNETAllThingModel = oneNetProductInfos.ThingModelInfos.Deserialize<OneNETAllThingModel>();
|
||||||
|
|
||||||
|
if (oneNETAllThingModel == null)
|
||||||
|
{
|
||||||
|
return selectResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
await FreeRedisProvider.Instance.HSetAsync<OneNETAllThingModel>(key, input.IoTPlatformProductId, oneNETAllThingModel);
|
||||||
|
|
||||||
|
return OneNETAllThingModel.GetAllPropertiesSelectResult(oneNETAllThingModel.Properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectResults;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using JiShe.IoT.DeviceAggregation.Dto;
|
|||||||
using JiShe.IoT.IoTPlatformAggregation;
|
using JiShe.IoT.IoTPlatformAggregation;
|
||||||
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
||||||
using JiShe.ServicePro;
|
using JiShe.ServicePro;
|
||||||
|
using JiShe.ServicePro.Commons;
|
||||||
using JiShe.ServicePro.Core;
|
using JiShe.ServicePro.Core;
|
||||||
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
||||||
|
|
||||||
@ -32,5 +33,17 @@ namespace JiShe.IoT.Controllers
|
|||||||
return await _iotPlatformAggregationService.GetIoTPlatformProductInfoAsync(input);
|
return await _iotPlatformAggregationService.GetIoTPlatformProductInfoAsync(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取平台产品物模型属性信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost(nameof(GetIoTPlatformProductPropertyInfoAsync))]
|
||||||
|
[SwaggerOperation(summary: "获取平台产品物模型属性信息", Tags = new[] { "AggregationIoTPlatform" })]
|
||||||
|
public async Task<List<SelectResult>> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input)
|
||||||
|
{
|
||||||
|
return await _iotPlatformAggregationService.GetIoTPlatformProductPropertyInfoAsync(input);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user