From 519b6bcafb5aacec2ac8bca2da0bb46122a199f5 Mon Sep 17 00:00:00 2001 From: tq <1916474859@qq,com> Date: Fri, 5 Jul 2024 10:29:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Repository/BaseRepository.cs | 23 ++++++++++++++++++++++ Service/Station/EquipAlarmRecordService.cs | 6 +++++- Service/Station/MonitorService.cs | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Repository/BaseRepository.cs b/Repository/BaseRepository.cs index dd7bdc4..97d4376 100644 --- a/Repository/BaseRepository.cs +++ b/Repository/BaseRepository.cs @@ -1507,6 +1507,29 @@ public abstract class BaseRepository where T : class, new() .ToPageListAsync(pageNumber, pageSize, totalNumber); return page; } + + public async Task> QueryPageAsync( + Expression> whereExpression, + bool isWhere1, Expression> expression1, + bool isWhere2, Expression> expression2, + bool isWhere3, Expression> expression3, + Expression> orderBy, + OrderByType orderType, // 新增排序参数 + int pageNumber, int pageSize, RefAsync totalNumber, + bool blUseNoLock = false) + { + var page = await DbBaseClient + .Queryable() + .Where(whereExpression) + .WhereIF(isWhere1, expression1) + .WhereIF(isWhere2, expression2) + .WhereIF(isWhere3, expression3) + .OrderBy(orderBy, orderType) + .WithNoLockOrNot(blUseNoLock) + .ToPageListAsync(pageNumber, pageSize, totalNumber); + return page; + } + /// /// 查询-2表查询 diff --git a/Service/Station/EquipAlarmRecordService.cs b/Service/Station/EquipAlarmRecordService.cs index a03d1c0..d05e76f 100644 --- a/Service/Station/EquipAlarmRecordService.cs +++ b/Service/Station/EquipAlarmRecordService.cs @@ -8,6 +8,7 @@ using HybirdFrameworkCore.Utils; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.Mvc; using Repository.Station; +using SqlSugar; namespace Service.Station; @@ -34,6 +35,7 @@ public class EquipAlarmRecordService : BaseServices var equipCode = req.EquipCode; List list = BaseDal.Queryable().WhereIF(reqTypeCode != -1, it => it.EquipTypeCode == reqTypeCode) .WhereIF(ObjUtils.IsNotNullOrWhiteSpace(equipCode), it => it.EquipCode == equipCode) + .OrderBy(it => it.CreatedTime, OrderByType.Desc) .ToPageList(req.PageNum, req.PageSize, ref totalCount); PageResult result = new PageResult() @@ -82,8 +84,10 @@ public class EquipAlarmRecordService : BaseServices int totalCount = 0; int reqTypeCode = req.TypeCode; var equipCode = req.EquipCode; - List list = ProcessRecordRepository.Queryable().WhereIF(reqTypeCode != -1, it => it.EquipTypeCode == reqTypeCode) + List list = ProcessRecordRepository.Queryable() + .WhereIF(reqTypeCode != -1, it => it.EquipTypeCode == reqTypeCode) .WhereIF(ObjUtils.IsNotNullOrWhiteSpace(equipCode), it => it.EquipCode == equipCode) + .OrderBy(it => it.CreatedTime, OrderByType.Desc) .ToPageList(req.PageNum, req.PageSize, ref totalCount); PageResult result = new PageResult() diff --git a/Service/Station/MonitorService.cs b/Service/Station/MonitorService.cs index f81a193..00e0ceb 100644 --- a/Service/Station/MonitorService.cs +++ b/Service/Station/MonitorService.cs @@ -44,7 +44,7 @@ public class MonitorService !string.IsNullOrWhiteSpace(input.UpBatterySoc), u => u.UpBatterySoc.Equals(input.UpBatterySoc.Trim()), !string.IsNullOrWhiteSpace(input.UpBinNo), u => u.UpBinNo.Equals(input.UpBinNo.Trim()), !string.IsNullOrWhiteSpace(input.UpBatteryNo), u => u.UpBatteryNo.Equals(input.UpBatteryNo.Trim()), - u => u.CreatedTime, input.PageNum, input.PageSize, total); + u => u.CreatedTime, OrderByType.Desc, input.PageNum, input.PageSize, total); return new PageResult() { PageNum = input.PageNum,