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.

119 lines
5.9 KiB

7 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>
/// 换电订单电池
7 months ago
/// </summary>
[Scope("SingleInstance")]
public class SwapOrderBatteryService : BaseServices<SwapOrderBattery>
{
SwapOrderBatteryRepository _swapOrderBatteryRepository;
public SwapOrderBatteryService(SwapOrderBatteryRepository dal)
{
_swapOrderBatteryRepository = dal;
BaseDal = dal;
}
/// <summary>
/// 根据条件查询分页数据
7 months ago
/// </summary>
/// <param name="equipAlarmLevel"></param>
/// <returns></returns>
public PageResult<SwapOrderBatteryResp> QuerySwapOrderBattery(QuerySwapOrderBatteryReq swapOrderBattery)
{
//创建一个空的表达式树
7 months ago
Expression<Func<SwapOrderBattery, bool>> where = null;
//// 定义参数表达式
7 months ago
ParameterExpression parameter = Expression.Parameter(typeof(SwapOrderBattery), "u");
#region 构建动态查询树
7 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
//查询
7 months ago
return PageResult<SwapOrderBatteryResp>.ConvertPage(_swapOrderBatteryRepository.QueryIPageByCause(swapOrderBattery, where));
}
6 months ago
public PageResult<SwapOrderBatteryResp> QuerySwapOrderBatteryList(QuerySwapOrderPageReq swapOrderBattery)
{
//创建一个空的表达式树
Expression<Func<SwapOrderBattery, bool>> where = null;
//// 定义参数表达式
ParameterExpression parameter = Expression.Parameter(typeof(SwapOrderBattery), "u");
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 (!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.SwapBeginTime != null && swapOrderBattery.SwapEndTime != null)
{
Expression<Func<SwapOrderBattery, bool>> condition2Expr = u => u.CreatedTime >= swapOrderBattery.SwapBeginTime && u.CreatedTime <= swapOrderBattery.SwapEndTime;
where = where == null
? condition2Expr
: Expression.Lambda<Func<SwapOrderBattery, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
return PageResult<SwapOrderBatteryResp>.ConvertPage(_swapOrderBatteryRepository.QueryIPageByCause(swapOrderBattery, where));
//查询
}
7 months ago
}