提出选包,将枚举挪到entity .换电站reslove Autofac bean

zw
lxw 6 months ago
parent de9d5ae6fc
commit 3a8de78a25

@ -1,8 +1,8 @@
using System.Reflection;
namespace Swapping.Business.Tech;
namespace Entity.Attr;
public class InfoAttribute : Attribute
public class InfoAttribute : System.Attribute
{
private string _Led;
private string _Sound;
@ -32,7 +32,7 @@ public static class InfoExtend
FieldInfo? fieldInfo = type.GetField(value.ToString());
if (fieldInfo != null && fieldInfo.IsDefined(typeof(InfoAttribute), true))
{
Attribute? attribute = fieldInfo.GetCustomAttribute(typeof(InfoAttribute));
System.Attribute? attribute = fieldInfo.GetCustomAttribute(typeof(InfoAttribute));
if (attribute != null)
{
return ((InfoAttribute)attribute).GetLed();
@ -48,7 +48,7 @@ public static class InfoExtend
FieldInfo? fieldInfo = type.GetField(value.ToString());
if (fieldInfo != null && fieldInfo.IsDefined(typeof(InfoAttribute), true))
{
Attribute? attribute = fieldInfo.GetCustomAttribute(typeof(InfoAttribute));
System.Attribute? attribute = fieldInfo.GetCustomAttribute(typeof(InfoAttribute));
if (attribute != null)
{
return ((InfoAttribute)attribute).GetSound();

@ -1,8 +1,8 @@
using System.Reflection;
namespace Service.Execute.Tech;
namespace Entity.Attr;
public class RemarkAttribute : Attribute
public class RemarkAttribute : System.Attribute
{
private string _Remark;
@ -25,7 +25,7 @@ public static class RemarkExtend
FieldInfo? fieldInfo = type.GetField(value.ToString());
if (fieldInfo != null && fieldInfo.IsDefined(typeof(RemarkAttribute), true))
{
Attribute? attribute = fieldInfo.GetCustomAttribute(typeof(RemarkAttribute));
System.Attribute? attribute = fieldInfo.GetCustomAttribute(typeof(RemarkAttribute));
if (attribute != null)
{
return ((RemarkAttribute)attribute).GetRemark();

@ -1,7 +1,6 @@
using Service.Execute.Tech;
using Swapping.Business.Tech;
using Entity.Attr;
namespace Service.Execute.Enum;
namespace Entity.Constant;
public class InfoEnum
{

@ -40,7 +40,7 @@ namespace Entity.DbModel.Station
public string BatteryType {get;set;}
/// <summary>
/// Desc:车辆vin码
/// Desc:车牌号
/// Default:
/// Nullable:True
/// </summary>
@ -151,10 +151,6 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName="updated_time")]
public DateTime? UpdatedTime {get;set;}
/// <summary>
/// 车牌
/// </summary>
public string VehicleNo { get; set; }
}
}

@ -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;
}
}

@ -1,11 +1,11 @@
using Entity.DbModel.Station;
using Entity.Constant;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Repository.Station;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Host.Resp;
using Service.Execute.Enum;
using Service.Init;
namespace Service.Cloud.Handler;

@ -1,8 +1,8 @@
using Entity.Constant;
using Entity.DbModel.Station;
using log4net;
using Service.Cloud.Client;
using Service.Cloud.Msg.Cloud.Req;
using Service.Execute.Enum;
using Service.Execute.Model;
namespace Service.Execute.Api;

@ -1,6 +1,6 @@
using Entity.Constant;
using Entity.DbModel.Station;
using NewLife.Common;
using Service.Execute.Enum;
namespace Service.Execute.Model;

@ -1,14 +1,16 @@
using log4net;
using Autofac;
using Entity.Constant;
using HybirdFrameworkCore.Autofac;
using log4net;
using Repository.Station;
using Service.Execute.Enum;
namespace Service.Execute.Step;
public class CancelState : IState
{
private SwapOrderRepository SwapOrderRepository { get; set; }
private readonly SwapOrderRepository _swapOrderRepository= AppInfo.Container.Resolve<SwapOrderRepository>();
private SwapAmtOrderRepository SwapAmtOrderRepository { get; set; }
private readonly SwapAmtOrderRepository _swapAmtOrderRepository = AppInfo.Container.Resolve<SwapAmtOrderRepository>();
private static readonly ILog _log = LogManager.GetLogger(typeof(CancelState));
public StateResult Handle(SwappingStateMachine machine)
@ -18,13 +20,13 @@ public class CancelState : IState
if (machine.SwapOrderBatteryInfo.swapAmtOrder != null)
{
machine.SwapOrderBatteryInfo.swapAmtOrder.Status = (byte)InfoEnum.AmtOrderStatus.SwapFail;
SwapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder);
_swapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder);
}
if (machine.SwapOrder != null)
{
machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Fail;
SwapOrderRepository.Update(machine.SwapOrder);
_swapOrderRepository.Update(machine.SwapOrder);
}
machine.Reset();

@ -1,11 +1,11 @@
using log4net;
using Entity.Attr;
using Entity.Constant;
using log4net;
using Service.Execute.Api;
using Service.Execute.Enum;
using Service.Execute.Model;
using Service.Execute.StaticTools;
using Service.Execute.SwapException;
using Service.Station;
using Swapping.Business.Tech;
namespace Service.Execute.Step;

@ -1,16 +1,18 @@
using AutoMapper;
using Autofac;
using AutoMapper;
using Entity.Attr;
using Entity.Constant;
using Entity.DbModel.Station;
using Entity.Dto;
using HybirdFrameworkCore.Autofac;
using log4net;
using Repository.Station;
using Service.Execute.Api;
using Service.Execute.Enum;
using Service.Execute.Model;
using Service.Execute.StaticTools;
using Service.Execute.SwapException;
using Service.Init;
using Service.Station;
using Swapping.Business.Tech;
namespace Service.Execute.Step;
@ -19,11 +21,11 @@ public class CarPrepareState : IState
private readonly ILog _log = LogManager.GetLogger(typeof(CarPrepareState));
private BinInfoRepository BinInfoRepository { get; set; }
public SwapOrderStepService SwapOrderStepService { get; set; }
private SwapAmtOrderRepository AmtOrderRepository { get; set; }
private readonly BinInfoRepository _binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
private readonly SwapOrderStepService _swapOrderStepService = AppInfo.Container.Resolve<SwapOrderStepService>();
private readonly SwapAmtOrderRepository _amtOrderRepository = AppInfo.Container.Resolve<SwapAmtOrderRepository>();
private SwapOrderBatteryRepository SwapOrderBatteryRepository { get; set; }
private readonly SwapOrderBatteryRepository _swapOrderBatteryRepository = AppInfo.Container.Resolve<SwapOrderBatteryRepository>();
public StateResult Handle(SwappingStateMachine machine)
{
@ -119,7 +121,7 @@ public class CarPrepareState : IState
//清除下发的指令,等待新的指令
CloudApi.ClearCarCanStartInfo();
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CarInPositionFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
}
@ -158,7 +160,7 @@ public class CarPrepareState : IState
machine.CloudVelCheckFlag = true;
machine.LedTool.WriteProgramContent("换电准备中:云平台车辆验证完成");
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
}
@ -266,8 +268,8 @@ public class CarPrepareState : IState
public InvokeStatus SelectPack(SwappingStateMachine machine)
{
SwapAmtOrder? swapAmtOrder =
AmtOrderRepository.QueryByClause(i =>
i.Status == (int)InfoEnum.AmtOrderStatus.Success && i.VehicleNo.Equals(machine.BoxCarInfoModel.CarNo));
_amtOrderRepository.QueryByClause(i =>
i.Status == (int)InfoEnum.AmtOrderStatus.Success && i.CarNo.Equals(machine.BoxCarInfoModel.CarNo));
return Invoker.Invoke("selectPack", 500, 20, machine.IsCanceled,
@ -315,7 +317,7 @@ public class CarPrepareState : IState
UpBatteryBinNo = int.Parse(UpBin.No),
DownBatteryBinNo = int.Parse(InBin.No),
};
SwapOrderBatteryRepository.Insert(swapOrderBattery);
_swapOrderBatteryRepository.Insert(swapOrderBattery);
}
/// <summary>
@ -330,7 +332,7 @@ public class CarPrepareState : IState
BinInfo dbBinInfo = mapperBinInfo.Map<BinInfo>(orderBatteryInfo.UpBinInfo);
dbBinInfo.AmtLock = (int)InfoEnum.AmtBatLockStatus.Lock;
BinInfoRepository.Update(dbBinInfo);
_binInfoRepository.Update(dbBinInfo);
if (!orderBatteryInfo.isAmt)
{
return;
@ -341,7 +343,7 @@ public class CarPrepareState : IState
IMapper mapperAmt = configAmt.CreateMapper();
SwapAmtOrder swapAmtOrder = mapperAmt.Map<SwapAmtOrder>(orderBatteryInfo.swapAmtOrder);
swapAmtOrder.Status = (int)InfoEnum.AmtOrderStatus.Swapping;
AmtOrderRepository.Update(swapAmtOrder);
_amtOrderRepository.Update(swapAmtOrder);
}
/// 1.仓位状态:启动
@ -377,7 +379,7 @@ public class CarPrepareState : IState
SwapOrderBatteryInfo orderBatteryInfo = new SwapOrderBatteryInfo();
orderBatteryInfo.swapAmtOrder = swapAmtOrder;
orderBatteryInfo.isAmt = true;
BinInfo UpBin = BinInfoRepository.QueryByClause(i => i.No.Equals(swapAmtOrder.AmtBinNoList));
BinInfo UpBin = _binInfoRepository.QueryByClause(i => i.No.Equals(swapAmtOrder.AmtBinNoList));
bool CanSwap = UpBin.Exists == 1 && UpBin.Status == 1 && UpBin.ChargeStatus == 2
&& UpBin.AmtLock == (int)InfoEnum.AmtBatLockStatus.Lock && new TimeSpan(DateTime.Now.Ticks -
UpBin.LastChargeFinishTime.ToDateTime()
@ -402,53 +404,23 @@ public class CarPrepareState : IState
/// <param name="orderBatteryInfo"></param>
private void UpBin(SwapOrderBatteryInfo orderBatteryInfo)
{
List<BinInfo> list =
BinInfoRepository.QueryListByClause(i =>
i.Exists == 1 && i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock);
if (list.Count <= 0)
{
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.NoBattery;
return;
}
list = list.Where(i => i.ChargeStatus == 2).ToList();
if (list.Count <= 0)
{
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.LessOfFinishCharging;
return;
}
SelectPackDto selectPack =
_binInfoRepository.SelectPack(StaticStationInfo.SwapSoc, StaticStationInfo.SwapFinishChargeTime);
list = list.Where(i => i.Soc > int.Parse(StaticStationInfo.SwapSoc)).ToList();
if (list.Count <= 0)
{
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.LessOfSoc;
return;
}
list = list.Where(i => new TimeSpan(DateTime.Now.Ticks -
i.LastChargeFinishTime.ToDateTime().Ticks)
.TotalMinutes > int.Parse(StaticStationInfo.SwapFinishChargeTime)).ToList();
if (list.Count <= 0)
{
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.LessOf3Minute;
return;
}
orderBatteryInfo.UpBinInfo = list[0];
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.Success;
orderBatteryInfo.UpBinInfo = selectPack.BinInfo;
orderBatteryInfo.CanSwap = selectPack.Info;
}
/// <summary>
/// 放电池判断
/// 放电池判断:取出来的电池仓位能不能放
/// </summary>
/// <param name="orderBatteryInfo"></param>
private void InBin(SwapOrderBatteryInfo orderBatteryInfo)
{
List<BinInfo> list =
BinInfoRepository.QueryListByClause(i =>
i.Exists == 1 && i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock
&& i.Exists == 0);
_binInfoRepository.QueryListByClause(i =>
i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock
&& i.Exists == 0);
if (list.Count <= 0)
{
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.LessOfEmptyBin;

@ -1,20 +1,22 @@
using log4net;
using Autofac;
using Entity.Attr;
using Entity.Constant;
using HybirdFrameworkCore.Autofac;
using log4net;
using Repository.Station;
using Service.Execute.Api;
using Service.Execute.Enum;
using Service.Execute.Model;
using Service.Execute.StaticTools;
using Service.Execute.SwapException;
using Service.Station;
using Swapping.Business.Tech;
namespace Service.Execute.Step;
public class DoSwappingState : IState
{
private readonly ILog _log = LogManager.GetLogger(typeof(DoSwappingState));
private SwapOrderRepository SwapOrderRepository { get; set; }
public SwapOrderStepService SwapOrderStepService { get; set; }
private readonly SwapOrderRepository _swapOrderRepository = AppInfo.Container.Resolve<SwapOrderRepository>();
private readonly SwapOrderStepService _swapOrderStepService = AppInfo.Container.Resolve<SwapOrderStepService>();
public StateResult Handle(SwappingStateMachine machine)
{
@ -107,10 +109,10 @@ public class DoSwappingState : IState
if (startSwapping)
{
machine.SwapOrder.SwapBeginTime = DateTime.Now;
SwapOrderRepository.Update(machine.SwapOrder);
_swapOrderRepository.Update(machine.SwapOrder);
machine.SwapStatus = 0;
machine.StartSwappingFlag = true;
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.StartSwappingFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
}
@ -138,7 +140,7 @@ public class DoSwappingState : IState
if (machine.UnOldBatteryFlag)
{
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
}, () => { });
@ -156,7 +158,7 @@ public class DoSwappingState : IState
if (machine.StorageOldBatteryFlag)
{
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
}, () => { });
@ -173,7 +175,7 @@ public class DoSwappingState : IState
machine.OutNewBatteryFlag = PlcApi.ReadPlcTaskStatus() == 1004;
if (machine.OutNewBatteryFlag)
{
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
}, () => { });
@ -192,7 +194,7 @@ public class DoSwappingState : IState
if (machine.InstallNewBatteryFlag)
{
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.InstallNewBatteryFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
}, () => { });
@ -215,7 +217,7 @@ public class DoSwappingState : IState
//上报云平台换电完成
machine.SwapStatus = 1;
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
}, () => { });

