diff --git a/JiShe.ServicePro b/JiShe.ServicePro
index 5eee6ae..87668cc 160000
--- a/JiShe.ServicePro
+++ b/JiShe.ServicePro
@@ -1 +1 @@
-Subproject commit 5eee6ae6ecdae8325f89c8a1bff2007062388dd8
+Subproject commit 87668ccc6f5fea1111470327fa7da683b9756430
diff --git a/src/JiShe.IoT.Application.Contracts/CTWingAggregation/Dto/CTWingWorkshopProductListOutput.cs b/src/JiShe.IoT.Application.Contracts/CTWingAggregation/Dto/CTWingWorkshopProductListOutput.cs
deleted file mode 100644
index 1a4fd72..0000000
--- a/src/JiShe.IoT.Application.Contracts/CTWingAggregation/Dto/CTWingWorkshopProductListOutput.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-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
- {
- ///
- /// 产品数据Id
- ///
- [SwaggerSchema("产品数据Id")]
- public Guid ProductDataId { get; set; }
-
- ///
- /// 产品名称
- ///
- [SwaggerSchema("产品名称")]
- public string ProductName { get; set; }
-
- ///
- /// 设备访问密钥
- ///
- [SwaggerSchema("设备访问密钥")]
- public string ProductAccesskey { 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
deleted file mode 100644
index bfd899f..0000000
--- a/src/JiShe.IoT.Application.Contracts/CTWingAggregation/ICTWingAggregationService.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-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/Workshops/ProductionEquipmentMessageBody.cs b/src/JiShe.IoT.Application.Contracts/Workshops/Dto/ProductionEquipmentMessageBody.cs
similarity index 82%
rename from src/JiShe.IoT.Application.Contracts/Workshops/ProductionEquipmentMessageBody.cs
rename to src/JiShe.IoT.Application.Contracts/Workshops/Dto/ProductionEquipmentMessageBody.cs
index 1083b34..8109a3b 100644
--- a/src/JiShe.IoT.Application.Contracts/Workshops/ProductionEquipmentMessageBody.cs
+++ b/src/JiShe.IoT.Application.Contracts/Workshops/Dto/ProductionEquipmentMessageBody.cs
@@ -23,5 +23,10 @@ namespace JiShe.IoT.Workshops
/// 物联网平台对应的产品Id
///
public string IoTPlatformProductId { get; set; }
+
+ ///
+ /// 平台类型
+ ///
+ public IoTPlatformTypeEnum IoTPlatform { get; set; }
}
}
diff --git a/src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListInput.cs b/src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListInput.cs
new file mode 100644
index 0000000..aa4fc90
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListInput.cs
@@ -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.Workshops
+{
+ ///
+ /// 车间产品列表请求参数
+ ///
+ public class WorkshopProductListInput
+ {
+ ///
+ /// 平台类型
+ ///
+ public IoTPlatformTypeEnum IoTPlatform { get; set; }
+ }
+}
diff --git a/src/JiShe.IoT.Application.Contracts/OneNETAggregation/Dto/OneNetWorkshopProductListOutput.cs b/src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListOutput.cs
similarity index 89%
rename from src/JiShe.IoT.Application.Contracts/OneNETAggregation/Dto/OneNetWorkshopProductListOutput.cs
rename to src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListOutput.cs
index f108d5e..9c5c38e 100644
--- a/src/JiShe.IoT.Application.Contracts/OneNETAggregation/Dto/OneNetWorkshopProductListOutput.cs
+++ b/src/JiShe.IoT.Application.Contracts/Workshops/Dto/WorkshopProductListOutput.cs
@@ -6,12 +6,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace JiShe.IoT.OneNETAggregation.Dto
+namespace JiShe.IoT.Workshops
{
///
- /// 生产车间获取OneNET产品列表
+ /// 生产车间获取产品列表
///
- public class OneNetWorkshopProductListOutput
+ public class WorkshopProductListOutput
{
///
/// 产品数据Id
diff --git a/src/JiShe.IoT.Application.Contracts/OneNETAggregation/IOneNETAggregationService.cs b/src/JiShe.IoT.Application.Contracts/Workshops/IWorkshopAggregationService.cs
similarity index 63%
rename from src/JiShe.IoT.Application.Contracts/OneNETAggregation/IOneNETAggregationService.cs
rename to src/JiShe.IoT.Application.Contracts/Workshops/IWorkshopAggregationService.cs
index 09498fe..c88a5d7 100644
--- a/src/JiShe.IoT.Application.Contracts/OneNETAggregation/IOneNETAggregationService.cs
+++ b/src/JiShe.IoT.Application.Contracts/Workshops/IWorkshopAggregationService.cs
@@ -1,4 +1,4 @@
-using JiShe.IoT.OneNETAggregation.Dto;
+using JiShe.IoT.Workshops;
using JiShe.ServicePro;
using JiShe.ServicePro.OneNETManagement.OneNETProducts;
using System;
@@ -7,12 +7,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace JiShe.IoT.OneNETAggregation
+namespace JiShe.IoT.Workshops
{
///
- /// OneNET聚合服务
+ /// 生产车间聚合服务
///
- public interface IOneNETAggregationService : IApplicationService
+ public interface IWorkshopAggregationService : IApplicationService
{
///
/// 接收车间生产信息
@@ -22,8 +22,8 @@ namespace JiShe.IoT.OneNETAggregation
Task ReceiveWorkshopProductionInfoAsync(OpenApiRequest input);
///
- /// 获取OneNET产品列表
+ /// 获取物联网产品列表
///
- Task GetProductListAsync(OpenApiRequest input);
+ Task>> GetProductListAsync(OpenApiRequest input);
}
}
diff --git a/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs b/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs
index 31da3cd..696bc23 100644
--- a/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs
+++ b/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs
@@ -44,37 +44,7 @@ namespace JiShe.IoT.BusinessSystemAggregation
}
var messageBody = handleResult.Data;
string tempMessageBody = null;
-
- //bool verifySignatureReult = EncryptUtil.OpenApiVerifySignature(input.Message, input.Nonce, input.Timestamp, input.Signature, srverOptions.SignatureToken);
- //if (verifySignatureReult == false)//签名校验失败
- //{
- // return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
- //}
-
- //if (string.IsNullOrWhiteSpace(input.Message))
- //{
- // return HttpDataResultExtensions.Failed("指令下发内容不能为空", -102, ResponeResultEnum.Fail);
- //}
-
- ////判断是否需要解密
- //ReceiveCommandInfoDto messageBody = null;
- //string tempMessageBody = null;
- //if (srverOptions.IsAesEncrypted && !string.IsNullOrWhiteSpace(srverOptions.AesSecurityKey))
- //{
- // tempMessageBody = EncryptUtil.OpenApiDecrypto(input.Message, srverOptions.AesSecurityKey);
- // messageBody = tempMessageBody.Deserialize();
- //}
- //else
- //{
- // tempMessageBody = input.Message;
- // messageBody = input.Message.Deserialize();
- //}
-
- //if (messageBody == null)
- //{
- // return HttpDataResultExtensions.Failed("指令下发内容不能为空", -103, ResponeResultEnum.Fail);
- //}
-
+
//限定来源类型必须为业务系统
if (messageBody.SourceType != DeviceTelemetrySourceTypeEnum.BusinessSystem)
{
diff --git a/src/JiShe.IoT.Application/CTWingAggregation/CTWingAggregationService.cs b/src/JiShe.IoT.Application/CTWingAggregation/CTWingAggregationService.cs
deleted file mode 100644
index 9eed820..0000000
--- a/src/JiShe.IoT.Application/CTWingAggregation/CTWingAggregationService.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using JiShe.IoT.CTWingAggregation.Dto;
-using JiShe.IoT.DeviceAggregation;
-using JiShe.IoT.DeviceAggregation.Dto;
-using JiShe.IoT.Workshops;
-using JiShe.ServicePro;
-using JiShe.ServicePro.Core;
-using JiShe.ServicePro.CTWingManagement.CTWingProduct;
-using JiShe.ServicePro.Encrypt;
-using JiShe.ServicePro.Enums;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
-
-namespace JiShe.IoT.CTWingAggregation
-{
- ///
- /// CTWing聚合服务
- ///
- /// 设备聚合服务
- ///
- ///
- public class CTWingAggregationService(IDeviceAggregationService deviceAggregationService, 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.SignatureToken);
- if (verifySignatureReult == false)//签名校验失败
- {
- return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
- }
-
- ProductionEquipmentMessageBody productionEquipmentMessageBody = input.Message.Deserialize();
-
- if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.IoTPlatformProductId))
- {
- return HttpDataResultExtensions.Failed("CTWing平台产品Id不能为空", -102, ResponeResultEnum.Fail);
- }
-
- if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.DeviceAddress))
- {
- return HttpDataResultExtensions.Failed("设备地址不能为空", -103, ResponeResultEnum.Fail);
- }
-
- CreateDeviceAggregationInput deviceInsertInput = new CreateDeviceAggregationInput()
- {
- DeviceAddress = productionEquipmentMessageBody.DeviceAddress,
- IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId,
- IoTPlatform = IoTPlatformTypeEnum.CTWing,
- };
-
- //创建设备信息
- var insertResult = await deviceAggregationService.CreateDeviceWorkshopAsync(deviceInsertInput);
- if (!insertResult)
- {
- logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} 创建设备信息失败:{insertResult.Serialize()}");
- return HttpDataResultExtensions.Failed("CTWing推送设备失败!", -105);
- }
-
- return HttpDataResultExtensions.Success("CTWing推送设备成功!");
- }
- catch (Exception ex)
- {
- logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} 生产车间数据推送发生异常:{ex.Serialize()}");
- return HttpDataResultExtensions.Failed("生产车间推送CTWing数据发生异常", -107, ResponeResultEnum.Exception);
- }
- }
-
- ///
- /// 获取CTWing产品列表
- ///
- [AllowAnonymous]
- public async Task GetProductListAsync(OpenApiRequest input)
- {
- try
- {
- bool verifySignatureReult = EncryptUtil.OpenApiVerifySignature(input.Message, input.Nonce, input.Timestamp, input.Signature, srverOptions.SignatureToken);
- if (verifySignatureReult == false)//签名校验失败
- {
- return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
- }
-
- var pageListQuery = FreeSqlDbContext.Instance.Select()
- .Where(e => e.IsEnabled == true)
- .OrderByDescending(e => e.CreationTime);
-
- var pageList = await pageListQuery.ToListAsync(d => new CTWingWorkshopProductListOutput
- {
- ProductDataId = d.Id,
- ProductName = d.ProductName,
- CommunicationAddress = d.CommunicationAddress,
- ProductAccesskey = d.FeatureAccesskey,
- });
-
- if (pageList == null || pageList.Count <= 0)
- {
- return HttpDataResultExtensions.Failed("获取CTWing产品失败", -102, ResponeResultEnum.NotAllowed);
- }
-
- var rawMessage = pageList.Serialize();
- var signatureResult = EncryptUtil.OpenApiSignature(rawMessage, DateTimeOffset.UtcNow.AddSeconds(3).ToUnixTimeMilliseconds(), srverOptions.SignatureToken);
-
- return HttpDataResultExtensions.Success(rawMessage, signatureResult.Item1, signatureResult.Item2);
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- }
-}
diff --git a/src/JiShe.IoT.Application/DeviceAggregation/DeviceAggregationService.cs b/src/JiShe.IoT.Application/DeviceAggregation/DeviceAggregationService.cs
index a445794..5104c78 100644
--- a/src/JiShe.IoT.Application/DeviceAggregation/DeviceAggregationService.cs
+++ b/src/JiShe.IoT.Application/DeviceAggregation/DeviceAggregationService.cs
@@ -69,6 +69,7 @@ namespace JiShe.IoT.DeviceAggregation
///
///
///
+ [Authorize(DeviceManagementPermissions.DeviceInfoManagement.Create)]
public async Task BatchCreateDeviceForApiAsync(BatchCreateDeviceAggregationInput input)
{
try
diff --git a/src/JiShe.IoT.Application/IoTAppService.cs b/src/JiShe.IoT.Application/IoTAppService.cs
index 65aa64c..c3ac315 100644
--- a/src/JiShe.IoT.Application/IoTAppService.cs
+++ b/src/JiShe.IoT.Application/IoTAppService.cs
@@ -103,6 +103,12 @@ namespace JiShe.IoT
//жǷҪ
T messageBody = default;
string tempMessageBody = null;
+
+ if (string.IsNullOrWhiteSpace(input.Message))
+ {
+ return HttpDataResultExtensions.Success(messageBody, "ǩУɹû");
+ }
+
if (serverOptions.IsAesEncrypted && !string.IsNullOrWhiteSpace(serverOptions.AesSecurityKey))
{
tempMessageBody = EncryptUtil.OpenApiDecrypto(input.Message, serverOptions.AesSecurityKey);
diff --git a/src/JiShe.IoT.Application/OneNETAggregation/OneNETAggregationService.cs b/src/JiShe.IoT.Application/OneNETAggregation/OneNETAggregationService.cs
deleted file mode 100644
index 4087a00..0000000
--- a/src/JiShe.IoT.Application/OneNETAggregation/OneNETAggregationService.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-using JiShe.IoT.DeviceAggregation;
-using JiShe.IoT.DeviceAggregation.Dto;
-using JiShe.IoT.OneNETAggregation.Dto;
-using JiShe.IoT.Workshops;
-using JiShe.ServicePro;
-using JiShe.ServicePro.Core;
-using JiShe.ServicePro.Encrypt;
-using JiShe.ServicePro.Enums;
-using JiShe.ServicePro.OneNETManagement.OneNETProducts;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
-
-namespace JiShe.IoT.OneNETAggregation
-{
- ///
- /// OneNET聚合服务
- ///
- /// 设备聚合服务
- /// 服务配置
- ///
- public class OneNETAggregationService(IDeviceAggregationService deviceAggregationService, IOptions options, ILogger logger) : IoTAppService, IOneNETAggregationService
- {
- ServerApplicationOptions serverOptions = options.Value;
-
- ///
- /// 接收车间生产信息
- ///
- ///
- ///
- [AllowAnonymous]
- public async Task ReceiveWorkshopProductionInfoAsync(OpenApiRequest input)
- {
-
- try
- {
- bool verifySignatureReult = EncryptUtil.OpenApiVerifySignature(input.Message, input.Nonce, input.Timestamp, input.Signature, serverOptions.SignatureToken);
- if (verifySignatureReult == false)//签名校验失败
- {
- return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
- }
-
-
- ProductionEquipmentMessageBody productionEquipmentMessageBody = null;
- if (serverOptions.IsAesEncrypted && !string.IsNullOrWhiteSpace(serverOptions.AesSecurityKey))
- {
- string tempRaw = EncryptUtil.OpenApiDecrypto(input.Message, serverOptions.AesSecurityKey);
- productionEquipmentMessageBody = tempRaw.Deserialize();
- }
- else
- {
- productionEquipmentMessageBody = input.Message.Deserialize();
- }
-
- if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.IoTPlatformProductId))
- {
- return HttpDataResultExtensions.Failed("物联网平台产品Id不能为空", -102, ResponeResultEnum.Fail);
- }
-
- if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.DeviceAddress))
- {
- return HttpDataResultExtensions.Failed("设备地址不能为空", -103, ResponeResultEnum.Fail);
- }
-
-
- CreateDeviceAggregationInput deviceInsertInput = new CreateDeviceAggregationInput()
- {
- DeviceAddress = productionEquipmentMessageBody.DeviceAddress,
- IoTPlatform = IoTPlatformTypeEnum.OneNET,
- IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId,
- };
-
- //创建设备信息
- var insertResult = await deviceAggregationService.CreateDeviceWorkshopAsync(deviceInsertInput);
- if (!insertResult)
- {
- logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} OneNET创建设备信息失败:{insertResult.Serialize()}");
- return HttpDataResultExtensions.Failed("OneNET推送设备失败!", -105);
- }
-
- return HttpDataResultExtensions.Success("OneNET推送设备成功!");
-
- }
- catch (Exception ex)
- {
- logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} 生产车间数据推送发生异常:{ex.Serialize()}");
- return HttpDataResultExtensions.Failed("生产车间推送OneNET数据发生异常", -107, ResponeResultEnum.Exception);
- }
- }
-
- ///
- /// 获取OneNET产品列表
- ///
- [AllowAnonymous]
- public async Task GetProductListAsync(OpenApiRequest input)
- {
-
- try
- {
- bool verifySignatureReult = EncryptUtil.OpenApiVerifySignature(input.Message, input.Nonce, input.Timestamp, input.Signature, serverOptions.SignatureToken);
- if (verifySignatureReult == false)//签名校验失败
- {
- return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
- }
-
- if (serverOptions.IsAesEncrypted && !string.IsNullOrWhiteSpace(serverOptions.AesSecurityKey))
- {
- string tempRaw = EncryptUtil.OpenApiDecrypto(input.Message, serverOptions.AesSecurityKey);
- }
-
-
- var pageListQuery = FreeSqlDbContext.Instance.Select()
- .Where(e => e.IsEnabled == true)
- .OrderByDescending(e => e.CreationTime);
-
- var pageList = await pageListQuery.ToListAsync(d => new OneNetWorkshopProductListOutput
- {
- ProductDataId = d.Id,
- ProductName = d.ProductName,
- CommunicationAddress = d.CommunicationAddress,
- ProductAccesskey = d.ProductAccesskey,
- CommunicationAddressTLS = d.CommunicationAddressTLS
- });
-
- if (pageList == null || pageList.Count <= 0)
- {
- return HttpDataResultExtensions.Failed("获取OneNET产品失败", -102, ResponeResultEnum.NotAllowed);
- }
-
- var rawMessage = pageList.Serialize();
- long timestamp = serverOptions.GetOpenApiSignatureTimeStamp();
- var signatureResult = EncryptUtil.OpenApiSignature(rawMessage, timestamp, serverOptions.SignatureToken);
-
- return HttpDataResultExtensions.Success(rawMessage, signatureResult.Item1, signatureResult.Item2);
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- }
-}
diff --git a/src/JiShe.IoT.Application/Workshops/WorkshopAggregationService.cs b/src/JiShe.IoT.Application/Workshops/WorkshopAggregationService.cs
new file mode 100644
index 0000000..6632d5a
--- /dev/null
+++ b/src/JiShe.IoT.Application/Workshops/WorkshopAggregationService.cs
@@ -0,0 +1,147 @@
+using JiShe.IoT.DeviceAggregation;
+using JiShe.IoT.DeviceAggregation.Dto;
+using JiShe.IoT.Workshops;
+using JiShe.ServicePro;
+using JiShe.ServicePro.Core;
+using JiShe.ServicePro.CTWingManagement.CTWingProduct;
+using JiShe.ServicePro.Encrypt;
+using JiShe.ServicePro.Enums;
+using JiShe.ServicePro.OneNETManagement.OneNETProducts;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+
+namespace JiShe.IoT.Workshops
+{
+ ///
+ /// 生产车间聚合服务
+ ///
+ /// 设备聚合服务
+ /// 服务配置
+ ///
+ public class WorkshopAggregationService(IDeviceAggregationService deviceAggregationService, IOptions options, ILogger logger) : IoTAppService, IWorkshopAggregationService
+ {
+ ServerApplicationOptions serverOptions = options.Value;
+
+ ///
+ /// 接收车间生产信息
+ ///
+ ///
+ ///
+ [AllowAnonymous]
+ public async Task ReceiveWorkshopProductionInfoAsync(OpenApiRequest input)
+ {
+
+ try
+ {
+ var handleResult = HandleOpenApiRequest(input, serverOptions);
+ if (handleResult.Success == false)
+ {
+ return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
+ }
+
+ var productionEquipmentMessageBody = handleResult.Data;
+
+ if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.IoTPlatformProductId))
+ {
+ return HttpDataResultExtensions.Failed("物联网平台产品Id不能为空", -102, ResponeResultEnum.Fail);
+ }
+
+ if (string.IsNullOrWhiteSpace(productionEquipmentMessageBody.DeviceAddress))
+ {
+ return HttpDataResultExtensions.Failed("设备地址不能为空", -103, ResponeResultEnum.Fail);
+ }
+
+
+ CreateDeviceAggregationInput deviceInsertInput = new CreateDeviceAggregationInput()
+ {
+ DeviceAddress = productionEquipmentMessageBody.DeviceAddress,
+ IoTPlatform = productionEquipmentMessageBody.IoTPlatform,
+ IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId,
+ };
+
+ //创建设备信息
+ var insertResult = await deviceAggregationService.CreateDeviceWorkshopAsync(deviceInsertInput);
+ if (!insertResult)
+ {
+ logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} {productionEquipmentMessageBody.IoTPlatform}创建设备信息失败:{insertResult.Serialize()}");
+ return HttpDataResultExtensions.Failed($"{productionEquipmentMessageBody.IoTPlatform}推送设备失败!", -105);
+ }
+
+ return HttpDataResultExtensions.Success($"{productionEquipmentMessageBody.IoTPlatform}推送设备成功!");
+
+ }
+ catch (Exception ex)
+ {
+ logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} 生产车间数据推送发生异常:{ex.Serialize()}");
+ return HttpDataResultExtensions.Failed($"生产车间推送数据发生异常", -107, ResponeResultEnum.Exception);
+ }
+ }
+
+ ///
+ /// 获取物联网产品列表
+ ///
+ [AllowAnonymous]
+ public async Task>> GetProductListAsync(OpenApiRequest input)
+ {
+ try
+ {
+ var handleResult = HandleOpenApiRequest(input, serverOptions);
+ if (handleResult.Success == false)
+ {
+ return HttpDataResultExtensions.Failed>("签名校验失败", -101, ResponeResultEnum.NotAllowed);
+ }
+
+ var messageBody = handleResult.Data;
+
+ List workshopProductListOutputs = new List();
+
+ if (messageBody.IoTPlatform == IoTPlatformTypeEnum.CTWing)
+ {
+ workshopProductListOutputs = await FreeSqlDbContext.Instance.Select()
+ .Where(e => e.IsEnabled == true)
+ .OrderByDescending(e => e.CreationTime)
+ .ToListAsync(d => new WorkshopProductListOutput
+ {
+ ProductDataId = d.Id,
+ ProductName = d.ProductName,
+ CommunicationAddress = d.CommunicationAddress,
+ ProductAccesskey = d.FeatureAccesskey,
+ });
+ }
+ else if (messageBody.IoTPlatform == IoTPlatformTypeEnum.CTWing)
+ {
+ workshopProductListOutputs = await FreeSqlDbContext.Instance.Select()
+ .Where(e => e.IsEnabled == true)
+ .OrderByDescending(e => e.CreationTime)
+ .ToListAsync(d => new WorkshopProductListOutput
+ {
+ ProductDataId = d.Id,
+ ProductName = d.ProductName,
+ CommunicationAddress = d.CommunicationAddress,
+ ProductAccesskey = d.ProductAccesskey,
+ CommunicationAddressTLS = d.CommunicationAddressTLS
+ });
+ }
+ else
+ {
+ logger.LogError($"{nameof(GetProductListAsync)} 未知物联网平台:{messageBody.IoTPlatform}");
+
+ return HttpDataResultExtensions.Failed>("获取物联网产品失败,未知的平台", -102, ResponeResultEnum.NotAllowed);
+ }
+
+
+ if (workshopProductListOutputs == null || workshopProductListOutputs.Count <= 0)
+ {
+ return HttpDataResultExtensions.Failed>("获取物联网产品失败", -102, ResponeResultEnum.NotAllowed);
+ }
+
+ return HttpDataResultExtensions.Success>(workshopProductListOutputs, "获取物联网产品成功");
+ }
+ catch (Exception)
+ {
+
+ throw;
+ }
+ }
+ }
+}
diff --git a/src/JiShe.IoT.EntityFrameworkCore/EntityFrameworkCore/IoTDbContext.cs b/src/JiShe.IoT.EntityFrameworkCore/EntityFrameworkCore/IoTDbContext.cs
index f1634ee..f979f4e 100644
--- a/src/JiShe.IoT.EntityFrameworkCore/EntityFrameworkCore/IoTDbContext.cs
+++ b/src/JiShe.IoT.EntityFrameworkCore/EntityFrameworkCore/IoTDbContext.cs
@@ -4,6 +4,7 @@ using JiShe.ServicePro.CTWingManagement.CTWingProduct;
using JiShe.ServicePro.CTWingManagement.EntityFrameworkCore;
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
using JiShe.ServicePro.DeviceManagement.EntityFrameworkCore;
+using JiShe.ServicePro.DeviceManagement.ThingModelInfos;
using JiShe.ServicePro.DynamicMenuManagement.EntityFrameworkCore;
using JiShe.ServicePro.DynamicMenuManagement.Menus;
using JiShe.ServicePro.FileManagement.EntityFrameworkCore;
diff --git a/src/JiShe.IoT.HttpApi/Controllers/CTWingAggregationController.cs b/src/JiShe.IoT.HttpApi/Controllers/CTWingAggregationController.cs
deleted file mode 100644
index e550c26..0000000
--- a/src/JiShe.IoT.HttpApi/Controllers/CTWingAggregationController.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-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);
- }
- }
-}
diff --git a/src/JiShe.IoT.HttpApi/Controllers/OneNETAggregationController.cs b/src/JiShe.IoT.HttpApi/Controllers/OneNETAggregationController.cs
deleted file mode 100644
index 73d3042..0000000
--- a/src/JiShe.IoT.HttpApi/Controllers/OneNETAggregationController.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using JiShe.IoT.CommonServices;
-using JiShe.IoT.CommonServices.Dto;
-using JiShe.IoT.OneNETAggregation;
-using JiShe.IoT.OneNETAggregation.Dto;
-using JiShe.ServicePro;
-using JiShe.ServicePro.Commons;
-using JiShe.ServicePro.OneNETManagement.OneNETProducts;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace JiShe.IoT.Controllers
-{
- ///
- /// OneNET聚合服务
- ///
- [Route("/Aggregation/OneNET")]
- public class OneNETAggregationController : IoTController
- {
- private readonly IOneNETAggregationService _oneNETAggregationServiceService;
- public OneNETAggregationController(IOneNETAggregationService oneNETAggregationServiceService)
- {
- _oneNETAggregationServiceService = oneNETAggregationServiceService;
- }
-
- ///
- /// 接收车间生产信息
- ///
- ///
- ///
- [HttpPost(nameof(ReceiveWorkshopProductionInfoAsync))]
- [SwaggerOperation(summary: "接收车间生产信息", Tags = new[] { "AggregationOneNET" })]
- public async Task ReceiveWorkshopProductionInfoAsync(OpenApiRequest input)
- {
- return await _oneNETAggregationServiceService.ReceiveWorkshopProductionInfoAsync(input);
- }
-
- ///
- /// 获取OneNET产品列表
- ///
- [HttpPost(nameof(GetProductListAsync))]
- [SwaggerOperation(summary: "获取OneNET产品列表", Tags = new[] { "AggregationOneNET" })]
- public async Task GetProductListAsync(OpenApiRequest input)
- {
- return await _oneNETAggregationServiceService.GetProductListAsync(input);
- }
- }
-}
diff --git a/src/JiShe.IoT.HttpApi/Controllers/WorkshopAggregationController.cs b/src/JiShe.IoT.HttpApi/Controllers/WorkshopAggregationController.cs
new file mode 100644
index 0000000..fdb0a50
--- /dev/null
+++ b/src/JiShe.IoT.HttpApi/Controllers/WorkshopAggregationController.cs
@@ -0,0 +1,40 @@
+using JiShe.IoT.Workshops;
+using JiShe.ServicePro;
+
+namespace JiShe.IoT.Controllers
+{
+ ///
+ /// 生产车间聚合服务
+ ///
+ [Route("/Aggregation/Workshop")]
+ public class WorkshopAggregationController : IoTController
+ {
+ private readonly IWorkshopAggregationService _workshopAggregationService;
+ public WorkshopAggregationController(IWorkshopAggregationService workshopAggregationService)
+ {
+ _workshopAggregationService = workshopAggregationService;
+ }
+
+ ///
+ /// 接收车间生产信息
+ ///
+ ///
+ ///
+ [HttpPost(nameof(ReceiveWorkshopProductionInfoAsync))]
+ [SwaggerOperation(summary: "接收车间生产信息", Tags = new[] { "Workshop" })]
+ public async Task ReceiveWorkshopProductionInfoAsync(OpenApiRequest input)
+ {
+ return await _workshopAggregationService.ReceiveWorkshopProductionInfoAsync(input);
+ }
+
+ ///
+ /// 获取物联网产品列表
+ ///
+ [HttpPost(nameof(GetProductListAsync))]
+ [SwaggerOperation(summary: "获取物联网产品列表", Tags = new[] { "Workshop" })]
+ public async Task GetProductListAsync(OpenApiRequest input)
+ {
+ return await _workshopAggregationService.GetProductListAsync(input);
+ }
+ }
+}