仓位列表添加 入仓时间 去掉入仓顺序 换电订单列表添加 上报次数

master
lxw 5 months ago
parent d3d83ec9c8
commit 3ad7457a31

@ -8,7 +8,6 @@ namespace Entity.Api.Resp
///</summary> ///</summary>
public class SwapOrderResp public class SwapOrderResp
{ {
/// <summary> /// <summary>
/// Desc:id /// Desc:id
/// Default: /// Default:
@ -120,15 +119,22 @@ namespace Entity.Api.Resp
/// Nullable:True /// Nullable:True
/// </summary> /// </summary>
public DateTime? UpdatedTime { get; set; } public DateTime? UpdatedTime { get; set; }
/// <summary> /// <summary>
/// 云平台订单号 /// 云平台订单号
/// </summary> /// </summary>
public string? CloudSn { get; set; } public string? CloudSn { get; set; }
/// <summary> /// <summary>
/// 换电类型 /// 换电类型
/// </summary> /// </summary>
public int? SwapWay { get; set; } public int? SwapWay { get; set; }
/// <summary>
/// 上报次数
/// </summary>
public int? ReportCloudNum { get; set; }
///// <summary> ///// <summary>
///// 换电电池 ///// 换电电池
///// </summary> ///// </summary>
@ -138,6 +144,5 @@ namespace Entity.Api.Resp
/// 换电小步 /// 换电小步
/// </summary> /// </summary>
public List<SwapOrderStepResp> StepList { get; set; } public List<SwapOrderStepResp> StepList { get; set; }
} }
} }

@ -28,7 +28,7 @@ public class BinInfoRepository : BaseRepository<BinInfo>
List<BinInfo> list = List<BinInfo> list =
QueryListByClause(i => i.CacheBinFlag == 0 && i.CanSwapFlag==1 && QueryListByClause(i => i.CacheBinFlag == 0 && i.CanSwapFlag==1 &&
i.Exists == 1 && i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock, i.Exists == 1 && i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock,
"battery_enter_seq asc"); "in_time asc");
BinInfo? cacheBinBattery = ChooseCacheBinBattery(); BinInfo? cacheBinBattery = ChooseCacheBinBattery();
if (list.Count <= 0 && cacheBinBattery == null) if (list.Count <= 0 && cacheBinBattery == null)
{ {

@ -73,15 +73,21 @@ public class SwapOrderMgr
i.SwapResult == 1 && i.SwapEndTime >= DateTime.Today && i.SwapEndTime < swapOrder.SwapEndTime); i.SwapResult == 1 && i.SwapEndTime >= DateTime.Today && i.SwapEndTime < swapOrder.SwapEndTime);
var uploadSwapOrder = CloudApi.UploadSwapOrder(swapOrder, count++, swapOrderBattery, uploadType); var uploadSwapOrder = CloudApi.UploadSwapOrder(swapOrder, count++, swapOrderBattery, uploadType);
swapOrderReportClouds.TryGetValue(swapOrder.Id, out SwapOrderReportCloud value);
if (uploadSwapOrder == 0) if (uploadSwapOrder == 0)
{ {
swapOrder.CloudReportStatus = 1; swapOrder.CloudReportStatus = 1;
updateDbOrder.Add(swapOrder); updateDbOrder.Add(swapOrder);
swapOrderReportClouds.TryGetValue(swapOrder.Id, out SwapOrderReportCloud value);
value.CloudReportStatus = 1; value.CloudReportStatus = 1;
value.UploadTime = DateTime.Now; value.UploadTime = DateTime.Now;
updateDbCloudReport.Add(value); updateDbCloudReport.Add(value);
} }
else
{
//当 cloudReportStatus >=100 就不需要上传了
value.CloudReportStatus++;
}
} }
if (updateDbOrder.Count > 0) if (updateDbOrder.Count > 0)

@ -44,7 +44,7 @@ public class SwapOrderReportCloudTask : ITask
} }
List<SwapOrderReportCloud> List<SwapOrderReportCloud>
list = ReportCloudRepository.QueryListByClause(i => i.CloudReportStatus == 0); list = ReportCloudRepository.QueryListByClause(i => i.CloudReportStatus < 100);
SwapOrderMgr.UploadCloud(list, 1); SwapOrderMgr.UploadCloud(list, 1);
} }

