增加排序

master
tq 5 months ago
parent b00d28562b
commit 519b6bcafb

@ -1508,6 +1508,29 @@ public abstract class BaseRepository<T> where T : class, new()
return page; 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> /// <summary>
/// 查询-2表查询 /// 查询-2表查询
/// </summary> /// </summary>

@ -8,6 +8,7 @@ using HybirdFrameworkCore.Utils;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Repository.Station; using Repository.Station;
using SqlSugar;
namespace Service.Station; namespace Service.Station;
@ -34,6 +35,7 @@ public class EquipAlarmRecordService : BaseServices<EquipAlarmRecord>
var equipCode = req.EquipCode; var equipCode = req.EquipCode;
List<EquipAlarmRecord> list = BaseDal.Queryable().WhereIF(reqTypeCode != -1, it => it.EquipTypeCode == reqTypeCode) List<EquipAlarmRecord> list = BaseDal.Queryable().WhereIF(reqTypeCode != -1, it => it.EquipTypeCode == reqTypeCode)
.WhereIF(ObjUtils.IsNotNullOrWhiteSpace(equipCode), it => it.EquipCode == equipCode) .WhereIF(ObjUtils.IsNotNullOrWhiteSpace(equipCode), it => it.EquipCode == equipCode)
.OrderBy(it => it.CreatedTime, OrderByType.Desc)
.ToPageList(req.PageNum, req.PageSize, ref totalCount); .ToPageList(req.PageNum, req.PageSize, ref totalCount);
PageResult<EquipAlarmRecord> result = new PageResult<EquipAlarmRecord>() PageResult<EquipAlarmRecord> result = new PageResult<EquipAlarmRecord>()
@ -82,8 +84,10 @@ public class EquipAlarmRecordService : BaseServices<EquipAlarmRecord>
int totalCount = 0; int totalCount = 0;
int reqTypeCode = req.TypeCode; int reqTypeCode = req.TypeCode;
var equipCode = req.EquipCode; 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) .WhereIF(ObjUtils.IsNotNullOrWhiteSpace(equipCode), it => it.EquipCode == equipCode)
.OrderBy(it => it.CreatedTime, OrderByType.Desc)
.ToPageList(req.PageNum, req.PageSize, ref totalCount); .ToPageList(req.PageNum, req.PageSize, ref totalCount);
PageResult<EquipAlarmProcessRecord> result = new PageResult<EquipAlarmProcessRecord>() 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.UpBatterySoc), u => u.UpBatterySoc.Equals(input.UpBatterySoc.Trim()),
!string.IsNullOrWhiteSpace(input.UpBinNo), u => u.UpBinNo.Equals(input.UpBinNo.Trim()), !string.IsNullOrWhiteSpace(input.UpBinNo), u => u.UpBinNo.Equals(input.UpBinNo.Trim()),
!string.IsNullOrWhiteSpace(input.UpBatteryNo), u => u.UpBatteryNo.Equals(input.UpBatteryNo.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>() return new PageResult<MoveBinRecord>()
{ {
PageNum = input.PageNum, PageNum = input.PageNum,

Loading…
Cancel
Save