You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
namespace Repository.Station;
[Scope("SingleInstance")]
public class ChargeOrderRepository : BaseRepository<ChargeOrder>
{
public ChargeOrderRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
5 months ago
public void SaveChargeGunOrder(string chargeOrder,string chargeOrderNo, string chargerNo, string chargerGunNo,
string outChargerGunNo)
{
ChargeOrder order = new ChargeOrder();
5 months ago
order.Sn = chargeOrder;
order.CmdStatus = 0;
order.ChargerNo = chargerNo;
order.ChargerGunNo = chargerGunNo;
order.OutChargerGunNo = outChargerGunNo;
order.ChargeMode = 1;
order.StartMode = 1;
order.CloudChargeOrder = chargeOrderNo;
order.CreatedTime = DateTime.Now;
5 months ago
Insert(order);
}
public ChargeOrder? GetLatestChargeGunOrder(string pn, string chargerCode)
{
try
{
var chargeOrder = DbBaseClient.Queryable<ChargeOrder>()
.Where(co => co.OutChargerGunNo == pn && co.ChargerNo == chargerCode)
.OrderByDescending(co => co.CreatedTime)
.First();
return chargeOrder;
}
catch (Exception e)
{
return null;
}
}
public ChargeOrder? QueryLatestByBatterySn(string? batterySn)
{
if (string.IsNullOrWhiteSpace(batterySn))
{
return null;
}
return QueryByClause(it => it.BatteryNo == batterySn, it => it.CreatedTime, OrderByType.Desc);
}
/// <summary>
///
/// </summary>
/// <param name="swapOrderNo"></param>
/// <param name="batteryNo"></param>
/// <returns></returns>
public List<ChargeOrder> QueryBySwapOrderAndBatterySn(string? swapOrderNo, string? batteryNo)
{
if (string.IsNullOrWhiteSpace(swapOrderNo) || string.IsNullOrWhiteSpace(batteryNo))
{
return new List<ChargeOrder>(0);
}
return QueryListByClause(it => it.SwapOrderSn == swapOrderNo && it.BatteryNo == batteryNo, it => it.CreatedTime,
OrderByType.Asc);
}
}