Merge remote-tracking branch 'origin/V1.0.2_TboxMerge'

master
lxw 5 months ago
commit acbedfb805

@ -40,4 +40,15 @@ public class SwapVehicleResp
/// 钥匙状态 0: OFF 1: ACC 2: ON 0xFF: 不支持 /// 钥匙状态 0: OFF 1: ACC 2: ON 0xFF: 不支持
/// </summary> /// </summary>
public byte? KeyStatus { get; set; } public byte? KeyStatus { get; set; }
/// <summary>
/// 车辆档位 最小值:-1最大值 14 0x0F表示无效-1 代表倒档 R0 代表空挡 N大于 0 代表前进档 D
/// </summary>
public byte? Gear { get; set; }
/// <summary>
/// 刹车状态 "0:未拉手刹1已拉手刹 其它值无效"
/// </summary>
public byte? Break { get; set; }
} }

@ -15,7 +15,8 @@ public class InfoEnum
[Info("车辆连接失败", "车辆连接失败,请联系站务人员")] ErrorTBoxConn , [Info("车辆连接失败", "车辆连接失败,请联系站务人员")] ErrorTBoxConn ,
[Info("云端校验失败", "云端校验失败,请联系站务人员")] ErrorCloudCheck , [Info("云端校验失败", "云端校验失败,请联系站务人员")] ErrorCloudCheck ,
[Info("车辆已到位", "车辆已到位")] InfoCarInPosition , [Info("车辆已到位", "车辆已到位")] InfoCarInPosition ,
[Info("车辆到位超时", "车辆到位超时")] ErrorCarInPositionTimeout, //TODO:: 录音内容已改
[Info("请熄火挂空挡拉手刹", "请熄火挂空挡拉手刹")] ErrorCarInPositionTimeout,
[Info("云平台下发换电失败", "云平台下发换电超时")] CloudSendSwapError , [Info("云平台下发换电失败", "云平台下发换电超时")] CloudSendSwapError ,

@ -65,7 +65,6 @@ public class StationParamConst
public static readonly string Sevstatus = "Station.Sevstatus"; public static readonly string Sevstatus = "Station.Sevstatus";
/// <summary> /// <summary>
/// 投放时间 /// 投放时间
/// </summary> /// </summary>
@ -179,13 +178,11 @@ public class StationParamConst
#endregion 换电站基础信息 #endregion 换电站基础信息
#region 系统管理-基础设置 #region 系统管理-基础设置
//提交灯光日间时间 //提交灯光日间时间
public static readonly string SetLightDayStartTime = "Station.LightDayStartTime"; public static readonly string SetLightDayStartTime = "Station.LightDayStartTime";
public static readonly string SetLightDayEndTime = "Station.LightDayEndTime"; public static readonly string SetLightDayEndTime = "Station.LightDayEndTime";
#endregion 系统管理-基础设置 #endregion 系统管理-基础设置
//选包策略中最后结束充电时间需要>此值 //选包策略中最后结束充电时间需要>此值
@ -198,9 +195,12 @@ public class StationParamConst
public static readonly string ChargeSoc = "Station.ChargeSoc"; public static readonly string ChargeSoc = "Station.ChargeSoc";
public static readonly string ChargePower = "Station.ChargePower"; public static readonly string ChargePower = "Station.ChargePower";
public static readonly string AutoChargeEnabled = "Station.AutoChargeEnabled"; public static readonly string AutoChargeEnabled = "Station.AutoChargeEnabled";
public static readonly string Eid = "Station.Eid"; public static readonly string Eid = "Station.Eid";
//运营模型 //运营模型
public static readonly string Oid = "Station.Oid"; public static readonly string Oid = "Station.Oid";
//电价模型 //电价模型
public static readonly string Ceid = "Station.Ceid"; public static readonly string Ceid = "Station.Ceid";
@ -208,6 +208,45 @@ public class StationParamConst
public static readonly string StationWay = "Station.StationWay"; public static readonly string StationWay = "Station.StationWay";
public static readonly string StationModel = "Station.StationModel"; public static readonly string StationModel = "Station.StationModel";
#region Tbox
//Tbox是否需要连接
public static readonly string TboxStateConnect = "Tbox.StateConnect";
//Tbox是否需要检测熄火
public static readonly string TboxStateFlameout = "Tbox.StateFlameout";
//Tbox是否需要检测N挡
public static readonly string TboxStateN = "Tbox.StateTboxStateN";
//Tbox是否需要检测手刹
public static readonly string TboxStateBreak = "Tbox.StateHandbrake";
//Tbox是否需要断连
public static readonly string TboxStateDisConnect = "Tbox.StateDisConnect";
public static readonly string TboxStateCarList = "Tbox.TboxStateCarList";
//Tbox是否需要连接
public static readonly string TboxUrlConnect = "Tbox.UrlConnect";
//Tbox 断连url
public static readonly string TboxUrlDisConnect = "Tbox.UrlDisConnect";
//Tbox解锁url
public static readonly string TboxUrlUnLock = "Tbox.UrlUnLock";
//Tbox上锁url
public static readonly string TboxUrlLock = "Tbox.UrlLock";
//Tbox获取车辆信息url
public static readonly string TboxUrlCarInfo = "Tbox.UrlCarInfo";
//Tbox 清除url
public static readonly string TboxUrlClear = "Tbox.UrlClear";
//Tbox 获取所有车辆url
public static readonly string TboxUrlCarInfoList = "Tbox.UrlCarInfoList";
#endregion
#region cloud param #region cloud param
public static readonly string CloudServerMqttVersion = "Cloud.CloudServerMqttVersion"; public static readonly string CloudServerMqttVersion = "Cloud.CloudServerMqttVersion";
@ -220,4 +259,4 @@ public class StationParamConst
public static readonly string CloudPubTopic = "Cloud.CloudPubTopic"; public static readonly string CloudPubTopic = "Cloud.CloudPubTopic";
#endregion #endregion
} }

@ -145,7 +145,7 @@ namespace Service.Cloud.Msg.Host.Req
/// 车朝总里程 /// 车朝总里程
/// 单位:kWh, 保留两位小数 /// 单位:kWh, 保留两位小数
/// </summary> /// </summary>
public float vtm { get; set; } public float? vtm { get; set; }
/// <summary> /// <summary>
/// 车制累计换电次数 /// 车制累计换电次数
/// </summary> /// </summary>

