Former-commit-id: e1678ce8de798adad5a7b6b9cc4796f97de274b5
Former-commit-id: dea19dbe7e883aeff52fc51b3d1414ed74ce751c
1.0
wanggang 5 years ago
parent 4fcc746e5f
commit b1d32ee1c5

@ -87,7 +87,9 @@ namespace Platform.Controllers
var query = this._buildingRepo.ReadOnlyTable()
.Where(o => o.ParentId != null)
.Where(o => o.OrganId == model.OrganId.Value)
.WhereIf(model.BuildingId.HasValue, o => o.Left >= currentBuilding.Left && o.Right <= currentBuilding.Right)
.WhereIf(!model.ShowAll && model.BuildingId.HasValue, o => o.Id == model.BuildingId.Value)
.WhereIf(!model.ShowAll && !model.BuildingId.HasValue, o => false)
.WhereIf(model.ShowAll && model.BuildingId.HasValue, o => o.Left >= currentBuilding.Left && o.Right <= currentBuilding.Right)
.SelectMany(o => o.IoTGateways)
.SelectMany(o => o.Devices);
model.TotalCount = query.Count();

@ -7,6 +7,7 @@ namespace Platform.ViewModels
{
public class HomeModel : PagedList<IoTDevice>
{
public bool ShowAll { get; set; }
public Guid? OrganId { get; set; }
public Guid? BuildingId { get; set; }

@ -1,6 +1,28 @@
@model Platform.ViewModels.HomeModel
@{
HideBread = true;
var lightList = Model.Deviceses.SelectMany(o => o.Data).Where(o => o.Key == "Light")
.Select(o => string.IsNullOrEmpty(o.Value) ? 0 : int.Parse(o.Value))
.ToList();
var maxLight = lightList.Any() ? new Nullable<int>(lightList.Max()) : null;
var minLight = lightList.Any() ? new Nullable<int>(lightList.Min()) : null;
var temperatureList = Model.Deviceses.SelectMany(o => o.Data).Where(o => o.Key == "Temperature")
.Select(o => string.IsNullOrEmpty(o.Value) ? 0 : float.Parse(o.Value))
.ToList();
var maxTemperature = temperatureList.Any() ? new Nullable<float>(temperatureList.Max()) : null;
var minTemperature = temperatureList.Any() ? new Nullable<float>(temperatureList.Min()) : null;
var humidityList = Model.Deviceses.SelectMany(o => o.Data).Where(o => o.Key == "Humidity")
.Select(o => string.IsNullOrEmpty(o.Value) ? 0 : float.Parse(o.Value))
.ToList();
var maxHumidity = humidityList.Any() ? new Nullable<float>(humidityList.Max()) : null;
var minHhumidity = humidityList.Any() ? new Nullable<float>(humidityList.Min()) : null;
var elist = Model.Deviceses.Where(o => o.Name.Contains("开关") || o.Name.Contains("插座"));
var open = elist.Any() ? new Nullable<int>(elist.Where(o => o.Data.Any(o => o.Key == "State" && o.Value == "开")).Count()) : null;
var close = elist.Any() ? new Nullable<int>(elist.Where(o => o.Data.Any(o => o.Key == "State" && o.Value == "关")).Count()) : null;
}
<br />
<div class="row">
@ -29,9 +51,55 @@
<text> / @Model.Building.GetDisplayName()</text>
}
</h5>
<div class="card-tools"><label style="margin:0;">下级:@Html.CheckBoxFor(o=>o.ShowAll)</label></div>
</div>
<div class="card-header">
<div class="card-body">
<div class="row">
<div class="col-sm-3">
<div class="position-relative p-3 bg-gray">
<div class="ribbon-wrapper">
<div class="ribbon bg-primary">
光照
</div>
</div>
<p>最大值:@(maxLight.HasValue?$"{maxLight.Value.ToString("f2")} Lux":"无设备")</p>
<p>最小值:@(minLight.HasValue?$"{minLight.Value.ToString("f2")} Lux":"无设备")</p>
</div>
</div>
<div class="col-sm-3">
<div class="position-relative p-3 bg-gray">
<div class="ribbon-wrapper">
<div class="ribbon bg-primary">
温度
</div>
</div>
<p>最大值:@(maxTemperature.HasValue?$"{maxTemperature.Value.ToString("f2")} ℃":"无设备")</p>
<p>最小值:@(minTemperature.HasValue?$"{minTemperature.Value.ToString("f2")} ℃":"无设备")</p>
</div>
</div>
<div class="col-sm-3">
<div class="position-relative p-3 bg-gray">
<div class="ribbon-wrapper">
<div class="ribbon bg-primary">
湿度
</div>
</div>
<p>最大值:@(maxTemperature.HasValue?$"{maxTemperature.Value.ToString("f2")} RH%" :"无设备")</p>
<p>最小值:@(minTemperature.HasValue?$"{minTemperature.Value.ToString("f2")} RH%" :"无设备")</p>
</div>
</div>
<div class="col-sm-3">
<div class="position-relative p-3 bg-gray">
<div class="ribbon-wrapper">
<div class="ribbon bg-primary">
用电
</div>
</div>
<p>开:@(open.HasValue?$"{maxTemperature.Value}":"无设备")</p>
<p>关:@(close.HasValue?$"{minTemperature.Value}":"无设备")</p>
</div>
</div>
</div>
</div>
</div>
<div class="card">
@ -142,9 +210,14 @@
@section scripts{
<script>
$('#ShowAll').click(function () {
var url = new URI(window.location.href).removeSearch('showAll').addSearch('showAll', $('#ShowAll:checked').val() ? true : false);
window.location.href = url;
});
var tree = $('.jstree').on('changed.jstree', function (e, data) {
if (data.event) {
window.location.href = data.event.currentTarget.href;
var url = new URI(data.event.currentTarget.href).removeSearch('showAll').addSearch('showAll', $('#ShowAll:checked').val() ? true : false);
window.location.href = url;
}
else {
var parents = data.instance.get_node(data.selected).parents;

Loading…
Cancel
Save