diff --git a/Entity/Api/Req/AddSwapOrderReq.cs b/Entity/Api/Req/AddSwapOrderReq.cs index 2d31fc7..89f3462 100644 --- a/Entity/Api/Req/AddSwapOrderReq.cs +++ b/Entity/Api/Req/AddSwapOrderReq.cs @@ -113,7 +113,9 @@ /// public DateTime? UpdatedTime {get;set;} = DateTime.Now; - - + /// + /// 云平台订单号 + /// + public string? CloudSn { get;set;} } } diff --git a/Entity/Api/Req/ModifySwapOrderReq.cs b/Entity/Api/Req/ModifySwapOrderReq.cs index 2e5d262..c62d9a7 100644 --- a/Entity/Api/Req/ModifySwapOrderReq.cs +++ b/Entity/Api/Req/ModifySwapOrderReq.cs @@ -120,6 +120,10 @@ namespace Entity.Api.Req /// public DateTime? UpdatedTime { get; set; } = DateTime.Now; + /// + /// 云平台订单号 + /// + public string? CloudSn { get; set; } } } diff --git a/Entity/Api/Resp/SwapOrderBatteryResp.cs b/Entity/Api/Resp/SwapOrderBatteryResp.cs index d2198b2..b25b77f 100644 --- a/Entity/Api/Resp/SwapOrderBatteryResp.cs +++ b/Entity/Api/Resp/SwapOrderBatteryResp.cs @@ -1,205 +1,208 @@ -namespace Entity.Api.Resp +using SqlSugar; + +namespace Entity.Api.Resp { /// ///换电订单电池 /// public class SwapOrderBatteryResp { - /// - /// Desc:id - /// Default: - /// Nullable:False - /// - public int Id {get;set;} - - /// - /// Desc:换电订单编号 - /// Default: - /// Nullable:True - /// - public string SwapOrderSn {get;set;} - - /// - /// Desc:亏电包编码 - /// Default: - /// Nullable:True - /// - public string DownBatteryNo {get;set;} - - /// - /// Desc:亏电包soc - /// Default: - /// Nullable:True - /// - public decimal? DownBatterySoc {get;set;} - - /// - /// Desc:亏电包soe - /// Default: - /// Nullable:True - /// - public decimal? DownBatterySoe {get;set;} - - /// - /// Desc:亏电包真实soc - /// Default: - /// Nullable:True - /// - public decimal? DownBatteryRealSoc {get;set;} - - /// - /// Desc:亏电包上次换电结算时soc - /// Default: - /// Nullable:True - /// - public decimal? DownBatteryLastSoc {get;set;} - - /// - /// Desc:亏电包上次换电结算时soe - /// Default: - /// Nullable:True - /// - public decimal? DownBatteryLastSoe {get;set;} - - /// - /// Desc:亏电包站内充电能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? DownBatteryInChageElecCount {get;set;} - - /// - /// Desc:亏电包站外插枪充电能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? DownBatteryOutChageElecCount {get;set;} - - /// - /// Desc:亏电包站外回充能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? DownBatteryOutReChagreCount {get;set;} - - /// - /// Desc:亏电包站外放电能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? DownBatteryInDischageElecCount {get;set;} - - /// - /// Desc:亏电包站内放电电能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? DownBatteryOutDischageElecCount {get;set;} - - /// - /// Desc:放电池仓位号 亏电包仓号 - /// Default: - /// Nullable:True - /// - public int? DownBatteryBinNo {get;set;} - - /// - /// Desc:满电包编码 - /// Default: - /// Nullable:True - /// - public string UpBatteryNo {get;set;} - - /// - /// Desc:满电包soc - /// Default: - /// Nullable:True - /// - public decimal? UpBatterySoc {get;set;} - - /// - /// Desc:满电包soe - /// Default: - /// Nullable:True - /// - public decimal? UpBatterySoe {get;set;} - - /// - /// Desc:满电包真实soc - /// Default: - /// Nullable:True - /// - public decimal? UpBatteryRealSoc {get;set;} - - /// - /// Desc:满电包站内充电能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? UpBatteryInChageElecCount {get;set;} - - /// - /// Desc:满电包站外插枪充电能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? UpBatteryOutChageElecCount {get;set;} - - /// - /// Desc:满电包站外回充能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? UpBatteryOutReChagreCount {get;set;} - - /// - /// Desc:满电包站外放电能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? UpBatteryInDischageElecCount {get;set;} - - /// - /// Desc:满电包站内放电电能量(累计) - /// Default: - /// Nullable:True - /// - public decimal? UpBatteryOutDischageElecCount {get;set;} - - /// - /// Desc:取电池仓位号 满电包仓号 - /// Default: - /// Nullable:True - /// - public int? UpBatteryBinNo {get;set;} - - /// - /// Desc:创建人 - /// Default: - /// Nullable:True - /// - public string CreatedBy {get;set;} - - /// - /// Desc:创建时间 - /// Default:CURRENT_TIMESTAMP - /// Nullable:True - /// - public DateTime? CreatedTime {get;set;} - - /// - /// Desc:更新人 - /// Default: - /// Nullable:True - /// - public string UpdatedBy {get;set;} - - /// - /// Desc:更新时间 - /// Default:CURRENT_TIMESTAMP - /// Nullable:True - /// - public DateTime? UpdatedTime {get;set;} + + /// + /// Desc:id + /// Default: + /// Nullable:False + /// + public int Id { get; set; } + + /// + /// Desc:换电订单编号 + /// Default: + /// Nullable:True + /// + public string? SwapOrderSn { get; set; } + + /// + /// Desc:亏电包编码 + /// Default: + /// Nullable:True + /// + public string? DownBatteryNo { get; set; } + + /// + /// Desc:亏电包soc + /// Default: + /// Nullable:True + /// + public decimal? DownBatterySoc { get; set; } + + /// + /// Desc:亏电包soe + /// Default: + /// Nullable:True + /// + public decimal? DownBatterySoe { get; set; } + + /// + /// Desc:亏电包真实soc + /// Default: + /// Nullable:True + /// + public decimal? DownBatteryRealSoc { get; set; } + + /// + /// Desc:亏电包上次换电结算时soc + /// Default: + /// Nullable:True + /// + public decimal? DownBatteryLastSoc { get; set; } + + /// + /// Desc:亏电包上次换电结算时soe + /// Default: + /// Nullable:True + /// + public decimal? DownBatteryLastSoe { get; set; } + + /// + /// Desc:亏电包站内充电能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? DownBatteryInChageElecCount { get; set; } + + /// + /// Desc:亏电包站外插枪充电能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? DownBatteryOutChageElecCount { get; set; } + + /// + /// Desc:亏电包站外回充能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? DownBatteryOutReChagreCount { get; set; } + + /// + /// Desc:亏电包站外放电能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? DownBatteryInDischageElecCount { get; set; } + + /// + /// Desc:亏电包站内放电电能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? DownBatteryOutDischageElecCount { get; set; } + + /// + /// Desc:放电池仓位号 亏电包仓号 + /// Default: + /// Nullable:True + /// + public int? DownBatteryBinNo { get; set; } + + /// + /// Desc:满电包编码 + /// Default: + /// Nullable:True + /// + public string? UpBatteryNo { get; set; } + + /// + /// Desc:满电包soc + /// Default: + /// Nullable:True + /// + public decimal? UpBatterySoc { get; set; } + + /// + /// Desc:满电包soe + /// Default: + /// Nullable:True + /// + public decimal? UpBatterySoe { get; set; } + + /// + /// Desc:满电包真实soc + /// Default: + /// Nullable:True + /// + public decimal? UpBatteryRealSoc { get; set; } + + /// + /// Desc:满电包站内充电能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? UpBatteryInChageElecCount { get; set; } + + /// + /// Desc:满电包站外插枪充电能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? UpBatteryOutChageElecCount { get; set; } + + /// + /// Desc:满电包站外回充能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? UpBatteryOutReChagreCount { get; set; } + + /// + /// Desc:满电包站外放电能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? UpBatteryInDischageElecCount { get; set; } + + /// + /// Desc:满电包站内放电电能量(累计) + /// Default: + /// Nullable:True + /// + public decimal? UpBatteryOutDischageElecCount { get; set; } + + /// + /// Desc:取电池仓位号 满电包仓号 + /// Default: + /// Nullable:True + /// + public int? UpBatteryBinNo { get; set; } + + /// + /// Desc:创建人 + /// Default: + /// Nullable:True + /// + public string? CreatedBy { get; set; } + + /// + /// Desc:创建时间 + /// Default:CURRENT_TIMESTAMP + /// Nullable:True + /// + public DateTime? CreatedTime { get; set; } + + /// + /// Desc:更新人 + /// Default: + /// Nullable:True + /// + public string ?UpdatedBy { get; set; } + + /// + /// Desc:更新时间 + /// Default:CURRENT_TIMESTAMP + /// Nullable:True + /// + public DateTime? UpdatedTime { get; set; } } } diff --git a/Entity/Api/Resp/SwapOrderResp.cs b/Entity/Api/Resp/SwapOrderResp.cs index c6dc720..648fa4b 100644 --- a/Entity/Api/Resp/SwapOrderResp.cs +++ b/Entity/Api/Resp/SwapOrderResp.cs @@ -120,11 +120,14 @@ namespace Entity.Api.Resp /// Nullable:True /// public DateTime? UpdatedTime {get;set;} - - /// - /// 换电电池 - /// - public List BatteryList{get;set;} + /// + /// 云平台订单号 + /// + public string? CloudSn { get; set; } + ///// + ///// 换电电池 + ///// + //public List BatteryList{get;set;} /// /// 换电小步 diff --git a/Entity/DbModel/Station/SwapOrderBattery.cs b/Entity/DbModel/Station/SwapOrderBattery.cs index 497b67a..1183478 100644 --- a/Entity/DbModel/Station/SwapOrderBattery.cs +++ b/Entity/DbModel/Station/SwapOrderBattery.cs @@ -11,233 +11,230 @@ namespace Entity.DbModel.Station [SugarTable("swap_order_battery")] public partial class SwapOrderBattery { - public SwapOrderBattery(){ - - - } - /// - /// Desc:id - /// Default: - /// Nullable:False - /// - [SugarColumn(IsPrimaryKey=true,IsIdentity=true,ColumnName="id")] - public int Id {get;set;} - - /// - /// Desc:换电订单编号 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="swap_order_sn")] - public string SwapOrderSn {get;set;} - - /// - /// Desc:亏电包编码 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_no")] - public string DownBatteryNo {get;set;} - - /// - /// Desc:亏电包soc - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_soc")] - public decimal? DownBatterySoc {get;set;} - - /// - /// Desc:亏电包soe - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_soe")] - public decimal? DownBatterySoe {get;set;} - - /// - /// Desc:亏电包真实soc - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_real_soc")] - public decimal? DownBatteryRealSoc {get;set;} - - /// - /// Desc:亏电包上次换电结算时soc - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_last_soc")] - public decimal? DownBatteryLastSoc {get;set;} - - /// - /// Desc:亏电包上次换电结算时soe - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_last_soe")] - public decimal? DownBatteryLastSoe {get;set;} - - /// - /// Desc:亏电包站内充电能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_in_chage_elec_count")] - public decimal? DownBatteryInChageElecCount {get;set;} - - /// - /// Desc:亏电包站外插枪充电能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_out_chage_elec_count")] - public decimal? DownBatteryOutChageElecCount {get;set;} - - /// - /// Desc:亏电包站外回充能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_out_re_chagre_count")] - public decimal? DownBatteryOutReChagreCount {get;set;} - - /// - /// Desc:亏电包站外放电能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_in_dischage_elec_count")] - public decimal? DownBatteryInDischageElecCount {get;set;} - - /// - /// Desc:亏电包站内放电电能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_out_dischage_elec_count")] - public decimal? DownBatteryOutDischageElecCount {get;set;} - - /// - /// Desc:放电池仓位号 亏电包仓号 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="down_battery_bin_no")] - public int? DownBatteryBinNo {get;set;} - - /// - /// Desc:满电包编码 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_no")] - public string UpBatteryNo {get;set;} - - /// - /// Desc:满电包soc - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_soc")] - public decimal? UpBatterySoc {get;set;} - - /// - /// Desc:满电包soe - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_soe")] - public decimal? UpBatterySoe {get;set;} - - /// - /// Desc:满电包真实soc - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_real_soc")] - public decimal? UpBatteryRealSoc {get;set;} - - /// - /// Desc:满电包站内充电能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_in_chage_elec_count")] - public decimal? UpBatteryInChageElecCount {get;set;} - - /// - /// Desc:满电包站外插枪充电能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_out_chage_elec_count")] - public decimal? UpBatteryOutChageElecCount {get;set;} - - /// - /// Desc:满电包站外回充能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_out_re_chagre_count")] - public decimal? UpBatteryOutReChagreCount {get;set;} - - /// - /// Desc:满电包站外放电能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_in_dischage_elec_count")] - public decimal? UpBatteryInDischageElecCount {get;set;} - - /// - /// Desc:满电包站内放电电能量(累计) - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_out_dischage_elec_count")] - public decimal? UpBatteryOutDischageElecCount {get;set;} - - /// - /// Desc:取电池仓位号 满电包仓号 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="up_battery_bin_no")] - public int? UpBatteryBinNo {get;set;} - - /// - /// Desc:创建人 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="created_by")] - public string CreatedBy {get;set;} - - /// - /// Desc:创建时间 - /// Default:CURRENT_TIMESTAMP - /// Nullable:True - /// - [SugarColumn(ColumnName="created_time")] - public DateTime? CreatedTime {get;set;} - - /// - /// Desc:更新人 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName="updated_by")] - public string UpdatedBy {get;set;} - - /// - /// Desc:更新时间 - /// Default:CURRENT_TIMESTAMP - /// Nullable:True - /// - [SugarColumn(ColumnName="updated_time")] - public DateTime? UpdatedTime {get;set;} + + /// + /// Desc:id + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")] + public int Id { get; set; } + + /// + /// Desc:换电订单编号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "swap_order_sn")] + public string? SwapOrderSn { get; set; } + + /// + /// Desc:亏电包编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_no")] + public string? DownBatteryNo { get; set; } + + /// + /// Desc:亏电包soc + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_soc")] + public decimal? DownBatterySoc { get; set; } + + /// + /// Desc:亏电包soe + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_soe")] + public decimal? DownBatterySoe { get; set; } + + /// + /// Desc:亏电包真实soc + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_real_soc")] + public decimal? DownBatteryRealSoc { get; set; } + + /// + /// Desc:亏电包上次换电结算时soc + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_last_soc")] + public decimal? DownBatteryLastSoc { get; set; } + + /// + /// Desc:亏电包上次换电结算时soe + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_last_soe")] + public decimal? DownBatteryLastSoe { get; set; } + + /// + /// Desc:亏电包站内充电能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_in_chage_elec_count")] + public decimal? DownBatteryInChageElecCount { get; set; } + + /// + /// Desc:亏电包站外插枪充电能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_out_chage_elec_count")] + public decimal? DownBatteryOutChageElecCount { get; set; } + + /// + /// Desc:亏电包站外回充能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_out_re_chagre_count")] + public decimal? DownBatteryOutReChagreCount { get; set; } + + /// + /// Desc:亏电包站外放电能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_in_dischage_elec_count")] + public decimal? DownBatteryInDischageElecCount { get; set; } + + /// + /// Desc:亏电包站内放电电能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_out_dischage_elec_count")] + public decimal? DownBatteryOutDischageElecCount { get; set; } + + /// + /// Desc:放电池仓位号 亏电包仓号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "down_battery_bin_no")] + public int? DownBatteryBinNo { get; set; } + + /// + /// Desc:满电包编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_no")] + public string? UpBatteryNo { get; set; } + + /// + /// Desc:满电包soc + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_soc")] + public decimal? UpBatterySoc { get; set; } + + /// + /// Desc:满电包soe + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_soe")] + public decimal? UpBatterySoe { get; set; } + + /// + /// Desc:满电包真实soc + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_real_soc")] + public decimal? UpBatteryRealSoc { get; set; } + + /// + /// Desc:满电包站内充电能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_in_chage_elec_count")] + public decimal? UpBatteryInChageElecCount { get; set; } + + /// + /// Desc:满电包站外插枪充电能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_out_chage_elec_count")] + public decimal? UpBatteryOutChageElecCount { get; set; } + + /// + /// Desc:满电包站外回充能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_out_re_chagre_count")] + public decimal? UpBatteryOutReChagreCount { get; set; } + + /// + /// Desc:满电包站外放电能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_in_dischage_elec_count")] + public decimal? UpBatteryInDischageElecCount { get; set; } + + /// + /// Desc:满电包站内放电电能量(累计) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_out_dischage_elec_count")] + public decimal? UpBatteryOutDischageElecCount { get; set; } + + /// + /// Desc:取电池仓位号 满电包仓号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "up_battery_bin_no")] + public int? UpBatteryBinNo { get; set; } + + /// + /// Desc:创建人 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "created_by")] + public string? CreatedBy { get; set; } + + /// + /// Desc:创建时间 + /// Default:CURRENT_TIMESTAMP + /// Nullable:True + /// + [SugarColumn(ColumnName = "created_time")] + public DateTime? CreatedTime { get; set; } + + /// + /// Desc:更新人 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "updated_by")] + public string? UpdatedBy { get; set; } + + /// + /// Desc:更新时间 + /// Default:CURRENT_TIMESTAMP + /// Nullable:True + /// + [SugarColumn(ColumnName = "updated_time")] + public DateTime? UpdatedTime { get; set; } } } diff --git a/Service/Station/SwapOrderService.cs b/Service/Station/SwapOrderService.cs index 89fce29..d5380d6 100644 --- a/Service/Station/SwapOrderService.cs +++ b/Service/Station/SwapOrderService.cs @@ -29,7 +29,7 @@ public class SwapOrderService : BaseServices /// public PageResult QuerySwapOrder(QuerySwapOrderPageReq swapOrder) { - + //һյıʽ Expression> where = null; //// ʽ @@ -74,6 +74,15 @@ public class SwapOrderService : BaseServices #endregion //ѯ + + //var swapOrderResp = PageResult.ConvertPage(swapOrderRepository.QueryIPageByCause(swapOrder, where)); + //for (int i = 0; i < swapOrderResp.Rows.Count; i++) + //{ + // swapOrderResp.Rows[0].BatteryList.AddRange() + //} + + //List BatteryList = new List(); + //List StepList = new List(); return PageResult.ConvertPage(swapOrderRepository.QueryIPageByCause(swapOrder, where)); diff --git a/WebStarter/Controllers/SwapOrderController.cs b/WebStarter/Controllers/SwapOrderController.cs index e23edf9..97b4fa5 100644 --- a/WebStarter/Controllers/SwapOrderController.cs +++ b/WebStarter/Controllers/SwapOrderController.cs @@ -4,7 +4,9 @@ using Entity.Api.Resp; using Entity.DbModel.Station; using HybirdFrameworkCore.Entity; using Microsoft.AspNetCore.Mvc; +using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; using Service.Station; +using System.Collections.Generic; namespace WebStarter.Controllers; @@ -16,10 +18,14 @@ namespace WebStarter.Controllers; public class SwapOrderController : ControllerBase { private readonly SwapOrderService swapOrderService; - - public SwapOrderController(SwapOrderService swapOrderService) + private readonly SwapOrderBatteryService swapOrderBatteryService; + private readonly SwapOrderStepService swapOrderStepService; + + public SwapOrderController(SwapOrderService swapOrderService, SwapOrderBatteryService swapOrderBatteryService, SwapOrderStepService swapOrderStepService) { this.swapOrderService = swapOrderService; + this.swapOrderBatteryService = swapOrderBatteryService; + this.swapOrderStepService = swapOrderStepService; } /// /// 查询分页数据 @@ -28,8 +34,46 @@ public class SwapOrderController : ControllerBase [HttpPost("QueryPage")] public async Task>> QueryPage([FromBody] QuerySwapOrderPageReq req) { - - return Result>.Success(swapOrderService.QuerySwapOrder(req)); + var swapOrderResp = 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 ().ReverseMap()); + //IMapper mapper = config.CreateMapper(); + //List swapOrderBattery = mapper.Map>(batteryList); + + + ////将电池数据添加到换电订单数据中 + //for (int i = 0; i < swapOrderResp.Rows.Count; i++) + //{ + // swapOrderResp.Rows[i].BatteryList = new List(); + // 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().ReverseMap()); + IMapper mapper2 = config2.CreateMapper(); + List swapOrderStep = mapper2.Map>(stepList); + + + //将步序数据添加到换电订单数据中 + for (int i = 0; i < swapOrderResp.Rows.Count; i++) + { + swapOrderResp.Rows[i].StepList = new List(); + swapOrderResp.Rows[i].StepList.AddRange(swapOrderStep.Where(step => step.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList()); + } + + return Result>.Success(swapOrderResp); } /// /// 新增 @@ -39,18 +83,29 @@ public class SwapOrderController : ControllerBase public async Task> Add([FromBody] AddSwapOrderReq req) { //映射数据 - var config = new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap()); + var config = new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap()); IMapper mapper = config.CreateMapper(); SwapOrder swapOrder = mapper.Map(req); - if (swapOrderService.Insert(swapOrder) != 0) + var swap = swapOrderService.QueryByClause(u => u.Sn == req.Sn); + if (swap != null) { - return Result.Success("新增成功"); + return Result.Fail("新增失败!订单号重复"); } else { - return Result.Fail("新增失败"); + if (swapOrderService.Insert(swapOrder) != 0) + { + return Result.Success("新增成功"); + } + else + { + return Result.Fail("新增失败"); + } + } + + } ///