@ -7,6 +7,7 @@ using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Cloud.Resp; using Service.Cloud.Msg.Cloud.Resp;
using Service.Cloud.Msg.Host.Req; using Service.Cloud.Msg.Host.Req;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Execute.Model.Tbox;
using Service.Init; using Service.Init;
namespace Service.Execute.Api; namespace Service.Execute.Api;
@ -56,7 +57,8 @@ public abstract class CloudApi
/// <param name="rfidReadModel"></param> /// <param name="rfidReadModel"></param>
/// <param name="swapOrder"></param> /// <param name="swapOrder"></param>
/// <returns></returns> /// <returns></returns>
public static int UploadSwapOrder(SwapOrder swapOrder, int seq, SwapOrderBattery swapOrderBattery, int uploadType) public static int UploadSwapOrder(SwapOrder swapOrder, int seq, SwapOrderBattery swapOrderBattery, int uploadType
,SwapOrderReportCloud orderReportCloud)
{ {
UploadSwapOrder uploadSwapOrder = new() UploadSwapOrder uploadSwapOrder = new()
@ -71,7 +73,7 @@ public abstract class CloudApi
dbid = swapOrderBattery.UpBatteryNo, dbid = swapOrderBattery.UpBatteryNo,
deno = swapOrderBattery.UpBatteryBinNo, deno = swapOrderBattery.UpBatteryBinNo,
dsoc = swapOrderBattery.UpBatterySoc.ToInt(), dsoc = swapOrderBattery.UpBatterySoc.ToInt(),
// dsoe = swapOrderBattery.UpBatterySoe.ToInt(), //dsoe = swapOrderBattery.UpBatterySoe.ToInt(),
et = swapOrder.SwapEndTime, et = swapOrder.SwapEndTime,
od = 0, od = 0,
ot = swapOrder.VehicleLeaveTime, ot = swapOrder.VehicleLeaveTime,
@ -85,6 +87,7 @@ public abstract class CloudApi
vin = swapOrder.VehicleVin, vin = swapOrder.VehicleVin,
wt = new TimeSpan((swapOrder.SwapEndTime.ToDateTime().Ticks - swapOrder.SwapBeginTime.ToDateTime().Ticks)) wt = new TimeSpan((swapOrder.SwapEndTime.ToDateTime().Ticks - swapOrder.SwapBeginTime.ToDateTime().Ticks))
.TotalSeconds.ToInt(), .TotalSeconds.ToInt(),
vtm=orderReportCloud.Vtm,
}; };
Log.Info( Log.Info(
$" CloudApi UploadSwapOrder seq={seq} SendUploadPowerChangeOrder param={JsonConvert.SerializeObject(uploadSwapOrder)}"); $" CloudApi UploadSwapOrder seq={seq} SendUploadPowerChangeOrder param={JsonConvert.SerializeObject(uploadSwapOrder)}");

@ -2,6 +2,9 @@ using log4net;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Execute.Model.Tbox;
using Service.Init;
using TboxCarInfoModel = Service.Execute.Model.Tbox.TboxCarInfoModel;
namespace Service.Execute.Api; namespace Service.Execute.Api;
@ -9,7 +12,7 @@ public class TBoxApi
{ {
private static readonly ILog Log = LogManager.GetLogger("TboxApi"); private static readonly ILog Log = LogManager.GetLogger("TboxApi");
private static readonly string BASE_URL = "http://localhost:5036/Car"; private static readonly string BASE_URL = "http://localhost:5036";
private static int _times = 5; private static int _times = 5;
private static int _successTimes = 3; private static int _successTimes = 3;
@ -19,20 +22,27 @@ public class TBoxApi
Timeout = TimeSpan.FromSeconds(60) Timeout = TimeSpan.FromSeconds(60)
}; };
/// <summary>
/// /Car/getCarInfo/
/// </summary>
/// <param name="carNo"></param>
/// <returns></returns>
public static async Task<TboxCarInfoModel> GetCarInfo(string carNo) public static async Task<TboxCarInfoModel> GetCarInfo(string carNo)
{ {
Log.Info($" TBoxApi GetCarInfo carNo={carNo}"); Log.Info($" TBoxApi GetCarInfo carNo={carNo}");
string url = BASE_URL + "/getCarInfo/" + carNo; string url = BASE_URL + StaticStationInfo.TboxUrlCarInfo + carNo;
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
TboxCarInfoModel? tboxCarInfoModel = null; Log.Info($"TBoxApi GetCarInfo resp = {s}");
TboxCarInfoModel tboxCarInfoModel = null;
if (!String.IsNullOrWhiteSpace(s)) if (!String.IsNullOrWhiteSpace(s))
{ {
tboxCarInfoModel = JsonConvert.DeserializeObject<TboxCarInfoModel>(s); tboxCarInfoModel = JsonConvert.DeserializeObject<TboxCarInfoModel>(s);
} }
Log.Info($"TBoxApi GetCarInfo resp = {JsonConvert.SerializeObject(tboxCarInfoModel)}");
return tboxCarInfoModel; return tboxCarInfoModel;
} }
catch (Exception e) catch (Exception e)
@ -42,10 +52,15 @@ public class TBoxApi
} }
} }
/// <summary>
/// /Car/Clear
/// </summary>
/// <param name="carNo"></param>
/// <returns></returns>
public static async Task<bool> Reset(string carNo) public static async Task<bool> Reset(string carNo)
{ {
Log.Info(" TBoxApi Reset"); Log.Info(" TBoxApi Reset");
string url = BASE_URL + "/Clear/" + carNo; string url = BASE_URL + StaticStationInfo.TboxUrlClear + carNo;
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -63,25 +78,10 @@ public class TBoxApi
public static async Task<bool> IsConnected(string carNo) public static async Task<bool> IsConnected(string carNo)
{ {
Log.Info($"IsConnected carNo={carNo}"); Log.Info($"IsConnected carNo={carNo}");
string url = BASE_URL + "/getCarInfo/"+carNo; TboxCarInfoModel tboxCarInfoModel = await GetCarInfo(carNo);
try Log.Info($"IsConnected resp={JsonConvert.SerializeObject(tboxCarInfoModel)}");
{
string s = await _httpClient.GetStringAsync(url);
TboxCarInfoModel? tboxCarInfoModel = null;
if (!String.IsNullOrWhiteSpace(s))
{
tboxCarInfoModel = JsonConvert.DeserializeObject<TboxCarInfoModel>(s);
Log.Info($"IsConnected resp={JsonConvert.SerializeObject(tboxCarInfoModel)}");
}
Log.Info($"GetCarInfo resp = {JsonConvert.SerializeObject(tboxCarInfoModel)}"); return tboxCarInfoModel == null ? false : tboxCarInfoModel.Connected;
return tboxCarInfoModel.Connected;
}
catch (Exception e)
{
Log.Error($"IsConnected e = {e}");
return false;
}
} }
@ -99,7 +99,9 @@ public class TBoxApi
bools.Add(unLockCar); bools.Add(unLockCar);
} }
} }
Log.Info($" TBoxApi end UnLockCarManyTimes carNo={carNo} times={_times} resp={JsonConvert.SerializeObject(bools)}");
Log.Info(
$" TBoxApi end UnLockCarManyTimes carNo={carNo} times={_times} resp={JsonConvert.SerializeObject(bools)}");
return bools.Select(i => i).Count() > _successTimes; return bools.Select(i => i).Count() > _successTimes;
} }
@ -117,19 +119,22 @@ public class TBoxApi
bools.Add(unLockCar); bools.Add(unLockCar);
} }
} }
Log.Info($" TBoxApi end LockCarManyTimes carNo={carNo} times={_times} resp={JsonConvert.SerializeObject(bools)}");
Log.Info(
$" TBoxApi end LockCarManyTimes carNo={carNo} times={_times} resp={JsonConvert.SerializeObject(bools)}");
return bools.Select(i => i).Count() > _successTimes; return bools.Select(i => i).Count() > _successTimes;
} }
/// <summary> /// <summary>
/// 车辆解锁 /// 车辆解锁
/// /Car/unLock/
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static async Task<bool> UnLockCar(string carNo) public static async Task<bool> UnLockCar(string carNo)
{ {
Log.Info("UnLockCar"); Log.Info("UnLockCar");
string url = BASE_URL + "/unLock/" + carNo; string url = BASE_URL + StaticStationInfo.TboxUrlUnLock + carNo;
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -144,11 +149,62 @@ public class TBoxApi
return false; return false;
} }
} }
/// <summary>
/// Tbox连接
/// /Car/unLock/
/// </summary>
/// <returns></returns>
public static async Task<bool> Connect(string carNo)
{
Log.Info("TboxConnect");
string url = BASE_URL + StaticStationInfo.TboxUrlConnect + carNo;
try
{
string s = await _httpClient.GetStringAsync(url);
Log.Info($"TboxConnect resp = {s}");
return bool.Parse(s);
}
catch (Exception e)
{
Log.Error($"TboxConnect e = {e}");
return false;
}
}
/// <summary>
/// Tbox断连
/// /Car/unLock/
/// </summary>
/// <returns></returns>
public static async Task<bool> DisConnect(string carNo)
{
Log.Info("TboxDisConnect");
string url = BASE_URL + StaticStationInfo.TboxUrlDisConnect + carNo;
try
{
string s = await _httpClient.GetStringAsync(url);
Log.Info($"TboxDisConnect resp = {s}");
return bool.Parse(s);
}
catch (Exception e)
{
Log.Error($"TboxDisConnect e = {e}");
return false;
}
}
/// <summary>
/// /Car/getCarInfoList
/// </summary>
/// <returns></returns>
public static async Task<List<TboxCarInfoModel>> GetCarInfoList() public static async Task<List<TboxCarInfoModel>> GetCarInfoList()
{ {
Log.Info(" TBoxApi GetCarInfoList start "); Log.Info(" TBoxApi GetCarInfoList start ");
string url = BASE_URL + "/getCarInfoList" ; string url = BASE_URL + StaticStationInfo.TboxUrlCarInfoList;
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -175,7 +231,7 @@ public class TBoxApi
public static async Task<bool> LockCar(string carNo) public static async Task<bool> LockCar(string carNo)
{ {
Log.Info("LockCar"); Log.Info("LockCar");
string url = BASE_URL + "/lock/" + carNo; string url = BASE_URL +StaticStationInfo.TboxUrlLock + carNo;
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -190,4 +246,4 @@ public class TBoxApi
return false; return false;
} }
} }
} }

