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