diff --git a/Directory.Build.targets b/Directory.Build.targets index 9f890cd..d873e17 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -93,7 +93,7 @@ - - - + + + \ No newline at end of file diff --git a/JiShe.ServicePro b/JiShe.ServicePro index bcf2fe5..163b1c3 160000 --- a/JiShe.ServicePro +++ b/JiShe.ServicePro @@ -1 +1 @@ -Subproject commit bcf2fe561c8b143835214e0974f640cc40cbe84f +Subproject commit 163b1c303938c7e2d8f343fc456b7f091014426d diff --git a/src/JiShe.IoT.Application/Workshop/ProductionWorkshopService.cs b/src/JiShe.IoT.Application/Workshop/ProductionWorkshopService.cs index e49e42e..51f876b 100644 --- a/src/JiShe.IoT.Application/Workshop/ProductionWorkshopService.cs +++ b/src/JiShe.IoT.Application/Workshop/ProductionWorkshopService.cs @@ -2,28 +2,23 @@ using JiShe.ServicePro; using JiShe.ServicePro.Core; using JiShe.ServicePro.DeviceManagement.Focuses; +using JiShe.ServicePro.DeviceManagement.Focuses.Dto; using JiShe.ServicePro.DeviceManagement.Meters; +using JiShe.ServicePro.DeviceManagement.Meters.Dto; using JiShe.ServicePro.Encrypt; using JiShe.ServicePro.Enums; -using JiShe.ServicePro.OneNET.Provider.Interface; +using JiShe.ServicePro.OneNETManagement.OneNETDevices; using JiShe.ServicePro.OneNETManagement.OneNETProducts; using JiShe.ServicePro.ServerOptions; -using Mapster.Utils; using Microsoft.Extensions.Logging; 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, IOneNETRequestService oneNETRequestService, IOptions options, ILogger logger) : IoTAppService, IProductionWorkshopService + public class ProductionWorkshopService(IFocusAppService focusAppService, IMeterAppService meterAppService, IOneNETDeviceService oneNETDeviceService, IOptions options, ILogger logger) : IoTAppService, IProductionWorkshopService { ServerApplicationOptions srverOptions = options.Value; @@ -81,25 +76,35 @@ namespace JiShe.IoT.Workshop return HttpDataResultExtensions.Failed("没有找到对应的产品信息", -108, ResponeResultEnum.Fail); } - FocusInfo focusInfoEntity = new FocusInfo() { - FocusAddress = productionEquipmentMessageBody.DeviceAddress, - Name = productionEquipmentMessageBody.DeviceOpenInfo, + CreateFocusInput focusInfoEntity = new CreateFocusInput() + { + FocusAddress = productionEquipmentMessageBody.DeviceAddress, IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId, - BusinessSystem = BusinessSystemEnum.Energy, IoTPlatform = IoTPlatformTypeEnum.OneNET, IoTPlatformDeviceOpenInfo = productionEquipmentMessageBody.DeviceOpenInfo, - PlatformPassword = productInfo.ProductAccesskey, + PlatformPassword = productInfo.ProductAccesskey, }; - focusInfoEntity.CreateId(GuidGenerator.Create()); - MeterInfo meterInfoEntity = new MeterInfo() { MeterAddress = productionEquipmentMessageBody.DeviceAddress, + CreateMeterInput meterInfoEntity = new CreateMeterInput() + { + MeterAddress = productionEquipmentMessageBody.DeviceAddress, Password = productInfo.ProductAccesskey, - BusinessSystem = BusinessSystemEnum.Energy, IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId, IoTPlatformDeviceOpenInfo = productionEquipmentMessageBody.DeviceOpenInfo, + FocusAddress = productionEquipmentMessageBody.DeviceAddress,//todo: 集中器地址 }; - //oneNETRequestService + //创建本地设备信息 + await focusAppService.CreateAsync(focusInfoEntity); + await meterAppService.CreateAsync(meterInfoEntity); + + //推送至OneNET平台 + await oneNETDeviceService.CreateDeviceInfoAsync(new CreateDeviceInfoInput() { + DeviceName = productionEquipmentMessageBody.DeviceOpenInfo, + ProductId = productionEquipmentMessageBody.IoTPlatformProductId, + OneNETAccountId = productInfo.OneNETAccountId, + Description = productionEquipmentMessageBody.DeviceOpenInfo, + }); return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed); } diff --git a/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250722081519_InitialCreate.Designer.cs b/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250723054349_InitialCreate.Designer.cs similarity index 99% rename from src/JiShe.IoT.EntityFrameworkCore/Migrations/20250722081519_InitialCreate.Designer.cs rename to src/JiShe.IoT.EntityFrameworkCore/Migrations/20250723054349_InitialCreate.Designer.cs index 9c4583b..00ed29c 100644 --- a/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250722081519_InitialCreate.Designer.cs +++ b/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250723054349_InitialCreate.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace JiShe.IoT.Migrations { [DbContext(typeof(IoTDbContext))] - [Migration("20250722081519_InitialCreate")] + [Migration("20250723054349_InitialCreate")] partial class InitialCreate { /// @@ -510,10 +510,6 @@ namespace JiShe.IoT.Migrations .HasColumnType("varchar(20)") .HasComment("APN"); - b.Property("BusinessSystem") - .HasColumnType("int") - .HasComment("业务系统"); - b.Property("ConcurrencyStamp") .IsConcurrencyToken() .IsRequired() @@ -724,10 +720,6 @@ namespace JiShe.IoT.Migrations .HasColumnType("varchar(128)") .HasComment("品牌类型"); - b.Property("BusinessSystem") - .HasColumnType("int") - .HasComment("业务系统"); - b.Property("ConcurrencyStamp") .IsConcurrencyToken() .IsRequired() diff --git a/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250722081519_InitialCreate.cs b/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250723054349_InitialCreate.cs similarity index 99% rename from src/JiShe.IoT.EntityFrameworkCore/Migrations/20250722081519_InitialCreate.cs rename to src/JiShe.IoT.EntityFrameworkCore/Migrations/20250723054349_InitialCreate.cs index 5927aef..0c09568 100644 --- a/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250722081519_InitialCreate.cs +++ b/src/JiShe.IoT.EntityFrameworkCore/Migrations/20250723054349_InitialCreate.cs @@ -840,7 +840,6 @@ namespace JiShe.IoT.Migrations columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - BusinessSystem = table.Column(type: "int", nullable: false, comment: "业务系统"), Name = table.Column(type: "varchar(128)", maxLength: 128, nullable: false, comment: "集中器名称") .Annotation("MySql:CharSet", "utf8mb4"), FocusAddress = table.Column(type: "varchar(20)", maxLength: 20, nullable: false, comment: "集中器地址") @@ -955,7 +954,6 @@ namespace JiShe.IoT.Migrations columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - BusinessSystem = table.Column(type: "int", nullable: false, comment: "业务系统"), MeterName = table.Column(type: "varchar(128)", maxLength: 128, nullable: false, comment: "表计名称") .Annotation("MySql:CharSet", "utf8mb4"), MeterAddress = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "表计地址") diff --git a/src/JiShe.IoT.EntityFrameworkCore/Migrations/IoTDbContextModelSnapshot.cs b/src/JiShe.IoT.EntityFrameworkCore/Migrations/IoTDbContextModelSnapshot.cs index f057721..beb3e71 100644 --- a/src/JiShe.IoT.EntityFrameworkCore/Migrations/IoTDbContextModelSnapshot.cs +++ b/src/JiShe.IoT.EntityFrameworkCore/Migrations/IoTDbContextModelSnapshot.cs @@ -507,10 +507,6 @@ namespace JiShe.IoT.Migrations .HasColumnType("varchar(20)") .HasComment("APN"); - b.Property("BusinessSystem") - .HasColumnType("int") - .HasComment("业务系统"); - b.Property("ConcurrencyStamp") .IsConcurrencyToken() .IsRequired() @@ -721,10 +717,6 @@ namespace JiShe.IoT.Migrations .HasColumnType("varchar(128)") .HasComment("品牌类型"); - b.Property("BusinessSystem") - .HasColumnType("int") - .HasComment("业务系统"); - b.Property("ConcurrencyStamp") .IsConcurrencyToken() .IsRequired()