From 000f9752eae50c2d89f0bcf463be91307d40c767 Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Wed, 30 Jul 2025 11:09:12 +0800
Subject: [PATCH] =?UTF-8?q?CTWing=E8=B4=A6=E5=8F=B7=E7=AE=A1=E7=90=86?=
=?UTF-8?q?=EF=BC=8C=E4=BA=A7=E5=93=81=E7=AE=A1=E7=90=86=EF=BC=8C=E8=AE=BE?=
=?UTF-8?q?=E5=A4=87=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3=E6=A1=86=E6=9E=B6?=
=?UTF-8?q?=E5=AE=9A=E4=B9=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
JiShe.ServicePro | 2 +-
.../Dto/CTWingWorkshopProductListOutput.cs | 52 ++++++
.../ICTWingAggregationService.cs | 26 +++
.../ProductionEquipmentMessageBody.cs | 2 +-
.../CTWingAggregationService.cs | 166 ++++++++++++++++++
.../OneNETAggregationService.cs | 1 +
... 20250730030313_InitialCreate.Designer.cs} | 55 ++++--
...ate.cs => 20250730030313_InitialCreate.cs} | 22 ++-
.../Migrations/IoTDbContextModelSnapshot.cs | 53 +++++-
.../CTWingAggregationController.cs | 41 +++++
10 files changed, 394 insertions(+), 26 deletions(-)
create mode 100644 src/JiShe.IoT.Application.Contracts/CTWingAggregation/Dto/CTWingWorkshopProductListOutput.cs
create mode 100644 src/JiShe.IoT.Application.Contracts/CTWingAggregation/ICTWingAggregationService.cs
rename src/JiShe.IoT.Application.Contracts/{OneNETAggregation/Dto => Workshops}/ProductionEquipmentMessageBody.cs (96%)
create mode 100644 src/JiShe.IoT.Application/CTWingAggregation/CTWingAggregationService.cs
rename src/JiShe.IoT.EntityFrameworkCore/Migrations/{20250729024912_InitialCreate.Designer.cs => 20250730030313_InitialCreate.Designer.cs} (98%)
rename src/JiShe.IoT.EntityFrameworkCore/Migrations/{20250729024912_InitialCreate.cs => 20250730030313_InitialCreate.cs} (98%)
create mode 100644 src/JiShe.IoT.HttpApi/Controllers/CTWingAggregationController.cs
diff --git a/JiShe.ServicePro b/JiShe.ServicePro
index cf3eff7..5562b1a 160000
--- a/JiShe.ServicePro
+++ b/JiShe.ServicePro
@@ -1 +1 @@
-Subproject commit cf3eff7465d5f3d89b4f95d372a0a7e797f4dec0
+Subproject commit 5562b1a3c43e34f663b4f58415698b1c9d0190d6
diff --git a/src/JiShe.IoT.Application.Contracts/CTWingAggregation/Dto/CTWingWorkshopProductListOutput.cs b/src/JiShe.IoT.Application.Contracts/CTWingAggregation/Dto/CTWingWorkshopProductListOutput.cs
new file mode 100644
index 0000000..3f5617a
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/CTWingAggregation/Dto/CTWingWorkshopProductListOutput.cs
@@ -0,0 +1,52 @@
+using JiShe.ServicePro;
+using Swashbuckle.AspNetCore.Annotations;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.IoT.CTWingAggregation.Dto
+{
+ ///
+ /// 生产车间获取CTWing产品列表
+ ///
+ public class CTWingWorkshopProductListOutput : OpenApiRequest
+ {
+ ///
+ /// CTWing账户Id
+ ///
+ [SwaggerSchema("CTWing账户Id")]
+ public string CTWingAccountId { get; set; }
+
+ ///
+ /// 物联网平台对应的产品Id
+ ///
+ [SwaggerSchema("物联网平台对应的产品Id")]
+ public string IoTPlatformProductId { get; set; }
+
+ ///
+ /// 产品名称
+ ///
+ [SwaggerSchema("产品名称")]
+ public string ProductName { get; set; }
+
+ ///
+ /// 设备访问密钥
+ ///
+ [SwaggerSchema("设备访问密钥")]
+ public string FeatureAccesskey { get; set; }
+
+ ///
+ /// 通讯服务地址
+ ///
+ [SwaggerSchema("通讯服务地址")]
+ public string CommunicationAddress { get; set; }
+
+ ///
+ /// TLS通讯服务地址
+ ///
+ [SwaggerSchema("TLS通讯服务地址")]
+ public string CommunicationAddressTLS { get; set; }
+ }
+}
diff --git a/src/JiShe.IoT.Application.Contracts/CTWingAggregation/ICTWingAggregationService.cs b/src/JiShe.IoT.Application.Contracts/CTWingAggregation/ICTWingAggregationService.cs
new file mode 100644
index 0000000..f6faac0
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/CTWingAggregation/ICTWingAggregationService.cs
@@ -0,0 +1,26 @@
+using JiShe.IoT.CTWingAggregation.Dto;
+using JiShe.IoT.OneNETAggregation.Dto;
+using JiShe.ServicePro;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.IoT.CTWingAggregation
+{
+ public interface ICTWingAggregationService : IApplicationService
+ {
+ ///
+ /// 接收车间生产信息
+ ///
+ ///
+ ///
+ Task ReceiveWorkshopProductionInfoAsync(OpenApiRequest input);
+
+ ///
+ /// 获取CTWing产品列表
+ ///
+ Task>> GetProductListAsync(OpenApiRequest input);
+ }
+}
diff --git a/src/JiShe.IoT.Application.Contracts/OneNETAggregation/Dto/ProductionEquipmentMessageBody.cs b/src/JiShe.IoT.Application.Contracts/Workshops/ProductionEquipmentMessageBody.cs
similarity index 96%
rename from src/JiShe.IoT.Application.Contracts/OneNETAggregation/Dto/ProductionEquipmentMessageBody.cs
rename to src/JiShe.IoT.Application.Contracts/Workshops/ProductionEquipmentMessageBody.cs
index 4d72a6d..7b4abfe 100644
--- a/src/JiShe.IoT.Application.Contracts/OneNETAggregation/Dto/ProductionEquipmentMessageBody.cs
+++ b/src/JiShe.IoT.Application.Contracts/Workshops/ProductionEquipmentMessageBody.cs
@@ -7,7 +7,7 @@ using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
-namespace JiShe.IoT.OneNETAggregation.Dto
+namespace JiShe.IoT.Workshops
{
///
/// 生产设备详情
diff --git a/src/JiShe.IoT.Application/CTWingAggregation/CTWingAggregationService.cs b/src/JiShe.IoT.Application/CTWingAggregation/CTWingAggregationService.cs
new file mode 100644
index 0000000..0d81a3a
--- /dev/null
+++ b/src/JiShe.IoT.Application/CTWingAggregation/CTWingAggregationService.cs
@@ -0,0 +1,166 @@
+using JiShe.IoT.CTWingAggregation.Dto;
+using JiShe.IoT.Workshops;
+using JiShe.ServicePro;
+using JiShe.ServicePro.Core;
+using JiShe.ServicePro.CTWingManagement.CTWingDevices;
+using JiShe.ServicePro.CTWingManagement.CTWingProduct;
+using JiShe.ServicePro.DeviceManagement.DeviceInfos;
+using JiShe.ServicePro.DeviceManagement.DeviceInfos.Dto;
+using JiShe.ServicePro.Encrypt;
+using JiShe.ServicePro.Enums;
+using JiShe.ServicePro.FreeRedisProvider;
+using JiShe.ServicePro.ServerOptions;
+using Mapster;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+
+namespace JiShe.IoT.CTWingAggregation
+{
+ ///
+ /// CTWing聚合服务
+ ///
+ ///
+ ///
+ ///
+ ///
+ public class CTWingAggregationService(IDeviceAppService deviceAppService, ICTWingDeviceService ctwingDeviceService, IOptions options, ILogger logger) : IoTAppService, ICTWingAggregationService
+ {
+ ServerApplicationOptions srverOptions = options.Value;
+
+ ///
+ /// 接收车间生产信息
+ ///
+ ///
+ ///
+ [AllowAnonymous]
+ public async Task ReceiveWorkshopProductionInfoAsync(OpenApiRequest input)
+ {
+ try
+ {
+ bool verifySignatureReult = EncryptUtil.OpenApiVerifySignature(input.Message, input.Nonce, input.Timestamp, input.Signature, srverOptions.VerifySignatureToken);
+ if (verifySignatureReult == false)//签名校验失败
+ {
+ return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
+ }
+
+ ProductionEquipmentMessageBody productionEquipmentMessageBody = input.Message.Deserialize();
+
+ if (productionEquipmentMessageBody.MeterType.HasValue == false)
+ {
+ return HttpDataResultExtensions.Failed("设备类型不能为空", -103, ResponeResultEnum.Fail);
+ }
+
+ if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.IoTPlatformProductId))
+ {
+ return HttpDataResultExtensions.Failed("物联网平台产品Id不能为空", -104, ResponeResultEnum.Fail);
+ }
+
+
+ if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.IoTPlatformProductId))
+ {
+ return HttpDataResultExtensions.Failed("物联网平台产品Id不能为空", -105, ResponeResultEnum.Fail);
+ }
+
+ if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.DeviceAddress))
+ {
+ return HttpDataResultExtensions.Failed("设备地址不能为空", -106, ResponeResultEnum.Fail);
+ }
+
+ if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.DeviceOpenInfo))
+ {
+ return HttpDataResultExtensions.Failed("物联网平台唯一设备标识,不能为空", -107, ResponeResultEnum.Fail);
+ }
+
+ var productInfo = await FreeSqlDbContext.Instance.Select()
+ .Where(e => e.IsEnabled == true && e.IoTPlatformProductId == productionEquipmentMessageBody.IoTPlatformProductId)
+ .FirstAsync();
+
+ if (productInfo == null)
+ {
+ return HttpDataResultExtensions.Failed("没有找到对应的产品信息", -108, ResponeResultEnum.Fail);
+ }
+
+ CreateDeviceInput meterInfoEntity = new CreateDeviceInput()
+ {
+ DeviceAddress = productionEquipmentMessageBody.DeviceAddress,
+ PlatformPassword = productInfo.MasterKey,
+ IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId,
+ IoTPlatformDeviceOpenInfo = productionEquipmentMessageBody.DeviceOpenInfo,
+ DeviceName = productionEquipmentMessageBody.DeviceOpenInfo
+ };
+
+ //创建本地设备信息
+ var insertResult = await deviceAppService.CreateAsync(meterInfoEntity);
+
+ //推送至CTWing平台
+ var pushResult = await ctwingDeviceService.CreateDeviceInfoAsync(new CreateDeviceInfoInput()
+ {
+ //DeviceName = productionEquipmentMessageBody.DeviceOpenInfo,
+ //ProductId = productionEquipmentMessageBody.IoTPlatformProductId,
+ //CTWingAccountId = productInfo.CTWingAccountId,
+ //Description = productionEquipmentMessageBody.DeviceOpenInfo,
+ });
+
+ if (pushResult == null || pushResult.Code != ServicePro.Enums.ResponeResultEnum.Success)
+ {
+ logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} 推送设备信息失败:{pushResult.Serialize()}");
+ return HttpDataResultExtensions.Failed("推送设备信息CTWing失败", -109, ResponeResultEnum.Fail);
+ }
+
+ UpdateDeviceInput updateDeviceInput = insertResult.Adapt();
+ updateDeviceInput.IoTPlatformResponse = pushResult.Serialize();
+
+ var updateResult = await deviceAppService.UpdateAsync(updateDeviceInput);
+ if (updateResult == null)
+ {
+ logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} CTWing返回的设备信息更新失败:{input.Serialize()}");
+ return HttpDataResultExtensions.Failed("CTWing返回的设备信息更新失败", -110, ResponeResultEnum.Fail);
+ }
+
+ //设备数据缓存到Redis
+ DeviceCacheInfos deviceCacheInfos = insertResult.Adapt();
+ deviceCacheInfos.IoTPlatformResponse = updateDeviceInput.IoTPlatformResponse;
+
+ RedisProvider.Instance.HSet(RedisConst.CacheAllDeviceInfoHashKey, insertResult.DeviceAddress, deviceCacheInfos);
+
+ return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
+ }
+ catch (Exception ex)
+ {
+ logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} 生产车间数据推送发生异常:{ex.Serialize()}");
+ return HttpDataResultExtensions.Failed("生产车间数据推送发生异常", -101, ResponeResultEnum.Exception);
+ }
+ }
+
+ ///
+ /// 获取CTWing产品列表
+ ///
+ [AllowAnonymous]
+ public async Task>> GetProductListAsync(OpenApiRequest input)
+ {
+ try
+ {
+ bool verifySignatureReult = EncryptUtil.OpenApiVerifySignature(input.Message, input.Nonce, input.Timestamp, input.Signature, srverOptions.VerifySignatureToken);
+ if (verifySignatureReult == false)//签名校验失败
+ {
+ return HttpDataResultExtensions.Failed>("签名校验失败", -101, ResponeResultEnum.NotAllowed);
+ }
+
+ ProductionEquipmentMessageBody productionEquipmentMessageBody = input.Message.Deserialize();
+
+ var pageListQuery = FreeSqlDbContext.Instance.Select()
+ .Where(e => e.IsEnabled == true)
+ .OrderByDescending(e => e.CreationTime);
+
+ var pageList = await pageListQuery.ToListAsync();
+
+ return HttpDataResultExtensions.Success(pageList);
+ }
+ catch (Exception)
+ {
+
+ throw;
+ }
+ }
+ }
+}
diff --git a/src/JiShe.IoT.Application/OneNETAggregation/OneNETAggregationService.cs b/src/JiShe.IoT.Application/OneNETAggregation/OneNETAggregationService.cs
index eff12cb..5caad8f 100644
--- a/src/JiShe.IoT.Application/OneNETAggregation/OneNETAggregationService.cs
+++ b/src/JiShe.IoT.Application/OneNETAggregation/OneNETAggregationService.cs
@@ -1,4 +1,5 @@
using JiShe.IoT.OneNETAggregation.Dto;
+using JiShe.IoT.Workshops;
using JiShe.ServicePro;
using JiShe.ServicePro.Core;
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
diff --git a/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250729024912_InitialCreate.Designer.cs b/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250730030313_InitialCreate.Designer.cs
similarity index 98%
rename from src/JiShe.IoT.EntityFrameworkCore/Migrations/20250729024912_InitialCreate.Designer.cs
rename to src/JiShe.IoT.EntityFrameworkCore/Migrations/20250730030313_InitialCreate.Designer.cs
index 8014fd2..6c2e49f 100644
--- a/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250729024912_InitialCreate.Designer.cs
+++ b/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250730030313_InitialCreate.Designer.cs
@@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace JiShe.IoT.Migrations
{
[DbContext(typeof(IoTDbContext))]
- [Migration("20250729024912_InitialCreate")]
+ [Migration("20250730030313_InitialCreate")]
partial class InitialCreate
{
///
@@ -129,6 +129,24 @@ namespace JiShe.IoT.Migrations
.HasColumnType("varchar(128)")
.HasComment("账号名称");
+ b.Property("AppId")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)")
+ .HasComment("应用 ID");
+
+ b.Property("AppKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("varchar(128)")
+ .HasComment("应用 AppKey");
+
+ b.Property("AppSecret")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("varchar(128)")
+ .HasComment("应用 AppSecret");
+
b.Property("CommunicationAddress")
.HasMaxLength(128)
.HasColumnType("varchar(128)")
@@ -276,18 +294,30 @@ namespace JiShe.IoT.Migrations
b.Property("DeviceCount")
.HasColumnType("int");
- b.Property("DeviceThingModelUrl")
+ b.Property("DeviceThingModelFileId")
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)")
+ .HasComment("设备物模型文件Id");
+
+ b.Property("DeviceThingModelFileName")
.HasMaxLength(256)
.HasColumnType("varchar(256)")
- .HasComment("设备物模型文件管理地址");
+ .HasComment("设备物模型文件名称");
b.Property("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties")
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
- b.Property("IoTPlatformProductId")
- .HasColumnType("int");
+ b.Property("FeatureAccesskey")
+ .HasMaxLength(256)
+ .HasColumnType("varchar(256)")
+ .HasComment("设备访问密钥");
+
+ b.Property("IoTPlatformProductId")
+ .HasMaxLength(128)
+ .HasColumnType("varchar(128)")
+ .HasComment("产品ID");
b.Property("IsDeleted")
.ValueGeneratedOnAdd()
@@ -296,7 +326,8 @@ namespace JiShe.IoT.Migrations
.HasColumnName("IsDeleted");
b.Property("IsEnabled")
- .HasColumnType("tinyint(1)");
+ .HasColumnType("tinyint(1)")
+ .HasComment("是否启用");
b.Property("LastModificationTime")
.HasColumnType("datetime(6)")
@@ -307,9 +338,9 @@ namespace JiShe.IoT.Migrations
.HasColumnName("LastModifierId");
b.Property("MasterKey")
- .HasMaxLength(1024)
- .HasColumnType("varchar(1024)")
- .HasComment("主密钥");
+ .HasMaxLength(256)
+ .HasColumnType("varchar(256)")
+ .HasComment("OpenAPI 通信主密钥");
b.Property("NetworkType")
.HasColumnType("int");
@@ -594,6 +625,9 @@ namespace JiShe.IoT.Migrations
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
+ b.Property("IsPlatformPushSuccess")
+ .HasColumnType("tinyint(1)");
+
b.Property("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
@@ -1281,7 +1315,8 @@ namespace JiShe.IoT.Migrations
.HasComment("手机号码");
b.Property("ProductCount")
- .HasColumnType("int");
+ .HasColumnType("int")
+ .HasComment("产品数量");
b.Property("Remark")
.HasColumnType("longtext")
diff --git a/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250729024912_InitialCreate.cs b/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250730030313_InitialCreate.cs
similarity index 98%
rename from src/JiShe.IoT.EntityFrameworkCore/Migrations/20250729024912_InitialCreate.cs
rename to src/JiShe.IoT.EntityFrameworkCore/Migrations/20250730030313_InitialCreate.cs
index 062d8ea..1e95702 100644
--- a/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250729024912_InitialCreate.cs
+++ b/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250730030313_InitialCreate.cs
@@ -751,6 +751,12 @@ namespace JiShe.IoT.Migrations
.Annotation("MySql:CharSet", "utf8mb4"),
AccountId = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "账号ID")
.Annotation("MySql:CharSet", "utf8mb4"),
+ AppId = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "应用 ID")
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ AppKey = table.Column(type: "varchar(128)", maxLength: 128, nullable: false, comment: "应用 AppKey")
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ AppSecret = table.Column(type: "varchar(128)", maxLength: 128, nullable: false, comment: "应用 AppSecret")
+ .Annotation("MySql:CharSet", "utf8mb4"),
PlatformTenantId = table.Column(type: "varchar(128)", maxLength: 128, nullable: true, comment: "平台租户ID")
.Annotation("MySql:CharSet", "utf8mb4"),
CommunicationAddress = table.Column(type: "varchar(128)", maxLength: 128, nullable: true, comment: "通讯服务地址")
@@ -792,9 +798,12 @@ namespace JiShe.IoT.Migrations
.Annotation("MySql:CharSet", "utf8mb4"),
CommunicationAddress = table.Column(type: "varchar(128)", maxLength: 128, nullable: false, comment: "通讯服务地址")
.Annotation("MySql:CharSet", "utf8mb4"),
- MasterKey = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true, comment: "主密钥")
+ MasterKey = table.Column(type: "varchar(256)", maxLength: 256, nullable: true, comment: "OpenAPI 通信主密钥")
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ FeatureAccesskey = table.Column(type: "varchar(256)", maxLength: 256, nullable: true, comment: "设备访问密钥")
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ IoTPlatformProductId = table.Column(type: "varchar(128)", maxLength: 128, nullable: true, comment: "产品ID")
.Annotation("MySql:CharSet", "utf8mb4"),
- IoTPlatformProductId = table.Column(type: "int", nullable: false),
ProductName = table.Column(type: "varchar(128)", maxLength: 128, nullable: true, comment: "产品名称")
.Annotation("MySql:CharSet", "utf8mb4"),
Protocol = table.Column(type: "varchar(20)", maxLength: 20, nullable: true, comment: "通讯协议")
@@ -817,9 +826,11 @@ namespace JiShe.IoT.Migrations
TupDeviceModel = table.Column(type: "varchar(128)", maxLength: 128, nullable: true, comment: "设备型号")
.Annotation("MySql:CharSet", "utf8mb4"),
DeviceCount = table.Column(type: "int", nullable: false),
- DeviceThingModelUrl = table.Column(type: "varchar(256)", maxLength: 256, nullable: true, comment: "设备物模型文件管理地址")
+ DeviceThingModelFileId = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "设备物模型文件Id")
.Annotation("MySql:CharSet", "utf8mb4"),
- IsEnabled = table.Column(type: "tinyint(1)", nullable: false),
+ DeviceThingModelFileName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true, comment: "设备物模型文件名称")
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ IsEnabled = table.Column(type: "tinyint(1)", nullable: false, comment: "是否启用"),
ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreationTime = table.Column(type: "datetime(6)", nullable: false),
@@ -865,6 +876,7 @@ namespace JiShe.IoT.Migrations
.Annotation("MySql:CharSet", "utf8mb4"),
IoTPlatformResponse = table.Column(type: "varchar(512)", maxLength: 512, nullable: false, comment: "物联网平台返回的响应信息")
.Annotation("MySql:CharSet", "utf8mb4"),
+ IsPlatformPushSuccess = table.Column(type: "tinyint(1)", nullable: false),
ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreationTime = table.Column(type: "datetime(6)", nullable: false),
@@ -951,7 +963,7 @@ namespace JiShe.IoT.Migrations
.Annotation("MySql:CharSet", "utf8mb4"),
AccountAccesskey = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: false, comment: "账户通信密钥,平台可以重置密钥")
.Annotation("MySql:CharSet", "utf8mb4"),
- ProductCount = table.Column(type: "int", nullable: false),
+ ProductCount = table.Column(type: "int", nullable: false, comment: "产品数量"),
ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreationTime = table.Column(type: "datetime(6)", nullable: false),
diff --git a/src/JiShe.IoT.EntityFrameworkCore/Migrations/IoTDbContextModelSnapshot.cs b/src/JiShe.IoT.EntityFrameworkCore/Migrations/IoTDbContextModelSnapshot.cs
index bfb4682..9e14868 100644
--- a/src/JiShe.IoT.EntityFrameworkCore/Migrations/IoTDbContextModelSnapshot.cs
+++ b/src/JiShe.IoT.EntityFrameworkCore/Migrations/IoTDbContextModelSnapshot.cs
@@ -126,6 +126,24 @@ namespace JiShe.IoT.Migrations
.HasColumnType("varchar(128)")
.HasComment("账号名称");
+ b.Property("AppId")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)")
+ .HasComment("应用 ID");
+
+ b.Property("AppKey")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("varchar(128)")
+ .HasComment("应用 AppKey");
+
+ b.Property("AppSecret")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("varchar(128)")
+ .HasComment("应用 AppSecret");
+
b.Property("CommunicationAddress")
.HasMaxLength(128)
.HasColumnType("varchar(128)")
@@ -273,18 +291,30 @@ namespace JiShe.IoT.Migrations
b.Property("DeviceCount")
.HasColumnType("int");
- b.Property("DeviceThingModelUrl")
+ b.Property("DeviceThingModelFileId")
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)")
+ .HasComment("设备物模型文件Id");
+
+ b.Property("DeviceThingModelFileName")
.HasMaxLength(256)
.HasColumnType("varchar(256)")
- .HasComment("设备物模型文件管理地址");
+ .HasComment("设备物模型文件名称");
b.Property("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties")
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
- b.Property("IoTPlatformProductId")
- .HasColumnType("int");
+ b.Property("FeatureAccesskey")
+ .HasMaxLength(256)
+ .HasColumnType("varchar(256)")
+ .HasComment("设备访问密钥");
+
+ b.Property("IoTPlatformProductId")
+ .HasMaxLength(128)
+ .HasColumnType("varchar(128)")
+ .HasComment("产品ID");
b.Property("IsDeleted")
.ValueGeneratedOnAdd()
@@ -293,7 +323,8 @@ namespace JiShe.IoT.Migrations
.HasColumnName("IsDeleted");
b.Property("IsEnabled")
- .HasColumnType("tinyint(1)");
+ .HasColumnType("tinyint(1)")
+ .HasComment("是否启用");
b.Property("LastModificationTime")
.HasColumnType("datetime(6)")
@@ -304,9 +335,9 @@ namespace JiShe.IoT.Migrations
.HasColumnName("LastModifierId");
b.Property("MasterKey")
- .HasMaxLength(1024)
- .HasColumnType("varchar(1024)")
- .HasComment("主密钥");
+ .HasMaxLength(256)
+ .HasColumnType("varchar(256)")
+ .HasComment("OpenAPI 通信主密钥");
b.Property("NetworkType")
.HasColumnType("int");
@@ -591,6 +622,9 @@ namespace JiShe.IoT.Migrations
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
+ b.Property("IsPlatformPushSuccess")
+ .HasColumnType("tinyint(1)");
+
b.Property("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
@@ -1278,7 +1312,8 @@ namespace JiShe.IoT.Migrations
.HasComment("手机号码");
b.Property("ProductCount")
- .HasColumnType("int");
+ .HasColumnType("int")
+ .HasComment("产品数量");
b.Property("Remark")
.HasColumnType("longtext")
diff --git a/src/JiShe.IoT.HttpApi/Controllers/CTWingAggregationController.cs b/src/JiShe.IoT.HttpApi/Controllers/CTWingAggregationController.cs
new file mode 100644
index 0000000..4b8e399
--- /dev/null
+++ b/src/JiShe.IoT.HttpApi/Controllers/CTWingAggregationController.cs
@@ -0,0 +1,41 @@
+using JiShe.IoT.CTWingAggregation;
+using JiShe.IoT.CTWingAggregation.Dto;
+using JiShe.ServicePro;
+
+namespace JiShe.IoT.Controllers
+{
+ ///
+ /// CTWing聚合服务
+ ///
+ [Route("/Aggregation/CTWing")]
+ public class CTWingAggregationController : IoTController
+ {
+ private readonly ICTWingAggregationService _CTWingAggregationServiceService;
+ public CTWingAggregationController(ICTWingAggregationService CTWingAggregationServiceService)
+ {
+ _CTWingAggregationServiceService = CTWingAggregationServiceService;
+ }
+
+ ///
+ /// 接收车间生产信息
+ ///
+ ///
+ ///
+ [HttpPost(nameof(ReceiveWorkshopProductionInfoAsync))]
+ [SwaggerOperation(summary: "接收车间生产信息", Tags = new[] { "AggregationCTWing" })]
+ public async Task ReceiveWorkshopProductionInfoAsync(OpenApiRequest input)
+ {
+ await _CTWingAggregationServiceService.ReceiveWorkshopProductionInfoAsync(input);
+ }
+
+ ///
+ /// 获取CTWing产品列表
+ ///
+ [HttpPost(nameof(GetProductListAsync))]
+ [SwaggerOperation(summary: "获取CTWing产品列表", Tags = new[] { "AggregationCTWing" })]
+ public async Task>> GetProductListAsync(OpenApiRequest input)
+ {
+ return await _CTWingAggregationServiceService.GetProductListAsync(input);
+ }
+ }
+}