feat 消费机及离线设备详情
This commit is contained in:
@@ -146,7 +146,16 @@ public class BalancesController : ControllerBase
|
||||
return await _balanceService.GetConsumeNumberAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取消费机详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("consumeDevices")]
|
||||
public async Task<Pagination<DevicePageResponse>> GetConsumeDeviceAsync([FromQuery] GetConsumeDeviceRequest request)
|
||||
{
|
||||
return await _balanceService.GetConsumeDeviceAsync(request);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class GetConsumeDeviceRequest : PageDto
|
||||
{
|
||||
public bool IsOff { get; set; }
|
||||
}
|
||||
}
|
||||
104
Src/Dlhis.Canteen/Order/Response/DevicePageResponseResponse.cs
Normal file
104
Src/Dlhis.Canteen/Order/Response/DevicePageResponseResponse.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
{
|
||||
public class DevicePageResponse
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备code
|
||||
/// </summary>
|
||||
public Guid Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备唯一码,IP/MAC/SNO
|
||||
/// </summary>
|
||||
public string UniqueNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 心跳间隔
|
||||
/// </summary>
|
||||
public int HeartbeatInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 品牌
|
||||
/// </summary>
|
||||
public string Brand { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 供应商
|
||||
/// </summary>
|
||||
public string Supplier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备功能 DeviceFuncEnumType
|
||||
/// </summary>
|
||||
public List<DeviceFuncEnumType> Funcs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (FuncsStr.IsEmpty()) FuncsStr = "[]";
|
||||
|
||||
return FuncsStr.ToObject<List<DeviceFuncEnumType>>();
|
||||
}
|
||||
}
|
||||
|
||||
public string FuncsStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备机功能类型
|
||||
/// </summary>
|
||||
public DeviceTypeEnumType Type { get; set; }
|
||||
|
||||
public string TypeDescription => Type.GetDescription();
|
||||
|
||||
/// <summary>
|
||||
/// 部署点
|
||||
/// </summary>
|
||||
public string DeployPlace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部署坐标
|
||||
/// </summary>
|
||||
public string DeployPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部署方向
|
||||
/// </summary>
|
||||
public string DeployDirection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板code
|
||||
/// </summary>
|
||||
public Guid TemplateCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 连接信息
|
||||
/// </summary>
|
||||
public string ConnectionInfo { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
public bool IsOnline { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消费总额
|
||||
/// </summary>
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消费人次
|
||||
/// </summary>
|
||||
public int UserCount { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public interface IBalanceService : IScopeDependency
|
||||
|
||||
Task<ConsumeNumberResponse> GetConsumeNumberAsync();
|
||||
|
||||
|
||||
Task<Pagination<DevicePageResponse>> GetConsumeDeviceAsync(GetConsumeDeviceRequest request);
|
||||
|
||||
|
||||
Task<Pagination<OaEMealVoucherResponse>> GetOaEMealVoucherAsync([FromQuery] OaEMealVoucherRequest request);
|
||||
|
||||
@@ -551,7 +551,7 @@ public class BalanceService : IBalanceService
|
||||
public async Task<ConsumeNumberResponse> GetConsumeNumberAsync()
|
||||
{
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>()
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Meal && x.Enable)
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Meal)
|
||||
.ToListAsync();
|
||||
|
||||
var offCount = await GetOfflineDevicesCount(devices);
|
||||
@@ -593,6 +593,47 @@ public class BalanceService : IBalanceService
|
||||
|
||||
}
|
||||
|
||||
public async Task<Pagination<DevicePageResponse>> GetConsumeDeviceAsync(GetConsumeDeviceRequest request)
|
||||
{
|
||||
if (request.IsOff)
|
||||
{
|
||||
//消费机离线设备
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>()
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Meal)
|
||||
.ToListAsync();
|
||||
|
||||
var offs = await GetOfflineDevicesCount(devices);
|
||||
var offUniqueNos = offs.Select(x => x.UniqueNo).ToList();
|
||||
|
||||
var offpage = await _dbContext.Queryable<DeviceEntity>()
|
||||
.LeftJoin<DeviceTemplateEntity>((d, dt) => d.TemplateCode == dt.Code)
|
||||
.Where(d => offUniqueNos.Contains(d.UniqueNo))
|
||||
.Select((d, dt) => new DevicePageResponse
|
||||
{
|
||||
FuncsStr = d.Funcs.ToString(),
|
||||
Brand = dt.Brand,
|
||||
Type = d.Type,
|
||||
|
||||
}, true)
|
||||
.ToPageListAsync(request);
|
||||
return offpage;
|
||||
}
|
||||
//消费机总数
|
||||
var page = await _dbContext.Queryable<DeviceEntity>()
|
||||
.LeftJoin<DeviceTemplateEntity>((d, dt) => d.TemplateCode == dt.Code)
|
||||
.Where(d => d.Type == DeviceTypeEnumType.Meal)
|
||||
.Select((d, dt) => new DevicePageResponse
|
||||
{
|
||||
FuncsStr = d.Funcs.ToString(),
|
||||
Brand = dt.Brand,
|
||||
Type = d.Type,
|
||||
|
||||
}, true)
|
||||
.ToPageListAsync(request);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取离线设备
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user