增加排序

master
tq 5 months ago
parent b00d28562b
commit 519b6bcafb

@ -1507,6 +1507,29 @@ public abstract class BaseRepository<T> where T : class, new()
.ToPageListAsync(pageNumber, pageSize, totalNumber);
return page;
}
public async Task<List<T>> QueryPageAsync(
Expression<Func<T, bool>> whereExpression,
bool isWhere1, Expression<Func<T, bool>> expression1,
bool isWhere2, Expression<Func<T, bool>> expression2,
bool isWhere3, Expression<Func<T, bool>> expression3,
Expression<Func<T, object>> orderBy,
OrderByType orderType, // 新增排序参数
int pageNumber, int pageSize, RefAsync<int> totalNumber,
bool blUseNoLock = false)
{
var page = await DbBaseClient
.Queryable<T>()
.Where(whereExpression)
.WhereIF(isWhere1, expression1)
.WhereIF(isWhere2, expression2)
.WhereIF(isWhere3, expression3)
.OrderBy(orderBy, orderType)
.WithNoLockOrNot(blUseNoLock)
.ToPageListAsync(pageNumber, pageSize, totalNumber);
return page;
}
/// <summary>
/// 查询-2表查询

@ -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<EquipAlarmRecord>
var equipCode = req.EquipCode;
List<EquipAlarmRecord> 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<EquipAlarmRecord> result = new PageResult<EquipAlarmRecord>()
@ -82,8 +84,10 @@ public class EquipAlarmRecordService : BaseServices<EquipAlarmRecord>
int totalCount = 0;
int reqTypeCode = req.TypeCode;
var equipCode = req.EquipCode;
List<EquipAlarmProcessRecord> list = ProcessRecordRepository.Queryable().WhereIF(reqTypeCode != -1, it => it.EquipTypeCode == reqTypeCode)
List<EquipAlarmProcessRecord> 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<EquipAlarmProcessRecord> result = new PageResult<EquipAlarmProcessRecord>()

@ -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<MoveBinRecord>()
{
PageNum = input.PageNum,

Loading…
Cancel
Save