|
|
|
@ -52,10 +52,10 @@ namespace Platform.Controllers
|
|
|
|
|
|
|
|
|
|
public IActionResult GetOrgan()
|
|
|
|
|
{
|
|
|
|
|
var userOrganId = User.GetOrganId().Value;//当前用户机构Id
|
|
|
|
|
var organId = User.GetOrganId().Value;//当前用户机构Id
|
|
|
|
|
var organ = this._organRepo.ReadOnlyTable()
|
|
|
|
|
.Include(o => o.Buildings)
|
|
|
|
|
.FirstOrDefault(o => o.Id == userOrganId);
|
|
|
|
|
.FirstOrDefault(o => o.Id == organId);
|
|
|
|
|
organ.Buildings.ToTree();
|
|
|
|
|
var rootBuildingId = this._buildingRepo.ReadOnlyTable().Where(o => o.ParentId == null).Select(o => o.Id).FirstOrDefault();
|
|
|
|
|
organ.Buildings = organ.Buildings
|
|
|
|
@ -63,28 +63,37 @@ namespace Platform.Controllers
|
|
|
|
|
.ToList();
|
|
|
|
|
var model = new {
|
|
|
|
|
Organ= organ,
|
|
|
|
|
MaxLight = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{userOrganId}]MaxLight").FirstOrDefault()?.Value,
|
|
|
|
|
MinLight = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{userOrganId}]MinLight").FirstOrDefault()?.Value,
|
|
|
|
|
MaxTemperature = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{userOrganId}]MaxTemperature").FirstOrDefault()?.Value,
|
|
|
|
|
MinTemperature = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{userOrganId}]MinTemperature").FirstOrDefault()?.Value,
|
|
|
|
|
MaxHumidity = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{userOrganId}]MaxHumidity").FirstOrDefault()?.Value,
|
|
|
|
|
MinHumidity = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{userOrganId}]MinHumidity").FirstOrDefault()?.Value,
|
|
|
|
|
DeviceOpenCount = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{userOrganId}]DeviceOpenCount").FirstOrDefault()?.Value,
|
|
|
|
|
DeviceCloseCount = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{userOrganId}]DeviceCloseCount").FirstOrDefault()?.Value,
|
|
|
|
|
MaxLight = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}]MaxLight").FirstOrDefault()?.Value,
|
|
|
|
|
MinLight = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}]MinLight").FirstOrDefault()?.Value,
|
|
|
|
|
MaxTemperature = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}]MaxTemperature").FirstOrDefault()?.Value,
|
|
|
|
|
MinTemperature = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}]MinTemperature").FirstOrDefault()?.Value,
|
|
|
|
|
MaxHumidity = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}]MaxHumidity").FirstOrDefault()?.Value,
|
|
|
|
|
MinHumidity = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}]MinHumidity").FirstOrDefault()?.Value,
|
|
|
|
|
DeviceOpenCount = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}]DeviceOpenCount").FirstOrDefault()?.Value,
|
|
|
|
|
DeviceCloseCount = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}]DeviceCloseCount").FirstOrDefault()?.Value,
|
|
|
|
|
};
|
|
|
|
|
return Json(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult GetBuilding(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var model = new
|
|
|
|
|
{
|
|
|
|
|
Building = this._buildingRepo.ReadOnlyTable()
|
|
|
|
|
.Include(o=>o.Scenes)
|
|
|
|
|
var organId = User.GetOrganId().Value;//当前用户机构Id
|
|
|
|
|
var building = this._buildingRepo.ReadOnlyTable()
|
|
|
|
|
.Include(o => o.Scenes)
|
|
|
|
|
.Include(o => o.IoTGateways)
|
|
|
|
|
.ThenInclude(o => o.Devices).ThenInclude(o => o.Data)
|
|
|
|
|
.ToList()
|
|
|
|
|
|
|
|
|
|
.FirstOrDefault();
|
|
|
|
|
var model = new
|
|
|
|
|
{
|
|
|
|
|
Building = building,
|
|
|
|
|
MaxLight = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}][{id}]MaxLight").FirstOrDefault()?.Value,
|
|
|
|
|
MinLight = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}][{id}]MinLight").FirstOrDefault()?.Value,
|
|
|
|
|
MaxTemperature = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}][{id}]MaxTemperature").FirstOrDefault()?.Value,
|
|
|
|
|
MinTemperature = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}][{id}]MinTemperature").FirstOrDefault()?.Value,
|
|
|
|
|
MaxHumidity = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}][{id}]MaxHumidity").FirstOrDefault()?.Value,
|
|
|
|
|
MinHumidity = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}][{id}]MinHumidity").FirstOrDefault()?.Value,
|
|
|
|
|
DeviceOpenCount = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}][{id}]DeviceOpenCount").FirstOrDefault()?.Value,
|
|
|
|
|
DeviceCloseCount = this._statisticRepo.ReadOnlyTable().Where(o => o.Key == $"[{organId}][{id}]DeviceCloseCount").FirstOrDefault()?.Value,
|
|
|
|
|
};
|
|
|
|
|
return Json(model);
|
|
|
|
|
}
|
|
|
|
|