From b14df70fa0a077ea377dc6dafa60bad6a7946a20 Mon Sep 17 00:00:00 2001 From: ChenYi <296215406@outlook.com> Date: Mon, 5 Jan 2026 17:25:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=A0=87=E5=87=86=E7=89=A9?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... IoTPlatformProductThingModelInfoInput.cs} | 2 +- ...eIoTPlatformProductThingModelInfoInput.cs} | 5 ++- .../IIoTPlatformAggregationService.cs | 4 +- .../Dto/WorkshopProductListOutput.cs | 16 ++++--- .../IoTPlatformAggregationService.cs | 43 +++++++++++++------ ...ceCommunicationChannelSubscriberService.cs | 4 +- .../Workshops/WorkshopAggregationService.cs | 12 +++--- .../IoTPlatformAggregationController.cs | 20 ++++----- 8 files changed, 66 insertions(+), 40 deletions(-) rename src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/{IoTPlatformProductPropertyInfoInput.cs => IoTPlatformProductThingModelInfoInput.cs} (94%) rename src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/{UpdateIoTPlatformProductPropertyInfoInput.cs => UpdateIoTPlatformProductThingModelInfoInput.cs} (84%) diff --git a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductPropertyInfoInput.cs b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductThingModelInfoInput.cs similarity index 94% rename from src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductPropertyInfoInput.cs rename to src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductThingModelInfoInput.cs index b697d54..3373c1f 100644 --- a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductPropertyInfoInput.cs +++ b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductThingModelInfoInput.cs @@ -12,7 +12,7 @@ namespace JiShe.IoT.IoTPlatformAggregation.Dto /// /// 产品属性信息输入 /// - public class IoTPlatformProductPropertyInfoInput + public class IoTPlatformProductThingModelInfoInput { /// /// 物联网平台类型,默认没有指定 diff --git a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/UpdateIoTPlatformProductPropertyInfoInput.cs b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/UpdateIoTPlatformProductThingModelInfoInput.cs similarity index 84% rename from src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/UpdateIoTPlatformProductPropertyInfoInput.cs rename to src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/UpdateIoTPlatformProductThingModelInfoInput.cs index 2f09bf4..65e451d 100644 --- a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/UpdateIoTPlatformProductPropertyInfoInput.cs +++ b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/UpdateIoTPlatformProductThingModelInfoInput.cs @@ -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 /// /// 平台产品属性更新输入 /// - public class UpdateIoTPlatformProductPropertyInfoInput + public class UpdateIoTPlatformProductThingModelInfoInput { /// /// 物联网平台类型,默认没有指定 diff --git a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/IIoTPlatformAggregationService.cs b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/IIoTPlatformAggregationService.cs index 60c46e3..2a9178d 100644 --- a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/IIoTPlatformAggregationService.cs +++ b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/IIoTPlatformAggregationService.cs @@ -35,7 +35,7 @@ namespace JiShe.IoT.IoTPlatformAggregation /// /// /// - Task> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input + Task> GetIoTPlatformProductThingModelInfoAsync(IoTPlatformProductThingModelInfoInput input ); /// @@ -43,7 +43,7 @@ namespace JiShe.IoT.IoTPlatformAggregation /// /// /// - Task UpdateIoTPlatformProductPropertyInfoAsync(UpdateIoTPlatformProductPropertyInfoInput input + Task UpdateIoTPlatformProductThingModelInfoAsync(UpdateIoTPlatformProductThingModelInfoInput input ); } } diff --git a/src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListOutput.cs b/src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListOutput.cs index 9c5c38e..bc16864 100644 --- a/src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListOutput.cs +++ b/src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListOutput.cs @@ -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 { /// - /// 产品数据Id + /// 平台类型 /// - [SwaggerSchema("产品数据Id")] - public Guid ProductDataId { get; set; } + public IoTPlatformTypeEnum IoTPlatform { get; set; } + + /// + /// 产品Id + /// + [SwaggerSchema("产品Id")] + public string IoTPlatformProductId { get; set; } /// /// 产品名称 /// [SwaggerSchema("产品名称")] - public string ProductName { get; set; } + public string IoTPlatformProductName { get; set; } /// /// 产品访问密钥 /// [SwaggerSchema("产品访问密钥")] - public string ProductAccesskey { get; set; } + public string IoTPlatformProductAccesskey { get; set; } /// /// 通讯服务地址 diff --git a/src/JiShe.IoT.Application/IoTPlatformAggregation/IoTPlatformAggregationService.cs b/src/JiShe.IoT.Application/IoTPlatformAggregation/IoTPlatformAggregationService.cs index b67b481..bda24d8 100644 --- a/src/JiShe.IoT.Application/IoTPlatformAggregation/IoTPlatformAggregationService.cs +++ b/src/JiShe.IoT.Application/IoTPlatformAggregation/IoTPlatformAggregationService.cs @@ -176,13 +176,13 @@ namespace JiShe.IoT.IoTPlatformAggregation /// /// /// - public async Task> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input) + public async Task> 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 selectResults = new List(); @@ -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 /// /// /// - public async Task UpdateIoTPlatformProductPropertyInfoAsync(UpdateIoTPlatformProductPropertyInfoInput input + public async Task 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() { 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(); 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 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); diff --git a/src/JiShe.IoT.Application/Subscribers/ServiceCommunicationChannelSubscriberService.cs b/src/JiShe.IoT.Application/Subscribers/ServiceCommunicationChannelSubscriberService.cs index e71ba0b..49b26c9 100644 --- a/src/JiShe.IoT.Application/Subscribers/ServiceCommunicationChannelSubscriberService.cs +++ b/src/JiShe.IoT.Application/Subscribers/ServiceCommunicationChannelSubscriberService.cs @@ -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); } diff --git a/src/JiShe.IoT.Application/Workshops/WorkshopAggregationService.cs b/src/JiShe.IoT.Application/Workshops/WorkshopAggregationService.cs index 6361552..8df8b2c 100644 --- a/src/JiShe.IoT.Application/Workshops/WorkshopAggregationService.cs +++ b/src/JiShe.IoT.Application/Workshops/WorkshopAggregationService.cs @@ -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 }); } diff --git a/src/JiShe.IoT.HttpApi/Controllers/IoTPlatformAggregationController.cs b/src/JiShe.IoT.HttpApi/Controllers/IoTPlatformAggregationController.cs index 42fa526..37fff38 100644 --- a/src/JiShe.IoT.HttpApi/Controllers/IoTPlatformAggregationController.cs +++ b/src/JiShe.IoT.HttpApi/Controllers/IoTPlatformAggregationController.cs @@ -46,27 +46,27 @@ namespace JiShe.IoT.Controllers } /// - /// 获取平台产品物模型属性信息 + /// 获取平台产品物模型信息 /// /// /// - [HttpPost(nameof(GetIoTPlatformProductPropertyInfoAsync))] - [SwaggerOperation(summary: "获取平台产品物模型属性信息", Tags = new[] { "AggregationIoTPlatform" })] - public async Task> GetIoTPlatformProductPropertyInfoAsync(IoTPlatformProductPropertyInfoInput input) + [HttpPost(nameof(GetIoTPlatformProductThingModelInfoAsync))] + [SwaggerOperation(summary: "获取平台产品物模型信息", Tags = new[] { "AggregationIoTPlatform" })] + public async Task> GetIoTPlatformProductThingModelInfoAsync(IoTPlatformProductThingModelInfoInput input) { - return await _iotPlatformAggregationService.GetIoTPlatformProductPropertyInfoAsync(input); + return await _iotPlatformAggregationService.GetIoTPlatformProductThingModelInfoAsync(input); } /// - /// 更新平台产品物模型属性信息 + /// 更新平台产品物模型信息 /// /// /// - [HttpPost(nameof(UpdateIoTPlatformProductPropertyInfoAsync))] - [SwaggerOperation(summary: "更新平台产品物模型属性信息", Tags = new[] { "AggregationIoTPlatform" })] - public async Task UpdateIoTPlatformProductPropertyInfoAsync(UpdateIoTPlatformProductPropertyInfoInput input) + [HttpPost(nameof(UpdateIoTPlatformProductThingModelInfoAsync))] + [SwaggerOperation(summary: "更新平台产品物模型信息", Tags = new[] { "AggregationIoTPlatform" })] + public async Task UpdateIoTPlatformProductThingModelInfoAsync(UpdateIoTPlatformProductThingModelInfoInput input) { - return await _iotPlatformAggregationService.UpdateIoTPlatformProductPropertyInfoAsync(input); + return await _iotPlatformAggregationService.UpdateIoTPlatformProductThingModelInfoAsync(input); } }