@ -58,18 +58,22 @@ public class CommonMgr
public void SaveSwapBattery(SwappingStateMachine machine) public void SaveSwapBattery(SwappingStateMachine machine)
{ {
BinInfo UpBin = machine.SwapOrderBatteryInfo.UpBinInfo; BinInfo upBin = machine.SwapOrderBatteryInfo.UpBinInfo;
BinInfo InBin = machine.SwapOrderBatteryInfo.InBinInfo; BinInfo inBin = machine.SwapOrderBatteryInfo.InBinInfo;
SwapOrderBattery swapOrderBattery = new SwapOrderBattery() SwapOrderBattery swapOrderBattery = new SwapOrderBattery()
{ {
SwapOrderSn = machine.SwapOrder.Sn, SwapOrderSn = machine.SwapOrder.Sn,
UpBatterySoc = UpBin.Soc, UpBatterySoc = upBin.Soc,
UpBatteryNo = UpBin.BatteryNo, UpBatteryNo = upBin.BatteryNo,
UpBatterySoe = UpBin.Soe, UpBatterySoe = upBin.Soe,
UpBatteryBinNo = int.Parse(UpBin.No), UpBatteryBinNo = int.Parse(upBin.No),
DownBatteryBinNo = int.Parse(InBin.No), DownBatteryBinNo = int.Parse(inBin.No),
DownBatteryNo = inBin.BatteryNo,
DownBatterySoc = inBin.Soc,
DownBatterySoe = inBin.Soe,
}; };
swapOrderBattery = _swapOrderBatteryRepository.Insert(swapOrderBattery);
_swapOrderBatteryRepository.Insert(swapOrderBattery);
} }
/// <summary> /// <summary>
@ -112,7 +116,7 @@ public class CommonMgr
.TotalMinutes > StaticStationInfo.SwapFinishChargeTime .TotalMinutes > StaticStationInfo.SwapFinishChargeTime
&& i.Soc > StaticStationInfo.Soc && i.Soc > StaticStationInfo.Soc
*/ */
public SwapOrderBatteryInfo SelectPackNotArm() public SwapOrderBatteryInfo SelectPackNotArm(SwappingStateMachine machine)
{ {
SwapOrderBatteryInfo orderBatteryInfo = new SwapOrderBatteryInfo(); SwapOrderBatteryInfo orderBatteryInfo = new SwapOrderBatteryInfo();
UpBin(orderBatteryInfo); UpBin(orderBatteryInfo);
@ -121,12 +125,12 @@ public class CommonMgr
return orderBatteryInfo; return orderBatteryInfo;
} }
InBin(orderBatteryInfo); InBin(orderBatteryInfo, machine);
return orderBatteryInfo; return orderBatteryInfo;
} }
public SwapOrderBatteryInfo SelectPackArm(SwapAmtOrder swapAmtOrder) public SwapOrderBatteryInfo SelectPackArm(SwapAmtOrder swapAmtOrder, SwappingStateMachine machine)
{ {
SwapOrderBatteryInfo orderBatteryInfo = new SwapOrderBatteryInfo(); SwapOrderBatteryInfo orderBatteryInfo = new SwapOrderBatteryInfo();
orderBatteryInfo.swapAmtOrder = swapAmtOrder; orderBatteryInfo.swapAmtOrder = swapAmtOrder;
@ -146,7 +150,7 @@ public class CommonMgr
} }
orderBatteryInfo.UpBinInfo = UpBin; orderBatteryInfo.UpBinInfo = UpBin;
InBin(orderBatteryInfo); InBin(orderBatteryInfo, machine);
return orderBatteryInfo; return orderBatteryInfo;
} }
@ -167,7 +171,7 @@ public class CommonMgr
/// 放电池判断:取出来的电池仓位能不能放 /// 放电池判断:取出来的电池仓位能不能放
/// </summary> /// </summary>
/// <param name="orderBatteryInfo"></param> /// <param name="orderBatteryInfo"></param>
public void InBin(SwapOrderBatteryInfo orderBatteryInfo) public void InBin(SwapOrderBatteryInfo orderBatteryInfo, SwappingStateMachine machine)
{ {
List<BinInfo> list = List<BinInfo> list =
_binInfoRepository.QueryListByClause(i => _binInfoRepository.QueryListByClause(i =>
@ -182,6 +186,19 @@ public class CommonMgr
} }
orderBatteryInfo.InBinInfo = list[0]; orderBatteryInfo.InBinInfo = list[0];
orderBatteryInfo.InBinInfo.BatteryNo = "-1";
orderBatteryInfo.InBinInfo.Soc = -1;
orderBatteryInfo.InBinInfo.Soe = -1;
orderBatteryInfo.InBinInfo.Soh = -1;
var carInfoBatteryInfos = machine.BoxCarInfoModel?.CarInfo?.BatteryInfos;
if (carInfoBatteryInfos != null && carInfoBatteryInfos.Count > 0)
{
orderBatteryInfo.InBinInfo.BatteryNo = carInfoBatteryInfos[0].BatteryNo;
// orderBatteryInfo.InBinInfo.Soc = carInfoBatteryInfos[0].Soc;
orderBatteryInfo.InBinInfo.Soe = carInfoBatteryInfos[0].Soe;
orderBatteryInfo.InBinInfo.Soh = carInfoBatteryInfos[0].Soh;
}
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.Success; orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.Success;
} }
@ -228,17 +245,12 @@ public class CommonMgr
if (machineSwapOrderBatteryInfo != null) if (machineSwapOrderBatteryInfo != null)
{ {
var inBinInfo = machineSwapOrderBatteryInfo.InBinInfo; var inBinInfo = machineSwapOrderBatteryInfo.InBinInfo;
inBinInfo.Soc = -1;
inBinInfo.Soe = -1;
inBinInfo.BatteryNo = "-1";
//修改入仓顺序 //修改入仓顺序
BinInfo binInfo = _binInfoRepository BinInfo binInfo = _binInfoRepository
.QueryListByClause(i => i.BatteryEnterSeq != null, "battery_enter_seq desc").First(); .QueryListByClause(i => i.BatteryEnterSeq != null, "battery_enter_seq desc").First();
inBinInfo.BatteryEnterSeq = binInfo.BatteryEnterSeq + 1; inBinInfo.BatteryEnterSeq = binInfo.BatteryEnterSeq + 1;
inBinInfo.InTime = DateTime.Now; inBinInfo.InTime = DateTime.Now;
_binInfoRepository.Update(inBinInfo); _binInfoRepository.Update(inBinInfo);
var upBinInfo = machineSwapOrderBatteryInfo.UpBinInfo; var upBinInfo = machineSwapOrderBatteryInfo.UpBinInfo;
upBinInfo.Soc = -1; upBinInfo.Soc = -1;
upBinInfo.Soe = -1; upBinInfo.Soe = -1;
@ -255,12 +267,14 @@ public class CommonMgr
public void InsertCloudReportForSwapSuccess(SwappingStateMachine machine) public void InsertCloudReportForSwapSuccess(SwappingStateMachine machine)
{ {
SwapOrder? machineSwapOrder = machine.SwapOrder; SwapOrder? machineSwapOrder = machine.SwapOrder;
_swapOrderReportCloudRepository.Insert(new SwapOrderReportCloud() _swapOrderReportCloudRepository.Insert(new SwapOrderReportCloud()
{ {
SwapOrderSn = machineSwapOrder.Sn, SwapOrderSn = machineSwapOrder.Sn,
SwapOrderId = machineSwapOrder.Id, SwapOrderId = machineSwapOrder.Id,
CloudReportStatus = 0, CloudReportStatus = 0,
Vin = machineSwapOrder.VehicleVin Vin = machineSwapOrder.VehicleVin,
Vtm = Convert.ToSingle(machine.BoxCarInfoModel?.ElecMsg?.TotalMile),
}); });
} }
} }

