|
|
|
@ -3,6 +3,7 @@ using System.Transactions;
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
using Entity.Api.Req;
|
|
|
|
|
using Entity.Api.Resp;
|
|
|
|
|
using Entity.Constant;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using Entity.Dto;
|
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
@ -23,7 +24,6 @@ namespace WebStarter.Controllers;
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
public class SwapOrderController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(SwapOrderController));
|
|
|
|
|
private readonly SwapOrderService swapOrderService;
|
|
|
|
|
private readonly SwapOrderBatteryService swapOrderBatteryService;
|
|
|
|
@ -33,8 +33,9 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
private readonly BaseVehicleRepository _baseVehicleRepository;
|
|
|
|
|
|
|
|
|
|
public SwapOrderController(SwapOrderService swapOrderService, SwapOrderBatteryService swapOrderBatteryService,
|
|
|
|
|
SwapOrderStepService swapOrderStepService,SwapOrderReportCloudRepository swapOrderReportCloudRepository,BaseVehicleRepository baseVehicleRepository
|
|
|
|
|
)
|
|
|
|
|
SwapOrderStepService swapOrderStepService, SwapOrderReportCloudRepository swapOrderReportCloudRepository,
|
|
|
|
|
BaseVehicleRepository baseVehicleRepository
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
this.swapOrderService = swapOrderService;
|
|
|
|
|
this.swapOrderBatteryService = swapOrderBatteryService;
|
|
|
|
@ -51,17 +52,18 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
public async Task<Result<PageResult<SwapOrderResp>>> QueryPage([FromBody] QuerySwapOrderPageReq req)
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"SwapOrderController QueryPage req={req}");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(req.DownBatteryNo)||!string.IsNullOrEmpty(req.UpBatteryNo))
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(req.DownBatteryNo) || !string.IsNullOrEmpty(req.UpBatteryNo))
|
|
|
|
|
{
|
|
|
|
|
var result = BatteryCodeList(req);
|
|
|
|
|
return Result<PageResult<SwapOrderResp>>.Success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.Info($"查询换电订单 SwapOrderController start QueryPage swapOrderService.QuerySwapOrder req={req}");
|
|
|
|
|
var swapOrderResp = swapOrderService.QuerySwapOrder(req);
|
|
|
|
|
Log.Info($"查询换电订单 SwapOrderController end QueryPage swapOrderService.QuerySwapOrder req={req}");
|
|
|
|
|
PackageSwapOrder(swapOrderResp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SwapOrderResp>? list = swapOrderResp.Rows;
|
|
|
|
|
List<string> vehicleNoList = list?.Select(resp => resp.VehicleNo).ToList() ?? new List<string>();
|
|
|
|
|
// 查询车辆的部门
|
|
|
|
@ -74,16 +76,17 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
foreach (var swapOrder in list)
|
|
|
|
|
{
|
|
|
|
|
var matchingVehicle = vehicleList.FirstOrDefault(v => v.VehicleNo == swapOrder.VehicleNo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingVehicle != null)
|
|
|
|
|
{
|
|
|
|
|
swapOrder.Company = matchingVehicle.Company;
|
|
|
|
|
swapOrder.Departments = matchingVehicle.Departments;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Result<PageResult<SwapOrderResp>>.Success(swapOrderResp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// app查询换电订单
|
|
|
|
|
/// </summary>
|
|
|
|
@ -93,11 +96,11 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
public async Task<Result<PageResult<SwapOrderResp>>> AppSwapOrder([FromBody] QuerySwapOrderPageReq req)
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"SwapOrderController QueryPage req={req}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.Info($"查询换电订单 SwapOrderController start QueryPage swapOrderService.QuerySwapOrder req={req}");
|
|
|
|
|
var swapOrderResp = swapOrderService.AppQuerySwapOrder(req);
|
|
|
|
|
Log.Info($"查询换电订单 SwapOrderController end QueryPage swapOrderService.QuerySwapOrder req={req}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PackageSwapOrder(swapOrderResp);
|
|
|
|
|
return Result<PageResult<SwapOrderResp>>.Success(swapOrderResp);
|
|
|
|
|
}
|
|
|
|
@ -106,31 +109,28 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
//获取所有订单号
|
|
|
|
|
var orderSns = swapOrderResp.Rows.Select(row => row.Sn).ToList();
|
|
|
|
|
Log.Info($"查询上报云平台次数 SwapOrderController start QueryPage swapOrderService.QueryReportCloudNumBySn req={orderSns}");
|
|
|
|
|
//查询上报云平台次数
|
|
|
|
|
//Dictionary<string, int?> queryReportCloudNumBySn = swapOrderService.QueryReportCloudNumBySn(orderSns);
|
|
|
|
|
|
|
|
|
|
Log.Info($"查询上报云平台次数 SwapOrderController end QueryPage swapOrderService.QueryReportCloudNumBySn req={orderSns}");
|
|
|
|
|
Log.Info($"查询订单电池数据 SwapOrderController start QueryPage swapOrderBatteryService.QueryListByClause req={orderSns}");
|
|
|
|
|
|
|
|
|
|
////查询订单电池数据
|
|
|
|
|
List<SwapOrderBattery> batteryList =
|
|
|
|
|
swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
|
|
|
|
|
Log.Info($"查询订单电池数据 SwapOrderController end QueryPage swapOrderBatteryService.QueryListByClause req={orderSns}");
|
|
|
|
|
//映射
|
|
|
|
|
var config =
|
|
|
|
|
new MapperConfiguration(cfg => cfg.CreateMap<SwapOrderBatteryResp, SwapOrderBattery>().ReverseMap());
|
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SwapOrderBatteryResp> swapOrderBattery = mapper.Map<List<SwapOrderBatteryResp>>(batteryList);
|
|
|
|
|
|
|
|
|
|
Log.Info($"查询公里数 SwapOrderController start QueryPage swapOrderReportCloudRepository.QueryListByClause req={orderSns}");
|
|
|
|
|
List<SwapOrderReportCloud> swapOrderReportClouds = swapOrderReportCloudRepository.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
|
|
|
|
|
Log.Info($"查询公里数 SwapOrderController end QueryPage swapOrderReportCloudRepository.QueryListByClause req={orderSns}");
|
|
|
|
|
|
|
|
|
|
List<SwapOrderReportCloud> swapOrderReportClouds =
|
|
|
|
|
swapOrderReportCloudRepository.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将电池数据添加到换电订单数据中
|
|
|
|
|
foreach (var row in swapOrderResp.Rows)
|
|
|
|
|
{
|
|
|
|
|
row.BatteryList = swapOrderBattery.Where(battery => battery.SwapOrderSn == row.Sn).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var matchingReport = swapOrderReportClouds.FirstOrDefault(r => r.SwapOrderSn == row.Sn);
|
|
|
|
|
if (matchingReport != null)
|
|
|
|
@ -141,44 +141,48 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Log.Info($"查询订单步序数据 SwapOrderController start QueryPage swapOrderStepService.QueryListByClause req={orderSns}");
|
|
|
|
|
|
|
|
|
|
//查询订单步序数据
|
|
|
|
|
var stepList = swapOrderStepService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
|
|
|
|
|
Log.Info($"查询订单步序数据 SwapOrderController end QueryPage swapOrderStepService.QueryListByClause req={orderSns}");
|
|
|
|
|
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>();
|
|
|
|
|
var swapOrderStepResps = swapOrderStep.Where(step => step.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList();
|
|
|
|
|
swapOrderResp.Rows[i].StepList
|
|
|
|
|
.AddRange(swapOrderStep.Where(step => step.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList());
|
|
|
|
|
.AddRange(swapOrderStepResps);
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
swapOrderResp.Rows[i].ManualStep = String.Join(",",
|
|
|
|
|
swapOrderStepResps.Where(i => i.StepType == (int)SwapConstant.StepType.MANUAL).Select(i => i.StepDesc)
|
|
|
|
|
.ToList());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private PageResult<SwapOrderResp> BatteryCodeList(QuerySwapOrderPageReq req)
|
|
|
|
|
{
|
|
|
|
|
PageResult<SwapOrderBatteryResp> batteryCodeList = swapOrderBatteryService.QuerySwapOrderBatteryList(req);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var batteryOrderSn = batteryCodeList.Rows.Select(row => row.SwapOrderSn).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SwapOrder> swapOrderRespList = swapOrderService.QueryListByClause(u => batteryOrderSn.Contains(u.Sn));
|
|
|
|
|
//获取所有订单号
|
|
|
|
|
var orderSns = swapOrderRespList.Select(row => row.Sn).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////查询订单电池数据
|
|
|
|
|
List<SwapOrderBattery> batteryList =
|
|
|
|
|
swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var config = new MapperConfiguration(cfg =>
|
|
|
|
|
{
|
|
|
|
|
cfg.CreateMap<SwapOrderResp, SwapOrder>().ReverseMap();
|
|
|
|
@ -186,12 +190,13 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
});
|
|
|
|
|
//映射
|
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SwapOrderBatteryResp> swapOrderBattery = mapper.Map<List<SwapOrderBatteryResp>>(batteryList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SwapOrderResp> swapOrderResp = mapper.Map<List<SwapOrderResp>>(swapOrderRespList);
|
|
|
|
|
|
|
|
|
|
List<SwapOrderReportCloud> swapOrderReportClouds = swapOrderReportCloudRepository.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
|
|
|
|
|
|
|
|
|
|
List<SwapOrderReportCloud> swapOrderReportClouds =
|
|
|
|
|
swapOrderReportCloudRepository.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将电池数据添加到换电订单数据中
|
|
|
|
@ -496,7 +501,6 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
// 将电池数据添加到换电订单数据中
|
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (language == "en")
|
|
|
|
|
{
|
|
|
|
|
SwapLoseOrderDto2 dto = list2[i];
|
|
|
|
@ -507,7 +511,6 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo;
|
|
|
|
|
dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -519,7 +522,6 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo;
|
|
|
|
|
dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -536,6 +538,4 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|