生产车间设备信息上报服务接口

This commit is contained in:
ChenYi 2025-07-23 17:35:21 +08:00
parent 85214ab407
commit 3e639cb1e4
6 changed files with 28 additions and 41 deletions

View File

@ -93,7 +93,7 @@
<!-- redis分布式锁--> <!-- redis分布式锁-->
<PackageReference Update="DistributedLock.Redis" Version="1.0.3" /> <PackageReference Update="DistributedLock.Redis" Version="1.0.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1 +1 @@
Subproject commit bcf2fe561c8b143835214e0974f640cc40cbe84f Subproject commit 163b1c303938c7e2d8f343fc456b7f091014426d

View File

@ -2,28 +2,23 @@
using JiShe.ServicePro; using JiShe.ServicePro;
using JiShe.ServicePro.Core; using JiShe.ServicePro.Core;
using JiShe.ServicePro.DeviceManagement.Focuses; using JiShe.ServicePro.DeviceManagement.Focuses;
using JiShe.ServicePro.DeviceManagement.Focuses.Dto;
using JiShe.ServicePro.DeviceManagement.Meters; using JiShe.ServicePro.DeviceManagement.Meters;
using JiShe.ServicePro.DeviceManagement.Meters.Dto;
using JiShe.ServicePro.Encrypt; using JiShe.ServicePro.Encrypt;
using JiShe.ServicePro.Enums; using JiShe.ServicePro.Enums;
using JiShe.ServicePro.OneNET.Provider.Interface; using JiShe.ServicePro.OneNETManagement.OneNETDevices;
using JiShe.ServicePro.OneNETManagement.OneNETProducts; using JiShe.ServicePro.OneNETManagement.OneNETProducts;
using JiShe.ServicePro.ServerOptions; using JiShe.ServicePro.ServerOptions;
using Mapster.Utils;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; 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 namespace JiShe.IoT.Workshop
{ {
/// <summary> /// <summary>
/// 生产车间服务 /// 生产车间服务
/// </summary> /// </summary>
public class ProductionWorkshopService(IFocusAppService focusAppService, IMeterAppService meterAppService, IOneNETRequestService oneNETRequestService, IOptions<ServerApplicationOptions> options, ILogger<ProductionWorkshopService> logger) : IoTAppService, IProductionWorkshopService public class ProductionWorkshopService(IFocusAppService focusAppService, IMeterAppService meterAppService, IOneNETDeviceService oneNETDeviceService, IOptions<ServerApplicationOptions> options, ILogger<ProductionWorkshopService> logger) : IoTAppService, IProductionWorkshopService
{ {
ServerApplicationOptions srverOptions = options.Value; ServerApplicationOptions srverOptions = options.Value;
@ -81,25 +76,35 @@ namespace JiShe.IoT.Workshop
return HttpDataResultExtensions.Failed("没有找到对应的产品信息", -108, ResponeResultEnum.Fail); return HttpDataResultExtensions.Failed("没有找到对应的产品信息", -108, ResponeResultEnum.Fail);
} }
FocusInfo focusInfoEntity = new FocusInfo() { CreateFocusInput focusInfoEntity = new CreateFocusInput()
FocusAddress = productionEquipmentMessageBody.DeviceAddress, {
Name = productionEquipmentMessageBody.DeviceOpenInfo, FocusAddress = productionEquipmentMessageBody.DeviceAddress,
IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId, IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId,
BusinessSystem = BusinessSystemEnum.Energy,
IoTPlatform = IoTPlatformTypeEnum.OneNET, IoTPlatform = IoTPlatformTypeEnum.OneNET,
IoTPlatformDeviceOpenInfo = productionEquipmentMessageBody.DeviceOpenInfo, 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, Password = productInfo.ProductAccesskey,
BusinessSystem = BusinessSystemEnum.Energy,
IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId, IoTPlatformProductId = productionEquipmentMessageBody.IoTPlatformProductId,
IoTPlatformDeviceOpenInfo = productionEquipmentMessageBody.DeviceOpenInfo, 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); return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
} }

View File

@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace JiShe.IoT.Migrations namespace JiShe.IoT.Migrations
{ {
[DbContext(typeof(IoTDbContext))] [DbContext(typeof(IoTDbContext))]
[Migration("20250722081519_InitialCreate")] [Migration("20250723054349_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -510,10 +510,6 @@ namespace JiShe.IoT.Migrations
.HasColumnType("varchar(20)") .HasColumnType("varchar(20)")
.HasComment("APN"); .HasComment("APN");
b.Property<int>("BusinessSystem")
.HasColumnType("int")
.HasComment("业务系统");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.IsRequired() .IsRequired()
@ -724,10 +720,6 @@ namespace JiShe.IoT.Migrations
.HasColumnType("varchar(128)") .HasColumnType("varchar(128)")
.HasComment("品牌类型"); .HasComment("品牌类型");
b.Property<int>("BusinessSystem")
.HasColumnType("int")
.HasComment("业务系统");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.IsRequired() .IsRequired()

View File

@ -840,7 +840,6 @@ namespace JiShe.IoT.Migrations
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
BusinessSystem = table.Column<int>(type: "int", nullable: false, comment: "业务系统"),
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "集中器名称") Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "集中器名称")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
FocusAddress = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false, comment: "集中器地址") FocusAddress = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false, comment: "集中器地址")
@ -955,7 +954,6 @@ namespace JiShe.IoT.Migrations
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
BusinessSystem = table.Column<int>(type: "int", nullable: false, comment: "业务系统"),
MeterName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "表计名称") MeterName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "表计名称")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
MeterAddress = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "表计地址") MeterAddress = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "表计地址")

View File

@ -507,10 +507,6 @@ namespace JiShe.IoT.Migrations
.HasColumnType("varchar(20)") .HasColumnType("varchar(20)")
.HasComment("APN"); .HasComment("APN");
b.Property<int>("BusinessSystem")
.HasColumnType("int")
.HasComment("业务系统");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.IsRequired() .IsRequired()
@ -721,10 +717,6 @@ namespace JiShe.IoT.Migrations
.HasColumnType("varchar(128)") .HasColumnType("varchar(128)")
.HasComment("品牌类型"); .HasComment("品牌类型");
b.Property<int>("BusinessSystem")
.HasColumnType("int")
.HasComment("业务系统");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.IsRequired() .IsRequired()