Compare commits

..

No commits in common. "19dd451fbbc626d12c0420f201fbd89103905354" and "85214ab407ca962bdb872b7c3bb961d9b0d4a77b" have entirely different histories.

6 changed files with 41 additions and 28 deletions

@ -1 +1 @@
Subproject commit 3b61e5ab8402b1fed3c545312540e19f3293095b Subproject commit bcf2fe561c8b143835214e0974f640cc40cbe84f

View File

@ -2,23 +2,28 @@
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.OneNETManagement.OneNETDevices; using JiShe.ServicePro.OneNET.Provider.Interface;
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, IOneNETDeviceService oneNETDeviceService, IOptions<ServerApplicationOptions> options, ILogger<ProductionWorkshopService> logger) : IoTAppService, IProductionWorkshopService public class ProductionWorkshopService(IFocusAppService focusAppService, IMeterAppService meterAppService, IOneNETRequestService oneNETRequestService, IOptions<ServerApplicationOptions> options, ILogger<ProductionWorkshopService> logger) : IoTAppService, IProductionWorkshopService
{ {
ServerApplicationOptions srverOptions = options.Value; ServerApplicationOptions srverOptions = options.Value;
@ -76,35 +81,25 @@ namespace JiShe.IoT.Workshop
return HttpDataResultExtensions.Failed("没有找到对应的产品信息", -108, ResponeResultEnum.Fail); return HttpDataResultExtensions.Failed("没有找到对应的产品信息", -108, ResponeResultEnum.Fail);
} }
CreateFocusInput focusInfoEntity = new CreateFocusInput() FocusInfo focusInfoEntity = new FocusInfo() {
{
FocusAddress = productionEquipmentMessageBody.DeviceAddress, FocusAddress = productionEquipmentMessageBody.DeviceAddress,
Name = productionEquipmentMessageBody.DeviceOpenInfo,
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());
CreateMeterInput meterInfoEntity = new CreateMeterInput() MeterInfo meterInfoEntity = new MeterInfo() { MeterAddress = productionEquipmentMessageBody.DeviceAddress,
{
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("20250723054349_InitialCreate")] [Migration("20250722081519_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -510,6 +510,10 @@ 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()
@ -720,6 +724,10 @@ 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,6 +840,7 @@ 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: "集中器地址")
@ -954,6 +955,7 @@ 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,6 +507,10 @@ 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()
@ -717,6 +721,10 @@ 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()