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

master
lxw 5 months ago
parent d3d83ec9c8
commit 3ad7457a31

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

@ -15,7 +15,7 @@ public class SwapOrderMgr
public SwapOrderBatteryRepository _swapOrderBatteryRepository { get; set; } 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) if (list.Count <= 0)
{ {
@ -71,17 +71,23 @@ public class SwapOrderMgr
var count = _swapOrderRepository.GetCount(i => var count = _swapOrderRepository.GetCount(i =>
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