|
|
@ -4,7 +4,9 @@ using Entity.Api.Resp;
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
|
|
|
|
using Service.Station;
|
|
|
|
using Service.Station;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WebStarter.Controllers;
|
|
|
|
namespace WebStarter.Controllers;
|
|
|
|
|
|
|
|
|
|
|
@ -16,10 +18,14 @@ namespace WebStarter.Controllers;
|
|
|
|
public class SwapOrderController : ControllerBase
|
|
|
|
public class SwapOrderController : ControllerBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly SwapOrderService swapOrderService;
|
|
|
|
private readonly SwapOrderService swapOrderService;
|
|
|
|
|
|
|
|
private readonly SwapOrderBatteryService swapOrderBatteryService;
|
|
|
|
|
|
|
|
private readonly SwapOrderStepService swapOrderStepService;
|
|
|
|
|
|
|
|
|
|
|
|
public SwapOrderController(SwapOrderService swapOrderService)
|
|
|
|
public SwapOrderController(SwapOrderService swapOrderService, SwapOrderBatteryService swapOrderBatteryService, SwapOrderStepService swapOrderStepService)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.swapOrderService = swapOrderService;
|
|
|
|
this.swapOrderService = swapOrderService;
|
|
|
|
|
|
|
|
this.swapOrderBatteryService = swapOrderBatteryService;
|
|
|
|
|
|
|
|
this.swapOrderStepService = swapOrderStepService;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 查询分页数据
|
|
|
|
/// 查询分页数据
|
|
|
@ -28,8 +34,46 @@ public class SwapOrderController : ControllerBase
|
|
|
|
[HttpPost("QueryPage")]
|
|
|
|
[HttpPost("QueryPage")]
|
|
|
|
public async Task<Result<PageResult<SwapOrderResp>>> QueryPage([FromBody] QuerySwapOrderPageReq req)
|
|
|
|
public async Task<Result<PageResult<SwapOrderResp>>> QueryPage([FromBody] QuerySwapOrderPageReq req)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var swapOrderResp = swapOrderService.QuerySwapOrder(req);
|
|
|
|
|
|
|
|
|
|
|
|
return Result<PageResult<SwapOrderResp>>.Success(swapOrderService.QuerySwapOrder(req));
|
|
|
|
//获取所有订单号
|
|
|
|
|
|
|
|
var orderSns = swapOrderResp.Rows.Select(row => row.Sn).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//电池不要了
|
|
|
|
|
|
|
|
////查询订单电池数据
|
|
|
|
|
|
|
|
//List< SwapOrderBattery> batteryList = swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////映射
|
|
|
|
|
|
|
|
//var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrderBatteryResp,SwapOrderBattery > ().ReverseMap());
|
|
|
|
|
|
|
|
//IMapper mapper = config.CreateMapper();
|
|
|
|
|
|
|
|
//List<SwapOrderBatteryResp> swapOrderBattery = mapper.Map<List<SwapOrderBatteryResp>>(batteryList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////将电池数据添加到换电订单数据中
|
|
|
|
|
|
|
|
//for (int i = 0; i < swapOrderResp.Rows.Count; i++)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// swapOrderResp.Rows[i].BatteryList = new List<SwapOrderBatteryResp>();
|
|
|
|
|
|
|
|
// swapOrderResp.Rows[i].BatteryList.AddRange(swapOrderBattery.Where(battery => battery.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList());
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询订单步序数据
|
|
|
|
|
|
|
|
var stepList = swapOrderStepService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
|
|
|
|
|
|
|
|
stepList = stepList.OrderBy(s => s.Sort).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//映射
|
|
|
|
|
|
|
|
var config2 = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrderStep,SwapOrderStepResp>().ReverseMap());
|
|
|
|
|
|
|
|
IMapper mapper2 = config2.CreateMapper();
|
|
|
|
|
|
|
|
List<SwapOrderStepResp> swapOrderStep = mapper2.Map<List<SwapOrderStepResp>>(stepList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将步序数据添加到换电订单数据中
|
|
|
|
|
|
|
|
for (int i = 0; i < swapOrderResp.Rows.Count; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
swapOrderResp.Rows[i].StepList = new List<SwapOrderStepResp>();
|
|
|
|
|
|
|
|
swapOrderResp.Rows[i].StepList.AddRange(swapOrderStep.Where(step => step.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result<PageResult<SwapOrderResp>>.Success(swapOrderResp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 新增
|
|
|
|
/// 新增
|
|
|
@ -39,10 +83,17 @@ public class SwapOrderController : ControllerBase
|
|
|
|
public async Task<Result<bool>> Add([FromBody] AddSwapOrderReq req)
|
|
|
|
public async Task<Result<bool>> Add([FromBody] AddSwapOrderReq req)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//映射数据
|
|
|
|
//映射数据
|
|
|
|
var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrder, ModifySwapOrderReq>().ReverseMap());
|
|
|
|
var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrder, AddSwapOrderReq>().ReverseMap());
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
SwapOrder swapOrder = mapper.Map<SwapOrder>(req);
|
|
|
|
SwapOrder swapOrder = mapper.Map<SwapOrder>(req);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var swap = swapOrderService.QueryByClause(u => u.Sn == req.Sn);
|
|
|
|
|
|
|
|
if (swap != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail("新增失败!订单号重复");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
if (swapOrderService.Insert(swapOrder) != 0)
|
|
|
|
if (swapOrderService.Insert(swapOrder) != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Result<bool>.Success("新增成功");
|
|
|
|
return Result<bool>.Success("新增成功");
|
|
|
@ -51,6 +102,10 @@ public class SwapOrderController : ControllerBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Result<bool>.Fail("新增失败");
|
|
|
|
return Result<bool>.Fail("新增失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|