@ -0,0 +1,23 @@
namespace Service.Execute.Model.Tbox
{
public class BatteryInfo
{
public string? BatteryNo { get; set; }
/// <summary>
/// 电池类型
/// </summary>
public int? BatteryType { get; set; }
/// <summary>
/// 电池包型号
/// </summary>
public int? BatteryPackageModel { get; set; }
public decimal? Soe { get; set; }
public decimal? Soc { get; set; }
public decimal? Soh { get; set; }
}
}

@ -0,0 +1,26 @@
namespace Service.Execute.Model.Tbox;
public class CarInfo
{
public string CarNo { get; set; }
public string CarVin { get; set; }
/// <summary>
/// 车型数据 "0:无效值1:牵引车 2:搅拌车 3:自卸车"
/// </summary>
public byte? CarType { get; set; }
/// <summary>
/// 电池数
/// </summary>
public int BatteryNum { get; set; }
/// <summary>
/// 车辆电池数据
/// </summary>
public List<BatteryInfo>? BatteryInfos { get; set; }
}

@ -0,0 +1,28 @@
namespace Service.Execute.Model.Tbox;
public class CarStatus
{
/// <summary>
/// 车辆档位 最小值:-1最大值 14 0x0F表示无效-1 代表倒档 R0 代表空挡 N大于 0 代表前进档 D
/// </summary>
public byte? Gear { get; set; }
/// <summary>
/// 刹车状态 "0:未拉手刹1已拉手刹 其它值无效"
/// </summary>
public byte? Break { get; set; }
/// <summary>
/// 钥匙状态 "0:OFF1:ACC ON 2:IG ON 其它值无效"
/// </summary>
public byte? Keys { get; set; }
/// <summary>
/// 0未解锁未上锁
/// 1解锁成功
/// 2上锁成功
/// 3无效数据
/// </summary>
public byte? LockStatus { get; set; }
}

