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

6 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>
/// <20><><EFBFBD><EFBFBD><E7B6A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
[Scope("SingleInstance")]
public class SwapOrderBatteryService : BaseServices<SwapOrderBattery>
{
SwapOrderBatteryRepository _swapOrderBatteryRepository;
public SwapOrderBatteryService(SwapOrderBatteryRepository dal)
{
_swapOrderBatteryRepository = dal;
BaseDal = dal;
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>
/// </summary>
/// <param name="equipAlarmLevel"></param>
/// <returns></returns>
public PageResult<SwapOrderBatteryResp> QuerySwapOrderBattery(QuerySwapOrderBatteryReq swapOrderBattery)
{
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>յı<D5B5><C4B1><EFBFBD>ʽ<EFBFBD><CABD>
Expression<Func<SwapOrderBattery, bool>> where = null;
//// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
ParameterExpression parameter = Expression.Parameter(typeof(SwapOrderBattery), "u");
#region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC>ѯ<EFBFBD><D1AF>
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
//<2F><>ѯ
return PageResult<SwapOrderBatteryResp>.ConvertPage(_swapOrderBatteryRepository.QueryIPageByCause(swapOrderBattery, where));
}
}