新增子设备表,以及完善业务系统新增设备
This commit is contained in:
parent
376ce4a0a5
commit
ea48f30d4f
@ -4,7 +4,7 @@
|
|||||||
"CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://10.10.90.3:4200"
|
"CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://10.10.90.3:4200"
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"
|
"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB386;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"
|
||||||
},
|
},
|
||||||
"Hangfire": {
|
"Hangfire": {
|
||||||
"Redis": {
|
"Redis": {
|
||||||
@ -80,7 +80,8 @@
|
|||||||
"AesSecurityKey": "RPTEIGCA1KvDEXS1",
|
"AesSecurityKey": "RPTEIGCA1KvDEXS1",
|
||||||
"IsAesEncrypted": false,
|
"IsAesEncrypted": false,
|
||||||
"DistributedMessage": 2,
|
"DistributedMessage": 2,
|
||||||
"SnowflakeWorkerId": 1
|
"SnowflakeWorkerId": 1,
|
||||||
|
"DownloadDeviceFirmwareBasicUrl": "http://121.42.175.177:32580/Aggregation/Device/DownloadFirmware?Id="
|
||||||
},
|
},
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
"Audience": "JiShe.IoT",
|
"Audience": "JiShe.IoT",
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
"Serilog.Sinks.Console",
|
"Serilog.Sinks.Console",
|
||||||
"Serilog.Sinks.File"
|
"Serilog.Sinks.File",
|
||||||
|
"Serilog.Sinks.Grafana.Loki"
|
||||||
],
|
],
|
||||||
"MinimumLevel": {
|
"MinimumLevel": {
|
||||||
"Default": "Warning",
|
"Default": "Warning",
|
||||||
@ -21,10 +22,27 @@
|
|||||||
"Name": "Console"
|
"Name": "Console"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "File",
|
"Name": "GrafanaLoki",
|
||||||
"Args": {
|
"Args": {
|
||||||
"path": "logs/logs-.txt",
|
"uri": "http://192.168.111.164:3100",
|
||||||
"rollingInterval": "Hour"
|
"labels": [
|
||||||
|
{
|
||||||
|
"key": "app",
|
||||||
|
"value": "OneNETAdmin" // 应用名称
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "environment",
|
||||||
|
"value": "dev" // 环境(dev/staging/prod)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "version",
|
||||||
|
"value": "1.2.3" // 应用版本(可选)
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"propertiesAsLabels": [
|
||||||
|
"Level",
|
||||||
|
"SourceContext"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -0,0 +1,40 @@
|
|||||||
|
using JiShe.ServicePro.Enums;
|
||||||
|
using JiShe.ServicePro.OpenAPIModels;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace JiShe.IoT.BusinessSystemAggregation.Dto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 业务系统批量创建设备信息
|
||||||
|
/// </summary>
|
||||||
|
public class BatchCreateDeviceBusinessSystemInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设备信息集合
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "设备信息不能为空")]
|
||||||
|
public List<OpenApiDeviceInfoInput> DeviceInfos { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物联网平台类型
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "物联网平台类型不能为空")]
|
||||||
|
public IoTPlatformTypeEnum IoTPlatform { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 集中器在物联网平台中对应的产品Id
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "产品Id不能为空")]
|
||||||
|
public string IoTPlatformProductId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备类型,用来区分主设备是网关设备还是直连设备
|
||||||
|
/// </summary>
|
||||||
|
public DeviceTypeEnum? DeviceType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备来源类型
|
||||||
|
/// </summary>
|
||||||
|
public DeviceSourceTypeEnum? DeviceSourceType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,55 +0,0 @@
|
|||||||
using JiShe.ServicePro.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace JiShe.IoT.BusinessSystemAggregation.Dto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 批量创建设备信息输入
|
|
||||||
/// </summary>
|
|
||||||
public class BatchCreateDeviceInfoInput
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 设备来源类型,只接收 预付费业务系统推送、能耗业务系统推送
|
|
||||||
/// </summary>
|
|
||||||
public DeviceSourceTypeEnum DeviceSourceType { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 物联网平台类型
|
|
||||||
/// </summary>
|
|
||||||
public IoTPlatformTypeEnum IoTPlatform { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 集中器在物联网平台中对应的产品Id
|
|
||||||
/// </summary>
|
|
||||||
public string IoTPlatformProductId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设备地址集合
|
|
||||||
/// </summary>
|
|
||||||
public List<string> DeviceAddresses { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SubDeviceInfoInput
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 设备地址
|
|
||||||
/// </summary>
|
|
||||||
public string DeviceAddresses { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子设备地址
|
|
||||||
/// </summary>
|
|
||||||
public string SubDeviceAddress { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子设备索引
|
|
||||||
/// </summary>
|
|
||||||
public int SubDeviceIndex { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -35,7 +35,7 @@ namespace JiShe.IoT.BusinessSystemAggregation
|
|||||||
Task<HttpDataResult<List<IoTDBDynamicObject>>> QueryDeviceDataInfoAsync(OpenApiRequest input);
|
Task<HttpDataResult<List<IoTDBDynamicObject>>> QueryDeviceDataInfoAsync(OpenApiRequest input);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 业务系统批量新增设备数据,Msg 字段为 BatchCreateDeviceInfoInput 实体
|
/// 业务系统批量新增设备数据,Msg 字段为 BatchCreateDeviceBusinessSystemInput 实体
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using JiShe.ServicePro.Enums;
|
using JiShe.ServicePro.Enums;
|
||||||
|
using JiShe.ServicePro.OpenAPIModels;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace JiShe.IoT.DeviceAggregation
|
namespace JiShe.IoT.DeviceAggregation
|
||||||
@ -9,11 +10,16 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
public class BatchCreateDeviceAggregationInput
|
public class BatchCreateDeviceAggregationInput
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 表通信地址集合
|
/// 设备地址不能为空
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required(ErrorMessage = "设备地址不能为空")]
|
[Required(ErrorMessage = "设备地址不能为空")]
|
||||||
public List<string> AddressList { get; set; }
|
public List<string> AddressList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备信息
|
||||||
|
/// </summary>
|
||||||
|
public List<OpenApiDeviceInfoInput> DeviceInfos { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物联网平台类型
|
/// 物联网平台类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -30,6 +36,11 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
/// 设备来源类型
|
/// 设备来源类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public DeviceSourceTypeEnum? DeviceSourceTypeEnum { get; set; }
|
public DeviceSourceTypeEnum? DeviceSourceType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备类型
|
||||||
|
/// </summary>
|
||||||
|
public DeviceTypeEnum? DeviceType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using JiShe.ServicePro.Enums;
|
using JiShe.ServicePro.Enums;
|
||||||
|
using JiShe.ServicePro.OpenAPIModels;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace JiShe.IoT.DeviceAggregation.Dto
|
namespace JiShe.IoT.DeviceAggregation.Dto
|
||||||
@ -14,6 +15,11 @@ namespace JiShe.IoT.DeviceAggregation.Dto
|
|||||||
[Required(ErrorMessage = "设备地址不能为空")]
|
[Required(ErrorMessage = "设备地址不能为空")]
|
||||||
public string DeviceAddress { get; set; }
|
public string DeviceAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备信息
|
||||||
|
/// </summary>
|
||||||
|
public OpenApiDeviceInfoInput DeviceInfos { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物联网平台类型
|
/// 物联网平台类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -30,7 +36,13 @@ namespace JiShe.IoT.DeviceAggregation.Dto
|
|||||||
/// 设备来源类型
|
/// 设备来源类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public DeviceSourceTypeEnum? DeviceSourceTypeEnum { get; set; }
|
public DeviceSourceTypeEnum? DeviceSourceType { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备类型,与业务系统无关
|
||||||
|
/// </summary>
|
||||||
|
public DeviceTypeEnum? DeviceType { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using JiShe.IoT.DeviceAggregation.Dto;
|
using JiShe.IoT.BusinessSystemAggregation.Dto;
|
||||||
|
using JiShe.IoT.DeviceAggregation.Dto;
|
||||||
using JiShe.ServicePro;
|
using JiShe.ServicePro;
|
||||||
using JiShe.ServicePro.Core;
|
using JiShe.ServicePro.Core;
|
||||||
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
||||||
@ -103,6 +104,6 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> BatchCreateDeviceBusinessSystemAsync(BatchCreateDeviceAggregationInput input);
|
Task<bool> BatchCreateDeviceBusinessSystemAsync(BatchCreateDeviceBusinessSystemInput input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -300,7 +300,7 @@ namespace JiShe.IoT.BusinessSystemAggregation
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 业务系统批量新增设备数据,Msg 字段为 BatchCreateDeviceInfoInput 实体
|
/// 业务系统批量新增设备数据,Msg 字段为 BatchCreateDeviceBusinessSystemInput 实体
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -309,25 +309,20 @@ namespace JiShe.IoT.BusinessSystemAggregation
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var handleResult = HandleOpenApiRequest<BatchCreateDeviceInfoInput>(input, serverOptions);
|
var handleResult = HandleOpenApiRequest<BatchCreateDeviceBusinessSystemInput>(input, serverOptions);
|
||||||
if (handleResult.Success == false)
|
if (handleResult.Success == false)
|
||||||
{
|
{
|
||||||
return HttpDataResultExtensions.Failed(handleResult.Message, handleResult.LocationCode);
|
return HttpDataResultExtensions.Failed(handleResult.Message, handleResult.LocationCode);
|
||||||
}
|
}
|
||||||
var messageBody = handleResult.Data;
|
var messageBody = handleResult.Data;
|
||||||
|
|
||||||
if (messageBody.DeviceAddresses == null || messageBody.DeviceAddresses.Count <= 0)
|
if (messageBody.DeviceInfos == null || messageBody.DeviceInfos.Count <= 0)
|
||||||
{
|
{
|
||||||
return HttpDataResultExtensions.Failed("设备地址不能为空", -101);
|
return HttpDataResultExtensions.Failed("设备地址不能为空", -101);
|
||||||
}
|
}
|
||||||
|
|
||||||
var createResult = await deviceAggregationService.BatchCreateDeviceBusinessSystemAsync(new BatchCreateDeviceAggregationInput()
|
// 批量新增设备
|
||||||
{
|
var createResult = await deviceAggregationService.BatchCreateDeviceBusinessSystemAsync(messageBody);
|
||||||
DeviceSourceTypeEnum = messageBody.DeviceSourceType,
|
|
||||||
IoTPlatform = messageBody.IoTPlatform,
|
|
||||||
IoTPlatformProductId = messageBody.IoTPlatformProductId,
|
|
||||||
AddressList = messageBody.DeviceAddresses
|
|
||||||
});
|
|
||||||
|
|
||||||
if (createResult == false)
|
if (createResult == false)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using JiShe.IoT.DeviceAggregation.Dto;
|
using JiShe.IoT.BusinessSystemAggregation.Dto;
|
||||||
|
using JiShe.IoT.DeviceAggregation.Dto;
|
||||||
using JiShe.ServicePro;
|
using JiShe.ServicePro;
|
||||||
using JiShe.ServicePro.ApacheIoTDB.Provider.Options;
|
using JiShe.ServicePro.ApacheIoTDB.Provider.Options;
|
||||||
using JiShe.ServicePro.Core;
|
using JiShe.ServicePro.Core;
|
||||||
@ -58,7 +59,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
input.DeviceSourceTypeEnum = ServicePro.Enums.DeviceSourceTypeEnum.AdminSystem;
|
input.DeviceSourceType = ServicePro.Enums.DeviceSourceTypeEnum.AdminSystem;
|
||||||
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
||||||
{
|
{
|
||||||
return await CTWingDeviceCreateAsync(input);
|
return await CTWingDeviceCreateAsync(input);
|
||||||
@ -99,7 +100,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
throw new UserFriendlyException($"批量创建设备失败,设备信息不能超过100个。");
|
throw new UserFriendlyException($"批量创建设备失败,设备信息不能超过100个。");
|
||||||
}
|
}
|
||||||
|
|
||||||
input.DeviceSourceTypeEnum = ServicePro.Enums.DeviceSourceTypeEnum.AdminSystem;
|
input.DeviceSourceType = ServicePro.Enums.DeviceSourceTypeEnum.AdminSystem;
|
||||||
|
|
||||||
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
||||||
{
|
{
|
||||||
@ -128,7 +129,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
input.DeviceSourceTypeEnum = DeviceSourceTypeEnum.Workshop;
|
input.DeviceSourceType = DeviceSourceTypeEnum.Workshop;
|
||||||
|
|
||||||
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
||||||
{
|
{
|
||||||
@ -168,7 +169,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
throw new UserFriendlyException($"批量创建设备失败,设备信息不能超过100个。");
|
throw new UserFriendlyException($"批量创建设备失败,设备信息不能超过100个。");
|
||||||
}
|
}
|
||||||
|
|
||||||
input.DeviceSourceTypeEnum = DeviceSourceTypeEnum.Workshop;
|
input.DeviceSourceType = DeviceSourceTypeEnum.Workshop;
|
||||||
|
|
||||||
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
||||||
{
|
{
|
||||||
@ -651,32 +652,38 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> BatchCreateDeviceBusinessSystemAsync(BatchCreateDeviceAggregationInput input)
|
public async Task<bool> BatchCreateDeviceBusinessSystemAsync(BatchCreateDeviceBusinessSystemInput input)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (input.AddressList == null || input.AddressList.Count <= 0)
|
if (input.DeviceInfos == null || input.DeviceInfos.Count <= 0)
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException($"业务系统批量创建设备信息,设备信息不能为空。");
|
throw new UserFriendlyException($"业务系统批量创建设备信息,设备信息不能为空。");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.AddressList.Count > 100)
|
if (input.DeviceInfos.Count > 100)
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException($"业务系统批量创建设备信息,设备信息不能超过100个。");
|
throw new UserFriendlyException($"业务系统批量创建设备信息,设备信息不能超过100个。");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.DeviceSourceTypeEnum != DeviceSourceTypeEnum.Prepay && input.DeviceSourceTypeEnum != DeviceSourceTypeEnum.Energy)
|
if (input.DeviceSourceType != DeviceSourceTypeEnum.Prepay && input.DeviceSourceType != DeviceSourceTypeEnum.Energy)
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException($"业务系统批量创建设备信息,设备来源异常。");
|
throw new UserFriendlyException($"业务系统批量创建设备信息,设备来源异常。");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
|
||||||
{
|
{
|
||||||
return await CTWingDeviceBatchCreateAsync(input);
|
var batchCreateDeviceInput = input.Adapt<BatchCreateDeviceAggregationInput>();
|
||||||
|
batchCreateDeviceInput.AddressList = input.DeviceInfos.Select(f => f.DeviceAddress.Trim()).ToList();
|
||||||
|
|
||||||
|
return await CTWingDeviceBatchCreateAsync(batchCreateDeviceInput);
|
||||||
}
|
}
|
||||||
else if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.OneNET)
|
else if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.OneNET)
|
||||||
{
|
{
|
||||||
return await OneNETDeviceBatchCreateAsync(input);
|
var batchCreateDeviceInput = input.Adapt<BatchCreateDeviceAggregationInput>();
|
||||||
|
batchCreateDeviceInput.AddressList = input.DeviceInfos.Select(f => f.DeviceAddress.Trim()).ToList();
|
||||||
|
|
||||||
|
return await OneNETDeviceBatchCreateAsync(batchCreateDeviceInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UserFriendlyException($"不支持的物联网平台");
|
throw new UserFriendlyException($"不支持的物联网平台");
|
||||||
@ -708,7 +715,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
throw new UserFriendlyException($"OneNET创建设备失败,未找到对应的产品配置信息。");
|
throw new UserFriendlyException($"OneNET创建设备失败,未找到对应的产品配置信息。");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.DeviceSourceTypeEnum == DeviceSourceTypeEnum.Workshop && !productInfo.IsEnabled) //车间生产推送,必须是已经启用的产品才可以
|
if (input.DeviceSourceType == DeviceSourceTypeEnum.Workshop && !productInfo.IsEnabled) //车间生产推送,必须是已经启用的产品才可以
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException($"车间生产推送OneNET创建设备失败,产品未启用。");
|
throw new UserFriendlyException($"车间生产推送OneNET创建设备失败,产品未启用。");
|
||||||
}
|
}
|
||||||
@ -719,6 +726,10 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
createDeviceInput.PlatformPassword = productInfo.ProductAccesskey;
|
createDeviceInput.PlatformPassword = productInfo.ProductAccesskey;
|
||||||
createDeviceInput.IoTPlatformProductName = productInfo.ProductName;
|
createDeviceInput.IoTPlatformProductName = productInfo.ProductName;
|
||||||
createDeviceInput.AccountPhoneNumber = productInfo.AccountPhoneNumber;
|
createDeviceInput.AccountPhoneNumber = productInfo.AccountPhoneNumber;
|
||||||
|
if (input.DeviceType.HasValue)
|
||||||
|
{
|
||||||
|
createDeviceInput.DeviceType = input.DeviceType.Value;
|
||||||
|
}
|
||||||
|
|
||||||
var insertResult = await deviceAppService.CreateAsync(createDeviceInput);
|
var insertResult = await deviceAppService.CreateAsync(createDeviceInput);
|
||||||
if (insertResult == null)
|
if (insertResult == null)
|
||||||
@ -742,6 +753,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//更新OneNET平台推送结果
|
||||||
await DeviceUpdateHandler(insertResult, pushResult, pushResult.Data.SecurityKey);
|
await DeviceUpdateHandler(insertResult, pushResult, pushResult.Data.SecurityKey);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -764,7 +776,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
{
|
{
|
||||||
var productInfo = await FreeSqlDbContext.Instance.Select<OneNETProductInfos>()
|
var productInfo = await FreeSqlDbContext.Instance.Select<OneNETProductInfos>()
|
||||||
.Where(e => e.IoTPlatformProductId == input.IoTPlatformProductId)//此处不需要过滤产品状态,方便测试产品配置信息是否准确,避免跟车间生产搞混
|
.Where(e => e.IoTPlatformProductId == input.IoTPlatformProductId)//此处不需要过滤产品状态,方便测试产品配置信息是否准确,避免跟车间生产搞混
|
||||||
.WhereIf(input.DeviceSourceTypeEnum == DeviceSourceTypeEnum.Workshop, e => e.IsEnabled == true)
|
.WhereIf(input.DeviceSourceType == DeviceSourceTypeEnum.Workshop, e => e.IsEnabled == true)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
|
|
||||||
if (productInfo == null)
|
if (productInfo == null)
|
||||||
@ -778,8 +790,27 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
AddressList = input.AddressList,
|
AddressList = input.AddressList,
|
||||||
DeviceInputs = new List<CreateDeviceInput>()
|
DeviceInputs = new List<CreateDeviceInput>()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//检查网关或者直连设备信息是否已经存在
|
||||||
|
var checkDevicesInfos = await deviceAppService.FindByDeviceAddressAsync(new FindByDeviceAddressInput()
|
||||||
|
{
|
||||||
|
AddressList = input.AddressList,
|
||||||
|
IoTPlatform = input.IoTPlatform,
|
||||||
|
IoTPlatformProductId = input.IoTPlatformProductId,
|
||||||
|
});
|
||||||
|
|
||||||
foreach (var item in input.AddressList)
|
foreach (var item in input.AddressList)
|
||||||
{
|
{
|
||||||
|
if (checkDevicesInfos != null)
|
||||||
|
{
|
||||||
|
if (checkDevicesInfos.Any(e => e.DeviceAddress == item))
|
||||||
|
{
|
||||||
|
logger.LogError($"{nameof(OneNETDeviceBatchCreateAsync)} 平台{input.IoTPlatform} 产品 {input.IoTPlatformProductId} 下设备信息已存在:{item}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CreateDeviceInput createDeviceInput = input.Adapt<CreateDeviceInput>();
|
CreateDeviceInput createDeviceInput = input.Adapt<CreateDeviceInput>();
|
||||||
createDeviceInput.DeviceName = item;
|
createDeviceInput.DeviceName = item;
|
||||||
createDeviceInput.DeviceAddress = item;
|
createDeviceInput.DeviceAddress = item;
|
||||||
@ -788,7 +819,18 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
createDeviceInput.PlatformPassword = productInfo.ProductAccesskey;
|
createDeviceInput.PlatformPassword = productInfo.ProductAccesskey;
|
||||||
createDeviceInput.IoTPlatformProductName = productInfo.ProductName;
|
createDeviceInput.IoTPlatformProductName = productInfo.ProductName;
|
||||||
createDeviceInput.AccountPhoneNumber = productInfo.AccountPhoneNumber;
|
createDeviceInput.AccountPhoneNumber = productInfo.AccountPhoneNumber;
|
||||||
createDeviceInput.DeviceSourceTypeEnum = input.DeviceSourceTypeEnum.Value;
|
createDeviceInput.DeviceSourceType = input.DeviceSourceType.Value;
|
||||||
|
createDeviceInput.DeviceType = input.DeviceType.Value;
|
||||||
|
|
||||||
|
if (input.DeviceSourceType.HasValue)
|
||||||
|
{
|
||||||
|
createDeviceInput.DeviceSourceType = input.DeviceSourceType.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.DeviceType.HasValue)
|
||||||
|
{
|
||||||
|
createDeviceInput.DeviceType = input.DeviceType.Value;
|
||||||
|
}
|
||||||
|
|
||||||
batchCreateDeviceInput.DeviceInputs.Add(createDeviceInput);
|
batchCreateDeviceInput.DeviceInputs.Add(createDeviceInput);
|
||||||
}
|
}
|
||||||
@ -819,6 +861,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//更新OneNET平台推送结果
|
||||||
foreach (var item in insertResult)
|
foreach (var item in insertResult)
|
||||||
{
|
{
|
||||||
var successEntity = pushResult.Data.Successlist.Where(d => d.DeviceName == item.IoTPlatformDeviceOpenInfo).FirstOrDefault();
|
var successEntity = pushResult.Data.Successlist.Where(d => d.DeviceName == item.IoTPlatformDeviceOpenInfo).FirstOrDefault();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"
|
"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB386;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"
|
||||||
},
|
},
|
||||||
"IoTDBOptions": {
|
"IoTDBOptions": {
|
||||||
"UserName": "root",
|
"UserName": "root",
|
||||||
|
|||||||
@ -69,6 +69,7 @@ namespace JiShe.IoT.EntityFrameworkCore
|
|||||||
|
|
||||||
// 设备管理
|
// 设备管理
|
||||||
public DbSet<DeviceManagementInfo> DeviceManagementInfo { get; set; }
|
public DbSet<DeviceManagementInfo> DeviceManagementInfo { get; set; }
|
||||||
|
public DbSet<SubDeviceManagementInfo> SubDeviceManagementInfo { get; set; }
|
||||||
public DbSet<DeviceThingModelManagement> DeviceThingModelManagement { get; set; }
|
public DbSet<DeviceThingModelManagement> DeviceThingModelManagement { get; set; }
|
||||||
public DbSet<DeviceThingModelPropertyInfo> DeviceThingModelDetailInfo { get; set; }
|
public DbSet<DeviceThingModelPropertyInfo> DeviceThingModelDetailInfo { get; set; }
|
||||||
public DbSet<DeviceThingModelCommandInfo> DeviceThingModelCommandInfo { get; set; }
|
public DbSet<DeviceThingModelCommandInfo> DeviceThingModelCommandInfo { get; set; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user