From 645f558c4b6e7aa19f524438652085aed770ad58 Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Tue, 23 Dec 2025 10:46:53 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=AE=BE=E5=A4=87=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E5=92=8C=E7=BB=91=E5=AE=9A=E7=89=A9=E6=A8=A1=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/IoTPlatformAccountInfoInput.cs | 22 ++++++
.../Dto/IoTPlatformAccountInfoOutput.cs | 31 ++++++++
.../Dto/IoTPlatformProductInfoInput.cs | 5 ++
.../IIoTPlatformAggregationService.cs | 9 +++
.../IoTPlatformAggregationService.cs | 79 +++++++++++++++++--
.../IoTPlatformAggregationController.cs | 12 +++
6 files changed, 153 insertions(+), 5 deletions(-)
create mode 100644 src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformAccountInfoInput.cs
create mode 100644 src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformAccountInfoOutput.cs
diff --git a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformAccountInfoInput.cs b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformAccountInfoInput.cs
new file mode 100644
index 0000000..51317c5
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformAccountInfoInput.cs
@@ -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
+{
+ ///
+ /// 平台账号信息输入
+ ///
+ public class IoTPlatformAccountInfoInput
+ {
+ ///
+ /// 平台类型
+ ///
+ [Required]
+ public IoTPlatformTypeEnum IoTPlatformType { get; set; }
+ }
+}
diff --git a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformAccountInfoOutput.cs b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformAccountInfoOutput.cs
new file mode 100644
index 0000000..7b5c723
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformAccountInfoOutput.cs
@@ -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
+{
+ ///
+ /// 平台账号信息
+ ///
+ public class IoTPlatformAccountInfoOutput
+ {
+ ///
+ /// 物联网平台类型
+ ///
+ public IoTPlatformTypeEnum IoTPlatformType { get; set; }
+
+ ///
+ /// 平台账号
+ ///
+ public string IoTPlatformAccount { get; set; }
+
+ ///
+ /// 平台账号手机号
+ ///
+ public string IoTPlatformPhoneNumber { get; set; }
+ }
+}
diff --git a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductInfoInput.cs b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductInfoInput.cs
index a8d4f0d..ff62e9f 100644
--- a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductInfoInput.cs
+++ b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/Dto/IoTPlatformProductInfoInput.cs
@@ -18,5 +18,10 @@ namespace JiShe.IoT.IoTPlatformAggregation.Dto
///
[Required]
public IoTPlatformTypeEnum IoTPlatformType { get; set; }
+
+ ///
+ /// 平台账号
+ ///
+ public string IoTPlatformAccount { get; set; }
}
}
diff --git a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/IIoTPlatformAggregationService.cs b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/IIoTPlatformAggregationService.cs
index 8ab80d0..b5abc45 100644
--- a/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/IIoTPlatformAggregationService.cs
+++ b/src/JiShe.IoT.Application.Contracts/IoTPlatformAggregation/IIoTPlatformAggregationService.cs
@@ -21,6 +21,15 @@ namespace JiShe.IoT.IoTPlatformAggregation
Task> GetIoTPlatformProductInfoAsync(IoTPlatformProductInfoInput input
);
+
+ ///
+ /// 获取平台账号信息
+ ///
+ ///
+ ///
+ Task> GetIoTPlatformAccountInfoAsync(IoTPlatformAccountInfoInput input
+ );
+
///
/// 获取平台产品物模型属性信息
///
diff --git a/src/JiShe.IoT.Application/IoTPlatformAggregation/IoTPlatformAggregationService.cs b/src/JiShe.IoT.Application/IoTPlatformAggregation/IoTPlatformAggregationService.cs
index ae6a17f..af47905 100644
--- a/src/JiShe.IoT.Application/IoTPlatformAggregation/IoTPlatformAggregationService.cs
+++ b/src/JiShe.IoT.Application/IoTPlatformAggregation/IoTPlatformAggregationService.cs
@@ -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 _logger;
private readonly ICTWingProductService _ctwingProductService;
private readonly IOneNETProductService _oneNetProductService;
+ private readonly ICTWingAccountService _ctwingAccountService;
+ private readonly IOneNETAccountService _oneNETAccountService;
public IoTPlatformAggregationService(ILogger logger,
ICTWingProductService ctwingProductService,
- IOneNETProductService oneNetProductService)
+ IOneNETProductService oneNetProductService,
+ ICTWingAccountService ctwingAccountService,
+ IOneNETAccountService oneNETAccountService)
{
_logger = logger;
_ctwingProductService = ctwingProductService;
_oneNetProductService = oneNetProductService;
+ _ctwingAccountService = ctwingAccountService;
+ _oneNETAccountService = oneNETAccountService;
}
///
@@ -47,12 +55,12 @@ namespace JiShe.IoT.IoTPlatformAggregation
{
if (input == null)
{
- throw new UserFriendlyException($"{nameof(GetIoTPlatformProductInfoAsync)} 平台产品聚合服务获取产品信息失败,参数异常");
+ throw new UserFriendlyException($"{nameof(GetIoTPlatformProductInfoAsync)} 平台聚合服务获取产品信息失败,参数异常");
}
List ioTPlatformProductInfoOutputs = new List();
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
}
}
+ ///
+ /// 获取平台账号信息
+ ///
+ ///
+ ///
+ public async Task> GetIoTPlatformAccountInfoAsync(IoTPlatformAccountInfoInput input
+ )
+ {
+ try
+ {
+ if (input == null)
+ {
+ throw new UserFriendlyException($"{nameof(GetIoTPlatformAccountInfoAsync)} 平台聚合服务获取账户信息失败,参数异常");
+ }
+ List ioTPlatformAccountInfoOutputs = new List();
+ 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;
+ }
+ }
+
///
/// 获取平台产品物模型属性信息
@@ -152,7 +221,7 @@ namespace JiShe.IoT.IoTPlatformAggregation
return selectResults;
}
-
+
oneNETAllThingModel = oneNetProductInfos.ThingModelInfos.Deserialize();
diff --git a/src/JiShe.IoT.HttpApi/Controllers/IoTPlatformAggregationController.cs b/src/JiShe.IoT.HttpApi/Controllers/IoTPlatformAggregationController.cs
index e71e67f..b96240f 100644
--- a/src/JiShe.IoT.HttpApi/Controllers/IoTPlatformAggregationController.cs
+++ b/src/JiShe.IoT.HttpApi/Controllers/IoTPlatformAggregationController.cs
@@ -33,6 +33,18 @@ namespace JiShe.IoT.Controllers
return await _iotPlatformAggregationService.GetIoTPlatformProductInfoAsync(input);
}
+ ///
+ /// 获取平台账号信息
+ ///
+ ///
+ ///
+ [HttpPost(nameof(GetIoTPlatformAccountInfoAsync))]
+ [SwaggerOperation(summary: "获取平台账号信息", Tags = new[] { "AggregationIoTPlatform" })]
+ public async Task> GetIoTPlatformAccountInfoAsync(IoTPlatformAccountInfoInput input)
+ {
+ return await _iotPlatformAggregationService.GetIoTPlatformAccountInfoAsync(input);
+ }
+
///
/// 获取平台产品物模型属性信息
///