From 534826a4bbce6cddc2ab16278981497335d25657 Mon Sep 17 00:00:00 2001 From: Hinse <756681202@qq.com> Date: Thu, 30 Sep 2021 13:53:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Waste.Application/Business/BusinessService.cs | 2 +- Waste.Application/Device/DeviceService.cs | 31 ++++++++++++- Waste.Application/Device/Dtos/DeviceDto.cs | 26 +++++++++++ Waste.Application/Device/IDeviceService.cs | 6 +++ Waste.Application/Waste.Application.xml | 44 +++++++++++++++++++ Waste.Web.Entry/Pages/Device/Detail.cshtml.cs | 10 ++++- Waste.Web.Entry/Pages/Device/Index.cshtml | 6 +++ 7 files changed, 122 insertions(+), 3 deletions(-) diff --git a/Waste.Application/Business/BusinessService.cs b/Waste.Application/Business/BusinessService.cs index abb9dae..c556be6 100644 --- a/Waste.Application/Business/BusinessService.cs +++ b/Waste.Application/Business/BusinessService.cs @@ -457,7 +457,7 @@ namespace Waste.Application if (BusinessId != Guid.Empty) { var tdbClient = repository.Change().Context; - int todaydevactivecnt = await repository.Change().Context.Queryable().Where(x => x.Businessid == BusinessId && SqlFunc.DateIsSame(x.LastHeartTime, DateTime.Now)).CountAsync(); + int todaydevactivecnt = await dbClient.Queryable().Where(x => x.Businessid == BusinessId && SqlFunc.DateIsSame(x.LastHeartTime, DateTime.Now)).CountAsync(); int devcnt = await repository.Change().Context.Queryable().Where(x => x.Businessid == BusinessId).CountAsync(); int businesscnt = await dbClient.Queryable().Where(x => x.ParentId == BusinessId).CountAsync(); if (!await tdbClient.Queryable().AnyAsync(x => x.BusinessId == BusinessId)) diff --git a/Waste.Application/Device/DeviceService.cs b/Waste.Application/Device/DeviceService.cs index 09db2f5..9614708 100644 --- a/Waste.Application/Device/DeviceService.cs +++ b/Waste.Application/Device/DeviceService.cs @@ -120,6 +120,35 @@ namespace Waste.Application.Device Id = devicedata.Id }; } + /// + /// 设备详情数据 + /// + /// + /// + public async Task DeviceDetailAsync(Guid id) + { + var devicedata = await dbClient.Queryable().FirstAsync(x => x.DeviceId == id); + var deviceresult = await dbClient.Queryable().FirstAsync(x => x.DeviceId == id); + var device = await dbClient.Queryable().FirstAsync(x => x.Id == id); + return new DeviceDetailS2Dto + { + Id = device.Id, + Name = device.Name, + Status = device.Status, + LastStartTime = devicedata != null ? (devicedata.LastStartTime.HasValue ? devicedata.LastStartTime.ToString() : "-") : "-", + LastBeatTime = devicedata != null ? (devicedata.LastBeatTime.HasValue ? devicedata.LastBeatTime.ToString() : "-") : "-", + LastHeartTime = device.LastHeartTime, + Latitude = devicedata.Latitude, + Longitude = devicedata.Longitude, + ActiveTime = device.ActiveTime, + Address = device.Address, + version = devicedata.Version, + Tare = device.Tare, + Ecode = device.Ecode, + FacEcode = device.FacEcode + }; + } + /// /// 设备列表 /// @@ -280,7 +309,7 @@ namespace Waste.Application.Device var tdbclient = repository.Change().Context; if (!await tdbclient.Queryable().AnyAsync(x => x.DeviceId == role.Id)) { - if(!string.IsNullOrEmpty(role.Secret) && !string.IsNullOrEmpty(role.SecretHash) && !string.IsNullOrEmpty(role.DevId)) + if (!string.IsNullOrEmpty(role.Secret) && !string.IsNullOrEmpty(role.SecretHash) && !string.IsNullOrEmpty(role.DevId)) { await tdbclient.Insertable(new W_SZDevice { diff --git a/Waste.Application/Device/Dtos/DeviceDto.cs b/Waste.Application/Device/Dtos/DeviceDto.cs index df08a6f..1692cd6 100644 --- a/Waste.Application/Device/Dtos/DeviceDto.cs +++ b/Waste.Application/Device/Dtos/DeviceDto.cs @@ -100,4 +100,30 @@ namespace Waste.Application /// public string Secret { get; set; } } + /// + /// 设备详情 + /// + public class DeviceDetailS2Dto: W_Device + { + /// + /// 最近心跳时间 + /// + public string LastBeatTime { get; set; } + /// + /// 最近开机时间 + /// + public string LastStartTime { get; set; } + /// + /// 纬度 + /// + public string Latitude { get; set; } + /// + /// 经度 + /// + public string Longitude { get; set; } + /// + /// 使用的版本号 + /// + public string version { get; set; } + } } diff --git a/Waste.Application/Device/IDeviceService.cs b/Waste.Application/Device/IDeviceService.cs index fed105c..29e4dd4 100644 --- a/Waste.Application/Device/IDeviceService.cs +++ b/Waste.Application/Device/IDeviceService.cs @@ -38,5 +38,11 @@ namespace Waste.Application /// /// Task BatchSetAsync(DeviceBatchModel deviceBatchModel); + /// + /// 设备详情数据 + /// + /// + /// + Task DeviceDetailAsync(Guid id); } } diff --git a/Waste.Application/Waste.Application.xml b/Waste.Application/Waste.Application.xml index 37baef3..4cacc51 100644 --- a/Waste.Application/Waste.Application.xml +++ b/Waste.Application/Waste.Application.xml @@ -593,6 +593,13 @@ + + + 设备详情数据 + + + + 设备列表 @@ -712,6 +719,36 @@ 设备对应的Secret + + + 设备详情 + + + + + 最近心跳时间 + + + + + 最近开机时间 + + + + + 纬度 + + + + + 经度 + + + + + 使用的版本号 + + 设备管理 @@ -745,6 +782,13 @@ + + + 设备详情数据 + + + + 定时任务 diff --git a/Waste.Web.Entry/Pages/Device/Detail.cshtml.cs b/Waste.Web.Entry/Pages/Device/Detail.cshtml.cs index a4e6ed3..785eafc 100644 --- a/Waste.Web.Entry/Pages/Device/Detail.cshtml.cs +++ b/Waste.Web.Entry/Pages/Device/Detail.cshtml.cs @@ -4,13 +4,21 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using Waste.Application; namespace Waste.Web.Entry.Pages.Device { public class DetailModel : BaseModel { - public void OnGet() + public DeviceDetailS2Dto data = new DeviceDetailS2Dto(); + private readonly IDeviceService _deviceService; + public DetailModel(IDeviceService deviceService) { + _deviceService = deviceService; + } + public async Task OnGetAsync(Guid id) + { + data = await _deviceService.DeviceDetailAsync(id); } } } diff --git a/Waste.Web.Entry/Pages/Device/Index.cshtml b/Waste.Web.Entry/Pages/Device/Index.cshtml index 46473a7..33067a0 100644 --- a/Waste.Web.Entry/Pages/Device/Index.cshtml +++ b/Waste.Web.Entry/Pages/Device/Index.cshtml @@ -255,6 +255,12 @@ }); }); }); + $("body").on("click", ".js-detail", function () { + var id = $(this).data('id'); + common.dialog({ + content:"/Device/Detail?id="+id + }); + }); }); }