diff --git a/Entity/Dto/SwapOrderDto.cs b/Entity/Dto/SwapOrderDto.cs index c43d112..ce23b28 100644 --- a/Entity/Dto/SwapOrderDto.cs +++ b/Entity/Dto/SwapOrderDto.cs @@ -54,7 +54,25 @@ public class SwapOrderDto [ExporterHeader(DisplayName = "所属部门", IsBold = true)] public string? Departments {get;set;} - + /// + /// Desc:换电类型:;1自动换电;2手动换电 + /// Default:0 + /// Nullable:True + /// + [ExporterHeader(DisplayName = "换电类型", IsBold = true)] + public string SwapWayDisplay + { + get + { + return SwapWay switch + { + 1 => "自动换电", + 2 => "手动换电", + 3 => "半自动换电", + _ => "未知" + }; + } + } /// /// Desc:换电类型:;1自动换电;2手动换电 /// Default:0 @@ -149,8 +167,18 @@ public class SwapOrderDto /// Default: /// Nullable:True /// - [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; + } + } /// @@ -182,10 +210,19 @@ public class SwapOrderDto /// Default: /// Nullable:True /// - [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; + } + } + /// /// 电量差 @@ -227,23 +264,9 @@ public class SwapOrderDto [ExporterHeader(DisplayName = "总费用", IsBold = true)] public decimal? TotalFee { get; set; } - /// - /// Desc:换电类型:;1自动换电;2手动换电 - /// Default:0 - /// Nullable:True - /// - [ExporterHeader(DisplayName = "备注", IsBold = true)] - public string SwapWayDisplay - { - get - { - return SwapWay switch - { - 1 => "自动换电", - 2 => "手动换电", - 3 => "半自动换电", - _ => "未知" - }; - } - } + + [ExporterHeader(DisplayName = "手动操作", IsBold = true)] + public string? ManualStep { get; set; } + + } \ No newline at end of file diff --git a/Entity/Dto/SwapOrderDto2.cs b/Entity/Dto/SwapOrderDto2.cs index 4d9d406..b86a1a9 100644 --- a/Entity/Dto/SwapOrderDto2.cs +++ b/Entity/Dto/SwapOrderDto2.cs @@ -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; } } \ No newline at end of file diff --git a/WebStarter/Controllers/SwapOrderController.cs b/WebStarter/Controllers/SwapOrderController.cs index acc08a3..79480d9 100644 --- a/WebStarter/Controllers/SwapOrderController.cs +++ b/WebStarter/Controllers/SwapOrderController.cs @@ -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().ReverseMap(); cfg.CreateMap().ReverseMap(); cfg.CreateMap().ReverseMap(); + cfg.CreateMap().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 swapOrderStep = mapper.Map>(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(); + + // 获取与当前订单匹配的步骤信息 + 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 list = mapper.Map>(swapOrderResp);