@ -1,84 +1,79 @@
using HybirdFrameworkCore.Autofac.Attribute; namespace Service.Execute.Model.Tbox;
namespace Service.Execute.Model; public class ElecMsg
public class TboxElecMsg
{ {
/// <summary>
/// 小计里程 0~16777215
/// </summary>
public double? SubMile { get; set; }
/// <summary>
/// 车辆总里程 0~16777215
/// </summary>
public double? TotalMile { get; set; }
/// <summary> /// <summary>
/// 车辆累计放电量 /// 车辆累计放电量
/// </summary> /// </summary>
[Property(248, 24, scale: 0.01, round: 2)]
public double AccDischargeCount { get; set; } public double AccDischargeCount { get; set; }
/// <summary> /// <summary>
/// 车辆累计回馈电量 /// 车辆累计回馈电量
/// </summary> /// </summary>
[Property(272, 24, scale: 0.01, round: 2)]
public double AccFallbackCount { get; set; } public double AccFallbackCount { get; set; }
/// <summary> /// <summary>
/// 车辆累计插枪充电量 /// 车辆累计插枪充电量
/// </summary> /// </summary>
[Property(296, 24, scale: 0.01, round: 2)]
public double AccChargeCount { get; set; } public double AccChargeCount { get; set; }
/// <summary> /// <summary>
/// 5 车辆累计综合能耗 /// 5 车辆累计综合能耗
/// </summary> /// </summary>
[Property(320, 24, scale: 0.01, round: 2)]
public double AccKgce { get; set; } public double AccKgce { get; set; }
/// <summary> /// <summary>
/// 6 本次实时放电量 /// 6 本次实时放电量
/// </summary> /// </summary>
[Property(344, 24, scale: 0.01, round: 2)]
public double ThisTimeRealDischarge { get; set; } public double ThisTimeRealDischarge { get; set; }
/// <summary> /// <summary>
/// 7 上一次结算放电量 /// 7 上一次结算放电量
/// </summary> /// </summary>
[Property(368, 24, scale: 0.01, round: 2)]
public double LastTimeBalanceDischarge { get; set; } public double LastTimeBalanceDischarge { get; set; }
/// <summary> /// <summary>
/// 8 本次实时回馈电量 /// 8 本次实时回馈电量
/// </summary> /// </summary>
[Property(392, 24, scale: 0.01, round: 2)]
public double ThisTimeRealFeedbackPower { get; set; } public double ThisTimeRealFeedbackPower { get; set; }
/// <summary> /// <summary>
/// 9 上一次结算回馈电量 /// 9 上一次结算回馈电量
/// </summary> /// </summary>
[Property(416, 24, scale: 0.01, round: 2)]
public double LastTimeBalanceFeedbackPower { get; set; } public double LastTimeBalanceFeedbackPower { get; set; }
/// <summary> /// <summary>
/// 10 本次实时插枪充电量 /// 10 本次实时插枪充电量
/// </summary> /// </summary>
[Property(440, 24, scale: 0.01, round: 2)]
public double ThisTimeRealChargeCount { get; set; } public double ThisTimeRealChargeCount { get; set; }
/// <summary> /// <summary>
/// 11 上一次结算插枪充电量 /// 11 上一次结算插枪充电量
/// </summary> /// </summary>
[Property(464, 24, scale: 0.01, round: 2)]
public double LastTimeBalanceChargeCount { get; set; } public double LastTimeBalanceChargeCount { get; set; }
/// <summary> /// <summary>
/// 12 本次实时综合能耗 /// 12 本次实时综合能耗
/// </summary> /// </summary>
[Property(488, 24, scale: 0.01, round: 2)]
public double ThisTimeRealKgce { get; set; } public double ThisTimeRealKgce { get; set; }
/// <summary> /// <summary>
/// 13 上一次结算综合能耗 /// 13 上一次结算综合能耗
/// </summary> /// </summary>
[Property(512, 24, scale: 0.01, round: 2)]
public double LastTimeBalanceKgce { get; set; } public double LastTimeBalanceKgce { get; set; }
/// <summary> /// <summary>
/// 14 待结算电费电量 /// 14 待结算电费电量
/// </summary> /// </summary>
[Property(536, 24, scale: 0.01, round: 2)]
public double ElectricityToBeSettled { get; set; } public double ElectricityToBeSettled { get; set; }
} }

@ -0,0 +1,27 @@
namespace Service.Execute.Model.Tbox;
/// <summary>
/// 车辆返回
/// </summary>
public class TboxCarInfoModel
{
public bool Connected { get; set; }
public string CarNo { get; set; }
/// <summary>
/// 度电数据
/// </summary>
/// <returns></returns>
public ElecMsg? ElecMsg { get; set; }
/// <summary>
/// 车辆信息
/// </summary>
public CarInfo? CarInfo { get; set; }
/// <summary>
/// 车辆状态信息
/// </summary>
public CarStatus? CarStatus { get; set; }
}

@ -1,27 +0,0 @@
namespace Service.Execute.Model;
/// <summary>
/// 车辆数据
/// </summary>
public class TboxCarInfoModel
{
/// <summary>
/// 连接状态
/// </summary>
public bool Connected { get; set; }
/// <summary>
/// 车牌号
/// </summary>
public string? CarNo { get; set; }
/// <summary>
/// 度电数据
/// </summary>
public TboxElecMsg? ElecMsg { get; set; }
/// <summary>
/// 状态数据
/// </summary>
public TboxHeartBeatMsg? HeartBeatMsg { get; set; }
}

