|
|
|
@ -30,15 +30,17 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
private readonly SwapOrderStepService swapOrderStepService;
|
|
|
|
|
private readonly SwapOrderReportCloudRepository swapOrderReportCloudRepository;
|
|
|
|
|
private readonly VehicleService vehicleService;
|
|
|
|
|
private readonly BaseVehicleRepository _baseVehicleRepository;
|
|
|
|
|
|
|
|
|
|
public SwapOrderController(SwapOrderService swapOrderService, SwapOrderBatteryService swapOrderBatteryService,
|
|
|
|
|
SwapOrderStepService swapOrderStepService,SwapOrderReportCloudRepository swapOrderReportCloudRepository)
|
|
|
|
|
SwapOrderStepService swapOrderStepService,SwapOrderReportCloudRepository swapOrderReportCloudRepository,BaseVehicleRepository baseVehicleRepository
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
this.swapOrderService = swapOrderService;
|
|
|
|
|
this.swapOrderBatteryService = swapOrderBatteryService;
|
|
|
|
|
this.swapOrderStepService = swapOrderStepService;
|
|
|
|
|
this.swapOrderReportCloudRepository = swapOrderReportCloudRepository;
|
|
|
|
|
|
|
|
|
|
_baseVehicleRepository = baseVehicleRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -58,8 +60,27 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
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>();
|
|
|
|
|
// 查询车辆的部门
|
|
|
|
|
List<BaseVehicle> vehicleList = await _baseVehicleRepository
|
|
|
|
|
.Queryable()
|
|
|
|
|
.In(vehicle => vehicle.VehicleNo, vehicleNoList)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
// 给换电订单赋值车的公司和部门
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -363,91 +384,157 @@ public class SwapOrderController : ControllerBase
|
|
|
|
|
var config = new MapperConfiguration(cfg =>
|
|
|
|
|
{
|
|
|
|
|
cfg.CreateMap<SwapOrderBatteryResp, SwapOrderBattery>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<SwapOrderDto, SwapOrder>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<SwapOrderDto2, SwapOrder>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<SwapOrderDto, SwapOrderResp>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<SwapOrderResp, SwapOrder>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<SwapOrderDto2, SwapOrderResp>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<SwapLoseOrderDto, SwapOrderResp>().ReverseMap();
|
|
|
|
|
cfg.CreateMap<SwapLoseOrderDto2, SwapOrderResp>().ReverseMap();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
IMapper mapper = config.CreateMapper();
|
|
|
|
|
|
|
|
|
|
List<SwapOrderBatteryResp> swapOrderBattery = mapper.Map<List<SwapOrderBatteryResp>>(batteryList);
|
|
|
|
|
List<SwapOrderDto> list = mapper.Map<List<SwapOrderDto>>(orderList);
|
|
|
|
|
List<SwapOrderDto2> list2 = mapper.Map<List<SwapOrderDto2>>(orderList);
|
|
|
|
|
|
|
|
|
|
// 将电池数据添加到换电订单数据中
|
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
|
// 换电订单
|
|
|
|
|
List<SwapOrderResp> swapOrderResp = mapper.Map<List<SwapOrderResp>>(orderList);
|
|
|
|
|
|
|
|
|
|
List<string> vehicleNoList = swapOrderResp.Select(resp => resp.VehicleNo).ToList() ?? new List<string>();
|
|
|
|
|
// 查询车辆的部门
|
|
|
|
|
List<BaseVehicle> vehicleList = await _baseVehicleRepository
|
|
|
|
|
.Queryable()
|
|
|
|
|
.In(vehicle => vehicle.VehicleNo, vehicleNoList)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
// 给换电订单赋值车的公司和部门
|
|
|
|
|
foreach (var swapOrder in swapOrderResp)
|
|
|
|
|
{
|
|
|
|
|
if (language == "en")
|
|
|
|
|
var matchingVehicle = vehicleList.FirstOrDefault(v => v.VehicleNo == swapOrder.VehicleNo);
|
|
|
|
|
|
|
|
|
|
if (matchingVehicle != null)
|
|
|
|
|
{
|
|
|
|
|
SwapOrderDto2 dto = list2[i];
|
|
|
|
|
swapOrder.Company = matchingVehicle.Company;
|
|
|
|
|
swapOrder.Departments = matchingVehicle.Departments;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (req.SwapResult == 0 || req.SwapResult == 1)
|
|
|
|
|
{
|
|
|
|
|
List<SwapOrderDto> list = mapper.Map<List<SwapOrderDto>>(swapOrderResp);
|
|
|
|
|
List<SwapOrderDto2> list2 = mapper.Map<List<SwapOrderDto2>>(swapOrderResp);
|
|
|
|
|
|
|
|
|
|
SwapOrderBatteryResp? swapOrderBatteryResp =
|
|
|
|
|
swapOrderBattery.FirstOrDefault(battery => battery.SwapOrderSn == dto.Sn);
|
|
|
|
|
if (swapOrderBatteryResp != null)
|
|
|
|
|
// 将电池数据添加到换电订单数据中
|
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (language == "en")
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatterySoc = swapOrderBatteryResp.DownBatterySoc;
|
|
|
|
|
dto.DownBatteryRealSoc = swapOrderBatteryResp.DownBatteryRealSoc;
|
|
|
|
|
dto.DownBatteryLastSoc = swapOrderBatteryResp.DownBatteryLastSoc;
|
|
|
|
|
dto.DownBatteryNo = swapOrderBatteryResp.DownBatteryNo;
|
|
|
|
|
dto.UpBatteryNo = swapOrderBatteryResp.UpBatteryNo;
|
|
|
|
|
dto.UpBatterySoc = swapOrderBatteryResp.UpBatterySoc;
|
|
|
|
|
dto.UpBatteryRealSoc = swapOrderBatteryResp.UpBatteryRealSoc;
|
|
|
|
|
dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo;
|
|
|
|
|
dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo;
|
|
|
|
|
dto.StationNumber = StaticStationInfo.StationNumber;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatteryElectricQuantity = ((double)dto.DownBatterySoc * 3.75).ToString();
|
|
|
|
|
dto.UpBatteryElectricQuantity = ((double)dto.UpBatterySoc * 3.75).ToString();
|
|
|
|
|
double ElectricQuantity = ((float)(dto.UpBatterySoc - dto.DownBatterySoc)) * 3.75;
|
|
|
|
|
dto.ElectricQuantity = ElectricQuantity.ToString();
|
|
|
|
|
SwapOrderDto2 dto = list2[i];
|
|
|
|
|
|
|
|
|
|
SwapOrderBatteryResp? swapOrderBatteryResp =
|
|
|
|
|
swapOrderBattery.FirstOrDefault(battery => battery.SwapOrderSn == dto.Sn);
|
|
|
|
|
if (swapOrderBatteryResp != null)
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatterySoc = swapOrderBatteryResp.DownBatterySoc;
|
|
|
|
|
dto.DownBatteryNo = swapOrderBatteryResp.DownBatteryNo;
|
|
|
|
|
dto.UpBatteryNo = swapOrderBatteryResp.UpBatteryNo;
|
|
|
|
|
dto.UpBatterySoc = swapOrderBatteryResp.UpBatterySoc;
|
|
|
|
|
dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo;
|
|
|
|
|
dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatteryElectricQuantity = ((double)dto.DownBatterySoc * 3.75).ToString();
|
|
|
|
|
dto.UpBatteryElectricQuantity = ((double)dto.UpBatterySoc * 3.75).ToString();
|
|
|
|
|
double ElectricQuantity = ((float)(dto.UpBatterySoc - dto.DownBatterySoc)) * 3.75;
|
|
|
|
|
dto.ElectricQuantity = ElectricQuantity.ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SwapOrderDto dto = list[i];
|
|
|
|
|
SwapOrderBatteryResp? swapOrderBatteryResp =
|
|
|
|
|
swapOrderBattery.FirstOrDefault(battery => battery.SwapOrderSn == dto.Sn);
|
|
|
|
|
if (swapOrderBatteryResp != null)
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatterySoc = swapOrderBatteryResp.DownBatterySoc;
|
|
|
|
|
dto.DownBatteryNo = swapOrderBatteryResp.DownBatteryNo;
|
|
|
|
|
dto.UpBatteryNo = swapOrderBatteryResp.UpBatteryNo;
|
|
|
|
|
dto.UpBatterySoc = swapOrderBatteryResp.UpBatterySoc;
|
|
|
|
|
dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo;
|
|
|
|
|
dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatteryElectricQuantity = ((double)dto.DownBatterySoc * 3.75).ToString();
|
|
|
|
|
dto.UpBatteryElectricQuantity = ((double)dto.UpBatterySoc * 3.75).ToString();
|
|
|
|
|
double ElectricQuantity = ((float)(dto.UpBatterySoc - dto.DownBatterySoc)) * 3.75;
|
|
|
|
|
dto.ElectricQuantity = ElectricQuantity.ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
IExcelExporter excelExporter = new ExcelExporter();
|
|
|
|
|
var res = language == "en"
|
|
|
|
|
? await excelExporter.ExportAsByteArray(list2)
|
|
|
|
|
: await excelExporter.ExportAsByteArray(list);
|
|
|
|
|
|
|
|
|
|
return new FileStreamResult(new MemoryStream(res), "application/octet-stream")
|
|
|
|
|
{
|
|
|
|
|
SwapOrderDto dto = list[i];
|
|
|
|
|
SwapOrderBatteryResp? swapOrderBatteryResp =
|
|
|
|
|
swapOrderBattery.FirstOrDefault(battery => battery.SwapOrderSn == dto.Sn);
|
|
|
|
|
if (swapOrderBatteryResp != null)
|
|
|
|
|
FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") +
|
|
|
|
|
(language == "en" ? "_Swap_Orders.xlsx" : "2号站换电记录.xlsx")
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
List<SwapLoseOrderDto> list = mapper.Map<List<SwapLoseOrderDto>>(swapOrderResp);
|
|
|
|
|
List<SwapLoseOrderDto2> list2 = mapper.Map<List<SwapLoseOrderDto2>>(swapOrderResp);
|
|
|
|
|
|
|
|
|
|
// 将电池数据添加到换电订单数据中
|
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (language == "en")
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatterySoc = swapOrderBatteryResp.DownBatterySoc;
|
|
|
|
|
dto.DownBatteryRealSoc = swapOrderBatteryResp.DownBatteryRealSoc;
|
|
|
|
|
dto.DownBatteryLastSoc = swapOrderBatteryResp.DownBatteryLastSoc;
|
|
|
|
|
dto.DownBatteryNo = swapOrderBatteryResp.DownBatteryNo;
|
|
|
|
|
dto.UpBatteryNo = swapOrderBatteryResp.UpBatteryNo;
|
|
|
|
|
dto.UpBatterySoc = swapOrderBatteryResp.UpBatterySoc;
|
|
|
|
|
dto.UpBatteryRealSoc = swapOrderBatteryResp.UpBatteryRealSoc;
|
|
|
|
|
dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo;
|
|
|
|
|
dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo;
|
|
|
|
|
dto.StationNumber = StaticStationInfo.StationNumber;
|
|
|
|
|
try
|
|
|
|
|
SwapLoseOrderDto2 dto = list2[i];
|
|
|
|
|
|
|
|
|
|
SwapOrderBatteryResp? swapOrderBatteryResp =
|
|
|
|
|
swapOrderBattery.FirstOrDefault(battery => battery.SwapOrderSn == dto.Sn);
|
|
|
|
|
if (swapOrderBatteryResp != null)
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatteryElectricQuantity = ((double)dto.DownBatterySoc * 3.75).ToString();
|
|
|
|
|
dto.UpBatteryElectricQuantity = ((double)dto.UpBatterySoc * 3.75).ToString();
|
|
|
|
|
double ElectricQuantity = ((float)(dto.UpBatterySoc - dto.DownBatterySoc)) * 3.75;
|
|
|
|
|
dto.ElectricQuantity = ElectricQuantity.ToString();
|
|
|
|
|
dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo;
|
|
|
|
|
dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SwapLoseOrderDto dto = list[i];
|
|
|
|
|
SwapOrderBatteryResp? swapOrderBatteryResp =
|
|
|
|
|
swapOrderBattery.FirstOrDefault(battery => battery.SwapOrderSn == dto.Sn);
|
|
|
|
|
if (swapOrderBatteryResp != null)
|
|
|
|
|
{
|
|
|
|
|
dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo;
|
|
|
|
|
dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IExcelExporter excelExporter = new ExcelExporter();
|
|
|
|
|
var res = language == "en"
|
|
|
|
|
? await excelExporter.ExportAsByteArray(list2)
|
|
|
|
|
: await excelExporter.ExportAsByteArray(list);
|
|
|
|
|
IExcelExporter excelExporter = new ExcelExporter();
|
|
|
|
|
var res = language == "en"
|
|
|
|
|
? await excelExporter.ExportAsByteArray(list2)
|
|
|
|
|
: await excelExporter.ExportAsByteArray(list);
|
|
|
|
|
|
|
|
|
|
return new FileStreamResult(new MemoryStream(res), "application/octet-stream")
|
|
|
|
|
{
|
|
|
|
|
FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") +
|
|
|
|
|
(language == "en" ? "_Swap_Orders.xlsx" : "2号站换电记录.xlsx")
|
|
|
|
|
};
|
|
|
|
|
return new FileStreamResult(new MemoryStream(res), "application/octet-stream")
|
|
|
|
|
{
|
|
|
|
|
FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") +
|
|
|
|
|
(language == "en" ? "_Swap_Lose_Orders.xlsx" : "2号站换电失败记录.xlsx")
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|