@ -1,20 +1,21 @@
using System.Text;
using Autofac;
using Entity.Attr;
using Entity.Constant;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using log4net;
using Microsoft.OpenApi.Extensions;
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using Repository.Station;
using Service.Execute.Api;
using Service.Execute.Enum;
using Service.Execute.Model;
using Service.Execute.StaticTools;
using Service.Execute.SwapException;
using Service.Init;
using Service.Station;
using Swapping.Business.Common;
using Swapping.Business.Tech;
namespace Service.Execute.Step;
@ -23,9 +24,9 @@ public class StationReadyState : IState
private readonly ILog _log = LogManager.GetLogger(typeof(StationReadyState));
public SwapOrderRepository SwapOrderRepository { get; set; }
private readonly SwapOrderRepository _swapOrderRepository = AppInfo.Container.Resolve<SwapOrderRepository>();
public SwapOrderStepService SwapOrderStepService { get; set; }
private readonly SwapOrderStepService _swapOrderStepService = AppInfo.Container.Resolve<SwapOrderStepService>();
public StateResult Handle(SwappingStateMachine machine)
{
@ -203,11 +204,11 @@ public class StationReadyState : IState
//新增换电订单
machine.SwapOrder = SaveOrder(BuildOrder(machine.RfidReadModel));
//新增小步
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.Idel,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.Idel,
machine.StepSort++, machine.SwapOrder.Sn);
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.RadarInFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.RadarInFlag,
machine.StepSort++, machine.SwapOrder.Sn);
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.RfidReadFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.RfidReadFlag,
machine.StepSort++, machine.SwapOrder.Sn);
RfidApi.StopRead();
_log.Info("stop read rfid");
@ -239,7 +240,7 @@ public class StationReadyState : IState
private SwapOrder SaveOrder(SwapOrder swapOrder)
{
SwapOrderRepository.Insert(swapOrder);
_swapOrderRepository.Insert(swapOrder);
return swapOrder;
}
}

