完善标准物模型数据查询接口等

This commit is contained in:
ChenYi 2026-01-05 17:25:32 +08:00
parent 8ef2e83791
commit b14df70fa0
8 changed files with 66 additions and 40 deletions

View File

@ -12,7 +12,7 @@ namespace JiShe.IoT.IoTPlatformAggregation.Dto
/// <summary> /// <summary>
/// 产品属性信息输入 /// 产品属性信息输入
/// </summary> /// </summary>
public class IoTPlatformProductPropertyInfoInput public class IoTPlatformProductThingModelInfoInput
{ {
/// <summary> /// <summary>
/// 物联网平台类型,默认没有指定 /// 物联网平台类型,默认没有指定

View File

@ -1,4 +1,5 @@
using JiShe.ServicePro.Enums; using JiShe.ServicePro.Core;
using JiShe.ServicePro.Enums;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
@ -11,7 +12,7 @@ namespace JiShe.IoT.IoTPlatformAggregation.Dto
/// <summary> /// <summary>
/// 平台产品属性更新输入 /// 平台产品属性更新输入
/// </summary> /// </summary>
public class UpdateIoTPlatformProductPropertyInfoInput public class UpdateIoTPlatformProductThingModelInfoInput
{ {
/// <summary> /// <summary>
/// 物联网平台类型,默认没有指定 /// 物联网平台类型,默认没有指定

View File

@ -35,7 +35,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
Task<List<SelectResult>> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input Task<List<SelectResult>> GetIoTPlatformProductThingModelInfoAsync(IoTPlatformProductThingModelInfoInput input
); );
/// <summary> /// <summary>
@ -43,7 +43,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
Task<object> UpdateIoTPlatformProductPropertyInfoAsync(UpdateIoTPlatformProductPropertyInfoInput input Task<object> UpdateIoTPlatformProductThingModelInfoAsync(UpdateIoTPlatformProductThingModelInfoInput input
); );
} }
} }

View File

