You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
4.1 KiB

5 months ago
using Entity.Api.Req;
using Entity.Api.Resp;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using Repository.Station;
using SqlSugar;
using System.Linq.Expressions;
namespace Service.Station;
/// <summary>
/// 换电订单电池
5 months ago
/// </summary>
[Scope("SingleInstance")]
public class SwapOrderBatteryService : BaseServices<SwapOrderBattery>
{
SwapOrderBatteryRepository _swapOrderBatteryRepository;
public SwapOrderBatteryService(SwapOrderBatteryRepository dal)
{
_swapOrderBatteryRepository = dal;
BaseDal = dal;
}
/// <summary>
/// 根据条件查询分页数据
5 months ago
/// </summary>
/// <param name="equipAlarmLevel"></param>
/// <returns></returns>
public PageResult<SwapOrderBatteryResp> QuerySwapOrderBattery(QuerySwapOrderBatteryReq swapOrderBattery)
{
//创建一个空的表达式树
5 months ago
Expression<Func<SwapOrderBattery, bool>> where = null;
//// 定义参数表达式
5 months ago
ParameterExpression parameter = Expression.Parameter(typeof(SwapOrderBattery), "u");
#region 构建动态查询树
5 months ago
if (swapOrderBattery.Id != 0)
{
Expression<Func<SwapOrderBattery, bool>> condition1Expr = u => u.Id == swapOrderBattery.Id;
where = condition1Expr;
}
if (!string.IsNullOrEmpty(swapOrderBattery.SwapOrderSn))
{
Expression<Func<SwapOrderBattery, bool>> condition2Expr = u => u.SwapOrderSn == swapOrderBattery.SwapOrderSn;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrderBattery, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (!string.IsNullOrEmpty(swapOrderBattery.DownBatteryNo))
{
Expression<Func<SwapOrderBattery, bool>> condition2Expr = u => u.DownBatteryNo == swapOrderBattery.DownBatteryNo;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrderBattery, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (swapOrderBattery.DownBatteryBinNo != 0)
{
Expression<Func<SwapOrderBattery, bool>> condition2Expr = u => u.DownBatteryBinNo == swapOrderBattery.DownBatteryBinNo;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrderBattery, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (!string.IsNullOrEmpty(swapOrderBattery.UpBatteryNo))
{
Expression<Func<SwapOrderBattery, bool>> condition2Expr = u => u.UpBatteryNo == swapOrderBattery.UpBatteryNo;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrderBattery, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (swapOrderBattery.UpBatteryBinNo != 0)
{
Expression<Func<SwapOrderBattery, bool>> condition2Expr = u => u.UpBatteryBinNo == swapOrderBattery.UpBatteryBinNo;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrderBattery, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (swapOrderBattery.CreatedTime != null && swapOrderBattery.CreatedTime != DateTime.MinValue)
{
Expression<Func<SwapOrderBattery, bool>> condition2Expr = u => u.CreatedTime == swapOrderBattery.CreatedTime;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrderBattery, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (swapOrderBattery.UpdatedTime != null && swapOrderBattery.UpdatedTime != DateTime.MinValue)
{
Expression<Func<SwapOrderBattery, bool>> condition2Expr = u => u.UpdatedTime == swapOrderBattery.UpdatedTime;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrderBattery, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
#endregion
//查询
5 months ago
return PageResult<SwapOrderBatteryResp>.ConvertPage(_swapOrderBatteryRepository.QueryIPageByCause(swapOrderBattery, where));
}
}