From 7e07cd511760b57d7bf71871dba759e6f3deb23e Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Tue, 22 Jul 2025 14:54:03 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E9=97=B4=E6=9C=8D=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
JiShe.ServicePro | 2 +-
.../appsettings.Development.json | 3 +-
.../appsettings.Production.json | 3 +-
.../Dto/ProductionEquipmentInput.cs | 36 --------
.../CommonServices/ICommonService.cs | 9 +-
.../Dto/OneNetWorkshopProductListInput.cs | 16 ++++
.../Dto/OneNetWorkshopProductListOutput.cs | 52 ++++++++++++
.../Workshop/Dto/ProductionEquipmentInput.cs | 18 ++++
.../Dto/ProductionEquipmentMessageBody.cs | 33 ++++++++
.../Workshop/IProductionWorkshopService.cs | 31 +++++++
.../CommonServices/CommonService.cs | 15 +---
.../Workshop/ProductionWorkshopService.cs | 82 +++++++++++++++++++
.../Controllers/CommonController.cs | 17 +---
.../ProductionWorkshopController.cs | 50 +++++++++++
14 files changed, 293 insertions(+), 74 deletions(-)
delete mode 100644 src/JiShe.IoT.Application.Contracts/CommonServices/Dto/ProductionEquipmentInput.cs
create mode 100644 src/JiShe.IoT.Application.Contracts/Workshop/Dto/OneNetWorkshopProductListInput.cs
create mode 100644 src/JiShe.IoT.Application.Contracts/Workshop/Dto/OneNetWorkshopProductListOutput.cs
create mode 100644 src/JiShe.IoT.Application.Contracts/Workshop/Dto/ProductionEquipmentInput.cs
create mode 100644 src/JiShe.IoT.Application.Contracts/Workshop/Dto/ProductionEquipmentMessageBody.cs
create mode 100644 src/JiShe.IoT.Application.Contracts/Workshop/IProductionWorkshopService.cs
create mode 100644 src/JiShe.IoT.Application/Workshop/ProductionWorkshopService.cs
create mode 100644 src/JiShe.IoT.HttpApi/Controllers/ProductionWorkshopController.cs
diff --git a/JiShe.ServicePro b/JiShe.ServicePro
index 389b858..59bd271 160000
--- a/JiShe.ServicePro
+++ b/JiShe.ServicePro
@@ -1 +1 @@
-Subproject commit 389b858c61d7202d3d3988a23a93a5a47df5273b
+Subproject commit 59bd271ad62f7fd3ff0d95a761f40209bcc6d438
diff --git a/host/JiShe.IoT.HttpApi.Host/appsettings.Development.json b/host/JiShe.IoT.HttpApi.Host/appsettings.Development.json
index 3b2a161..84989bd 100644
--- a/host/JiShe.IoT.HttpApi.Host/appsettings.Development.json
+++ b/host/JiShe.IoT.HttpApi.Host/appsettings.Development.json
@@ -50,7 +50,8 @@
"AutomaticTelematicsModuleTime": "17:30:00",
"AutomaticDayFreezeTime": "02:30:00",
"AutomaticMonthFreezeTime": "03:30:00",
- "DefaultProtocolPlugin": "T37612012ProtocolPlugin"
+ "DefaultProtocolPlugin": "T37612012ProtocolPlugin",
+ "VerifySignatureToken": "SIcPQnpMgaFDmNlIjNmzq5smshz7cKrh"
},
"Jwt": {
"Audience": "JiShe.IoT",
diff --git a/host/JiShe.IoT.HttpApi.Host/appsettings.Production.json b/host/JiShe.IoT.HttpApi.Host/appsettings.Production.json
index 726d7fc..250e986 100644
--- a/host/JiShe.IoT.HttpApi.Host/appsettings.Production.json
+++ b/host/JiShe.IoT.HttpApi.Host/appsettings.Production.json
@@ -69,7 +69,8 @@
"AutomaticTelematicsModuleTime": "17:30:00",
"AutomaticDayFreezeTime": "02:30:00",
"AutomaticMonthFreezeTime": "03:30:00",
- "DefaultProtocolPlugin": "T37612012ProtocolPlugin"
+ "DefaultProtocolPlugin": "T37612012ProtocolPlugin",
+ "VerifySignatureToken": "SIcPQnpMgaFDmNlIjNmzq5smshz7cKrh"
},
"OneNETSecureReceiveOptions": {
"OneNETVerifySignatureToken": "SIcPQnpMgaFDmNlIjNmzq5smshz7cKrh",
diff --git a/src/JiShe.IoT.Application.Contracts/CommonServices/Dto/ProductionEquipmentInput.cs b/src/JiShe.IoT.Application.Contracts/CommonServices/Dto/ProductionEquipmentInput.cs
deleted file mode 100644
index 6887d15..0000000
--- a/src/JiShe.IoT.Application.Contracts/CommonServices/Dto/ProductionEquipmentInput.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-
-namespace JiShe.IoT.CommonServices.Dto
-{
- ///
- /// 生产设备
- ///
- public class ProductionEquipmentInput
- {
- ///
- /// 用于计算签名字符的随机串
- ///
- public string Nonce { get; set; }
-
- ///
- /// 加密签名,用以校验推送客户端身份合法性,校验方法见实例验证
- ///
- public string Signature { get; set; }
-
- ///
- /// 签名有效期(毫秒)
- ///
- public long Timestamp { get; set; }
-
- ///
- /// 消息内容,JSON字符串,具体的设备相关信息
- ///
- [JsonPropertyName("msg")]
- public string Message { get; set; }
- }
-}
diff --git a/src/JiShe.IoT.Application.Contracts/CommonServices/ICommonService.cs b/src/JiShe.IoT.Application.Contracts/CommonServices/ICommonService.cs
index b8e4c38..7cd96fe 100644
--- a/src/JiShe.IoT.Application.Contracts/CommonServices/ICommonService.cs
+++ b/src/JiShe.IoT.Application.Contracts/CommonServices/ICommonService.cs
@@ -25,13 +25,6 @@ namespace JiShe.IoT.CommonServices
///
///
///
- List GetSelectResultList(SelectResultListInput input);
-
- ///
- /// 接收车间生产设备信息
- ///
- ///
- ///
- Task ReceiveWorkshopProductionEquipment(ProductionEquipmentInput input);
+ List GetSelectResultList(SelectResultListInput input);
}
}
diff --git a/src/JiShe.IoT.Application.Contracts/Workshop/Dto/OneNetWorkshopProductListInput.cs b/src/JiShe.IoT.Application.Contracts/Workshop/Dto/OneNetWorkshopProductListInput.cs
new file mode 100644
index 0000000..d98a11c
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/Workshop/Dto/OneNetWorkshopProductListInput.cs
@@ -0,0 +1,16 @@
+using JiShe.ServicePro;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.IoT.Workshop.Dto
+{
+ ///
+ /// 生产车间获取OneNET产品列表
+ ///
+ public class OneNetWorkshopProductListInput : OpenApiRequest
+ {
+ }
+}
diff --git a/src/JiShe.IoT.Application.Contracts/Workshop/Dto/OneNetWorkshopProductListOutput.cs b/src/JiShe.IoT.Application.Contracts/Workshop/Dto/OneNetWorkshopProductListOutput.cs
new file mode 100644
index 0000000..7c9f758
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/Workshop/Dto/OneNetWorkshopProductListOutput.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.Workshop.Dto
+{
+ ///
+ /// 生产车间获取OneNET产品列表
+ ///
+ public class OneNetWorkshopProductListOutput: OpenApiRequest
+ {
+ ///
+ /// OneNET账户Id
+ ///
+ [SwaggerSchema("OneNET账户Id")]
+ public string OneNETAccountId { get; set; }
+
+ ///
+ /// 物联网平台对应的产品Id
+ ///
+ [SwaggerSchema("物联网平台对应的产品Id")]
+ public string IoTPlatformProductId { 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/Workshop/Dto/ProductionEquipmentInput.cs b/src/JiShe.IoT.Application.Contracts/Workshop/Dto/ProductionEquipmentInput.cs
new file mode 100644
index 0000000..4faf3f1
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/Workshop/Dto/ProductionEquipmentInput.cs
@@ -0,0 +1,18 @@
+using JiShe.ServicePro;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json.Serialization;
+using System.Threading.Tasks;
+
+namespace JiShe.IoT.Workshop.Dto
+{
+ ///
+ /// 生产设备
+ ///
+ public class ProductionEquipmentInput: OpenApiRequest
+ {
+
+ }
+}
diff --git a/src/JiShe.IoT.Application.Contracts/Workshop/Dto/ProductionEquipmentMessageBody.cs b/src/JiShe.IoT.Application.Contracts/Workshop/Dto/ProductionEquipmentMessageBody.cs
new file mode 100644
index 0000000..cecacca
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/Workshop/Dto/ProductionEquipmentMessageBody.cs
@@ -0,0 +1,33 @@
+using JiShe.ServicePro;
+using JiShe.ServicePro.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json.Serialization;
+using System.Threading.Tasks;
+
+namespace JiShe.IoT.Workshop.Dto
+{
+ ///
+ /// 生产设备详情
+ ///
+ public class ProductionEquipmentMessageBody
+ {
+ ///
+ /// 表计类型
+ /// 电表= 1,水表= 2,燃气表= 3,热能表= 4,水表流量计=5,燃气表流量计=6,特殊电表=7
+ ///
+ public MeterTypeEnum MeterType { get; set; }
+
+ ///
+ /// 集中器地址
+ ///
+ public string FocusAddress { get; set; }
+
+ ///
+ /// 表通信地址
+ ///
+ public string MeterAddress { get; set; }
+ }
+}
diff --git a/src/JiShe.IoT.Application.Contracts/Workshop/IProductionWorkshopService.cs b/src/JiShe.IoT.Application.Contracts/Workshop/IProductionWorkshopService.cs
new file mode 100644
index 0000000..7ef9a77
--- /dev/null
+++ b/src/JiShe.IoT.Application.Contracts/Workshop/IProductionWorkshopService.cs
@@ -0,0 +1,31 @@
+using JiShe.IoT.Workshop.Dto;
+using JiShe.ServicePro;
+using JiShe.ServicePro.OneNETManagement.OneNETProducts;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.IoT.Workshop
+{
+ ///
+ /// 生产车间服务
+ ///
+ public interface IProductionWorkshopService
+ {
+ ///
+ /// 接收车间生产设备信息
+ ///
+ ///
+ ///
+ Task ReceiveWorkshopProductionEquipment(ProductionEquipmentInput input);
+
+
+
+ ///
+ /// 生产车间获取OneNET产品列表
+ ///
+ Task>> OneNetProductListForWorkshopAsync(OneNetWorkshopProductListInput input);
+ }
+}
diff --git a/src/JiShe.IoT.Application/CommonServices/CommonService.cs b/src/JiShe.IoT.Application/CommonServices/CommonService.cs
index 2f5a79b..5e0bdbc 100644
--- a/src/JiShe.IoT.Application/CommonServices/CommonService.cs
+++ b/src/JiShe.IoT.Application/CommonServices/CommonService.cs
@@ -1,6 +1,7 @@
using JiShe.IoT.CommonServices.Dto;
using JiShe.ServicePro.Commons;
using JiShe.ServicePro.Core;
+using JiShe.ServicePro.DeviceManagement.Focuses;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
@@ -40,18 +41,6 @@ namespace JiShe.IoT.CommonServices
List selectResults = _selectListType.TryGetValue(input.TypeName, out var list) ? list : new List();
return selectResults;
- }
-
-
- ///
- /// 接收车间生产设备信息
- ///
- ///
- ///
- [AllowAnonymous]
- public async Task ReceiveWorkshopProductionEquipment(ProductionEquipmentInput input)
- {
- await Task.CompletedTask;
- }
+ }
}
}
diff --git a/src/JiShe.IoT.Application/Workshop/ProductionWorkshopService.cs b/src/JiShe.IoT.Application/Workshop/ProductionWorkshopService.cs
new file mode 100644
index 0000000..42955db
--- /dev/null
+++ b/src/JiShe.IoT.Application/Workshop/ProductionWorkshopService.cs
@@ -0,0 +1,82 @@
+using JiShe.IoT.Workshop.Dto;
+using JiShe.ServicePro;
+using JiShe.ServicePro.DeviceManagement.Focuses;
+using JiShe.ServicePro.DeviceManagement.Meters;
+using JiShe.ServicePro.Encrypt;
+using JiShe.ServicePro.Enums;
+using JiShe.ServicePro.OneNETManagement.OneNETProducts;
+using JiShe.ServicePro.ServerOptions;
+using Mapster.Utils;
+using Microsoft.Extensions.Options;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace JiShe.IoT.Workshop
+{
+ ///
+ /// 生产车间服务
+ ///
+ public class ProductionWorkshopService(IFocusAppService focusAppService, IMeterAppService meterAppService, IOptions options ) : IoTAppService,IProductionWorkshopService
+ {
+ ServerApplicationOptions srverOptions = options.Value;
+
+ ///
+ /// 接收车间生产设备信息
+ ///
+ ///
+ ///
+ [AllowAnonymous]
+ public async Task ReceiveWorkshopProductionEquipment(ProductionEquipmentInput 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);
+ }
+ return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
+ }
+ catch (Exception)
+ {
+
+ throw;
+ }
+ }
+
+ ///
+ /// 生产车间获取OneNET产品列表
+ ///
+ [AllowAnonymous]
+ public async Task>> OneNetProductListForWorkshopAsync(OneNetWorkshopProductListInput 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);
+ }
+
+ 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.HttpApi/Controllers/CommonController.cs b/src/JiShe.IoT.HttpApi/Controllers/CommonController.cs
index b7beb37..c3ec9b6 100644
--- a/src/JiShe.IoT.HttpApi/Controllers/CommonController.cs
+++ b/src/JiShe.IoT.HttpApi/Controllers/CommonController.cs
@@ -1,6 +1,8 @@
using JiShe.IoT.CommonServices;
using JiShe.IoT.CommonServices.Dto;
+using JiShe.ServicePro;
using JiShe.ServicePro.Commons;
+using JiShe.ServicePro.OneNETManagement.OneNETProducts;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -28,19 +30,6 @@ namespace JiShe.IoT.Controllers
public List GetSelectResultList(SelectResultListInput input)
{
return _commonService.GetSelectResultList(input);
- }
-
- ///
- /// 接收车间生产设备信息
- ///
- ///
- ///
- [HttpGet("WorkshopProductionEquipment")]
- [SwaggerOperation(summary: "车间生产设备信息", Tags = new[] { "Common" })]
- public async Task ReceiveWorkshopProductionEquipment(ProductionEquipmentInput input)
- {
-
- await Task.CompletedTask;
- }
+ }
}
}
diff --git a/src/JiShe.IoT.HttpApi/Controllers/ProductionWorkshopController.cs b/src/JiShe.IoT.HttpApi/Controllers/ProductionWorkshopController.cs
new file mode 100644
index 0000000..f0ce035
--- /dev/null
+++ b/src/JiShe.IoT.HttpApi/Controllers/ProductionWorkshopController.cs
@@ -0,0 +1,50 @@
+using JiShe.IoT.CommonServices;
+using JiShe.IoT.CommonServices.Dto;
+using JiShe.IoT.Workshop;
+using JiShe.IoT.Workshop.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
+{
+ ///
+ /// 车间管理服务
+ ///
+ [Route("Workshop")]
+ public class ProductionWorkshopController : IoTController
+ {
+ private readonly IProductionWorkshopService _productionWorkshopService;
+ public ProductionWorkshopController(IProductionWorkshopService productionWorkshopService)
+ {
+ _productionWorkshopService = productionWorkshopService;
+ }
+
+ ///
+ /// 接收车间生产设备信息
+ ///
+ ///
+ ///
+ [HttpGet("WorkshopProductionEquipment")]
+ [SwaggerOperation(summary: "车间生产设备信息", Tags = new[] { "Workshop" })]
+ public async Task ReceiveWorkshopProductionEquipment(ProductionEquipmentInput input)
+ {
+ await _productionWorkshopService.ReceiveWorkshopProductionEquipment(input);
+ }
+
+ ///
+ /// 生产车间获取OneNET产品列表
+ ///
+ [HttpPost(nameof(OneNetProductListForWorkshopAsync))]
+ [SwaggerOperation(summary: "生产车间获取OneNET产品列表", Tags = new[] { "Workshop" })]
+ public async Task>> OneNetProductListForWorkshopAsync(OneNetWorkshopProductListInput input)
+ {
+ return await _productionWorkshopService.OneNetProductListForWorkshopAsync(input);
+ }
+ }
+}