换电导出修改

master
tq 2 months ago
parent ff17b407d5
commit 8b6182cc55

@ -54,7 +54,25 @@ public class SwapOrderDto
[ExporterHeader(DisplayName = "所属部门", IsBold = true)]
public string? Departments {get;set;}
/// <summary>
/// Desc:换电类型:;1自动换电;2手动换电
/// Default:0
/// Nullable:True
/// </summary>
[ExporterHeader(DisplayName = "换电类型", IsBold = true)]
public string SwapWayDisplay
{
get
{
return SwapWay switch
{
1 => "自动换电",
2 => "手动换电",
3 => "半自动换电",
_ => "未知"
};
}
}
/// <summary>
/// Desc:换电类型:;1自动换电;2手动换电
/// Default:0
@ -149,8 +167,18 @@ public class SwapOrderDto
/// Default:
/// Nullable:True
/// </summary>
[ExporterHeader(DisplayName = "soc%", IsBold = true)]
[ExporterHeader(IsIgnore = true)]
public decimal? UpBatterySoc { get; set; }
[ExporterHeader(DisplayName = "soc", IsBold = true)]
public string? UpBatterySocDto
{
get
{
return UpBatterySoc.HasValue ? $"{UpBatterySoc.Value}%" : null;
}
}
/// <summary>
@ -182,10 +210,19 @@ public class SwapOrderDto
/// Default:
/// Nullable:True
/// </summary>
[ExporterHeader(DisplayName = "soc%", IsBold = true)]
[ExporterHeader(IsIgnore = true)]
public decimal? DownBatterySoc { get; set; }
[ExporterHeader(DisplayName = "soc", IsBold = true)]
public string? DownBatterySocDto
{
get
{
return DownBatterySoc.HasValue ? $"{DownBatterySoc.Value}%" : null;
}
}
/// <summary>
/// 电量差
@ -227,23 +264,9 @@ public class SwapOrderDto
[ExporterHeader(DisplayName = "总费用", IsBold = true)]
public decimal? TotalFee { get; set; }
/// <summary>
/// Desc:换电类型:;1自动换电;2手动换电
/// Default:0
/// Nullable:True
/// </summary>
[ExporterHeader(DisplayName = "备注", IsBold = true)]
public string SwapWayDisplay
{
get
{
return SwapWay switch
{
1 => "自动换电",
2 => "手动换电",
3 => "半自动换电",
_ => "未知"
};
}
}
[ExporterHeader(DisplayName = "手动操作", IsBold = true)]
public string? ManualStep { get; set; }
}

@ -120,7 +120,7 @@ public class SwapOrderDto2
[ExporterHeader(DisplayName = "TOTAL COST", IsBold = true)]
public decimal? TotalFee { get; set; }
[ExporterHeader(DisplayName = "REMARK", IsBold = true)]
[ExporterHeader(DisplayName = "Swap Type", IsBold = true)]
public string SwapWayDisplay
{
get
@ -134,4 +134,7 @@ public class SwapOrderDto2
};
}
}
[ExporterHeader(DisplayName = "MANUAL OPERATION", IsBold = true)]
public string? ManualStep { get; set; }
}

@ -159,8 +159,7 @@ public class SwapOrderController : ControllerBase
var swapOrderStepResps = swapOrderStep.Where(step => step.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList();
swapOrderResp.Rows[i].StepList
.AddRange(swapOrderStepResps);
;
swapOrderResp.Rows[i].ManualStep = String.Join(",",
swapOrderStepResps.Where(i => i.StepType == (int)SwapConstant.StepType.MANUAL).Select(i => i.StepDesc)
.ToList());
@ -394,6 +393,7 @@ public class SwapOrderController : ControllerBase
cfg.CreateMap<SwapOrderDto2, SwapOrderResp>().ReverseMap();
cfg.CreateMap<SwapLoseOrderDto, SwapOrderResp>().ReverseMap();
cfg.CreateMap<SwapLoseOrderDto2, SwapOrderResp>().ReverseMap();
cfg.CreateMap<SwapOrderStep, SwapOrderStepResp>().ReverseMap();
});
IMapper mapper = config.CreateMapper();
@ -427,19 +427,38 @@ public class SwapOrderController : ControllerBase
.Queryable()
.In(vehicle => vehicle.VehicleNo, vehicleNoList)
.ToListAsync();
var stepList = swapOrderStepService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
stepList = stepList.OrderBy(s => s.Sort).ToList();
List<SwapOrderStepResp> swapOrderStep = mapper.Map<List<SwapOrderStepResp>>(stepList);
//将步序数据添加到换电订单数据中
// 给换电订单赋值车的公司和部门
foreach (var swapOrder in swapOrderResp)
for (int i = 0; i < swapOrderResp.Count; i++)
{
var matchingVehicle = vehicleList.FirstOrDefault(v => v.VehicleNo == swapOrder.VehicleNo);
// 初始化 StepList
swapOrderResp[i].StepList = new List<SwapOrderStepResp>();
// 获取与当前订单匹配的步骤信息
var swapOrderStepResps = swapOrderStep.Where(step => step.SwapOrderSn == swapOrderResp[i].Sn).ToList();
swapOrderResp[i].StepList.AddRange(swapOrderStepResps);
// 设置 ManualStep 字段
swapOrderResp[i].ManualStep = string.Join(",",
swapOrderStepResps.Where(step => step.StepType == (int)SwapConstant.StepType.MANUAL)
.Select(step => step.StepDesc)
.ToList());
// 查找匹配的车辆信息并赋值公司和部门字段
var matchingVehicle = vehicleList.FirstOrDefault(v => v.VehicleNo == swapOrderResp[i].VehicleNo);
if (matchingVehicle != null)
{
swapOrder.Company = matchingVehicle.Company;
swapOrder.Departments = matchingVehicle.Departments;
swapOrderResp[i].Company = matchingVehicle.Company;
swapOrderResp[i].Departments = matchingVehicle.Departments;
}
}
if (req.SwapResult == 0 || req.SwapResult == 1)
{
List<SwapOrderDto> list = mapper.Map<List<SwapOrderDto>>(swapOrderResp);

Loading…
Cancel
Save