diff --git a/Entity/Api/Resp/SwapOrderResp.cs b/Entity/Api/Resp/SwapOrderResp.cs
index f77888d..dd36282 100644
--- a/Entity/Api/Resp/SwapOrderResp.cs
+++ b/Entity/Api/Resp/SwapOrderResp.cs
@@ -6,138 +6,143 @@ namespace Entity.Api.Resp
///
///换电订单
///
- public class SwapOrderResp
+ public class SwapOrderResp
{
-
- ///
- /// Desc:id
- /// Default:
- /// Nullable:False
- ///
- public int Id {get;set;}
-
- ///
- /// Desc:订单编号
- /// Default:
- /// Nullable:True
- ///
- public string Sn {get;set;}
-
- ///
- /// Desc:车牌号
- /// Default:
- /// Nullable:True
- ///
- public string VehicleNo {get;set;}
-
- ///
- /// Desc:车辆mac
- /// Default:
- /// Nullable:True
- ///
- public string VehicleMac {get;set;}
-
- ///
- /// Desc:车辆vin码
- /// Default:
- /// Nullable:True
- ///
- public string VehicleVin {get;set;}
-
- ///
- /// Desc:车辆进场时间
- /// Default:
- /// Nullable:True
- ///
- public DateTime? VehicleEnterTime {get;set;}
-
- ///
- /// Desc:车辆离场时间
- /// Default:
- /// Nullable:True
- ///
- public DateTime? VehicleLeaveTime {get;set;}
-
- ///
- /// Desc:换电开始时间
- /// Default:
- /// Nullable:True
- ///
- public DateTime? SwapBeginTime {get;set;}
-
- ///
- /// Desc:换电结束时间
- /// Default:
- /// Nullable:True
- ///
- public DateTime? SwapEndTime {get;set;}
-
- ///
- /// Desc:换电结果;0-未知;1-成功;2-失败
- /// Default:0
- /// Nullable:True
- ///
- public int? SwapResult {get;set;}
-
- ///
- /// Desc:失败原因
- /// Default:
- /// Nullable:True
- ///
- public string FailReason {get;set;}
-
- ///
- /// Desc:上传云平台状态;0-未上传;1-已上传
- /// Default:0
- /// Nullable:True
- ///
- public int? CloudReportStatus {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 Sn { get; set; }
+
+ ///
+ /// Desc:车牌号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string VehicleNo { get; set; }
+
+ ///
+ /// Desc:车辆mac
+ /// Default:
+ /// Nullable:True
+ ///
+ public string VehicleMac { get; set; }
+
+ ///
+ /// Desc:车辆vin码
+ /// Default:
+ /// Nullable:True
+ ///
+ public string VehicleVin { get; set; }
+
+ ///
+ /// Desc:车辆进场时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? VehicleEnterTime { get; set; }
+
+ ///
+ /// Desc:车辆离场时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? VehicleLeaveTime { get; set; }
+
+ ///
+ /// Desc:换电开始时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? SwapBeginTime { get; set; }
+
+ ///
+ /// Desc:换电结束时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? SwapEndTime { get; set; }
+
+ ///
+ /// Desc:换电结果;0-未知;1-成功;2-失败
+ /// Default:0
+ /// Nullable:True
+ ///
+ public int? SwapResult { get; set; }
+
+ ///
+ /// Desc:失败原因
+ /// Default:
+ /// Nullable:True
+ ///
+ public string FailReason { get; set; }
+
+ ///
+ /// Desc:上传云平台状态;0-未上传;1-已上传
+ /// Default:0
+ /// Nullable:True
+ ///
+ public int? CloudReportStatus { 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; }
+
///
/// 云平台订单号
///
public string? CloudSn { get; set; }
+
///
/// 换电类型
///
public int? SwapWay { get; set; }
+ ///
+ /// 上报次数
+ ///
+ public int? ReportCloudNum { get; set; }
+
/////
///// 换电电池
/////
- public List BatteryList{get;set;}
-
- ///
- /// 换电小步
- ///
- public List StepList{get;set;}
+ public List BatteryList { get; set; }
+ ///
+ /// 换电小步
+ ///
+ public List StepList { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/Repository/Station/BinInfoRepository.cs b/Repository/Station/BinInfoRepository.cs
index 3d721e6..9b93ca9 100644
--- a/Repository/Station/BinInfoRepository.cs
+++ b/Repository/Station/BinInfoRepository.cs
@@ -28,7 +28,7 @@ public class BinInfoRepository : BaseRepository
List list =
QueryListByClause(i => i.CacheBinFlag == 0 && i.CanSwapFlag==1 &&
i.Exists == 1 && i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock,
- "battery_enter_seq asc");
+ "in_time asc");
BinInfo? cacheBinBattery = ChooseCacheBinBattery();
if (list.Count <= 0 && cacheBinBattery == null)
{
diff --git a/Service/Mgr/SwapOrderMgr.cs b/Service/Mgr/SwapOrderMgr.cs
index 3558589..6396009 100644
--- a/Service/Mgr/SwapOrderMgr.cs
+++ b/Service/Mgr/SwapOrderMgr.cs
@@ -15,7 +15,7 @@ public class SwapOrderMgr
public SwapOrderBatteryRepository _swapOrderBatteryRepository { get; set; }
- public bool UploadCloud(List list ,int uploadType)
+ public bool UploadCloud(List list, int uploadType)
{
if (list.Count <= 0)
{
@@ -71,17 +71,23 @@ public class SwapOrderMgr
var count = _swapOrderRepository.GetCount(i =>
i.SwapResult == 1 && i.SwapEndTime >= DateTime.Today && i.SwapEndTime < swapOrder.SwapEndTime);
-
+
var uploadSwapOrder = CloudApi.UploadSwapOrder(swapOrder, count++, swapOrderBattery, uploadType);
+ swapOrderReportClouds.TryGetValue(swapOrder.Id, out SwapOrderReportCloud value);
if (uploadSwapOrder == 0)
{
swapOrder.CloudReportStatus = 1;
updateDbOrder.Add(swapOrder);
- swapOrderReportClouds.TryGetValue(swapOrder.Id, out SwapOrderReportCloud value);
+
value.CloudReportStatus = 1;
- value.UploadTime=DateTime.Now;
+ value.UploadTime = DateTime.Now;
updateDbCloudReport.Add(value);
}
+ else
+ {
+ //当 cloudReportStatus >=100 就不需要上传了
+ value.CloudReportStatus++;
+ }
}
if (updateDbOrder.Count > 0)
diff --git a/Service/MyTask/SwapOrderReportCloudTask.cs b/Service/MyTask/SwapOrderReportCloudTask.cs
index 1921544..d3b0382 100644
--- a/Service/MyTask/SwapOrderReportCloudTask.cs
+++ b/Service/MyTask/SwapOrderReportCloudTask.cs
@@ -44,7 +44,7 @@ public class SwapOrderReportCloudTask : ITask
}
List
- list = ReportCloudRepository.QueryListByClause(i => i.CloudReportStatus == 0);
+ list = ReportCloudRepository.QueryListByClause(i => i.CloudReportStatus < 100);
SwapOrderMgr.UploadCloud(list, 1);
}
diff --git a/Service/Station/SwapOrderService.cs b/Service/Station/SwapOrderService.cs
index f2bd209..2f2f27e 100644
--- a/Service/Station/SwapOrderService.cs
+++ b/Service/Station/SwapOrderService.cs
@@ -31,19 +31,37 @@ public class SwapOrderService : BaseServices
}
+ public Dictionary QueryReportCloudNumBySn(List swapOrderSns)
+ {
+ if (swapOrderSns.Count <= 0)
+ {
+ return new Dictionary();
+ }
+
+ List swapOrderReportClouds =
+ SwapOrderReportCloudRepository.QueryListByClause(i => swapOrderSns.Contains(i.SwapOrderSn));
+
+ if (swapOrderReportClouds.Count <= 0)
+ {
+ return new Dictionary();
+ }
+
+ return swapOrderReportClouds.ToDictionary(i => i.SwapOrderSn, i => i.CloudReportStatus++);
+ }
+
public Result UploadCloud(int id)
{
List list =
- SwapOrderReportCloudRepository.QueryListByClause(i => i.CloudReportStatus == 0 && i.SwapOrderId == id);
+ SwapOrderReportCloudRepository.QueryListByClause(i => i.CloudReportStatus < 100 && i.SwapOrderId == id);
if (list.Count <= 0)
{
return Result.Fail("当前换电订单不满足上报云平台的条件");
}
-
- return SwapOrderMgr.UploadCloud(list,2) ? Result.Success() : Result.Fail();
+ return SwapOrderMgr.UploadCloud(list, 2) ? Result.Success() : Result.Fail();
}
+
///
/// 查询需要导出换电订单
///
@@ -55,12 +73,15 @@ public class SwapOrderService : BaseServices
ParameterExpression parameter = Expression.Parameter(typeof(SwapOrder), "u");
#region 构建动态查询树
+
where = queryTree(swapOrder, where, parameter);
+
#endregion
// 查询需要导出充电订单 不分页
return await swapOrderRepository.QuerySwapOrderList(where);
}
+
///
/// 根据条件查询分页数据
///
@@ -92,7 +113,8 @@ public class SwapOrderService : BaseServices
return PageResult.ConvertPage(swapOrderRepository.QueryIPage(swapOrder, where));
}
- private static Expression>? queryTree(QuerySwapOrderPageReq swapOrder, Expression>? where, ParameterExpression parameter)
+ private static Expression>? queryTree(QuerySwapOrderPageReq swapOrder,
+ Expression>? where, ParameterExpression parameter)
{
if (!string.IsNullOrEmpty(swapOrder.Sn))
{
diff --git a/WebStarter/Controllers/SwapOrderController.cs b/WebStarter/Controllers/SwapOrderController.cs
index 800d6f7..a56c37c 100644
--- a/WebStarter/Controllers/SwapOrderController.cs
+++ b/WebStarter/Controllers/SwapOrderController.cs
@@ -44,7 +44,10 @@ public class SwapOrderController : ControllerBase
//获取所有订单号
var orderSns = swapOrderResp.Rows.Select(row => row.Sn).ToList();
- //电池不要了
+ //查询上报云平台次数
+ Dictionary queryReportCloudNumBySn = swapOrderService.QueryReportCloudNumBySn(orderSns);
+
+
////查询订单电池数据
List batteryList =
swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
@@ -62,6 +65,13 @@ public class SwapOrderController : ControllerBase
swapOrderResp.Rows[i].BatteryList = new List();
swapOrderResp.Rows[i].BatteryList.AddRange(swapOrderBattery
.Where(battery => battery.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList());
+ queryReportCloudNumBySn.TryGetValue(swapOrderResp.Rows[i].Sn, out int? num);
+ if (num == null)
+ {
+ num = 0;
+ }
+
+ swapOrderResp.Rows[i].ReportCloudNum = num;
}
//查询订单步序数据