@ -1,4 +1,5 @@
using JiShe.ServicePro; using JiShe.ServicePro;
using JiShe.ServicePro.Enums;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -14,22 +15,27 @@ namespace JiShe.IoT.Workshops
public class WorkshopProductListOutput public class WorkshopProductListOutput
{ {
/// <summary> /// <summary>
/// 产品数据Id /// 平台类型
/// </summary> /// </summary>
[SwaggerSchema("产品数据Id")] public IoTPlatformTypeEnum IoTPlatform { get; set; }
public Guid ProductDataId { get; set; }
/// <summary>
/// 产品Id
/// </summary>
[SwaggerSchema("产品Id")]
public string IoTPlatformProductId { get; set; }
/// <summary> /// <summary>
/// 产品名称 /// 产品名称
/// </summary> /// </summary>
[SwaggerSchema("产品名称")] [SwaggerSchema("产品名称")]
public string ProductName { get; set; } public string IoTPlatformProductName { get; set; }
/// <summary> /// <summary>
/// 产品访问密钥 /// 产品访问密钥
/// </summary> /// </summary>
[SwaggerSchema("产品访问密钥")] [SwaggerSchema("产品访问密钥")]
public string ProductAccesskey { get; set; } public string IoTPlatformProductAccesskey { get; set; }
/// <summary> /// <summary>
/// 通讯服务地址 /// 通讯服务地址

View File

@ -176,13 +176,13 @@ namespace JiShe.IoT.IoTPlatformAggregation
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
public async Task<List<SelectResult>> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input) public async Task<List<SelectResult>> GetIoTPlatformProductThingModelInfoAsync(IoTPlatformProductThingModelInfoInput input)
{ {
try try
{ {
if (input == null) if (input == null)
{ {
throw new UserFriendlyException($"{nameof(GetIoTPlatformProductPropertyInfoAsync)} 平台产品聚合服务获取产品属性信息失败,参数异常"); throw new UserFriendlyException($"{nameof(GetIoTPlatformProductThingModelInfoAsync)} 平台产品聚合服务获取产品属性信息失败,参数异常");
} }
var key = string.Format($"{RedisConst.CachePlatformProductThingModelInfoKey}", input.IoTPlatformType); var key = string.Format($"{RedisConst.CachePlatformProductThingModelInfoKey}", input.IoTPlatformType);
List<SelectResult> selectResults = new List<SelectResult>(); List<SelectResult> selectResults = new List<SelectResult>();
@ -205,7 +205,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
// ProductName = ctwingProductInfo.ProductName // ProductName = ctwingProductInfo.ProductName
// }); // });
//} //}
_logger.LogError($"{nameof(GetIoTPlatformProductPropertyInfoAsync)}产品聚合服务暂不支持CTWing产品物模型属性信息查询"); _logger.LogError($"{nameof(GetIoTPlatformProductThingModelInfoAsync)}产品聚合服务暂不支持CTWing产品物模型属性信息查询");
return selectResults; return selectResults;
} }
@ -243,10 +243,18 @@ namespace JiShe.IoT.IoTPlatformAggregation
if (!string.IsNullOrWhiteSpace(input.FiledType) && input.FiledType.ToLowerInvariant().Contains("event")) 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; return selectResults;
@ -265,7 +273,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <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) if (input == null)
{ {
throw new UserFriendlyException($"{nameof(UpdateIoTPlatformProductPropertyInfoAsync)} 平台产品聚合服务获取产品属性信息失败,参数异常"); throw new UserFriendlyException($"{nameof(UpdateIoTPlatformProductThingModelInfoAsync)} 平台产品聚合服务获取产品属性信息失败,参数异常");
} }
if (input.IoTPlatformType == IoTPlatformTypeEnum.CTWing) if (input.IoTPlatformType == IoTPlatformTypeEnum.CTWing)
{ {
_logger.LogError($"{nameof(UpdateIoTPlatformProductPropertyInfoAsync)}产品聚合服务暂不支持CTWing产品物模型属性信息更新"); _logger.LogError($"{nameof(UpdateIoTPlatformProductThingModelInfoAsync)}产品聚合服务暂不支持CTWing产品物模型属性信息更新");
return null; return null;
} }
@ -290,19 +298,30 @@ namespace JiShe.IoT.IoTPlatformAggregation
var oneNetProductInfos = await _oneNetProductService.UpdateThingModelAsync(new IdInput<string>() { Id = input.IoTPlatformProductId }); var oneNetProductInfos = await _oneNetProductService.UpdateThingModelAsync(new IdInput<string>() { Id = input.IoTPlatformProductId });
if (oneNetProductInfos == null || string.IsNullOrWhiteSpace(oneNetProductInfos.ThingModelInfos)) 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; return null;
} }
var oneNETAllThingModel = oneNetProductInfos.ThingModelInfos.Deserialize<OneNETAllThingModel>(); var oneNETAllThingModel = oneNetProductInfos.ThingModelInfos.Deserialize<OneNETAllThingModel>();
if (oneNETAllThingModel == null) if (oneNETAllThingModel == null)
{ {
_logger.LogError($"{nameof(UpdateIoTPlatformProductPropertyInfoAsync)}产品聚合服务OneNET产品{input.IoTPlatformProductId}物模型属性信息更新失败,-102"); _logger.LogError($"{nameof(UpdateIoTPlatformProductThingModelInfoAsync)}产品聚合服务OneNET产品{input.IoTPlatformProductId}物模型属性信息更新失败,-102");
return null; return null;
} }
//将平台产品最新物模型信息更新到平台端物模型表中 List<SelectResult> selectResults = OneNETAllThingModel.GetAllPropertiesSelectResult(oneNETAllThingModel.Properties);
var 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); await _ioTPlatformThingModelInfoAppService.UpdatePlatformThingModelAsync(input.IoTPlatformProductId, input.IoTPlatformType, selectResults);

View File

@ -84,11 +84,11 @@ namespace JiShe.ServicePro.OneNETManagement.Subscribers
} }
deviceEntity.DeviceOnlineStatus = deviceStatusMessage.Status; deviceEntity.DeviceOnlineStatus = deviceStatusMessage.Status;
if (deviceStatusMessage.Status == DeviceOnlineStatusEnum.Online) if (deviceStatusMessage.Status == DeviceOnlineStatus.Online)
{ {
deviceEntity.LastOnlineTime = TimestampHelper.ConvertToDateTime(deviceStatusMessage.ReceivedTime, TimestampUnit.Milliseconds, DateTimeKind.Local); 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); deviceEntity.LastOfflineTime = TimestampHelper.ConvertToDateTime(deviceStatusMessage.ReceivedTime, TimestampUnit.Milliseconds, DateTimeKind.Local);
} }

