换电订单

master
xjl 6 months ago
parent ad404750dd
commit 53d526bab1

@ -3,7 +3,7 @@
namespace Entity.Api.Req
{
///<summary>
///新增换电订单
///修改换电订单
///</summary>
public class ModifySwapOrderReq:AddSwapOrderReq
{

@ -52,5 +52,5 @@ public class QuerySwapOrderPageReq : QueryPageModel
/// Default:0
/// Nullable:True
/// </summary>
public int? SwapResult { get; set; }
public int SwapResult { get; set; }
}

@ -9,7 +9,7 @@ using System.Linq.Expressions;
namespace Service.Station;
/// <summary>
/// 뻣든땐데든넥
/// 념든땐데
/// </summary>
[Scope("SingleInstance")]
public class ChargeOrderService : BaseServices<ChargeOrder>
@ -46,11 +46,6 @@ public class ChargeOrderService : BaseServices<ChargeOrder>
Expression<Func<ChargeOrder, bool>> condition2Expr = u => u.Sn == chargeOrder.Sn;
where = where == null ? condition2Expr : Expression.Lambda<Func<ChargeOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (!string.IsNullOrEmpty(chargeOrder.Sn))
{
Expression<Func<ChargeOrder, bool>> condition2Expr = u => u.Sn == chargeOrder.Sn;
where = where == null ? condition2Expr : Expression.Lambda<Func<ChargeOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (!string.IsNullOrEmpty(chargeOrder.BatteryNo))
{
Expression<Func<ChargeOrder, bool>> condition2Expr = u => u.BatteryNo == chargeOrder.BatteryNo;

@ -0,0 +1,81 @@
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 SwapOrderService : BaseServices<SwapOrder>
{
SwapOrderRepository swapOrderRepository;
public SwapOrderService(SwapOrderRepository dal)
{
swapOrderRepository = dal;
BaseDal = dal;
}
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="equipAlarmLevel"></param>
/// <returns></returns>
public PageResult<SwapOrderResp> QuerySwapOrder(QuerySwapOrderPageReq swapOrder)
{
//创建一个空的表达式树
Expression<Func<SwapOrder, bool>> where = null;
//// 定义参数表达式
ParameterExpression parameter = Expression.Parameter(typeof(SwapOrder), "u");
#region 构建动态查询树
if (!string.IsNullOrEmpty(swapOrder.Sn))
{
Expression<Func<SwapOrder, bool>> condition2Expr = u => u.Sn == swapOrder.Sn;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (!string.IsNullOrEmpty(swapOrder.VehicleNo))
{
Expression<Func<SwapOrder, bool>> condition2Expr = u => u.VehicleNo == swapOrder.VehicleNo;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (!string.IsNullOrEmpty(swapOrder.VehicleMac))
{
Expression<Func<SwapOrder, bool>> condition2Expr = u => u.VehicleMac == swapOrder.VehicleMac;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (!string.IsNullOrEmpty(swapOrder.VehicleVin))
{
Expression<Func<SwapOrder, bool>> condition2Expr = u => u.VehicleVin == swapOrder.VehicleVin;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (swapOrder.SwapBeginTime != null && swapOrder.SwapBeginTime != DateTime.MinValue)
{
Expression<Func<SwapOrder, bool>> condition2Expr = u => u.SwapBeginTime == swapOrder.SwapBeginTime;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (swapOrder.SwapEndTime != null && swapOrder.SwapEndTime != DateTime.MinValue)
{
Expression<Func<SwapOrder, bool>> condition2Expr = u => u.SwapEndTime == swapOrder.SwapEndTime;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (swapOrder.SwapResult != 0)
{
Expression<Func<SwapOrder, bool>> condition2Expr = u => u.SwapResult == swapOrder.SwapResult;
where = where == null ? condition2Expr : Expression.Lambda<Func<SwapOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
#endregion
//查询
return PageResult<SwapOrderResp>.ConvertPage(swapOrderRepository.QueryIPageByCause(swapOrder, where));
}
}

@ -1,14 +1,16 @@
using AutoMapper;
using Entity.Api.Req;
using Entity.Api.Resp;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Station;
namespace WebStarter.Controllers;
/**
*
*/
/// <summary>
/// 充电订
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class ChargeOrderController : ControllerBase
@ -21,53 +23,52 @@ public class ChargeOrderController : ControllerBase
}
/// <summary>
/// 分页数据
/// 查询分页数据
/// </summary>
/// <returns></returns>
[HttpPost("QueryPage")]
public async Task<Result<PageResult<ChargeOrderResp>>> QueryPage([FromBody] QueryChargeOrderReq req)
{
chargeOrderService.QueryChargeOrder(req);
return Result<PageResult<ChargeOrderResp>>.Success(null);
return Result<PageResult<ChargeOrderResp>>.Success(chargeOrderService.QueryChargeOrder(req));
}
/// <summary>
/// 获取列表
/// 修改充电订单
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost("GetList")]
public async Task<Result<List<ChargeOrderResp>>> GetList([FromBody] QueryChargeOrderReq req)
{
[HttpPost("Modify")]
public async Task<Result<bool>> Modify([FromBody] ModifyChargeOrderReq req)
{
//映射数据
var config = new MapperConfiguration(cfg => cfg.CreateMap<ChargeOrder, ModifyChargeOrderReq>().ReverseMap());
IMapper mapper = config.CreateMapper();
ChargeOrder chargeOrder = mapper.Map<ChargeOrder>(req);
return Result<List<ChargeOrderResp>>.Success(null);
if (chargeOrderService.Update(chargeOrder))
{
return Result<bool>.Success("更改成功");
}
/// <summary>
/// 修改充电订单
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost("Modify")]
public async Task<Result<bool>> Modify([FromBody] ModifyChargeOrderReq req)
else
{
return Result<bool>.Success(null);
return Result<bool>.Fail("更改失败");
}
}
/// <summary>
/// 充电订单上报云端
/// </summary>
/// <returns></returns>
[HttpGet("UploadCloud/{id}")]
public async Task<Result<bool>> UploadCloud(long id)
{
return Result<bool>.Success(null);
}
/// <summary>
/// 充电订单上报云端
/// </summary>
/// <returns></returns>
[HttpGet("UploadCloud/{id}")]
public async Task<Result<bool>> UploadCloud(long id)
{
return Result<bool>.Success(null);
}

@ -1,27 +1,56 @@
using AutoMapper;
using Entity.Api.Req;
using Entity.Api.Resp;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Station;
namespace WebStarter.Controllers;
/**
*
*/
/// <summary>
/// 换电订
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class SwapOrderController : ControllerBase
{
private readonly SwapOrderService swapOrderService;
public SwapOrderController(SwapOrderService swapOrderService)
{
this.swapOrderService = swapOrderService;
}
/// <summary>
/// 分页数据
/// 查询分页数据
/// </summary>
/// <returns></returns>
[HttpPost("QueryPage")]
public async Task<Result<PageResult<SwapOrderResp>>> QueryPage([FromBody] QuerySwapOrderPageReq req)
{
return Result<PageResult<SwapOrderResp>>.Success(null);
return Result<PageResult<SwapOrderResp>>.Success(swapOrderService.QuerySwapOrder(req));
}
/// <summary>
/// 新增
/// </summary>
/// <returns></returns>
[HttpPost("Add")]
public async Task<Result<bool>> Add([FromBody] AddSwapOrderReq req)
{
//映射数据
var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrder, ModifySwapOrderReq>().ReverseMap());
IMapper mapper = config.CreateMapper();
SwapOrder swapOrder = mapper.Map<SwapOrder>(req);
if (swapOrderService.Insert(swapOrder) != 0)
{
return Result<bool>.Success("新增成功");
}
else
{
return Result<bool>.Fail("新增失败");
}
}
/// <summary>
@ -32,32 +61,39 @@ public class SwapOrderController : ControllerBase
[HttpPost("Modify")]
public async Task<Result<bool>> Modify([FromBody] ModifySwapOrderReq req)
{
return Result<bool>.Success(null);
//映射数据
var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrder, ModifySwapOrderReq>().ReverseMap());
IMapper mapper = config.CreateMapper();
SwapOrder swapOrder = mapper.Map<SwapOrder>(req);
if (swapOrderService.Update(swapOrder))
{
return Result<bool>.Success("更改成功");
}
else
{
return Result<bool>.Fail("更改失败");
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids">ids 订单列表</param>
/// <param name="ids">ids id列表</param>
/// <returns></returns>
[HttpPost("DeleteByIds")]
public async Task<Result<bool>> DeleteByIds([FromBody] List<long> ids)
{
return Result<bool>.Success(null);
if (swapOrderService.DeleteByIds(ids))
{
return Result<bool>.Success("删除成功");
}
else
{
return Result<bool>.Fail("删除失败");
}
}
/// <summary>
/// 换电订单上报云端
/// </summary>
/// <returns></returns>
[HttpPost("Add")]
public async Task<Result<bool>> Add([FromBody] AddSwapOrderReq req)
{
return Result<bool>.Success(null);
}
/// <summary>
/// 换电订单上报云端

Loading…
Cancel
Save