|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
using Infrastructure.Data;
|
|
|
|
|
using Application.Domain.Entities;
|
|
|
|
|
using Infrastructure.Data;
|
|
|
|
|
using Infrastructure.Events;
|
|
|
|
|
using Infrastructure.Extensions;
|
|
|
|
|
using Infrastructure.Web.SignalR;
|
|
|
|
|
using Application.Domain.Entities;
|
|
|
|
|
using IoT.Shared.Application.Models;
|
|
|
|
|
using IoT.Shared.Services;
|
|
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
@ -36,15 +36,10 @@ namespace Platform.Services
|
|
|
|
|
|
|
|
|
|
private readonly IRepository<IoTApi> _apiRepo;
|
|
|
|
|
|
|
|
|
|
//private readonly IRepository<IoTCommand> _commandRepo;
|
|
|
|
|
private readonly IRepository<IoTProductCategory> _categoryRepo;
|
|
|
|
|
|
|
|
|
|
private readonly IRepository<IoTProduct> _productRepo;
|
|
|
|
|
|
|
|
|
|
//private readonly IRepository<IoTScene> _sceneRepo;
|
|
|
|
|
//private readonly IRepository<IoTSceneIoTCommand> _sceneCommandRepo;
|
|
|
|
|
//private readonly IRepository<IoTSceneTimer> _iotTimerRepo;
|
|
|
|
|
//private readonly IRepository<IoTSceneTigger> _iotTiggerRepo;
|
|
|
|
|
private readonly DataService _dataService;
|
|
|
|
|
|
|
|
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
|
|
@ -57,13 +52,8 @@ namespace Platform.Services
|
|
|
|
|
IRepository<IoTDevice> deviceRepo,
|
|
|
|
|
IRepository<IoTData> dataRepo,
|
|
|
|
|
IRepository<IoTApi> apiRepo,
|
|
|
|
|
//IRepository<IoTCommand> commandRepo,
|
|
|
|
|
IRepository<IoTProductCategory> categoryRepo,
|
|
|
|
|
IRepository<IoTProduct> productRepo,
|
|
|
|
|
//IRepository<IoTScene> sceneRepo,
|
|
|
|
|
//IRepository<IoTSceneIoTCommand> sceneCommandRepo,
|
|
|
|
|
//IRepository<IoTSceneTimer> iotTimerRepo,
|
|
|
|
|
//IRepository<IoTSceneTigger> iotTiggerRepo,
|
|
|
|
|
DataService dataService,
|
|
|
|
|
IHttpClientFactory httpClientFactory,
|
|
|
|
|
IEventPublisher publisher)
|
|
|
|
@ -74,13 +64,8 @@ namespace Platform.Services
|
|
|
|
|
this._deviceRepo = deviceRepo;
|
|
|
|
|
this._dataRepo = dataRepo;
|
|
|
|
|
this._apiRepo = apiRepo;
|
|
|
|
|
//this._commandRepo = commandRepo;
|
|
|
|
|
this._categoryRepo = categoryRepo;
|
|
|
|
|
this._productRepo = productRepo;
|
|
|
|
|
//this._sceneRepo = sceneRepo;
|
|
|
|
|
//this._sceneCommandRepo = sceneCommandRepo;
|
|
|
|
|
//this._iotTimerRepo = iotTimerRepo;
|
|
|
|
|
//this._iotTiggerRepo = iotTiggerRepo;
|
|
|
|
|
this._dataService = dataService;
|
|
|
|
|
this._httpClientFactory = httpClientFactory;
|
|
|
|
|
this._publisher = publisher;
|
|
|
|
@ -136,76 +121,29 @@ namespace Platform.Services
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//网关上传
|
|
|
|
|
if (method == Methods.UpdateNodeResponse)//接收网关
|
|
|
|
|
if (method == $"{nameof(IoTGateway)}EntityUpdated")//接收网关
|
|
|
|
|
{
|
|
|
|
|
var number = message.To<IoTGateway>().Number;
|
|
|
|
|
this._dataService.Update<IoTGateway>(message, o => o.Number == number,new string[] { nameof(IoTGateway.BuildingId) });
|
|
|
|
|
var entity = message.FromJson<IoTGateway>();
|
|
|
|
|
this._dataService.Update(entity, o => o.Number == entity.Number, new string[] { nameof(IoTGateway.BuildingId) });
|
|
|
|
|
}
|
|
|
|
|
else if (method == Methods.UpdateProductResponse)//接收产品
|
|
|
|
|
else if (method == $"{nameof(IoTProduct)}EntityUpdated")//接收产品
|
|
|
|
|
{
|
|
|
|
|
this._dataService.Update<IoTProduct>(message, skips: new string[] { nameof(IoTProduct.IoTProductCategoryId), nameof(IoTProduct.DisplayOrder) });
|
|
|
|
|
var entity = message.FromJson<IoTProduct>();
|
|
|
|
|
this._dataService.Update(entity, o => o.Number == entity.Number, skips: new string[] { nameof(IoTProduct.IoTProductCategoryId), nameof(IoTProduct.DisplayOrder) });
|
|
|
|
|
}
|
|
|
|
|
else if (method == Methods.UpdateApiResponse)//接收接口
|
|
|
|
|
{
|
|
|
|
|
this._dataService.Update<IoTApi>(message);
|
|
|
|
|
}
|
|
|
|
|
else if (method == Methods.UpdateParameterResponse)//接收参数
|
|
|
|
|
{
|
|
|
|
|
this._dataService.Update<IoTParameter>(message);
|
|
|
|
|
}
|
|
|
|
|
else if (method == Methods.UpdateDeviceIdListResponse)//接收设备Id列表
|
|
|
|
|
else if (method == Methods.UpdateDeviceIdList)//接收设备Id列表
|
|
|
|
|
{
|
|
|
|
|
this._dataService.UpdateList<IoTDevice>(message, o => o.IoTGateway.Number == from);
|
|
|
|
|
}
|
|
|
|
|
else if (method == Methods.UpdateDeviceResponse)//接收设备
|
|
|
|
|
else if (method == $"{nameof(IoTDevice)}EntityUpdated")//接收设备
|
|
|
|
|
{
|
|
|
|
|
var number = message.To<IoTDevice>().Number;
|
|
|
|
|
this._dataService.Update<IoTDevice>(message, o => o.Number == number);
|
|
|
|
|
var entity = message.FromJson<IoTDevice>();
|
|
|
|
|
this._dataService.Update(entity, o => o.Number == entity.Number);
|
|
|
|
|
}
|
|
|
|
|
else if (method == Methods.UpdateDataResponse)//接收数据
|
|
|
|
|
else if (method == $"{nameof(IoTData)}EntityUpdated")//接收数据
|
|
|
|
|
{
|
|
|
|
|
this._dataService.Update<IoTData>(message);
|
|
|
|
|
this._dataService.Update(message.FromJson<IoTData>());
|
|
|
|
|
}
|
|
|
|
|
//else if (method == Methods.UpdateCommandIdListResponse)//接收命令Id列表
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.UpdateList<IoTCommand>(message, o => o.Device.Node.Number == from);
|
|
|
|
|
//}
|
|
|
|
|
//else if (method == Methods.UpdateCommandResponse)//接收命令
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.Update<IoTCommand>(message);
|
|
|
|
|
//}
|
|
|
|
|
//else if (method == Methods.UpdateSceneIdListResponse)//接收场景Id列表
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.UpdateList<IoTScene>(message, o => o.Node.Number == from);
|
|
|
|
|
//}
|
|
|
|
|
//else if (method == Methods.UpdateSceneResponse)//接收场景
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.Update<IoTScene>(message);
|
|
|
|
|
//}
|
|
|
|
|
//else if (method == Methods.UpdateIoTTimerIdListResponse)//接收定时器Id列表
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.UpdateList<IoTSceneTimer>(message, o => o.Scene.Node.Number == from);
|
|
|
|
|
//}
|
|
|
|
|
//else if (method == Methods.UpdateIoTTimerResponse)//接收定时器
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.Update<IoTSceneTimer>(message);
|
|
|
|
|
//}
|
|
|
|
|
//else if (method == Methods.UpdateIoTTiggerIdListResponse)//接收触发器Id列表
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.UpdateList<IoTSceneTigger>(message, o => o.Scene.Node.Number == from);
|
|
|
|
|
//}
|
|
|
|
|
//else if (method == Methods.UpdateIoTTiggerResponse)//接收触发器
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.Update<IoTSceneTigger>(message);
|
|
|
|
|
//}
|
|
|
|
|
//else if (method == Methods.UpdateSceneCommandIdListResponse)//接收场景命令Id列表
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.UpdateList<IoTSceneIoTCommand>(message, o => o.Scene.Node.Number == from);
|
|
|
|
|
//}
|
|
|
|
|
//else if (method == Methods.UpdateSceneCommandResponse)//接收场景命令
|
|
|
|
|
//{
|
|
|
|
|
// this._dataService.Update<IoTSceneIoTCommand>(message);
|
|
|
|
|
//}
|
|
|
|
|
//后台编辑
|
|
|
|
|
else if (method == $"Edit{nameof(IoTGateway)}")//编辑节点返回
|
|
|
|
|
{
|
|
|
|
|