@ -31,19 +31,37 @@ public class SwapOrderService : BaseServices<SwapOrder>
} }
public Dictionary<string, int?> QueryReportCloudNumBySn(List<string> swapOrderSns)
{
if (swapOrderSns.Count <= 0)
{
return new Dictionary<string, int?>();
}
List<SwapOrderReportCloud> swapOrderReportClouds =
SwapOrderReportCloudRepository.QueryListByClause(i => swapOrderSns.Contains(i.SwapOrderSn));
if (swapOrderReportClouds.Count <= 0)
{
return new Dictionary<string, int?>();
}
return swapOrderReportClouds.ToDictionary(i => i.SwapOrderSn, i => i.CloudReportStatus++);
}
public Result<bool> UploadCloud(int id) public Result<bool> UploadCloud(int id)
{ {
List<SwapOrderReportCloud> list = List<SwapOrderReportCloud> list =
SwapOrderReportCloudRepository.QueryListByClause(i => i.CloudReportStatus == 0 && i.SwapOrderId == id); SwapOrderReportCloudRepository.QueryListByClause(i => i.CloudReportStatus < 100 && i.SwapOrderId == id);
if (list.Count <= 0) if (list.Count <= 0)
{ {
return Result<bool>.Fail("当前换电订单不满足上报云平台的条件"); return Result<bool>.Fail("当前换电订单不满足上报云平台的条件");
} }
return SwapOrderMgr.UploadCloud(list, 2) ? Result<bool>.Success() : Result<bool>.Fail(); return SwapOrderMgr.UploadCloud(list, 2) ? Result<bool>.Success() : Result<bool>.Fail();
} }
/// <summary> /// <summary>
/// 查询需要导出换电订单 /// 查询需要导出换电订单
/// </summary> /// </summary>
@ -55,12 +73,15 @@ public class SwapOrderService : BaseServices<SwapOrder>
ParameterExpression parameter = Expression.Parameter(typeof(SwapOrder), "u"); ParameterExpression parameter = Expression.Parameter(typeof(SwapOrder), "u");
#region 构建动态查询树 #region 构建动态查询树
where = queryTree(swapOrder, where, parameter); where = queryTree(swapOrder, where, parameter);
#endregion #endregion
// 查询需要导出充电订单 不分页 // 查询需要导出充电订单 不分页
return await swapOrderRepository.QuerySwapOrderList(where); return await swapOrderRepository.QuerySwapOrderList(where);
} }
/// <summary> /// <summary>
/// 根据条件查询分页数据 /// 根据条件查询分页数据
/// </summary> /// </summary>
@ -92,7 +113,8 @@ public class SwapOrderService : BaseServices<SwapOrder>
return PageResult<SwapOrderResp>.ConvertPage(swapOrderRepository.QueryIPage(swapOrder, where)); return PageResult<SwapOrderResp>.ConvertPage(swapOrderRepository.QueryIPage(swapOrder, where));
} }
private static Expression<Func<SwapOrder, bool>>? queryTree(QuerySwapOrderPageReq swapOrder, Expression<Func<SwapOrder, bool>>? where, ParameterExpression parameter) private static Expression<Func<SwapOrder, bool>>? queryTree(QuerySwapOrderPageReq swapOrder,
Expression<Func<SwapOrder, bool>>? where, ParameterExpression parameter)
{ {
if (!string.IsNullOrEmpty(swapOrder.Sn)) if (!string.IsNullOrEmpty(swapOrder.Sn))
{ {

@ -44,7 +44,10 @@ public class SwapOrderController : ControllerBase
//获取所有订单号 //获取所有订单号
var orderSns = swapOrderResp.Rows.Select(row => row.Sn).ToList(); var orderSns = swapOrderResp.Rows.Select(row => row.Sn).ToList();
//电池不要了 //查询上报云平台次数
Dictionary<string, int?> queryReportCloudNumBySn = swapOrderService.QueryReportCloudNumBySn(orderSns);
////查询订单电池数据 ////查询订单电池数据
List<SwapOrderBattery> batteryList = List<SwapOrderBattery> batteryList =
swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
@ -62,6 +65,13 @@ public class SwapOrderController : ControllerBase
swapOrderResp.Rows[i].BatteryList = new List<SwapOrderBatteryResp>(); swapOrderResp.Rows[i].BatteryList = new List<SwapOrderBatteryResp>();
swapOrderResp.Rows[i].BatteryList.AddRange(swapOrderBattery swapOrderResp.Rows[i].BatteryList.AddRange(swapOrderBattery
.Where(battery => battery.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList()); .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;
} }
//查询订单步序数据 //查询订单步序数据

Loading…
Cancel
Save