View File

@ -104,10 +104,10 @@ namespace JiShe.IoT.Workshops
.OrderByDescending(e => e.CreationTime) .OrderByDescending(e => e.CreationTime)
.ToListAsync(d => new WorkshopProductListOutput .ToListAsync(d => new WorkshopProductListOutput
{ {
ProductDataId = d.Id, IoTPlatformProductId = d.IoTPlatformProductId,
ProductName = d.ProductName, IoTPlatformProductName = d.ProductName,
CommunicationAddress = d.CommunicationAddress, CommunicationAddress = d.CommunicationAddress,
ProductAccesskey = d.FeatureAccesskey, IoTPlatformProductAccesskey = d.FeatureAccesskey,
}); });
} }
else if (messageBody.IoTPlatform == IoTPlatformTypeEnum.CTWing) else if (messageBody.IoTPlatform == IoTPlatformTypeEnum.CTWing)
@ -117,10 +117,10 @@ namespace JiShe.IoT.Workshops
.OrderByDescending(e => e.CreationTime) .OrderByDescending(e => e.CreationTime)
.ToListAsync(d => new WorkshopProductListOutput .ToListAsync(d => new WorkshopProductListOutput
{ {
ProductDataId = d.Id, IoTPlatformProductId = d.IoTPlatformProductId,
ProductName = d.ProductName, IoTPlatformProductName = d.ProductName,
CommunicationAddress = d.CommunicationAddress, CommunicationAddress = d.CommunicationAddress,
ProductAccesskey = d.ProductAccesskey, IoTPlatformProductAccesskey = d.ProductAccesskey,
CommunicationAddressTLS = d.CommunicationAddressTLS CommunicationAddressTLS = d.CommunicationAddressTLS
}); });
} }

View File

@ -46,27 +46,27 @@ namespace JiShe.IoT.Controllers
} }
/// <summary> /// <summary>
/// 获取平台产品物模型属性信息 /// 获取平台产品物模型信息
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost(nameof(GetIoTPlatformProductPropertyInfoAsync))] [HttpPost(nameof(GetIoTPlatformProductThingModelInfoAsync))]
[SwaggerOperation(summary: "获取平台产品物模型属性信息", Tags = new[] { "AggregationIoTPlatform" })] [SwaggerOperation(summary: "获取平台产品物模型信息", Tags = new[] { "AggregationIoTPlatform" })]
public async Task<List<SelectResult>> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input) public async Task<List<SelectResult>> GetIoTPlatformProductThingModelInfoAsync(IoTPlatformProductThingModelInfoInput input)
{ {
return await _iotPlatformAggregationService.GetIoTPlatformProductPropertyInfoAsync(input); return await _iotPlatformAggregationService.GetIoTPlatformProductThingModelInfoAsync(input);
} }
/// <summary> /// <summary>
/// 更新平台产品物模型属性信息 /// 更新平台产品物模型信息
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost(nameof(UpdateIoTPlatformProductPropertyInfoAsync))] [HttpPost(nameof(UpdateIoTPlatformProductThingModelInfoAsync))]
[SwaggerOperation(summary: "更新平台产品物模型属性信息", Tags = new[] { "AggregationIoTPlatform" })] [SwaggerOperation(summary: "更新平台产品物模型信息", Tags = new[] { "AggregationIoTPlatform" })]
public async Task<object> UpdateIoTPlatformProductPropertyInfoAsync(UpdateIoTPlatformProductPropertyInfoInput input) public async Task<object> UpdateIoTPlatformProductThingModelInfoAsync(UpdateIoTPlatformProductThingModelInfoInput input)
{ {
return await _iotPlatformAggregationService.UpdateIoTPlatformProductPropertyInfoAsync(input); return await _iotPlatformAggregationService.UpdateIoTPlatformProductThingModelInfoAsync(input);
} }
} }