@ -5,6 +5,7 @@ using HybirdFrameworkCore.Autofac;
using log4net; using log4net;
using Service.Execute.Api; using Service.Execute.Api;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Execute.Model.Tbox;
using Service.Execute.StaticTools; using Service.Execute.StaticTools;
using Service.Execute.SwapException; using Service.Execute.SwapException;
using Service.Execute.Utils; using Service.Execute.Utils;
@ -19,6 +20,8 @@ public class CarCtrlState : IState
public StateResult Handle(SwappingStateMachine machine) public StateResult Handle(SwappingStateMachine machine)
{ {
//解锁车辆 //解锁车辆
InvokeStatus unLockCar = UnLockCar(machine); InvokeStatus unLockCar = UnLockCar(machine);
if (unLockCar != InvokeStatus.Done) if (unLockCar != InvokeStatus.Done)
@ -57,9 +60,10 @@ public class CarCtrlState : IState
{ {
//查询车辆锁止状态 //查询车辆锁止状态
Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
var resultHeartBeatMsg = carInfo.Result.HeartBeatMsg; var resultHeartBeatMsg = carInfo.Result.CarStatus;
if (resultHeartBeatMsg.LockStatus == 1 || resultHeartBeatMsg.LockStatus==0) if (resultHeartBeatMsg?.LockStatus == 1)
{ {
machine.BoxCarInfoModel = carInfo.Result;
machine.VelUnlockFlag = true; machine.VelUnlockFlag = true;
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag, _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag,
machine); machine);

@ -10,6 +10,7 @@ using Repository.Station;
using Service.Cloud.Msg.Cloud.Resp; using Service.Cloud.Msg.Cloud.Resp;
using Service.Execute.Api; using Service.Execute.Api;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Execute.Model.Tbox;
using Service.Execute.StaticTools; using Service.Execute.StaticTools;
using Service.Execute.SwapException; using Service.Execute.SwapException;
using Service.Execute.Utils; using Service.Execute.Utils;
@ -47,6 +48,16 @@ public class CarPrepareState : IState
return SwappingStateMachine.ReturnWithInvokeErr(cloudCheckVel, ExceptionReason.None); return SwappingStateMachine.ReturnWithInvokeErr(cloudCheckVel, ExceptionReason.None);
} }
//TBox连接
if (StaticStationInfo.TboxStateConnect)
{
InvokeStatus tboxConnect = TboxConnect(machine);
if (tboxConnect != InvokeStatus.Done)
{
return SwappingStateMachine.ReturnWithInvokeErr(tboxConnect, ExceptionReason.None);
}
}
//检查tbox链接状态 //检查tbox链接状态
InvokeStatus checkTBoxConnect = CheckTBoxConnectFlag(machine); InvokeStatus checkTBoxConnect = CheckTBoxConnectFlag(machine);
if (checkTBoxConnect != InvokeStatus.Done) if (checkTBoxConnect != InvokeStatus.Done)
@ -78,6 +89,7 @@ public class CarPrepareState : IState
return SwappingStateMachine.ReturnWithInvokeErr(selectPack, ExceptionReason.None); return SwappingStateMachine.ReturnWithInvokeErr(selectPack, ExceptionReason.None);
} }
//车辆到位 //车辆到位
InvokeStatus carInPosition = CarInPosition(machine); InvokeStatus carInPosition = CarInPosition(machine);
if (carInPosition != InvokeStatus.Done) if (carInPosition != InvokeStatus.Done)
@ -98,13 +110,46 @@ public class CarPrepareState : IState
/// <returns></returns> /// <returns></returns>
public InvokeStatus CarInPosition(SwappingStateMachine machine) public InvokeStatus CarInPosition(SwappingStateMachine machine)
{ {
return Invoker.Invoke("check CarInPosition", 500, 50, machine.IsCanceled, return Invoker.Invoke("check CarInPosition", 500, 5, machine.IsCanceled,
() => machine.VehiclesInPlaceFlag, () => () => machine.VehiclesInPlaceFlag, () =>
{ {
var result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); var result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
int succCount = 0;
List<bool> succL = new List<bool>()
{
StaticStationInfo.TboxStateFlameout, StaticStationInfo.TboxStateBreak, StaticStationInfo.TboxStateN
};
var successCount = succL.Where(i => i).Count();
TboxCarInfoModel tboxCarInfoModel = result.Result; TboxCarInfoModel tboxCarInfoModel = result.Result;
if (tboxCarInfoModel.HeartBeatMsg.KeyStatus == 0) var status = tboxCarInfoModel?.CarStatus;
if (StaticStationInfo.TboxStateFlameout)
{
if (status?.Keys == 0)
{
succCount++;
}
}
if (StaticStationInfo.TboxStateBreak)
{
if (status?.Break == 1)
{
succCount++;
}
}
if (StaticStationInfo.TboxStateN)
{
if (status?.Gear == 0)
{
succCount++;
}
}
if (succCount == successCount)
{ {
machine.VehiclesInPlaceFlag = true; machine.VehiclesInPlaceFlag = true;
//写入口等 :红灯 //写入口等 :红灯
@ -123,6 +168,7 @@ public class CarPrepareState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag, _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
machine); machine);
machine.BoxCarInfoModel = tboxCarInfoModel;
} }
} }
}, () => }, () =>
@ -131,7 +177,7 @@ public class CarPrepareState : IState
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed()); // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorCarInPositionTimeout.GetLed());
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout); SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorCarInPositionTimeout);
}, false, () => { } }, false, () => { }
, 20, InvokeStatus.None); , 10, InvokeStatus.None);
} }
@ -148,9 +194,10 @@ public class CarPrepareState : IState
BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>( BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
StaticStationInfo.StationModel)) StaticStationInfo.StationModel))
{ {
VehicleCertificationResp? vehicleCertificationResp = CloudApi.VehicleCheck(machine.RfidReadModel, machine.SwapOrder); VehicleCertificationResp? vehicleCertificationResp =
CloudApi.VehicleCheck(machine.RfidReadModel, machine.SwapOrder);
if (vehicleCertificationResp==null || vehicleCertificationResp.re!=0) if (vehicleCertificationResp == null || vehicleCertificationResp.re != 0)
{ {
_log.Info("cloud check vehicle error"); _log.Info("cloud check vehicle error");
// machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成"); // machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成");
@ -208,6 +255,44 @@ public class CarPrepareState : IState
} }
/// <summary>
/// 连接TBox
/// </summary
/// <returns></returns>
public InvokeStatus TboxConnect(SwappingStateMachine machine)
{
return Invoker.Invoke("TBox connect", 1000, 10, machine.IsCanceled,
() => machine.BoxConnectFlag, () =>
{
Task<bool> result = TBoxApi.Connect(machine.RfidReadModel.VelVin);
bool isConnect = result.Result;
if (isConnect)
{
//读取车辆carNo=carVin
Task<TboxCarInfoModel> carInfoResult = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
var tboxCarInfoModel = carInfoResult.Result;
var carInfo = tboxCarInfoModel?.CarInfo;
if (carInfo != null)
{
if (carInfo.CarNo.Equals(carInfo.CarVin))
{
machine.BoxConnectFlag = true;
}
}
}
}, () =>
{
machine.ExceptionReason = ExceptionReason.ConnTBoxError;
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn);
}, false, () =>
{
machine.ExceptionReason = ExceptionReason.ConnTBoxError;
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrorTBoxConn.GetLed());
}
, 20, InvokeStatus.None);
}
/// <summary> /// <summary>
/// 车辆本地验证:车牌校验 /// 车辆本地验证:车牌校验
/// </summary> /// </summary>
@ -285,11 +370,11 @@ public class CarPrepareState : IState
SwapOrderBatteryInfo orderBatteryInfo = null; SwapOrderBatteryInfo orderBatteryInfo = null;
if (swapAmtOrder != null) if (swapAmtOrder != null)
{ {
orderBatteryInfo = _CommonMgr.SelectPackArm(swapAmtOrder); orderBatteryInfo = _CommonMgr.SelectPackArm(swapAmtOrder, machine);
} }
else else
{ {
orderBatteryInfo = _CommonMgr.SelectPackNotArm(); orderBatteryInfo = _CommonMgr.SelectPackNotArm(machine);
} }
if (orderBatteryInfo.CanSwap != InfoEnum.SelectBinStatusInfo.Success) if (orderBatteryInfo.CanSwap != InfoEnum.SelectBinStatusInfo.Success)