@ -1,15 +1,16 @@
using Entity.Constant;
using Autofac;
using Entity.Attr;
using Entity.Constant;
using HybirdFrameworkCore.Autofac;
using log4net;
using Repository.Station;
using Service.Cloud.Client;
using Service.Cloud.Msg.Cloud.Req;
using Service.Execute.Api;
using Service.Execute.Enum;
using Service.Execute.StaticTools;
using Service.Execute.SwapException;
using Service.Init;
using Service.Station;
using Swapping.Business.Tech;
namespace Service.Execute.Step;
@ -20,8 +21,8 @@ public class SwapCanStartState : IState
{
private readonly ILog _log = LogManager.GetLogger(typeof(SwapCanStartState));
public SwapOrderStepService SwapOrderStepService { get; set; }
private SwapOrderRepository SwapOrderRepository { get; set; }
private readonly SwapOrderStepService _swapOrderStepService = AppInfo.Container.Resolve<SwapOrderStepService>();
private readonly SwapOrderRepository _swapOrderRepository = AppInfo.Container.Resolve<SwapOrderRepository>();
public StateResult Handle(SwappingStateMachine machine)
{
@ -65,10 +66,10 @@ public class SwapCanStartState : IState
_log.Info("SwapCanStart ok");
//更新换电订单
machine.SwapOrder.CloudSn = carCanStart.on;
SwapOrderRepository.Update(machine.SwapOrder.CloudSn);
_swapOrderRepository.Update(machine.SwapOrder.CloudSn);
machine.CloudCarCanStartFlag = true;
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudCarCanStartFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudCarCanStartFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
else

@ -1,20 +1,22 @@
using log4net;
using Autofac;
using Entity.Attr;
using Entity.Constant;
using HybirdFrameworkCore.Autofac;
using log4net;
using Repository.Station;
using Service.Execute.Api;
using Service.Execute.Enum;
using Service.Execute.Model;
using Service.Execute.StaticTools;
using Service.Execute.SwapException;
using Service.Station;
using Swapping.Business.Tech;
namespace Service.Execute.Step;
public class SwapDoneState : IState
{
private SwapOrderRepository SwapOrderRepository { get; set; }
public SwapOrderStepService SwapOrderStepService { get; set; }
private SwapAmtOrderRepository SwapAmtOrderRepository { get; set; }
private readonly SwapOrderRepository _swapOrderRepository = AppInfo.Container.Resolve<SwapOrderRepository>();
private readonly SwapOrderStepService _swapOrderStepService = AppInfo.Container.Resolve<SwapOrderStepService>();
private readonly SwapAmtOrderRepository _swapAmtOrderRepository = AppInfo.Container.Resolve<SwapAmtOrderRepository>();
private readonly ILog _log = LogManager.GetLogger(typeof(SwapDoneState));
@ -30,7 +32,7 @@ public class SwapDoneState : IState
machine.SwapOrder.SwapResult = machine.SwapStatus;
machine.SwapOrder.SwapEndTime = DateTime.Now;
machine.SwapOrder.FailReason = machine.SwapFailReason;
SwapOrderRepository.Update(machine.SwapOrder);
_swapOrderRepository.Update(machine.SwapOrder);
if (machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success)
@ -92,7 +94,7 @@ public class SwapDoneState : IState
machine.VelLockFlag = true;
SwapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.VelLockFlag,
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.VelLockFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
}
@ -128,19 +130,19 @@ public class SwapDoneState : IState
machine.BusinessSwappingForCloudState =
InfoEnum.BusinessSwappingForCloudState.SwapDoneWithoutVel;
machine.SwapOrder!.VehicleLeaveTime = DateTime.Now;
SwapOrderRepository.Update(machine.SwapOrder);
_swapOrderRepository.Update(machine.SwapOrder);
if (machine.SwapOrderBatteryInfo!.swapAmtOrder != null)
{
machine.SwapOrderBatteryInfo.swapAmtOrder.Status =
machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success
? (int)InfoEnum.AmtOrderStatus.SwapFinish
: (int)InfoEnum.AmtOrderStatus.SwapFail;
SwapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder);
_swapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder);
}
machine.RadarOutFlag = true;
SwapOrderStepService.InsertSwapStepForSwapMain(
_swapOrderStepService.InsertSwapStepForSwapMain(
machine.SwapStatus == (int)InfoEnum.SwapOrderResult.Success
? InfoEnum.BusinessSwappingStep.RadarOutFlag
: InfoEnum.BusinessSwappingStep.RadarOutFailFlag,

@ -1,15 +1,16 @@
using DotNetty.Common.Utilities;
using Autofac;
using DotNetty.Common.Utilities;
using Entity.Constant;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Execute.Api;
using Service.Execute.Enum;
using Service.Execute.Model;
using Service.Execute.StaticTools;
using Service.Execute.Step;
using Service.Execute.SwapException;
using Service.Execute.Tech;
namespace Service.Execute;
@ -17,9 +18,12 @@ public class SwappingStateMachine : IDisposable
{
private static readonly ILog Log = LogManager.GetLogger(typeof(SwappingStateMachine));
private static readonly SwappingStateMachine SwappingMachine = new SwappingStateMachine();
private BinInfoRepository BinInfoRepository { get; set; }
private SwapAmtOrderRepository AmtOrderRepository { get; set; }
public bool CancelFlag { get; set; } = false;
public bool StopFlag { get; set; } = false;
@ -137,6 +141,9 @@ public class SwappingStateMachine : IDisposable
_dictionary[SwappingState.Canceled] = new CancelState();
LedTool = new LedTool();
BinInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
AmtOrderRepository = AppInfo.Container.Resolve<SwapAmtOrderRepository>();
}
public static SwappingStateMachine GetInstance()

@ -39,4 +39,8 @@
<ProjectReference Include="..\Repository\Repository.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Execute\Tech\" />
</ItemGroup>
</Project>

@ -7,7 +7,6 @@ using Repository.Station;
using SqlSugar;
using System.Linq.Expressions;
using Entity.Constant;
using Service.Execute.Enum;
namespace Service.Station;

@ -446,7 +446,7 @@ namespace Service.System
var typeList = GetConstAttributeList();
var type = typeList.FirstOrDefault(u => u.Name == typeName);
var isEnum = type.BaseType.Name == "Enum";
var isEnum = type.BaseType.Name == "Utils";
constlist = type.GetFields()?
.Where(isEnum, u => u.FieldType.Name == typeName)
.Select(u => new ConstResp

@ -28,7 +28,7 @@ builder.Host.ConfigureContainer<ContainerBuilder>(cb =>
ConnectionString = AppSettingsConstVars.DbSqlConnection, // 设置数据库连接字符串
DbType = AppSettingsConstVars.DbDbType == IocDbType.MySql.ToString() ? DbType.MySql : DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute // 如果使用实体类的属性进行主键标识,请设置为 InitKeyType.Attribute
InitKeyType = InitKeyType.Attribute // 如果使用实体类的属性进行主键标识,请设置为 InitKeyType.Attr
});
return db;
}).As<ISqlSugarClient>().SingleInstance();

@ -37,7 +37,7 @@ internal static class Program
ConnectionString = AppSettingsConstVars.DbSqlConnection, // 设置数据库连接字符串
DbType = AppSettingsConstVars.DbDbType == IocDbType.MySql.ToString() ? DbType.MySql : DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute // 如果使用实体类的属性进行主键标识,请设置为 InitKeyType.Attribute
InitKeyType = InitKeyType.Attribute // 如果使用实体类的属性进行主键标识,请设置为 InitKeyType.Attr
});
return db;
}).As<ISqlSugarClient>().InstancePerLifetimeScope();

@ -25,7 +25,7 @@ public partial class App : Application
? DbType.MySql
: DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute // 如果使用实体类的属性进行主键标识,请设置为 InitKeyType.Attribute
InitKeyType = InitKeyType.Attribute // 如果使用实体类的属性进行主键标识,请设置为 InitKeyType.Attr
});
return db;
}).As<ISqlSugarClient>().InstancePerLifetimeScope();

Loading…
Cancel
Save