parent
de9d5ae6fc
commit
3a8de78a25
@ -0,0 +1,16 @@
|
||||
using Entity.Constant;
|
||||
using Entity.DbModel.Station;
|
||||
|
||||
namespace Entity.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// 选包dto
|
||||
/// </summary>
|
||||
public class SelectPackDto
|
||||
{
|
||||
public bool SuccessFlag { get; set; }
|
||||
|
||||
public InfoEnum.SelectBinStatusInfo Info { get; set; }
|
||||
|
||||
public BinInfo BinInfo { get; set; }
|
||||
}
|
@ -1,14 +1,67 @@
|
||||
using Entity.Constant;
|
||||
using Entity.DbModel.Station;
|
||||
using Entity.Dto;
|
||||
using HybirdFrameworkCore.Autofac.Attribute;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Repository.Station;
|
||||
|
||||
[Scope("SingleInstance")]
|
||||
public class BinInfoRepository:BaseRepository<BinInfo>
|
||||
public class BinInfoRepository : BaseRepository<BinInfo>
|
||||
{
|
||||
|
||||
public BinInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选包
|
||||
/// </summary>
|
||||
/// <param name="swapSoc"> StaticStationInfo.SwapSoc </param>
|
||||
/// <param name="swapFinishChargeTime">StaticStationInfo.SwapFinishChargeTime</param>
|
||||
/// <returns></returns>
|
||||
public SelectPackDto SelectPack(string swapSoc, string swapFinishChargeTime)
|
||||
{
|
||||
SelectPackDto selectPackDto = new()
|
||||
{
|
||||
SuccessFlag = false,
|
||||
};
|
||||
List<BinInfo> list =
|
||||
QueryListByClause(i =>
|
||||
i.Exists == 1 && i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock);
|
||||
if (list.Count <= 0)
|
||||
{
|
||||
selectPackDto.Info = InfoEnum.SelectBinStatusInfo.NoBattery;
|
||||
return selectPackDto;
|
||||
}
|
||||
|
||||
list = list.Where(i => i.ChargeStatus == 2).ToList();
|
||||
if (list.Count <= 0)
|
||||
{
|
||||
selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOfFinishCharging;
|
||||
return selectPackDto;
|
||||
}
|
||||
|
||||
|
||||
list = list.Where(i => i.Soc > int.Parse(swapSoc)).ToList();
|
||||
if (list.Count <= 0)
|
||||
{
|
||||
selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOfSoc;
|
||||
return selectPackDto;
|
||||
}
|
||||
|
||||
list = list.Where(i => new TimeSpan(DateTime.Now.Ticks -
|
||||
i.LastChargeFinishTime.ToDateTime().Ticks)
|
||||
.TotalMinutes > int.Parse(swapFinishChargeTime)).ToList();
|
||||
if (list.Count <= 0)
|
||||
{
|
||||
selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOf3Minute;
|
||||
return selectPackDto;
|
||||
}
|
||||
|
||||
selectPackDto.BinInfo = list[0];
|
||||
selectPackDto.Info = InfoEnum.SelectBinStatusInfo.Success;
|
||||
selectPackDto.SuccessFlag = true;
|
||||
|
||||
return selectPackDto;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue