完善标准物模型数据查询接口等
This commit is contained in:
parent
8ef2e83791
commit
b14df70fa0
@ -12,7 +12,7 @@ namespace JiShe.IoT.IoTPlatformAggregation.Dto
|
||||
/// <summary>
|
||||
/// 产品属性信息输入
|
||||
/// </summary>
|
||||
public class IoTPlatformProductPropertyInfoInput
|
||||
public class IoTPlatformProductThingModelInfoInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 物联网平台类型,默认没有指定
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.ServicePro.Enums;
|
||||
using JiShe.ServicePro.Core;
|
||||
using JiShe.ServicePro.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@ -11,7 +12,7 @@ namespace JiShe.IoT.IoTPlatformAggregation.Dto
|
||||
/// <summary>
|
||||
/// 平台产品属性更新输入
|
||||
/// </summary>
|
||||
public class UpdateIoTPlatformProductPropertyInfoInput
|
||||
public class UpdateIoTPlatformProductThingModelInfoInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 物联网平台类型,默认没有指定
|
||||
@ -35,7 +35,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SelectResult>> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input
|
||||
Task<List<SelectResult>> GetIoTPlatformProductThingModelInfoAsync(IoTPlatformProductThingModelInfoInput input
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
@ -43,7 +43,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<object> UpdateIoTPlatformProductPropertyInfoAsync(UpdateIoTPlatformProductPropertyInfoInput input
|
||||
Task<object> UpdateIoTPlatformProductThingModelInfoAsync(UpdateIoTPlatformProductThingModelInfoInput input
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using JiShe.ServicePro;
|
||||
using JiShe.ServicePro.Enums;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -14,22 +15,27 @@ namespace JiShe.IoT.Workshops
|
||||
public class WorkshopProductListOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品数据Id
|
||||
/// 平台类型
|
||||
/// </summary>
|
||||
[SwaggerSchema("产品数据Id")]
|
||||
public Guid ProductDataId { get; set; }
|
||||
public IoTPlatformTypeEnum IoTPlatform { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品Id
|
||||
/// </summary>
|
||||
[SwaggerSchema("产品Id")]
|
||||
public string IoTPlatformProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品名称
|
||||
/// </summary>
|
||||
[SwaggerSchema("产品名称")]
|
||||
public string ProductName { get; set; }
|
||||
public string IoTPlatformProductName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品访问密钥
|
||||
/// </summary>
|
||||
[SwaggerSchema("产品访问密钥")]
|
||||
public string ProductAccesskey { get; set; }
|
||||
public string IoTPlatformProductAccesskey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯服务地址
|
||||
|
||||
@ -176,13 +176,13 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<SelectResult>> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input)
|
||||
public async Task<List<SelectResult>> GetIoTPlatformProductThingModelInfoAsync(IoTPlatformProductThingModelInfoInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new UserFriendlyException($"{nameof(GetIoTPlatformProductPropertyInfoAsync)} 平台产品聚合服务获取产品属性信息失败,参数异常");
|
||||
throw new UserFriendlyException($"{nameof(GetIoTPlatformProductThingModelInfoAsync)} 平台产品聚合服务获取产品属性信息失败,参数异常");
|
||||
}
|
||||
var key = string.Format($"{RedisConst.CachePlatformProductThingModelInfoKey}", input.IoTPlatformType);
|
||||
List<SelectResult> selectResults = new List<SelectResult>();
|
||||
@ -205,7 +205,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
// ProductName = ctwingProductInfo.ProductName
|
||||
// });
|
||||
//}
|
||||
_logger.LogError($"{nameof(GetIoTPlatformProductPropertyInfoAsync)}产品聚合服务暂不支持CTWing产品物模型属性信息查询");
|
||||
_logger.LogError($"{nameof(GetIoTPlatformProductThingModelInfoAsync)}产品聚合服务暂不支持CTWing产品物模型属性信息查询");
|
||||
|
||||
return selectResults;
|
||||
}
|
||||
@ -243,10 +243,18 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(input.FiledType) && input.FiledType.ToLowerInvariant().Contains("event"))
|
||||
{
|
||||
return OneNETAllThingModel.GetAllEventsSelectResult(oneNETAllThingModel.Events);
|
||||
var tempEventResult = OneNETAllThingModel.GetAllEventsSelectResult(oneNETAllThingModel.Events);
|
||||
if (tempEventResult != null)
|
||||
{
|
||||
selectResults.AddRange(tempEventResult);
|
||||
}
|
||||
}
|
||||
|
||||
return OneNETAllThingModel.GetAllPropertiesSelectResult(oneNETAllThingModel.Properties);
|
||||
var tempPropertyResult = OneNETAllThingModel.GetAllPropertiesSelectResult(oneNETAllThingModel.Properties);
|
||||
if (tempPropertyResult != null)
|
||||
{
|
||||
selectResults.AddRange(tempPropertyResult);
|
||||
}
|
||||
}
|
||||
|
||||
return selectResults;
|
||||
@ -265,7 +273,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<object> UpdateIoTPlatformProductPropertyInfoAsync(UpdateIoTPlatformProductPropertyInfoInput input
|
||||
public async Task<object> UpdateIoTPlatformProductThingModelInfoAsync(UpdateIoTPlatformProductThingModelInfoInput input
|
||||
)
|
||||
|
||||
{
|
||||
@ -273,13 +281,13 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new UserFriendlyException($"{nameof(UpdateIoTPlatformProductPropertyInfoAsync)} 平台产品聚合服务获取产品属性信息失败,参数异常");
|
||||
throw new UserFriendlyException($"{nameof(UpdateIoTPlatformProductThingModelInfoAsync)} 平台产品聚合服务获取产品属性信息失败,参数异常");
|
||||
}
|
||||
|
||||
if (input.IoTPlatformType == IoTPlatformTypeEnum.CTWing)
|
||||
{
|
||||
|
||||
_logger.LogError($"{nameof(UpdateIoTPlatformProductPropertyInfoAsync)}产品聚合服务暂不支持CTWing产品物模型属性信息更新");
|
||||
_logger.LogError($"{nameof(UpdateIoTPlatformProductThingModelInfoAsync)}产品聚合服务暂不支持CTWing产品物模型属性信息更新");
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -290,19 +298,30 @@ namespace JiShe.IoT.IoTPlatformAggregation
|
||||
var oneNetProductInfos = await _oneNetProductService.UpdateThingModelAsync(new IdInput<string>() { Id = input.IoTPlatformProductId });
|
||||
if (oneNetProductInfos == null || string.IsNullOrWhiteSpace(oneNetProductInfos.ThingModelInfos))
|
||||
{
|
||||
_logger.LogError($"{nameof(UpdateIoTPlatformProductPropertyInfoAsync)}产品聚合服务OneNET产品{input.IoTPlatformProductId}物模型属性信息更新失败,-101");
|
||||
_logger.LogError($"{nameof(UpdateIoTPlatformProductThingModelInfoAsync)}产品聚合服务OneNET产品{input.IoTPlatformProductId}物模型属性信息更新失败,-101");
|
||||
return null;
|
||||
}
|
||||
|
||||
var oneNETAllThingModel = oneNetProductInfos.ThingModelInfos.Deserialize<OneNETAllThingModel>();
|
||||
if (oneNETAllThingModel == null)
|
||||
{
|
||||
_logger.LogError($"{nameof(UpdateIoTPlatformProductPropertyInfoAsync)}产品聚合服务OneNET产品{input.IoTPlatformProductId}物模型属性信息更新失败,-102");
|
||||
_logger.LogError($"{nameof(UpdateIoTPlatformProductThingModelInfoAsync)}产品聚合服务OneNET产品{input.IoTPlatformProductId}物模型属性信息更新失败,-102");
|
||||
return null;
|
||||
}
|
||||
|
||||
//将平台产品最新物模型信息更新到平台端物模型表中
|
||||
var selectResults = OneNETAllThingModel.GetAllPropertiesSelectResult(oneNETAllThingModel.Properties);
|
||||
List<SelectResult> selectResults = OneNETAllThingModel.GetAllPropertiesSelectResult(oneNETAllThingModel.Properties);
|
||||
var tempEventSelectResults = OneNETAllThingModel.GetAllEventsSelectResult(oneNETAllThingModel.Events);
|
||||
if (tempEventSelectResults != null)
|
||||
{
|
||||
selectResults.AddRange(tempEventSelectResults);
|
||||
}
|
||||
|
||||
|
||||
if (selectResults == null)
|
||||
{
|
||||
_logger.LogError($"{nameof(UpdateIoTPlatformProductThingModelInfoAsync)}产品聚合服务OneNET产品{input.IoTPlatformProductId}物模型属性信息更新失败,-103");
|
||||
return null;
|
||||
}
|
||||
|
||||
await _ioTPlatformThingModelInfoAppService.UpdatePlatformThingModelAsync(input.IoTPlatformProductId, input.IoTPlatformType, selectResults);
|
||||
|
||||
|
||||
@ -84,11 +84,11 @@ namespace JiShe.ServicePro.OneNETManagement.Subscribers
|
||||
}
|
||||
|
||||
deviceEntity.DeviceOnlineStatus = deviceStatusMessage.Status;
|
||||
if (deviceStatusMessage.Status == DeviceOnlineStatusEnum.Online)
|
||||
if (deviceStatusMessage.Status == DeviceOnlineStatus.Online)
|
||||
{
|
||||
deviceEntity.LastOnlineTime = TimestampHelper.ConvertToDateTime(deviceStatusMessage.ReceivedTime, TimestampUnit.Milliseconds, DateTimeKind.Local);
|
||||
}
|
||||
else if (deviceStatusMessage.Status == DeviceOnlineStatusEnum.Offline)
|
||||
else if (deviceStatusMessage.Status == DeviceOnlineStatus.Offline)
|
||||
{
|
||||
deviceEntity.LastOfflineTime = TimestampHelper.ConvertToDateTime(deviceStatusMessage.ReceivedTime, TimestampUnit.Milliseconds, DateTimeKind.Local);
|
||||
}
|
||||
|
||||
@ -104,10 +104,10 @@ namespace JiShe.IoT.Workshops
|
||||
.OrderByDescending(e => e.CreationTime)
|
||||
.ToListAsync(d => new WorkshopProductListOutput
|
||||
{
|
||||
ProductDataId = d.Id,
|
||||
ProductName = d.ProductName,
|
||||
IoTPlatformProductId = d.IoTPlatformProductId,
|
||||
IoTPlatformProductName = d.ProductName,
|
||||
CommunicationAddress = d.CommunicationAddress,
|
||||
ProductAccesskey = d.FeatureAccesskey,
|
||||
IoTPlatformProductAccesskey = d.FeatureAccesskey,
|
||||
});
|
||||
}
|
||||
else if (messageBody.IoTPlatform == IoTPlatformTypeEnum.CTWing)
|
||||
@ -117,10 +117,10 @@ namespace JiShe.IoT.Workshops
|
||||
.OrderByDescending(e => e.CreationTime)
|
||||
.ToListAsync(d => new WorkshopProductListOutput
|
||||
{
|
||||
ProductDataId = d.Id,
|
||||
ProductName = d.ProductName,
|
||||
IoTPlatformProductId = d.IoTPlatformProductId,
|
||||
IoTPlatformProductName = d.ProductName,
|
||||
CommunicationAddress = d.CommunicationAddress,
|
||||
ProductAccesskey = d.ProductAccesskey,
|
||||
IoTPlatformProductAccesskey = d.ProductAccesskey,
|
||||
CommunicationAddressTLS = d.CommunicationAddressTLS
|
||||
});
|
||||
}
|
||||
|
||||
@ -46,27 +46,27 @@ namespace JiShe.IoT.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取平台产品物模型属性信息
|
||||
/// 获取平台产品物模型信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost(nameof(GetIoTPlatformProductPropertyInfoAsync))]
|
||||
[SwaggerOperation(summary: "获取平台产品物模型属性信息", Tags = new[] { "AggregationIoTPlatform" })]
|
||||
public async Task<List<SelectResult>> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input)
|
||||
[HttpPost(nameof(GetIoTPlatformProductThingModelInfoAsync))]
|
||||
[SwaggerOperation(summary: "获取平台产品物模型信息", Tags = new[] { "AggregationIoTPlatform" })]
|
||||
public async Task<List<SelectResult>> GetIoTPlatformProductThingModelInfoAsync(IoTPlatformProductThingModelInfoInput input)
|
||||
{
|
||||
return await _iotPlatformAggregationService.GetIoTPlatformProductPropertyInfoAsync(input);
|
||||
return await _iotPlatformAggregationService.GetIoTPlatformProductThingModelInfoAsync(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新平台产品物模型属性信息
|
||||
/// 更新平台产品物模型信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost(nameof(UpdateIoTPlatformProductPropertyInfoAsync))]
|
||||
[SwaggerOperation(summary: "更新平台产品物模型属性信息", Tags = new[] { "AggregationIoTPlatform" })]
|
||||
public async Task<object> UpdateIoTPlatformProductPropertyInfoAsync(UpdateIoTPlatformProductPropertyInfoInput input)
|
||||
[HttpPost(nameof(UpdateIoTPlatformProductThingModelInfoAsync))]
|
||||
[SwaggerOperation(summary: "更新平台产品物模型信息", Tags = new[] { "AggregationIoTPlatform" })]
|
||||
public async Task<object> UpdateIoTPlatformProductThingModelInfoAsync(UpdateIoTPlatformProductThingModelInfoInput input)
|
||||
{
|
||||
return await _iotPlatformAggregationService.UpdateIoTPlatformProductPropertyInfoAsync(input);
|
||||
return await _iotPlatformAggregationService.UpdateIoTPlatformProductThingModelInfoAsync(input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user