平台产品聚合服务
This commit is contained in:
parent
8f9fb1816d
commit
fb5c9eca52
@ -0,0 +1,20 @@
|
|||||||
|
using JiShe.ServicePro.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JiShe.IoT.IoTPlatformAggregation.Dto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 产品信息输入
|
||||||
|
/// </summary>
|
||||||
|
public class IoTPlatformProductInfoInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 平台类型
|
||||||
|
/// </summary>
|
||||||
|
public IoTPlatformTypeEnum IoTPlatformType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
using JiShe.ServicePro.Enums;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JiShe.IoT.IoTPlatformAggregation.Dto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 平台产品信息
|
||||||
|
/// </summary>
|
||||||
|
public class IoTPlatformProductInfoOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 物联网平台类型
|
||||||
|
/// </summary>
|
||||||
|
public IoTPlatformTypeEnum IoTPlatformType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物联网平台对应的产品Id
|
||||||
|
/// </summary>
|
||||||
|
public string IoTPlatformProductId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 产品名称
|
||||||
|
/// </summary>
|
||||||
|
public string ProductName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JiShe.IoT.IoTPlatformAggregation
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 平台聚合服务
|
||||||
|
/// </summary>
|
||||||
|
public interface IIoTPlatformAggregationService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取平台产品信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<IoTPlatformProductInfoOutput>> GetIoTPlatformProductInfoAsync(IoTPlatformProductInfoInput input
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,95 @@
|
|||||||
|
using Castle.Core.Logging;
|
||||||
|
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
||||||
|
using JiShe.ServicePro.CTWingManagement.CTWingProducts;
|
||||||
|
using JiShe.ServicePro.Enums;
|
||||||
|
using JiShe.ServicePro.OneNETManagement.OneNETProducts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Volo.Abp;
|
||||||
|
|
||||||
|
namespace JiShe.IoT.IoTPlatformAggregation
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 平台聚合服务
|
||||||
|
/// </summary>
|
||||||
|
public class IoTPlatformAggregationService : IoTAppService, IIoTPlatformAggregationService
|
||||||
|
{
|
||||||
|
private readonly ILogger<IoTPlatformAggregationService> _logger;
|
||||||
|
private readonly ICTWingProductService _ctwingProductService;
|
||||||
|
private readonly IOneNETProductService _oneNetProductService;
|
||||||
|
|
||||||
|
public IoTPlatformAggregationService(ILogger<IoTPlatformAggregationService> logger,
|
||||||
|
ICTWingProductService ctwingProductService,
|
||||||
|
IOneNETProductService oneNetProductService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_ctwingProductService = ctwingProductService;
|
||||||
|
_oneNetProductService = oneNetProductService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取平台产品信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<IoTPlatformProductInfoOutput>> GetIoTPlatformProductInfoAsync(IoTPlatformProductInfoInput input
|
||||||
|
)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (input == null)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException($"{nameof(GetIoTPlatformProductInfoAsync)} 平台产品聚合服务获取产品信息失败,参数异常");
|
||||||
|
}
|
||||||
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(input.IoTPlatformType == IoTPlatformTypeEnum.OneNET)
|
||||||
|
{
|
||||||
|
var oneNetProductInfos = await _oneNetProductService.GetAllListAsync();
|
||||||
|
if(oneNetProductInfos == null)
|
||||||
|
{
|
||||||
|
return ioTPlatformProductInfoOutputs;
|
||||||
|
}
|
||||||
|
foreach (var oneNetProductInfo in oneNetProductInfos)
|
||||||
|
{
|
||||||
|
ioTPlatformProductInfoOutputs.Add(new IoTPlatformProductInfoOutput
|
||||||
|
{
|
||||||
|
IoTPlatformType = IoTPlatformTypeEnum.OneNET,
|
||||||
|
IoTPlatformProductId = oneNetProductInfo.IoTPlatformProductId,
|
||||||
|
ProductName = oneNetProductInfo.ProductName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ioTPlatformProductInfoOutputs;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3839
src/JiShe.IoT.EntityFrameworkCore/Migrations/20251217033440_update20251217.Designer.cs
generated
Normal file
3839
src/JiShe.IoT.EntityFrameworkCore/Migrations/20251217033440_update20251217.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,50 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace JiShe.IoT.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class update20251217 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "IoTPlatformRawFieldExtension",
|
||||||
|
table: "ServiceProIoTPlatformThingModelInfo",
|
||||||
|
type: "text",
|
||||||
|
nullable: true,
|
||||||
|
comment: "物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "text",
|
||||||
|
oldComment: "物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "ServiceProIoTPlatformThingModelInfo",
|
||||||
|
keyColumn: "IoTPlatformRawFieldExtension",
|
||||||
|
keyValue: null,
|
||||||
|
column: "IoTPlatformRawFieldExtension",
|
||||||
|
value: "");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "IoTPlatformRawFieldExtension",
|
||||||
|
table: "ServiceProIoTPlatformThingModelInfo",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
comment: "物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "text",
|
||||||
|
oldNullable: true,
|
||||||
|
oldComment: "物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,7 +19,7 @@ namespace JiShe.IoT.Migrations
|
|||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
|
||||||
.HasAnnotation("ProductVersion", "9.0.6")
|
.HasAnnotation("ProductVersion", "9.0.11")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||||
|
|
||||||
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
||||||
@ -1155,7 +1155,6 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasComment("物联网平台中对应的产品Id");
|
.HasComment("物联网平台中对应的产品Id");
|
||||||
|
|
||||||
b.Property<string>("IoTPlatformRawFieldExtension")
|
b.Property<string>("IoTPlatformRawFieldExtension")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasComment("物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型");
|
.HasComment("物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型");
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,36 @@
|
|||||||
|
using JiShe.IoT.DeviceAggregation;
|
||||||
|
using JiShe.IoT.DeviceAggregation.Dto;
|
||||||
|
using JiShe.IoT.IoTPlatformAggregation;
|
||||||
|
using JiShe.IoT.IoTPlatformAggregation.Dto;
|
||||||
|
using JiShe.ServicePro;
|
||||||
|
using JiShe.ServicePro.Core;
|
||||||
|
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
||||||
|
|
||||||
|
namespace JiShe.IoT.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 平台产品聚合服务
|
||||||
|
/// </summary>
|
||||||
|
[Route("/Aggregation/IoTPlatform")]
|
||||||
|
public class IoTPlatformAggregationController : IoTController
|
||||||
|
{
|
||||||
|
private readonly IIoTPlatformAggregationService _iotPlatformAggregationService;
|
||||||
|
public IoTPlatformAggregationController(IIoTPlatformAggregationService deviceAggregationService)
|
||||||
|
{
|
||||||
|
_iotPlatformAggregationService = deviceAggregationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取平台产品信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost(nameof(GetIoTPlatformProductInfoAsync))]
|
||||||
|
[SwaggerOperation(summary: "获取平台产品信息", Tags = new[] { "AggregationIoTPlatform" })]
|
||||||
|
public async Task<List<IoTPlatformProductInfoOutput>> GetIoTPlatformProductInfoAsync(IoTPlatformProductInfoInput input)
|
||||||
|
{
|
||||||
|
return await _iotPlatformAggregationService.GetIoTPlatformProductInfoAsync(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user