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

master
lxw 6 months ago
parent d3d83ec9c8
commit 3ad7457a31

@ -8,136 +8,141 @@ namespace Entity.Api.Resp
///</summary>
public class SwapOrderResp
{
/// <summary>
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
public int Id {get;set;}
public int Id { get; set; }
/// <summary>
/// Desc:订单编号
/// Default:
/// Nullable:True
/// </summary>
public string Sn {get;set;}
public string Sn { get; set; }
/// <summary>
/// Desc:车牌号
/// Default:
/// Nullable:True
/// </summary>
public string VehicleNo {get;set;}
public string VehicleNo { get; set; }
/// <summary>
/// Desc:车辆mac
/// Default:
/// Nullable:True
/// </summary>
public string VehicleMac {get;set;}
public string VehicleMac { get; set; }
/// <summary>
/// Desc:车辆vin码
/// Default:
/// Nullable:True
/// </summary>
public string VehicleVin {get;set;}
public string VehicleVin { get; set; }
/// <summary>
/// Desc:车辆进场时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime? VehicleEnterTime {get;set;}
public DateTime? VehicleEnterTime { get; set; }
/// <summary>
/// Desc:车辆离场时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime? VehicleLeaveTime {get;set;}
public DateTime? VehicleLeaveTime { get; set; }
/// <summary>
/// Desc:换电开始时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime? SwapBeginTime {get;set;}
public DateTime? SwapBeginTime { get; set; }
/// <summary>
/// Desc:换电结束时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime? SwapEndTime {get;set;}
public DateTime? SwapEndTime { get; set; }
/// <summary>
/// Desc:换电结果;0-未知1-成功2-失败
/// Default:0
/// Nullable:True
/// </summary>
public int? SwapResult {get;set;}
public int? SwapResult { get; set; }
/// <summary>
/// Desc:失败原因
/// Default:
/// Nullable:True
/// </summary>
public string FailReason {get;set;}
public string FailReason { get; set; }
/// <summary>
/// Desc:上传云平台状态;0-未上传1-已上传
/// Default:0
/// Nullable:True
/// </summary>
public int? CloudReportStatus {get;set;}
public int? CloudReportStatus { get; set; }
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
public string CreatedBy {get;set;}
public string CreatedBy { get; set; }
/// <summary>
/// Desc:创建时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
public DateTime? CreatedTime {get;set;}
public DateTime? CreatedTime { get; set; }
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
public string UpdatedBy {get;set;}
public string UpdatedBy { get; set; }
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
public DateTime? UpdatedTime {get;set;}
public DateTime? UpdatedTime { get; set; }
/// <summary>
/// 云平台订单号
/// </summary>
public string? CloudSn { get; set; }
/// <summary>
/// 换电类型
/// </summary>
public int? SwapWay { get; set; }
/// <summary>
/// 上报次数
/// </summary>
public int? ReportCloudNum { get; set; }
///// <summary>
///// 换电电池
///// </summary>
public List<SwapOrderBatteryResp> BatteryList{get;set;}
public List<SwapOrderBatteryResp> BatteryList { get; set; }
/// <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 =
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)
{

@ -15,7 +15,7 @@ public class SwapOrderMgr
public SwapOrderBatteryRepository _swapOrderBatteryRepository { get; set; }
public bool UploadCloud(List<SwapOrderReportCloud> list ,int uploadType)
public bool UploadCloud(List<SwapOrderReportCloud> list, int uploadType)
{
if (list.Count <= 0)
{
@ -73,15 +73,21 @@ public class SwapOrderMgr
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)

@ -44,7 +44,7 @@ public class SwapOrderReportCloudTask : ITask
}
List<SwapOrderReportCloud>
list = ReportCloudRepository.QueryListByClause(i => i.CloudReportStatus == 0);
list = ReportCloudRepository.QueryListByClause(i => i.CloudReportStatus < 100);
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)
{
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)
{
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>
@ -55,12 +73,15 @@ public class SwapOrderService : BaseServices<SwapOrder>
ParameterExpression parameter = Expression.Parameter(typeof(SwapOrder), "u");
#region 构建动态查询树
where = queryTree(swapOrder, where, parameter);
#endregion
// 查询需要导出充电订单 不分页
return await swapOrderRepository.QuerySwapOrderList(where);
}
/// <summary>
/// 根据条件查询分页数据
/// </summary>
@ -92,7 +113,8 @@ public class SwapOrderService : BaseServices<SwapOrder>
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))
{

@ -44,7 +44,10 @@ public class SwapOrderController : ControllerBase
//获取所有订单号
var orderSns = swapOrderResp.Rows.Select(row => row.Sn).ToList();
//电池不要了
//查询上报云平台次数
Dictionary<string, int?> queryReportCloudNumBySn = swapOrderService.QueryReportCloudNumBySn(orderSns);
////查询订单电池数据
List<SwapOrderBattery> batteryList =
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.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;
}
//查询订单步序数据

Loading…
Cancel
Save