首页添加设备状态和设备变量状态图表展示
This commit is contained in:
parent
e447489694
commit
34ecac1029
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,6 +10,8 @@ using Microsoft.AspNetCore.DataProtection;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Plugin;
|
||||||
|
using PluginInterface;
|
||||||
using WalkingTec.Mvvm.Core;
|
using WalkingTec.Mvvm.Core;
|
||||||
using WalkingTec.Mvvm.Core.Auth;
|
using WalkingTec.Mvvm.Core.Auth;
|
||||||
using WalkingTec.Mvvm.Core.Extensions;
|
using WalkingTec.Mvvm.Core.Extensions;
|
||||||
@ -19,6 +21,11 @@ namespace IoTGateway.Controllers
|
|||||||
{
|
{
|
||||||
public class HomeController : BaseController
|
public class HomeController : BaseController
|
||||||
{
|
{
|
||||||
|
private readonly DeviceService _deviceService;
|
||||||
|
public HomeController(DeviceService deviceService)
|
||||||
|
{
|
||||||
|
_deviceService = deviceService;
|
||||||
|
}
|
||||||
[AllRights]
|
[AllRights]
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
@ -39,6 +46,61 @@ namespace IoTGateway.Controllers
|
|||||||
return PartialView();
|
return PartialView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult GetDeviceChart()
|
||||||
|
{
|
||||||
|
var data = new List<ChartData>();
|
||||||
|
|
||||||
|
|
||||||
|
data.Add(new ChartData
|
||||||
|
{
|
||||||
|
Value = _deviceService.DeviceThreads.Where(x => !x.Device.AutoStart).Count(),
|
||||||
|
Category = "停止",
|
||||||
|
Series = "Device"
|
||||||
|
});
|
||||||
|
|
||||||
|
data.Add(new ChartData
|
||||||
|
{
|
||||||
|
Value = _deviceService.DeviceThreads.Where(x => x.Device.AutoStart && x.Driver.IsConnected).Count(),
|
||||||
|
Category = "运行",
|
||||||
|
Series = "Device",
|
||||||
|
});
|
||||||
|
|
||||||
|
data.Add(new ChartData
|
||||||
|
{
|
||||||
|
Value = _deviceService.DeviceThreads.Where(x => x.Device.AutoStart && !x.Driver.IsConnected).Count(),
|
||||||
|
Category = "异常",
|
||||||
|
Series = "Device"
|
||||||
|
});
|
||||||
|
var rv = data.ToChartData();
|
||||||
|
return Json(rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult GetDeviceVariableChart()
|
||||||
|
{
|
||||||
|
var data = new List<ChartData>();
|
||||||
|
foreach (var deviceThread in _deviceService.DeviceThreads.OrderBy(x => x.Device.DeviceName))
|
||||||
|
{
|
||||||
|
data.Add(new ChartData
|
||||||
|
{
|
||||||
|
Category = deviceThread.Device.DeviceName,
|
||||||
|
Value = deviceThread.DeviceValues.Where(x => x.Value.StatusType != VaribaleStatusTypeEnum.Good).Count(),
|
||||||
|
Series = "Others"
|
||||||
|
});
|
||||||
|
|
||||||
|
data.Add(new ChartData
|
||||||
|
{
|
||||||
|
Category = deviceThread.Device.DeviceName,
|
||||||
|
Value = deviceThread.DeviceValues.Where(x => x.Value.StatusType == VaribaleStatusTypeEnum.Good).Count(),
|
||||||
|
Series = "Good"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var rv = data.ToChartData();
|
||||||
|
return Json(rv);
|
||||||
|
}
|
||||||
|
|
||||||
public IActionResult GetActionChart()
|
public IActionResult GetActionChart()
|
||||||
{
|
{
|
||||||
var areas = GlobaInfo.AllModule.Select(x => x.Area).Distinct();
|
var areas = GlobaInfo.AllModule.Select(x => x.Area).Distinct();
|
||||||
|
@ -55,6 +55,22 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">设备状态</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<wt:chart is-horizontal="true" show-legend="true" show-tooltip="true" type="Pie" height="300" trigger-url="/Home/GetDeviceChart" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md8">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">设备变量状态</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<wt:chart show-legend="false" show-tooltip="true" type="Bar" height="300" trigger-url="/Home/GetDeviceVariableChart" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-col-md6">
|
<div class="layui-col-md6">
|
||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
|
@ -93,7 +93,7 @@ namespace Plugin
|
|||||||
foreach (var kv in payload.Values)
|
foreach (var kv in payload.Values)
|
||||||
{
|
{
|
||||||
//更新到UAService
|
//更新到UAService
|
||||||
_uaNodeManager.UpdateNode($"{device.Parent.DeviceName}.{device.DeviceName}.{kv.Key}", kv.Value);
|
_uaNodeManager?.UpdateNode($"{device.Parent.DeviceName}.{device.DeviceName}.{kv.Key}", kv.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user