@ -6,9 +6,11 @@ using log4net;
using Repository.Station; using Repository.Station;
using Service.Execute.Api; using Service.Execute.Api;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Execute.Model.Tbox;
using Service.Execute.StaticTools; using Service.Execute.StaticTools;
using Service.Execute.SwapException; using Service.Execute.SwapException;
using Service.Execute.Utils; using Service.Execute.Utils;
using Service.Init;
using Service.Station; using Service.Station;
namespace Service.Execute.Step; namespace Service.Execute.Step;
@ -414,7 +416,40 @@ public class DoSwappingState : IState
var result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); var result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
TboxCarInfoModel tboxCarInfoModel = result.Result; TboxCarInfoModel tboxCarInfoModel = result.Result;
if (tboxCarInfoModel.HeartBeatMsg.KeyStatus == 0) int succCount = 0;
List<bool> succL = new List<bool>()
{
StaticStationInfo.TboxStateFlameout, StaticStationInfo.TboxStateBreak, StaticStationInfo.TboxStateN
};
var successCount = succL.Where(i => i).Count();
var status = tboxCarInfoModel?.CarStatus;
if (StaticStationInfo.TboxStateFlameout)
{
if (status?.Keys == 0)
{
succCount++;
}
}
if (StaticStationInfo.TboxStateBreak)
{
if (status?.Break == 1)
{
succCount++;
}
}
if (StaticStationInfo.TboxStateN)
{
if (status?.Gear == 0)
{
succCount++;
}
}
if (succCount==successCount)
{ {
machine.VehiclesInPlace2Flag = true; machine.VehiclesInPlace2Flag = true;
} }

