2025-07-03 13:53:29 +08:00
|
|
|
using System.Diagnostics;
|
2025-07-15 22:18:37 +08:00
|
|
|
using AutoMapper;
|
2025-07-18 22:21:16 +08:00
|
|
|
using DMS.Infrastructure.Entities;
|
|
|
|
|
using DMS.Core.Enums;
|
2025-07-19 09:25:01 +08:00
|
|
|
using DMS.Core.Helper;
|
|
|
|
|
using DMS.Core.Models;
|
|
|
|
|
using DMS.Infrastructure.Data;
|
2025-06-24 20:48:38 +08:00
|
|
|
using SqlSugar;
|
2025-07-19 11:11:01 +08:00
|
|
|
using DMS.Infrastructure.Interfaces;
|
2025-06-10 22:13:06 +08:00
|
|
|
|
2025-07-18 22:21:16 +08:00
|
|
|
namespace DMS.Infrastructure.Repositories;
|
2025-06-10 22:13:06 +08:00
|
|
|
|
2025-07-19 14:36:34 +08:00
|
|
|
public class DeviceRepository : BaseRepository<DbDevice>
|
2025-06-10 22:13:06 +08:00
|
|
|
{
|
2025-07-02 22:07:16 +08:00
|
|
|
|
2025-07-19 14:36:34 +08:00
|
|
|
public DeviceRepository(ITransaction transaction)
|
|
|
|
|
: base(transaction)
|
2025-06-24 20:48:38 +08:00
|
|
|
{
|
2025-07-19 14:36:34 +08:00
|
|
|
|
2025-06-10 22:13:06 +08:00
|
|
|
}
|
2025-06-23 17:01:06 +08:00
|
|
|
|
2025-07-02 22:07:16 +08:00
|
|
|
|
2025-07-19 14:36:34 +08:00
|
|
|
public override async Task<List<DbDevice>> GetAllAsync()
|
2025-06-10 22:13:06 +08:00
|
|
|
{
|
2025-07-03 13:53:29 +08:00
|
|
|
Stopwatch stopwatch = new Stopwatch();
|
|
|
|
|
stopwatch.Start();
|
2025-07-19 11:11:01 +08:00
|
|
|
var dlist = await Db.Queryable<DbDevice>()
|
|
|
|
|
.Includes(d => d.VariableTables, dv => dv.Device)
|
|
|
|
|
.Includes(d => d.VariableTables, dvd => dvd.Variables, data => data.VariableTable)
|
|
|
|
|
.Includes(d => d.VariableTables, vt => vt.Variables, v => v.VariableMqtts)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
2025-07-04 18:33:48 +08:00
|
|
|
stopwatch.Stop();
|
2025-07-19 11:11:01 +08:00
|
|
|
NlogHelper.Info($"加载设备列表总耗时:{stopwatch.ElapsedMilliseconds}ms");
|
2025-07-19 14:36:34 +08:00
|
|
|
return dlist;
|
2025-07-04 18:33:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-07-19 09:25:01 +08:00
|
|
|
|
|
|
|
|
|
2025-07-19 14:36:34 +08:00
|
|
|
|
2025-06-10 22:13:06 +08:00
|
|
|
}
|