@ -6,9 +6,11 @@ using log4net;
using Repository.Station; using Repository.Station;
using Service.Execute.Api; using Service.Execute.Api;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Execute.Model.Tbox;
using Service.Execute.StaticTools; using Service.Execute.StaticTools;
using Service.Execute.SwapException; using Service.Execute.SwapException;
using Service.Execute.Utils; using Service.Execute.Utils;
using Service.Init;
using Service.Station; using Service.Station;
namespace Service.Execute.Step; namespace Service.Execute.Step;
@ -101,8 +103,9 @@ public class SwapDoneState : IState
{ {
//查询车辆锁止状态 //查询车辆锁止状态
Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
if (carInfo.Result.HeartBeatMsg!.LockStatus == 2) if (carInfo.Result?.CarStatus?.LockStatus == 2)
{ {
machine.BoxCarInfoModel = carInfo.Result;
//设置出口的是绿灯 //设置出口的是绿灯
if (PlcApi.WriteExistLamp(1000)) if (PlcApi.WriteExistLamp(1000))
{ {
@ -114,7 +117,11 @@ public class SwapDoneState : IState
? (int)InfoEnum.SwapInfo.InfoCarLeave ? (int)InfoEnum.SwapInfo.InfoCarLeave
: (int)InfoEnum.SwapInfo.ErrInfoCarLeave); : (int)InfoEnum.SwapInfo.ErrInfoCarLeave);
machine.VelLockFlag = true; machine.VelLockFlag = true;
//断连Tbox
if (StaticStationInfo.TboxStateDisConnect)
{
TBoxApi.DisConnect(machine.BoxCarInfoModel.CarNo);
}
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag,
machine); machine);

@ -8,6 +8,7 @@ using Newtonsoft.Json;
using Repository.Station; using Repository.Station;
using Service.Execute.Api; using Service.Execute.Api;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Execute.Model.Tbox;
using Service.Execute.StaticTools; using Service.Execute.StaticTools;
using Service.Execute.Step; using Service.Execute.Step;
using Service.Execute.SwapException; using Service.Execute.SwapException;
@ -28,9 +29,9 @@ public class SwappingStateMachine : IDisposable
public bool StopFlag { get; set; } = false; public bool StopFlag { get; set; } = false;
public bool PlcSwapFlag { get; set; } = false; public bool PlcSwapFlag { get; set; } = false;
//手动确认换电成功 //手动确认换电成功
public bool ManualSwapSuccFlag { get; set; }=false; public bool ManualSwapSuccFlag { get; set; } = false;
public OperateModel OperateModel = null; public OperateModel OperateModel = null;
@ -156,7 +157,7 @@ public class SwappingStateMachine : IDisposable
_dictionary[SwappingState.SwapDone] = new SwapDoneState(); _dictionary[SwappingState.SwapDone] = new SwapDoneState();
_dictionary[SwappingState.Exception] = new ExceptionState(); _dictionary[SwappingState.Exception] = new ExceptionState();
_dictionary[SwappingState.Canceled] = new CancelState(); _dictionary[SwappingState.Canceled] = new CancelState();
_dictionary[SwappingState.ManualSucc] = new CancelState(); _dictionary[SwappingState.ManualSucc] = new ManualSuccState();
LedTool = new LedTool(); LedTool = new LedTool();
@ -227,7 +228,7 @@ public class SwappingStateMachine : IDisposable
{ {
return CancelFlag; return CancelFlag;
} }
public bool IsManualSwapSucc() public bool IsManualSwapSucc()
{ {
return ManualSwapSuccFlag; return ManualSwapSuccFlag;
@ -245,7 +246,7 @@ public class SwappingStateMachine : IDisposable
{ {
Log.Info("reset data"); Log.Info("reset data");
ResetOrderAmtStatus(); ResetOrderAmtStatus();
if (RfidReadModel != null && RfidReadModel.VelNo != null) if (RfidReadModel != null)
{ {
//wifi数据重置 //wifi数据重置
TBoxApi.Reset(RfidReadModel.VelVin); TBoxApi.Reset(RfidReadModel.VelVin);

@ -72,6 +72,90 @@ public class StaticStationInfo
set => Set(StationParamConst.SwapSoc, value); set => Set(StationParamConst.SwapSoc, value);
} }
#region Tbox
public static bool TboxStateConnect
{
get => bool.Parse(Resolve(StationParamConst.TboxStateConnect));
set => Set(StationParamConst.TboxStateConnect, value);
}
public static bool TboxStateFlameout
{
get => bool.Parse(Resolve(StationParamConst.TboxStateFlameout));
set => Set(StationParamConst.TboxStateFlameout, value);
}
public static bool TboxStateN
{
get => bool.Parse(Resolve(StationParamConst.TboxStateN));
set => Set(StationParamConst.TboxStateN, value);
}
public static bool TboxStateCarList
{
get => bool.Parse(Resolve(StationParamConst.TboxStateCarList));
set => Set(StationParamConst.TboxStateCarList, value);
}
public static bool TboxStateBreak
{
get => bool.Parse(Resolve(StationParamConst.TboxStateBreak));
set => Set(StationParamConst.TboxStateBreak, value);
}
public static bool TboxStateDisConnect
{
get => bool.Parse(Resolve(StationParamConst.TboxStateDisConnect));
set => Set(StationParamConst.TboxStateDisConnect, value);
}
public static string TboxUrlDisConnect
{
get => Resolve(StationParamConst.TboxUrlDisConnect);
set => Set(StationParamConst.TboxUrlDisConnect, value);
}
public static string TboxUrlConnect
{
get => Resolve(StationParamConst.TboxUrlConnect);
set => Set(StationParamConst.TboxUrlConnect, value);
}
public static string TboxUrlLock
{
get => Resolve(StationParamConst.TboxUrlLock);
set => Set(StationParamConst.TboxUrlLock, value);
}
public static string TboxUrlUnLock
{
get => Resolve(StationParamConst.TboxUrlUnLock);
set => Set(StationParamConst.TboxUrlUnLock, value);
}
public static string TboxUrlCarInfoList
{
get => Resolve(StationParamConst.TboxUrlCarInfoList);
set => Set(StationParamConst.TboxUrlCarInfoList, value);
}
public static string TboxUrlCarInfo
{
get => Resolve(StationParamConst.TboxUrlCarInfo);
set => Set(StationParamConst.TboxUrlUnLock, value);
}
public static string TboxUrlClear
{
get => Resolve(StationParamConst.TboxUrlClear);
set => Set(StationParamConst.TboxUrlClear, value);
}
#endregion
#region 充电相关 #region 充电相关
public static int Eid public static int Eid
@ -145,6 +229,7 @@ public class StaticStationInfo
get => Resolve(StationParamConst.CloudServerMqttVersion, "4.0.0"); get => Resolve(StationParamConst.CloudServerMqttVersion, "4.0.0");
set => Set(StationParamConst.CloudServerMqttVersion, value); set => Set(StationParamConst.CloudServerMqttVersion, value);
} }
public static string CloudClientId public static string CloudClientId
{ {
get => Resolve(StationParamConst.CloudClientId); get => Resolve(StationParamConst.CloudClientId);
@ -208,4 +293,4 @@ public class StaticStationInfo
} }
#endregion #endregion
} }

@ -35,7 +35,8 @@ public class SwapOrderMgr
List<SwapOrderBattery> batterys = List<SwapOrderBattery> batterys =
_swapOrderBatteryRepository.QueryListByClause(i => _swapOrderBatteryRepository.QueryListByClause(i =>
swapOrderSn.Contains(i.SwapOrderSn) && i.DownBatteryNo != null); swapOrderSn.Contains(i.SwapOrderSn) && i.DownBatteryNo != null && i.DownBatteryNo!="-1"
&& i.DownBatterySoc!=-1 && i.DownBatterySoc!=null);
if (batterys.Count <= 0) if (batterys.Count <= 0)
{ {
@ -59,7 +60,12 @@ public class SwapOrderMgr
continue; continue;
} }
if (null == swapOrderBattery.DownBatteryNo)
if (null == swapOrderBattery.DownBatteryNo || "-1".Equals(swapOrderBattery.DownBatteryNo))
{
continue;
}
if (null == swapOrderBattery.DownBatterySoc || -1==swapOrderBattery.DownBatterySoc)
{ {
continue; continue;
} }
@ -71,9 +77,9 @@ 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);
swapOrderReportClouds.TryGetValue(swapOrder.Id, out SwapOrderReportCloud value); swapOrderReportClouds.TryGetValue(swapOrder.Id, out SwapOrderReportCloud value);
var uploadSwapOrder = CloudApi.UploadSwapOrder(swapOrder, count++, swapOrderBattery, uploadType,value);
if (uploadSwapOrder == 0) if (uploadSwapOrder == 0)
{ {
swapOrder.CloudReportStatus = 1; swapOrder.CloudReportStatus = 1;

@ -39,7 +39,7 @@ public class UpdateDownBatteryInfoTask : ITask
{ {
List<SwapOrderBattery> batterys = List<SwapOrderBattery> batterys =
_swapOrderBatteryRepository.QueryListByClause( _swapOrderBatteryRepository.QueryListByClause(
i => i.DownBatteryNo == null && i.DownBatteryBinNo != null); i => (i.DownBatteryNo == null || i.DownBatterySoc<0) && i.DownBatteryBinNo != null);
if (batterys.Count <= 0) if (batterys.Count <= 0)

@ -183,6 +183,7 @@ public class PlcMgr
{ {
if (PlcClient != null) if (PlcClient != null)
{ {
ResetPlc();
return PlcToHostData.TaskType.Value == taskNo; return PlcToHostData.TaskType.Value == taskNo;
} }

@ -56,14 +56,17 @@ public class MonitorService
VelMac = StationSoftMgr.SwappingStateMachine.RfidReadModel != null VelMac = StationSoftMgr.SwappingStateMachine.RfidReadModel != null
? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelMac ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelMac
: null, : null,
LockStatus = tboxCarInfoModel != null ? tboxCarInfoModel.HeartBeatMsg.LockStatus : null, LockStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus.LockStatus : null,
KeyStatus = tboxCarInfoModel != null ? tboxCarInfoModel.HeartBeatMsg.KeyStatus : null, KeyStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus.Keys : null,
VelNo = StationSoftMgr.SwappingStateMachine.RfidReadModel != null VelNo = StationSoftMgr.SwappingStateMachine.RfidReadModel != null
? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo
: null, : null,
VelVin = StationSoftMgr.SwappingStateMachine.RfidReadModel != null VelVin = StationSoftMgr.SwappingStateMachine.RfidReadModel != null
? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelVin ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelVin
: null, : null,
Break = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Break,
Gear = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Gear,
}, },
BatteryInfo = new() BatteryInfo = new()
{ {

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc;
using Service.Execute; using Service.Execute;
using Service.Execute.Api; using Service.Execute.Api;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Execute.Model.Tbox;
using Service.Init; using Service.Init;
using Service.Plc.Client; using Service.Plc.Client;
using Service.Station; using Service.Station;
@ -269,6 +270,20 @@ public class SwapMonitorController : ControllerBase
[HttpGet("GetCarList")] [HttpGet("GetCarList")]
public async Task<Result<List<TboxCarInfoModel>>> GetCarList() public async Task<Result<List<TboxCarInfoModel>>> GetCarList()
{ {
//兼容不能查车辆列表的,就获取当前换电车辆
if (!StaticStationInfo.TboxStateCarList)
{
if (StationSoftMgr.SwappingStateMachine.BoxCarInfoModel == null)
{
return Result<List<TboxCarInfoModel>>.Success(new List<TboxCarInfoModel>());
}
return Result<List<TboxCarInfoModel>>.Success(new()
{
StationSoftMgr.SwappingStateMachine.BoxCarInfoModel
});
}
var carInfoList = await TBoxApi.GetCarInfoList(); var carInfoList = await TBoxApi.GetCarInfoList();
if (carInfoList == null || carInfoList.Count <= 0) if (carInfoList == null || carInfoList.Count <= 0)
{ {

Loading…
Cancel
Save